Sat, 05 Sep 2015 23:03:24 +0300
Make documents members of the main window
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 |
968 | 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 | * configDialog.cxx: Settings dialog and everything related to it. |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
20 | * Actual configuration core is in config.cxx. |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
21 | */ |
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 | #include <QGridLayout> |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
24 | #include <QFileDialog> |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
25 | #include <QColorDialog> |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
26 | #include <QBoxLayout> |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
27 | #include <QKeyEvent> |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
28 | #include <QGroupBox> |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
29 | #include <QDoubleSpinBox> |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
30 | #include <QLineEdit> |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
31 | #include <QCheckBox> |
971
c00f9665a9f8
Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
970
diff
changeset
|
32 | #include <QSettings> |
975
24ba5aa3393f
Move ConfigDialog into src/dialogs/ subfolder
Teemu Piippo <crimsondusk64@gmail.com>
parents:
974
diff
changeset
|
33 | #include <QPushButton> |
24ba5aa3393f
Move ConfigDialog into src/dialogs/ subfolder
Teemu Piippo <crimsondusk64@gmail.com>
parents:
974
diff
changeset
|
34 | #include "../main.h" |
24ba5aa3393f
Move ConfigDialog into src/dialogs/ subfolder
Teemu Piippo <crimsondusk64@gmail.com>
parents:
974
diff
changeset
|
35 | #include "../ldDocument.h" |
24ba5aa3393f
Move ConfigDialog into src/dialogs/ subfolder
Teemu Piippo <crimsondusk64@gmail.com>
parents:
974
diff
changeset
|
36 | #include "../miscallenous.h" |
24ba5aa3393f
Move ConfigDialog into src/dialogs/ subfolder
Teemu Piippo <crimsondusk64@gmail.com>
parents:
974
diff
changeset
|
37 | #include "../glRenderer.h" |
24ba5aa3393f
Move ConfigDialog into src/dialogs/ subfolder
Teemu Piippo <crimsondusk64@gmail.com>
parents:
974
diff
changeset
|
38 | #include "../guiutilities.h" |
24ba5aa3393f
Move ConfigDialog into src/dialogs/ subfolder
Teemu Piippo <crimsondusk64@gmail.com>
parents:
974
diff
changeset
|
39 | #include "colorselector.h" |
24ba5aa3393f
Move ConfigDialog into src/dialogs/ subfolder
Teemu Piippo <crimsondusk64@gmail.com>
parents:
974
diff
changeset
|
40 | #include "configdialog.h" |
24ba5aa3393f
Move ConfigDialog into src/dialogs/ subfolder
Teemu Piippo <crimsondusk64@gmail.com>
parents:
974
diff
changeset
|
41 | #include "ui_configdialog.h" |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
42 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
43 | const char* g_extProgPathFilter = |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
44 | #ifdef _WIN32 |
814
c8ef30fd0e54
- refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
806
diff
changeset
|
45 | "Applications (*.exe)(*.exe);;" |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
46 | #endif |
814
c8ef30fd0e54
- refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
806
diff
changeset
|
47 | "All files (*.*)(*.*)"; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
48 | |
970
c8aae45afd85
Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
49 | ConfigDialog::ConfigDialog (QWidget* parent, ConfigDialog::Tab defaulttab, Qt::WindowFlags f) : |
c8aae45afd85
Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
50 | QDialog (parent, f), |
971
c00f9665a9f8
Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
970
diff
changeset
|
51 | HierarchyElement (parent), |
976
b7aac3606b65
Make ui a reference pointer in ConfigDialog
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
52 | ui (*new Ui_ConfigDialog), |
971
c00f9665a9f8
Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
970
diff
changeset
|
53 | m_settings (m_window->makeSettings (this)) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
54 | { |
976
b7aac3606b65
Make ui a reference pointer in ConfigDialog
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
55 | ui.setupUi (this); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
56 | |
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:
850
diff
changeset
|
57 | // Set defaults |
971
c00f9665a9f8
Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
970
diff
changeset
|
58 | applyToWidgetOptions ( |
c00f9665a9f8
Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
970
diff
changeset
|
59 | [&](QWidget* widget, QString confname) |
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:
850
diff
changeset
|
60 | { |
971
c00f9665a9f8
Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
970
diff
changeset
|
61 | QVariant value = m_settings->value (confname, m_config->defaultValueByName (confname)); |
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:
850
diff
changeset
|
62 | QLineEdit* le; |
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:
850
diff
changeset
|
63 | QSpinBox* spinbox; |
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:
850
diff
changeset
|
64 | QDoubleSpinBox* doublespinbox; |
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:
850
diff
changeset
|
65 | QSlider* slider; |
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:
850
diff
changeset
|
66 | QCheckBox* checkbox; |
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:
850
diff
changeset
|
67 | QPushButton* button; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
68 | |
971
c00f9665a9f8
Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
970
diff
changeset
|
69 | if ((le = qobject_cast<QLineEdit*> (widget)) != null) |
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:
850
diff
changeset
|
70 | { |
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:
850
diff
changeset
|
71 | le->setText (value.toString()); |
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:
850
diff
changeset
|
72 | } |
971
c00f9665a9f8
Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
970
diff
changeset
|
73 | else if ((spinbox = qobject_cast<QSpinBox*> (widget)) != null) |
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:
850
diff
changeset
|
74 | { |
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:
850
diff
changeset
|
75 | spinbox->setValue (value.toInt()); |
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:
850
diff
changeset
|
76 | } |
971
c00f9665a9f8
Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
970
diff
changeset
|
77 | else if ((doublespinbox = qobject_cast<QDoubleSpinBox*> (widget)) != null) |
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:
850
diff
changeset
|
78 | { |
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:
850
diff
changeset
|
79 | doublespinbox->setValue (value.toDouble()); |
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:
850
diff
changeset
|
80 | } |
971
c00f9665a9f8
Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
970
diff
changeset
|
81 | else if ((slider = qobject_cast<QSlider*> (widget)) != null) |
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:
850
diff
changeset
|
82 | { |
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:
850
diff
changeset
|
83 | slider->setValue (value.toInt()); |
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:
850
diff
changeset
|
84 | } |
971
c00f9665a9f8
Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
970
diff
changeset
|
85 | else if ((checkbox = qobject_cast<QCheckBox*> (widget)) != null) |
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:
850
diff
changeset
|
86 | { |
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:
850
diff
changeset
|
87 | checkbox->setChecked (value.toBool()); |
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:
850
diff
changeset
|
88 | } |
971
c00f9665a9f8
Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
970
diff
changeset
|
89 | else if ((button = qobject_cast<QPushButton*> (widget)) != null) |
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:
850
diff
changeset
|
90 | { |
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:
850
diff
changeset
|
91 | setButtonBackground (button, value.toString()); |
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:
850
diff
changeset
|
92 | connect (button, SIGNAL (clicked()), this, SLOT (setButtonColor())); |
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:
850
diff
changeset
|
93 | } |
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:
850
diff
changeset
|
94 | else |
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:
850
diff
changeset
|
95 | { |
971
c00f9665a9f8
Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
970
diff
changeset
|
96 | print ("Unknown widget of type %1\n", widget->metaObject()->className()); |
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:
850
diff
changeset
|
97 | } |
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:
850
diff
changeset
|
98 | }); |
780
b0d84fb70ea5
- made coordinate rounding precision configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
760
diff
changeset
|
99 | |
970
c8aae45afd85
Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
100 | m_window->applyToActions ([&](QAction* act) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
101 | { |
970
c8aae45afd85
Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
102 | addShortcut (act); |
c8aae45afd85
Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
103 | }); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
104 | |
976
b7aac3606b65
Make ui a reference pointer in ConfigDialog
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
105 | ui.shortcutsList->setSortingEnabled (true); |
b7aac3606b65
Make ui a reference pointer in ConfigDialog
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
106 | ui.shortcutsList->sortItems(); |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
860
diff
changeset
|
107 | quickColors = LoadQuickColorList(); |
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:
850
diff
changeset
|
108 | updateQuickColorList(); |
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:
850
diff
changeset
|
109 | initExtProgs(); |
970
c8aae45afd85
Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
110 | selectPage (defaulttab); |
976
b7aac3606b65
Make ui a reference pointer in ConfigDialog
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
111 | connect (ui.shortcut_set, SIGNAL (clicked()), this, SLOT (slot_setShortcut())); |
b7aac3606b65
Make ui a reference pointer in ConfigDialog
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
112 | connect (ui.shortcut_reset, SIGNAL (clicked()), this, SLOT (slot_resetShortcut())); |
b7aac3606b65
Make ui a reference pointer in ConfigDialog
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
113 | connect (ui.shortcut_clear, SIGNAL (clicked()), this, SLOT (slot_clearShortcut())); |
b7aac3606b65
Make ui a reference pointer in ConfigDialog
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
114 | connect (ui.quickColor_add, SIGNAL (clicked()), this, SLOT (slot_setColor())); |
b7aac3606b65
Make ui a reference pointer in ConfigDialog
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
115 | connect (ui.quickColor_remove, SIGNAL (clicked()), this, SLOT (slot_delColor())); |
b7aac3606b65
Make ui a reference pointer in ConfigDialog
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
116 | connect (ui.quickColor_edit, SIGNAL (clicked()), this, SLOT (slot_setColor())); |
b7aac3606b65
Make ui a reference pointer in ConfigDialog
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
117 | connect (ui.quickColor_addSep, SIGNAL (clicked()), this, SLOT (slot_addColorSeparator())); |
b7aac3606b65
Make ui a reference pointer in ConfigDialog
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
118 | connect (ui.quickColor_moveUp, SIGNAL (clicked()), this, SLOT (slot_moveColor())); |
b7aac3606b65
Make ui a reference pointer in ConfigDialog
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
119 | connect (ui.quickColor_moveDown, SIGNAL (clicked()), this, SLOT (slot_moveColor())); |
b7aac3606b65
Make ui a reference pointer in ConfigDialog
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
120 | connect (ui.quickColor_clear, SIGNAL (clicked()), this, SLOT (slot_clearColors())); |
b7aac3606b65
Make ui a reference pointer in ConfigDialog
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
121 | connect (ui.findDownloadPath, SIGNAL (clicked (bool)), this, SLOT (slot_findDownloadFolder())); |
b7aac3606b65
Make ui a reference pointer in ConfigDialog
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
122 | connect (ui.buttonBox, SIGNAL (clicked (QAbstractButton*)), |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
123 | this, SLOT (buttonClicked (QAbstractButton*))); |
976
b7aac3606b65
Make ui a reference pointer in ConfigDialog
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
124 | connect (ui.m_pages, SIGNAL (currentChanged (int)), this, SLOT (selectPage (int))); |
b7aac3606b65
Make ui a reference pointer in ConfigDialog
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
125 | connect (ui.m_pagelist, SIGNAL (currentRowChanged (int)), this, SLOT (selectPage (int))); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
126 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
127 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
128 | ConfigDialog::~ConfigDialog() |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
129 | { |
976
b7aac3606b65
Make ui a reference pointer in ConfigDialog
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
130 | delete &ui; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
131 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
132 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
133 | void ConfigDialog::selectPage (int row) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
134 | { |
976
b7aac3606b65
Make ui a reference pointer in ConfigDialog
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
135 | ui.m_pagelist->setCurrentRow (row); |
b7aac3606b65
Make ui a reference pointer in ConfigDialog
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
136 | ui.m_pages->setCurrentIndex (row); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
137 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
138 | |
814
c8ef30fd0e54
- refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
806
diff
changeset
|
139 | // |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
140 | // Adds a shortcut entry to the list of shortcuts. |
814
c8ef30fd0e54
- refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
806
diff
changeset
|
141 | // |
806
4240f47aa2d4
- moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
795
diff
changeset
|
142 | void ConfigDialog::addShortcut (QAction* act) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
143 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
144 | ShortcutListItem* item = new ShortcutListItem; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
145 | item->setIcon (act->icon()); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
146 | item->setAction (act); |
806
4240f47aa2d4
- moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
795
diff
changeset
|
147 | item->setSequence (act->shortcut()); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
148 | setShortcutText (item); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
149 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
150 | // If the action doesn't have a valid icon, use an empty one |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
151 | // so that the list is kept aligned. |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
152 | if (act->icon().isNull()) |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
860
diff
changeset
|
153 | item->setIcon (GetIcon ("empty")); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
154 | |
976
b7aac3606b65
Make ui a reference pointer in ConfigDialog
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
155 | ui.shortcutsList->insertItem (ui.shortcutsList->count(), item); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
156 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
157 | |
814
c8ef30fd0e54
- refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
806
diff
changeset
|
158 | // |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
159 | // Initializes the stuff in the ext programs tab |
814
c8ef30fd0e54
- refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
806
diff
changeset
|
160 | // |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
161 | void ConfigDialog::initExtProgs() |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
162 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
163 | QGridLayout* pathsLayout = new QGridLayout; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
164 | int row = 0; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
165 | |
970
c8aae45afd85
Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
166 | for (int i = 0; i < NumExternalPrograms; ++i) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
167 | { |
970
c8aae45afd85
Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
168 | ExtProgramType program = (ExtProgramType) i; |
c8aae45afd85
Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
169 | ExternalProgramWidgets& widgets = m_externalProgramWidgets[i]; |
c8aae45afd85
Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
170 | QString name = m_window->externalPrograms()->externalProgramName (program); |
c8aae45afd85
Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
171 | QLabel* icon = new QLabel; |
c8aae45afd85
Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
172 | QLabel* progLabel = new QLabel (name); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
173 | QLineEdit* input = new QLineEdit; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
174 | QPushButton* setPathButton = new QPushButton; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
175 | |
970
c8aae45afd85
Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
176 | icon->setPixmap (GetIcon (name.toLower())); |
971
c00f9665a9f8
Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
970
diff
changeset
|
177 | input->setText (m_window->externalPrograms()->getPathSetting (program)); |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
860
diff
changeset
|
178 | setPathButton->setIcon (GetIcon ("folder")); |
970
c8aae45afd85
Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
179 | widgets.input = input; |
c8aae45afd85
Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
180 | widgets.setPathButton = setPathButton; |
c8aae45afd85
Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
181 | widgets.wineBox = nullptr; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
182 | connect (setPathButton, SIGNAL (clicked()), this, SLOT (slot_setExtProgPath())); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
183 | pathsLayout->addWidget (icon, row, 0); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
184 | pathsLayout->addWidget (progLabel, row, 1); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
185 | pathsLayout->addWidget (input, row, 2); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
186 | pathsLayout->addWidget (setPathButton, row, 3); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
187 | |
970
c8aae45afd85
Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
188 | #ifdef Q_OS_UNIX |
814
c8ef30fd0e54
- refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
806
diff
changeset
|
189 | { |
c8ef30fd0e54
- refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
806
diff
changeset
|
190 | QCheckBox* wineBox = new QCheckBox ("Wine"); |
970
c8aae45afd85
Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
191 | wineBox->setChecked (m_window->externalPrograms()->programUsesWine (program)); |
c8aae45afd85
Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
192 | widgets.wineBox = wineBox; |
814
c8ef30fd0e54
- refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
806
diff
changeset
|
193 | pathsLayout->addWidget (wineBox, row, 4); |
c8ef30fd0e54
- refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
806
diff
changeset
|
194 | } |
970
c8aae45afd85
Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
195 | #endif |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
196 | ++row; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
197 | } |
976
b7aac3606b65
Make ui a reference pointer in ConfigDialog
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
198 | ui.extProgs->setLayout (pathsLayout); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
199 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
200 | |
971
c00f9665a9f8
Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
970
diff
changeset
|
201 | void ConfigDialog::applyToWidgetOptions (std::function<void (QWidget*, QString)> func) |
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:
850
diff
changeset
|
202 | { |
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:
850
diff
changeset
|
203 | // Apply configuration |
860
a496e72af069
- more refactor, updated .hgignore
Teemu Piippo <crimsondusk64@gmail.com>
parents:
855
diff
changeset
|
204 | for (QWidget* widget : findChildren<QWidget*>()) |
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:
850
diff
changeset
|
205 | { |
860
a496e72af069
- more refactor, updated .hgignore
Teemu Piippo <crimsondusk64@gmail.com>
parents:
855
diff
changeset
|
206 | if (not widget->objectName().startsWith ("config")) |
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:
850
diff
changeset
|
207 | continue; |
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:
850
diff
changeset
|
208 | |
971
c00f9665a9f8
Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
970
diff
changeset
|
209 | QString optionname (widget->objectName().mid (strlen ("config"))); |
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:
850
diff
changeset
|
210 | |
972
a34b73114823
Now doesn't crash anymore
Teemu Piippo <crimsondusk64@gmail.com>
parents:
971
diff
changeset
|
211 | if (m_config->existsEntry (optionname)) |
971
c00f9665a9f8
Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
970
diff
changeset
|
212 | func (widget, optionname); |
c00f9665a9f8
Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
970
diff
changeset
|
213 | else |
c00f9665a9f8
Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
970
diff
changeset
|
214 | print ("Couldn't find configuration entry named %1", optionname); |
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:
850
diff
changeset
|
215 | } |
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:
850
diff
changeset
|
216 | } |
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:
850
diff
changeset
|
217 | |
814
c8ef30fd0e54
- refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
806
diff
changeset
|
218 | // |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
219 | // Set the settings based on widget data. |
814
c8ef30fd0e54
- refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
806
diff
changeset
|
220 | // |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
221 | void ConfigDialog::applySettings() |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
222 | { |
971
c00f9665a9f8
Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
970
diff
changeset
|
223 | applyToWidgetOptions ([&](QWidget* widget, QString confname) |
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:
850
diff
changeset
|
224 | { |
971
c00f9665a9f8
Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
970
diff
changeset
|
225 | QVariant value; |
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:
850
diff
changeset
|
226 | QLineEdit* le; |
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:
850
diff
changeset
|
227 | QSpinBox* spinbox; |
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:
850
diff
changeset
|
228 | QDoubleSpinBox* doublespinbox; |
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:
850
diff
changeset
|
229 | QSlider* slider; |
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:
850
diff
changeset
|
230 | QCheckBox* checkbox; |
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:
850
diff
changeset
|
231 | QPushButton* button; |
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:
850
diff
changeset
|
232 | |
860
a496e72af069
- more refactor, updated .hgignore
Teemu Piippo <crimsondusk64@gmail.com>
parents:
855
diff
changeset
|
233 | if ((le = qobject_cast<QLineEdit*> (widget)) != null) |
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:
850
diff
changeset
|
234 | value = le->text(); |
967 | 235 | else if ((spinbox = qobject_cast<QSpinBox*> (widget)) != null) |
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:
850
diff
changeset
|
236 | value = spinbox->value(); |
967 | 237 | else if ((doublespinbox = qobject_cast<QDoubleSpinBox*> (widget)) != null) |
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:
850
diff
changeset
|
238 | value = doublespinbox->value(); |
967 | 239 | else if ((slider = qobject_cast<QSlider*> (widget)) != null) |
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:
850
diff
changeset
|
240 | value = slider->value(); |
967 | 241 | else if ((checkbox = qobject_cast<QCheckBox*> (widget)) != null) |
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:
850
diff
changeset
|
242 | value = checkbox->isChecked(); |
967 | 243 | else if ((button = qobject_cast<QPushButton*> (widget)) != null) |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
860
diff
changeset
|
244 | value = m_buttonColors[button]; |
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:
850
diff
changeset
|
245 | else |
971
c00f9665a9f8
Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
970
diff
changeset
|
246 | { |
860
a496e72af069
- more refactor, updated .hgignore
Teemu Piippo <crimsondusk64@gmail.com>
parents:
855
diff
changeset
|
247 | print ("Unknown widget of type %1\n", widget->metaObject()->className()); |
971
c00f9665a9f8
Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
970
diff
changeset
|
248 | return; |
c00f9665a9f8
Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
970
diff
changeset
|
249 | } |
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:
850
diff
changeset
|
250 | |
971
c00f9665a9f8
Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
970
diff
changeset
|
251 | m_settings->setValue (confname, value); |
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:
850
diff
changeset
|
252 | }); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
253 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
254 | // Rebuild the quick color toolbar |
970
c8aae45afd85
Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
255 | m_window->setQuickColors (quickColors); |
971
c00f9665a9f8
Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
970
diff
changeset
|
256 | m_config->setQuickColorToolbar (quickColorString()); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
257 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
258 | // Ext program settings |
970
c8aae45afd85
Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
259 | for (int i = 0; i < NumExternalPrograms; ++i) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
260 | { |
970
c8aae45afd85
Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
261 | ExtProgramType program = (ExtProgramType) i; |
c8aae45afd85
Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
262 | ExtProgramToolset* toolset = m_window->externalPrograms(); |
c8aae45afd85
Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
263 | ExternalProgramWidgets& widgets = m_externalProgramWidgets[i]; |
c8aae45afd85
Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
264 | toolset->getPathSetting (program) = widgets.input->text(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
265 | |
970
c8aae45afd85
Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
266 | if (widgets.wineBox) |
971
c00f9665a9f8
Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
970
diff
changeset
|
267 | toolset->setWineSetting (program, widgets.wineBox->isChecked()); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
268 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
269 | |
806
4240f47aa2d4
- moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
795
diff
changeset
|
270 | // Apply shortcuts |
976
b7aac3606b65
Make ui a reference pointer in ConfigDialog
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
271 | for (int i = 0; i < ui.shortcutsList->count(); ++i) |
806
4240f47aa2d4
- moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
795
diff
changeset
|
272 | { |
976
b7aac3606b65
Make ui a reference pointer in ConfigDialog
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
273 | auto item = static_cast<ShortcutListItem*> (ui.shortcutsList->item (i)); |
806
4240f47aa2d4
- moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
795
diff
changeset
|
274 | item->action()->setShortcut (item->sequence()); |
4240f47aa2d4
- moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
795
diff
changeset
|
275 | } |
4240f47aa2d4
- moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
795
diff
changeset
|
276 | |
971
c00f9665a9f8
Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
970
diff
changeset
|
277 | m_window->syncSettings(); |
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
976
diff
changeset
|
278 | currentDocument()->reloadAllSubfiles(); |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
860
diff
changeset
|
279 | LoadLogoStuds(); |
970
c8aae45afd85
Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
280 | m_window->R()->setBackground(); |
c8aae45afd85
Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
281 | m_window->doFullRefresh(); |
c8aae45afd85
Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
282 | m_window->updateDocumentList(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
283 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
284 | |
814
c8ef30fd0e54
- refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
806
diff
changeset
|
285 | // |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
286 | // A dialog button was clicked |
814
c8ef30fd0e54
- refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
806
diff
changeset
|
287 | // |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
288 | void ConfigDialog::buttonClicked (QAbstractButton* button) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
289 | { |
976
b7aac3606b65
Make ui a reference pointer in ConfigDialog
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
290 | QDialogButtonBox* dbb = ui.buttonBox; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
291 | |
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:
850
diff
changeset
|
292 | if (button == dbb->button (QDialogButtonBox::Ok)) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
293 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
294 | applySettings(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
295 | accept(); |
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:
850
diff
changeset
|
296 | } |
967 | 297 | else if (button == dbb->button (QDialogButtonBox::Apply)) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
298 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
299 | applySettings(); |
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:
850
diff
changeset
|
300 | } |
967 | 301 | else if (button == dbb->button (QDialogButtonBox::Cancel)) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
302 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
303 | reject(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
304 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
305 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
306 | |
814
c8ef30fd0e54
- refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
806
diff
changeset
|
307 | // |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
308 | // Update the list of color toolbar items in the quick color tab. |
814
c8ef30fd0e54
- refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
806
diff
changeset
|
309 | // |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
310 | void ConfigDialog::updateQuickColorList (LDQuickColor* sel) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
311 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
312 | for (QListWidgetItem * item : quickColorItems) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
313 | delete item; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
314 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
315 | quickColorItems.clear(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
316 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
317 | // Init table items |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
318 | for (LDQuickColor& entry : quickColors) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
319 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
320 | QListWidgetItem* item = new QListWidgetItem; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
321 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
322 | if (entry.isSeparator()) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
323 | { |
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:
850
diff
changeset
|
324 | item->setText ("<hr />"); |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
860
diff
changeset
|
325 | item->setIcon (GetIcon ("empty")); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
326 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
327 | else |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
328 | { |
946 | 329 | LDColor color = entry.color(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
330 | |
946 | 331 | if (color.isValid()) |
332 | { | |
333 | item->setText (color.name()); | |
974
b2fa5f89798a
Added a GuiUtilities class to contain useful non-MainWindow-related GUI functions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
972
diff
changeset
|
334 | item->setIcon (guiUtilities()->makeColorIcon (color, 16)); |
946 | 335 | } |
336 | else | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
337 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
338 | item->setText ("[[unknown color]]"); |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
860
diff
changeset
|
339 | item->setIcon (GetIcon ("error")); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
340 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
341 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
342 | |
976
b7aac3606b65
Make ui a reference pointer in ConfigDialog
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
343 | ui.quickColorList->addItem (item); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
344 | quickColorItems << item; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
345 | |
840
d077dd19bf9a
- changed `&&` and `||` operators to their named variants `and` and `or`
Teemu Piippo <crimsondusk64@gmail.com>
parents:
814
diff
changeset
|
346 | if (sel and &entry == sel) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
347 | { |
976
b7aac3606b65
Make ui a reference pointer in ConfigDialog
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
348 | ui.quickColorList->setCurrentItem (item); |
b7aac3606b65
Make ui a reference pointer in ConfigDialog
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
349 | ui.quickColorList->scrollToItem (item); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
350 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
351 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
352 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
353 | |
814
c8ef30fd0e54
- refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
806
diff
changeset
|
354 | // |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
355 | // Quick colors: add or edit button was clicked. |
814
c8ef30fd0e54
- refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
806
diff
changeset
|
356 | // |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
357 | void ConfigDialog::slot_setColor() |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
358 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
359 | LDQuickColor* entry = null; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
360 | QListWidgetItem* item = null; |
976
b7aac3606b65
Make ui a reference pointer in ConfigDialog
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
361 | const bool isNew = static_cast<QPushButton*> (sender()) == ui.quickColor_add; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
362 | |
662
2f1bd9112408
- use the keyword 'not' in place of the exclamation mark for operator!, this is clearer. also converted uses of '== false' to this.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
363 | if (not isNew) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
364 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
365 | item = getSelectedQuickColor(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
366 | |
662
2f1bd9112408
- use the keyword 'not' in place of the exclamation mark for operator!, this is clearer. also converted uses of '== false' to this.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
367 | if (not item) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
368 | return; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
369 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
370 | int i = getItemRow (item, quickColorItems); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
371 | entry = &quickColors[i]; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
372 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
373 | if (entry->isSeparator() == true) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
374 | return; // don't color separators |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
375 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
376 | |
946 | 377 | LDColor defaultValue = entry ? entry->color() : LDColor::nullColor(); |
378 | LDColor value; | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
379 | |
971
c00f9665a9f8
Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
970
diff
changeset
|
380 | if (not ColorSelector::selectColor (this, value, defaultValue)) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
381 | return; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
382 | |
860
a496e72af069
- more refactor, updated .hgignore
Teemu Piippo <crimsondusk64@gmail.com>
parents:
855
diff
changeset
|
383 | if (entry != null) |
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:
850
diff
changeset
|
384 | { |
946 | 385 | entry->setColor (value); |
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:
850
diff
changeset
|
386 | } |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
387 | else |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
388 | { |
946 | 389 | LDQuickColor newentry (value, null); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
390 | item = getSelectedQuickColor(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
391 | int idx = (item) ? getItemRow (item, quickColorItems) + 1 : quickColorItems.size(); |
946 | 392 | quickColors.insert (idx, newentry); |
393 | entry = &quickColors[idx]; | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
394 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
395 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
396 | updateQuickColorList (entry); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
397 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
398 | |
814
c8ef30fd0e54
- refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
806
diff
changeset
|
399 | // |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
400 | // Remove a quick color |
814
c8ef30fd0e54
- refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
806
diff
changeset
|
401 | // |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
402 | void ConfigDialog::slot_delColor() |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
403 | { |
976
b7aac3606b65
Make ui a reference pointer in ConfigDialog
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
404 | if (ui.quickColorList->selectedItems().isEmpty()) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
405 | return; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
406 | |
976
b7aac3606b65
Make ui a reference pointer in ConfigDialog
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
407 | QListWidgetItem* item = ui.quickColorList->selectedItems() [0]; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
408 | quickColors.removeAt (getItemRow (item, quickColorItems)); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
409 | updateQuickColorList(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
410 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
411 | |
814
c8ef30fd0e54
- refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
806
diff
changeset
|
412 | // |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
413 | // Move a quick color up/down |
814
c8ef30fd0e54
- refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
806
diff
changeset
|
414 | // |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
415 | void ConfigDialog::slot_moveColor() |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
416 | { |
976
b7aac3606b65
Make ui a reference pointer in ConfigDialog
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
417 | const bool up = (static_cast<QPushButton*> (sender()) == ui.quickColor_moveUp); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
418 | |
976
b7aac3606b65
Make ui a reference pointer in ConfigDialog
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
419 | if (ui.quickColorList->selectedItems().isEmpty()) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
420 | return; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
421 | |
976
b7aac3606b65
Make ui a reference pointer in ConfigDialog
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
422 | QListWidgetItem* item = ui.quickColorList->selectedItems() [0]; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
423 | int idx = getItemRow (item, quickColorItems); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
424 | int dest = up ? (idx - 1) : (idx + 1); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
425 | |
840
d077dd19bf9a
- changed `&&` and `||` operators to their named variants `and` and `or`
Teemu Piippo <crimsondusk64@gmail.com>
parents:
814
diff
changeset
|
426 | if (dest < 0 or dest >= quickColorItems.size()) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
427 | return; // destination out of bounds |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
428 | |
860
a496e72af069
- more refactor, updated .hgignore
Teemu Piippo <crimsondusk64@gmail.com>
parents:
855
diff
changeset
|
429 | qSwap (quickColors[dest], quickColors[idx]); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
430 | updateQuickColorList (&quickColors[dest]); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
431 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
432 | |
814
c8ef30fd0e54
- refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
806
diff
changeset
|
433 | // |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
434 | // |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
435 | // Add a separator to quick colors |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
436 | // |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
437 | void ConfigDialog::slot_addColorSeparator() |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
438 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
439 | quickColors << LDQuickColor::getSeparator(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
440 | updateQuickColorList (&quickColors[quickColors.size() - 1]); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
441 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
442 | |
814
c8ef30fd0e54
- refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
806
diff
changeset
|
443 | // |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
444 | // |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
445 | // Clear all quick colors |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
446 | // |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
447 | void ConfigDialog::slot_clearColors() |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
448 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
449 | quickColors.clear(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
450 | updateQuickColorList(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
451 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
452 | |
814
c8ef30fd0e54
- refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
806
diff
changeset
|
453 | // |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
454 | // |
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:
850
diff
changeset
|
455 | void ConfigDialog::setButtonColor() |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
456 | { |
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:
850
diff
changeset
|
457 | QPushButton* button = qobject_cast<QPushButton*> (sender()); |
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:
850
diff
changeset
|
458 | |
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:
850
diff
changeset
|
459 | if (button == null) |
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:
850
diff
changeset
|
460 | { |
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:
850
diff
changeset
|
461 | print ("setButtonColor: null sender!\n"); |
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:
850
diff
changeset
|
462 | return; |
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:
850
diff
changeset
|
463 | } |
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:
850
diff
changeset
|
464 | |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
860
diff
changeset
|
465 | QColor color = QColorDialog::getColor (m_buttonColors[button]); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
466 | |
860
a496e72af069
- more refactor, updated .hgignore
Teemu Piippo <crimsondusk64@gmail.com>
parents:
855
diff
changeset
|
467 | if (color.isValid()) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
468 | { |
860
a496e72af069
- more refactor, updated .hgignore
Teemu Piippo <crimsondusk64@gmail.com>
parents:
855
diff
changeset
|
469 | QString colorname; |
a496e72af069
- more refactor, updated .hgignore
Teemu Piippo <crimsondusk64@gmail.com>
parents:
855
diff
changeset
|
470 | colorname.sprintf ("#%.2X%.2X%.2X", color.red(), color.green(), color.blue()); |
a496e72af069
- more refactor, updated .hgignore
Teemu Piippo <crimsondusk64@gmail.com>
parents:
855
diff
changeset
|
471 | setButtonBackground (button, colorname); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
472 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
473 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
474 | |
814
c8ef30fd0e54
- refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
806
diff
changeset
|
475 | // |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
476 | // Sets background color of a given button. |
814
c8ef30fd0e54
- refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
806
diff
changeset
|
477 | // |
789
4b7306f52bb5
- String -> QString
Santeri Piippo <crimsondusk64@gmail.com>
parents:
780
diff
changeset
|
478 | void ConfigDialog::setButtonBackground (QPushButton* button, QString value) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
479 | { |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
860
diff
changeset
|
480 | button->setIcon (GetIcon ("colorselect")); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
481 | button->setAutoFillBackground (true); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
482 | button->setStyleSheet (format ("background-color: %1", value)); |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
860
diff
changeset
|
483 | m_buttonColors[button] = QColor (value); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
484 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
485 | |
814
c8ef30fd0e54
- refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
806
diff
changeset
|
486 | // |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
487 | // Finds the given list widget item in the list of widget items given. |
814
c8ef30fd0e54
- refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
806
diff
changeset
|
488 | // |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
489 | int ConfigDialog::getItemRow (QListWidgetItem* item, QList<QListWidgetItem*>& haystack) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
490 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
491 | int i = 0; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
492 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
493 | for (QListWidgetItem* it : haystack) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
494 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
495 | if (it == item) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
496 | return i; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
497 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
498 | ++i; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
499 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
500 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
501 | return -1; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
502 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
503 | |
814
c8ef30fd0e54
- refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
806
diff
changeset
|
504 | // |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
505 | // Which quick color is currently selected? |
814
c8ef30fd0e54
- refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
806
diff
changeset
|
506 | // |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
507 | QListWidgetItem* ConfigDialog::getSelectedQuickColor() |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
508 | { |
976
b7aac3606b65
Make ui a reference pointer in ConfigDialog
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
509 | if (ui.quickColorList->selectedItems().isEmpty()) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
510 | return null; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
511 | |
976
b7aac3606b65
Make ui a reference pointer in ConfigDialog
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
512 | return ui.quickColorList->selectedItems() [0]; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
513 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
514 | |
814
c8ef30fd0e54
- refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
806
diff
changeset
|
515 | // |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
516 | // Get the list of shortcuts selected |
814
c8ef30fd0e54
- refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
806
diff
changeset
|
517 | // |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
518 | QList<ShortcutListItem*> ConfigDialog::getShortcutSelection() |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
519 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
520 | QList<ShortcutListItem*> out; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
521 | |
976
b7aac3606b65
Make ui a reference pointer in ConfigDialog
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
522 | for (QListWidgetItem* entry : ui.shortcutsList->selectedItems()) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
523 | out << static_cast<ShortcutListItem*> (entry); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
524 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
525 | return out; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
526 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
527 | |
814
c8ef30fd0e54
- refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
806
diff
changeset
|
528 | // |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
529 | // Edit the shortcut of a given action. |
814
c8ef30fd0e54
- refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
806
diff
changeset
|
530 | // |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
531 | void ConfigDialog::slot_setShortcut() |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
532 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
533 | QList<ShortcutListItem*> sel = getShortcutSelection(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
534 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
535 | if (sel.size() < 1) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
536 | return; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
537 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
538 | ShortcutListItem* item = sel[0]; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
539 | |
806
4240f47aa2d4
- moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
795
diff
changeset
|
540 | if (KeySequenceDialog::staticDialog (item, this)) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
541 | setShortcutText (item); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
542 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
543 | |
814
c8ef30fd0e54
- refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
806
diff
changeset
|
544 | // |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
545 | // Reset a shortcut to defaults |
814
c8ef30fd0e54
- refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
806
diff
changeset
|
546 | // |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
547 | void ConfigDialog::slot_resetShortcut() |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
548 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
549 | QList<ShortcutListItem*> sel = getShortcutSelection(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
550 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
551 | for (ShortcutListItem* item : sel) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
552 | { |
806
4240f47aa2d4
- moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
795
diff
changeset
|
553 | item->setSequence (MainWindow::defaultShortcut (item->action())); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
554 | setShortcutText (item); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
555 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
556 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
557 | |
814
c8ef30fd0e54
- refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
806
diff
changeset
|
558 | // |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
559 | // Remove the shortcut of an action. |
814
c8ef30fd0e54
- refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
806
diff
changeset
|
560 | // |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
561 | void ConfigDialog::slot_clearShortcut() |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
562 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
563 | QList<ShortcutListItem*> sel = getShortcutSelection(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
564 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
565 | for (ShortcutListItem* item : sel) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
566 | { |
806
4240f47aa2d4
- moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
795
diff
changeset
|
567 | item->setSequence (QKeySequence()); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
568 | setShortcutText (item); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
569 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
570 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
571 | |
814
c8ef30fd0e54
- refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
806
diff
changeset
|
572 | // |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
573 | // Set the path of an external program |
814
c8ef30fd0e54
- refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
806
diff
changeset
|
574 | // |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
575 | void ConfigDialog::slot_setExtProgPath() |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
576 | { |
970
c8aae45afd85
Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
577 | ExtProgramType program = NumExternalPrograms; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
578 | |
970
c8aae45afd85
Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
579 | for (int i = 0; i < NumExternalPrograms; ++i) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
580 | { |
970
c8aae45afd85
Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
581 | if (m_externalProgramWidgets[i].setPathButton == sender()) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
582 | { |
970
c8aae45afd85
Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
583 | program = (ExtProgramType) i; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
584 | break; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
585 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
586 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
587 | |
970
c8aae45afd85
Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
588 | if (program != NumExternalPrograms) |
958
1dc890c73e01
Removed all asserts from the code. Removed assert handling and the bomb box dialog.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
952
diff
changeset
|
589 | { |
970
c8aae45afd85
Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
590 | ExtProgramToolset* toolset = m_window->externalPrograms(); |
c8aae45afd85
Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
591 | ExternalProgramWidgets& widgets = m_externalProgramWidgets[program]; |
958
1dc890c73e01
Removed all asserts from the code. Removed assert handling and the bomb box dialog.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
952
diff
changeset
|
592 | QString filepath = QFileDialog::getOpenFileName (this, |
970
c8aae45afd85
Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
593 | format ("Path to %1", toolset->externalProgramName (program)), |
c8aae45afd85
Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
594 | widgets.input->text(), g_extProgPathFilter); |
958
1dc890c73e01
Removed all asserts from the code. Removed assert handling and the bomb box dialog.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
952
diff
changeset
|
595 | |
1dc890c73e01
Removed all asserts from the code. Removed assert handling and the bomb box dialog.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
952
diff
changeset
|
596 | if (filepath.isEmpty()) |
1dc890c73e01
Removed all asserts from the code. Removed assert handling and the bomb box dialog.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
952
diff
changeset
|
597 | return; |
1dc890c73e01
Removed all asserts from the code. Removed assert handling and the bomb box dialog.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
952
diff
changeset
|
598 | |
970
c8aae45afd85
Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
599 | widgets.input->setText (filepath); |
958
1dc890c73e01
Removed all asserts from the code. Removed assert handling and the bomb box dialog.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
952
diff
changeset
|
600 | } |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
601 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
602 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
603 | // |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
604 | // '...' button pressed for the download path |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
605 | // |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
606 | void ConfigDialog::slot_findDownloadFolder() |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
607 | { |
789
4b7306f52bb5
- String -> QString
Santeri Piippo <crimsondusk64@gmail.com>
parents:
780
diff
changeset
|
608 | QString dpath = QFileDialog::getExistingDirectory(); |
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:
850
diff
changeset
|
609 | |
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:
850
diff
changeset
|
610 | if (not dpath.isEmpty()) |
976
b7aac3606b65
Make ui a reference pointer in ConfigDialog
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
611 | ui.configDownloadFilePath->setText (dpath); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
612 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
613 | |
814
c8ef30fd0e54
- refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
806
diff
changeset
|
614 | // |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
615 | // |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
616 | // Updates the text string for a given shortcut list item |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
617 | // |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
618 | void ConfigDialog::setShortcutText (ShortcutListItem* item) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
619 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
620 | QAction* act = item->action(); |
789
4b7306f52bb5
- String -> QString
Santeri Piippo <crimsondusk64@gmail.com>
parents:
780
diff
changeset
|
621 | QString label = act->iconText(); |
806
4240f47aa2d4
- moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
795
diff
changeset
|
622 | QString keybind = item->sequence().toString(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
623 | item->setText (format ("%1 (%2)", label, keybind)); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
624 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
625 | |
814
c8ef30fd0e54
- refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
806
diff
changeset
|
626 | // |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
627 | // Gets the configuration string of the quick color toolbar |
814
c8ef30fd0e54
- refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
806
diff
changeset
|
628 | // |
789
4b7306f52bb5
- String -> QString
Santeri Piippo <crimsondusk64@gmail.com>
parents:
780
diff
changeset
|
629 | QString ConfigDialog::quickColorString() |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
630 | { |
789
4b7306f52bb5
- String -> QString
Santeri Piippo <crimsondusk64@gmail.com>
parents:
780
diff
changeset
|
631 | QString val; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
632 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
633 | for (const LDQuickColor& entry : quickColors) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
634 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
635 | if (val.length() > 0) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
636 | val += ':'; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
637 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
638 | if (entry.isSeparator()) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
639 | val += '|'; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
640 | else |
806
4240f47aa2d4
- moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
795
diff
changeset
|
641 | val += format ("%1", entry.color().index()); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
642 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
643 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
644 | return val; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
645 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
646 | |
814
c8ef30fd0e54
- refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
806
diff
changeset
|
647 | // |
c8ef30fd0e54
- refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
806
diff
changeset
|
648 | // |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
649 | KeySequenceDialog::KeySequenceDialog (QKeySequence seq, QWidget* parent, Qt::WindowFlags f) : |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
650 | QDialog (parent, f), seq (seq) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
651 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
652 | lb_output = new QLabel; |
964 | 653 | |
654 | bbx_buttons = new QDialogButtonBox (QDialogButtonBox::Ok | QDialogButtonBox::Cancel); \ | |
655 | connect (bbx_buttons, SIGNAL (accepted()), this, SLOT (accept())); \ | |
656 | connect (bbx_buttons, SIGNAL (rejected()), this, SLOT (reject())); \ | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
657 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
658 | setWhatsThis (tr ("Into this dialog you can input a key sequence for use as a " |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
659 | "shortcut in LDForge. Use OK to confirm the new shortcut and Cancel to " |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
660 | "dismiss.")); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
661 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
662 | QVBoxLayout* layout = new QVBoxLayout; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
663 | layout->addWidget (lb_output); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
664 | layout->addWidget (bbx_buttons); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
665 | setLayout (layout); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
666 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
667 | updateOutput(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
668 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
669 | |
814
c8ef30fd0e54
- refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
806
diff
changeset
|
670 | // |
c8ef30fd0e54
- refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
806
diff
changeset
|
671 | // |
806
4240f47aa2d4
- moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
795
diff
changeset
|
672 | bool KeySequenceDialog::staticDialog (ShortcutListItem* item, QWidget* parent) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
673 | { |
806
4240f47aa2d4
- moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
795
diff
changeset
|
674 | KeySequenceDialog dlg (item->sequence(), parent); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
675 | |
662
2f1bd9112408
- use the keyword 'not' in place of the exclamation mark for operator!, this is clearer. also converted uses of '== false' to this.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
676 | if (dlg.exec() == QDialog::Rejected) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
677 | return false; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
678 | |
806
4240f47aa2d4
- moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
795
diff
changeset
|
679 | item->setSequence (dlg.seq); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
680 | return true; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
681 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
682 | |
814
c8ef30fd0e54
- refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
806
diff
changeset
|
683 | // |
c8ef30fd0e54
- refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
806
diff
changeset
|
684 | // |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
685 | void KeySequenceDialog::updateOutput() |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
686 | { |
789
4b7306f52bb5
- String -> QString
Santeri Piippo <crimsondusk64@gmail.com>
parents:
780
diff
changeset
|
687 | QString shortcut = seq.toString(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
688 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
689 | if (seq == QKeySequence()) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
690 | shortcut = "<empty>"; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
691 | |
789
4b7306f52bb5
- String -> QString
Santeri Piippo <crimsondusk64@gmail.com>
parents:
780
diff
changeset
|
692 | QString text = format ("<center><b>%1</b></center>", shortcut); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
693 | lb_output->setText (text); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
694 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
695 | |
814
c8ef30fd0e54
- refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
806
diff
changeset
|
696 | // |
c8ef30fd0e54
- refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
806
diff
changeset
|
697 | // |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
698 | void KeySequenceDialog::keyPressEvent (QKeyEvent* ev) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
699 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
700 | seq = ev->key() + ev->modifiers(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
701 | updateOutput(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
702 | } |