File indexing completed on 2024-04-28 05:49:28

0001 /*
0002     SPDX-FileCopyrightText: 2001 Christoph Cullmann <cullmann@kde.org>
0003     SPDX-FileCopyrightText: 2002 Joseph Wenninger <jowenn@kde.org>
0004     SPDX-FileCopyrightText: 2007 Mirko Stocker <me@misto.ch>
0005 
0006     SPDX-License-Identifier: LGPL-2.0-or-later
0007 */
0008 
0009 #pragma once
0010 
0011 #include <QPointer>
0012 
0013 #include <KTextEditor/ConfigPage>
0014 #include <KTextEditor/Document>
0015 #include <KTextEditor/Editor>
0016 #include <KTextEditor/Plugin>
0017 
0018 #include <KPageDialog>
0019 
0020 #ifdef WITH_KUSERFEEDBACK
0021 #include <KUserFeedback/FeedbackConfigWidget>
0022 #endif
0023 
0024 #include "ui_sessionconfigwidget.h"
0025 
0026 class QCheckBox;
0027 class QComboBox;
0028 class QSpinBox;
0029 class KateMainWindow;
0030 class KPluralHandlingSpinBox;
0031 
0032 struct PluginPageListItem {
0033     KTextEditor::Plugin *plugin;
0034     int idInPlugin;
0035     KTextEditor::ConfigPage *pluginPage;
0036     KPageWidgetItem *pageWidgetItem;
0037 };
0038 
0039 class KateConfigDialog : public KPageDialog
0040 {
0041     Q_OBJECT
0042 
0043 public:
0044     // create new dialog
0045     explicit KateConfigDialog(KateMainWindow *parent);
0046 
0047     /**
0048      * Reads the value from the given open config. If not present in config yet then
0049      * the default value 10 is used.
0050      */
0051     static int recentFilesMaxCount();
0052 
0053     /**
0054      * Overwrite size hint for better default window sizes
0055      * @return size hint
0056      */
0057     QSize sizeHint() const override;
0058 
0059 public:
0060     void addPluginPage(KTextEditor::Plugin *plugin);
0061     void removePluginPage(KTextEditor::Plugin *plugin);
0062     void showAppPluginPage(KTextEditor::Plugin *plugin, int id);
0063 
0064 protected Q_SLOTS:
0065     void slotApply();
0066     void slotChanged();
0067     static void slotHelp();
0068 
0069 protected:
0070     void closeEvent(QCloseEvent *event) override;
0071 
0072 private:
0073     void addBehaviorPage();
0074     void addSessionPage();
0075     void addPluginsPage();
0076     void addFeedbackPage();
0077     void addPluginPages();
0078     void addEditorPages();
0079 
0080     // add page variant that ensures the page is wrapped into a QScrollArea
0081     KPageWidgetItem *addScrollablePage(QWidget *page, const QString &itemName);
0082 
0083 private:
0084     KateMainWindow *m_mainWindow;
0085 
0086     bool m_dataChanged = false;
0087 
0088     QComboBox *m_messageTypes = nullptr;
0089     QSpinBox *m_outputHistoryLimit = nullptr;
0090     QComboBox *m_mouseBackActions = nullptr;
0091     QComboBox *m_mouseForwardActions = nullptr;
0092     QCheckBox *m_sdiMode = nullptr;
0093     QCheckBox *m_modNotifications = nullptr;
0094     QCheckBox *m_syncSectionSizeWithSidebarTabs = nullptr;
0095     QCheckBox *m_showTextForLeftRightSidebars = nullptr;
0096     QSpinBox *m_leftRightSidebarsIconSize = nullptr;
0097     QComboBox *m_cmbQuickOpenListMode;
0098     QSpinBox *m_tabLimit;
0099     QCheckBox *m_autoHideTabs;
0100     QCheckBox *m_showTabCloseButton;
0101     QCheckBox *m_expandTabs;
0102     QCheckBox *m_tabDoubleClickNewDocument;
0103     QCheckBox *m_tabMiddleClickCloseDocument;
0104     QCheckBox *m_tabsScrollable = nullptr;
0105     QCheckBox *m_tabsElided = nullptr;
0106     QComboBox *m_diffStyle = nullptr;
0107     QCheckBox *m_urlBarShowSymbols = nullptr;
0108     QCheckBox *m_openNewTabInFrontOfCurrent = nullptr;
0109     QSpinBox *m_diagnosticsLimit = nullptr;
0110 
0111     Ui::SessionConfigWidget sessionConfigUi;
0112 
0113     QHash<KPageWidgetItem *, PluginPageListItem> m_pluginPages;
0114     std::vector<KTextEditor::ConfigPage *> m_editorPages;
0115 
0116     QPointer<class QListView> m_sideBar;
0117     QSet<KPageWidgetItem *> m_allPages;
0118 
0119 #ifdef WITH_KUSERFEEDBACK
0120     KUserFeedback::FeedbackConfigWidget *m_userFeedbackWidget = nullptr;
0121 #endif
0122 
0123     class KateConfigPluginPage *m_configPluginPage = nullptr;
0124 };