File indexing completed on 2024-04-21 13:19:20

0001 // clang-format off
0002 /*
0003  * KDiff3 - Text Diff And Merge Tool
0004  *
0005  * SPDX-FileCopyrightText: 2002-2011 Joachim Eibl, joachim.eibl at gmx.de
0006  * SPDX-FileCopyrightText: 2018-2020 Michael Reeves reeves.87@gmail.com
0007  * SPDX-License-Identifier: GPL-2.0-or-later
0008  */
0009 // clang-format on
0010 
0011 #ifndef OPTIONDIALOG_H
0012 #define OPTIONDIALOG_H
0013 
0014 #include "options.h"
0015 #include "ui_FontChooser.h"
0016 
0017 #include <QFont>
0018 #include <QGroupBox>
0019 #include <QSharedPointer>
0020 #include <QStringList>
0021 
0022 #include <KLocalizedString>
0023 #include <KPageDialog>
0024 #include <KSharedConfig>
0025 
0026 class OptionCheckBox;
0027 class OptionEncodingComboBox;
0028 class OptionLineEdit;
0029 
0030 class OptionDialog: public KPageDialog
0031 {
0032     Q_OBJECT
0033 
0034   public:
0035     explicit OptionDialog(bool bShowDirMergeSettings, QWidget* parent = nullptr);
0036     ~OptionDialog() override;
0037     const QString parseOptions(const QStringList& optionList);
0038     QString calcOptionHelp();
0039 
0040     void saveOptions(KSharedConfigPtr config);
0041     void readOptions(KSharedConfigPtr config);
0042 
0043     void setState(); // Must be called before calling exec();
0044   protected Q_SLOTS:
0045     virtual void slotDefault();
0046     virtual void slotOk();
0047     virtual void slotApply();
0048     //virtual void buttonClicked( QAbstractButton* );
0049     virtual void helpRequested();
0050 
0051     void slotEncodingChanged();
0052     void slotHistoryMergeRegExpTester();
0053   Q_SIGNALS:
0054     void applyDone();
0055 
0056   private:
0057     void setupFontPage();
0058     void setupColorPage();
0059     void setupEditPage();
0060     void setupDiffPage();
0061     void setupMergePage();
0062     void setupDirectoryMergePage();
0063     void setupRegionalPage();
0064     void setupIntegrationPage();
0065     void resetToDefaults();
0066 
0067     OptionCheckBox* m_pSameEncoding;
0068     OptionEncodingComboBox* m_pEncodingAComboBox;
0069     OptionCheckBox* mAutoDetectA;
0070     OptionEncodingComboBox* m_pEncodingBComboBox;
0071     OptionCheckBox* mAutoDetectB;
0072     OptionEncodingComboBox* m_pEncodingCComboBox;
0073     OptionCheckBox* mAutoDetectC;
0074     OptionEncodingComboBox* m_pEncodingOutComboBox;
0075     OptionCheckBox* m_pAutoSelectOutEncoding;
0076     OptionEncodingComboBox* m_pEncodingPPComboBox;
0077     OptionCheckBox* m_pHistoryAutoMerge;
0078     OptionLineEdit* m_pAutoMergeRegExpLineEdit;
0079     OptionLineEdit* m_pHistoryStartRegExpLineEdit;
0080     OptionLineEdit* m_pHistoryEntryStartRegExpLineEdit;
0081     OptionCheckBox* m_pHistoryMergeSorting;
0082     OptionLineEdit* m_pHistorySortKeyOrderLineEdit;
0083 
0084     const QString s_historyEntryStartRegExpToolTip = i18n("A version control history entry consists of several lines.\n"
0085                                                           "Specify the regular expression to detect the first line (without the leading comment).\n"
0086                                                           "Use parentheses to group the keys you want to use for sorting.\n"
0087                                                           "If left empty, then KDiff3 assumes that empty lines separate history entries.\n"
0088                                                           "See the documentation for details.");
0089     const QString s_historyEntryStartSortKeyOrderToolTip = i18n("Each pair of parentheses used in the regular expression for the history start entry\n"
0090                                                                 "groups a key that can be used for sorting.\n"
0091                                                                 "Specify the list of keys (that are numbered in order of occurrence\n"
0092                                                                 "starting with 1) using ',' as separator (e.g. \"4,5,6,1,2,3,7\").\n"
0093                                                                 "If left empty, then no sorting will be done.\n"
0094                                                                 "See the documentation for details.");
0095     const QString s_autoMergeRegExpToolTip = i18n("Regular expression for lines where KDiff3 should automatically choose one source.\n"
0096                                                   "When a line with a conflict matches the regular expression then\n"
0097                                                   "- if available - C, otherwise B will be chosen.");
0098     const QString s_historyStartRegExpToolTip = i18n("Regular expression for the start of the version control history entry.\n"
0099                                                      "Usually this line contains the \"$Log$\" keyword.\n"
0100                                                      "Default value: \".*\\$Log.*\\$.*\"");
0101 };
0102 
0103 class FontChooser: public QGroupBox
0104 {
0105     Q_OBJECT
0106     QFont m_font;
0107     Ui::FontGroupBox fontChooserUi;
0108 
0109   public:
0110     explicit FontChooser(QWidget* pParent);
0111     QFont font();
0112     void setFont(const QFont&, bool);
0113 
0114   private Q_SLOTS:
0115     void slotSelectFont();
0116 };
0117 
0118 #endif