1 /* |
|
2 * LDForge: LDraw parts authoring CAD |
|
3 * Copyright (C) 2013 - 2015 Teemu Piippo |
|
4 * |
|
5 * This program is free software: you can redistribute it and/or modify |
|
6 * it under the terms of the GNU General Public License as published by |
|
7 * the Free Software Foundation, either version 3 of the License, or |
|
8 * (at your option) any later version. |
|
9 * |
|
10 * This program is distributed in the hope that it will be useful, |
|
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 * GNU General Public License for more details. |
|
14 * |
|
15 * You should have received a copy of the GNU General Public License |
|
16 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
17 */ |
|
18 |
|
19 #pragma once |
|
20 #include "mainwindow.h" |
|
21 #include "toolsets/extprogramtoolset.h" |
|
22 #include <QDialog> |
|
23 |
|
24 class Ui_ConfigUI; |
|
25 class QLabel; |
|
26 class QDoubleSpinBox; |
|
27 |
|
28 // ============================================================================= |
|
29 class ShortcutListItem : public QListWidgetItem |
|
30 { |
|
31 PROPERTY (public, QAction*, action, setAction, STOCK_WRITE) |
|
32 PROPERTY (public, QKeySequence, sequence, setSequence, STOCK_WRITE) |
|
33 |
|
34 public: |
|
35 explicit ShortcutListItem (QListWidget* view = null, int type = Type) : |
|
36 QListWidgetItem (view, type) {} |
|
37 }; |
|
38 |
|
39 struct ExternalProgramWidgets |
|
40 { |
|
41 class QLineEdit* input; |
|
42 class QPushButton* setPathButton; |
|
43 class QCheckBox* wineBox; |
|
44 }; |
|
45 |
|
46 // ============================================================================= |
|
47 class ConfigDialog : public QDialog, public HierarchyElement |
|
48 { |
|
49 Q_OBJECT |
|
50 |
|
51 public: |
|
52 enum Tab |
|
53 { |
|
54 InterfaceTab, |
|
55 EditingToolsTab, |
|
56 ProfileTab, |
|
57 ShortcutsTab, |
|
58 QuickColorsTab, |
|
59 GridsTab, |
|
60 ExtProgsTab, |
|
61 DownloadTab |
|
62 }; |
|
63 |
|
64 explicit ConfigDialog (QWidget* parent = nullptr, Tab defaulttab = (Tab) 0, Qt::WindowFlags f = 0); |
|
65 virtual ~ConfigDialog(); |
|
66 |
|
67 QList<LDQuickColor> quickColors; |
|
68 |
|
69 private: |
|
70 Ui_ConfigUI* ui; |
|
71 QList<QListWidgetItem*> quickColorItems; |
|
72 QMap<QPushButton*, QColor> m_buttonColors; |
|
73 ExternalProgramWidgets m_externalProgramWidgets[NumExternalPrograms]; |
|
74 QSettings* m_settings; |
|
75 |
|
76 void applySettings(); |
|
77 void addShortcut (QAction* act); |
|
78 void setButtonBackground (QPushButton* button, QString value); |
|
79 void updateQuickColorList (LDQuickColor* sel = null); |
|
80 void setShortcutText (ShortcutListItem* item); |
|
81 int getItemRow (QListWidgetItem* item, QList<QListWidgetItem*>& haystack); |
|
82 QString quickColorString(); |
|
83 QListWidgetItem* getSelectedQuickColor(); |
|
84 QList<ShortcutListItem*> getShortcutSelection(); |
|
85 void initExtProgs(); |
|
86 void applyToWidgetOptions (std::function<void (QWidget*, QString)> func); |
|
87 |
|
88 private slots: |
|
89 void setButtonColor(); |
|
90 void slot_setShortcut(); |
|
91 void slot_resetShortcut(); |
|
92 void slot_clearShortcut(); |
|
93 void slot_setColor(); |
|
94 void slot_delColor(); |
|
95 void slot_addColorSeparator(); |
|
96 void slot_moveColor(); |
|
97 void slot_clearColors(); |
|
98 void slot_setExtProgPath(); |
|
99 void slot_findDownloadFolder(); |
|
100 void buttonClicked (QAbstractButton* button); |
|
101 void selectPage (int row); |
|
102 }; |
|
103 |
|
104 // ============================================================================= |
|
105 // |
|
106 class KeySequenceDialog : public QDialog |
|
107 { |
|
108 Q_OBJECT |
|
109 |
|
110 public: |
|
111 explicit KeySequenceDialog (QKeySequence seq, QWidget* parent = null, Qt::WindowFlags f = 0); |
|
112 static bool staticDialog (ShortcutListItem* item, QWidget* parent = null); |
|
113 |
|
114 QLabel* lb_output; |
|
115 QDialogButtonBox* bbx_buttons; |
|
116 QKeySequence seq; |
|
117 |
|
118 private: |
|
119 void updateOutput(); |
|
120 |
|
121 private slots: |
|
122 virtual void keyPressEvent (QKeyEvent* ev) override; |
|
123 }; |
|