src/configDialog.cc

Fri, 13 Dec 2013 20:01:49 +0200

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Fri, 13 Dec 2013 20:01:49 +0200
changeset 557
04e140bdeb0b
child 574
10874674fe30
permissions
-rw-r--r--

- changed source file extension from .cpp to .cc

557
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
1 /*
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
2 * LDForge: LDraw parts authoring CAD
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2013 Santeri Piippo
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
4 *
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
5 * This program is free software: you can redistribute it and/or modify
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
6 * it under the terms of the GNU General Public License as published by
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
7 * the Free Software Foundation, either version 3 of the License, or
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
8 * (at your option) any later version.
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
9 *
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
10 * This program is distributed in the hope that it will be useful,
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
13 * GNU General Public License for more details.
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
14 *
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
17 * =====================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
18 *
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
19 * configDialog.cpp: Settings dialog and everything related to it.
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
20 * Actual configuration core is in config.cpp.
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
21 */
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
22
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
23 #include <QGridLayout>
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
24 #include <QFileDialog>
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
25 #include <QColorDialog>
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
26 #include <QBoxLayout>
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
27 #include <QKeyEvent>
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
28 #include <QGroupBox>
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
29 #include <QDoubleSpinBox>
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
30 #include <QLineEdit>
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
31 #include <QCheckBox>
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
32 #include "main.h"
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
33 #include "configDialog.h"
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
34 #include "document.h"
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
35 #include "config.h"
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
36 #include "misc.h"
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
37 #include "colors.h"
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
38 #include "colorSelectDialog.h"
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
39 #include "gldraw.h"
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
40 #include "ui_config.h"
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
41 #include "moc_configDialog.cpp"
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
42
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
43 extern_cfg (String, gl_bgcolor);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
44 extern_cfg (String, gl_maincolor);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
45 extern_cfg (Bool, lv_colorize);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
46 extern_cfg (Bool, gl_colorbfc);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
47 extern_cfg (Float, gl_maincolor_alpha);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
48 extern_cfg (Int, gl_linethickness);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
49 extern_cfg (String, gui_colortoolbar);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
50 extern_cfg (Bool, edit_schemanticinline);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
51 extern_cfg (Bool, gl_blackedges);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
52 extern_cfg (Bool, gl_aa);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
53 extern_cfg (Bool, gui_implicitfiles);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
54 extern_cfg (String, net_downloadpath);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
55 extern_cfg (Bool, net_guesspaths);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
56 extern_cfg (Bool, net_autoclose);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
57 extern_cfg (Bool, gl_logostuds);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
58 extern_cfg (String, ld_defaultname);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
59 extern_cfg (String, ld_defaultuser);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
60 extern_cfg (Int, ld_defaultlicense);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
61 extern_cfg (String, prog_ytruder);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
62 extern_cfg (String, prog_rectifier);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
63 extern_cfg (String, prog_intersector);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
64 extern_cfg (String, prog_coverer);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
65 extern_cfg (String, prog_isecalc);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
66 extern_cfg (String, prog_edger2);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
67 extern_cfg (Bool, prog_ytruder_wine);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
68 extern_cfg (Bool, prog_rectifier_wine);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
69 extern_cfg (Bool, prog_intersector_wine);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
70 extern_cfg (Bool, prog_coverer_wine);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
71 extern_cfg (Bool, prog_isecalc_wine);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
72 extern_cfg (Bool, prog_edger2_wine);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
73
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
74 #define act(N) extern_cfg (KeySequence, key_##N);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
75 #include "actions.h"
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
76
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
77 const char* g_extProgPathFilter =
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
78 #ifdef _WIN32
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
79 "Applications (*.exe)(*.exe);;All files (*.*)(*.*)";
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
80 #else
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
81 "";
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
82 #endif
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
83
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
84 // =============================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
85 // -----------------------------------------------------------------------------
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
86 ConfigDialog::ConfigDialog (ConfigDialog::Tab deftab, QWidget* parent, Qt::WindowFlags f) :
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
87 QDialog (parent, f)
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
88 {
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
89 assert (g_win != null);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
90 ui = new Ui_ConfigUI;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
91 ui->setupUi (this);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
92
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
93 // Interface tab
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
94 setButtonBackground (ui->backgroundColorButton, gl_bgcolor);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
95 connect (ui->backgroundColorButton, SIGNAL (clicked()),
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
96 this, SLOT (slot_setGLBackground()));
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
97
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
98 setButtonBackground (ui->mainColorButton, gl_maincolor);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
99 connect (ui->mainColorButton, SIGNAL (clicked()),
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
100 this, SLOT (slot_setGLForeground()));
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
101
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
102 ui->mainColorAlpha->setValue (gl_maincolor_alpha * 10.0f);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
103 ui->lineThickness->setValue (gl_linethickness);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
104 ui->colorizeObjects->setChecked (lv_colorize);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
105 ui->colorBFC->setChecked (gl_colorbfc);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
106 ui->blackEdges->setChecked (gl_blackedges);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
107 ui->m_aa->setChecked (gl_aa);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
108 ui->implicitFiles->setChecked (gui_implicitfiles);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
109 ui->m_logostuds->setChecked (gl_logostuds);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
110
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
111 int i = 0;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
112 #define act(N) addShortcut (key_##N, ACTION(N), i);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
113 #include "actions.h"
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
114
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
115 ui->shortcutsList->setSortingEnabled (true);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
116 ui->shortcutsList->sortItems();
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
117
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
118 connect (ui->shortcut_set, SIGNAL (clicked()), this, SLOT (slot_setShortcut()));
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
119 connect (ui->shortcut_reset, SIGNAL (clicked()), this, SLOT (slot_resetShortcut()));
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
120 connect (ui->shortcut_clear, SIGNAL (clicked()), this, SLOT (slot_clearShortcut()));
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
121
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
122 quickColors = quickColorsFromConfig();
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
123 updateQuickColorList();
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
124
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
125 connect (ui->quickColor_add, SIGNAL (clicked()), this, SLOT (slot_setColor()));
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
126 connect (ui->quickColor_remove, SIGNAL (clicked()), this, SLOT (slot_delColor()));
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
127 connect (ui->quickColor_edit, SIGNAL (clicked()), this, SLOT (slot_setColor()));
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
128 connect (ui->quickColor_addSep, SIGNAL (clicked()), this, SLOT (slot_addColorSeparator()));
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
129 connect (ui->quickColor_moveUp, SIGNAL (clicked()), this, SLOT (slot_moveColor()));
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
130 connect (ui->quickColor_moveDown, SIGNAL (clicked()), this, SLOT (slot_moveColor()));
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
131 connect (ui->quickColor_clear, SIGNAL (clicked()), this, SLOT (slot_clearColors()));
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
132
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
133 ui->downloadPath->setText (net_downloadpath);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
134 ui->guessNetPaths->setChecked (net_guesspaths);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
135 ui->autoCloseNetPrompt->setChecked (net_autoclose);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
136 connect (ui->findDownloadPath, SIGNAL (clicked (bool)), this, SLOT (slot_findDownloadFolder()));
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
137
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
138 ui->m_profileName->setText (ld_defaultname);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
139 ui->m_profileUsername->setText (ld_defaultuser);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
140 ui->m_profileLicense->setCurrentIndex (ld_defaultlicense);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
141
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
142 initGrids();
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
143 initExtProgs();
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
144 selectPage (deftab);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
145
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
146 connect (ui->buttonBox, SIGNAL (clicked (QAbstractButton*)),
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
147 this, SLOT (buttonClicked (QAbstractButton*)));
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
148
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
149 connect (ui->m_pages, SIGNAL (currentChanged (int)),
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
150 this, SLOT (selectPage (int)));
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
151
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
152 connect (ui->m_pagelist, SIGNAL (currentRowChanged (int)),
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
153 this, SLOT (selectPage (int)));
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
154 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
155
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
156 // =============================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
157 // -----------------------------------------------------------------------------
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
158 ConfigDialog::~ConfigDialog()
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
159 { delete ui;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
160 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
161
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
162 // =============================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
163 // -----------------------------------------------------------------------------
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
164 void ConfigDialog::selectPage (int row)
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
165 { ui->m_pagelist->setCurrentRow (row);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
166 ui->m_pages->setCurrentIndex (row);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
167 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
168
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
169 // =============================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
170 // Adds a shortcut entry to the list of shortcuts.
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
171 // -----------------------------------------------------------------------------
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
172 void ConfigDialog::addShortcut (KeySequenceConfig& cfg, QAction* act, int& i)
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
173 { ShortcutListItem* item = new ShortcutListItem;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
174 item->setIcon (act->icon());
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
175 item->setKeyConfig (&cfg);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
176 item->setAction (act);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
177 setShortcutText (item);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
178
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
179 // If the action doesn't have a valid icon, use an empty one
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
180 // so that the list is kept aligned.
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
181 if (act->icon().isNull())
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
182 item->setIcon (getIcon ("empty"));
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
183
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
184 ui->shortcutsList->insertItem (i++, item);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
185 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
186
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
187 // =============================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
188 // Initializes the table of grid stuff
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
189 // -----------------------------------------------------------------------------
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
190 void ConfigDialog::initGrids()
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
191 { QGridLayout* gridlayout = new QGridLayout;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
192 QLabel* xlabel = new QLabel ("X"),
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
193 *ylabel = new QLabel ("Y"),
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
194 *zlabel = new QLabel ("Z"),
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
195 *anglabel = new QLabel ("Angle");
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
196 int i = 1;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
197
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
198 for (QLabel* label : initlist<QLabel*> ({xlabel, ylabel, zlabel, anglabel}))
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
199 { label->setAlignment (Qt::AlignCenter);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
200 gridlayout->addWidget (label, 0, i++);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
201 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
202
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
203 for (int i = 0; i < g_NumGrids; ++i)
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
204 { // Icon
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
205 lb_gridIcons[i] = new QLabel;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
206 lb_gridIcons[i]->setPixmap (getIcon (fmt ("grid-%1", str (g_GridInfo[i].name).toLower())));
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
207
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
208 // Text label
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
209 lb_gridLabels[i] = new QLabel (fmt ("%1:", g_GridInfo[i].name));
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
210
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
211 QHBoxLayout* labellayout = new QHBoxLayout;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
212 labellayout->addWidget (lb_gridIcons[i]);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
213 labellayout->addWidget (lb_gridLabels[i]);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
214 gridlayout->addLayout (labellayout, i + 1, 0);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
215
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
216 // Add the widgets
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
217 for (int j = 0; j < 4; ++j)
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
218 { dsb_gridData[i][j] = new QDoubleSpinBox;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
219 dsb_gridData[i][j]->setValue (g_GridInfo[i].confs[j]->value);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
220 gridlayout->addWidget (dsb_gridData[i][j], i + 1, j + 1);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
221 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
222 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
223
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
224 ui->grids->setLayout (gridlayout);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
225 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
226
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
227 // =============================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
228 // -----------------------------------------------------------------------------
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
229 static const struct LDExtProgInfo
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
230 { const str name, iconname;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
231 StringConfig* const path;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
232 mutable QLineEdit* input;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
233 mutable QPushButton* setPathButton;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
234 #ifndef _WIN32
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
235 BoolConfig* const wine;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
236 mutable QCheckBox* wineBox;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
237 #endif // _WIN32
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
238 } g_LDExtProgInfo[] =
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
239 {
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
240 #ifndef _WIN32
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
241 # define EXTPROG(NAME, LOWNAME) { #NAME, #LOWNAME, &prog_##LOWNAME, null, null, &prog_##LOWNAME##_wine, null },
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
242 #else
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
243 # define EXTPROG(NAME, LOWNAME) { #NAME, #LOWNAME, &prog_##LOWNAME, null, null },
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
244 #endif
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
245 EXTPROG (Ytruder, ytruder)
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
246 EXTPROG (Rectifier, rectifier)
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
247 EXTPROG (Intersector, intersector)
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
248 EXTPROG (Isecalc, isecalc)
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
249 EXTPROG (Coverer, coverer)
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
250 EXTPROG (Edger2, edger2)
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
251 #undef EXTPROG
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
252 };
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
253
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
254 // =============================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
255 // Initializes the stuff in the ext programs tab
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
256 // -----------------------------------------------------------------------------
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
257 void ConfigDialog::initExtProgs()
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
258 { QGridLayout* pathsLayout = new QGridLayout;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
259 int row = 0;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
260
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
261 for (const LDExtProgInfo& info : g_LDExtProgInfo)
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
262 { QLabel* icon = new QLabel,
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
263 *progLabel = new QLabel (info.name);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
264 QLineEdit* input = new QLineEdit;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
265 QPushButton* setPathButton = new QPushButton;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
266
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
267 icon->setPixmap (getIcon (info.iconname));
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
268 input->setText (info.path->value);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
269 setPathButton->setIcon (getIcon ("folder"));
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
270 info.input = input;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
271 info.setPathButton = setPathButton;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
272
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
273 connect (setPathButton, SIGNAL (clicked()), this, SLOT (slot_setExtProgPath()));
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
274
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
275 pathsLayout->addWidget (icon, row, 0);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
276 pathsLayout->addWidget (progLabel, row, 1);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
277 pathsLayout->addWidget (input, row, 2);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
278 pathsLayout->addWidget (setPathButton, row, 3);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
279
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
280 #ifndef _WIN32
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
281 QCheckBox* wineBox = new QCheckBox ("Wine");
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
282 wineBox->setChecked (*info.wine);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
283 info.wineBox = wineBox;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
284 pathsLayout->addWidget (wineBox, row, 4);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
285 #endif
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
286
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
287 ++row;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
288 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
289
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
290 ui->extProgs->setLayout (pathsLayout);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
291 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
292
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
293 // =============================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
294 // Set the settings based on widget data.
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
295 // -----------------------------------------------------------------------------
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
296 void ConfigDialog::applySettings()
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
297 { // Apply configuration
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
298 lv_colorize = ui->colorizeObjects->isChecked();
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
299 gl_colorbfc = ui->colorBFC->isChecked();
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
300 gl_blackedges = ui->blackEdges->isChecked();
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
301 gl_maincolor_alpha = ( (double) ui->mainColorAlpha->value()) / 10.0f;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
302 gl_linethickness = ui->lineThickness->value();
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
303 gui_implicitfiles = ui->implicitFiles->isChecked();
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
304 net_downloadpath = ui->downloadPath->text();
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
305 net_guesspaths = ui->guessNetPaths->isChecked();
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
306 net_autoclose = ui->autoCloseNetPrompt->isChecked();
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
307 gl_logostuds = ui->m_logostuds->isChecked();
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
308 ld_defaultuser = ui->m_profileUsername->text();
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
309 ld_defaultname = ui->m_profileName->text();
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
310 ld_defaultlicense = ui->m_profileLicense->currentIndex();
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
311 gl_aa = ui->m_aa->isChecked();
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
312
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
313 // Rebuild the quick color toolbar
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
314 g_win->setQuickColors (quickColors);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
315 gui_colortoolbar = quickColorString();
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
316
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
317 // Set the grid settings
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
318 for (int i = 0; i < g_NumGrids; ++i)
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
319 for (int j = 0; j < 4; ++j)
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
320 g_GridInfo[i].confs[j]->value = dsb_gridData[i][j]->value();
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
321
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
322 // Apply key shortcuts
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
323 #define act(N) ACTION(N)->setShortcut (key_##N);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
324 #include "actions.h"
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
325
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
326 // Ext program settings
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
327 for (const LDExtProgInfo& info : g_LDExtProgInfo)
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
328 { *info.path = info.input->text();
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
329
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
330 #ifndef _WIN32
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
331 *info.wine = info.wineBox->isChecked();
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
332 #endif // _WIN32
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
333 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
334
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
335 Config::save();
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
336 reloadAllSubfiles();
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
337 loadLogoedStuds();
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
338 g_win->R()->setBackground();
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
339 g_win->doFullRefresh();
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
340 g_win->updateToolBars();
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
341 g_win->updateDocumentList();
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
342 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
343
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
344 // =============================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
345 // A dialog button was clicked
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
346 // -----------------------------------------------------------------------------
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
347 void ConfigDialog::buttonClicked (QAbstractButton* button)
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
348 { typedef QDialogButtonBox QDDB;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
349 QDialogButtonBox* dbb = ui->buttonBox;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
350
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
351 if (button == dbb->button (QDDB::Ok))
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
352 { applySettings();
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
353 accept();
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
354 } elif (button == dbb->button (QDDB::Apply))
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
355 { applySettings();
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
356 } elif (button == dbb->button (QDDB::Cancel))
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
357 { reject();
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
358 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
359 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
360
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
361 // =============================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
362 // Update the list of color toolbar items in the quick color tab.
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
363 // -----------------------------------------------------------------------------
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
364 void ConfigDialog::updateQuickColorList (LDQuickColor* sel)
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
365 { for (QListWidgetItem * item : quickColorItems)
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
366 delete item;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
367
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
368 quickColorItems.clear();
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
369
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
370 // Init table items
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
371 for (LDQuickColor& entry : quickColors)
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
372 { QListWidgetItem* item = new QListWidgetItem;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
373
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
374 if (entry.isSeparator())
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
375 { item->setText ("--------");
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
376 item->setIcon (getIcon ("empty"));
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
377 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
378 else
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
379 { LDColor* col = entry.getColor();
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
380
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
381 if (col == null)
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
382 { item->setText ("[[unknown color]]");
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
383 item->setIcon (getIcon ("error"));
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
384 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
385 else
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
386 { item->setText (col->name);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
387 item->setIcon (makeColorIcon (col, 16));
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
388 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
389 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
390
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
391 ui->quickColorList->addItem (item);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
392 quickColorItems << item;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
393
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
394 if (sel && &entry == sel)
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
395 { ui->quickColorList->setCurrentItem (item);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
396 ui->quickColorList->scrollToItem (item);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
397 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
398 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
399 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
400
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
401 // =============================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
402 // Quick colors: add or edit button was clicked.
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
403 // -----------------------------------------------------------------------------
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
404 void ConfigDialog::slot_setColor()
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
405 { LDQuickColor* entry = null;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
406 QListWidgetItem* item = null;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
407 const bool isNew = static_cast<QPushButton*> (sender()) == ui->quickColor_add;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
408
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
409 if (isNew == false)
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
410 { item = getSelectedQuickColor();
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
411
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
412 if (!item)
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
413 return;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
414
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
415 int i = getItemRow (item, quickColorItems);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
416 entry = &quickColors[i];
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
417
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
418 if (entry->isSeparator() == true)
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
419 return; // don't color separators
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
420 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
421
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
422 int defval = entry ? entry->getColor()->index : -1;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
423 int val;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
424
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
425 if (ColorSelector::selectColor (val, defval, this) == false)
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
426 return;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
427
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
428 if (entry)
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
429 entry->setColor (getColor (val));
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
430 else
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
431 { LDQuickColor entry (getColor (val), null);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
432
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
433 item = getSelectedQuickColor();
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
434 int idx = (item) ? getItemRow (item, quickColorItems) + 1 : quickColorItems.size();
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
435
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
436 quickColors.insert (idx, entry);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
437 entry = quickColors[idx];
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
438 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
439
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
440 updateQuickColorList (entry);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
441 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
442
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
443 // =============================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
444 // Remove a quick color
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
445 // -----------------------------------------------------------------------------
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
446 void ConfigDialog::slot_delColor()
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
447 { if (ui->quickColorList->selectedItems().isEmpty())
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
448 return;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
449
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
450 QListWidgetItem* item = ui->quickColorList->selectedItems() [0];
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
451 quickColors.removeAt (getItemRow (item, quickColorItems));
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
452 updateQuickColorList();
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
453 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
454
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
455 // =============================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
456 // Move a quick color up/down
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
457 // -----------------------------------------------------------------------------
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
458 void ConfigDialog::slot_moveColor()
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
459 { const bool up = (static_cast<QPushButton*> (sender()) == ui->quickColor_moveUp);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
460
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
461 if (ui->quickColorList->selectedItems().isEmpty())
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
462 return;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
463
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
464 QListWidgetItem* item = ui->quickColorList->selectedItems() [0];
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
465 int idx = getItemRow (item, quickColorItems);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
466 int dest = up ? (idx - 1) : (idx + 1);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
467
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
468 if (dest < 0 || dest >= quickColorItems.size())
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
469 return; // destination out of bounds
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
470
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
471 LDQuickColor tmp = quickColors[dest];
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
472 quickColors[dest] = quickColors[idx];
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
473 quickColors[idx] = tmp;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
474
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
475 updateQuickColorList (&quickColors[dest]);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
476 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
477
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
478 // =============================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
479 // Add a separator to quick colors
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
480 // -----------------------------------------------------------------------------
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
481 void ConfigDialog::slot_addColorSeparator()
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
482 { quickColors << LDQuickColor::getSeparator();
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
483 updateQuickColorList (&quickColors[quickColors.size() - 1]);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
484 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
485
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
486 // =============================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
487 // Clear all quick colors
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
488 // -----------------------------------------------------------------------------
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
489 void ConfigDialog::slot_clearColors()
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
490 { quickColors.clear();
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
491 updateQuickColorList();
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
492 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
493
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
494 // =============================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
495 // Pick a color and set the appropriate configuration option.
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
496 // -----------------------------------------------------------------------------
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
497 void ConfigDialog::pickColor (StringConfig& conf, QPushButton* button)
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
498 { QColor col = QColorDialog::getColor (QColor (conf));
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
499
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
500 if (col.isValid())
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
501 { uchar r = col.red(),
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
502 g = col.green(),
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
503 b = col.blue();
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
504 conf.value.sprintf ("#%.2X%.2X%.2X", r, g, b);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
505 setButtonBackground (button, conf.value);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
506 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
507 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
508
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
509 // =============================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
510 // -----------------------------------------------------------------------------
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
511 void ConfigDialog::slot_setGLBackground()
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
512 { pickColor (gl_bgcolor, ui->backgroundColorButton);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
513 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
514
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
515 // =============================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
516 // -----------------------------------------------------------------------------
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
517 void ConfigDialog::slot_setGLForeground()
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
518 { pickColor (gl_maincolor, ui->mainColorButton);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
519 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
520
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
521 // =============================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
522 // Sets background color of a given button.
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
523 // -----------------------------------------------------------------------------
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
524 void ConfigDialog::setButtonBackground (QPushButton* button, str value)
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
525 { button->setIcon (getIcon ("colorselect"));
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
526 button->setAutoFillBackground (true);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
527 button->setStyleSheet (fmt ("background-color: %1", value));
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
528 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
529
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
530 // =============================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
531 // Finds the given list widget item in the list of widget items given.
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
532 // -----------------------------------------------------------------------------
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
533 int ConfigDialog::getItemRow (QListWidgetItem* item, QList<QListWidgetItem*>& haystack)
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
534 { int i = 0;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
535
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
536 for (QListWidgetItem* it : haystack)
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
537 { if (it == item)
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
538 return i;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
539
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
540 ++i;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
541 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
542
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
543 return -1;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
544 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
545
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
546 // =============================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
547 // Which quick color is currently selected?
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
548 // -----------------------------------------------------------------------------
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
549 QListWidgetItem* ConfigDialog::getSelectedQuickColor()
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
550 { if (ui->quickColorList->selectedItems().isEmpty())
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
551 return null;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
552
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
553 return ui->quickColorList->selectedItems() [0];
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
554 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
555
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
556 // =============================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
557 // Get the list of shortcuts selected
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
558 // -----------------------------------------------------------------------------
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
559 QList<ShortcutListItem*> ConfigDialog::getShortcutSelection()
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
560 { QList<ShortcutListItem*> out;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
561
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
562 for (QListWidgetItem* entry : ui->shortcutsList->selectedItems())
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
563 out << static_cast<ShortcutListItem*> (entry);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
564
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
565 return out;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
566 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
567
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
568 // =============================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
569 // Edit the shortcut of a given action.
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
570 // -----------------------------------------------------------------------------
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
571 void ConfigDialog::slot_setShortcut()
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
572 { QList<ShortcutListItem*> sel = getShortcutSelection();
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
573
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
574 if (sel.size() < 1)
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
575 return;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
576
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
577 ShortcutListItem* item = sel[0];
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
578
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
579 if (KeySequenceDialog::staticDialog (item->getKeyConfig(), this))
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
580 setShortcutText (item);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
581 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
582
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
583 // =============================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
584 // Reset a shortcut to defaults
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
585 // -----------------------------------------------------------------------------
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
586 void ConfigDialog::slot_resetShortcut()
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
587 { QList<ShortcutListItem*> sel = getShortcutSelection();
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
588
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
589 for (ShortcutListItem* item : sel)
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
590 { item->getKeyConfig()->reset();
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
591 setShortcutText (item);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
592 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
593 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
594
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
595 // =============================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
596 // Remove the shortcut of an action.
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
597 // -----------------------------------------------------------------------------
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
598 void ConfigDialog::slot_clearShortcut()
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
599 { QList<ShortcutListItem*> sel = getShortcutSelection();
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
600
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
601 for (ShortcutListItem* item : sel)
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
602 { item->getKeyConfig()->value = QKeySequence();
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
603 setShortcutText (item);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
604 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
605 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
606
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
607 // =============================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
608 // Set the path of an external program
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
609 // -----------------------------------------------------------------------------
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
610 void ConfigDialog::slot_setExtProgPath()
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
611 { const LDExtProgInfo* info = null;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
612
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
613 for (const LDExtProgInfo& it : g_LDExtProgInfo)
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
614 { if (it.setPathButton == sender())
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
615 { info = &it;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
616 break;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
617 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
618 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
619
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
620 assert (info != null);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
621 str fpath = QFileDialog::getOpenFileName (this, fmt ("Path to %1", info->name), *info->path, g_extProgPathFilter);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
622
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
623 if (fpath.isEmpty())
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
624 return;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
625
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
626 info->input->setText (fpath);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
627 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
628
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
629 // =============================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
630 // '...' button pressed for the download path
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
631 // -----------------------------------------------------------------------------
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
632 void ConfigDialog::slot_findDownloadFolder()
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
633 { str dpath = QFileDialog::getExistingDirectory();
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
634 ui->downloadPath->setText (dpath);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
635 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
636
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
637 // =============================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
638 // Updates the text string for a given shortcut list item
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
639 // -----------------------------------------------------------------------------
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
640 void ConfigDialog::setShortcutText (ShortcutListItem* item)
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
641 { QAction* act = item->getAction();
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
642 str label = act->iconText();
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
643 str keybind = item->getKeyConfig()->value.toString();
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
644 item->setText (fmt ("%1 (%2)", label, keybind));
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
645 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
646
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
647 // =============================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
648 // Gets the configuration string of the quick color toolbar
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
649 // -----------------------------------------------------------------------------
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
650 str ConfigDialog::quickColorString()
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
651 { str val;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
652
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
653 for (const LDQuickColor& entry : quickColors)
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
654 { if (val.length() > 0)
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
655 val += ':';
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
656
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
657 if (entry.isSeparator())
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
658 val += '|';
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
659 else
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
660 val += fmt ("%1", entry.getColor()->index);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
661 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
662
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
663 return val;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
664 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
665
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
666 // ===============================================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
667 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
668 // ===============================================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
669 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
670 // ===============================================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
671 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
672 // ===============================================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
673 KeySequenceDialog::KeySequenceDialog (QKeySequence seq, QWidget* parent, Qt::WindowFlags f) :
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
674 QDialog (parent, f), seq (seq)
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
675 { lb_output = new QLabel;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
676 IMPLEMENT_DIALOG_BUTTONS
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
677
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
678 setWhatsThis (tr ("Into this dialog you can input a key sequence for use as a "
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
679 "shortcut in LDForge. Use OK to confirm the new shortcut and Cancel to "
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
680 "dismiss."));
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
681
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
682 QVBoxLayout* layout = new QVBoxLayout;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
683 layout->addWidget (lb_output);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
684 layout->addWidget (bbx_buttons);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
685 setLayout (layout);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
686
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
687 updateOutput();
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
688 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
689
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
690 // =============================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
691 // -----------------------------------------------------------------------------
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
692 bool KeySequenceDialog::staticDialog (KeySequenceConfig* cfg, QWidget* parent)
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
693 { KeySequenceDialog dlg (cfg->value, parent);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
694
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
695 if (dlg.exec() == false)
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
696 return false;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
697
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
698 cfg->value = dlg.seq;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
699 return true;
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
700 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
701
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
702 // =============================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
703 // -----------------------------------------------------------------------------
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
704 void KeySequenceDialog::updateOutput()
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
705 { str shortcut = seq.toString();
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
706
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
707 if (seq == QKeySequence())
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
708 shortcut = "&lt;empty&gt;";
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
709
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
710 str text = fmt ("<center><b>%1</b></center>", shortcut);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
711 lb_output->setText (text);
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
712 }
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
713
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
714 // =============================================================================
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
715 // -----------------------------------------------------------------------------
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
716 void KeySequenceDialog::keyPressEvent (QKeyEvent* ev)
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
717 { seq = ev->key() + ev->modifiers();
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
718 updateOutput();
04e140bdeb0b - changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
719 }

mercurial