Skip to content

user macros can be "activated" (checked)#4361

Merged
sunderme merged 7 commits intotexstudio-org:masterfrom
octaeder:usermacro
Mar 13, 2026
Merged

user macros can be "activated" (checked)#4361
sunderme merged 7 commits intotexstudio-org:masterfrom
octaeder:usermacro

Conversation

@octaeder
Copy link
Copy Markdown
Contributor

@octaeder octaeder commented Mar 11, 2026

Final remarks about results from the comments:

Macros are not really deactivated when they are not checked. They are still visible in the Macro menu as well as in the side panel and can be executed from there. You can also execute them in the Macro Editor by pressing the Exec button. While the macro shortcut and trigger won't work (s. added tooltip), the abbreviation can still be used. No checkbox has been added to the macro browser (repo). Any macro downloaded from there will be "activated" (checked).

Original PR

This PR resolves #3971. I made commits (starting with class changes) for each file changed. Some commits give further details. So I hope it's easier to understand. I also added some testing.

Loading/importing macros set checked macros not having checkState element, otherwise they are checked accordingly.
When importing from macro repo you can decide what checkState they should have (s. image below).

Screenshots:

show only checked macros in side bar and menu:

grafik grafik

Tree view in macro editor:

grafik

Macro browser (macro repo):

grafik

@sunderme
Copy link
Copy Markdown
Member

1)The issue is about deactivating triggers (and maybe shortcuts).
There is no need to hide those macros.

  1. default must be "active"
  2. "import as ..." is superfluous, there is no reasonable scenario where the use imports and deactivates (and he could do so afterwards)

Comment on lines +37 to +39
checkBox=new QCheckBox();
checkBox->setChecked(false);
auto *lblCheckBox=new QLabel(tr("Import as active macros"));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

default is active, this has to go

// add elements
for(const auto &m:configManager.completerConfig->userMacros) {
if (m.name == TXS_AUTO_REPLACE_QUOTE_OPEN || m.name == TXS_AUTO_REPLACE_QUOTE_CLOSE || m.document)
if (m.name == TXS_AUTO_REPLACE_QUOTE_OPEN || m.name == TXS_AUTO_REPLACE_QUOTE_CLOSE || m.document || m.checkState() != Qt::Checked)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no hiding


void Texstudio::execMacro(const Macro &m, const MacroExecContext &context, bool allowWrite)
{
if (m.checkState() != Qt::Checked) return;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only trigger and maybe shortcut are to be deactivated

Comment on lines +45 to +48
hlayout->addWidget(checkBox);
hlayout->addWidget(lblCheckBox);
hlayout->addWidget(buttonBox);
layout->addLayout(hlayout);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see above

@octaeder octaeder marked this pull request as draft March 12, 2026 18:09
@octaeder octaeder force-pushed the usermacro branch 3 times, most recently from c93e53e to db19238 Compare March 12, 2026 19:19
{
QTreeWidgetItem *item = ui.treeWidget->currentItem();
if (item==nullptr) return;
if (item==nullptr || item->checkState(0)!=Qt::Checked) return;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is the "execute macro" button blocked with active/inactive macro ?

}
}

void UserMenuDialog::checkStateChanged(QTreeWidgetItem *item)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure why the checkstate is not just queried at getMacros ?

- don't test unchecked macros for duplicate trigger with quotes macros
- update shortcuts for checked macros only
- counter used needs to be the same as in original (full) user macros list
@octaeder octaeder force-pushed the usermacro branch 3 times, most recently from 5508ff5 to d5478e1 Compare March 12, 2026 22:57
@sunderme
Copy link
Copy Markdown
Member

and at last, there should be a tooltip on the checkboxes, so that user may know what they are deactivating

@octaeder
Copy link
Copy Markdown
Contributor Author

ok, I was thinking about tooltips at the beginning. But I assumed this could be to much UI activity while cursor is moving. Do you have an idea regarding the latexcompleter (s. question above)?

@octaeder
Copy link
Copy Markdown
Contributor Author

tooltips also for folder items?

set checkState in getMacros
and on exportMacros
toolTips
@octaeder octaeder marked this pull request as ready for review March 13, 2026 16:00
@sunderme sunderme merged commit b42dc0d into texstudio-org:master Mar 13, 2026
8 checks passed
@sunderme
Copy link
Copy Markdown
Member

thanks

@octaeder octaeder changed the title user macros can be activated (checked) user macros can be "activated" (checked) Mar 13, 2026
@octaeder octaeder deleted the usermacro branch March 13, 2026 18:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Add a toggle button for macros

2 participants