From 007c734b4a210f4e1e73fd39ee274a9473e1e83e Mon Sep 17 00:00:00 2001 From: octaeder <102688820+octaeder@users.noreply.github.com> Date: Sat, 16 Mar 2024 18:42:40 +0100 Subject: [PATCH] Replace user tags in side panel (#3566) * cosmetics * add user tags to side panel --- src/texstudio.cpp | 20 +++++++++++++------- src/texstudio.h | 12 ++++++------ 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/src/texstudio.cpp b/src/texstudio.cpp index 5ca3f97781..e834383c16 100644 --- a/src/texstudio.cpp +++ b/src/texstudio.cpp @@ -589,16 +589,22 @@ void Texstudio::addTagList(const QString &id, const QString &iconName, const QSt { XmlTagsListWidget *list = qobject_cast(leftPanel->widget(id)); if (!list) { - list = new XmlTagsListWidget(this, ":/tags/" + tagFile); + // check for user tags + QString configBaseDir = configManager.configBaseDir; + QString pathPrefix=joinPath(configBaseDir,"tags/"); + QFileInfo userTagFile(pathPrefix+tagFile); + if(!QFileInfo::exists(pathPrefix+tagFile) || !userTagFile.isReadable()) { + pathPrefix = ":/tags/"; + } + list = new XmlTagsListWidget(this, pathPrefix + tagFile); list->setObjectName("tags/" + tagFile.left(tagFile.indexOf("_tags.xml"))); UtilsUi::enableTouchScrolling(list); - connect(list, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(insertXmlTag(QListWidgetItem*))); + connect(list, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(insertXmlTag(QListWidgetItem*))); leftPanel->addWidget(list, id, text, iconName); - //(*list)->setProperty("mType",2); - } else { - leftPanel->setWidgetText(list, text); - leftPanel->setWidgetIcon(list,iconName); - } + } else { + leftPanel->setWidgetText(list, text); + leftPanel->setWidgetIcon(list,iconName); + } } /*! diff --git a/src/texstudio.h b/src/texstudio.h index b0c02b0b7d..7b0afcda3f 100644 --- a/src/texstudio.h +++ b/src/texstudio.h @@ -104,21 +104,21 @@ public slots: //these are just wrappers around configManager so we don't have to type so much (todo??? move them to configmanager.h and use a singleton design???) Q_INVOKABLE inline QMenu *newManagedMenu(const QString &id, const QString &text) { return configManager.newManagedMenu(id, text); } Q_INVOKABLE inline QMenu *newManagedMenu(QMenu *menu, const QString &id, const QString &text) { return configManager.newManagedMenu(menu, id, text); } - Q_INVOKABLE QAction *newManagedAction(QWidget *menu, const QString &id, const QString &text, const char *slotName = nullptr, const QKeySequence &shortCut = 0, const QString &iconFile = "", const QList &args = QList()); + Q_INVOKABLE QAction *newManagedAction(QWidget *menu, const QString &id, const QString &text, const char *slotName = nullptr, const QKeySequence &shortCut = 0, const QString &iconFile = "", const QList &args = QList()); Q_INVOKABLE QAction *newManagedAction(QWidget *menu, const QString &id, const QString &text, const char *slotName, const QList &shortCuts, const QString &iconFile = "", const QList &args = QList()); - Q_INVOKABLE QAction *newManagedEditorAction(QWidget *menu, const QString &id, const QString &text, const char *slotName = nullptr, const QKeySequence &shortCut = 0, const QString &iconFile = "", const QList &args = QList()); + Q_INVOKABLE QAction *newManagedEditorAction(QWidget *menu, const QString &id, const QString &text, const char *slotName = nullptr, const QKeySequence &shortCut = 0, const QString &iconFile = "", const QList &args = QList()); Q_INVOKABLE QAction *newManagedEditorAction(QWidget *menu, const QString &id, const QString &text, const char *slotName, const QList &shortCuts, const QString &iconFile = "", const QList &args = QList()); Q_INVOKABLE inline QAction *newManagedAction(QWidget *menu, const QString &id, QAction *act) { return configManager.newManagedAction(menu, id, act); } Q_INVOKABLE inline QMenu *getManagedMenu(const QString &id) { return configManager.getManagedMenu(id); } Q_INVOKABLE inline QAction *getManagedAction(const QString &id) { return configManager.getManagedAction(id); } Q_INVOKABLE inline QList getManagedActions(const QStringList &ids, const QString &commonPrefix = "") { return configManager.getManagedActions(ids, commonPrefix); } - Q_INVOKABLE QAction *insertManagedAction(QAction *before, const QString &id, const QString &text, const char *slotName = nullptr, const QKeySequence &shortCut = 0, const QString &iconFile = ""); - Q_INVOKABLE void loadManagedMenu(const QString &fn); + Q_INVOKABLE QAction *insertManagedAction(QAction *before, const QString &id, const QString &text, const char *slotName = nullptr, const QKeySequence &shortCut = 0, const QString &iconFile = ""); + Q_INVOKABLE void loadManagedMenu(const QString &fn); - Q_INVOKABLE void setupToolBars(); + Q_INVOKABLE void setupToolBars(); void addTagList(const QString &id, const QString &iconName, const QString &text, const QString &tagFile); - void addMacrosAsTagList(); + void addMacrosAsTagList(); private slots: void updateToolBarMenu(const QString &menuName);