Skip to content

Commit

Permalink
execute any type of macro from Macro Dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
octaeder committed Dec 23, 2023
1 parent 5cc868f commit c6d4bcf
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 27 deletions.
2 changes: 1 addition & 1 deletion src/texstudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5603,7 +5603,7 @@ void Texstudio::editMacros()
userMacroDialog->selectFirst();
connect(userMacroDialog, SIGNAL(accepted()), SLOT(macroDialogAccepted()));
connect(userMacroDialog, SIGNAL(rejected()), SLOT(macroDialogRejected()));
connect(userMacroDialog, SIGNAL(runScript(QString)), SLOT(runScript(QString)));
connect(userMacroDialog, SIGNAL(execMacro(Macro)), SLOT(execMacro(Macro)));
// persistent setting like wrap
userMacroDialog->setLineWrap(configManager.macroEditorUsesLineWrap);
}
Expand Down
15 changes: 9 additions & 6 deletions src/usermenudialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ UserMenuDialog::UserMenuDialog(QWidget *parent, QString name, QLanguageFactory

connect(ui.okButton, SIGNAL(clicked()), SLOT(slotOk()));

connect(ui.runScriptButton, SIGNAL(clicked()), SLOT(slotRunScript()));
connect(ui.runScriptButton, SIGNAL(clicked()), SLOT(slotExecMacro()));

connect(ui.pushButtonAdd, SIGNAL(clicked()), SLOT(slotAdd()));
connect(ui.pushButtonAddFolder, SIGNAL(clicked()), SLOT(slotAddFolder()));
Expand Down Expand Up @@ -314,12 +314,15 @@ void UserMenuDialog::slotOk()
{
accept();
}
void UserMenuDialog::slotRunScript()
void UserMenuDialog::slotExecMacro()
{
QString script = codeedit->editor()->text();
if (script.startsWith("%SCRIPT\n"))
script = script.mid(8);
emit runScript(script);
QTreeWidgetItem *item=ui.treeWidget->currentItem();
if (item==nullptr) return;
QVariant v = item->data(0,Qt::UserRole);
if (v.isValid()){
Macro m = v.value<Macro>();
emit execMacro(m);
}
}

void UserMenuDialog::slotAdd()
Expand Down
4 changes: 2 additions & 2 deletions src/usermenudialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ class UserMenuDialog : public QDialog
virtual void keyPressEvent(QKeyEvent *e) override;

signals:
void runScript(const QString &script);
void execMacro(const Macro &macro);

private slots:
void change(QTreeWidgetItem *current,QTreeWidgetItem *previous);
void slotOk();
void slotRunScript();
void slotExecMacro();
void slotAdd();
void slotRemove();
void slotAddFolder();
Expand Down
20 changes: 2 additions & 18 deletions src/usermenudialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -443,10 +443,10 @@ p, li { white-space: pre-wrap; }
<item>
<widget class="QPushButton" name="runScriptButton">
<property name="enabled">
<bool>false</bool>
<bool>true</bool>
</property>
<property name="text">
<string>Run Script</string>
<string>Exec Macro</string>
</property>
</widget>
</item>
Expand Down Expand Up @@ -585,22 +585,6 @@ p, li { white-space: pre-wrap; }
<include location="../images.qrc"/>
</resources>
<connections>
<connection>
<sender>radioButtonScript</sender>
<signal>toggled(bool)</signal>
<receiver>runScriptButton</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>824</x>
<y>128</y>
</hint>
<hint type="destinationlabel">
<x>686</x>
<y>330</y>
</hint>
</hints>
</connection>
<connection>
<sender>cancelButton</sender>
<signal>clicked()</signal>
Expand Down

0 comments on commit c6d4bcf

Please sign in to comment.