author | Eckhart Koeppen <eckhart.koppen@nokia.com> |
Wed, 21 Apr 2010 09:15:16 +0300 | |
branch | RCL_3 |
changeset 10 | 68d3b337861b |
parent 4 | 3b1da2848fc7 |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
7 |
** This file is part of the tools applications of the Qt Toolkit. |
|
8 |
** |
|
9 |
** $QT_BEGIN_LICENSE:LGPL$ |
|
10 |
** No Commercial Usage |
|
11 |
** This file contains pre-release code and may not be distributed. |
|
12 |
** You may use this file in accordance with the terms and conditions |
|
13 |
** contained in the Technology Preview License Agreement accompanying |
|
14 |
** this package. |
|
15 |
** |
|
16 |
** GNU Lesser General Public License Usage |
|
17 |
** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 |
** General Public License version 2.1 as published by the Free Software |
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 |
** packaging of this file. Please review the following information to |
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 |
** |
|
24 |
** In addition, as a special exception, Nokia gives you certain additional |
|
25 |
** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 |
** |
|
28 |
** If you have questions regarding the use of this file, please contact |
|
29 |
** Nokia at qt-info@nokia.com. |
|
30 |
** |
|
31 |
** |
|
32 |
** |
|
33 |
** |
|
34 |
** |
|
35 |
** |
|
36 |
** |
|
37 |
** |
|
38 |
** $QT_END_LICENSE$ |
|
39 |
** |
|
40 |
****************************************************************************/ |
|
41 |
||
42 |
#include "mainwindow.h" |
|
43 |
#include "colorbutton.h" |
|
44 |
#include "previewframe.h" |
|
45 |
#include "paletteeditoradvanced.h" |
|
46 |
||
47 |
#include <QLabel> |
|
48 |
#include <QApplication> |
|
49 |
#include <QComboBox> |
|
50 |
#include <QStyleFactory> |
|
51 |
#include <QFontDatabase> |
|
52 |
#include <QLineEdit> |
|
53 |
#include <QSpinBox> |
|
54 |
#include <QCheckBox> |
|
55 |
#include <QFileDialog> |
|
56 |
#include <QAction> |
|
57 |
#include <QStatusBar> |
|
58 |
#include <QSettings> |
|
59 |
#include <QMessageBox> |
|
60 |
#include <QStyle> |
|
61 |
#include <QtEvents> |
|
62 |
#include <Q3ValueList> |
|
63 |
#include <QInputContext> |
|
64 |
#include <QInputContextFactory> |
|
65 |
#include <QtDebug> |
|
66 |
||
67 |
#include <stdlib.h> |
|
68 |
||
69 |
#ifndef QT_NO_GSTREAMER |
|
70 |
#include <gst/gst.h> |
|
71 |
#include <phonon/phononnamespace.h> |
|
72 |
#endif |
|
73 |
||
74 |
#include <QtGui/private/qt_x11_p.h> |
|
75 |
||
76 |
QT_BEGIN_NAMESPACE |
|
77 |
||
78 |
// from qapplication.cpp and qapplication_x11.cpp - These are NOT for |
|
79 |
// external use ignore them |
|
80 |
// extern bool Q_CORE_EXPORT qt_resolve_symlinks; |
|
81 |
||
82 |
static const char *appearance_text = |
|
83 |
"<p><b><font size+=2>Appearance</font></b></p>" |
|
84 |
"<hr>" |
|
85 |
"<p>Use this tab to customize the appearance of your Qt applications.</p>" |
|
86 |
"<p>You can select the default GUI Style from the drop down list and " |
|
87 |
"customize the colors.</p>" |
|
88 |
"<p>Any GUI Style plugins in your plugin path will automatically be added " |
|
89 |
"to the list of built-in Qt styles. (See the Library Paths tab for " |
|
90 |
"information on adding new plugin paths.)</p>" |
|
91 |
"<p>When you choose 3-D Effects and Window Background colors, the Qt " |
|
92 |
"Configuration program will automatically generate a palette for you. " |
|
93 |
"To customize colors further, press the Tune Palette button to open " |
|
94 |
"the advanced palette editor." |
|
95 |
"<p>The Preview Window shows what the selected Style and colors look " |
|
96 |
"like."; |
|
97 |
||
98 |
static const char *font_text = |
|
99 |
"<p><b><font size+=2>Fonts</font></b></p>" |
|
100 |
"<hr>" |
|
101 |
"<p>Use this tab to select the default font for your Qt applications. " |
|
102 |
"The selected font is shown (initially as 'Sample Text') in the line " |
|
103 |
"edit below the Family, " |
|
104 |
"Style and Point Size drop down lists.</p>" |
|
105 |
"<p>Qt has a powerful font substitution feature that allows you to " |
|
106 |
"specify a list of substitute fonts. Substitute fonts are used " |
|
107 |
"when a font cannot be loaded, or if the specified font doesn't have " |
|
108 |
"a particular character." |
|
109 |
"<p>For example, if you select the font Lucida, which doesn't have Korean " |
|
110 |
"characters, but need to show some Korean text using the Mincho font family " |
|
111 |
"you can do so by adding Mincho to the list. Once Mincho is added, any " |
|
112 |
"Korean characters that are not found in the Lucida font will be taken " |
|
113 |
"from the Mincho font. Because the font substitutions are " |
|
114 |
"lists, you can also select multiple families, such as Song Ti (for " |
|
115 |
"use with Chinese text)."; |
|
116 |
||
117 |
static const char *interface_text = |
|
118 |
"<p><b><font size+=2>Interface</font></b></p>" |
|
119 |
"<hr>" |
|
120 |
"<p>Use this tab to customize the feel of your Qt applications.</p>" |
|
121 |
"<p>If the Resolve Symlinks checkbox is checked Qt will follow symlinks " |
|
122 |
"when handling URLs. For example, in the file dialog, if this setting is turned " |
|
123 |
"on and /usr/tmp is a symlink to /var/tmp, entering the /usr/tmp directory " |
|
124 |
"will cause the file dialog to change to /var/tmp. With this setting turned " |
|
125 |
"off, symlinks are not resolved or followed.</p>" |
|
126 |
"<p>The Global Strut setting is useful for people who require a " |
|
127 |
"minimum size for all widgets (e.g. when using a touch panel or for users " |
|
128 |
"who are visually impaired). Leaving the Global Strut width and height " |
|
129 |
"at 0 will disable the Global Strut feature</p>" |
|
130 |
"<p>XIM (Extended Input Methods) are used for entering characters in " |
|
131 |
"languages that have large character sets, for example, Chinese and " |
|
132 |
"Japanese."; |
|
133 |
// ### What does the 'Enhanced support for languages written R2L do? |
|
134 |
||
135 |
static const char *printer_text = |
|
136 |
"<p><b><font size+=2>Printer</font></b></p>" |
|
137 |
"<hr>" |
|
138 |
"<p>Use this tab to configure the way Qt generates output for the printer." |
|
139 |
"You can specify if Qt should try to embed fonts into its generated output." |
|
140 |
"If you enable font embedding, the resulting postscript will be more " |
|
141 |
"portable and will more accurately reflect the " |
|
142 |
"visual output on the screen; however the resulting postscript file " |
|
143 |
"size will be bigger." |
|
144 |
"<p>When using font embedding you can select additional directories where " |
|
145 |
"Qt should search for embeddable font files. By default, the X " |
|
146 |
"server font path is used."; |
|
147 |
||
148 |
static const char *phonon_text = |
|
149 |
"<p><b><font size+=2>Phonon</font></b></p>" |
|
150 |
"<hr>" |
|
151 |
"<p>Use this tab to configure the Phonon GStreamer multimedia backend. " |
|
152 |
"<p>It is reccommended to leave all settings on \"Auto\" to let " |
|
153 |
"Phonon determine your settings automatically."; |
|
154 |
||
155 |
static QColorGroup::ColorRole centralFromItem( int item ) |
|
156 |
{ |
|
157 |
switch( item ) { |
|
158 |
case 0: return QColorGroup::Window; |
|
159 |
case 1: return QColorGroup::WindowText; |
|
160 |
case 2: return QColorGroup::Button; |
|
161 |
case 3: return QColorGroup::Base; |
|
162 |
case 4: return QColorGroup::Text; |
|
163 |
case 5: return QColorGroup::BrightText; |
|
164 |
case 6: return QColorGroup::ButtonText; |
|
165 |
case 7: return QColorGroup::Highlight; |
|
166 |
case 8: return QColorGroup::HighlightedText; |
|
167 |
default: return QColorGroup::NColorRoles; |
|
168 |
} |
|
169 |
} |
|
170 |
||
171 |
||
172 |
static QColorGroup::ColorRole effectFromItem( int item ) |
|
173 |
{ |
|
174 |
switch( item ) { |
|
175 |
case 0: return QColorGroup::Light; |
|
176 |
case 1: return QColorGroup::Midlight; |
|
177 |
case 2: return QColorGroup::Mid; |
|
178 |
case 3: return QColorGroup::Dark; |
|
179 |
case 4: return QColorGroup::Shadow; |
|
180 |
default: return QColorGroup::NColorRoles; |
|
181 |
} |
|
182 |
} |
|
183 |
||
184 |
||
185 |
static void setStyleHelper(QWidget *w, QStyle *s) |
|
186 |
{ |
|
187 |
const QObjectList children = w->children(); |
|
188 |
for (int i = 0; i < children.size(); ++i) { |
|
189 |
QObject *child = children.at(i); |
|
190 |
if (child->isWidgetType()) |
|
191 |
setStyleHelper((QWidget *) child, s); |
|
192 |
} |
|
193 |
w->setStyle(s); |
|
194 |
} |
|
195 |
||
196 |
||
197 |
MainWindow::MainWindow() |
|
198 |
: MainWindowBase(0, "main window"), |
|
199 |
editPalette(palette()), previewPalette(palette()), previewstyle(0) |
|
200 |
{ |
|
201 |
modified = true; |
|
202 |
desktopThemeName = tr("Desktop Settings (Default)"); |
|
203 |
QStringList gstyles = QStyleFactory::keys(); |
|
204 |
gstyles.sort(); |
|
205 |
gstylecombo->addItem(desktopThemeName); |
|
206 |
gstylecombo->setItemData(gstylecombo->findText(desktopThemeName), |
|
207 |
tr("Choose style and palette based on your desktop settings."), Qt::ToolTipRole); |
|
208 |
gstylecombo->insertStringList(gstyles); |
|
209 |
||
210 |
QSettings settings(QLatin1String("Trolltech")); |
|
211 |
settings.beginGroup(QLatin1String("Qt")); |
|
212 |
||
213 |
QString currentstyle = settings.value(QLatin1String("style")).toString(); |
|
214 |
if (currentstyle.isEmpty()) { |
|
215 |
gstylecombo->setCurrentItem(gstylecombo->findText(desktopThemeName)); |
|
216 |
currentstyle = QLatin1String(QApplication::style()->name()); |
|
217 |
} else { |
|
218 |
int index = gstylecombo->findText(currentstyle, Qt::MatchFixedString); |
|
219 |
if (index != -1) { |
|
220 |
gstylecombo->setCurrentItem(index); |
|
221 |
} else { // we give up |
|
222 |
gstylecombo->insertItem(QLatin1String("Unknown")); |
|
223 |
gstylecombo->setCurrentItem(gstylecombo->count() - 1); |
|
224 |
} |
|
225 |
} |
|
226 |
buttonMainColor->setColor(palette().color(QPalette::Active, |
|
227 |
QColorGroup::Button)); |
|
228 |
buttonMainColor2->setColor(palette().color(QPalette::Active, |
|
229 |
QColorGroup::Window)); |
|
230 |
connect(buttonMainColor, SIGNAL(colorChanged(QColor)), |
|
231 |
this, SLOT(buildPalette())); |
|
232 |
connect(buttonMainColor2, SIGNAL(colorChanged(QColor)), |
|
233 |
this, SLOT(buildPalette())); |
|
234 |
||
235 |
if (X11->desktopEnvironment == DE_KDE) |
|
236 |
colorConfig->hide(); |
|
237 |
else |
|
238 |
labelKDENote->hide(); |
|
239 |
||
240 |
QFontDatabase db; |
|
241 |
QStringList families = db.families(); |
|
242 |
familycombo->insertStringList(families); |
|
243 |
||
244 |
QStringList fs = families; |
|
245 |
QStringList fs2 = QFont::substitutions(); |
|
246 |
QStringList::Iterator fsit = fs2.begin(); |
|
247 |
while (fsit != fs2.end()) { |
|
248 |
if (! fs.contains(*fsit)) |
|
249 |
fs += *fsit; |
|
250 |
fsit++; |
|
251 |
} |
|
252 |
fs.sort(); |
|
253 |
familysubcombo->insertStringList(fs); |
|
254 |
||
255 |
choosesubcombo->insertStringList(families); |
|
256 |
Q3ValueList<int> sizes = db.standardSizes(); |
|
257 |
Q3ValueList<int>::Iterator it = sizes.begin(); |
|
258 |
while (it != sizes.end()) |
|
259 |
psizecombo->insertItem(QString::number(*it++)); |
|
260 |
||
261 |
dcispin->setValue(QApplication::doubleClickInterval()); |
|
262 |
cfispin->setValue(QApplication::cursorFlashTime()); |
|
263 |
wslspin->setValue(QApplication::wheelScrollLines()); |
|
264 |
// ############# |
|
265 |
// resolvelinks->setChecked(qt_resolve_symlinks); |
|
266 |
||
267 |
effectcheckbox->setChecked(QApplication::isEffectEnabled(Qt::UI_General)); |
|
268 |
effectbase->setEnabled(effectcheckbox->isChecked()); |
|
269 |
||
270 |
if (QApplication::isEffectEnabled(Qt::UI_FadeMenu)) |
|
271 |
menueffect->setCurrentItem(2); |
|
272 |
else if (QApplication::isEffectEnabled(Qt::UI_AnimateMenu)) |
|
273 |
menueffect->setCurrentItem(1); |
|
274 |
||
275 |
if (QApplication::isEffectEnabled(Qt::UI_AnimateCombo)) |
|
276 |
comboeffect->setCurrentItem(1); |
|
277 |
||
278 |
if (QApplication::isEffectEnabled(Qt::UI_FadeTooltip)) |
|
279 |
tooltipeffect->setCurrentItem(2); |
|
280 |
else if (QApplication::isEffectEnabled(Qt::UI_AnimateTooltip)) |
|
281 |
tooltipeffect->setCurrentItem(1); |
|
282 |
||
283 |
if ( QApplication::isEffectEnabled( Qt::UI_AnimateToolBox ) ) |
|
284 |
toolboxeffect->setCurrentItem( 1 ); |
|
285 |
||
286 |
QSize globalStrut = QApplication::globalStrut(); |
|
287 |
strutwidth->setValue(globalStrut.width()); |
|
288 |
strutheight->setValue(globalStrut.height()); |
|
289 |
||
290 |
// find the default family |
|
291 |
QStringList::Iterator sit = families.begin(); |
|
292 |
int i = 0, possible = -1; |
|
293 |
while (sit != families.end()) { |
|
294 |
if (*sit == QApplication::font().family()) |
|
295 |
break; |
|
296 |
if ((*sit).contains(QApplication::font().family())) |
|
297 |
possible = i; |
|
298 |
||
299 |
i++; |
|
300 |
sit++; |
|
301 |
} |
|
302 |
if (sit == families.end()) |
|
303 |
i = possible; |
|
304 |
if (i == -1) // no clue about the current font |
|
305 |
i = 0; |
|
306 |
||
307 |
familycombo->setCurrentItem(i); |
|
308 |
||
309 |
QStringList styles = db.styles(familycombo->currentText()); |
|
310 |
stylecombo->insertStringList(styles); |
|
311 |
||
312 |
QString stylestring = db.styleString(QApplication::font()); |
|
313 |
sit = styles.begin(); |
|
314 |
i = 0; |
|
315 |
possible = -1; |
|
316 |
while (sit != styles.end()) { |
|
317 |
if (*sit == stylestring) |
|
318 |
break; |
|
319 |
if ((*sit).contains(stylestring)) |
|
320 |
possible = i; |
|
321 |
||
322 |
i++; |
|
323 |
sit++; |
|
324 |
} |
|
325 |
if (sit == styles.end()) |
|
326 |
i = possible; |
|
327 |
if (i == -1) // no clue about the current font |
|
328 |
i = 0; |
|
329 |
stylecombo->setCurrentItem(i); |
|
330 |
||
331 |
i = 0; |
|
332 |
for (int psize = QApplication::font().pointSize(); i < psizecombo->count(); ++i) { |
|
333 |
const int sz = psizecombo->text(i).toInt(); |
|
334 |
if (sz == psize) { |
|
335 |
psizecombo->setCurrentItem(i); |
|
336 |
break; |
|
337 |
} else if(sz > psize) { |
|
338 |
psizecombo->insertItem(i, QString::number(psize)); |
|
339 |
psizecombo->setCurrentItem(i); |
|
340 |
break; |
|
341 |
} |
|
342 |
} |
|
343 |
||
344 |
QStringList subs = QFont::substitutes(familysubcombo->currentText()); |
|
345 |
sublistbox->clear(); |
|
346 |
sublistbox->insertStringList(subs); |
|
347 |
||
348 |
rtlExtensions->setChecked(settings.value(QLatin1String("useRtlExtensions"), false).toBool()); |
|
349 |
||
350 |
#ifdef Q_WS_X11 |
|
351 |
inputStyle->setCurrentText(settings.value(QLatin1String("XIMInputStyle"), trUtf8("On The Spot")).toString()); |
|
352 |
#else |
|
353 |
inputStyle->hide(); |
|
354 |
inputStyleLabel->hide(); |
|
355 |
#endif |
|
356 |
||
357 |
#if defined(Q_WS_X11) && !defined(QT_NO_XIM) |
|
358 |
QStringList inputMethods = QInputContextFactory::keys(); |
|
359 |
int inputMethodIndex = -1; |
|
360 |
QString defaultInputMethod = settings.value(QLatin1String("DefaultInputMethod"), QLatin1String("xim")).toString(); |
|
361 |
for (int i = inputMethods.size()-1; i >= 0; --i) { |
|
362 |
const QString &im = inputMethods.at(i); |
|
363 |
if (im.contains(QLatin1String("imsw"))) { |
|
364 |
inputMethods.removeAt(i); |
|
365 |
if (inputMethodIndex > i) |
|
366 |
--inputMethodIndex; |
|
367 |
} else if (im == defaultInputMethod) { |
|
368 |
inputMethodIndex = i; |
|
369 |
} |
|
370 |
} |
|
371 |
if (inputMethodIndex == -1 && !inputMethods.isEmpty()) |
|
372 |
inputMethodIndex = 0; |
|
373 |
inputMethod->addItems(inputMethods); |
|
374 |
inputMethod->setCurrentIndex(inputMethodIndex); |
|
375 |
#else |
|
376 |
inputMethod->hide(); |
|
377 |
inputMethodLabel->hide(); |
|
378 |
#endif |
|
379 |
||
380 |
fontembeddingcheckbox->setChecked(settings.value(QLatin1String("embedFonts"), true).toBool()); |
|
381 |
fontpaths = settings.value(QLatin1String("fontPath")).toStringList(); |
|
382 |
fontpathlistbox->insertStringList(fontpaths); |
|
383 |
||
384 |
audiosinkCombo->addItem(tr("Auto (default)"), QLatin1String("Auto")); |
|
385 |
audiosinkCombo->setItemData(audiosinkCombo->findText(tr("Auto (default)")), |
|
386 |
tr("Choose audio output automatically."), Qt::ToolTipRole); |
|
387 |
audiosinkCombo->addItem(tr("aRts"), QLatin1String("artssink")); |
|
388 |
audiosinkCombo->setItemData(audiosinkCombo->findText(tr("aRts")), |
|
389 |
tr("Experimental aRts support for GStreamer."), Qt::ToolTipRole); |
|
390 |
#ifndef QT_NO_GSTREAMER |
|
391 |
phononVersionLabel->setText(QLatin1String(Phonon::phononVersion())); |
|
392 |
if (gst_init_check(0, 0, 0)) { |
|
393 |
gchar *versionString = gst_version_string(); |
|
394 |
gstversionLabel->setText(QLatin1String(versionString)); |
|
395 |
g_free(versionString); |
|
396 |
GList* factoryList = gst_registry_get_feature_list(gst_registry_get_default (), GST_TYPE_ELEMENT_FACTORY); |
|
397 |
QString name, klass, description; |
|
398 |
for (GList* iter = g_list_first(factoryList) ; iter != NULL ; iter = g_list_next(iter)) { |
|
399 |
GstPluginFeature *feature = GST_PLUGIN_FEATURE(iter->data); |
|
400 |
klass = QLatin1String(gst_element_factory_get_klass(GST_ELEMENT_FACTORY(feature))); |
|
401 |
if (klass == QLatin1String("Sink/Audio")) { |
|
402 |
name = QLatin1String(GST_PLUGIN_FEATURE_NAME(feature)); |
|
403 |
if (name == QLatin1String("sfsink")) |
|
404 |
continue; //useless to output audio to file when you cannot set the file path |
|
405 |
else if (name == QLatin1String("autoaudiosink")) |
|
406 |
continue; //This is used implicitly from the auto setting |
|
407 |
GstElement *sink = gst_element_factory_make (qPrintable(name), NULL); |
|
408 |
if (sink) { |
|
409 |
description = QLatin1String(gst_element_factory_get_description (GST_ELEMENT_FACTORY(feature))); |
|
410 |
audiosinkCombo->addItem(name, name); |
|
411 |
audiosinkCombo->setItemData(audiosinkCombo->findText(name), description, Qt::ToolTipRole); |
|
412 |
gst_object_unref (sink); |
|
413 |
} |
|
414 |
} |
|
415 |
} |
|
416 |
g_list_free(factoryList); |
|
417 |
} |
|
418 |
#else |
|
419 |
tab4->setEnabled(false); |
|
420 |
phononLabel->setText(tr("Phonon GStreamer backend not available.")); |
|
421 |
#endif |
|
422 |
||
423 |
videomodeCombo->addItem(tr("Auto (default)"), QLatin1String("Auto")); |
|
424 |
videomodeCombo->setItemData(videomodeCombo->findText(tr("Auto (default)")), tr("Choose render method automatically"), Qt::ToolTipRole); |
|
425 |
#ifdef Q_WS_X11 |
|
426 |
videomodeCombo->addItem(tr("X11"), QLatin1String("X11")); |
|
427 |
videomodeCombo->setItemData(videomodeCombo->findText(tr("X11")), tr("Use X11 Overlays"), Qt::ToolTipRole); |
|
428 |
#endif |
|
429 |
#ifndef QT_NO_OPENGL |
|
430 |
videomodeCombo->addItem(tr("OpenGL"), QLatin1String("OpenGL")); |
|
431 |
videomodeCombo->setItemData(videomodeCombo->findText(tr("OpenGL")), tr("Use OpenGL if avaiable"), Qt::ToolTipRole); |
|
432 |
#endif |
|
433 |
videomodeCombo->addItem(tr("Software"), QLatin1String("Software")); |
|
434 |
videomodeCombo->setItemData(videomodeCombo->findText(tr("Software")), tr("Use simple software rendering"), Qt::ToolTipRole); |
|
435 |
||
436 |
QString audioSink = settings.value(QLatin1String("audiosink"), QLatin1String("Auto")).toString(); |
|
437 |
QString videoMode = settings.value(QLatin1String("videomode"), QLatin1String("Auto")).toString(); |
|
438 |
audiosinkCombo->setCurrentItem(audiosinkCombo->findData(audioSink)); |
|
439 |
videomodeCombo->setCurrentItem(videomodeCombo->findData(videoMode)); |
|
440 |
||
441 |
settings.endGroup(); // Qt |
|
442 |
||
443 |
helpview->setText(tr(appearance_text)); |
|
444 |
||
445 |
setModified(false); |
|
446 |
updateStyleLayout(); |
|
447 |
} |
|
448 |
||
449 |
||
450 |
MainWindow::~MainWindow() |
|
451 |
{ |
|
452 |
} |
|
453 |
||
454 |
#ifdef Q_WS_X11 |
|
455 |
extern void qt_x11_apply_settings_in_all_apps(); |
|
456 |
#endif |
|
457 |
||
458 |
void MainWindow::fileSave() |
|
459 |
{ |
|
460 |
if (! modified) { |
|
461 |
statusBar()->showMessage(tr("No changes to be saved."), 2000); |
|
462 |
return; |
|
463 |
} |
|
464 |
||
465 |
statusBar()->showMessage(tr("Saving changes...")); |
|
466 |
||
467 |
{ |
|
468 |
QSettings settings(QLatin1String("Trolltech")); |
|
469 |
settings.beginGroup(QLatin1String("Qt")); |
|
470 |
QFontDatabase db; |
|
471 |
QFont font = db.font(familycombo->currentText(), |
|
472 |
stylecombo->currentText(), |
|
473 |
psizecombo->currentText().toInt()); |
|
474 |
||
475 |
QStringList actcg, inactcg, discg; |
|
476 |
bool overrideDesktopSettings = (gstylecombo->currentText() != desktopThemeName); |
|
477 |
if (overrideDesktopSettings) { |
|
478 |
int i; |
|
479 |
for (i = 0; i < QColorGroup::NColorRoles; i++) |
|
480 |
actcg << editPalette.color(QPalette::Active, |
|
481 |
(QColorGroup::ColorRole) i).name(); |
|
482 |
for (i = 0; i < QColorGroup::NColorRoles; i++) |
|
483 |
inactcg << editPalette.color(QPalette::Inactive, |
|
484 |
(QColorGroup::ColorRole) i).name(); |
|
485 |
for (i = 0; i < QColorGroup::NColorRoles; i++) |
|
486 |
discg << editPalette.color(QPalette::Disabled, |
|
487 |
(QColorGroup::ColorRole) i).name(); |
|
488 |
} |
|
489 |
||
490 |
settings.setValue(QLatin1String("font"), font.toString()); |
|
491 |
settings.setValue(QLatin1String("Palette/active"), actcg); |
|
492 |
settings.setValue(QLatin1String("Palette/inactive"), inactcg); |
|
493 |
settings.setValue(QLatin1String("Palette/disabled"), discg); |
|
494 |
||
495 |
settings.setValue(QLatin1String("fontPath"), fontpaths); |
|
496 |
settings.setValue(QLatin1String("embedFonts"), fontembeddingcheckbox->isChecked()); |
|
497 |
settings.setValue(QLatin1String("style"), overrideDesktopSettings ? gstylecombo->currentText() : QString()); |
|
498 |
||
499 |
settings.setValue(QLatin1String("doubleClickInterval"), dcispin->value()); |
|
500 |
settings.setValue(QLatin1String("cursorFlashTime"), cfispin->value() == 9 ? 0 : cfispin->value() ); |
|
501 |
settings.setValue(QLatin1String("wheelScrollLines"), wslspin->value()); |
|
502 |
settings.setValue(QLatin1String("resolveSymlinks"), resolvelinks->isChecked()); |
|
503 |
||
504 |
QSize strut(strutwidth->value(), strutheight->value()); |
|
505 |
settings.setValue(QLatin1String("globalStrut/width"), strut.width()); |
|
506 |
settings.setValue(QLatin1String("globalStrut/height"), strut.height()); |
|
507 |
||
508 |
settings.setValue(QLatin1String("useRtlExtensions"), rtlExtensions->isChecked()); |
|
509 |
||
510 |
#ifdef Q_WS_X11 |
|
511 |
QString style = inputStyle->currentText(); |
|
512 |
QString str = QLatin1String("On The Spot"); |
|
513 |
if ( style == trUtf8( "Over The Spot" ) ) |
|
514 |
str = QLatin1String("Over The Spot"); |
|
515 |
else if ( style == trUtf8( "Off The Spot" ) ) |
|
516 |
str = QLatin1String("Off The Spot"); |
|
517 |
else if ( style == trUtf8( "Root" ) ) |
|
518 |
str = QLatin1String("Root"); |
|
519 |
settings.setValue( QLatin1String("XIMInputStyle"), str ); |
|
520 |
#endif |
|
521 |
#if defined(Q_WS_X11) && !defined(QT_NO_XIM) |
|
522 |
settings.setValue(QLatin1String("DefaultInputMethod"), inputMethod->currentText()); |
|
523 |
#endif |
|
524 |
||
525 |
QString audioSink = settings.value(QLatin1String("audiosink"), QLatin1String("Auto")).toString(); |
|
526 |
QString videoMode = settings.value(QLatin1String("videomode"), QLatin1String("Auto")).toString(); |
|
527 |
settings.setValue(QLatin1String("audiosink"), audiosinkCombo->itemData(audiosinkCombo->currentIndex())); |
|
528 |
settings.setValue(QLatin1String("videomode"), videomodeCombo->itemData(videomodeCombo->currentIndex())); |
|
529 |
||
530 |
QStringList effects; |
|
531 |
if (effectcheckbox->isChecked()) { |
|
532 |
effects << QLatin1String("general"); |
|
533 |
||
534 |
switch (menueffect->currentItem()) { |
|
535 |
case 1: effects << QLatin1String("animatemenu"); break; |
|
536 |
case 2: effects << QLatin1String("fademenu"); break; |
|
537 |
} |
|
538 |
||
539 |
switch (comboeffect->currentItem()) { |
|
540 |
case 1: effects << QLatin1String("animatecombo"); break; |
|
541 |
} |
|
542 |
||
543 |
switch (tooltipeffect->currentItem()) { |
|
544 |
case 1: effects << QLatin1String("animatetooltip"); break; |
|
545 |
case 2: effects << QLatin1String("fadetooltip"); break; |
|
546 |
} |
|
547 |
||
548 |
switch ( toolboxeffect->currentItem() ) { |
|
549 |
case 1: effects << QLatin1String("animatetoolbox"); break; |
|
550 |
} |
|
551 |
} else |
|
552 |
effects << QLatin1String("none"); |
|
553 |
settings.setValue(QLatin1String("GUIEffects"), effects); |
|
554 |
||
555 |
QStringList familysubs = QFont::substitutions(); |
|
556 |
QStringList::Iterator fit = familysubs.begin(); |
|
557 |
settings.beginGroup(QLatin1String("Font Substitutions")); |
|
558 |
while (fit != familysubs.end()) { |
|
559 |
QStringList subs = QFont::substitutes(*fit); |
|
560 |
settings.setValue(*fit, subs); |
|
561 |
fit++; |
|
562 |
} |
|
563 |
settings.endGroup(); // Font Substitutions |
|
564 |
settings.endGroup(); // Qt |
|
565 |
} |
|
566 |
||
567 |
#if defined(Q_WS_X11) |
|
568 |
qt_x11_apply_settings_in_all_apps(); |
|
569 |
#endif // Q_WS_X11 |
|
570 |
||
571 |
setModified(false); |
|
572 |
statusBar()->showMessage(QLatin1String("Saved changes.")); |
|
573 |
} |
|
574 |
||
575 |
||
576 |
void MainWindow::fileExit() |
|
577 |
{ |
|
578 |
qApp->closeAllWindows(); |
|
579 |
} |
|
580 |
||
581 |
||
582 |
void MainWindow::setModified(bool m) |
|
583 |
{ |
|
584 |
if (modified == m) |
|
585 |
return; |
|
586 |
||
587 |
modified = m; |
|
588 |
fileSaveAction->setEnabled(m); |
|
589 |
} |
|
590 |
||
591 |
||
592 |
void MainWindow::buildPalette() |
|
593 |
{ |
|
594 |
int i; |
|
595 |
QColorGroup cg; |
|
596 |
QColor btn = buttonMainColor->color(); |
|
597 |
QColor back = buttonMainColor2->color(); |
|
598 |
QPalette automake( btn, back ); |
|
599 |
||
600 |
for (i = 0; i<9; i++) |
|
601 |
cg.setColor( centralFromItem(i), automake.active().color( centralFromItem(i) ) ); |
|
602 |
||
603 |
editPalette.setActive( cg ); |
|
604 |
buildActiveEffect(); |
|
605 |
||
606 |
cg = editPalette.inactive(); |
|
607 |
||
608 |
QPalette temp( editPalette.active().color( QColorGroup::Button ), |
|
609 |
editPalette.active().color( QColorGroup::Window ) ); |
|
610 |
||
611 |
for (i = 0; i<9; i++) |
|
612 |
cg.setColor( centralFromItem(i), temp.inactive().color( centralFromItem(i) ) ); |
|
613 |
||
614 |
editPalette.setInactive( cg ); |
|
615 |
buildInactiveEffect(); |
|
616 |
||
617 |
cg = editPalette.disabled(); |
|
618 |
||
619 |
for (i = 0; i<9; i++) |
|
620 |
cg.setColor( centralFromItem(i), temp.disabled().color( centralFromItem(i) ) ); |
|
621 |
||
622 |
editPalette.setDisabled( cg ); |
|
623 |
buildDisabledEffect(); |
|
624 |
||
625 |
updateColorButtons(); |
|
626 |
||
627 |
setModified(true); |
|
628 |
} |
|
629 |
||
630 |
||
631 |
void MainWindow::buildActiveEffect() |
|
632 |
{ |
|
633 |
QColorGroup cg = editPalette.active(); |
|
634 |
QColor btn = cg.color( QColorGroup::Button ); |
|
635 |
||
636 |
QPalette temp( btn, btn ); |
|
637 |
||
638 |
for (int i = 0; i<5; i++) |
|
639 |
cg.setColor( effectFromItem(i), temp.active().color( effectFromItem(i) ) ); |
|
640 |
||
641 |
editPalette.setActive( cg ); |
|
642 |
setPreviewPalette( editPalette ); |
|
643 |
||
644 |
updateColorButtons(); |
|
645 |
} |
|
646 |
||
647 |
||
648 |
void MainWindow::buildInactive() |
|
649 |
{ |
|
650 |
editPalette.setInactive( editPalette.active() ); |
|
651 |
buildInactiveEffect(); |
|
652 |
} |
|
653 |
||
654 |
||
655 |
void MainWindow::buildInactiveEffect() |
|
656 |
{ |
|
657 |
QColorGroup cg = editPalette.inactive(); |
|
658 |
||
659 |
QColor light, midlight, mid, dark, shadow; |
|
660 |
QColor btn = cg.color( QColorGroup::Button ); |
|
661 |
||
662 |
light = btn.light(150); |
|
663 |
midlight = btn.light(115); |
|
664 |
mid = btn.dark(150); |
|
665 |
dark = btn.dark(); |
|
666 |
shadow = Qt::black; |
|
667 |
||
668 |
cg.setColor( QColorGroup::Light, light ); |
|
669 |
cg.setColor( QColorGroup::Midlight, midlight ); |
|
670 |
cg.setColor( QColorGroup::Mid, mid ); |
|
671 |
cg.setColor( QColorGroup::Dark, dark ); |
|
672 |
cg.setColor( QColorGroup::Shadow, shadow ); |
|
673 |
||
674 |
editPalette.setInactive( cg ); |
|
675 |
setPreviewPalette( editPalette ); |
|
676 |
updateColorButtons(); |
|
677 |
} |
|
678 |
||
679 |
||
680 |
void MainWindow::buildDisabled() |
|
681 |
{ |
|
682 |
QColorGroup cg = editPalette.active(); |
|
683 |
cg.setColor( QColorGroup::ButtonText, Qt::darkGray ); |
|
684 |
cg.setColor( QColorGroup::WindowText, Qt::darkGray ); |
|
685 |
cg.setColor( QColorGroup::Text, Qt::darkGray ); |
|
686 |
cg.setColor( QColorGroup::HighlightedText, Qt::darkGray ); |
|
687 |
editPalette.setDisabled( cg ); |
|
688 |
||
689 |
buildDisabledEffect(); |
|
690 |
} |
|
691 |
||
692 |
||
693 |
void MainWindow::buildDisabledEffect() |
|
694 |
{ |
|
695 |
QColorGroup cg = editPalette.disabled(); |
|
696 |
||
697 |
QColor light, midlight, mid, dark, shadow; |
|
698 |
QColor btn = cg.color( QColorGroup::Button ); |
|
699 |
||
700 |
light = btn.light(150); |
|
701 |
midlight = btn.light(115); |
|
702 |
mid = btn.dark(150); |
|
703 |
dark = btn.dark(); |
|
704 |
shadow = Qt::black; |
|
705 |
||
706 |
cg.setColor( QColorGroup::Light, light ); |
|
707 |
cg.setColor( QColorGroup::Midlight, midlight ); |
|
708 |
cg.setColor( QColorGroup::Mid, mid ); |
|
709 |
cg.setColor( QColorGroup::Dark, dark ); |
|
710 |
cg.setColor( QColorGroup::Shadow, shadow ); |
|
711 |
||
712 |
editPalette.setDisabled( cg ); |
|
713 |
setPreviewPalette( editPalette ); |
|
714 |
updateColorButtons(); |
|
715 |
} |
|
716 |
||
717 |
||
718 |
void MainWindow::setPreviewPalette( const QPalette& pal ) |
|
719 |
{ |
|
720 |
QColorGroup cg; |
|
721 |
||
722 |
switch (paletteCombo->currentItem()) { |
|
723 |
case 0: |
|
724 |
default: |
|
725 |
cg = pal.active(); |
|
726 |
break; |
|
727 |
case 1: |
|
728 |
cg = pal.inactive(); |
|
729 |
break; |
|
730 |
case 2: |
|
731 |
cg = pal.disabled(); |
|
732 |
break; |
|
733 |
} |
|
734 |
previewPalette.setActive( cg ); |
|
735 |
previewPalette.setInactive( cg ); |
|
736 |
previewPalette.setDisabled( cg ); |
|
737 |
||
738 |
previewFrame->setPreviewPalette(previewPalette); |
|
739 |
} |
|
740 |
||
741 |
||
742 |
void MainWindow::updateColorButtons() |
|
743 |
{ |
|
744 |
buttonMainColor->setColor( editPalette.active().color( QColorGroup::Button )); |
|
745 |
buttonMainColor2->setColor( editPalette.active().color( QColorGroup::Window )); |
|
746 |
} |
|
747 |
||
748 |
||
749 |
void MainWindow::tunePalette() |
|
750 |
{ |
|
751 |
bool ok; |
|
752 |
QPalette pal = PaletteEditorAdvanced::getPalette(&ok, editPalette, |
|
753 |
backgroundMode(), this); |
|
754 |
if (! ok) |
|
755 |
return; |
|
756 |
||
757 |
editPalette = pal; |
|
758 |
setPreviewPalette(editPalette); |
|
759 |
setModified(true); |
|
760 |
} |
|
761 |
||
762 |
||
763 |
void MainWindow::paletteSelected(int) |
|
764 |
{ |
|
765 |
setPreviewPalette(editPalette); |
|
766 |
} |
|
767 |
||
768 |
void MainWindow::updateStyleLayout() |
|
769 |
{ |
|
770 |
QString currentStyle = gstylecombo->currentText(); |
|
771 |
bool autoStyle = (currentStyle == desktopThemeName); |
|
772 |
previewFrame->setPreviewVisible(!autoStyle); |
|
773 |
groupAutoPalette->setEnabled(currentStyle.toLower() != QLatin1String("gtk") && !autoStyle); |
|
774 |
} |
|
775 |
||
776 |
void MainWindow::styleSelected(const QString &stylename) |
|
777 |
{ |
|
778 |
QStyle *style = 0; |
|
779 |
if (stylename == desktopThemeName) { |
|
780 |
setModified(true); |
|
781 |
} else { |
|
782 |
style = QStyleFactory::create(stylename); |
|
783 |
if (!style) |
|
784 |
return; |
|
785 |
setStyleHelper(previewFrame, style); |
|
786 |
delete previewstyle; |
|
787 |
previewstyle = style; |
|
788 |
setModified(true); |
|
789 |
} |
|
790 |
updateStyleLayout(); |
|
791 |
} |
|
792 |
||
793 |
||
794 |
void MainWindow::familySelected(const QString &family) |
|
795 |
{ |
|
796 |
QFontDatabase db; |
|
797 |
QStringList styles = db.styles(family); |
|
798 |
stylecombo->clear(); |
|
799 |
stylecombo->insertStringList(styles); |
|
800 |
familysubcombo->insertItem(family); |
|
801 |
buildFont(); |
|
802 |
} |
|
803 |
||
804 |
||
805 |
void MainWindow::buildFont() |
|
806 |
{ |
|
807 |
QFontDatabase db; |
|
808 |
QFont font = db.font(familycombo->currentText(), |
|
809 |
stylecombo->currentText(), |
|
810 |
psizecombo->currentText().toInt()); |
|
811 |
samplelineedit->setFont(font); |
|
812 |
setModified(true); |
|
813 |
} |
|
814 |
||
815 |
||
816 |
void MainWindow::substituteSelected(const QString &family) |
|
817 |
{ |
|
818 |
QStringList subs = QFont::substitutes(family); |
|
819 |
sublistbox->clear(); |
|
820 |
sublistbox->insertStringList(subs); |
|
821 |
} |
|
822 |
||
823 |
||
824 |
void MainWindow::removeSubstitute() |
|
825 |
{ |
|
826 |
if (sublistbox->currentItem() < 0 || |
|
827 |
uint(sublistbox->currentItem()) > sublistbox->count()) |
|
828 |
return; |
|
829 |
||
830 |
int item = sublistbox->currentItem(); |
|
831 |
QStringList subs = QFont::substitutes(familysubcombo->currentText()); |
|
832 |
subs.removeAt(sublistbox->currentItem()); |
|
833 |
sublistbox->clear(); |
|
834 |
sublistbox->insertStringList(subs); |
|
835 |
if (uint(item) > sublistbox->count()) |
|
836 |
item = int(sublistbox->count()) - 1; |
|
837 |
sublistbox->setCurrentItem(item); |
|
838 |
QFont::removeSubstitution(familysubcombo->currentText()); |
|
839 |
QFont::insertSubstitutions(familysubcombo->currentText(), subs); |
|
840 |
setModified(true); |
|
841 |
} |
|
842 |
||
843 |
||
844 |
void MainWindow::addSubstitute() |
|
845 |
{ |
|
846 |
if (sublistbox->currentItem() < 0 || |
|
847 |
uint(sublistbox->currentItem()) > sublistbox->count()) { |
|
848 |
QFont::insertSubstitution(familysubcombo->currentText(), choosesubcombo->currentText()); |
|
849 |
QStringList subs = QFont::substitutes(familysubcombo->currentText()); |
|
850 |
sublistbox->clear(); |
|
851 |
sublistbox->insertStringList(subs); |
|
852 |
setModified(true); |
|
853 |
return; |
|
854 |
} |
|
855 |
||
856 |
int item = sublistbox->currentItem(); |
|
857 |
QFont::insertSubstitution(familysubcombo->currentText(), choosesubcombo->currentText()); |
|
858 |
QStringList subs = QFont::substitutes(familysubcombo->currentText()); |
|
859 |
sublistbox->clear(); |
|
860 |
sublistbox->insertStringList(subs); |
|
861 |
sublistbox->setCurrentItem(item); |
|
862 |
setModified(true); |
|
863 |
} |
|
864 |
||
865 |
||
866 |
void MainWindow::downSubstitute() |
|
867 |
{ |
|
868 |
if (sublistbox->currentItem() < 0 || |
|
869 |
uint(sublistbox->currentItem()) >= sublistbox->count()) |
|
870 |
return; |
|
871 |
||
872 |
int item = sublistbox->currentItem(); |
|
873 |
QStringList subs = QFont::substitutes(familysubcombo->currentText()); |
|
874 |
QString fam = subs.at(item); |
|
875 |
subs.removeAt(item); |
|
876 |
subs.insert(item+1, fam); |
|
877 |
sublistbox->clear(); |
|
878 |
sublistbox->insertStringList(subs); |
|
879 |
sublistbox->setCurrentItem(item + 1); |
|
880 |
QFont::removeSubstitution(familysubcombo->currentText()); |
|
881 |
QFont::insertSubstitutions(familysubcombo->currentText(), subs); |
|
882 |
setModified(true); |
|
883 |
} |
|
884 |
||
885 |
||
886 |
void MainWindow::upSubstitute() |
|
887 |
{ |
|
888 |
if (sublistbox->currentItem() < 1) |
|
889 |
return; |
|
890 |
||
891 |
int item = sublistbox->currentItem(); |
|
892 |
QStringList subs = QFont::substitutes(familysubcombo->currentText()); |
|
893 |
QString fam = subs.at(item); |
|
894 |
subs.removeAt(item); |
|
895 |
subs.insert(item-1, fam); |
|
896 |
sublistbox->clear(); |
|
897 |
sublistbox->insertStringList(subs); |
|
898 |
sublistbox->setCurrentItem(item - 1); |
|
899 |
QFont::removeSubstitution(familysubcombo->currentText()); |
|
900 |
QFont::insertSubstitutions(familysubcombo->currentText(), subs); |
|
901 |
setModified(true); |
|
902 |
} |
|
903 |
||
904 |
||
905 |
void MainWindow::removeFontpath() |
|
906 |
{ |
|
907 |
if (fontpathlistbox->currentItem() < 0 || |
|
908 |
uint(fontpathlistbox->currentItem()) > fontpathlistbox->count()) |
|
909 |
return; |
|
910 |
||
911 |
int item = fontpathlistbox->currentItem(); |
|
912 |
fontpaths.removeAt(fontpathlistbox->currentItem()); |
|
913 |
fontpathlistbox->clear(); |
|
914 |
fontpathlistbox->insertStringList(fontpaths); |
|
915 |
if (uint(item) > fontpathlistbox->count()) |
|
916 |
item = int(fontpathlistbox->count()) - 1; |
|
917 |
fontpathlistbox->setCurrentItem(item); |
|
918 |
setModified(true); |
|
919 |
} |
|
920 |
||
921 |
||
922 |
void MainWindow::addFontpath() |
|
923 |
{ |
|
924 |
if (fontpathlineedit->text().isEmpty()) |
|
925 |
return; |
|
926 |
||
927 |
if (fontpathlistbox->currentItem() < 0 || |
|
928 |
uint(fontpathlistbox->currentItem()) > fontpathlistbox->count()) { |
|
929 |
fontpaths.append(fontpathlineedit->text()); |
|
930 |
fontpathlistbox->clear(); |
|
931 |
fontpathlistbox->insertStringList(fontpaths); |
|
932 |
setModified(true); |
|
933 |
||
934 |
return; |
|
935 |
} |
|
936 |
||
937 |
int item = fontpathlistbox->currentItem(); |
|
938 |
fontpaths.insert(fontpathlistbox->currentItem()+1, |
|
939 |
fontpathlineedit->text()); |
|
940 |
fontpathlistbox->clear(); |
|
941 |
fontpathlistbox->insertStringList(fontpaths); |
|
942 |
fontpathlistbox->setCurrentItem(item); |
|
943 |
setModified(true); |
|
944 |
} |
|
945 |
||
946 |
||
947 |
void MainWindow::downFontpath() |
|
948 |
{ |
|
949 |
if (fontpathlistbox->currentItem() < 0 || |
|
950 |
uint(fontpathlistbox->currentItem()) >= fontpathlistbox->count() - 1) |
|
951 |
return; |
|
952 |
||
953 |
int item = fontpathlistbox->currentItem(); |
|
954 |
QString fam = fontpaths.at(item); |
|
955 |
fontpaths.removeAt(item); |
|
956 |
fontpaths.insert(item+1, fam); |
|
957 |
fontpathlistbox->clear(); |
|
958 |
fontpathlistbox->insertStringList(fontpaths); |
|
959 |
fontpathlistbox->setCurrentItem(item + 1); |
|
960 |
setModified(true); |
|
961 |
} |
|
962 |
||
963 |
||
964 |
void MainWindow::upFontpath() |
|
965 |
{ |
|
966 |
if (fontpathlistbox->currentItem() < 1) |
|
967 |
return; |
|
968 |
||
969 |
int item = fontpathlistbox->currentItem(); |
|
970 |
QString fam = fontpaths.at(item); |
|
971 |
fontpaths.removeAt(item); |
|
972 |
fontpaths.insert(item-1, fam); |
|
973 |
fontpathlistbox->clear(); |
|
974 |
fontpathlistbox->insertStringList(fontpaths); |
|
975 |
fontpathlistbox->setCurrentItem(item - 1); |
|
976 |
setModified(true); |
|
977 |
} |
|
978 |
||
979 |
||
980 |
void MainWindow::browseFontpath() |
|
981 |
{ |
|
982 |
QString dirname = QFileDialog::getExistingDirectory(QString(), this, 0, |
|
983 |
tr("Select a Directory")); |
|
984 |
if (dirname.isNull()) |
|
985 |
return; |
|
986 |
||
987 |
fontpathlineedit->setText(dirname); |
|
988 |
} |
|
989 |
||
990 |
||
991 |
void MainWindow::somethingModified() |
|
992 |
{ |
|
993 |
setModified(true); |
|
994 |
} |
|
995 |
||
996 |
||
997 |
void MainWindow::helpAbout() |
|
998 |
{ |
|
999 |
QMessageBox box(this); |
|
1000 |
box.setText(tr("<h3>%1</h3>" |
|
1001 |
"<br/>Version %2" |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1002 |
"<br/><br/>Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).") |
0 | 1003 |
.arg(tr("Qt Configuration")).arg(QLatin1String(QT_VERSION_STR))); |
1004 |
box.setWindowTitle(tr("Qt Configuration")); |
|
1005 |
box.setIcon(QMessageBox::NoIcon); |
|
1006 |
box.exec(); |
|
1007 |
} |
|
1008 |
||
1009 |
||
1010 |
void MainWindow::helpAboutQt() |
|
1011 |
{ |
|
1012 |
QMessageBox::aboutQt(this, tr("Qt Configuration")); |
|
1013 |
} |
|
1014 |
||
1015 |
||
1016 |
void MainWindow::pageChanged(QWidget *page) |
|
1017 |
{ |
|
1018 |
if (page == tab) |
|
1019 |
helpview->setText(tr(interface_text)); |
|
1020 |
else if (page == tab1) |
|
1021 |
helpview->setText(tr(appearance_text)); |
|
1022 |
else if (page == tab2) |
|
1023 |
helpview->setText(tr(font_text)); |
|
1024 |
else if (page == tab3) |
|
1025 |
helpview->setText(tr(printer_text)); |
|
1026 |
else if (page == tab4) |
|
1027 |
helpview->setText(tr(phonon_text)); |
|
1028 |
} |
|
1029 |
||
1030 |
||
1031 |
void MainWindow::closeEvent(QCloseEvent *e) |
|
1032 |
{ |
|
1033 |
if (modified) { |
|
1034 |
switch(QMessageBox::warning(this, tr("Save Changes"), |
|
1035 |
tr("Save changes to settings?"), |
|
1036 |
tr("&Yes"), tr("&No"), tr("&Cancel"), 0, 2)) { |
|
1037 |
case 0: // save |
|
1038 |
qApp->processEvents(); |
|
1039 |
fileSave(); |
|
1040 |
||
1041 |
// fall through intended |
|
1042 |
case 1: // don't save |
|
1043 |
e->accept(); |
|
1044 |
break; |
|
1045 |
||
1046 |
case 2: // cancel |
|
1047 |
e->ignore(); |
|
1048 |
break; |
|
1049 |
||
1050 |
default: break; |
|
1051 |
} |
|
1052 |
} else |
|
1053 |
e->accept(); |
|
1054 |
} |
|
1055 |
||
1056 |
QT_END_NAMESPACE |