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_unsavedChange(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 317 Lines • ▼ Show 20 Line(s) | 325 | { | |||
381 | // apply ktexteditor pages | 383 | // apply ktexteditor pages | ||
382 | foreach(KTextEditor::ConfigPage * page, m_editorPages) | 384 | foreach(KTextEditor::ConfigPage * page, m_editorPages) | ||
383 | page->apply(); | 385 | page->apply(); | ||
384 | 386 | | |||
385 | config->sync(); | 387 | config->sync(); | ||
386 | 388 | | |||
387 | m_dataChanged = false; | 389 | m_dataChanged = false; | ||
388 | buttonBox()->button(QDialogButtonBox::Apply)->setEnabled(false); | 390 | buttonBox()->button(QDialogButtonBox::Apply)->setEnabled(false); | ||
391 | m_unsavedChange = true; | ||||
389 | } | 392 | } | ||
390 | 393 | | |||
391 | void KateConfigDialog::slotChanged() | 394 | void KateConfigDialog::slotChanged() | ||
392 | { | 395 | { | ||
393 | m_dataChanged = true; | 396 | m_dataChanged = true; | ||
397 | m_unsavedChange = true; | ||||
394 | buttonBox()->button(QDialogButtonBox::Apply)->setEnabled(true); | 398 | buttonBox()->button(QDialogButtonBox::Apply)->setEnabled(true); | ||
395 | } | 399 | } | ||
396 | 400 | | |||
397 | void KateConfigDialog::showAppPluginPage(KTextEditor::Plugin *p, uint id) | 401 | void KateConfigDialog::showAppPluginPage(KTextEditor::Plugin *p, uint id) | ||
398 | { | 402 | { | ||
399 | foreach(PluginPageListItem * plugin, m_pluginPages) { | 403 | foreach(PluginPageListItem * plugin, m_pluginPages) { | ||
400 | if ((plugin->plugin == p) && (id == plugin->idInPlugin)) { | 404 | if ((plugin->plugin == p) && (id == plugin->idInPlugin)) { | ||
401 | setCurrentPage(plugin->pageWidgetItem); | 405 | setCurrentPage(plugin->pageWidgetItem); | ||
402 | break; | 406 | break; | ||
403 | } | 407 | } | ||
404 | } | 408 | } | ||
405 | } | 409 | } | ||
406 | 410 | | |||
407 | void KateConfigDialog::slotHelp() | 411 | void KateConfigDialog::slotHelp() | ||
408 | { | 412 | { | ||
409 | QDesktopServices::openUrl(QUrl(QStringLiteral("help:/"))); | 413 | QDesktopServices::openUrl(QUrl(QStringLiteral("help:/"))); | ||
410 | } | 414 | } | ||
411 | 415 | | |||
412 | int KateConfigDialog::recentFilesMaxCount() | 416 | int KateConfigDialog::recentFilesMaxCount() | ||
413 | { | 417 | { | ||
414 | int maxItems = KConfigGroup(KSharedConfig::openConfig(), "General").readEntry("Recent File List Entry Count", 10); | 418 | int maxItems = KConfigGroup(KSharedConfig::openConfig(), "General").readEntry("Recent File List Entry Count", 10); | ||
415 | return maxItems; | 419 | return maxItems; | ||
416 | } | 420 | } | ||
417 | 421 | | |||
422 | void KateConfigDialog::closeEvent(QCloseEvent* event) | ||||
423 | { | ||||
424 | if (!m_unsavedChange) { | ||||
425 | event->accept(); | ||||
426 | return; | ||||
427 | } | ||||
428 | | ||||
429 | const auto response = KMessageBox::warningYesNoCancel(this, | ||||
430 | i18n("You have have unsaved changes. Do you want to apply the changes or discard them?"), | ||||
dhaumann: Typo: have have | |||||
431 | i18n("Warning"), | ||||
432 | KStandardGuiItem::save(), | ||||
433 | KStandardGuiItem::discard(), | ||||
434 | KStandardGuiItem::cancel()); | ||||
435 | switch (response) { | ||||
436 | case KMessageBox::Yes: | ||||
437 | slotApply(); | ||||
438 | 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. | |||||
439 | case KMessageBox::No: | ||||
440 | event->accept(); | ||||
441 | break; | ||||
442 | case KMessageBox::Cancel: | ||||
443 | event->ignore(); | ||||
444 | break; | ||||
445 | default: | ||||
446 | break; | ||||
447 | } | ||||
448 | } |
Typo: have have