"Fossies" - the Fresh Open Source Software Archive

Member "texstudio-3.1.1/src/configmanager.h" (21 Feb 2021, 12869 Bytes) of package /linux/misc/texstudio-3.1.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "configmanager.h" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 3.1.0_vs_3.1.1.

    1 #ifndef CONFIGMANAGER_H
    2 #define CONFIGMANAGER_H
    3 
    4 #include "mostQtHeaders.h"
    5 
    6 #include "buildmanager.h"
    7 #include "configmanagerinterface.h"
    8 #include "smallUsefulFunctions.h"
    9 
   10 class ConfigDialog;
   11 class LatexCompleterConfig;
   12 class LatexEditorViewConfig;
   13 class WebPublishDialogConfig;
   14 class InsertGraphicsConfig;
   15 struct PDFDocumentConfig;
   16 class GrammarCheckerConfig;
   17 class InternalTerminalConfig;
   18 
   19 #ifdef Q_OS_WIN
   20 const QKeySequence::SequenceFormat SHORTCUT_FORMAT = QKeySequence::PortableText;
   21 #else
   22 const QKeySequence::SequenceFormat SHORTCUT_FORMAT = QKeySequence::NativeText;
   23 #endif
   24 
   25 struct ManagedToolBar {
   26     QString name;
   27     QStringList defaults;
   28     QStringList actualActions;
   29     QToolBar *toolbar;
   30     ManagedToolBar(const QString &newName, const QStringList &defs);
   31 };
   32 
   33 class ConfigManager: public QObject, public ConfigManagerInterface
   34 {
   35     Q_OBJECT
   36 
   37 public:
   38     static const int MAX_NUM_MACROS = 5000;
   39 
   40     ConfigManager(QObject *parent = nullptr);
   41     ~ConfigManager();
   42 
   43     QString iniPath();
   44     static QString portableConfigDir();
   45     bool isPortableMode();
   46 
   47     QSettings *newQSettings();
   48     QSettings *readSettings(bool reread = false);
   49     QSettings *saveSettings(const QString &saveName = "");
   50     QSettings *getSettings();
   51 
   52     void saveMacros();
   53 
   54     bool execConfigDialog(QWidget *parentToDialog);
   55 
   56 //public configuration
   57 
   58     static QTextCodec *newFileEncoding;
   59     QString newFileEncodingName;
   60     bool autoDetectEncodingFromChars;
   61     bool autoDetectEncodingFromLatex;
   62     QStringList commonEncodings;
   63 
   64     QHash<QString, int> editorKeys;
   65     QSet<int> editorAvailableOperations;
   66 
   67     //startup
   68     bool checkLatexConfiguration;
   69 
   70     //build
   71     BuildManager *buildManager;
   72     bool showMessagesWhenCompiling;
   73     bool runLaTeXBibTeXLaTeX;
   74     int showStdoutOption; //never = 0, user commands, always
   75 
   76     //svn
   77     //bool autoCheckinAfterSave;
   78     int autoCheckinAfterSaveLevel;
   79     int useVCS; // 0 SVN   1 GIT
   80     bool svnUndo;
   81     bool svnKeywordSubstitution;
   82     int svnSearchPathDepth;
   83 
   84 
   85     //appearance
   86     QPalette systemPalette;
   87     QString interfaceStyle;
   88     QString interfaceFontFamily;
   89     int guiToolbarIconSize, guiSymbolGridIconSize;
   90     int guiSecondaryToolbarIconSize;
   91     int guiPDFToolbarIconSize;
   92     int guiConfigShortcutColumnWidth;
   93     bool useTexmakerPalette;
   94     int interfaceFontSize;
   95     bool mruDocumentChooser;
   96     bool configShowAdvancedOptions, configRiddled;
   97     bool centralVisible;
   98     bool showStatusbar;
   99     bool showLineNumbersInStructure;
  100     int indentationInStructure;
  101     bool indentIncludesInStructure;
  102     bool showCommentedElementsInStructure;
  103     bool markStructureElementsBeyondEnd;
  104     bool markStructureElementsInAppendix;
  105     QString referenceCommandsInContextMenu;
  106 
  107     //update
  108     bool autoUpdateCheck;
  109     int updateLevel;
  110     int autoUpdateCheckIntervalDays;
  111     QDateTime lastUpdateCheck;
  112 
  113     //language
  114     QString language, lastLanguage;
  115     QTranslator *appTranslator;
  116     QTranslator *basicTranslator;
  117 
  118     //editor
  119     LatexEditorViewConfig *const editorConfig;
  120     //completion
  121     LatexCompleterConfig *const completerConfig;
  122 
  123     //webpublish dialog
  124     WebPublishDialogConfig *const webPublishDialogConfig;
  125     //pdf preview
  126     PDFDocumentConfig *const pdfDocumentConfig;
  127 
  128     //other dialogs
  129     int lastHardWrapColumn;
  130     bool lastHardWrapSmartScopeSelection;
  131     bool lastHardWrapJoinLines;
  132 
  133     //insert graphics dialog
  134     InsertGraphicsConfig *const insertGraphicsConfig;
  135 
  136     //Grammar check
  137     GrammarCheckerConfig *const grammarCheckerConfig;
  138 
  139     //Terminal
  140     InternalTerminalConfig *const terminalConfig;
  141 
  142     //bool autoReplaceCommands; // moved to static codesnippet
  143 
  144     int tabstop;
  145 
  146     bool useEscForClosingLog;
  147     bool useEscForClosingEmbeddedViewer;
  148     bool useEscForClosingFullscreen;
  149     bool showShortcutsInTooltips;
  150     int replaceQuotes; //0: none, 1: ``..'', 2: \"< \"> 3: \"`..\"' , 4: \\og..\\fg{} 5: \"> \"<
  151 
  152     // table autoformat
  153     QString tableAutoFormatSpecialCommands; // colon separated
  154     int tableAutoFormatSpecialCommandPos;
  155     bool tableAutoFormatOneLinePerCell;
  156 
  157     // LogView
  158     double logViewWarnIfFileSizeLargerMB;
  159     int logViewRememberChoice;
  160 
  161     //preview
  162     enum PreviewMode {PM_TOOLTIP_AS_FALLBACK = 0, PM_PANEL, PM_TOOLTIP, PM_BOTH, PM_INLINE, PM_EMBEDDED};
  163     enum AutoPreviewMode {AP_NEVER = 0, AP_PREVIOUSLY = 1};
  164     PreviewMode previewMode;
  165     AutoPreviewMode autoPreview;
  166     int autoPreviewDelay;
  167     int segmentPreviewScalePercent;
  168 
  169     // embedded viewer
  170     bool viewerEnlarged;
  171 
  172     //files
  173     QString lastDocument; //last opened document, for file open directory
  174     QStringList recentFilesList, recentProjectList, recentSessionList;
  175     QMap<QString, QString> recentFileHighlightLanguage;
  176     int maxRecentFiles, maxRecentProjects, maxRecentSessions;
  177     bool rememberFileFilter, useNativeFileDialog;
  178     bool sessionRestore;
  179     bool sessionStoreRelativePaths;
  180     bool parseBibTeX, parseMaster;
  181     QString logFileEncoding, bibFileEncoding;
  182     bool autoLoadChildren;
  183 
  184     // insert cite command, when no context available
  185     QString citeCommand;
  186 
  187     //autosave
  188     int autosaveEveryMinutes;
  189 
  190     bool addRecentFile(const QString &fileName, bool asMaster);  //adds a recent file
  191     void updateRecentFiles(bool alwaysRecreateMenuItems = false);
  192     QMenu *updateListMenu(const QString &menuName, const QStringList &items, const QString &namePrefix, bool prefixNumber, const char *slotName, const int baseShortCut, bool alwaysRecreateMenuItems = false, int additionalEntries = 2, const QList<QVariant> data=QList<QVariant>());
  193     void updateUserMacroMenu();
  194     void updateUserMacroShortcuts();
  195 
  196     QString additionalBibPaths;
  197     QString additionalImagePaths;
  198 
  199     //dictionaries
  200     QString spellDictDir;
  201     QString spellLanguage;
  202     QString spell_dic, thesaurus_database;
  203 
  204     //debug
  205 #ifndef QT_NO_DEBUG
  206     QDateTime debugLastFileModification;
  207     QDateTime debugLastFullTestRun;
  208 #endif
  209 
  210     bool goToErrorWhenDisplayingLog;
  211     bool showLogMarkersWhenClickingLogEntry;
  212     bool scanInstalledLatexPackages;
  213 
  214     // input unicode instead of latex command from symbolgrid (if available)
  215     bool insertSymbolsAsUnicode;
  216 
  217     // macro repository
  218     QString URLmacroRepository;
  219     //menus
  220     QObjectList menuParents;
  221     QObject *menuParent; //lets assume there is only one
  222     QMenuBar *menuParentsBar; //that's ugly, but faster as long as there is only one (both values could be extracted from the action's name)
  223     QList<QMenu *> managedMenus;
  224     QHash<QString, QKeySequence> managedMenuShortcuts;
  225     QList<QPair<QString, QString> > managedMenuNewShortcuts;
  226 #if (QT_VERSION <= 0x050700) && (defined(Q_OS_MAC))
  227     //workaround that osx/qt does not support alt+key/esc as shortcuts
  228     QMultiMap<QKeySequence, QAction *> specialShortcuts;
  229 #endif
  230 
  231     QMenu *newManagedMenu(const QString &id, const QString &text);
  232     QMenu *newManagedMenu(QMenu *menu, const QString &id, const QString &text);
  233     QMenu *newManagedMenu(QWidget *menuParent,QMenuBar *menuParentsBar,const QString &id, const QString &text);
  234     QAction *newManagedAction(QWidget *menu, const QString &id, const QString &text, const char *slotName, const QList<QKeySequence> &shortCuts = QList<QKeySequence>(), const QString &iconFile = "");
  235     QAction *newManagedAction(QObject *rootMenu,QWidget *menu, const QString &id, const QString &text, QObject *obj,const char *slotName, const QList<QKeySequence> &shortCuts = QList<QKeySequence>(), const QString &iconFile = "");
  236     QAction *newManagedAction(QWidget *menu, const QString &id, QAction *act);
  237     QAction *newOrLostOldManagedAction(QWidget *menu, const QString &id, const QString &text, const char *slotName, const QList<QKeySequence> &shortCuts = QList<QKeySequence>(), const QString &iconFile = "");
  238     QAction *getManagedAction(const QString &id);
  239     QList<QAction *> getManagedActions(const QString &id);
  240     QList<QAction *> getManagedActions(const QStringList &ids, const QString &commonPrefix = "");
  241     QMenu *getManagedMenu(const QString &id);
  242     void removeManagedMenus();
  243     void triggerManagedAction(const QString &id);
  244 
  245     static QString configDirOverride;
  246     static bool dontRestoreSession;
  247     static int RUNAWAYLIMIT;
  248 private:
  249     void setupDirectoryStructure();
  250     void moveCwls();
  251     void connectExtendedSlot(QAction *act, const QString &slot);
  252     bool modifyMenuContentsFirstCall;
  253     void modifyMenuContent(QStringList &ids, const QString &id);
  254     void clearMenu(QMenu *menu);
  255 public:
  256     void modifyMenuContents();
  257     void modifyManagedShortcuts(QString startsWith="");
  258     void setManagedShortCut(QAction *act, int num, const QKeySequence &key);
  259     void loadManagedMenu(QMenu *parent, const QDomElement &f);
  260     void loadManagedMenus(const QString &f);
  261     QStringList possibleMenuSlots;
  262 private:
  263     void managedMenuToTreeWidget(QTreeWidgetItem *parent, QMenu *menu);
  264     void treeWidgetToManagedMenuTo(QTreeWidgetItem *item);
  265 
  266     QTreeWidgetItem *managedLatexMenuToTreeWidget(QTreeWidgetItem *parent, QMenu *menu);
  267     void treeWidgetToManagedLatexMenuTo();
  268 
  269 public:
  270     // custom toolbar
  271     QList<ManagedToolBar> managedToolBars;
  272     QStringList watchedMenus;  //list of all sub menus mapped on toolbars
  273     QMap<QString, QVariant> replacedIconsOnMenus;
  274 
  275     void populateCustomActions(QListWidget *parent, QMenu *menu, bool go = false);
  276 
  277 signals:
  278     void watchedMenuChanged(const QString &menuId);
  279     void iconSizeChanged(int value);
  280     void secondaryIconSizeChanged(int value);
  281     void pdfIconSizeChanged(int value);
  282     void symbolGridIconSizeChanged(int value);
  283 public:
  284 //private:
  285     QString configFileName, configFileNameBase, defaultStyleName, configBaseDir;
  286     enum CommmandGridWidgetType {CG_ID, CG_RERUN, CG_CMD, CG_PROGRAM, CG_RESET, CG_CONFIG, CG_DEL, CG_MOVEUP, CG_MOVEDOWN, CG_ADD};
  287     CommandMapping tempCommands;
  288     QList<QPushButton *> rerunButtons; // only for non-user commands
  289     QList<QWidget *> commandInputs;   // only for non-user commands
  290     QGridLayout *userGridLayout;
  291     QLineEdit *pdflatexEdit;
  292     void loadTranslations(QString locale);
  293 
  294     void registerOption(const QString &name, void *storage, PropertyType type, QVariant def, void *displayWidgetOffset);
  295     virtual void registerOption(const QString &name, void *storage, PropertyType type, QVariant def);
  296 
  297 #define REGISTER_OPTION(TYPE, dummy) \
  298     void registerOption(const QString& name, TYPE* storage, QVariant def,  void* displayWidgetOffset); \
  299     virtual void registerOption(const QString& name, TYPE* storage, QVariant def=QVariant());
  300     PROPERTY_TYPE_FOREACH_MACRO(REGISTER_OPTION)
  301 #undef REGISTER_OPTION
  302 
  303     //virtual void registerOption(const QString& name, QVariant* storage, QVariant def);
  304     virtual void setOption(const QString &name, const QVariant &value);
  305     virtual QVariant getOption(const QString &name, const QVariant &defaultValue = QVariant()) const;
  306     virtual bool existsOption(const QString &name) const;
  307     virtual void linkOptionToDialogWidget(const void *optionStorage, QWidget *widget);
  308     virtual void linkOptionToObject(const void *optionStorage, QObject *widget, LinkOptions options);
  309     virtual void updateAllLinkedObjects(const void *optionStorage);
  310 
  311     static void getDefaultEncoding(const QByteArray &unused, QTextCodec *&guess, int &sure);
  312 
  313     QString parseDir(QString s) const;
  314     QStringList parseDirList(const QString &s) const;
  315     QString reverseParseDir(QString s) const;
  316     QString reverseParseDir(const QStringList &s) const;
  317 private:
  318     void setInterfaceStyle();
  319 
  320     QSettings *persistentConfig;
  321 
  322     QList<QTreeWidgetItem *> changedItemsList, superAdvancedItems;
  323     QHash<QString, QTreeWidgetItem *> manipulatedMenuTree;
  324 
  325     QMap<QString, QVariant> manipulatedMenus;
  326 
  327     QList<ManagedProperty> managedProperties;
  328 
  329     QMap<QWidget *, QList<QWidget *> > managedOptionDialogs;
  330     ManagedProperty *getManagedProperty(const void *storage);
  331     ManagedProperty *getManagedProperty(const QString &name);
  332     const ManagedProperty *getManagedProperty(const QString &name) const;
  333 
  334     QMap<ManagedProperty *, QPair<LinkOptions, QList<QObject *> > > managedOptionObjects;
  335 
  336     int userCommandRowCount();
  337     void addCommandRow(QGridLayout *parent, const CommandInfo &cmd, int row);
  338     void createCommandList(QGroupBox *box, const QStringList &order, bool user, bool meta);
  339     void setFirstRowMoveUpEnable(bool enable);
  340     void setLastRowMoveDownEnable(bool enable);
  341 private slots:
  342     void browseCommand();
  343     void undoCommand();
  344     void editCommand();
  345     void addCommand();
  346     void removeCommand();
  347     void moveUpCommand();
  348     void moveDownCommand();
  349     void moveCommand(int dir, int atRow = -1);
  350 
  351     void menuTreeItemChanged(QTreeWidgetItem *item, int l);
  352     void menuTreeNewItem(bool menu = false);
  353     void menuTreeNewMenuItem();
  354     void menuTreeRevertItem();
  355     void toggleVisibleTreeItems(bool show);
  356     void activateInternalViewer(bool activated);
  357 
  358     void managedOptionDialogAccepted();
  359     void managedOptionObjectDestroyed(QObject *obj);
  360     void managedOptionBoolToggled();
  361 private:
  362     void updateManagedOptionObjects(ManagedProperty *property);
  363 };
  364 #endif