void KonfUpdate::copyGroup(const KConfigBase *cfg1, const QString &group1, KConfigBase *cfg2, const QString &group2) { KConfigGroup cg1(cfg1, group1); KConfigGroup cg2(cfg2, group2); copyGroup(cg1, cg2); }
void applyColorScheme(const QString &colorScheme, KConfig *other) { QString src = QStandardPaths::locate(QStandardPaths::GenericDataLocation, "color-schemes/" + colorScheme + ".colors"); KSharedConfigPtr config = KSharedConfig::openConfig(src); foreach (const QString &grp, config->groupList()) { KConfigGroup cg(config, grp); KConfigGroup cg2(other, grp); cg.copyTo(&cg2); } }
void ClassName::setPalette(const QPalette &pal) { QPalette pal2(pal); QColorGroup cg(pal2.active()); cg.setColor(QColorGroup::Light, KexiUtils::bleachedColor(d->frameColor, 150)); cg.setColor(QColorGroup::Mid, d->frameColor); cg.setColor(QColorGroup::Dark, d->frameColor.dark(150)); pal2.setActive(cg); QColorGroup cg2(pal2.inactive()); cg2.setColor(QColorGroup::Light, cg.light()); cg2.setColor(QColorGroup::Mid, cg.mid()); cg2.setColor(QColorGroup::Dark, cg.dark()); pal2.setInactive(cg2); SuperClassName::setPalette(pal2); }
void KCMLookandFeel::setColors(const QString &scheme, const QString &colorFile) { if (scheme.isEmpty() && colorFile.isEmpty()) { return; } KConfigGroup configGroup(&m_config, "General"); configGroup.writeEntry("ColorScheme", scheme); configGroup.sync(); KSharedConfigPtr conf = KSharedConfig::openConfig(colorFile); foreach (const QString &grp, conf->groupList()) { KConfigGroup cg(conf, grp); KConfigGroup cg2(&m_config, grp); cg.copyTo(&cg2); } }
void KInvestmentListItem::paintCell(QPainter * p, const QColorGroup & cg, int column, int width, int align) { bool bPaintRed = false; if((column == COLUMN_RAWGAIN_INDEX && bColumn5Negative) || (column == COLUMN_1WEEKGAIN_INDEX && bColumn6Negative) || (column == COLUMN_4WEEKGAIN_INDEX && bColumn7Negative) || (column == COLUMN_3MONGAIN_INDEX && bColumn8Negative) || (column == COLUMN_YTDGAIN_INDEX && bColumn9Negative)) { bPaintRed = true; } p->save(); QColorGroup cg2(cg); if(isAlternate()) cg2.setColor(QColorGroup::Base, KMyMoneyGlobalSettings::listColor()); else cg2.setColor(QColorGroup::Base, KMyMoneyGlobalSettings::listBGColor()); #ifndef KMM_DESIGNER QFont font = KMyMoneyGlobalSettings::listCellFont(); // strike out closed accounts if(m_account.isClosed()) font.setStrikeOut(true); p->setFont(font); #endif if(bPaintRed) { QColorGroup _cg( cg2); QColor c = _cg.text(); _cg.setColor(QColorGroup::Text, Qt::red); QListViewItem::paintCell(p, _cg, column, width, align); _cg.setColor(QColorGroup::Text, c); } else { QListViewItem::paintCell(p, cg2, column, width, align); } p->restore(); }
void UserAgentDlg::load() { ui.sitePolicyTreeWidget->clear(); if (!m_config) m_config = new KConfig (QStringLiteral("kio_httprc"), KConfig::NoGlobals); else m_config->reparseConfiguration(); if (!m_userAgentInfo) m_userAgentInfo = new UserAgentInfo(); const QStringList list = m_config->groupList(); QStringList::ConstIterator endIt = list.end(); QString agentStr; for (QStringList::ConstIterator it = list.begin(); it != endIt; ++it) { if ( (*it) == QLatin1String("<default>")) continue; KConfigGroup cg (m_config, *it); agentStr = cg.readEntry ("UserAgent"); if (!agentStr.isEmpty()) { QTreeWidgetItem* item = new QTreeWidgetItem (ui.sitePolicyTreeWidget); item->setText (0, (*it).toLower()); item->setText (1, m_userAgentInfo->aliasStr (agentStr)); item->setText (2, agentStr); } } // Update buttons and checkboxes... KConfigGroup cg2 (m_config, QString()); bool b = cg2.readEntry ("SendUserAgent", true); ui.sendUACheckBox->setChecked (b); m_ua_keys = cg2.readEntry ("UserAgentKeys", DEFAULT_USER_AGENT_KEYS).toLower(); ui.defaultIdLineEdit->setText (KProtocolManager::defaultUserAgent (m_ua_keys)); ui.osNameCheckBox->setChecked (m_ua_keys.contains ('o')); ui.osVersionCheckBox->setChecked (m_ua_keys.contains ('v')); ui.processorTypeCheckBox->setChecked (m_ua_keys.contains ('m')); ui.languageCheckBox->setChecked (m_ua_keys.contains ('l')); updateButtons(); configChanged (false); }
void ExtensionManager::initialize() { // kDebug(1210) << "ExtensionManager::loadContainerConfig()"; KSharedConfig::Ptr config = KGlobal::config(); PluginManager* pm = PluginManager::self(); // set up the "main" panel if (config->hasGroup("Main Panel")) { KConfigGroup cg(config,"Main Panel"); if (cg.hasKey("DesktopFile")) { m_mainPanel = pm->createExtensionContainer(cg.readPathEntry("DesktopFile", false), true, cg.readPathEntry("ConfigFile", false), "Main Panel"); } } if (!m_mainPanel) { // fall back to a regular ol' PanelExtension m_mainPanel = pm->createExtensionContainer( "childpanelextension.desktop", true, QString(KGlobal::mainComponent().aboutData()->appName()) + "rc", "Main Panel"); } if (!m_mainPanel) { KMessageBox::error(0, i18n("The KDE panel (kicker) could not load the main panel " "due to a problem with your installation. "), i18n("Fatal Error")); exit(1); } configureMenubar(true); m_mainPanel->readConfig(); m_mainPanel->show(); kapp->processEvents(); // read extension list KConfigGroup cg2(config, "General"); QStringList elist = cg2.readEntry("Extensions2", QStringList() ); // now restore the extensions foreach (QString extensionId, elist) { // create a matching applet container if (extensionId.indexOf("Extension") == -1) { continue; } // is there a config group for this extension? if (!config->hasGroup(extensionId)) { continue; } // set config group KConfigGroup cg3(config, extensionId); ExtensionContainer* e = pm->createExtensionContainer(cg3.readPathEntry("DesktopFile", false), true, // is startup cg3.readPathEntry("ConfigFile", false), extensionId); if (e) { addContainer(e); e->readConfig(); e->show(); kapp->processEvents(); } } pm->clearUntrustedLists(); connect(Kicker::self(), SIGNAL(configurationChanged()), SLOT(configurationChanged())); QDBusInterface dbus("org.kde.ksmserver", "/ksmserver"); dbus.call("resumeStartup", "kicker"); }
void KonfUpdate::gotScript(const QString &_script) { QString script, interpreter; int i = _script.indexOf(','); if (i == -1) { script = _script.trimmed(); } else { script = _script.left(i).trimmed(); interpreter = _script.mid(i + 1).trimmed(); } if (script.isEmpty()) { logFileError() << "Script fails to specify filename"; m_skip = true; return; } QString path = KStandardDirs::locate("data", "kconf_update/" + script); if (path.isEmpty()) { if (interpreter.isEmpty()) { path = KStandardDirs::locate("lib", "kconf_update_bin/" + script); } if (path.isEmpty()) { logFileError() << "Script '" << script << "' not found" << endl; m_skip = true; return; } } if (!m_arguments.isNull()) { log() << m_currentFilename << ": Running script '" << script << "' with arguments '" << m_arguments << "'" << endl; } else { log() << m_currentFilename << ": Running script '" << script << "'" << endl; } QString cmd; if (interpreter.isEmpty()) { cmd = path; } else { cmd = interpreter + ' ' + path; } if (!m_arguments.isNull()) { cmd += ' '; cmd += m_arguments; } KTemporaryFile scriptIn; scriptIn.open(); KTemporaryFile scriptOut; scriptOut.open(); KTemporaryFile scriptErr; scriptErr.open(); int result; if (m_oldConfig1) { if (m_debug) { scriptIn.setAutoRemove(false); log() << "Script input stored in " << scriptIn.fileName() << endl; } KConfig cfg(scriptIn.fileName(), KConfig::SimpleConfig); if (m_oldGroup.isEmpty()) { // Write all entries to tmpFile; const QStringList grpList = m_oldConfig1->groupList(); for (QStringList::ConstIterator it = grpList.begin(); it != grpList.end(); ++it) { copyGroup(m_oldConfig1, *it, &cfg, *it); } } else { KConfigGroup cg1 = KConfigUtils::openGroup(m_oldConfig1, m_oldGroup); KConfigGroup cg2(&cfg, QString()); copyGroup(cg1, cg2); } cfg.sync(); #ifndef _WIN32_WCE result = system(QFile::encodeName(QString("%1 < %2 > %3 2> %4").arg(cmd, scriptIn.fileName(), scriptOut.fileName(), scriptErr.fileName()))); #else QString path_ = QDir::convertSeparators ( QFileInfo ( cmd ).absoluteFilePath() ); QString file_ = QFileInfo ( cmd ).fileName(); SHELLEXECUTEINFO execInfo; memset ( &execInfo,0,sizeof ( execInfo ) ); execInfo.cbSize = sizeof ( execInfo ); execInfo.fMask = SEE_MASK_FLAG_NO_UI; execInfo.lpVerb = L"open"; execInfo.lpFile = (LPCWSTR) path_.utf16(); execInfo.lpDirectory = (LPCWSTR) file_.utf16(); execInfo.lpParameters = (LPCWSTR) QString(" < %1 > %2 2> %3").arg( scriptIn.fileName(), scriptOut.fileName(), scriptErr.fileName()).utf16(); result = ShellExecuteEx ( &execInfo ); if (result != 0) { result = 0; } else { result = -1; } #endif } else { // No config file #ifndef _WIN32_WCE result = system(QFile::encodeName(QString("%1 2> %2").arg(cmd, scriptErr.fileName()))); #else QString path_ = QDir::convertSeparators ( QFileInfo ( cmd ).absoluteFilePath() ); QString file_ = QFileInfo ( cmd ).fileName(); SHELLEXECUTEINFO execInfo; memset ( &execInfo,0,sizeof ( execInfo ) ); execInfo.cbSize = sizeof ( execInfo ); execInfo.fMask = SEE_MASK_FLAG_NO_UI; execInfo.lpVerb = L"open"; execInfo.lpFile = (LPCWSTR) path_.utf16(); execInfo.lpDirectory = (LPCWSTR) file_.utf16(); execInfo.lpParameters = (LPCWSTR) QString(" 2> %1").arg( scriptErr.fileName()).utf16(); result = ShellExecuteEx ( &execInfo ); if (result != 0) { result = 0; } else { result = -1; } #endif } // Copy script stderr to log file { QFile output(scriptErr.fileName()); if (output.open(QIODevice::ReadOnly)) { QTextStream ts(&output); ts.setCodec(QTextCodec::codecForName("UTF-8")); while (!ts.atEnd()) { QString line = ts.readLine(); log() << "[Script] " << line << endl; } } } if (result) { log() << m_currentFilename << ": !! An error occurred while running '" << cmd << "'" << endl; return; } if (!m_oldConfig1) { return; // Nothing to merge } if (m_debug) { scriptOut.setAutoRemove(false); log() << "Script output stored in " << scriptOut.fileName() << endl; } // Deleting old entries { QStringList group = m_oldGroup; QFile output(scriptOut.fileName()); if (output.open(QIODevice::ReadOnly)) { QTextStream ts(&output); ts.setCodec(QTextCodec::codecForName("UTF-8")); while (!ts.atEnd()) { QString line = ts.readLine(); if (line.startsWith('[')) { group = parseGroupString(line); } else if (line.startsWith(QLatin1String("# DELETE "))) { QString key = line.mid(9); if (key[0] == '[') { int j = key.lastIndexOf(']') + 1; if (j > 0) { group = parseGroupString(key.left(j)); key = key.mid(j); } } KConfigGroup cg = KConfigUtils::openGroup(m_oldConfig2, group); cg.deleteEntry(key); log() << m_currentFilename << ": Script removes " << m_oldFile << ":" << group << ":" << key << endl; /*if (m_oldConfig2->deleteGroup(group, KConfig::Normal)) { // Delete group if empty. log() << m_currentFilename << ": Removing empty group " << m_oldFile << ":" << group << endl; } (this should be automatic)*/ } else if (line.startsWith(QLatin1String("# DELETEGROUP"))) { QString str = line.mid(13).trimmed(); if (!str.isEmpty()) { group = parseGroupString(str); } KConfigGroup cg = KConfigUtils::openGroup(m_oldConfig2, group); cg.deleteGroup(); log() << m_currentFilename << ": Script removes group " << m_oldFile << ":" << group << endl; } } } } // Merging in new entries. KConfig scriptOutConfig(scriptOut.fileName(), KConfig::NoGlobals); if (m_newGroup.isEmpty()) { // Copy "default" keys as members of "default" keys copyGroup(&scriptOutConfig, QString(), m_newConfig, QString()); } else { // Copy default keys as members of m_newGroup KConfigGroup srcCg = KConfigUtils::openGroup(&scriptOutConfig, QStringList()); KConfigGroup dstCg = KConfigUtils::openGroup(m_newConfig, m_newGroup); copyGroup(srcCg, dstCg); } Q_FOREACH(const QString &group, scriptOutConfig.groupList()) { copyGroup(&scriptOutConfig, group, m_newConfig, group); } }
/*!\reimp */ void QPlatinumStyle::drawControl( ControlElement element, QPainter *p, const QWidget *widget, const QRect &r, const QColorGroup &cg, SFlags how, const QStyleOption& opt ) const { switch( element ) { case CE_PushButton: { #ifndef QT_NO_PUSHBUTTON QColorGroup myCg( cg ); const QPushButton *btn; int x1, y1, x2, y2; bool useBevelButton; SFlags flags; flags = Style_Default; btn = (const QPushButton*)widget; p->setBrushOrigin( -widget->backgroundOffset().x(), -widget->backgroundOffset().y() ); // take care of the flags based on what we know... if ( btn->isDown() ) flags |= Style_Down; if ( btn->isOn() ) flags |= Style_On; if ( btn->isEnabled() ) flags |= Style_Enabled; if ( btn->isDefault() ) flags |= Style_Default; if (! btn->isFlat() && !(flags & Style_Down)) flags |= Style_Raised; r.coords( &x1, &y1, &x2, &y2 ); p->setPen( cg.foreground() ); p->setBrush( QBrush(cg.button(), NoBrush) ); QBrush fill; if ( btn->isDown() ) { fill = cg.brush( QColorGroup::Dark ); // this could be done differently, but this // makes a down Bezel drawn correctly... myCg.setBrush( QColorGroup::Mid, fill ); } else if ( btn->isOn() ) { fill = QBrush( cg.mid(), Dense4Pattern ); myCg.setBrush( QColorGroup::Mid, fill ); } // to quote the old QPlatinumStlye drawPushButton... // small or square image buttons as well as toggle buttons are // bevel buttons (what a heuristic....) if ( btn->isToggleButton() || ( btn->pixmap() && (btn->width() * btn->height() < 1600 || QABS( btn->width() - btn->height()) < 10 )) ) useBevelButton = TRUE; else useBevelButton = FALSE; int diw = pixelMetric( PM_ButtonDefaultIndicator, widget ); if ( btn->isDefault() ) { x1 += 1; y1 += 1; x2 -= 1; y2 -= 1; QColorGroup cg2( myCg ); SFlags myFlags = flags; // don't draw the default button sunken, unless it's necessary. if ( myFlags & Style_Down ) myFlags ^= Style_Down; if ( myFlags & Style_Sunken ) myFlags ^= Style_Sunken; cg2.setColor( QColorGroup::Button, cg.mid() ); if ( useBevelButton ) { drawPrimitive( PE_ButtonBevel, p, QRect( x1, y1, x2 - x1 + 1, y2 - y1 + 1 ), myCg, myFlags, opt ); } else { drawPrimitive( PE_ButtonCommand, p, QRect( x1, y1, x2 - x1 + 1, y2 - y1 + 1 ), cg2, myFlags, opt ); } } if ( btn->isDefault() || btn->autoDefault() ) { x1 += diw; y1 += diw; x2 -= diw; y2 -= diw; } if ( !btn->isFlat() || btn->isOn() || btn->isDown() ) { if ( useBevelButton ) { // fix for toggle buttons... if ( flags & (Style_Down | Style_On) ) flags |= Style_Sunken; drawPrimitive( PE_ButtonBevel, p, QRect( x1, y1, x2 - x1 + 1, y2 - y1 + 1 ), myCg, flags, opt ); } else { drawPrimitive( PE_ButtonCommand, p, QRect( x1, y1, x2 - x1 + 1, y2 - y1 + 1 ), myCg, flags, opt ); } } if ( p->brush().style() != NoBrush ) p->setBrush( NoBrush ); break; #endif } case CE_PushButtonLabel: { #ifndef QT_NO_PUSHBUTTON const QPushButton *btn; bool on; int x, y, w, h; SFlags flags; flags = Style_Default; btn = (const QPushButton*)widget; on = btn->isDown() || btn->isOn(); r.rect( &x, &y, &w, &h ); if ( btn->isMenuButton() ) { int dx = pixelMetric( PM_MenuButtonIndicator, widget ); QColorGroup g = cg; int xx = x + w - dx - 4; int yy = y - 3; int hh = h + 6; if ( !on ) { p->setPen( g.mid() ); p->drawLine( xx, yy + 2, xx, yy + hh - 3 ); p->setPen( g.button() ); p->drawLine( xx + 1, yy + 1, xx + 1, yy + hh - 2 ); p->setPen( g.light() ); p->drawLine( xx + 2, yy + 2, xx + 2, yy + hh - 2 ); } if ( btn->isEnabled() ) flags |= Style_Enabled; drawPrimitive( PE_ArrowDown, p, QRect(x + w - dx - 1, y + 2, dx, h - 4), g, flags, opt ); w -= dx; } #ifndef QT_NO_ICONSET if ( btn->iconSet() && !btn->iconSet()->isNull() ) { QIconSet::Mode mode = btn->isEnabled() ? QIconSet::Normal : QIconSet::Disabled; if ( mode == QIconSet::Normal && btn->hasFocus() ) mode = QIconSet::Active; QIconSet::State state = QIconSet::Off; if ( btn->isToggleButton() && btn->isOn() ) state = QIconSet::On; QPixmap pixmap = btn->iconSet()->pixmap( QIconSet::Small, mode, state ); int pixw = pixmap.width(); int pixh = pixmap.height(); p->drawPixmap( x + 2, y + h / 2 - pixh / 2, pixmap ); x += pixw + 4; w -= pixw + 4; } #endif drawItem( p, QRect( x, y, w, h ), AlignCenter | ShowPrefix, btn->colorGroup(), btn->isEnabled(), btn->pixmap(), btn->text(), -1, on ? &btn->colorGroup().brightText() : &btn->colorGroup().buttonText() ); if ( btn->hasFocus() ) drawPrimitive( PE_FocusRect, p, subRect(SR_PushButtonFocusRect, widget), cg, flags ); break; #endif } default: QWindowsStyle::drawControl( element, p, widget, r, cg, how, opt ); break; } }
void runRdb( uint flags ) { // Obtain the application palette that is about to be set. bool exportColors = flags & KRdbExportColors; bool exportQtColors = flags & KRdbExportQtColors; bool exportQtSettings = flags & KRdbExportQtSettings; bool exportXftSettings = flags & KRdbExportXftSettings; bool exportGtkTheme = flags & KRdbExportGtkTheme; KSharedConfigPtr kglobalcfg = KSharedConfig::openConfig( QStringLiteral("kdeglobals") ); KConfigGroup kglobals(kglobalcfg, "KDE"); QPalette newPal = KColorScheme::createApplicationPalette(kglobalcfg); QTemporaryFile tmpFile; if (!tmpFile.open()) { qDebug() << "Couldn't open temp file"; exit(0); } KConfigGroup generalCfgGroup(kglobalcfg, "General"); QString gtkTheme; if (kglobals.hasKey("widgetStyle")) gtkTheme = kglobals.readEntry("widgetStyle"); else gtkTheme = QStringLiteral("oxygen"); createGtkrc( exportColors, newPal, exportGtkTheme, gtkTheme, 1 ); createGtkrc( exportColors, newPal, exportGtkTheme, gtkTheme, 2 ); // Export colors to non-(KDE/Qt) apps (e.g. Motif, GTK+ apps) if (exportColors) { KConfigGroup g(KSharedConfig::openConfig(), "WM"); QString preproc; QColor backCol = newPal.color( QPalette::Active, QPalette::Background ); addColorDef(preproc, "FOREGROUND" , newPal.color( QPalette::Active, QPalette::Foreground ) ); addColorDef(preproc, "BACKGROUND" , backCol); addColorDef(preproc, "HIGHLIGHT" , backCol.light(100+(2*KColorScheme::contrast()+4)*16/1)); addColorDef(preproc, "LOWLIGHT" , backCol.dark(100+(2*KColorScheme::contrast()+4)*10)); addColorDef(preproc, "SELECT_BACKGROUND" , newPal.color( QPalette::Active, QPalette::Highlight)); addColorDef(preproc, "SELECT_FOREGROUND" , newPal.color( QPalette::Active, QPalette::HighlightedText)); addColorDef(preproc, "WINDOW_BACKGROUND" , newPal.color( QPalette::Active, QPalette::Base ) ); addColorDef(preproc, "WINDOW_FOREGROUND" , newPal.color( QPalette::Active, QPalette::Text ) ); addColorDef(preproc, "INACTIVE_BACKGROUND", g.readEntry("inactiveBackground", QColor(224, 223, 222))); addColorDef(preproc, "INACTIVE_FOREGROUND", g.readEntry("inactiveBackground", QColor(224, 223, 222))); addColorDef(preproc, "ACTIVE_BACKGROUND" , g.readEntry("activeBackground", QColor(48, 174, 232))); addColorDef(preproc, "ACTIVE_FOREGROUND" , g.readEntry("activeBackground", QColor(48, 174, 232))); //--------------------------------------------------------------- tmpFile.write( preproc.toLatin1(), preproc.length() ); QStringList list; const QStringList adPaths = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QStringLiteral("kdisplay/app-defaults/"), QStandardPaths::LocateDirectory); for (QStringList::ConstIterator it = adPaths.constBegin(); it != adPaths.constEnd(); ++it) { QDir dSys( *it ); if ( dSys.exists() ) { dSys.setFilter( QDir::Files ); dSys.setSorting( QDir::Name ); dSys.setNameFilters(QStringList(QStringLiteral("*.ad"))); list += dSys.entryList(); } } for (QStringList::ConstIterator it = list.constBegin(); it != list.constEnd(); ++it) copyFile(tmpFile, QStandardPaths::locate(QStandardPaths::GenericDataLocation, "kdisplay/app-defaults/"+(*it)), true); } // Merge ~/.Xresources or fallback to ~/.Xdefaults QString homeDir = QDir::homePath(); QString xResources = homeDir + "/.Xresources"; // very primitive support for ~/.Xresources by appending it if ( QFile::exists( xResources ) ) copyFile(tmpFile, xResources, true); else copyFile(tmpFile, homeDir + "/.Xdefaults", true); // Export the Xcursor theme & size settings KConfigGroup mousecfg(KSharedConfig::openConfig( QStringLiteral("kcminputrc") ), "Mouse" ); QString theme = mousecfg.readEntry("cursorTheme", QString()); QString size = mousecfg.readEntry("cursorSize", QString()); QString contents; if (!theme.isNull()) contents = "Xcursor.theme: " + theme + '\n'; if (!size.isNull()) contents += "Xcursor.size: " + size + '\n'; if (exportXftSettings) { if (generalCfgGroup.hasKey("XftAntialias")) { contents += QLatin1String("Xft.antialias: "); if(generalCfgGroup.readEntry("XftAntialias", true)) contents += QLatin1String("1\n"); else contents += QLatin1String("0\n"); } if (generalCfgGroup.hasKey("XftHintStyle")) { QString hintStyle = generalCfgGroup.readEntry("XftHintStyle", "hintmedium"); contents += QLatin1String("Xft.hinting: "); if(hintStyle.isEmpty()) contents += QLatin1String("-1\n"); else { if(hintStyle!=QLatin1String("hintnone")) contents += QLatin1String("1\n"); else contents += QLatin1String("0\n"); contents += "Xft.hintstyle: " + hintStyle + '\n'; } } if (generalCfgGroup.hasKey("XftSubPixel")) { QString subPixel = generalCfgGroup.readEntry("XftSubPixel"); if(!subPixel.isEmpty()) contents += "Xft.rgba: " + subPixel + '\n'; } KConfig _cfgfonts( QStringLiteral("kcmfonts") ); KConfigGroup cfgfonts(&_cfgfonts, "General"); if( cfgfonts.readEntry( "forceFontDPI", 0 ) != 0 ) contents += "Xft.dpi: " + cfgfonts.readEntry( "forceFontDPI" ) + '\n'; else { KProcess proc; proc << QStringLiteral("xrdb") << QStringLiteral("-quiet") << QStringLiteral("-remove") << QStringLiteral("-nocpp"); proc.start(); if (proc.waitForStarted()) { proc.write( QByteArray( "Xft.dpi\n" ) ); proc.closeWriteChannel(); proc.waitForFinished(); } } } if (contents.length() > 0) tmpFile.write( contents.toLatin1(), contents.length() ); tmpFile.flush(); KProcess proc; #ifndef NDEBUG proc << QStringLiteral("xrdb") << QStringLiteral("-merge") << tmpFile.fileName(); #else proc << "xrdb" << "-quiet" << "-merge" << tmpFile.fileName(); #endif proc.execute(); applyGtkStyles(exportColors, 1); applyGtkStyles(exportColors, 2); /* Qt exports */ if ( exportQtColors || exportQtSettings ) { QSettings* settings = new QSettings(QStringLiteral("Trolltech")); if ( exportQtColors ) applyQtColors( kglobalcfg, *settings, newPal ); // For kcmcolors if ( exportQtSettings ) applyQtSettings( kglobalcfg, *settings ); // For kcmstyle delete settings; QApplication::flush(); #if HAVE_X11 if (qApp->platformName() == QStringLiteral("xcb")) { // We let KIPC take care of ourselves, as we are in a KDE app with // QApp::setDesktopSettingsAware(false); // Instead of calling QApp::x11_apply_settings() directly, we instead // modify the timestamp which propagates the settings changes onto // Qt-only apps without adversely affecting ourselves. // Cheat and use the current timestamp, since we just saved to qtrc. QDateTime settingsstamp = QDateTime::currentDateTime(); static Atom qt_settings_timestamp = 0; if (!qt_settings_timestamp) { QString atomname(QStringLiteral("_QT_SETTINGS_TIMESTAMP_")); atomname += XDisplayName( 0 ); // Use the $DISPLAY envvar. qt_settings_timestamp = XInternAtom( QX11Info::display(), atomname.toLatin1(), False); } QBuffer stamp; QDataStream s(&stamp.buffer(), QIODevice::WriteOnly); s << settingsstamp; XChangeProperty( QX11Info::display(), QX11Info::appRootWindow(), qt_settings_timestamp, qt_settings_timestamp, 8, PropModeReplace, (unsigned char*) stamp.buffer().data(), stamp.buffer().size() ); QApplication::flush(); } #endif } //Legacy support: //Try to sync kde4 settings with ours Kdelibs4Migration migration; //kf5 congig groups for general and icons KConfigGroup generalGroup(kglobalcfg, "General"); KConfigGroup iconsGroup(kglobalcfg, "Icons"); const QString colorSchemeName = generalGroup.readEntry("ColorScheme", QString()); //if no valid color scheme saved, something weird is going on, abort if (colorSchemeName.isEmpty()) { return; } //fix filename, copied from ColorsCM::saveScheme() QString colorSchemeFilename = colorSchemeName; colorSchemeFilename.remove('\''); // So Foo's does not become FooS QRegExp fixer(QStringLiteral("[\\W,.-]+(.?)")); int offset; while ((offset = fixer.indexIn(colorSchemeFilename)) >= 0) colorSchemeFilename.replace(offset, fixer.matchedLength(), fixer.cap(1).toUpper()); colorSchemeFilename.replace(0, 1, colorSchemeFilename.at(0).toUpper()); //clone the color scheme QString src = QStandardPaths::locate(QStandardPaths::GenericDataLocation, "color-schemes/" + colorSchemeFilename + ".colors"); QString dest = migration.saveLocation("data", QStringLiteral("color-schemes")) + colorSchemeName + ".colors"; QFile::remove(dest); QFile::copy(src, dest); //Apply the color scheme QString configFilePath = migration.saveLocation("config") + "kdeglobals"; if (configFilePath.isEmpty()) { return; } KConfig kde4config(configFilePath, KConfig::SimpleConfig); KConfigGroup kde4generalGroup(&kde4config, "General"); kde4generalGroup.writeEntry("ColorScheme", colorSchemeName); //fonts QString font = generalGroup.readEntry("font", QString()); if (!font.isEmpty()) { kde4generalGroup.writeEntry("font", font); } font = generalGroup.readEntry("desktopFont", QString()); if (!font.isEmpty()) { kde4generalGroup.writeEntry("desktopFont", font); } font = generalGroup.readEntry("menuFont", QString()); if (!font.isEmpty()) { kde4generalGroup.writeEntry("menuFont", font); } font = generalGroup.readEntry("smallestReadableFont", QString()); if (!font.isEmpty()) { kde4generalGroup.writeEntry("smallestReadableFont", font); } font = generalGroup.readEntry("taskbarFont", QString()); if (!font.isEmpty()) { kde4generalGroup.writeEntry("taskbarFont", font); } font = generalGroup.readEntry("toolBarFont", QString()); if (!font.isEmpty()) { kde4generalGroup.writeEntry("toolBarFont", font); } //TODO: does exist any way to check if a qt4 widget style is present from a qt5 app? //kde4generalGroup.writeEntry("widgetStyle", "qtcurve"); kde4generalGroup.sync(); KConfigGroup kde4IconGroup(&kde4config, "Icons"); QString iconTheme = iconsGroup.readEntry("Theme", QString()); if (!iconTheme.isEmpty()) { kde4IconGroup.writeEntry("Theme", iconTheme); } kde4IconGroup.sync(); //copy all the groups in the color scheme in kdeglobals KSharedConfigPtr kde4ColorConfig = KSharedConfig::openConfig(src, KConfig::SimpleConfig); foreach (const QString &grp, kde4ColorConfig->groupList()) { KConfigGroup cg(kde4ColorConfig, grp); KConfigGroup cg2(&kde4config, grp); cg.copyTo(&cg2); } //widgets settings KConfigGroup kglobals4(&kde4config, "KDE"); kglobals4.writeEntry("ShowIconsInMenuItems", kglobals.readEntry("ShowIconsInMenuItems", true)); kglobals4.writeEntry("ShowIconsOnPushButtons", kglobals.readEntry("ShowIconsOnPushButtons", true)); kglobals4.writeEntry("contrast", kglobals.readEntry("contrast", 4)); //FIXME: this should somehow check if the kde4 version of the style is installed kde4generalGroup.writeEntry("widgetStyle", kglobals.readEntry("widgetStyle", "breeze")); //toolbar style KConfigGroup toolbars4(&kde4config, "Toolbar style"); KConfigGroup toolbars5(kglobalcfg, "Toolbar style"); toolbars4.writeEntry("ToolButtonStyle", toolbars5.readEntry("ToolButtonStyle", "TextBesideIcon")); toolbars4.writeEntry("ToolButtonStyleOtherToolbars", toolbars5.readEntry("ToolButtonStyleOtherToolbars", "TextBesideIcon")); }
static inline double cf( double x ) { return cg2(x)*cf_p(x); }
static inline double dd_cf( double x ) { return dd_cg2(x)*cf_p(x) + 2*d_cg2(x)*d_cf_p(x) + cg2(x)*dd_cf_p(x); }