void qDrawWinPanel(QPainter *p, int x, int y, int w, int h, const QPalette &pal, bool sunken, const QBrush *fill) { if (sunken) qDrawWinShades(p, x, y, w, h, pal.dark().color(), pal.light().color(), pal.shadow().color(), pal.midlight().color(), fill); else qDrawWinShades(p, x, y, w, h, pal.light().color(), pal.shadow().color(), pal.midlight().color(), pal.dark().color(), fill); }
void FormStyle::GlobalColorButtonCliked() { QColor initialColor; if ( focusWidget()->objectName() == "bC1_1" ) initialColor = applicationPalette.button().color().rgba(); else if ( focusWidget()->objectName() == "bC1_2" ) initialColor = applicationPalette.window().color().rgba(); else if ( focusWidget()->objectName() == "bC1_3" ) initialColor = applicationPalette.shadow().color().rgba(); else if ( focusWidget()->objectName() == "bC1_4" ) initialColor = applicationPalette.highlight().color().rgba(); else if ( focusWidget()->objectName() == "bC1_5" ) initialColor = applicationPalette.base().color().rgba(); else if ( focusWidget()->objectName() == "bC1_6" ) initialColor = applicationPalette.text().color().rgba(); else if ( focusWidget()->objectName() == "bC1_7" ) initialColor = applicationPalette.highlightedText().color().rgba(); else if ( focusWidget()->objectName() == "bC1_8" ) initialColor = sliderButtonColor.rgb(); else initialColor = Qt::white; QColor color = QColorDialog::getColor( initialColor, this, Texts[ 119 ] /*Wybierz kolor*/, QColorDialog::DontUseNativeDialog ); if ( !color.isValid() ) return; if ( focusWidget()->objectName() == "bC1_1" ) applicationPalette.setBrush( QPalette::Button, color ); else if ( focusWidget()->objectName() == "bC1_2" ) applicationPalette.setBrush( QPalette::Window, color ); else if ( focusWidget()->objectName() == "bC1_3" ) { applicationPalette.setBrush( QPalette::Shadow, color ); applicationPalette.setBrush( QPalette::Light, color ); applicationPalette.setBrush( QPalette::Dark, color ); } else if ( focusWidget()->objectName() == "bC1_4" ) applicationPalette.setBrush( QPalette::Highlight, color ); else if ( focusWidget()->objectName() == "bC1_5" ) applicationPalette.setBrush( QPalette::Base, color ); else if ( focusWidget()->objectName() == "bC1_6" ) { applicationPalette.setBrush( QPalette::Text, color ); applicationPalette.setBrush( QPalette::WindowText, color ); applicationPalette.setBrush( QPalette::ButtonText, color ); } else if ( focusWidget()->objectName() == "bC1_7" ) applicationPalette.setBrush( QPalette::HighlightedText, color ); else if ( focusWidget()->objectName() == "bC1_8" ) sliderButtonColor = color; setButtonsColor(); }
void FormStyle::setButtonsColor() { if ( ui.ccB->isChecked() ) { QPalette tmpPalette; tmpPalette.setBrush( QPalette::Button, applicationPalette.button() ); ui.bC1_1->setPalette( tmpPalette ); tmpPalette.setBrush( QPalette::Button, applicationPalette.window() ); ui.bC1_2->setPalette( tmpPalette ); tmpPalette.setBrush( QPalette::Button, applicationPalette.shadow() ); ui.bC1_3->setPalette( tmpPalette ); tmpPalette.setBrush( QPalette::Button, applicationPalette.highlight() ); ui.bC1_4->setPalette( tmpPalette ); tmpPalette.setBrush( QPalette::Button, applicationPalette.base() ); ui.bC1_5->setPalette( tmpPalette ); tmpPalette.setBrush( QPalette::Button, applicationPalette.text() ); ui.bC1_6->setPalette( tmpPalette ); tmpPalette.setBrush( QPalette::Button, applicationPalette.highlightedText() ); ui.bC1_7->setPalette( tmpPalette ); tmpPalette.setBrush( QPalette::Button, sliderButtonColor ); ui.bC1_8->setPalette( tmpPalette ); if ( !mainWindowPixmap.isNull() ) { QBrush brushW( mainWindowPixmap.scaled( ui.bP2_2->size(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation ) ); tmpPalette.setBrush( QPalette::Button, brushW ); ui.bP2_2->setPalette( tmpPalette ); } else ui.bP2_2->setPalette( qApp->palette() ); } else { ui.bC1_1->setPalette( qApp->palette() ); ui.bC1_2->setPalette( qApp->palette() ); ui.bC1_3->setPalette( qApp->palette() ); ui.bC1_4->setPalette( qApp->palette() ); ui.bC1_5->setPalette( qApp->palette() ); ui.bC1_6->setPalette( qApp->palette() ); ui.bC1_7->setPalette( qApp->palette() ); ui.bC1_8->setPalette( qApp->palette() ); ui.bP2_2->setPalette( qApp->palette() ); } }
static void qtmDrawShadeRoundPanel(QPainter *p, const QRect &r, const QPalette &pal, bool sunken, int lineWidth, const QBrush *fill) { if (r.width() == 0 || r.height() == 0) return; if (!(r.width() > 0 && r.height() > 0 && lineWidth >= 0)) { qWarning("qtmDrawShadeRoundPanel: Invalid parameters"); } QColor shade = pal.dark().color(); QColor light = pal.light().color(); if (fill) { if (fill->color() == shade) shade = pal.shadow().color(); if (fill->color() == light) light = pal.midlight().color(); } QPen oldPen = p->pen(); // save pen QBrush oldBrush = p->brush(); // save brush QRect rect(r); int border = 8; p->setPen(Qt::NoPen); if (sunken) { p->setBrush(light); qtmDrawRoundedRect(p,rect,border,border, Qt::AbsoluteSize); // p->drawRoundedRect(rect,border,border, Qt::AbsoluteSize); rect.adjust(0,0,-1,-1); p->setBrush(shade); qtmDrawRoundedRect(p,rect,border,border, Qt::AbsoluteSize); // p->drawRoundedRect(rect,border,border, Qt::AbsoluteSize); rect.adjust(1,1,0,0); } p->setBrush(fill ? *fill : shade); qtmDrawRoundedRect(p,rect,border,border, Qt::AbsoluteSize); // p->drawRoundedRect(rect,border,border, Qt::AbsoluteSize); p->setPen(oldPen); // restore pen p->setBrush(oldBrush); // restore brush }
QVariantMap Bridge::get_palette() { QVariantMap colors; QPalette palette = qApp->palette(); colors.insert("window", palette.window().color().name()); colors.insert("window_text", palette.windowText().color().name()); colors.insert("base", palette.base().color().name()); colors.insert("alternate_base", palette.alternateBase().color().name()); colors.insert("text", palette.text().color().name()); colors.insert("button", palette.buttonText().color().name()); colors.insert("bright_text", palette.brightText().color().name()); colors.insert("light", palette.light().color().name()); colors.insert("midlight", palette.midlight().color().name()); colors.insert("dark", palette.dark().color().name()); colors.insert("mid", palette.mid().color().name()); colors.insert("shadow", palette.shadow().color().name()); colors.insert("highlight", palette.highlight().color().name()); colors.insert("highlight_text", palette.highlightedText().color().name()); colors.insert("link", palette.link().color().name()); colors.insert("link_visited", palette.linkVisited().color().name()); return colors; }
void qDrawShadePanel(QPainter *p, int x, int y, int w, int h, const QPalette &pal, bool sunken, int lineWidth, const QBrush *fill) { if (w == 0 || h == 0) return; if (!(w > 0 && h > 0 && lineWidth >= 0)) { qWarning("qDrawShadePanel: Invalid parameters"); } QColor shade = pal.dark().color(); QColor light = pal.light().color(); if (fill) { if (fill->color() == shade) shade = pal.shadow().color(); if (fill->color() == light) light = pal.midlight().color(); } QPen oldPen = p->pen(); // save pen QVector<QLineF> lines; lines.reserve(2*lineWidth); if (sunken) p->setPen(shade); else p->setPen(light); int x1, y1, x2, y2; int i; x1 = x; y1 = y2 = y; x2 = x+w-2; for (i=0; i<lineWidth; i++) { // top shadow lines << QLineF(x1, y1++, x2--, y2++); } x2 = x1; y1 = y+h-2; for (i=0; i<lineWidth; i++) { // left shado lines << QLineF(x1++, y1, x2++, y2--); } p->drawLines(lines); lines.clear(); if (sunken) p->setPen(light); else p->setPen(shade); x1 = x; y1 = y2 = y+h-1; x2 = x+w-1; for (i=0; i<lineWidth; i++) { // bottom shadow lines << QLineF(x1++, y1--, x2, y2--); } x1 = x2; y1 = y; y2 = y+h-lineWidth-1; for (i=0; i<lineWidth; i++) { // right shadow lines << QLineF(x1--, y1++, x2--, y2); } p->drawLines(lines); if (fill) // fill with fill color p->fillRect(x+lineWidth, y+lineWidth, w-lineWidth*2, h-lineWidth*2, *fill); p->setPen(oldPen); // restore pen }
SeekSlider::SeekSlider( Qt::Orientation q, QWidget *_parent, bool _static ) : QSlider( q, _parent ), b_classic( _static ) { isSliding = false; f_buffering = 1.0; mHandleOpacity = 1.0; chapters = NULL; mHandleLength = -1; // prepare some static colors QPalette p = palette(); QColor background = p.color( QPalette::Active, QPalette::Background ); tickpointForeground = p.color( QPalette::Active, QPalette::WindowText ); tickpointForeground.setHsv( tickpointForeground.hue(), ( background.saturation() + tickpointForeground.saturation() ) / 2, ( background.value() + tickpointForeground.value() ) / 2 ); // set the background color and gradient QColor backgroundBase( p.window().color() ); backgroundGradient.setColorAt( 0.0, backgroundBase.darker( 140 ) ); backgroundGradient.setColorAt( 1.0, backgroundBase ); // set the foreground color and gradient QColor foregroundBase( 50, 156, 255 ); foregroundGradient.setColorAt( 0.0, foregroundBase ); foregroundGradient.setColorAt( 1.0, foregroundBase.darker( 140 ) ); // prepare the handle's gradient handleGradient.setColorAt( 0.0, p.window().color().lighter( 120 ) ); handleGradient.setColorAt( 0.9, p.window().color().darker( 120 ) ); // prepare the handle's shadow gradient QColor shadowBase = p.shadow().color(); if( shadowBase.lightness() > 100 ) shadowBase = QColor( 60, 60, 60 ); // Palette's shadow is too bright shadowDark = shadowBase.darker( 150 ); shadowLight = shadowBase.lighter( 180 ); shadowLight.setAlpha( 50 ); /* Timer used to fire intermediate updatePos() when sliding */ seekLimitTimer = new QTimer( this ); seekLimitTimer->setSingleShot( true ); /* Tooltip bubble */ mTimeTooltip = new TimeTooltip( this ); mTimeTooltip->setMouseTracking( true ); /* Properties */ setRange( MINIMUM, MAXIMUM ); setSingleStep( 2 ); setPageStep( 10 ); setMouseTracking( true ); setTracking( true ); setFocusPolicy( Qt::NoFocus ); /* Use the new/classic style */ if( !b_classic ) setStyle( new SeekStyle ); /* Init to 0 */ setPosition( -1.0, 0, 0 ); secstotimestr( psz_length, 0 ); animHandle = new QPropertyAnimation( this, "handleOpacity", this ); animHandle->setDuration( FADEDURATION ); animHandle->setStartValue( 0.0 ); animHandle->setEndValue( 1.0 ); hideHandleTimer = new QTimer( this ); hideHandleTimer->setSingleShot( true ); hideHandleTimer->setInterval( FADEOUTDELAY ); CONNECT( this, sliderMoved( int ), this, startSeekTimer() ); CONNECT( seekLimitTimer, timeout(), this, updatePos() ); CONNECT( hideHandleTimer, timeout(), this, hideHandle() ); mTimeTooltip->installEventFilter( this ); }
void FormStyle::quickSetColor() { QFont globalFont = SystemFont; if ( ui.ccB->isChecked() && !ResetColor ) { qApp->setPalette( applicationPalette ); QPalette qSliderPalette; qSliderPalette.setBrush( QPalette::Button, sliderButtonColor ); qApp->setPalette( qSliderPalette, "QSlider" ); if ( ui.use2->isChecked() ) { QPalette tmpPalette = qApp->palette(); if ( !mainWindowPixmap.isNull() ) { QBrush brushW( mainWindowPixmap.scaled( f1.size(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation ) ); tmpPalette.setBrush( QPalette::Window, brushW ); } QColor colorA; colorA = tmpPalette.button().color(); colorA.setAlphaF( ui.bP2_1->value() ); tmpPalette.setBrush( QPalette::Button, colorA ); colorA = tmpPalette.base().color(); colorA.setAlphaF( ui.bP2_1->value() ); tmpPalette.setBrush( QPalette::Base, colorA ); if ( ui.bHt2->isChecked() ) { colorA = tmpPalette.highlight().color(); colorA.setAlphaF( ui.bP2_1->value() ); tmpPalette.setBrush( QPalette::Highlight, colorA ); } if ( ui.bSt2->isChecked() ) { colorA = tmpPalette.shadow().color(); colorA.setAlphaF( ui.bP2_1->value() ); tmpPalette.setBrush( QPalette::Shadow, colorA ); } f1.setPalette( tmpPalette ); } else { f1.setPalette( qApp->palette() ); } globalFont = ui.bF1->currentFont(); globalFont.setPointSize( ui.bFSize1->value() ); } else { qApp->setPalette( systemPalette ); f1.setPalette( qApp->palette() ); sliderButtonColor = qApp->palette().brush( QPalette::Button ).color(); } if ( ResetColor ) { ResetColor = false; applicationPalette = systemPalette; ui.bF1->setCurrentFont( SystemFont.toString() ); ui.bFSize1->setValue( SystemFont.pointSize() ); } QColor col = qApp->palette().window().color(); col.setAlphaF( ui.bP2_1->value() ); fsl.SetColor( col ); f1.ui.pbL->setPalette( qApp->palette() ); f1.ui.pbR->setPalette( qApp->palette() ); globalFont.setBold( false ); globalFont.setItalic( false ); globalFont.setUnderline( false ); if ( globalFont.pointSize() > 14 ) globalFont.setPointSize( 14 ); else if ( globalFont.pointSize() < 6 ) globalFont.setPointSize( 6 ); #ifndef Q_OS_MAC qApp->setFont( globalFont ); #endif }