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