src/dialogs/configdialog.cpp

Mon, 04 Jun 2018 23:22:52 +0300

author
Teemu Piippo <teemu@hecknology.net>
date
Mon, 04 Jun 2018 23:22:52 +0300
changeset 1392
0541d9b21968
parent 1382
6f31a87006f2
child 1419
f7c53002a990
permissions
-rw-r--r--

fix compiler warnings

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
1326
69a90bd2dba2 Happy new year 2018
Teemu Piippo <teemu@hecknology.net>
parents: 1323
diff changeset
3 * Copyright (C) 2013 - 2018 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"
1145
02264bf0108d Renamed ldDocument.cpp → lddocument.cpp
Teemu Piippo <teemu@hecknology.net>
parents: 1115
diff changeset
35 #include "../lddocument.h"
1308
dcc8c02530c2 Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents: 1263
diff changeset
36 #include "../librariesmodel.h"
1103
ac7db4c076c3 Created a new GLRenderer derivative class "Canvas" and made MainWindow use it
Teemu Piippo <teemu@hecknology.net>
parents: 1072
diff changeset
37 #include "../canvas.h"
975
24ba5aa3393f Move ConfigDialog into src/dialogs/ subfolder
Teemu Piippo <crimsondusk64@gmail.com>
parents: 974
diff changeset
38 #include "../guiutilities.h"
998
5be0ce31ce60 Now compiles again
Teemu Piippo <crimsondusk64@gmail.com>
parents: 997
diff changeset
39 #include "../documentmanager.h"
975
24ba5aa3393f Move ConfigDialog into src/dialogs/ subfolder
Teemu Piippo <crimsondusk64@gmail.com>
parents: 974
diff changeset
40 #include "colorselector.h"
24ba5aa3393f Move ConfigDialog into src/dialogs/ subfolder
Teemu Piippo <crimsondusk64@gmail.com>
parents: 974
diff changeset
41 #include "configdialog.h"
24ba5aa3393f Move ConfigDialog into src/dialogs/ subfolder
Teemu Piippo <crimsondusk64@gmail.com>
parents: 974
diff changeset
42 #include "ui_configdialog.h"
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
43
1115
117e4880666e Cleaned up ExternalProgramPathDialog
Teemu Piippo <teemu@hecknology.net>
parents: 1114
diff changeset
44 const char* const ConfigDialog::externalProgramPathFilter =
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
45 #ifdef _WIN32
814
c8ef30fd0e54 - refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 806
diff changeset
46 "Applications (*.exe)(*.exe);;"
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
47 #endif
814
c8ef30fd0e54 - refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 806
diff changeset
48 "All files (*.*)(*.*)";
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
49
1010
969b48eddd6b A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 998
diff changeset
50 ShortcutListItem::ShortcutListItem (QListWidget* view, int type) :
969b48eddd6b A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 998
diff changeset
51 QListWidgetItem (view, type) {}
969b48eddd6b A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 998
diff changeset
52
969b48eddd6b A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 998
diff changeset
53 QAction* ShortcutListItem::action() const
969b48eddd6b A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 998
diff changeset
54 {
969b48eddd6b A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 998
diff changeset
55 return m_action;
969b48eddd6b A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 998
diff changeset
56 }
969b48eddd6b A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 998
diff changeset
57
969b48eddd6b A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 998
diff changeset
58 void ShortcutListItem::setAction (QAction* action)
969b48eddd6b A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 998
diff changeset
59 {
969b48eddd6b A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 998
diff changeset
60 m_action = action;
969b48eddd6b A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 998
diff changeset
61 }
969b48eddd6b A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 998
diff changeset
62
969b48eddd6b A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 998
diff changeset
63 QKeySequence ShortcutListItem::sequence() const
969b48eddd6b A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 998
diff changeset
64 {
969b48eddd6b A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 998
diff changeset
65 return m_sequence;
969b48eddd6b A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 998
diff changeset
66 }
969b48eddd6b A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 998
diff changeset
67
969b48eddd6b A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 998
diff changeset
68 void ShortcutListItem::setSequence (const QKeySequence& sequence)
969b48eddd6b A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 998
diff changeset
69 {
969b48eddd6b A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 998
diff changeset
70 m_sequence = sequence;
969b48eddd6b A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 998
diff changeset
71 }
969b48eddd6b A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 998
diff changeset
72
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
73 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
74 QDialog (parent, f),
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
75 HierarchyElement (parent),
976
b7aac3606b65 Make ui a reference pointer in ConfigDialog
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
76 ui (*new Ui_ConfigDialog),
1392
0541d9b21968 fix compiler warnings
Teemu Piippo <teemu@hecknology.net>
parents: 1382
diff changeset
77 librariesModel {new LibrariesModel {this->libraries, this}},
0541d9b21968 fix compiler warnings
Teemu Piippo <teemu@hecknology.net>
parents: 1382
diff changeset
78 libraries {config::libraries()}
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
79 {
976
b7aac3606b65 Make ui a reference pointer in ConfigDialog
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
80 ui.setupUi (this);
1308
dcc8c02530c2 Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents: 1263
diff changeset
81 ui.librariesView->setModel(this->librariesModel);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
82
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
83 // Set defaults
1023
9450ac3cd930 Split grid stuff into a new class Grid in grid.cpp/grid.h
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1017
diff changeset
84 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
85 {
1323
05b3e173c900 Config is now a namespace
Teemu Piippo <teemu@hecknology.net>
parents: 1319
diff changeset
86 QVariant value = ::settingsObject().value(confname, config::defaults().value(confname));
1023
9450ac3cd930 Split grid stuff into a new class Grid in grid.cpp/grid.h
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1017
diff changeset
87 QLineEdit* lineedit;
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
88 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
89 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
90 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
91 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
92 QPushButton* button;
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
93
1023
9450ac3cd930 Split grid stuff into a new class Grid in grid.cpp/grid.h
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1017
diff changeset
94 if ((lineedit = qobject_cast<QLineEdit*> (widget)))
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
95 {
1023
9450ac3cd930 Split grid stuff into a new class Grid in grid.cpp/grid.h
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1017
diff changeset
96 lineedit->setText (value.toString());
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 }
985
ed7b31b9f904 Remove "!= nullptr" expressions
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
98 else if ((spinbox = qobject_cast<QSpinBox*> (widget)))
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
99 {
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
100 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
101 }
985
ed7b31b9f904 Remove "!= nullptr" expressions
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
102 else if ((doublespinbox = qobject_cast<QDoubleSpinBox*> (widget)))
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
103 {
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
104 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
105 }
985
ed7b31b9f904 Remove "!= nullptr" expressions
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
106 else if ((slider = qobject_cast<QSlider*> (widget)))
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
107 {
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 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
109 }
985
ed7b31b9f904 Remove "!= nullptr" expressions
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
110 else if ((checkbox = qobject_cast<QCheckBox*> (widget)))
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
111 {
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
112 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
113 }
985
ed7b31b9f904 Remove "!= nullptr" expressions
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
114 else if ((button = qobject_cast<QPushButton*> (widget)))
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
115 {
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
116 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
117 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
118 }
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
119 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
120 {
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
121 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
122 }
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
123 });
780
b0d84fb70ea5 - made coordinate rounding precision configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents: 760
diff changeset
124
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
125 m_window->applyToActions ([&](QAction* act)
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
126 {
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
127 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
128 });
655
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 ui.shortcutsList->setSortingEnabled (true);
b7aac3606b65 Make ui a reference pointer in ConfigDialog
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
131 ui.shortcutsList->sortItems();
1017
fc1c13db9618 Renamed ConfigurationValueBag to Configuration and added a pointer to it into HierarchyElement. This helps with the fight against global variables.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1014
diff changeset
132 quickColors = guiUtilities()->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
133 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
134 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
135 selectPage (defaulttab);
976
b7aac3606b65 Make ui a reference pointer in ConfigDialog
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
136 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
137 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
138 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
139 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
140 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
141 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
142 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
143 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
144 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
145 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
146 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
147 connect (ui.buttonBox, SIGNAL (clicked (QAbstractButton*)),
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
148 this, SLOT (buttonClicked (QAbstractButton*)));
976
b7aac3606b65 Make ui a reference pointer in ConfigDialog
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
149 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
150 connect (ui.m_pagelist, SIGNAL (currentRowChanged (int)), this, SLOT (selectPage (int)));
1308
dcc8c02530c2 Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents: 1263
diff changeset
151 connect(
dcc8c02530c2 Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents: 1263
diff changeset
152 this->ui.addLibrary,
dcc8c02530c2 Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents: 1263
diff changeset
153 &QPushButton::clicked,
dcc8c02530c2 Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents: 1263
diff changeset
154 [&]()
dcc8c02530c2 Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents: 1263
diff changeset
155 {
dcc8c02530c2 Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents: 1263
diff changeset
156 this->librariesModel->insertRow(this->librariesModel->rowCount());
dcc8c02530c2 Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents: 1263
diff changeset
157 }
dcc8c02530c2 Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents: 1263
diff changeset
158 );
dcc8c02530c2 Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents: 1263
diff changeset
159 connect(
dcc8c02530c2 Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents: 1263
diff changeset
160 this->ui.removeLibrary,
dcc8c02530c2 Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents: 1263
diff changeset
161 &QPushButton::clicked,
dcc8c02530c2 Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents: 1263
diff changeset
162 [&]()
dcc8c02530c2 Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents: 1263
diff changeset
163 {
dcc8c02530c2 Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents: 1263
diff changeset
164 QModelIndex index = this->ui.librariesView->currentIndex();
dcc8c02530c2 Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents: 1263
diff changeset
165
dcc8c02530c2 Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents: 1263
diff changeset
166 if (index.isValid())
dcc8c02530c2 Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents: 1263
diff changeset
167 this->librariesModel->removeRow(index.row());
dcc8c02530c2 Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents: 1263
diff changeset
168 }
dcc8c02530c2 Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents: 1263
diff changeset
169 );
dcc8c02530c2 Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents: 1263
diff changeset
170 connect(
dcc8c02530c2 Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents: 1263
diff changeset
171 this->ui.moveLibraryUp,
dcc8c02530c2 Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents: 1263
diff changeset
172 &QPushButton::clicked,
dcc8c02530c2 Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents: 1263
diff changeset
173 [&]()
dcc8c02530c2 Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents: 1263
diff changeset
174 {
dcc8c02530c2 Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents: 1263
diff changeset
175 QModelIndex index = this->ui.librariesView->currentIndex();
dcc8c02530c2 Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents: 1263
diff changeset
176
dcc8c02530c2 Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents: 1263
diff changeset
177 if (index.isValid())
dcc8c02530c2 Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents: 1263
diff changeset
178 this->librariesModel->moveRows({}, index.row(), 1, {}, index.row() - 1);
dcc8c02530c2 Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents: 1263
diff changeset
179 }
dcc8c02530c2 Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents: 1263
diff changeset
180 );
dcc8c02530c2 Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents: 1263
diff changeset
181 connect(
dcc8c02530c2 Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents: 1263
diff changeset
182 this->ui.moveLibraryDown,
dcc8c02530c2 Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents: 1263
diff changeset
183 &QPushButton::clicked,
dcc8c02530c2 Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents: 1263
diff changeset
184 [&]()
dcc8c02530c2 Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents: 1263
diff changeset
185 {
dcc8c02530c2 Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents: 1263
diff changeset
186 QModelIndex index = this->ui.librariesView->currentIndex();
dcc8c02530c2 Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents: 1263
diff changeset
187
dcc8c02530c2 Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents: 1263
diff changeset
188 if (index.isValid())
dcc8c02530c2 Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents: 1263
diff changeset
189 this->librariesModel->moveRows({}, index.row(), 1, {}, index.row() + 2);
dcc8c02530c2 Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents: 1263
diff changeset
190 }
dcc8c02530c2 Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents: 1263
diff changeset
191 );
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
192 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
193
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
194 ConfigDialog::~ConfigDialog()
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
195 {
1308
dcc8c02530c2 Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents: 1263
diff changeset
196 delete this->librariesModel;
976
b7aac3606b65 Make ui a reference pointer in ConfigDialog
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
197 delete &ui;
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
198 }
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 void ConfigDialog::selectPage (int row)
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
201 {
976
b7aac3606b65 Make ui a reference pointer in ConfigDialog
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
202 ui.m_pagelist->setCurrentRow (row);
b7aac3606b65 Make ui a reference pointer in ConfigDialog
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
203 ui.m_pages->setCurrentIndex (row);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
204 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
205
814
c8ef30fd0e54 - refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 806
diff changeset
206 //
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
207 // Adds a shortcut entry to the list of shortcuts.
814
c8ef30fd0e54 - refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 806
diff changeset
208 //
806
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 795
diff changeset
209 void ConfigDialog::addShortcut (QAction* act)
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
210 {
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
211 ShortcutListItem* item = new ShortcutListItem;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
212 item->setIcon (act->icon());
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
213 item->setAction (act);
806
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 795
diff changeset
214 item->setSequence (act->shortcut());
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
215 setShortcutText (item);
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
216
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
217 // 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
218 // so that the list is kept aligned.
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
219 if (act->icon().isNull())
1157
1d6d244bdabd Moved GetIcon and makeSettings into the MainWindow namespace as static methods.
Teemu Piippo <teemu@hecknology.net>
parents: 1145
diff changeset
220 item->setIcon (MainWindow::getIcon ("empty"));
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
221
976
b7aac3606b65 Make ui a reference pointer in ConfigDialog
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
222 ui.shortcutsList->insertItem (ui.shortcutsList->count(), item);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
223 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
224
814
c8ef30fd0e54 - refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 806
diff changeset
225 //
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
226 // Initializes the stuff in the ext programs tab
814
c8ef30fd0e54 - refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 806
diff changeset
227 //
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
228 void ConfigDialog::initExtProgs()
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
229 {
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
230 QGridLayout* pathsLayout = new QGridLayout;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
231 int row = 0;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
232
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
233 for (int i = 0; i < NumExternalPrograms; ++i)
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
234 {
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
235 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
236 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
237 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
238 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
239 QLabel* progLabel = new QLabel (name);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
240 QLineEdit* input = new QLineEdit;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
241 QPushButton* setPathButton = new QPushButton;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
242
1157
1d6d244bdabd Moved GetIcon and makeSettings into the MainWindow namespace as static methods.
Teemu Piippo <teemu@hecknology.net>
parents: 1145
diff changeset
243 icon->setPixmap (MainWindow::getIcon (name.toLower()));
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
244 input->setText (m_window->externalPrograms()->getPathSetting (program));
1157
1d6d244bdabd Moved GetIcon and makeSettings into the MainWindow namespace as static methods.
Teemu Piippo <teemu@hecknology.net>
parents: 1145
diff changeset
245 setPathButton->setIcon (MainWindow::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
246 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
247 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
248 widgets.wineBox = nullptr;
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
249 connect (setPathButton, SIGNAL (clicked()), this, SLOT (slot_setExtProgPath()));
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
250 pathsLayout->addWidget (icon, row, 0);
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
251 pathsLayout->addWidget (progLabel, row, 1);
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
252 pathsLayout->addWidget (input, row, 2);
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
253 pathsLayout->addWidget (setPathButton, row, 3);
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
254
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 #ifdef Q_OS_UNIX
814
c8ef30fd0e54 - refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 806
diff changeset
256 {
c8ef30fd0e54 - refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 806
diff changeset
257 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
258 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
259 widgets.wineBox = wineBox;
814
c8ef30fd0e54 - refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 806
diff changeset
260 pathsLayout->addWidget (wineBox, row, 4);
c8ef30fd0e54 - refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 806
diff changeset
261 }
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
262 #endif
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
263 ++row;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
264 }
976
b7aac3606b65 Make ui a reference pointer in ConfigDialog
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
265 ui.extProgs->setLayout (pathsLayout);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
266 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
267
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
268 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
269 {
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
270 // Apply configuration
860
a496e72af069 - more refactor, updated .hgignore
Teemu Piippo <crimsondusk64@gmail.com>
parents: 855
diff changeset
271 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
272 {
860
a496e72af069 - more refactor, updated .hgignore
Teemu Piippo <crimsondusk64@gmail.com>
parents: 855
diff changeset
273 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
274 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
275
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
276 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
277
1323
05b3e173c900 Config is now a namespace
Teemu Piippo <teemu@hecknology.net>
parents: 1319
diff changeset
278 if (config::exists(optionname))
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
279 func (widget, optionname);
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
280 else
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
281 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
282 }
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
283 }
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
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 // Set the settings based on widget data.
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::applySettings()
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
289 {
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
290 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
291 {
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
292 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
293 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
294 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
295 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
296 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
297 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
298 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
299
985
ed7b31b9f904 Remove "!= nullptr" expressions
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
300 if ((le = qobject_cast<QLineEdit*> (widget)))
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
301 value = le->text();
985
ed7b31b9f904 Remove "!= nullptr" expressions
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
302 else if ((spinbox = qobject_cast<QSpinBox*> (widget)))
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
303 value = spinbox->value();
985
ed7b31b9f904 Remove "!= nullptr" expressions
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
304 else if ((doublespinbox = qobject_cast<QDoubleSpinBox*> (widget)))
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
305 value = doublespinbox->value();
985
ed7b31b9f904 Remove "!= nullptr" expressions
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
306 else if ((slider = qobject_cast<QSlider*> (widget)))
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
307 value = slider->value();
985
ed7b31b9f904 Remove "!= nullptr" expressions
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
308 else if ((checkbox = qobject_cast<QCheckBox*> (widget)))
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
309 value = checkbox->isChecked();
985
ed7b31b9f904 Remove "!= nullptr" expressions
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
310 else if ((button = qobject_cast<QPushButton*> (widget)))
861
83426c5fa732 - major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents: 860
diff changeset
311 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
312 else
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
313 {
860
a496e72af069 - more refactor, updated .hgignore
Teemu Piippo <crimsondusk64@gmail.com>
parents: 855
diff changeset
314 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
315 return;
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
316 }
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
317
1323
05b3e173c900 Config is now a namespace
Teemu Piippo <teemu@hecknology.net>
parents: 1319
diff changeset
318 settingsObject().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
319 });
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
320
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
321 // 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
322 m_window->setQuickColors (quickColors);
1323
05b3e173c900 Config is now a namespace
Teemu Piippo <teemu@hecknology.net>
parents: 1319
diff changeset
323 config::setQuickColorToolbar (quickColorString());
05b3e173c900 Config is now a namespace
Teemu Piippo <teemu@hecknology.net>
parents: 1319
diff changeset
324 config::setLibraries(this->libraries);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
325
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
326 // 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
327 for (int i = 0; i < NumExternalPrograms; ++i)
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
328 {
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
329 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
330 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
331 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
332 toolset->getPathSetting (program) = widgets.input->text();
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
333
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
334 if (widgets.wineBox)
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
335 toolset->setWineSetting (program, widgets.wineBox->isChecked());
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
336 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
337
806
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 795
diff changeset
338 // Apply shortcuts
976
b7aac3606b65 Make ui a reference pointer in ConfigDialog
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
339 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
340 {
976
b7aac3606b65 Make ui a reference pointer in ConfigDialog
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
341 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
342 item->action()->setShortcut (item->sequence());
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 795
diff changeset
343 }
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 795
diff changeset
344
1323
05b3e173c900 Config is now a namespace
Teemu Piippo <teemu@hecknology.net>
parents: 1319
diff changeset
345 settingsObject().sync();
998
5be0ce31ce60 Now compiles again
Teemu Piippo <crimsondusk64@gmail.com>
parents: 997
diff changeset
346 m_documents->loadLogoedStuds();
981
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 978
diff changeset
347 m_window->renderer()->setBackground();
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
348 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
349 m_window->updateDocumentList();
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
814
c8ef30fd0e54 - refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 806
diff changeset
352 //
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
353 // A dialog button was clicked
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 void ConfigDialog::buttonClicked (QAbstractButton* button)
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
356 {
976
b7aac3606b65 Make ui a reference pointer in ConfigDialog
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
357 QDialogButtonBox* dbb = ui.buttonBox;
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
358
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
359 if (button == dbb->button (QDialogButtonBox::Ok))
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
360 {
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
361 applySettings();
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
362 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
363 }
967
eb586d3e1a6a elif -> else if
Teemu Piippo <crimsondusk64@gmail.com>
parents: 964
diff changeset
364 else if (button == dbb->button (QDialogButtonBox::Apply))
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
365 {
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
366 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
367 }
967
eb586d3e1a6a elif -> else if
Teemu Piippo <crimsondusk64@gmail.com>
parents: 964
diff changeset
368 else if (button == dbb->button (QDialogButtonBox::Cancel))
655
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 reject();
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
371 }
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
814
c8ef30fd0e54 - refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 806
diff changeset
374 //
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
375 // 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
376 //
1010
969b48eddd6b A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 998
diff changeset
377 void ConfigDialog::updateQuickColorList (ColorToolbarItem* sel)
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
378 {
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
379 for (QListWidgetItem * item : quickColorItems)
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
380 delete item;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
381
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
382 quickColorItems.clear();
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
383
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
384 // Init table items
1010
969b48eddd6b A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 998
diff changeset
385 for (ColorToolbarItem& entry : quickColors)
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
386 {
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
387 QListWidgetItem* item = new QListWidgetItem;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
388
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
389 if (entry.isSeparator())
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
390 {
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
391 item->setText ("<hr />");
1157
1d6d244bdabd Moved GetIcon and makeSettings into the MainWindow namespace as static methods.
Teemu Piippo <teemu@hecknology.net>
parents: 1145
diff changeset
392 item->setIcon (MainWindow::getIcon ("empty"));
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
393 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
394 else
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
395 {
946
9cbd658b63f9 Cleanup progresses
Teemu Piippo <crimsondusk64@gmail.com>
parents: 867
diff changeset
396 LDColor color = entry.color();
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
397
946
9cbd658b63f9 Cleanup progresses
Teemu Piippo <crimsondusk64@gmail.com>
parents: 867
diff changeset
398 if (color.isValid())
9cbd658b63f9 Cleanup progresses
Teemu Piippo <crimsondusk64@gmail.com>
parents: 867
diff changeset
399 {
9cbd658b63f9 Cleanup progresses
Teemu Piippo <crimsondusk64@gmail.com>
parents: 867
diff changeset
400 item->setText (color.name());
1252
db1d4917626f refactor
Santeri Piippo
parents: 1157
diff changeset
401 item->setIcon (makeColorIcon (color, 16));
946
9cbd658b63f9 Cleanup progresses
Teemu Piippo <crimsondusk64@gmail.com>
parents: 867
diff changeset
402 }
9cbd658b63f9 Cleanup progresses
Teemu Piippo <crimsondusk64@gmail.com>
parents: 867
diff changeset
403 else
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
404 {
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
405 item->setText ("[[unknown color]]");
1157
1d6d244bdabd Moved GetIcon and makeSettings into the MainWindow namespace as static methods.
Teemu Piippo <teemu@hecknology.net>
parents: 1145
diff changeset
406 item->setIcon (MainWindow::getIcon ("error"));
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
407 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
408 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
409
976
b7aac3606b65 Make ui a reference pointer in ConfigDialog
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
410 ui.quickColorList->addItem (item);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
411 quickColorItems << item;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
412
840
d077dd19bf9a - changed `&&` and `||` operators to their named variants `and` and `or`
Teemu Piippo <crimsondusk64@gmail.com>
parents: 814
diff changeset
413 if (sel and &entry == sel)
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
414 {
976
b7aac3606b65 Make ui a reference pointer in ConfigDialog
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
415 ui.quickColorList->setCurrentItem (item);
b7aac3606b65 Make ui a reference pointer in ConfigDialog
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
416 ui.quickColorList->scrollToItem (item);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
417 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
418 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
419 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
420
814
c8ef30fd0e54 - refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 806
diff changeset
421 //
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
422 // Quick colors: add or edit button was clicked.
814
c8ef30fd0e54 - refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 806
diff changeset
423 //
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
424 void ConfigDialog::slot_setColor()
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
425 {
1010
969b48eddd6b A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 998
diff changeset
426 ColorToolbarItem* entry = nullptr;
984
a7b6f987d269 null -> nullptr
Teemu Piippo <crimsondusk64@gmail.com>
parents: 981
diff changeset
427 QListWidgetItem* item = nullptr;
976
b7aac3606b65 Make ui a reference pointer in ConfigDialog
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
428 const bool isNew = static_cast<QPushButton*> (sender()) == ui.quickColor_add;
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
429
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
430 if (not isNew)
655
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 item = getSelectedQuickColor();
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
433
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
434 if (not item)
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
435 return;
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 int i = getItemRow (item, quickColorItems);
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
438 entry = &quickColors[i];
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
439
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
440 if (entry->isSeparator() == true)
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
441 return; // don't color separators
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
442 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
443
1114
ffd49a28f49e Moved some global constants into appropriate namespaces.
Teemu Piippo <teemu@hecknology.net>
parents: 1103
diff changeset
444 LDColor defaultValue = entry ? entry->color() : LDColor::nullColor;
946
9cbd658b63f9 Cleanup progresses
Teemu Piippo <crimsondusk64@gmail.com>
parents: 867
diff changeset
445 LDColor value;
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
446
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
447 if (not ColorSelector::selectColor (this, value, defaultValue))
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
448 return;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
449
985
ed7b31b9f904 Remove "!= nullptr" expressions
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
450 if (entry)
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
451 {
946
9cbd658b63f9 Cleanup progresses
Teemu Piippo <crimsondusk64@gmail.com>
parents: 867
diff changeset
452 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
453 }
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
454 else
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
455 {
1382
6f31a87006f2 refactored the quick color toolbar
Teemu Piippo <teemu@hecknology.net>
parents: 1326
diff changeset
456 ColorToolbarItem newentry {value};
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
457 item = getSelectedQuickColor();
1065
c8ecddbd99e9 Actually, let's call it countof(). Makes more sense.
Teemu Piippo <teemu@hecknology.net>
parents: 1064
diff changeset
458 int idx = (item) ? getItemRow (item, quickColorItems) + 1 : countof(quickColorItems);
1382
6f31a87006f2 refactored the quick color toolbar
Teemu Piippo <teemu@hecknology.net>
parents: 1326
diff changeset
459 quickColors.insert(idx, newentry);
946
9cbd658b63f9 Cleanup progresses
Teemu Piippo <crimsondusk64@gmail.com>
parents: 867
diff changeset
460 entry = &quickColors[idx];
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
461 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
462
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
463 updateQuickColorList (entry);
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
464 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
465
814
c8ef30fd0e54 - refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 806
diff changeset
466 //
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
467 // Remove a quick color
814
c8ef30fd0e54 - refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 806
diff changeset
468 //
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
469 void ConfigDialog::slot_delColor()
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
470 {
976
b7aac3606b65 Make ui a reference pointer in ConfigDialog
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
471 if (ui.quickColorList->selectedItems().isEmpty())
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
472 return;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
473
976
b7aac3606b65 Make ui a reference pointer in ConfigDialog
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
474 QListWidgetItem* item = ui.quickColorList->selectedItems() [0];
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
475 quickColors.removeAt (getItemRow (item, quickColorItems));
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
476 updateQuickColorList();
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
477 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
478
814
c8ef30fd0e54 - refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 806
diff changeset
479 //
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
480 // Move a quick color up/down
814
c8ef30fd0e54 - refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 806
diff changeset
481 //
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
482 void ConfigDialog::slot_moveColor()
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
483 {
976
b7aac3606b65 Make ui a reference pointer in ConfigDialog
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
484 const bool up = (static_cast<QPushButton*> (sender()) == ui.quickColor_moveUp);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
485
976
b7aac3606b65 Make ui a reference pointer in ConfigDialog
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
486 if (ui.quickColorList->selectedItems().isEmpty())
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
487 return;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
488
976
b7aac3606b65 Make ui a reference pointer in ConfigDialog
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
489 QListWidgetItem* item = ui.quickColorList->selectedItems() [0];
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
490 int idx = getItemRow (item, quickColorItems);
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
491 int dest = up ? (idx - 1) : (idx + 1);
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
492
1065
c8ecddbd99e9 Actually, let's call it countof(). Makes more sense.
Teemu Piippo <teemu@hecknology.net>
parents: 1064
diff changeset
493 if (dest < 0 or dest >= countof(quickColorItems))
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
494 return; // destination out of bounds
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
495
860
a496e72af069 - more refactor, updated .hgignore
Teemu Piippo <crimsondusk64@gmail.com>
parents: 855
diff changeset
496 qSwap (quickColors[dest], quickColors[idx]);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
497 updateQuickColorList (&quickColors[dest]);
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
498 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
499
814
c8ef30fd0e54 - refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 806
diff changeset
500 //
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
501 //
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
502 // Add a separator to quick colors
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
503 //
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
504 void ConfigDialog::slot_addColorSeparator()
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
505 {
1010
969b48eddd6b A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 998
diff changeset
506 quickColors << ColorToolbarItem::makeSeparator();
1065
c8ecddbd99e9 Actually, let's call it countof(). Makes more sense.
Teemu Piippo <teemu@hecknology.net>
parents: 1064
diff changeset
507 updateQuickColorList (&quickColors[countof(quickColors) - 1]);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
508 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
509
814
c8ef30fd0e54 - refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 806
diff changeset
510 //
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
511 //
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
512 // Clear all quick colors
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 void ConfigDialog::slot_clearColors()
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
515 {
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
516 quickColors.clear();
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
517 updateQuickColorList();
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
518 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
519
814
c8ef30fd0e54 - refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 806
diff changeset
520 //
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
521 //
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
522 void ConfigDialog::setButtonColor()
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
523 {
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
524 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
525
984
a7b6f987d269 null -> nullptr
Teemu Piippo <crimsondusk64@gmail.com>
parents: 981
diff changeset
526 if (button == nullptr)
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
527 {
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
528 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
529 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
530 }
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
531
861
83426c5fa732 - major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents: 860
diff changeset
532 QColor color = QColorDialog::getColor (m_buttonColors[button]);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
533
860
a496e72af069 - more refactor, updated .hgignore
Teemu Piippo <crimsondusk64@gmail.com>
parents: 855
diff changeset
534 if (color.isValid())
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
535 {
860
a496e72af069 - more refactor, updated .hgignore
Teemu Piippo <crimsondusk64@gmail.com>
parents: 855
diff changeset
536 QString colorname;
a496e72af069 - more refactor, updated .hgignore
Teemu Piippo <crimsondusk64@gmail.com>
parents: 855
diff changeset
537 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
538 setButtonBackground (button, colorname);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
539 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
540 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
541
814
c8ef30fd0e54 - refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 806
diff changeset
542 //
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
543 // Sets background color of a given button.
814
c8ef30fd0e54 - refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 806
diff changeset
544 //
789
4b7306f52bb5 - String -> QString
Santeri Piippo <crimsondusk64@gmail.com>
parents: 780
diff changeset
545 void ConfigDialog::setButtonBackground (QPushButton* button, QString value)
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
546 {
1157
1d6d244bdabd Moved GetIcon and makeSettings into the MainWindow namespace as static methods.
Teemu Piippo <teemu@hecknology.net>
parents: 1145
diff changeset
547 button->setIcon (MainWindow::getIcon ("colorselect"));
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
548 button->setAutoFillBackground (true);
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
549 button->setStyleSheet (format ("background-color: %1", value));
861
83426c5fa732 - major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents: 860
diff changeset
550 m_buttonColors[button] = QColor (value);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
551 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
552
814
c8ef30fd0e54 - refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 806
diff changeset
553 //
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
554 // 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
555 //
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
556 int ConfigDialog::getItemRow (QListWidgetItem* item, QList<QListWidgetItem*>& haystack)
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
557 {
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
558 int i = 0;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
559
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
560 for (QListWidgetItem* it : haystack)
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
561 {
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
562 if (it == item)
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
563 return i;
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 ++i;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
566 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
567
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
568 return -1;
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
814
c8ef30fd0e54 - refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 806
diff changeset
571 //
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
572 // Which quick color is currently selected?
814
c8ef30fd0e54 - refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 806
diff changeset
573 //
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
574 QListWidgetItem* ConfigDialog::getSelectedQuickColor()
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
575 {
976
b7aac3606b65 Make ui a reference pointer in ConfigDialog
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
576 if (ui.quickColorList->selectedItems().isEmpty())
984
a7b6f987d269 null -> nullptr
Teemu Piippo <crimsondusk64@gmail.com>
parents: 981
diff changeset
577 return nullptr;
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
578
976
b7aac3606b65 Make ui a reference pointer in ConfigDialog
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
579 return ui.quickColorList->selectedItems() [0];
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
580 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
581
814
c8ef30fd0e54 - refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 806
diff changeset
582 //
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
583 // Get the list of shortcuts selected
814
c8ef30fd0e54 - refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 806
diff changeset
584 //
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
585 QList<ShortcutListItem*> ConfigDialog::getShortcutSelection()
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 QList<ShortcutListItem*> out;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
588
976
b7aac3606b65 Make ui a reference pointer in ConfigDialog
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
589 for (QListWidgetItem* entry : ui.shortcutsList->selectedItems())
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
590 out << static_cast<ShortcutListItem*> (entry);
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
591
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
592 return out;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
593 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
594
814
c8ef30fd0e54 - refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 806
diff changeset
595 //
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
596 // Edit the shortcut of a given action.
814
c8ef30fd0e54 - refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 806
diff changeset
597 //
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
598 void ConfigDialog::slot_setShortcut()
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
599 {
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
600 QList<ShortcutListItem*> sel = getShortcutSelection();
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
601
1065
c8ecddbd99e9 Actually, let's call it countof(). Makes more sense.
Teemu Piippo <teemu@hecknology.net>
parents: 1064
diff changeset
602 if (countof(sel) < 1)
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
603 return;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
604
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
605 ShortcutListItem* item = sel[0];
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
606
806
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 795
diff changeset
607 if (KeySequenceDialog::staticDialog (item, this))
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
608 setShortcutText (item);
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
609 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
610
814
c8ef30fd0e54 - refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 806
diff changeset
611 //
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
612 // Reset a shortcut to defaults
814
c8ef30fd0e54 - refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 806
diff changeset
613 //
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
614 void ConfigDialog::slot_resetShortcut()
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 QList<ShortcutListItem*> sel = getShortcutSelection();
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 for (ShortcutListItem* item : sel)
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
619 {
997
1b49f34e533d Commit work done on document manager. Happy 3rd birthday LDForge!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 985
diff changeset
620 item->setSequence (m_window->defaultShortcut (item->action()));
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
621 setShortcutText (item);
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
622 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
623 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
624
814
c8ef30fd0e54 - refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 806
diff changeset
625 //
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
626 // Remove the shortcut of an action.
814
c8ef30fd0e54 - refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 806
diff changeset
627 //
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
628 void ConfigDialog::slot_clearShortcut()
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
629 {
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
630 QList<ShortcutListItem*> sel = getShortcutSelection();
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
631
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
632 for (ShortcutListItem* item : sel)
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
633 {
806
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 795
diff changeset
634 item->setSequence (QKeySequence());
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
635 setShortcutText (item);
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
636 }
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
814
c8ef30fd0e54 - refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 806
diff changeset
639 //
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
640 // Set the path of an external program
814
c8ef30fd0e54 - refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 806
diff changeset
641 //
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
642 void ConfigDialog::slot_setExtProgPath()
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
643 {
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
644 ExtProgramType program = NumExternalPrograms;
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
645
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
646 for (int i = 0; i < NumExternalPrograms; ++i)
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
647 {
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
648 if (m_externalProgramWidgets[i].setPathButton == sender())
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
649 {
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
650 program = (ExtProgramType) i;
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
651 break;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
652 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
653 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
654
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
655 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
656 {
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
657 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
658 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
659 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
660 format ("Path to %1", toolset->externalProgramName (program)),
1115
117e4880666e Cleaned up ExternalProgramPathDialog
Teemu Piippo <teemu@hecknology.net>
parents: 1114
diff changeset
661 widgets.input->text(), externalProgramPathFilter);
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
662
1dc890c73e01 Removed all asserts from the code. Removed assert handling and the bomb box dialog.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 952
diff changeset
663 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
664 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
665
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
666 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
667 }
655
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
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
670 //
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
671 // '...' button pressed for the download path
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
672 //
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
673 void ConfigDialog::slot_findDownloadFolder()
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
674 {
789
4b7306f52bb5 - String -> QString
Santeri Piippo <crimsondusk64@gmail.com>
parents: 780
diff changeset
675 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
676
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
677 if (not dpath.isEmpty())
976
b7aac3606b65 Make ui a reference pointer in ConfigDialog
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
678 ui.configDownloadFilePath->setText (dpath);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
679 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
680
814
c8ef30fd0e54 - refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 806
diff changeset
681 //
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
682 //
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
683 // Updates the text string for a given shortcut list item
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
684 //
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
685 void ConfigDialog::setShortcutText (ShortcutListItem* item)
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
686 {
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
687 QAction* act = item->action();
789
4b7306f52bb5 - String -> QString
Santeri Piippo <crimsondusk64@gmail.com>
parents: 780
diff changeset
688 QString label = act->iconText();
806
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 795
diff changeset
689 QString keybind = item->sequence().toString();
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
690 item->setText (format ("%1 (%2)", label, keybind));
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
691 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
692
814
c8ef30fd0e54 - refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 806
diff changeset
693 //
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
694 // Gets the configuration string of the quick color toolbar
814
c8ef30fd0e54 - refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 806
diff changeset
695 //
789
4b7306f52bb5 - String -> QString
Santeri Piippo <crimsondusk64@gmail.com>
parents: 780
diff changeset
696 QString ConfigDialog::quickColorString()
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
697 {
789
4b7306f52bb5 - String -> QString
Santeri Piippo <crimsondusk64@gmail.com>
parents: 780
diff changeset
698 QString val;
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
699
1010
969b48eddd6b A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 998
diff changeset
700 for (const ColorToolbarItem& entry : quickColors)
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
701 {
1064
4c7a353cf583 Replaced '.length()' with 'length()' where appropriate
Teemu Piippo <teemu@hecknology.net>
parents: 1063
diff changeset
702 if (not val.isEmpty())
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
703 val += ':';
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
704
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
705 if (entry.isSeparator())
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
706 val += '|';
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
707 else
806
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 795
diff changeset
708 val += format ("%1", entry.color().index());
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
709 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
710
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
711 return val;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
712 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
713
814
c8ef30fd0e54 - refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 806
diff changeset
714 //
c8ef30fd0e54 - refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 806
diff changeset
715 //
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
716 KeySequenceDialog::KeySequenceDialog (QKeySequence seq, QWidget* parent, Qt::WindowFlags f) :
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
717 QDialog (parent, f), seq (seq)
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
718 {
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
719 lb_output = new QLabel;
964
70f6900a92d5 More refactor
Teemu Piippo <crimsondusk64@gmail.com>
parents: 958
diff changeset
720
70f6900a92d5 More refactor
Teemu Piippo <crimsondusk64@gmail.com>
parents: 958
diff changeset
721 bbx_buttons = new QDialogButtonBox (QDialogButtonBox::Ok | QDialogButtonBox::Cancel); \
70f6900a92d5 More refactor
Teemu Piippo <crimsondusk64@gmail.com>
parents: 958
diff changeset
722 connect (bbx_buttons, SIGNAL (accepted()), this, SLOT (accept())); \
70f6900a92d5 More refactor
Teemu Piippo <crimsondusk64@gmail.com>
parents: 958
diff changeset
723 connect (bbx_buttons, SIGNAL (rejected()), this, SLOT (reject())); \
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
724
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
725 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
726 "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
727 "dismiss."));
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
728
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
729 QVBoxLayout* layout = new QVBoxLayout;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
730 layout->addWidget (lb_output);
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
731 layout->addWidget (bbx_buttons);
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
732 setLayout (layout);
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
733
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
734 updateOutput();
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
735 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
736
814
c8ef30fd0e54 - refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 806
diff changeset
737 //
c8ef30fd0e54 - refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 806
diff changeset
738 //
806
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 795
diff changeset
739 bool KeySequenceDialog::staticDialog (ShortcutListItem* item, QWidget* parent)
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
740 {
806
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 795
diff changeset
741 KeySequenceDialog dlg (item->sequence(), parent);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
742
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
743 if (dlg.exec() == QDialog::Rejected)
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
744 return false;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
745
806
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 795
diff changeset
746 item->setSequence (dlg.seq);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
747 return true;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
748 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
749
814
c8ef30fd0e54 - refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 806
diff changeset
750 //
c8ef30fd0e54 - refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 806
diff changeset
751 //
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
752 void KeySequenceDialog::updateOutput()
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
753 {
789
4b7306f52bb5 - String -> QString
Santeri Piippo <crimsondusk64@gmail.com>
parents: 780
diff changeset
754 QString shortcut = seq.toString();
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
755
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
756 if (seq == QKeySequence())
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
757 shortcut = "&lt;empty&gt;";
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
758
789
4b7306f52bb5 - String -> QString
Santeri Piippo <crimsondusk64@gmail.com>
parents: 780
diff changeset
759 QString text = format ("<center><b>%1</b></center>", shortcut);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
760 lb_output->setText (text);
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
761 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
762
814
c8ef30fd0e54 - refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 806
diff changeset
763 //
c8ef30fd0e54 - refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 806
diff changeset
764 //
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
765 void KeySequenceDialog::keyPressEvent (QKeyEvent* ev)
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
766 {
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
767 seq = ev->key() + ev->modifiers();
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
768 updateOutput();
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
769 }

mercurial