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