Changeset View
Changeset View
Standalone View
Standalone View
shell/environmentconfigurebutton.cpp
Show All 23 Lines | |||||
24 | #include "settings/environmentpreferences.h" | 24 | #include "settings/environmentpreferences.h" | ||
25 | 25 | | |||
26 | #include <QApplication> | 26 | #include <QApplication> | ||
27 | #include <QDialog> | 27 | #include <QDialog> | ||
28 | #include <QDialogButtonBox> | 28 | #include <QDialogButtonBox> | ||
29 | #include <QIcon> | 29 | #include <QIcon> | ||
30 | #include <QVBoxLayout> | 30 | #include <QVBoxLayout> | ||
31 | 31 | | |||
32 | #include <util/scopeddialog.h> | ||||
33 | | ||||
32 | #include <KLocalizedString> | 34 | #include <KLocalizedString> | ||
33 | 35 | | |||
34 | namespace KDevelop { | 36 | namespace KDevelop { | ||
35 | 37 | | |||
36 | class EnvironmentConfigureButtonPrivate | 38 | class EnvironmentConfigureButtonPrivate | ||
37 | { | 39 | { | ||
38 | public: | 40 | public: | ||
39 | explicit EnvironmentConfigureButtonPrivate(EnvironmentConfigureButton* _q) | 41 | explicit EnvironmentConfigureButtonPrivate(EnvironmentConfigureButton* _q) | ||
40 | : q(_q), selectionWidget(nullptr) | 42 | : q(_q), selectionWidget(nullptr) | ||
41 | { | 43 | { | ||
42 | } | 44 | } | ||
43 | 45 | | |||
44 | void showDialog() | 46 | void showDialog() | ||
45 | { | 47 | { | ||
46 | QDialog dlg(qApp->activeWindow()); | 48 | ScopedDialog<QDialog> dlg(qApp->activeWindow()); | ||
47 | QString selected; | 49 | QString selected; | ||
48 | if (selectionWidget) { | 50 | if (selectionWidget) { | ||
49 | selected = selectionWidget->effectiveProfileName(); | 51 | selected = selectionWidget->effectiveProfileName(); | ||
50 | } | 52 | } | ||
51 | 53 | | |||
52 | EnvironmentPreferences prefs(selected, q); | 54 | auto prefs = new EnvironmentPreferences(selected, q); | ||
53 | 55 | | |||
54 | // TODO: This should be implicit when constructing EnvironmentPreferences | 56 | // TODO: This should be implicit when constructing EnvironmentPreferences | ||
55 | prefs.initConfigManager(); | 57 | prefs->initConfigManager(); | ||
56 | prefs.reset(); | 58 | prefs->reset(); | ||
57 | 59 | | |||
58 | auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | 60 | auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | ||
59 | | QDialogButtonBox::Cancel); | 61 | | QDialogButtonBox::Cancel); | ||
60 | QObject::connect(buttonBox, &QDialogButtonBox::accepted, &dlg, &QDialog::accept); | 62 | QObject::connect(buttonBox, &QDialogButtonBox::accepted, dlg, &QDialog::accept); | ||
61 | QObject::connect(buttonBox, &QDialogButtonBox::rejected, &dlg, &QDialog::reject); | 63 | QObject::connect(buttonBox, &QDialogButtonBox::rejected, dlg, &QDialog::reject); | ||
62 | auto layout = new QVBoxLayout; | 64 | auto layout = new QVBoxLayout; | ||
63 | layout->addWidget(&prefs); | 65 | layout->addWidget(prefs); | ||
64 | layout->addWidget(buttonBox); | 66 | layout->addWidget(buttonBox); | ||
65 | dlg.setLayout(layout); | 67 | dlg->setLayout(layout); | ||
66 | dlg.setWindowTitle(prefs.fullName()); | 68 | dlg->setWindowTitle(prefs->fullName()); | ||
67 | dlg.setWindowIcon(prefs.icon()); | 69 | dlg->setWindowIcon(prefs->icon()); | ||
68 | dlg.resize(800, 600); | 70 | dlg->resize(800, 600); | ||
69 | if (dlg.exec() == QDialog::Accepted) { | 71 | if (dlg->exec() == QDialog::Accepted) { | ||
70 | prefs.apply(); | 72 | prefs->apply(); | ||
71 | emit q->environmentConfigured(); | 73 | emit q->environmentConfigured(); | ||
72 | } | 74 | } | ||
73 | } | 75 | } | ||
74 | 76 | | |||
75 | EnvironmentConfigureButton *q; | 77 | EnvironmentConfigureButton *q; | ||
76 | EnvironmentSelectionWidget *selectionWidget; | 78 | EnvironmentSelectionWidget *selectionWidget; | ||
77 | }; | 79 | }; | ||
78 | 80 | | |||
Show All 29 Lines |