void DeclarativeSettingsPageImpl::showColorDialog() { QToolButton * b = qobject_cast<QToolButton*>(sender()); if (!b) return; QColor c = QColorDialog::getColor( buttonColor(b), pClass_, tr("Choose color") ); if (c.isValid()) { setButtonColor(b, c); } }
void DeclarativeSettingsPageImpl::accept() { if (!settings_) return; foreach (const QString & key, entries_.keys()) { const DeclarativeSettingsPage::Entry entry = entries_[key]; if (entry.type==DeclarativeSettingsPage::Integer) { QSpinBox * control = 0; if (widgets_.contains(key) && QString(widgets_[key]->metaObject()->className())=="QSpinBox") control = qobject_cast<QSpinBox*>(widgets_[key]); if (control) settings_->setValue(key, control->value()); } else if (entry.type==DeclarativeSettingsPage::Color) { QToolButton * control = 0; if (widgets_.contains(key) && QString(widgets_[key]->metaObject()->className())=="QToolButton") control = qobject_cast<QToolButton*>(widgets_[key]); if (control) settings_->setValue(key, buttonColor(control).name()); } else if (entry.type==DeclarativeSettingsPage::Double) { QDoubleSpinBox * control = 0; if (widgets_.contains(key) && QString(widgets_[key]->metaObject()->className())=="QDoubleSpinBox") control = qobject_cast<QDoubleSpinBox*>(widgets_[key]); if (control) settings_->setValue(key, control->value()); } else if (entry.type==DeclarativeSettingsPage::String) { QLineEdit * control = 0; if (widgets_.contains(key) && QString(widgets_[key]->metaObject()->className())=="QLineEdit") control = qobject_cast<QLineEdit*>(widgets_[key]); if (control) settings_->setValue(key, control->text()); } else if (entry.type==DeclarativeSettingsPage::Bool) { QCheckBox * control = 0; if (widgets_.contains(key) && QString(widgets_[key]->metaObject()->className())=="QCheckBox") control = qobject_cast<QCheckBox*>(widgets_[key]); if (control) settings_->setValue(key, control->isChecked()); } else { qFatal("Not implemented"); } } emit pClass_->settingsChanged(entries_.keys()); }
void MSEntryFieldCombo::buttonColor(ButtonFlag flag_, unsigned long color_) { if (color_ != buttonColor(flag_)) { switch(flag_) { case ComboButton: if(_comboArrow != 0) _comboArrow->color(color_); break; case UpDownArrows: if(_upArrow != 0) _upArrow->color(color_); if(_downArrow != 0) _downArrow->color(color_); break; case TextButton: default: break; } redraw(); } }
// ------------------------------------------------------------------ void GUIComboBox::onDraw() { glColor4f(1.0f, 1.0f, 1.0f, 1.0f); glBegin(GL_QUADS); glVertex2i(0, 0); glVertex2i(mSize.getX(), 0); glVertex2i(mSize.getX(), mSize.getY()); glVertex2i(0, mSize.getY()); glEnd(); glColor4f(0.3f, 0.3f, 0.3f, 1.0f); glBegin(GL_LINE_LOOP); glVertex2i(0, 0); glVertex2i(mSize.getX(), 0); glVertex2i(mSize.getX(), mSize.getY()); glVertex2i(0, mSize.getY()); glVertex2i(0, 0); glEnd(); Font* ft = Resources::inst().get<Font> (mFontName); if (mItems.size() > mSelectedItem) { glColor4f(0.0f, 0.0f, 0.0f, 1.0f); glPrint(ft, 2, (mSize.getY() + ft->getHeight()) / 2, mSize.getX() - 30, mItems[mSelectedItem].second); } Color buttonColor(0.6f, 0.6f, 0.6f, 1.0f); float ColorMult = (mExpandOver ? (mExpandDown ? 0.7 : 1.3) : 1.0); (buttonColor * ColorMult).glUse(); glBegin(GL_TRIANGLES); glVertex2i(mSize.getX() - 30, mSize.getY() / 2 - 4); glVertex2i(mSize.getX() - 6, mSize.getY() / 2 - 4); glVertex2i(mSize.getX() - 18, mSize.getY() / 2 + 8); glEnd(); if (mExpand) { unsigned itemHeight = (ft->getHeight() + 3); unsigned mHeight = mItems.size() * itemHeight + 5; glColor4f(1.0f, 1.0f, 1.0f, 0.7f); glBegin(GL_QUADS); glVertex2i(0, mSize.getY()); glVertex2i(mSize.getX(), mSize.getY()); glVertex2i(mSize.getX(), mSize.getY() + mHeight); glVertex2i(0, mSize.getY() + mHeight); glEnd(); if (mOverItem) { glColor4f(0.7f, 0.7f, 0.7f, 1.0f); glBegin(GL_QUADS); glVertex2i(0, mSize.getY() + itemHeight * mHoverItem + 3); glVertex2i(mSize.getX(), mSize.getY() + itemHeight * mHoverItem + 3); glVertex2i(mSize.getX(), mSize.getY() + itemHeight * (mHoverItem + 1) + 3); glVertex2i(0, mSize.getY() + itemHeight * (mHoverItem + 1) + 3); glEnd(); } glColor4f(0.3f, 0.3f, 0.3f, 1.0f); glBegin(GL_LINE_LOOP); glVertex2i(0, mSize.getY() + mHeight); glVertex2i(0, mSize.getY()); glVertex2i(mSize.getX(), mSize.getY()); glVertex2i(mSize.getX(), mSize.getY() + mHeight); glVertex2i(0, mSize.getY() + mHeight); glEnd(); mFontColor.glUse(); for (unsigned i = 0; i < mItems.size(); ++i) { glPrint(ft, 2, mSize.getY() + itemHeight * (i + 1), mSize.getX(), mItems[i].second); } } }
void SheetDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { const QAbstractItemModel *model = index.model(); Q_ASSERT(model); if (!model->parent(index).isValid()) { // this is a top-level item. QStyleOptionButton buttonOption; buttonOption.state = option.state; #ifdef Q_OS_MAC buttonOption.state |= QStyle::State_Raised; #endif buttonOption.state &= ~QStyle::State_HasFocus; buttonOption.rect = option.rect; buttonOption.palette = option.palette; buttonOption.features = QStyleOptionButton::None; painter->save(); QColor buttonColor(230, 230, 230); QBrush buttonBrush = option.palette.button(); if (!buttonBrush.gradient() && buttonBrush.texture().isNull()) buttonColor = buttonBrush.color(); QColor outlineColor = buttonColor.darker(150); QColor highlightColor = buttonColor.lighter(130); // Only draw topline if the previous item is expanded QModelIndex previousIndex = model->index(index.row() - 1, index.column()); bool drawTopline = (index.row() > 0 && m_view->isExpanded(previousIndex)); int highlightOffset = drawTopline ? 1 : 0; QLinearGradient gradient(option.rect.topLeft(), option.rect.bottomLeft()); gradient.setColorAt(0, buttonColor.lighter(102)); gradient.setColorAt(1, buttonColor.darker(106)); painter->setPen(Qt::NoPen); painter->setBrush(gradient); painter->drawRect(option.rect); painter->setPen(highlightColor); painter->drawLine(option.rect.topLeft() + QPoint(0, highlightOffset), option.rect.topRight() + QPoint(0, highlightOffset)); painter->setPen(outlineColor); if (drawTopline) painter->drawLine(option.rect.topLeft(), option.rect.topRight()); painter->drawLine(option.rect.bottomLeft(), option.rect.bottomRight()); painter->restore(); QStyleOption branchOption; static const int i = 9; // ### hardcoded in qcommonstyle.cpp QRect r = option.rect; branchOption.rect = QRect(r.left() + i/2, r.top() + (r.height() - i)/2, i, i); branchOption.palette = option.palette; branchOption.state = QStyle::State_Children; if (m_view->isExpanded(index)) branchOption.state |= QStyle::State_Open; m_view->style()->drawPrimitive(QStyle::PE_IndicatorBranch, &branchOption, painter, m_view); // draw text QRect textrect = QRect(r.left() + i*2, r.top(), r.width() - ((5*i)/2), r.height()); QString text = elidedText(option.fontMetrics, textrect.width(), Qt::ElideMiddle, model->data(index, Qt::DisplayRole).toString()); m_view->style()->drawItemText(painter, textrect, Qt::AlignCenter, option.palette, m_view->isEnabled(), text); } else { QItemDelegate::paint(painter, option, index); } }
void WindowButton::onRender( RenderContext & context, const RectInt & window ) { int baseAlpha = m_Alpha * 255; int alpha = Clamp( baseAlpha + (enabled() ? (m_ButtonDown ? DOWN_ALPHA : m_CursorOver ? OVER_ALPHA : 0) : DISABLED_ALPHA) , 0, 255 ); // update the image frame if ( m_Button.valid() ) { static RectFloat buttonUV( 0, 0, 1, 1 ); // get the button color //Color buttonColor( m_ButtonDown ? windowStyle()->highColor() : windowStyle()->color() ); Color buttonColor( m_ButtonDown ? m_Color * 2.0f : m_Color ); buttonColor.m_A = alpha; if ( m_bGreyed ) buttonColor.greyscale(BUTTON_GREYED_SCALE); // if the button has multiple frames, set the time to display the correct frame if ( m_Button->frames() > 1 ) { ASSERT( m_Button->fps() > 0 ); int frame = 0; if ( m_Button->frames() == 2 ) frame = m_ButtonDown ? 1 : 0; else frame = m_ButtonDown ? 1 : m_CursorOver ? 2 : 0; m_Time = (1.0f / m_Button->fps()) * frame; } RectInt buttonRect( window ); if ( (m_Style & LOCK_ICON_SIZE) != 0 ) { int nDiffuse = m_Button->findTexture( PrimitiveSurface::DIFFUSE ); if ( nDiffuse >= 0 ) { SizeInt buttonSize( m_Button->texture( nDiffuse ).m_pImage->size() ); // keep button original size buttonRect.setWidth( buttonSize.width ); buttonRect.setHeight( buttonSize.height ); } } // flush the button material, so we can have different frames for each button m_Button->flushMaterial(); // save then change the context time float fContextTime = context.time(); context.setTime( m_Time ); // push the button material Material::push( context, m_Button ); // draw the button PrimitiveWindow::push( context.display(), buttonRect, buttonUV, buttonColor ); // restore the context time context.setTime( fContextTime ); } // display the label if ( m_Label.length() > 0 ) { String sLabel = m_Label; Font * pFont = windowStyle()->font(); ASSERT( pFont ); Color cLabel = labelColor(); if ( m_Style & EFFECT_FADEIN && visibleTime() < BUTTON_FADE_IN_TIME ) cLabel.a = (visibleTime() / BUTTON_FADE_IN_TIME) * 255; else cLabel.a = 255; SizeInt labelSize( pFont->size( sLabel ) ); PointInt labelPos( window.m_Left + ((window.width() / 2) - (labelSize.width / 2)), window.m_Top + ((window.height() / 2) - (labelSize.height / 2)) ); Font::push( context.display(), pFont, labelPos, sLabel, cLabel ); } // display hotkey in lower right corner if ( (m_Style & SHOW_HOTKEY) != 0 && m_HotKey != 0 ) { Font * pFont = windowStyle()->font(); ASSERT( pFont ); Color color( ((m_CursorOver || m_ButtonDown) && enabled()) ? windowStyle()->highColor() : windowStyle()->color() ); if ( m_Style & EFFECT_FADEIN && visibleTime() < BUTTON_FADE_IN_TIME ) color.a = (visibleTime() / BUTTON_FADE_IN_TIME) * 255; else color.a = 255; if ( m_bGreyed ) color.greyscale(BUTTON_GREYED_SCALE); String sKey( Keyboard::keyShortText( Keyboard::unmap( m_HotKey ) ) ); SizeInt textSize( pFont->size( sKey ) ); PointInt textPos( window.m_Right - textSize.width, window.m_Bottom - textSize.height ); Font::push( context.display(), pFont, textPos, sKey, color ); } }
unsigned long MSComboField::comboArrowColor(void) { return buttonColor(ComboButton); }
void MSComboField::comboArrowColor(unsigned long color_) { buttonColor(ComboButton, color_); }
void MSComboField::comboArrowColor(const char * color_) { buttonColor(ComboButton, color_); }
QColor tabFrameColor(const QPalette& pal) const { if (! pal.button().texture().isNull()) return QColor(255, 255, 255, 8); return buttonColor(pal).lighter(104); }
void OptionHandler::reloadSettings() { // gather options... QSettings config; config.beginGroup("/baghira/Style"); //we need that first to make sure we use some proper settings ;) customButtonColor = QColor(config.readNumEntry("Design_ButtonColor",(int)qApp->palette().active().button().rgb())); // design handling: // first try file: QString tmpString; FILE *file = NULL; wmDesign = 5; for (int i = 0; i < 8; i++) custCols[i] = -1; if (qstrcmp( qApp->argv() [ 0 ], "ksplash" ) == 0) { style_ = Panther; _toolbuttonStyle = Panther; _buttonStyle = Panther; tabStyle_ = Clever; bgStipple = false; inactiveButtonColor = Background; } else { // first try for a tmp file from bab starter int tmpFile = 0; tmpString = QDir::homeDirPath() + "/.baghira/.bab/" + qApp->argv() [ 0 ]; file = fopen(tmpString.latin1(), "r"); if( file == NULL ) { tmpFile = 1; tmpString = QDir::homeDirPath() + "/.baghira/" + qApp->argv() [ 0 ]; file = fopen(tmpString.latin1(), "r"); if( file == NULL ) { tmpFile = 2; tmpString = QDir::homeDirPath() + "/.baghira/.bab/.style"; file = fopen(tmpString.latin1(), "r"); } } if (file != NULL) { style_ = _buttonStyle = _toolbuttonStyle = Panther; int i3 = inactiveButtonColor = -1; tabStyle_ = (tabStyle)-1; fscanf(file,"%u\n%u\n%u\n%u\n%u\n%u\n%d\n%d\n%d\n%d\n%d\n%d\n%d\n%d\n%d\n",&style_, &wmDesign, &_buttonStyle, &_toolbuttonStyle, &tabStyle_, &i3, &custCols[0], &custCols[1], &custCols[2], &custCols[3], &custCols[4], &custCols[5], &custCols[6], &custCols[7], &inactiveButtonColor); fclose(file); if (_toolbuttonStyle < 0 || _toolbuttonStyle >= NUMSTYLES) _toolbuttonStyle = (Style)config.readNumEntry( "Special_ToolbuttonStyle", style_); if (_buttonStyle < 0 || _buttonStyle >= NUMSTYLES) _buttonStyle = (Style)config.readNumEntry( "Special_ButtonStyle", style_); if (tabStyle_ < 0 || tabStyle_ > 2) tabStyle_ = (tabStyle) config.readNumEntry( (style_ == Brushed)?"Design_TabStyleBrushed":"Design_TabStyleAqua", Clever); if (inactiveButtonColor < 0 || inactiveButtonColor > 3) inactiveButtonColor = config.readNumEntry( "Design_InactiveButtonStyle", Background); if (style_ == Brushed) bgStipple = TRUE; else if (i3 == 0) bgStipple = FALSE; else bgStipple = config.readBoolEntry( "Design_StippleBackground", true ); // inactive Button if (tmpFile == 0) remove(tmpString.latin1()); // remove TEMPORARY file else if (tmpFile == 2) { tmpString = QDir::homeDirPath() + "/.baghira/.bab/.deco"; if ((file = fopen(tmpString.latin1(), "r")) != NULL) { fscanf(file,"%u\n%u\n",&i3, &wmDesign); fclose(file); } } } else { style_ = (Style)config.readNumEntry( "Design_Default", Panther ); _toolbuttonStyle = (Style)config.readNumEntry( "Special_ToolbuttonStyle", style_); _buttonStyle = (Style)config.readNumEntry( "Special_ButtonStyle", style_); tabStyle_ = (tabStyle) config.readNumEntry( (style_ == Brushed)?"Design_TabStyleBrushed":"Design_TabStyleAqua", Clever); bgStipple = (style_ == Brushed) ? true : config.readBoolEntry( "Design_StippleBackground", true ); inactiveButtonColor = config.readNumEntry( "Design_InactiveButtonStyle", Background); } } contrast = 0; if (wmDesign > 4) wmDesign = style_; if (style_ == Jaguar) contrast = 4; else if (style_ == Brushed) { tintBrush = config.readBoolEntry( "Colors_TintBrushedMetal", false ); if (tintBrush) brushTint.setRgb( config.readNumEntry( "Colors_BrushTint", ( int ) bgColor().rgb())); } // menu stuff glossyMenus_ = config.readBoolEntry( "Menu_Glossy", true ); menuBackground = config.readNumEntry( "Menu_Background", Standard); menuOpacity = config.readNumEntry( "Menu_Opacity", 70); int menuColorStyle = config.readNumEntry( "Menu_ColorStyle", 0); menuColorButton = (menuColorStyle == 1); useCustomMenuColor = (menuColorStyle == 2); shadowText = config.readBoolEntry( "Menu_ShadowText", false); if (useCustomMenuColor){ color = QColor( config.readNumEntry( "Menu_Color1", 0 ) ); color2 = QColor( config.readNumEntry( "Menu_Color2", 0 ) ); colorHigh = QColor( config.readNumEntry( "Menu_ColorHighlight", 0 ) ); fgColor = QColor( config.readNumEntry( "Menu_TextColor", 0 ) ); fgColorHigh = QColor( config.readNumEntry( "Menu_TextColorHighlight", 0 ) ); } else if (menuColorButton){ color = customButtonColor; color2 = customButtonColor.dark(130); } else { color = qApp->palette().active().background(); color2 = qApp->palette().active().background().dark(130); } drawMenuStripe_ = config.readBoolEntry("Menu_DrawMenuStripe", false); if (drawMenuStripe_) menuStripeColor_ = QColor(config.readNumEntry("Menu_StripeColor"),(int)Qt::white.rgb()); // color stuff // widgets customWidgetColor = config.readBoolEntry( "Colors_UseCustomColors", false); if ( customWidgetColor ) { customColors[ CustomRadioOn ].setRgb( config.readNumEntry( "Colors_RadioOn", ( int ) buttonColor().rgb() ) ); customColors[ CustomRadioOff ].setRgb( config.readNumEntry( "Colors_RadioOff", ( int ) bgColor().rgb() ) ); customColors[ CustomCBOn ].setRgb( config.readNumEntry( "Colors_CheckOn", ( int ) buttonColor().rgb() ) ); customColors[ CustomCBOff ].setRgb( config.readNumEntry( "Colors_CheckOff", ( int ) bgColor().rgb() ) ); customColors[ CustomTabOn ].setRgb( config.readNumEntry( "Colors_TabActive", ( int ) buttonColor().rgb() ) ); customColors[ CustomTabOff ].setRgb( config.readNumEntry( "Colors_TabInactive", ( int ) bgColor().rgb() ) ); customColors[ CustomSBSlider ].setRgb( config.readNumEntry( "Colors_Slider", ( int ) bgColor().rgb() ) ); customColors[ CustomSBSliderHover ].setRgb( config.readNumEntry( "Colors_SliderHovered", ( int ) buttonColor().rgb() ) ); customColors[ CustomSBSliderPressed ].setRgb( config.readNumEntry( "Colors_SliderPressed", ( int ) buttonColor().dark(110).rgb() ) ); customColors[ CustomSBGroove ].setRgb( config.readNumEntry( "Colors_SliderGroove", ( int ) bgColor().rgb() ) ); } if (inactiveButtonColor == Custom) customInactiveButtonColor = QColor( config.readNumEntry( "Design_InactiveButtonColor", (int) bgColor().rgb())); contrast += config.readNumEntry( "Design_StippleContrast", 3); bevelHighlights_ = config.readBoolEntry( "Design_BevelAsHighlight", true); //shadows groupboxshadow = (style_ == Brushed) ? false : config.readBoolEntry( "Design_ShadowGroupBoxes", true ); shadowDarkness = config.readNumEntry( "Design_GroupBoxeShadowDarkness", 6); //ListViews expanderStyle = config.readNumEntry( "Special_ExpanderStyle", Apple); useCustomExpanderColor = config.readBoolEntry( "Special_CustomExpanderColor", false); if (useCustomExpanderColor) expanderColor = QColor( config.readNumEntry( "Special_ExpanderColor", (int) qApp->palette().active().text().rgb())); drawDotlines = config.readBoolEntry( "Special_DrawTreeLines", true); if (drawDotlines){ dotlineStyle = config.readNumEntry( "Special_TreelineStyle", Line); dotlineColor = QColor( config.readNumEntry( "Special_TreelineColor", (int) qApp->palette().active().mid().rgb())); } //slider squeezesbslider = config.readBoolEntry( "Special_SqueezeSlider", false ); shadowsbslider = config.readBoolEntry( "Special_ShadowSlider", false ); animateSlider = config.readBoolEntry( "Special_AnimateSlider", true ); // toolbar int utb = config.readNumEntry( "Special_UnhoveredToolButtons", 2 ); tbFrame = (utb == 2) || ((style_ == Brushed) && (utb == 1)) || ((style_ != Brushed) && (utb == 0)); // tweaks centerTabs = config.readBoolEntry( "Design_CenterTabs", true); smoothListViewHeaders = (style_ == Milk) ? true : !config.readBoolEntry( "Special_UseFlatLVH", false); smootherLVH = config.readBoolEntry( "Special_RoundTaskbuttons", false); icyButtons = config.readNumEntry( "Design_ButtonStyle", 0) == 0; progressBar = config.readNumEntry( "Special_ProgressStyle", baghira); removeKickerBevel = config.readBoolEntry( "Special_RemoveKickerBevel", false); animateButton = config.readBoolEntry( "Design_AnimateButtons", true); animateProgress = config.readBoolEntry( "Design_AnimateProgress", true); drawProgressLabel = config.readBoolEntry( "Special_ShowProgressValue", false); config.endGroup(); config.beginGroup("/baghira/Deco"); titleButtonColor_[0] = QColor((unsigned int)config.readNumEntry( "CloseButtonColor", QColor(200,85,70).rgb())); titleButtonColor_[1] = QColor((unsigned int)config.readNumEntry( "MinButtonColor", QColor(230,155,40).rgb())); titleButtonColor_[2] = QColor((unsigned int)config.readNumEntry( "MaxButtonColor", QColor(121,180,54).rgb())); if (style_ == Jaguar) { titleColor_[0] = QColor((unsigned int)config.readNumEntry( "inactiveColor1_1", QColor(204,214,230).rgb())); titleColor_[1] = QColor((unsigned int)config.readNumEntry( "inactiveColor2_1", QColor(194,196,211).rgb())); } else if (style_ != Brushed) { titleColor_[0] = QColor((unsigned int)config.readNumEntry( "activeColor1_2", QColor(238,238,238).rgb())); titleColor_[1] = QColor((unsigned int)config.readNumEntry( "activeColor2_2", QColor(205,202,205).rgb())); } if (style_ == Tiger) { int r,g,b; aDecoColor1_ = QColor((unsigned int)config.readNumEntry( "activeColor2_4", (unsigned int) QColor(205,202,205).rgb())); aDecoColor2_ = QColor((unsigned int)config.readNumEntry( "activeColor1_4", (unsigned int) QColor(238,238,238).rgb())); r = (int)CLAMP(aDecoColor1_.red() * pow((double)aDecoColor1_.red() / (double)aDecoColor2_.red(),2.0),0,255); g = (int)CLAMP(aDecoColor1_.green() * pow((double)aDecoColor1_.green() / (double)aDecoColor2_.green(),2.0),0,255); b = (int)CLAMP(aDecoColor1_.blue() * pow((double)aDecoColor1_.blue() / (double)aDecoColor2_.blue(),2.0),0,255); aDecoColor2_.setRgb(r,g,b); } else { aDecoColor1_ = Qt::black; aDecoColor2_ = Qt::black; } config.endGroup(); // Option gathered }
void MSEntryFieldCombo::buttonColor(ButtonFlag flag_, const char * color_) { buttonColor(flag_, server()->pixel(color_)); }