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