src/configDialog.h

Sat, 29 Aug 2015 16:30:56 +0300

author
Teemu Piippo <crimsondusk64@gmail.com>
date
Sat, 29 Aug 2015 16:30:56 +0300
changeset 951
54d90af8542d
parent 941
f895379d7fab
permissions
-rw-r--r--

Closed old branch

655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
1 /*
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
2 * LDForge: LDraw parts authoring CAD
927
409b82a4765e - bump copyright year
Teemu Piippo <crimsondusk64@gmail.com>
parents: 861
diff changeset
3 * Copyright (C) 2013 - 2015 Teemu Piippo
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
4 *
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
5 * This program is free software: you can redistribute it and/or modify
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
6 * it under the terms of the GNU General Public License as published by
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
7 * the Free Software Foundation, either version 3 of the License, or
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
8 * (at your option) any later version.
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
9 *
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
10 * This program is distributed in the hope that it will be useful,
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
13 * GNU General Public License for more details.
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
14 *
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
17 */
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
18
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
19 #pragma once
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
20 #include "mainWindow.h"
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
21 #include <QDialog>
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
22
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
23 // =============================================================================
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
24 class ConfigDialog : public QDialog
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
25 {
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
26 Q_OBJECT
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
27
794
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 789
diff changeset
28 public:
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 789
diff changeset
29 enum Tab
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 789
diff changeset
30 {
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 789
diff changeset
31 InterfaceTab,
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 789
diff changeset
32 EditingToolsTab,
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 789
diff changeset
33 ProfileTab,
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 789
diff changeset
34 ShortcutsTab,
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 789
diff changeset
35 QuickColorsTab,
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 789
diff changeset
36 GridsTab,
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 789
diff changeset
37 ExtProgsTab,
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 789
diff changeset
38 DownloadTab
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 789
diff changeset
39 };
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
40
941
f895379d7fab Refactoring update.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 927
diff changeset
41 struct ShortcutInfo
f895379d7fab Refactoring update.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 927
diff changeset
42 {
f895379d7fab Refactoring update.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 927
diff changeset
43 QAction* action;
f895379d7fab Refactoring update.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 927
diff changeset
44 QKeySequence sequence;
f895379d7fab Refactoring update.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 927
diff changeset
45 };
f895379d7fab Refactoring update.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 927
diff changeset
46
f895379d7fab Refactoring update.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 927
diff changeset
47 using ShortcutInfoMap = QMap<QListWidgetItem*, ShortcutInfo>;
f895379d7fab Refactoring update.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 927
diff changeset
48
f895379d7fab Refactoring update.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 927
diff changeset
49 ConfigDialog (QWidget* parent = nullptr, Qt::WindowFlags f = 0);
f895379d7fab Refactoring update.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 927
diff changeset
50 ConfigDialog (Tab deftab, QWidget* parent = nullptr, Qt::WindowFlags f = 0);
794
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 789
diff changeset
51 virtual ~ConfigDialog();
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
52
794
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 789
diff changeset
53 private:
941
f895379d7fab Refactoring update.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 927
diff changeset
54 class Ui_ConfigUI& ui;
f895379d7fab Refactoring update.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 927
diff changeset
55 QList<QListWidgetItem*> m_colorToolbarItems;
f895379d7fab Refactoring update.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 927
diff changeset
56 QList<ColorToolbarEntry> m_colorToolbarEntries;
861
83426c5fa732 - major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents: 851
diff changeset
57 QMap<QPushButton*, QColor> m_buttonColors;
941
f895379d7fab Refactoring update.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 927
diff changeset
58 ShortcutInfoMap m_shortcutInfo;
f895379d7fab Refactoring update.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 927
diff changeset
59 bool m_hasValidMainWindow;
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
60
794
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 789
diff changeset
61 void applySettings();
806
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 794
diff changeset
62 void addShortcut (QAction* act);
794
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 789
diff changeset
63 void setButtonBackground (QPushButton* button, QString value);
941
f895379d7fab Refactoring update.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 927
diff changeset
64 void updateQuickColorList (ColorToolbarEntry* selected = nullptr);
f895379d7fab Refactoring update.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 927
diff changeset
65 void setShortcutText (QListWidgetItem* item);
794
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 789
diff changeset
66 int getItemRow (QListWidgetItem* item, QList<QListWidgetItem*>& haystack);
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 789
diff changeset
67 QString quickColorString();
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 789
diff changeset
68 QListWidgetItem* getSelectedQuickColor();
941
f895379d7fab Refactoring update.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 927
diff changeset
69 QList<QListWidgetItem*> getShortcutSelection();
794
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 789
diff changeset
70 void initExtProgs();
941
f895379d7fab Refactoring update.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 927
diff changeset
71 void applyToWidgetOptions (std::function<void (QWidget*, AbstractConfigEntry*)> func);
f895379d7fab Refactoring update.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 927
diff changeset
72
f895379d7fab Refactoring update.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 927
diff changeset
73 signals:
f895379d7fab Refactoring update.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 927
diff changeset
74 void settingsApplied();
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
75
794
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 789
diff changeset
76 private slots:
851
dbed6938238c - refactored up the configuration dialog. Instead of setting all configuration values one-by-one, dynamically fill in the values and save them into config based on widget names and data
Teemu Piippo <crimsondusk64@gmail.com>
parents: 844
diff changeset
77 void setButtonColor();
794
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 789
diff changeset
78 void slot_setShortcut();
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 789
diff changeset
79 void slot_resetShortcut();
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 789
diff changeset
80 void slot_clearShortcut();
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 789
diff changeset
81 void slot_setColor();
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 789
diff changeset
82 void slot_delColor();
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 789
diff changeset
83 void slot_addColorSeparator();
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 789
diff changeset
84 void slot_moveColor();
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 789
diff changeset
85 void slot_clearColors();
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 789
diff changeset
86 void slot_setExtProgPath();
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 789
diff changeset
87 void slot_findDownloadFolder();
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 789
diff changeset
88 void buttonClicked (QAbstractButton* button);
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 789
diff changeset
89 void selectPage (int row);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
90 };
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
91
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
92 // =============================================================================
794
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 789
diff changeset
93 //
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
94 class KeySequenceDialog : public QDialog
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
95 {
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
96 Q_OBJECT
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
97
794
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 789
diff changeset
98 public:
941
f895379d7fab Refactoring update.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 927
diff changeset
99 explicit KeySequenceDialog (QKeySequence keySequence, QWidget* parent = nullptr, Qt::WindowFlags f = 0);
f895379d7fab Refactoring update.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 927
diff changeset
100 QKeySequence keySequence() const;
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
101
794
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 789
diff changeset
102 private:
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 789
diff changeset
103 void updateOutput();
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
104
941
f895379d7fab Refactoring update.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 927
diff changeset
105 class QLabel* m_outputLabel;
f895379d7fab Refactoring update.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 927
diff changeset
106 QDialogButtonBox* m_buttonBox;
f895379d7fab Refactoring update.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 927
diff changeset
107 QKeySequence m_keySequence;
f895379d7fab Refactoring update.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 927
diff changeset
108
794
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 789
diff changeset
109 private slots:
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 789
diff changeset
110 virtual void keyPressEvent (QKeyEvent* ev) override;
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
111 };

mercurial