-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtoolwindow.h
73 lines (63 loc) · 2.31 KB
/
toolwindow.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
* This file is part of the PrismaticOutpost project.
* Copyright 2024. Isaac Raway. All rights reserved.
* This file is licensed under the terms of the AGPL-3.0,
* which you can find a copy of in the LICENSE.md file
* https://www.gnu.org/licenses/agpl-3.0.md.
* IMPORTANT: This license ALSO applies to all scripts
* and databases packaged with this distribution of
* PrismaticOutpost. If you wish to distribute proprietary
* scripts or databases, then they MUST NOT be packaged
* with this distribution or any binary distribution built
* from this distribution or any derivative of this
* distribution.
*/
// toolwindow.h
#ifndef TOOLWINDOW_H
#define TOOLWINDOW_H
#include <QDockWidget>
#include <QVector>
#include <QPushButton>
#include <QMenu>
#include <QContextMenuEvent>
#include <QHBoxLayout>
#include <QVBoxLayout>
class ToolWindow : public QDockWidget
{
Q_OBJECT
public:
enum LayoutType {
HorizontalLayout,
VerticalLayout
};
explicit ToolWindow(const QString &name, LayoutType layoutType = HorizontalLayout, QWidget *parent = nullptr);
void addItem(const QString &text, const QString &scriptPath = QString());
QStringList getItemNames() const;
QStringList getRemovedItemNames() const;
QString setScriptPath(const QString &itemName, const QString &scriptPath);
QString getScriptPath(const QString &itemName) const;
LayoutType getLayoutType() const { return layoutType; }
signals:
void itemClicked(const QString &itemText, const QString &scriptPath);
void editScriptRequested(const QString &itemText, const QString &scriptPath);
void deleteItemRequested(const QString &itemText);
void configurationChanged();
protected:
//void contextMenuEvent(QContextMenuEvent *event) override;
private slots:
void showItemContextMenu(const QPoint &pos);
void renameItem(QPushButton* button);
void editItemScript(QPushButton* button);
void deleteItem(QPushButton* button);
private:
QWidget *containerWidget;
QVector<QPushButton*> items;
QPushButton *addButton;
QMap<QString, QString> itemScripts;
QStringList removedItemNames;
QBoxLayout *layout;
LayoutType layoutType;
void setupUI();
void setupItemContextMenu(QPushButton *button);
};
#endif