Bugfixes and Keysets
[pierogi] / forms / pirmacroform.cpp
1 #include "pirmacroform.h"
2 #include "ui_pirmacroform.h"
3
4 //#include "mainwindow.h"
5 #include "macros/pirmacro.h"
6
7 class QTreeWidgetItem;
8 class MainWindow;
9
10 /*
11 PIRMacroForm::PIRMacroForm(QWidget *parent) :
12   QWidget(parent),
13   ui(new Ui::PIRMacroForm)
14 {
15   ui->setupUi(this);
16 }
17 */
18
19 PIRMacroForm::PIRMacroForm(
20   MainWindow *mw)
21   : QWidget(0),
22     ui(new Ui::PIRMacroForm),
23     smd(mw),
24     ccd(mw),
25     currentMacro(0)
26 {
27   ui->setupUi(this);
28
29   connect(
30     &smd,
31     SIGNAL(macroChosen(QTreeWidgetItem *)),
32     this,
33     SLOT(displayMacro(QTreeWidgetItem *)));
34 }
35
36 PIRMacroForm::~PIRMacroForm()
37 {
38   delete ui;
39 }
40
41
42 void PIRMacroForm::on_chooseMacroButton_clicked()
43 {
44   smd.exec();
45 }
46
47
48 void PIRMacroForm::on_runButton_clicked()
49 {
50   currentMacro->executeMacro();
51 }
52
53
54 void PIRMacroForm::displayMacro(
55   QTreeWidgetItem *item)
56 {
57   if (!item) return;
58
59   PIRMacro *m = dynamic_cast<PIRMacro *> (item);
60
61   if (!m) return;
62
63   currentMacro = m;
64
65   currentMacro->populateList(ui->macroListWidget);
66 }
67
68
69 void PIRMacroForm::on_addButton_clicked()
70 {
71   ccd.exec();
72 }