QString toGetSessionType(void) { QStyle *style = qApp->style(); QString sname = style->metaObject()->className(); // This is probably really slow, but who cares. QStringList keys = QStyleFactory::keys(); for (int i = 0; i < keys.size(); i++) { QString name = keys[i]; QStyle *t = QStyleFactory::create(name); if (!t) continue; if (sname == t->metaObject()->className()) { delete t; return name; } delete t; } // Weird should never get here. return sname; }
int ViewHelpMenu::getStyle() const { QStyle * style = QApplication::style(); const QMetaObject * mo = style->metaObject(); for(uint i = 0 ; i < __ids.size() ; i++){ if((QStyleFactory::create(__ids[i]->text()))->metaObject() == mo) return i; } return -1; }
void GetAppearance(QApplication *a, AppearanceAttributes *aa) { const char *mName = "GetAppearance: "; // get system default style QStyle *style = a->style(); QString style_class(style->metaObject()->className()); std::string styleName = "windows"; if(style_class == "QWindowsStyle") styleName = "windows"; else if(style_class == "QWindowsVistaStyle") styleName = "windowsvista"; else if(style_class == "QWindowsXPStyle") styleName = "windowsxp"; else if(style_class == "QMotifStyle") styleName = "motif"; else if(style_class == "QCleanlooksStyle") styleName = "cleanlooks"; else if(style_class == "QPlastiqueStyle") styleName = "plastique"; else if(style_class == "QCDEStyle") styleName = "cde"; else if(style_class == "QMacStyle") styleName = "macintosh"; debug1 << mName << "Default System Style is: " << styleName << endl; aa->SetDefaultStyle(styleName); // get system default font QFont font = a->font(); std::string font_name = font.key().toStdString(); debug1 << mName << "Default system font is:" << font_name << endl; aa->SetDefaultFontName(font_name); //set aa colors from defaults QColor bg = a->palette().window().color(); QColor fg = a->palette().windowText().color(); char tmp[20]; SNPRINTF(tmp, 20, "#%02x%02x%02x", bg.red(), bg.green(), bg.blue()); debug1 << mName << "Default background color is:" << tmp << endl; aa->SetDefaultBackground(tmp); SNPRINTF(tmp, 20, "#%02x%02x%02x", fg.red(), fg.green(), fg.blue()); debug1 << mName << "Default foreground color is:" << tmp << endl; aa->SetDefaultForeground(tmp); debug1 << mName << "Default orientation:" << 0 << endl; aa->SetDefaultOrientation(0); }