void QtStyleManager::ReadPreferences() { IPreferencesService* prefService = WorkbenchPlugin::GetDefault()->GetPreferencesService(); IPreferences::Pointer stylePref = prefService->GetSystemPreferences()->Node(QtPreferences::QT_STYLES_NODE); QString paths = stylePref->Get(QtPreferences::QT_STYLE_SEARCHPATHS, ""); QStringList pathList = paths.split(";", QString::SkipEmptyParts); QStringListIterator it(pathList); while (it.hasNext()) { AddStyles(it.next()); } QString styleName = stylePref->Get(QtPreferences::QT_STYLE_NAME, ""); // if a style is contributed via the Qt resource mechanism, it may not be // registered yet. if (Contains(styleName)) // do not update the style in the QApplication instance, // since it might not be created yet SetStyle(styleName, false); else SetDefaultStyle(false); }
void QtWorkbenchAdvisor::Initialize(IWorkbenchConfigurer::Pointer configurer) { WorkbenchAdvisor::Initialize(configurer); IPreferencesService* prefService = WorkbenchPlugin::GetDefault()->GetPreferencesService(); IPreferences::Pointer prefs = prefService->GetSystemPreferences()->Node(QtPreferences::QT_STYLES_NODE); QString styleName = prefs->Get(QtPreferences::QT_STYLE_NAME, ""); QString fontName = prefs->Get(QtPreferences::QT_FONT_NAME, ""); QString fontSize = prefs->Get(QtPreferences::QT_FONT_SIZE, ""); ctkServiceReference serviceRef = WorkbenchPlugin::GetDefault()->GetPluginContext()->getServiceReference<IQtStyleManager>(); if (serviceRef) { IQtStyleManager* styleManager = WorkbenchPlugin::GetDefault()->GetPluginContext()->getService<IQtStyleManager>(serviceRef); styleManager->SetStyle(styleName); styleManager->SetFont(fontName); styleManager->SetFontSize(fontSize.toInt()); styleManager->UpdateWorkbenchFont(); } QObject* eventFilter = new QtGlobalEventFilter(qApp); qApp->installEventFilter(eventFilter); }