Skip to content

Commit

Permalink
Replace user tags in side panel (texstudio-org#3566)
Browse files Browse the repository at this point in the history
* cosmetics

* add user tags to side panel
  • Loading branch information
octaeder authored Mar 16, 2024
1 parent 115d365 commit 007c734
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
20 changes: 13 additions & 7 deletions src/texstudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -589,16 +589,22 @@ void Texstudio::addTagList(const QString &id, const QString &iconName, const QSt
{
XmlTagsListWidget *list = qobject_cast<XmlTagsListWidget *>(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);
}
}

/*!
Expand Down
12 changes: 6 additions & 6 deletions src/texstudio.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<QVariant> &args = QList<QVariant>());
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<QVariant> &args = QList<QVariant>());
Q_INVOKABLE QAction *newManagedAction(QWidget *menu, const QString &id, const QString &text, const char *slotName, const QList<QKeySequence> &shortCuts, const QString &iconFile = "", const QList<QVariant> &args = QList<QVariant>());
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<QVariant> &args = QList<QVariant>());
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<QVariant> &args = QList<QVariant>());
Q_INVOKABLE QAction *newManagedEditorAction(QWidget *menu, const QString &id, const QString &text, const char *slotName, const QList<QKeySequence> &shortCuts, const QString &iconFile = "", const QList<QVariant> &args = QList<QVariant>());
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<QAction *> 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);
Expand Down

0 comments on commit 007c734

Please sign in to comment.