Changeset View
Changeset View
Standalone View
Standalone View
kcms/style/kcmstyle.cpp
Show All 27 Lines | |||||
28 | #include "kcmstyle.h" | 28 | #include "kcmstyle.h" | ||
29 | 29 | | |||
30 | #if defined(Q_OS_UNIX) && !defined(Q_OS_MAC) | 30 | #if defined(Q_OS_UNIX) && !defined(Q_OS_MAC) | ||
31 | #include <config-X11.h> | 31 | #include <config-X11.h> | ||
32 | #endif | 32 | #endif | ||
33 | 33 | | |||
34 | #include "styleconfdialog.h" | 34 | #include "styleconfdialog.h" | ||
35 | #include "ui_stylepreview.h" | 35 | #include "ui_stylepreview.h" | ||
36 | #include "ui_styleconfig.h" | ||||
36 | 37 | | |||
37 | #include <kaboutdata.h> | 38 | #include <kaboutdata.h> | ||
38 | #include <kapplication.h> | 39 | #include <kapplication.h> | ||
39 | #include <kcombobox.h> | 40 | #include <kcombobox.h> | ||
40 | #include <kmessagebox.h> | 41 | #include <kmessagebox.h> | ||
41 | #include <kstandarddirs.h> | 42 | #include <kstandarddirs.h> | ||
42 | #include <kautostart.h> | 43 | #include <kautostart.h> | ||
43 | #include <KDebug> | 44 | #include <KDebug> | ||
44 | #include <KLibrary> | 45 | #include <KLibrary> | ||
45 | #include <KColorScheme> | 46 | #include <KColorScheme> | ||
46 | #include <KStandardDirs> | 47 | #include <KStandardDirs> | ||
47 | #include <KNewStuff3/KNS3/DownloadDialog> | 48 | #include <KNewStuff3/KNS3/DownloadDialog> | ||
48 | #include <KConfigGroup> | 49 | #include <KConfigGroup> | ||
49 | 50 | | |||
50 | #include <QFile> | 51 | #include <QFile> | ||
51 | #include <QSettings> | 52 | #include <QSettings> | ||
52 | #include <QAbstractItemView> | 53 | #include <QAbstractItemView> | ||
53 | #include <QLabel> | 54 | #include <QLabel> | ||
55 | #include <QGroupBox> | ||||
54 | #include <QPainter> | 56 | #include <QPainter> | ||
55 | #include <QPixmapCache> | 57 | #include <QPixmapCache> | ||
56 | #include <QStyleFactory> | 58 | #include <QStyleFactory> | ||
57 | #include <QFormLayout> | 59 | #include <QFormLayout> | ||
58 | #include <QStandardItemModel> | 60 | #include <QStandardItemModel> | ||
59 | #include <QDBusConnection> | 61 | #include <QDBusConnection> | ||
60 | #include <QDBusMessage> | 62 | #include <QDBusMessage> | ||
61 | #include <QStyle> | 63 | #include <QStyle> | ||
▲ Show 20 Lines • Show All 79 Lines • ▼ Show 20 Line(s) | 142 | case QEvent::ContextMenu: | |||
141 | return true; // ignore | 143 | return true; // ignore | ||
142 | default: | 144 | default: | ||
143 | break; | 145 | break; | ||
144 | } | 146 | } | ||
145 | return false; | 147 | return false; | ||
146 | } | 148 | } | ||
147 | }; | 149 | }; | ||
148 | 150 | | |||
151 | class StyleConfig : public QWidget, public Ui::StyleConfig | ||||
152 | { | ||||
153 | public: | ||||
154 | StyleConfig(QWidget *parent = nullptr) | ||||
155 | : QWidget(parent) | ||||
156 | { | ||||
157 | setupUi(this); | ||||
158 | } | ||||
159 | }; | ||||
160 | | ||||
149 | QString KCMStyle::defaultStyle() | 161 | QString KCMStyle::defaultStyle() | ||
150 | { | 162 | { | ||
151 | #if defined(Q_OS_UNIX) && !defined(Q_OS_MAC) | 163 | #if defined(Q_OS_UNIX) && !defined(Q_OS_MAC) | ||
152 | return QStringLiteral("breeze"); | 164 | return QStringLiteral("breeze"); | ||
153 | #else | 165 | #else | ||
154 | return QString(); // native style | 166 | return QString(); // native style | ||
155 | #endif | 167 | #endif | ||
156 | } | 168 | } | ||
157 | 169 | | |||
158 | KCMStyle::KCMStyle( QWidget* parent, const QVariantList& ) | 170 | KCMStyle::KCMStyle( QWidget* parent, const QVariantList& ) | ||
159 | : KCModule( parent ), appliedStyle(nullptr) | 171 | : KCModule( parent ), appliedStyle(nullptr) | ||
160 | { | 172 | { | ||
161 | setQuickHelp( i18n("<h1>Style</h1>" | 173 | setQuickHelp( i18n("This module allows you to modify the visual appearance " | ||
162 | "This module allows you to modify the visual appearance " | 174 | "of applications' user interface elements.")); | ||
ngraham: "the application style" isn't an example of "user interface elements" so the sentence does not… | |||||
163 | "of user interface elements, such as the widget style " | | |||
164 | "and effects.")); | | |||
165 | 175 | | |||
166 | m_bStyleDirty= false; | 176 | m_bStyleDirty= false; | ||
167 | m_bEffectsDirty = false; | 177 | m_bEffectsDirty = false; | ||
168 | 178 | | |||
169 | 179 | | |||
170 | KGlobal::dirs()->addResourceType("themes", "data", "kstyle/themes"); | 180 | KGlobal::dirs()->addResourceType("themes", "data", "kstyle/themes"); | ||
171 | 181 | | |||
172 | KAboutData *about = | 182 | KAboutData *about = | ||
173 | new KAboutData( QStringLiteral("kcmstyle"), i18n("Widget Style"), QStringLiteral("1.0"), | 183 | new KAboutData( QStringLiteral("kcmstyle"), i18n("Application Style"), QStringLiteral("1.0"), | ||
174 | QString(), KAboutLicense::GPL, | 184 | QString(), KAboutLicense::GPL, | ||
175 | i18n("(c) 2002 Karol Szwed, Daniel Molkentin")); | 185 | i18n("(c) 2002 Karol Szwed, Daniel Molkentin")); | ||
176 | 186 | | |||
177 | about->addAuthor(i18n("Karol Szwed"), QString(), QStringLiteral("gallium@kde.org")); | 187 | about->addAuthor(i18n("Karol Szwed"), QString(), QStringLiteral("gallium@kde.org")); | ||
178 | about->addAuthor(i18n("Daniel Molkentin"), QString(), QStringLiteral("molkentin@kde.org")); | 188 | about->addAuthor(i18n("Daniel Molkentin"), QString(), QStringLiteral("molkentin@kde.org")); | ||
179 | setAboutData( about ); | 189 | setAboutData( about ); | ||
180 | 190 | | |||
181 | // Setup pages and mainLayout | 191 | // Setup mainLayout | ||
182 | mainLayout = new QVBoxLayout( this ); | 192 | mainLayout = new QVBoxLayout( this ); | ||
183 | mainLayout->setContentsMargins(0, 0, 0, 0); | 193 | mainLayout->setContentsMargins(0, 0, 0, 0); | ||
184 | 194 | | |||
185 | tabWidget = new QTabWidget( this ); | 195 | styleConfig = new StyleConfig(); | ||
186 | mainLayout->addWidget( tabWidget ); | 196 | | ||
197 | QHBoxLayout *previewLayout = new QHBoxLayout(); | ||||
198 | QGroupBox *gbPreview = new QGroupBox( i18n( "Preview" ) ); | ||||
199 | QHBoxLayout *previewLayoutInner = new QHBoxLayout(gbPreview); | ||||
200 | previewLayout->setContentsMargins(0, 0, 0, 0); | ||||
201 | previewLayoutInner->setContentsMargins(0, 0, 0, 0); | ||||
202 | previewLayout->addStretch(); | ||||
203 | previewLayout->addWidget( gbPreview ); | ||||
204 | previewLayout->addStretch(); | ||||
187 | 205 | | |||
188 | // Add Page1 (Applications Style) | | |||
189 | // ----------------- | | |||
190 | //gbWidgetStyle = new QGroupBox( i18n("Widget Style"), page1 ); | | |||
191 | page1 = new QWidget; | | |||
192 | page1Layout = new QVBoxLayout( page1 ); | | |||
193 | | ||||
194 | QWidget* gbWidgetStyle = new QWidget( page1 ); | | |||
195 | QVBoxLayout *widgetLayout = new QVBoxLayout(gbWidgetStyle); | | |||
196 | | ||||
197 | gbWidgetStyleLayout = new QVBoxLayout; | | |||
198 | widgetLayout->addLayout( gbWidgetStyleLayout ); | | |||
199 | gbWidgetStyleLayout->setAlignment( Qt::AlignTop ); | | |||
200 | hbLayout = new QHBoxLayout( ); | | |||
201 | hbLayout->setObjectName( QStringLiteral("hbLayout") ); | | |||
202 | | ||||
203 | QLabel* label=new QLabel(i18n("Widget style:"),this); | | |||
204 | hbLayout->addWidget( label ); | | |||
205 | | ||||
206 | cbStyle = new KComboBox( gbWidgetStyle ); | | |||
207 | cbStyle->setObjectName( QStringLiteral("cbStyle") ); | | |||
208 | cbStyle->setEditable( false ); | | |||
209 | hbLayout->addWidget( cbStyle ); | | |||
210 | hbLayout->setStretchFactor( cbStyle, 1 ); | | |||
211 | label->setBuddy(cbStyle); | | |||
212 | | ||||
213 | pbConfigStyle = new QPushButton( QIcon::fromTheme(QStringLiteral("configure")), i18n("Con&figure..."), gbWidgetStyle ); | | |||
214 | pbConfigStyle->setEnabled( false ); | | |||
215 | hbLayout->addWidget( pbConfigStyle ); | | |||
216 | | ||||
217 | gbWidgetStyleLayout->addLayout( hbLayout ); | | |||
218 | | ||||
219 | lblStyleDesc = new QLabel( gbWidgetStyle ); | | |||
220 | gbWidgetStyleLayout->addWidget( lblStyleDesc ); | | |||
221 | | ||||
222 | QGroupBox *gbPreview = new QGroupBox( i18n( "Preview" ), page1 ); | | |||
223 | QVBoxLayout *previewLayout = new QVBoxLayout(gbPreview); | | |||
224 | previewLayout->setMargin( 0 ); | | |||
225 | stylePreview = new StylePreview( gbPreview ); | 206 | stylePreview = new StylePreview( gbPreview ); | ||
226 | gbPreview->layout()->addWidget( stylePreview ); | 207 | previewLayoutInner->addWidget( stylePreview ); | ||
227 | 208 | | |||
228 | page1Layout->addWidget( gbWidgetStyle ); | 209 | mainLayout->addWidget( styleConfig ); | ||
229 | page1Layout->addWidget( gbPreview ); | 210 | mainLayout->addLayout( previewLayout ); | ||
230 | page1Layout->addStretch(); | 211 | mainLayout->addStretch(); | ||
231 | 212 | | |||
232 | connect( cbStyle, SIGNAL(activated(int)), this, SLOT(styleChanged()) ); | 213 | connect( styleConfig->comboStyle, SIGNAL(activated(int)), this, SLOT(styleChanged()) ); | ||
233 | connect( cbStyle, SIGNAL(activated(int)), this, SLOT(updateConfigButton())); | 214 | connect( styleConfig->comboStyle, SIGNAL(activated(int)), this, SLOT(updateConfigButton()) ); | ||
234 | connect( pbConfigStyle, &QAbstractButton::clicked, this, &KCMStyle::styleSpecificConfig); | 215 | connect( styleConfig->pbConfigStyle, &QAbstractButton::clicked, this, &KCMStyle::styleSpecificConfig ); | ||
235 | 216 | connect( styleConfig->comboStyle, SIGNAL(activated(int)), this, SLOT(setStyleDirty()) ); | |||
236 | // Add Page2 (Effects) | 217 | connect( styleConfig->cbIconsOnButtons, &QAbstractButton::toggled, this, &KCMStyle::setEffectsDirty ); | ||
237 | // ------------------- | 218 | connect( styleConfig->cbIconsInMenus, &QAbstractButton::toggled, this, &KCMStyle::setEffectsDirty ); | ||
238 | page2 = new QWidget; | 219 | connect( styleConfig->comboToolbarIcons, SIGNAL(activated(int)), this, SLOT(setEffectsDirty()) ); | ||
239 | fineTuningUi.setupUi(page2); | 220 | connect( styleConfig->comboSecondaryToolbarIcons, SIGNAL(activated(int)), this, SLOT(setEffectsDirty()) ); | ||
240 | | ||||
241 | connect(cbStyle, SIGNAL(activated(int)), this, SLOT(setStyleDirty())); | | |||
242 | connect(fineTuningUi.cbIconsOnButtons, &QAbstractButton::toggled, this, &KCMStyle::setEffectsDirty); | | |||
243 | connect(fineTuningUi.cbIconsInMenus, &QAbstractButton::toggled, this, &KCMStyle::setEffectsDirty); | | |||
244 | connect(fineTuningUi.comboToolbarIcons, SIGNAL(activated(int)), this, SLOT(setEffectsDirty())); | | |||
245 | connect(fineTuningUi.comboSecondaryToolbarIcons, SIGNAL(activated(int)), this, SLOT(setEffectsDirty())); | | |||
246 | 221 | | |||
247 | addWhatsThis(); | 222 | addWhatsThis(); | ||
248 | | ||||
249 | // Insert the pages into the tabWidget | | |||
250 | tabWidget->addTab(page1, i18nc("@title:tab", "&Applications")); | | |||
251 | tabWidget->addTab(page2, i18nc("@title:tab", "&Fine Tuning")); | | |||
252 | } | 223 | } | ||
253 | 224 | | |||
254 | 225 | | |||
255 | KCMStyle::~KCMStyle() | 226 | KCMStyle::~KCMStyle() | ||
256 | { | 227 | { | ||
257 | qDeleteAll(styleEntries); | 228 | qDeleteAll(styleEntries); | ||
258 | delete appliedStyle; | 229 | delete appliedStyle; | ||
259 | } | 230 | } | ||
260 | 231 | | |||
261 | void KCMStyle::updateConfigButton() | 232 | void KCMStyle::updateConfigButton() | ||
262 | { | 233 | { | ||
263 | if (!styleEntries[currentStyle()] || styleEntries[currentStyle()]->configPage.isEmpty()) { | 234 | if (!styleEntries[currentStyle()] || styleEntries[currentStyle()]->configPage.isEmpty()) { | ||
264 | pbConfigStyle->setEnabled(false); | 235 | styleConfig->pbConfigStyle->setEnabled(false); | ||
265 | return; | 236 | return; | ||
266 | } | 237 | } | ||
267 | 238 | | |||
268 | // We don't check whether it's loadable here - | 239 | // We don't check whether it's loadable here - | ||
269 | // lets us report an error and not waste time | 240 | // lets us report an error and not waste time | ||
270 | // loading things if the user doesn't click the button | 241 | // loading things if the user doesn't click the button | ||
271 | pbConfigStyle->setEnabled( true ); | 242 | styleConfig->pbConfigStyle->setEnabled( true ); | ||
272 | } | 243 | } | ||
273 | 244 | | |||
274 | void KCMStyle::styleSpecificConfig() | 245 | void KCMStyle::styleSpecificConfig() | ||
275 | { | 246 | { | ||
276 | QString libname = styleEntries[currentStyle()]->configPage; | 247 | QString libname = styleEntries[currentStyle()]->configPage; | ||
277 | 248 | | |||
278 | KLibrary library(libname); | 249 | KLibrary library(libname); | ||
279 | if (!library.load()) { | 250 | if (!library.load()) { | ||
▲ Show 20 Lines • Show All 79 Lines • ▼ Show 20 Line(s) | 329 | { | |||
359 | // Don't do anything if we don't need to. | 330 | // Don't do anything if we don't need to. | ||
360 | if ( !(m_bStyleDirty | m_bEffectsDirty ) ) | 331 | if ( !(m_bStyleDirty | m_bEffectsDirty ) ) | ||
361 | return; | 332 | return; | ||
362 | 333 | | |||
363 | // Save effects. | 334 | // Save effects. | ||
364 | KConfig _config(QStringLiteral("kdeglobals"), KConfig::NoGlobals); | 335 | KConfig _config(QStringLiteral("kdeglobals"), KConfig::NoGlobals); | ||
365 | KConfigGroup config(&_config, "KDE"); | 336 | KConfigGroup config(&_config, "KDE"); | ||
366 | // Effects page | 337 | // Effects page | ||
367 | config.writeEntry( "ShowIconsOnPushButtons", fineTuningUi.cbIconsOnButtons->isChecked()); | 338 | config.writeEntry( "ShowIconsOnPushButtons", styleConfig->cbIconsOnButtons->isChecked()); | ||
368 | config.writeEntry( "ShowIconsInMenuItems", fineTuningUi.cbIconsInMenus->isChecked()); | 339 | config.writeEntry( "ShowIconsInMenuItems", styleConfig->cbIconsInMenus->isChecked()); | ||
369 | 340 | | |||
370 | config.writeEntry("widgetStyle", currentStyle()); | 341 | config.writeEntry("widgetStyle", currentStyle()); | ||
371 | 342 | | |||
372 | KConfigGroup toolbarStyleGroup(&_config, "Toolbar style"); | 343 | KConfigGroup toolbarStyleGroup(&_config, "Toolbar style"); | ||
373 | toolbarStyleGroup.writeEntry("ToolButtonStyle", | 344 | toolbarStyleGroup.writeEntry("ToolButtonStyle", | ||
374 | toolbarButtonText(fineTuningUi.comboToolbarIcons->currentIndex())); | 345 | toolbarButtonText(styleConfig->comboToolbarIcons->currentIndex())); | ||
375 | toolbarStyleGroup.writeEntry("ToolButtonStyleOtherToolbars", | 346 | toolbarStyleGroup.writeEntry("ToolButtonStyleOtherToolbars", | ||
376 | toolbarButtonText(fineTuningUi.comboSecondaryToolbarIcons->currentIndex())); | 347 | toolbarButtonText(styleConfig->comboSecondaryToolbarIcons->currentIndex())); | ||
377 | 348 | | |||
378 | _config.sync(); | 349 | _config.sync(); | ||
379 | 350 | | |||
380 | // Export the changes we made to qtrc, and update all qt-only | 351 | // Export the changes we made to qtrc, and update all qt-only | ||
381 | // applications on the fly, ensuring that we still follow the user's | 352 | // applications on the fly, ensuring that we still follow the user's | ||
382 | // export fonts/colors settings. | 353 | // export fonts/colors settings. | ||
383 | if (m_bStyleDirty || m_bEffectsDirty) // Export only if necessary | 354 | if (m_bStyleDirty || m_bEffectsDirty) // Export only if necessary | ||
384 | { | 355 | { | ||
Show All 35 Lines | |||||
420 | { | 391 | { | ||
421 | StyleEntry* se = styleEntries[str.toLower()]; | 392 | StyleEntry* se = styleEntries[str.toLower()]; | ||
422 | 393 | | |||
423 | QString name = se ? se->name : str; | 394 | QString name = se ? se->name : str; | ||
424 | 395 | | |||
425 | combobox_item = 0; | 396 | combobox_item = 0; | ||
426 | 397 | | |||
427 | //look up name | 398 | //look up name | ||
428 | for( int i = 0; i < cbStyle->count(); i++ ) | 399 | for( int i = 0; i < styleConfig->comboStyle->count(); i++ ) | ||
429 | { | 400 | { | ||
430 | if ( cbStyle->itemText(i) == name ) | 401 | if ( styleConfig->comboStyle->itemText(i) == name ) | ||
431 | { | 402 | { | ||
432 | combobox_item = i; | 403 | combobox_item = i; | ||
433 | return true; | 404 | return true; | ||
434 | } | 405 | } | ||
435 | } | 406 | } | ||
436 | 407 | | |||
437 | return false; | 408 | return false; | ||
438 | } | 409 | } | ||
Show All 12 Lines | 421 | if (!found) | |||
451 | found = findStyle( QStringLiteral("plastique"), item ); | 422 | found = findStyle( QStringLiteral("plastique"), item ); | ||
452 | if (!found) | 423 | if (!found) | ||
453 | found = findStyle( QStringLiteral("windows"), item ); | 424 | found = findStyle( QStringLiteral("windows"), item ); | ||
454 | if (!found) | 425 | if (!found) | ||
455 | found = findStyle( QStringLiteral("platinum"), item ); | 426 | found = findStyle( QStringLiteral("platinum"), item ); | ||
456 | if (!found) | 427 | if (!found) | ||
457 | found = findStyle( QStringLiteral("motif"), item ); | 428 | found = findStyle( QStringLiteral("motif"), item ); | ||
458 | 429 | | |||
459 | cbStyle->setCurrentIndex( item ); | 430 | styleConfig->comboStyle->setCurrentIndex( item ); | ||
460 | 431 | | |||
461 | m_bStyleDirty = true; | 432 | m_bStyleDirty = true; | ||
462 | switchStyle( currentStyle() ); // make resets visible | 433 | switchStyle( currentStyle() ); // make resets visible | ||
463 | 434 | | |||
464 | // Effects | 435 | // Effects | ||
465 | fineTuningUi.comboToolbarIcons->setCurrentIndex(toolbarButtonIndex(QStringLiteral("TextBesideIcon"))); | 436 | styleConfig->comboToolbarIcons->setCurrentIndex(toolbarButtonIndex(QStringLiteral("TextBesideIcon"))); | ||
466 | fineTuningUi.comboSecondaryToolbarIcons->setCurrentIndex(toolbarButtonIndex(QStringLiteral("TextBesideIcon"))); | 437 | styleConfig->comboSecondaryToolbarIcons->setCurrentIndex(toolbarButtonIndex(QStringLiteral("TextBesideIcon"))); | ||
467 | fineTuningUi.cbIconsOnButtons->setChecked(true); | 438 | styleConfig->cbIconsOnButtons->setChecked(true); | ||
468 | fineTuningUi.cbIconsInMenus->setChecked(true); | 439 | styleConfig->cbIconsInMenus->setChecked(true); | ||
469 | emit changed(true); | 440 | emit changed(true); | ||
441 | emit updateConfigButton(); | ||||
470 | } | 442 | } | ||
471 | 443 | | |||
472 | void KCMStyle::setEffectsDirty() | 444 | void KCMStyle::setEffectsDirty() | ||
473 | { | 445 | { | ||
474 | m_bEffectsDirty = true; | 446 | m_bEffectsDirty = true; | ||
475 | emit changed(true); | 447 | emit changed(true); | ||
476 | } | 448 | } | ||
477 | 449 | | |||
478 | void KCMStyle::setStyleDirty() | 450 | void KCMStyle::setStyleDirty() | ||
479 | { | 451 | { | ||
480 | m_bStyleDirty = true; | 452 | m_bStyleDirty = true; | ||
481 | emit changed(true); | 453 | emit changed(true); | ||
482 | } | 454 | } | ||
483 | 455 | | |||
484 | // ---------------------------------------------------------------- | 456 | // ---------------------------------------------------------------- | ||
485 | // All the Style Switching / Preview stuff | 457 | // All the Style Switching / Preview stuff | ||
486 | // ---------------------------------------------------------------- | 458 | // ---------------------------------------------------------------- | ||
487 | 459 | | |||
488 | void KCMStyle::loadStyle( KConfig& config ) | 460 | void KCMStyle::loadStyle( KConfig& config ) | ||
489 | { | 461 | { | ||
490 | cbStyle->clear(); | 462 | styleConfig->comboStyle->clear(); | ||
491 | // Create a dictionary of WidgetStyle to Name and Desc. mappings, | 463 | // Create a dictionary of WidgetStyle to Name and Desc. mappings, | ||
492 | // as well as the config page info | 464 | // as well as the config page info | ||
493 | qDeleteAll(styleEntries); | 465 | qDeleteAll(styleEntries); | ||
494 | styleEntries.clear(); | 466 | styleEntries.clear(); | ||
495 | 467 | | |||
496 | QString strWidgetStyle; | 468 | QString strWidgetStyle; | ||
497 | QStringList list = KGlobal::dirs()->findAllResources("themes", QStringLiteral("*.themerc"), | 469 | QStringList list = KGlobal::dirs()->findAllResources("themes", QStringLiteral("*.themerc"), | ||
498 | KStandardDirs::Recursive | | 470 | KStandardDirs::Recursive | | ||
▲ Show 20 Lines • Show All 49 Lines • ▼ Show 20 Line(s) | 506 | { | |||
548 | { | 520 | { | ||
549 | styles += (*it); //Fall back to the key (but in original case) | 521 | styles += (*it); //Fall back to the key (but in original case) | ||
550 | nameToStyleKey[*it] = id; | 522 | nameToStyleKey[*it] = id; | ||
551 | } | 523 | } | ||
552 | } | 524 | } | ||
553 | 525 | | |||
554 | // Sort the style list, and add it to the combobox | 526 | // Sort the style list, and add it to the combobox | ||
555 | styles.sort(); | 527 | styles.sort(); | ||
556 | cbStyle->addItems( styles ); | 528 | styleConfig->comboStyle->addItems( styles ); | ||
557 | 529 | | |||
558 | // Find out which style is currently being used | 530 | // Find out which style is currently being used | ||
559 | KConfigGroup configGroup = config.group( "KDE" ); | 531 | KConfigGroup configGroup = config.group( "KDE" ); | ||
560 | QString defaultStyle = KCMStyle::defaultStyle(); | 532 | QString defaultStyle = KCMStyle::defaultStyle(); | ||
561 | QString cfgStyle = configGroup.readEntry( "widgetStyle", defaultStyle ); | 533 | QString cfgStyle = configGroup.readEntry( "widgetStyle", defaultStyle ); | ||
562 | 534 | | |||
563 | // Select the current style | 535 | // Select the current style | ||
564 | // Do not use cbStyle->listBox() as this may be NULL for some styles when | 536 | // Do not use comboStyle->listBox() as this may be NULL for some styles when | ||
565 | // they use QPopupMenus for the drop-down list! | 537 | // they use QPopupMenus for the drop-down list! | ||
566 | 538 | | |||
567 | // ##### Since Trolltech likes to seemingly copy & paste code, | 539 | // ##### Since Trolltech likes to seemingly copy & paste code, | ||
568 | // QStringList::findItem() doesn't have a Qt::StringComparisonMode field. | 540 | // QStringList::findItem() doesn't have a Qt::StringComparisonMode field. | ||
569 | // We roll our own (yuck) | 541 | // We roll our own (yuck) | ||
570 | cfgStyle = cfgStyle.toLower(); | 542 | cfgStyle = cfgStyle.toLower(); | ||
571 | int item = 0; | 543 | int item = 0; | ||
572 | for( int i = 0; i < cbStyle->count(); i++ ) | 544 | for( int i = 0; i < styleConfig->comboStyle->count(); i++ ) | ||
573 | { | 545 | { | ||
574 | QString id = nameToStyleKey[cbStyle->itemText(i)]; | 546 | QString id = nameToStyleKey[styleConfig->comboStyle->itemText(i)]; | ||
575 | item = i; | 547 | item = i; | ||
576 | if ( id == cfgStyle ) // ExactMatch | 548 | if ( id == cfgStyle ) // ExactMatch | ||
577 | break; | 549 | break; | ||
578 | else if ( id.contains( cfgStyle ) ) | 550 | else if ( id.contains( cfgStyle ) ) | ||
579 | break; | 551 | break; | ||
580 | else if ( id.contains( QApplication::style()->metaObject()->className() ) ) | 552 | else if ( id.contains( QApplication::style()->metaObject()->className() ) ) | ||
581 | break; | 553 | break; | ||
582 | item = 0; | 554 | item = 0; | ||
583 | } | 555 | } | ||
584 | cbStyle->setCurrentIndex( item ); | 556 | styleConfig->comboStyle->setCurrentIndex( item ); | ||
585 | m_bStyleDirty = false; | 557 | m_bStyleDirty = false; | ||
586 | 558 | | |||
587 | switchStyle( currentStyle() ); // make resets visible | 559 | switchStyle( currentStyle() ); // make resets visible | ||
588 | } | 560 | } | ||
589 | 561 | | |||
590 | QString KCMStyle::currentStyle() | 562 | QString KCMStyle::currentStyle() | ||
591 | { | 563 | { | ||
592 | return nameToStyleKey[cbStyle->currentText()]; | 564 | return nameToStyleKey[styleConfig->comboStyle->currentText()]; | ||
593 | } | 565 | } | ||
594 | 566 | | |||
595 | 567 | | |||
596 | void KCMStyle::styleChanged() | 568 | void KCMStyle::styleChanged() | ||
597 | { | 569 | { | ||
598 | switchStyle( currentStyle() ); | 570 | switchStyle( currentStyle() ); | ||
599 | } | 571 | } | ||
600 | 572 | | |||
Show All 14 Lines | 575 | { | |||
615 | 587 | | |||
616 | setStyleRecursive( stylePreview, style ); | 588 | setStyleRecursive( stylePreview, style ); | ||
617 | 589 | | |||
618 | // this flickers, but reliably draws the widgets correctly. | 590 | // this flickers, but reliably draws the widgets correctly. | ||
619 | stylePreview->resize( stylePreview->sizeHint() ); | 591 | stylePreview->resize( stylePreview->sizeHint() ); | ||
620 | 592 | | |||
621 | delete appliedStyle; | 593 | delete appliedStyle; | ||
622 | appliedStyle = style; | 594 | appliedStyle = style; | ||
623 | | ||||
624 | // Set the correct style description | | |||
625 | StyleEntry* entry = styleEntries[ styleName ]; | | |||
626 | QString desc; | | |||
627 | desc = i18n("Description: %1", entry ? entry->desc : i18n("No description available.") ); | | |||
628 | lblStyleDesc->setText( desc ); | | |||
629 | } | 595 | } | ||
630 | 596 | | |||
631 | void KCMStyle::setStyleRecursive(QWidget* w, QStyle* s) | 597 | void KCMStyle::setStyleRecursive(QWidget* w, QStyle* s) | ||
632 | { | 598 | { | ||
633 | // Don't let broken styles kill the palette | 599 | // Don't let broken styles kill the palette | ||
634 | // for other styles being previewed. (e.g SGI style) | 600 | // for other styles being previewed. (e.g SGI style) | ||
635 | w->setPalette(QPalette()); | 601 | w->setPalette(QPalette()); | ||
636 | 602 | | |||
▲ Show 20 Lines • Show All 71 Lines • ▼ Show 20 Line(s) | |||||
708 | } | 674 | } | ||
709 | 675 | | |||
710 | void KCMStyle::loadEffects( KConfig& config ) | 676 | void KCMStyle::loadEffects( KConfig& config ) | ||
711 | { | 677 | { | ||
712 | // KDE's Part via KConfig | 678 | // KDE's Part via KConfig | ||
713 | KConfigGroup configGroup = config.group("Toolbar style"); | 679 | KConfigGroup configGroup = config.group("Toolbar style"); | ||
714 | 680 | | |||
715 | QString tbIcon = configGroup.readEntry("ToolButtonStyle", "TextBesideIcon"); | 681 | QString tbIcon = configGroup.readEntry("ToolButtonStyle", "TextBesideIcon"); | ||
716 | fineTuningUi.comboToolbarIcons->setCurrentIndex(toolbarButtonIndex(tbIcon)); | 682 | styleConfig->comboToolbarIcons->setCurrentIndex(toolbarButtonIndex(tbIcon)); | ||
717 | tbIcon = configGroup.readEntry("ToolButtonStyleOtherToolbars", "TextBesideIcon"); | 683 | tbIcon = configGroup.readEntry("ToolButtonStyleOtherToolbars", "TextBesideIcon"); | ||
718 | fineTuningUi.comboSecondaryToolbarIcons->setCurrentIndex(toolbarButtonIndex(tbIcon)); | 684 | styleConfig->comboSecondaryToolbarIcons->setCurrentIndex(toolbarButtonIndex(tbIcon)); | ||
719 | 685 | | |||
720 | configGroup = config.group("KDE"); | 686 | configGroup = config.group("KDE"); | ||
721 | fineTuningUi.cbIconsOnButtons->setChecked(configGroup.readEntry("ShowIconsOnPushButtons", true)); | 687 | styleConfig->cbIconsOnButtons->setChecked(configGroup.readEntry("ShowIconsOnPushButtons", true)); | ||
722 | fineTuningUi.cbIconsInMenus->setChecked(configGroup.readEntry("ShowIconsInMenuItems", true)); | 688 | styleConfig->cbIconsInMenus->setChecked(configGroup.readEntry("ShowIconsInMenuItems", true)); | ||
723 | 689 | | |||
724 | m_bEffectsDirty = false; | 690 | m_bEffectsDirty = false; | ||
725 | } | 691 | } | ||
726 | 692 | | |||
727 | void KCMStyle::addWhatsThis() | 693 | void KCMStyle::addWhatsThis() | ||
728 | { | 694 | { | ||
729 | // Page1 | 695 | stylePreview->setWhatsThis( i18n("This area shows a preview of the currently selected style " | ||
730 | cbStyle->setWhatsThis( i18n("Here you can choose from a list of" | 696 | "without having to apply it to the whole desktop.") ); | ||
697 | styleConfig->comboStyle->setWhatsThis( i18n("Here you can choose from a list of" | ||||
731 | " predefined widget styles (e.g. the way buttons are drawn) which" | 698 | " predefined widget styles (e.g. the way buttons are drawn) which" | ||
732 | " may or may not be combined with a theme (additional information" | 699 | " may or may not be combined with a theme (additional information" | ||
733 | " like a marble texture or a gradient).") ); | 700 | " like a marble texture or a gradient).") ); | ||
734 | stylePreview->setWhatsThis( i18n("This area shows a preview of the currently selected style " | 701 | styleConfig->cbIconsOnButtons->setWhatsThis( i18n( "If you enable this option, applications will " | ||
735 | "without having to apply it to the whole desktop.") ); | 702 | "show small icons alongside some important buttons.") ); | ||
736 | // Page2 | 703 | styleConfig->cbIconsInMenus->setWhatsThis( i18n( "If you enable this option, applications will " | ||
737 | page2->setWhatsThis( i18n("This page allows you to choose details about the widget style options") ); | 704 | "show small icons alongside most menu items.") ); | ||
738 | fineTuningUi.comboToolbarIcons->setWhatsThis( i18n( "<p><b>No Text:</b> Shows only icons on toolbar buttons. " | 705 | styleConfig->comboToolbarIcons->setWhatsThis( i18n( "<p><b>No text:</b> Shows only icons on toolbar buttons. " | ||
739 | "Best option for low resolutions.</p>" | 706 | "Best option for low resolutions.</p>" | ||
740 | "<p><b>Text Only: </b>Shows only text on toolbar buttons.</p>" | 707 | "<p><b>Text only: </b>Shows only text on toolbar buttons.</p>" | ||
741 | "<p><b>Text Beside Icons: </b> Shows icons and text on toolbar buttons. " | 708 | "<p><b>Text beside icons: </b> Shows icons and text on toolbar buttons. " | ||
742 | "Text is aligned beside the icon.</p>" | 709 | "Text is aligned beside the icon.</p>" | ||
743 | "<b>Text Below Icons: </b> Shows icons and text on toolbar buttons. " | 710 | "<b>Text below icons: </b> Shows icons and text on toolbar buttons. " | ||
744 | "Text is aligned below the icon.") ); | 711 | "Text is aligned below the icon.") ); | ||
745 | fineTuningUi.cbIconsOnButtons->setWhatsThis( i18n( "If you enable this option, KDE Applications will " | | |||
746 | "show small icons alongside some important buttons.") ); | | |||
747 | fineTuningUi.cbIconsInMenus->setWhatsThis( i18n( "If you enable this option, KDE Applications will " | | |||
748 | "show small icons alongside most menu items.") ); | | |||
749 | } | 712 | } | ||
750 | 713 | | |||
751 | #include "kcmstyle.moc" | 714 | #include "kcmstyle.moc" | ||
752 | 715 | | |||
753 | // vim: set noet ts=4: | 716 | // vim: set noet ts=4: |
"the application style" isn't an example of "user interface elements" so the sentence does not make sense. This would be better:
"This module allows you to modify the visual appearance of applications' user interface elements"