65 lines
1.3 KiB
C++
65 lines
1.3 KiB
C++
#pragma once
|
|
|
|
#include <QAbstractButton>
|
|
#include <QDialog>
|
|
#include <QTreeWidgetItem>
|
|
|
|
#include "config.h"
|
|
#include "buttonmanageritems.h"
|
|
#include "mainwindow.h"
|
|
|
|
namespace Ui {
|
|
class ButtonManager;
|
|
}
|
|
|
|
class ButtonManager : public QDialog
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit ButtonManager(Config& conf, MainWindow *parent = nullptr);
|
|
~ButtonManager();
|
|
|
|
public slots:
|
|
virtual void accept();
|
|
virtual void reject();
|
|
|
|
private slots:
|
|
//buttons:
|
|
void addButton();
|
|
void editButton();
|
|
void deleteButton();
|
|
void upButton();
|
|
void downButton();
|
|
|
|
void itemSelected();
|
|
void itemChanged(QTreeWidgetItem* item, int column);
|
|
void itemDoubleClicked(QTreeWidgetItem* item);
|
|
void dialogButtonPressed(QAbstractButton* btn);
|
|
|
|
private:
|
|
Ui::ButtonManager *ui;
|
|
MainWindow* mainW = nullptr;
|
|
|
|
Config& mainConfig;
|
|
Config::RootConfig workingConfig;
|
|
|
|
void loadConfig();
|
|
void saveChanges();
|
|
|
|
void select(QTreeWidgetItem* item);
|
|
|
|
QTreeWidgetItem* getSelectedItem() const;
|
|
template<typename T>
|
|
T* getSelectedItem() const;
|
|
// create: allow this method to create a new Row, if nothing else is found
|
|
// onlyIfSelected: only return a row if there is a selection
|
|
RowItem* getCurrentRow(bool create = true, bool onlyIfSelected = false);
|
|
ButtonItem* getCurrentButton(bool create = true) const;
|
|
|
|
RowItem* addNewRow();
|
|
|
|
template<void (ButtonManagerItem::*T)()>
|
|
void perform();
|
|
};
|