Loading...
Searching...
No Matches
SettingsView.hpp
1#pragma once
2#include <score/plugins/settingsdelegate/SettingsDelegatePresenter.hpp>
3#include <score/plugins/settingsdelegate/SettingsDelegateView.hpp>
4
5#include <QDialog>
6#include <QDialogButtonBox>
7#include <QListWidget>
8#include <QSize>
9#include <QStackedWidget>
10#include <QVBoxLayout>
11#include <QWidget>
12
13#include <set>
14
15class QWidget;
16
17namespace score
18{
19template <typename Model>
20class SettingsView final : public QDialog
21{
22public:
23 SettingsView(QWidget* parent)
24 : QDialog{parent}
25 {
26 {
27 auto centerWidg = new QWidget{this};
28 {
29 m_settingsList->setMinimumWidth(150);
30 m_settingsList->setMaximumWidth(150);
31 m_hboxLayout->addWidget(m_settingsList);
32 m_hboxLayout->addWidget(m_stackedWidget);
33 centerWidg->setLayout(m_hboxLayout);
34 }
35
36 m_vertLayout->addWidget(centerWidg);
37 m_vertLayout->addWidget(m_buttons);
38 this->setLayout(m_vertLayout);
39 }
40
41 connect(
42 m_settingsList, &QListWidget::currentRowChanged, m_stackedWidget,
43 &QStackedWidget::setCurrentIndex);
44
45 connect(m_buttons, &QDialogButtonBox::accepted, this, &SettingsView::accept);
46 connect(m_buttons, &QDialogButtonBox::rejected, this, &SettingsView::reject);
47 }
48 void addSettingsView(SettingsDelegateView<Model>* view)
49 {
50 view->setParent(this);
51 QListWidgetItem* it = new QListWidgetItem{
52 view->getPresenter()->settingsIcon(), view->getPresenter()->settingsName(),
53 m_settingsList};
54 it->setSizeHint(QSize{0, 30});
55 m_settingsList->addItem(it);
56 m_stackedWidget->addWidget(view->getWidget());
57
58 m_pluginViews.insert(view);
59 }
60
61private:
62 std::set<SettingsDelegateView<Model>*> m_pluginViews;
63
64 QVBoxLayout* m_vertLayout{new QVBoxLayout{}};
65 QHBoxLayout* m_hboxLayout{new QHBoxLayout{}};
66 QListWidget* m_settingsList{new QListWidget{this}};
67 QStackedWidget* m_stackedWidget{new QStackedWidget{this}};
68
69 QDialogButtonBox* m_buttons{
70 new QDialogButtonBox{QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this}};
71};
72}
Definition SettingsDelegateView.hpp:18
Definition SettingsView.hpp:21
Base toolkit upon which the software is built.
Definition Application.cpp:90