Changeset View
Changeset View
Standalone View
Standalone View
kate/kateconfigdialog.cpp
Show All 30 Lines | |||||
31 | #include "katesessionmanager.h" | 31 | #include "katesessionmanager.h" | ||
32 | #include "katedebug.h" | 32 | #include "katedebug.h" | ||
33 | #include "katequickopenmodel.h" | 33 | #include "katequickopenmodel.h" | ||
34 | 34 | | |||
35 | #include <KTextEditor/ConfigPage> | 35 | #include <KTextEditor/ConfigPage> | ||
36 | 36 | | |||
37 | #include <KStandardAction> | 37 | #include <KStandardAction> | ||
38 | #include <KLocalizedString> | 38 | #include <KLocalizedString> | ||
39 | #include <KMessageBox> | ||||
39 | #include <KConfigGroup> | 40 | #include <KConfigGroup> | ||
40 | #include <KSharedConfig> | 41 | #include <KSharedConfig> | ||
41 | #include <KPluralHandlingSpinBox> | 42 | #include <KPluralHandlingSpinBox> | ||
42 | 43 | | |||
43 | #include <QDesktopServices> | 44 | #include <QDesktopServices> | ||
44 | #include <QCheckBox> | 45 | #include <QCheckBox> | ||
45 | #include <QDialogButtonBox> | 46 | #include <QDialogButtonBox> | ||
46 | #include <QFrame> | 47 | #include <QFrame> | ||
47 | #include <QGroupBox> | 48 | #include <QGroupBox> | ||
48 | #include <QLabel> | 49 | #include <QLabel> | ||
49 | #include <QVBoxLayout> | 50 | #include <QVBoxLayout> | ||
50 | #include <QComboBox> | 51 | #include <QComboBox> | ||
51 | 52 | | |||
52 | KateConfigDialog::KateConfigDialog(KateMainWindow *parent, KTextEditor::View *view) | 53 | KateConfigDialog::KateConfigDialog(KateMainWindow *parent, KTextEditor::View *view) | ||
53 | : KPageDialog(parent) | 54 | : KPageDialog(parent) | ||
54 | , m_mainWindow(parent) | 55 | , m_mainWindow(parent) | ||
55 | , m_view(view) | 56 | , m_view(view) | ||
57 | , m_dataChanged(false) | ||||
56 | { | 58 | { | ||
57 | setFaceType(Tree); | 59 | setFaceType(Tree); | ||
58 | setWindowTitle(i18n("Configure")); | 60 | setWindowTitle(i18n("Configure")); | ||
59 | setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Apply | QDialogButtonBox::Cancel | QDialogButtonBox::Help); | 61 | setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Apply | QDialogButtonBox::Cancel | QDialogButtonBox::Help); | ||
60 | setObjectName(QStringLiteral("configdialog")); | 62 | setObjectName(QStringLiteral("configdialog")); | ||
61 | 63 | | |||
62 | KSharedConfig::Ptr config = KSharedConfig::openConfig(); | 64 | KSharedConfig::Ptr config = KSharedConfig::openConfig(); | ||
63 | KConfigGroup cgGeneral = KConfigGroup(config, "General"); | 65 | KConfigGroup cgGeneral = KConfigGroup(config, "General"); | ||
▲ Show 20 Lines • Show All 178 Lines • ▼ Show 20 Line(s) | 239 | // editor widgets from kwrite/kwdialog | |||
242 | m_editorPage->setEnabled(false); | 244 | m_editorPage->setEnabled(false); | ||
243 | 245 | | |||
244 | addEditorPages(); | 246 | addEditorPages(); | ||
245 | 247 | | |||
246 | connect(this, &KateConfigDialog::accepted, this, &KateConfigDialog::slotApply); | 248 | connect(this, &KateConfigDialog::accepted, this, &KateConfigDialog::slotApply); | ||
247 | connect(buttonBox()->button(QDialogButtonBox::Apply), &QPushButton::clicked, this, &KateConfigDialog::slotApply); | 249 | connect(buttonBox()->button(QDialogButtonBox::Apply), &QPushButton::clicked, this, &KateConfigDialog::slotApply); | ||
248 | connect(buttonBox()->button(QDialogButtonBox::Help), &QPushButton::clicked, this, &KateConfigDialog::slotHelp); | 250 | connect(buttonBox()->button(QDialogButtonBox::Help), &QPushButton::clicked, this, &KateConfigDialog::slotHelp); | ||
249 | connect(this, &KateConfigDialog::currentPageChanged, this, &KateConfigDialog::slotCurrentPageChanged); | 251 | connect(this, &KateConfigDialog::currentPageChanged, this, &KateConfigDialog::slotCurrentPageChanged); | ||
250 | m_dataChanged = false; | | |||
251 | 252 | | |||
252 | resize(minimumSizeHint()); | 253 | resize(minimumSizeHint()); | ||
253 | } | 254 | } | ||
254 | 255 | | |||
255 | KateConfigDialog::~KateConfigDialog() | 256 | KateConfigDialog::~KateConfigDialog() | ||
256 | { | 257 | { | ||
257 | delete sessionConfigUi; | 258 | delete sessionConfigUi; | ||
258 | } | 259 | } | ||
▲ Show 20 Lines • Show All 171 Lines • ▼ Show 20 Line(s) | |||||
430 | } | 431 | } | ||
431 | 432 | | |||
432 | int KateConfigDialog::recentFilesMaxCount() | 433 | int KateConfigDialog::recentFilesMaxCount() | ||
433 | { | 434 | { | ||
434 | int maxItems = KConfigGroup(KSharedConfig::openConfig(), "General").readEntry("Recent File List Entry Count", 10); | 435 | int maxItems = KConfigGroup(KSharedConfig::openConfig(), "General").readEntry("Recent File List Entry Count", 10); | ||
435 | return maxItems; | 436 | return maxItems; | ||
436 | } | 437 | } | ||
437 | 438 | | |||
439 | void KateConfigDialog::closeEvent(QCloseEvent *event) | ||||
440 | { | ||||
441 | if (!m_dataChanged) { | ||||
442 | event->accept(); | ||||
443 | return; | ||||
444 | } | ||||
445 | | ||||
446 | const auto response = KMessageBox::warningYesNoCancel(this, | ||||
447 | i18n("You have have unsaved changes. Do you want to apply the changes or discard them?"), | ||||
dhaumann: Typo: have have | |||||
448 | i18n("Warning"), | ||||
449 | KStandardGuiItem::save(), | ||||
450 | KStandardGuiItem::discard(), | ||||
451 | KStandardGuiItem::cancel()); | ||||
452 | switch (response) { | ||||
453 | case KMessageBox::Yes: | ||||
454 | slotApply(); | ||||
455 | Q_FALLTHROUGH(); | ||||
I'd prefer to repeat event->accept + break here, instead of using fallthrough. dhaumann: I'd prefer to repeat event->accept + break here, instead of using fallthrough. | |||||
456 | case KMessageBox::No: | ||||
457 | event->accept(); | ||||
458 | break; | ||||
459 | case KMessageBox::Cancel: | ||||
460 | event->ignore(); | ||||
461 | break; | ||||
462 | default: | ||||
463 | break; | ||||
464 | } | ||||
465 | } |
Typo: have have