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 161 Lines • ▼ Show 20 Line(s) | 222 | // editor widgets from kwrite/kwdialog | |||
225 | m_editorPage->setEnabled(false); | 227 | m_editorPage->setEnabled(false); | ||
226 | 228 | | |||
227 | addEditorPages(); | 229 | addEditorPages(); | ||
228 | 230 | | |||
229 | connect(this, &KateConfigDialog::accepted, this, &KateConfigDialog::slotApply); | 231 | connect(this, &KateConfigDialog::accepted, this, &KateConfigDialog::slotApply); | ||
230 | connect(buttonBox()->button(QDialogButtonBox::Apply), &QPushButton::clicked, this, &KateConfigDialog::slotApply); | 232 | connect(buttonBox()->button(QDialogButtonBox::Apply), &QPushButton::clicked, this, &KateConfigDialog::slotApply); | ||
231 | connect(buttonBox()->button(QDialogButtonBox::Help), &QPushButton::clicked, this, &KateConfigDialog::slotHelp); | 233 | connect(buttonBox()->button(QDialogButtonBox::Help), &QPushButton::clicked, this, &KateConfigDialog::slotHelp); | ||
232 | connect(this, &KateConfigDialog::currentPageChanged, this, &KateConfigDialog::slotCurrentPageChanged); | 234 | connect(this, &KateConfigDialog::currentPageChanged, this, &KateConfigDialog::slotCurrentPageChanged); | ||
233 | m_dataChanged = false; | | |||
234 | 235 | | |||
235 | resize(minimumSizeHint()); | 236 | resize(minimumSizeHint()); | ||
236 | } | 237 | } | ||
237 | 238 | | |||
238 | KateConfigDialog::~KateConfigDialog() | 239 | KateConfigDialog::~KateConfigDialog() | ||
239 | { | 240 | { | ||
240 | delete sessionConfigUi; | 241 | delete sessionConfigUi; | ||
241 | } | 242 | } | ||
▲ Show 20 Lines • Show All 168 Lines • ▼ Show 20 Line(s) | |||||
410 | } | 411 | } | ||
411 | 412 | | |||
412 | int KateConfigDialog::recentFilesMaxCount() | 413 | int KateConfigDialog::recentFilesMaxCount() | ||
413 | { | 414 | { | ||
414 | int maxItems = KConfigGroup(KSharedConfig::openConfig(), "General").readEntry("Recent File List Entry Count", 10); | 415 | int maxItems = KConfigGroup(KSharedConfig::openConfig(), "General").readEntry("Recent File List Entry Count", 10); | ||
415 | return maxItems; | 416 | return maxItems; | ||
416 | } | 417 | } | ||
417 | 418 | | |||
419 | void KateConfigDialog::closeEvent(QCloseEvent *event) | ||||
420 | { | ||||
421 | if (!m_dataChanged) { | ||||
422 | event->accept(); | ||||
423 | return; | ||||
424 | } | ||||
425 | | ||||
426 | const auto response = KMessageBox::warningYesNoCancel(this, | ||||
427 | i18n("You have have unsaved changes. Do you want to apply the changes or discard them?"), | ||||
dhaumann: Typo: have have | |||||
428 | i18n("Warning"), | ||||
429 | KStandardGuiItem::save(), | ||||
430 | KStandardGuiItem::discard(), | ||||
431 | KStandardGuiItem::cancel()); | ||||
432 | switch (response) { | ||||
433 | case KMessageBox::Yes: | ||||
434 | slotApply(); | ||||
435 | 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. | |||||
436 | case KMessageBox::No: | ||||
437 | event->accept(); | ||||
438 | break; | ||||
439 | case KMessageBox::Cancel: | ||||
440 | event->ignore(); | ||||
441 | break; | ||||
442 | default: | ||||
443 | break; | ||||
444 | } | ||||
445 | } |
Typo: have have