1 /* 2 * KDiff3 - Text Diff And Merge Tool 3 * 4 * SPDX-FileCopyrightText: 2002-2011 Joachim Eibl, joachim.eibl at gmx.de 5 * SPDX-FileCopyrightText: 2018-2020 Michael Reeves reeves.87@gmail.com 6 * SPDX-License-Identifier: GPL-2.0-or-later 7 */ 8 9 #ifndef OPTIONS_H 10 #define OPTIONS_H 11 12 #include <KSharedConfig> 13 14 #include <list> 15 16 #include <QColor> 17 #include <QFont> 18 #include <QPoint> 19 #include <QSize> 20 #include <QStringList> 21 22 class OptionItemBase; 23 24 enum e_LineEndStyle 25 { 26 eLineEndStyleUnix=0, 27 eLineEndStyleDos, 28 eLineEndStyleAutoDetect, 29 eLineEndStyleUndefined, // only one line exists 30 eLineEndStyleConflict // User must resolve manually 31 }; 32 33 class Options 34 { 35 public: 36 void init(); 37 38 void apply(); 39 40 void resetToDefaults(); 41 42 void setToCurrent(); 43 44 void saveOptions(const KSharedConfigPtr config); 45 void readOptions(const KSharedConfigPtr config); 46 47 const QString parseOptions(const QStringList& optionList); 48 QString calcOptionHelp(); 49 50 void addOptionItem(OptionItemBase* inItem); 51 getGeometry()52 const QSize& getGeometry() const { return m_geometry; } setGeometry(const QSize & size)53 void setGeometry(const QSize& size) { m_geometry = size; } 54 getPosition()55 const QPoint& getPosition() const { return m_position; } setPosition(const QPoint & pos)56 void setPosition(const QPoint& pos) { m_position = pos; } 57 isFullScreen()58 bool isFullScreen() const { return m_bFullScreen; }; 59 setFullScreen(const bool fullScreen)60 void setFullScreen(const bool fullScreen) { m_bFullScreen = fullScreen;}; 61 isMaximised()62 bool isMaximised() const { return m_bMaximised; }; 63 setMaximised(const bool maximised)64 void setMaximised(const bool maximised) { m_bMaximised = maximised;}; 65 66 isToolBarVisable()67 bool isToolBarVisable() const { return m_bShowToolBar; } setToolbarState(bool inShown)68 void setToolbarState(bool inShown) { m_bShowToolBar = inShown; } 69 isStatusBarVisable()70 bool isStatusBarVisable() const { return m_bShowStatusBar; } setStatusBarState(bool inShown)71 void setStatusBarState(bool inShown) { m_bShowStatusBar = inShown; } 72 wordWrapOn()73 bool wordWrapOn() const { return m_bWordWrap; } setWordWrap(const bool enabled)74 void setWordWrap(const bool enabled) { m_bWordWrap = enabled;} 75 ignoreComments()76 [[nodiscard]] bool ignoreComments() const { return m_bIgnoreComments; } 77 whiteSpaceIsEqual()78 [[nodiscard]] bool whiteSpaceIsEqual() const { return m_bDmWhiteSpaceEqual; } 79 private: 80 std::list<OptionItemBase*> mOptionItemList; 81 82 // Some settings that are not available in the option dialog: 83 QSize m_geometry = QSize(600, 400); 84 QPoint m_position = QPoint(0, 22); 85 bool m_bFullScreen = false; 86 bool m_bMaximised = false; 87 bool m_bShowToolBar = true; 88 bool m_bShowStatusBar = true; 89 public: 90 91 // These are the results of the option dialog. 92 QFont m_font; 93 //bool m_bItalicForDeltas; 94 QFont m_appFont; 95 96 QColor m_fgColor = Qt::black; 97 QColor m_bgColor = Qt::white; 98 QColor m_diffBgColor; 99 QColor m_colorA; 100 QColor m_colorB; 101 QColor m_colorC; 102 QColor m_colorForConflict = Qt::red; 103 QColor m_currentRangeBgColor; 104 QColor m_currentRangeDiffBgColor; 105 QColor m_oldestFileColor = qRgb(0xf0, 0, 0); 106 QColor m_midAgeFileColor = qRgb(0xc0, 0xc0, 0); 107 QColor m_newestFileColor = qRgb(0, 0xd0, 0); 108 QColor m_missingFileColor = qRgb(0, 0, 0); 109 QColor m_manualHelpRangeColor = qRgb(0xff, 0xd0, 0x80); 110 111 bool m_bWordWrap = false; 112 113 bool m_bReplaceTabs = false; 114 bool m_bAutoIndentation = true; 115 int m_tabSize = 8; 116 bool m_bAutoCopySelection = false; 117 bool m_bSameEncoding = true; 118 QTextCodec* m_pEncodingA = nullptr; 119 bool m_bAutoDetectUnicodeA = true; 120 QTextCodec* m_pEncodingB = nullptr; 121 bool m_bAutoDetectUnicodeB = true; 122 QTextCodec* m_pEncodingC = nullptr; 123 bool m_bAutoDetectUnicodeC = true; 124 QTextCodec* m_pEncodingOut = nullptr; 125 bool m_bAutoSelectOutEncoding = true; 126 QTextCodec* m_pEncodingPP = nullptr; 127 e_LineEndStyle m_lineEndStyle = eLineEndStyleAutoDetect; 128 129 bool m_bPreserveCarriageReturn = false; 130 bool m_bTryHard = true; 131 bool m_bShowWhiteSpaceCharacters = true; 132 bool m_bShowWhiteSpace = true; 133 bool m_bShowLineNumbers = false; 134 bool m_bHorizDiffWindowSplitting = true; 135 bool m_bShowInfoDialogs = true; 136 bool m_bDiff3AlignBC = false; 137 138 int m_whiteSpace2FileMergeDefault = 0; 139 int m_whiteSpace3FileMergeDefault = 0; 140 bool m_bIgnoreCase = false; 141 bool m_bIgnoreNumbers = false; 142 bool m_bIgnoreComments = false; 143 QString m_PreProcessorCmd; 144 QString m_LineMatchingPreProcessorCmd; 145 bool m_bRunRegExpAutoMergeOnMergeStart = false; 146 QString m_autoMergeRegExp = ".*\\$(Version|Header|Date|Author).*\\$.*"; 147 bool m_bRunHistoryAutoMergeOnMergeStart = false; 148 QString m_historyStartRegExp = ".*\\$Log.*\\$.*"; 149 QString m_historyEntryStartRegExp; 150 bool m_bHistoryMergeSorting = false; 151 QString m_historyEntryStartSortKeyOrder = "4,3,2,5,1,6"; 152 int m_maxNofHistoryEntries = -1; 153 QString m_IrrelevantMergeCmd; 154 bool m_bAutoSaveAndQuitOnMergeWithoutConflicts = false; 155 156 bool m_bAutoAdvance = false; 157 int m_autoAdvanceDelay = 500; 158 159 QStringList m_recentAFiles; 160 QStringList m_recentBFiles; 161 QStringList m_recentCFiles; 162 163 QStringList m_recentEncodings; 164 165 QStringList m_recentOutputFiles; 166 167 // Directory Merge options 168 bool m_bDmSyncMode = false; 169 bool m_bDmRecursiveDirs = true; 170 bool m_bDmFollowFileLinks = true; 171 bool m_bDmFollowDirLinks = true; 172 bool m_bDmFindHidden = true; 173 bool m_bDmCreateBakFiles; 174 bool m_bDmBinaryComparison = true; 175 bool m_bDmFullAnalysis = false; 176 bool m_bDmTrustDate = false; 177 bool m_bDmTrustDateFallbackToBinary = false; 178 bool m_bDmTrustSize = false; 179 bool m_bDmCopyNewer = false; 180 //bool m_bDmShowOnlyDeltas; 181 bool m_bDmShowIdenticalFiles = true; 182 bool m_bDmUseCvsIgnore = false; 183 bool m_bDmWhiteSpaceEqual = true; 184 bool m_bDmCaseSensitiveFilenameComparison; 185 bool m_bDmUnfoldSubdirs = false; 186 bool m_bDmSkipDirStatus = false; 187 QString m_DmFilePattern = "*"; 188 QString m_DmFileAntiPattern = "*.orig;*.o;*.obj;*.rej;*.bak"; 189 QString m_DmDirAntiPattern = "CVS;.deps;.svn;.hg;.git"; 190 191 bool m_bRightToLeftLanguage = false; 192 193 QString m_ignorableCmdLineOptions = QString("-u;-query;-html;-abort"); 194 bool m_bEscapeKeyQuits = false; 195 }; 196 197 198 #endif