📄 klearlook.cpp
字号:
widget->removeEventFilter( this ); } else if ( ::qt_cast<QButton *>( widget ) || ::qt_cast<QComboBox *>( widget ) || widget->inherits( "QToolBarExtensionWidget" ) ) { widget->setBackgroundMode( QWidget::PaletteButton ); widget->removeEventFilter( this ); } else if ( ::qt_cast<QMenuBar *>( widget ) || ::qt_cast<QToolBar *>( widget ) || ::qt_cast<QPopupMenu *>( widget ) ) widget->setBackgroundMode( QWidget::PaletteBackground ); else if ( widget->inherits( "KToolBarSeparator" ) ) { widget->setBackgroundMode( PaletteBackground ); widget->removeEventFilter( this ); } else if ( ::qt_cast<QScrollBar *>( widget ) ) { widget->setMouseTracking( false ); widget->removeEventFilter( this ); widget->setBackgroundMode( QWidget::PaletteButton ); } else if ( ::qt_cast<QSlider *>( widget ) || ::qt_cast<QHeader *>( widget ) ) { widget->setMouseTracking( false ); widget->removeEventFilter( this ); } else if ( 0 == qstrcmp( widget->name(), kdeToolbarWidget ) ) { widget->removeEventFilter( this ); widget->setBackgroundMode( PaletteBackground ); } KStyle::unPolish( widget );}bool KlearlookStyle::eventFilter( QObject *object, QEvent *event ) { if ( object->parent() && 0 == qstrcmp( object->name(), kdeToolbarWidget ) ) { // Draw background for custom widgets in the toolbar that have specified a "kde toolbar widget" name. if ( QEvent::Paint == event->type() ) { QWidget * widget = static_cast<QWidget*>( object ), *parent = static_cast<QWidget*>( object->parent() );#ifdef QTC_GRADIENT_TOOLBARS_AND_MENUBARS // Find the top-level toolbar of this widget, since it may be nested in other // widgets that are on the toolbar. int x_offset = widget->x(), y_offset = widget->y(); while ( parent && parent->parent() && !qstrcmp( parent->name(), kdeToolbarWidget ) ) { x_offset += parent->x(); y_offset += parent->y(); parent = static_cast<QWidget*>( parent->parent() ); } QRect pr( parent->rect() ); bool horiz_grad = pr.width() < pr.height(); // Check if the parent is a QToolbar, and use its orientation, else guess. QToolBar *toolbar = dynamic_cast<QToolBar*>( parent ); if ( toolbar ) horiz_grad = toolbar->orientation() == Qt::Vertical; drawBevelGradient( parent->colorGroup().background(), true, 1, &QPainter( widget ), QRect( x_offset, y_offset, pr.width(), pr.height() ), horiz_grad, SHADE_BAR_LIGHT, SHADE_BAR_DARK );#else QPainter( widget ).fillRect( widget->rect(), parent->colorGroup().background() );#endif return false; // Now draw the contents } } else if ( object->inherits( "KToolBarSeparator" ) && QEvent::Paint == event->type() ) { QFrame * frame = dynamic_cast<QFrame*>( object ); if ( frame && QFrame::NoFrame != frame->frameShape() ) { QPainter painter( frame ); if ( QFrame::VLine == frame->frameShape() ) drawPrimitive( PE_DockWindowSeparator, &painter, frame->rect(), frame->colorGroup(), Style_Horizontal ); else if ( QFrame::HLine == frame->frameShape() ) drawPrimitive( PE_DockWindowSeparator, &painter, frame->rect(), frame->colorGroup() ); else return false; return true; // been drawn! } } switch ( event->type() ) { case QEvent::Enter: if ( object->isWidgetType() ) { hoverWidget = ( QWidget * ) object; if ( hoverWidget && hoverWidget->isEnabled() ) { if ( redrawHoverWidget() ) { hoverWidget->repaint( false ); if ( APP_KICKER == themedApp ) hover = HOVER_NONE; } oldCursor = QCursor::pos(); } else hoverWidget = NULL; } break; case QEvent::Leave: if ( hoverWidget && object == hoverWidget ) { oldCursor.setX( -1 ); oldCursor.setY( -1 ); hoverWidget = NULL; ( ( QWidget * ) object ) ->repaint( false ); } break; case QEvent::MouseMove: if ( hoverWidget && object->isWidgetType() ) { if ( redrawHoverWidget() ) { hoverWidget->repaint( false ); if ( APP_KICKER == themedApp ) hover = HOVER_NONE; } oldCursor = QCursor::pos(); } break; default: break; } return KStyle::eventFilter( object, event );}void KlearlookStyle::drawLightBevelButton( QPainter *p, const QRect &r, const QColorGroup &cg, QStyle::SFlags flags, bool useGrad, ERound round, const QColor &fill, const QColor *custom, bool light ) const{ QRect br( r ); bool sunken = ( flags & ( QStyle::Style_Down | QStyle::Style_On | QStyle::Style_Sunken ) ); int dark = borderButton ? 4 : 5, c1 = sunken ? dark : light ? 6 : 0; p->save(); if ( !borderButton ) br.addCoords( -1, -1, 1, 1 ); if ( ( sunken && !borderButton ) || ( !sunken && flags & QStyle::Style_Raised ) ) { p->setPen( custom ? custom[ c1 ] : gray[ c1 ] ); if ( APPEARANCE_LIGHT_GRADIENT != appearance ) { int c2 = sunken ? 0 : dark; p->drawLine( br.x() + 1, br.y() + 2, br.x() + 1, br.y() + br.height() - 3 ); // left p->drawLine( br.x() + 1, br.y() + 1, br.x() + br.width() - 2, br.y() + 1 ); // top p->setPen( custom ? custom[ c2 ] : gray[ c2 ] ); p->drawLine( br.x() + br.width() - 2, br.y() + 1, br.x() + br.width() - 2, br.y() + br.height() - 3 ); // right p->drawLine( br.x() + 1, br.y() + br.height() - 2, br.x() + br.width() - 2, br.y() + br.height() - 2 ); // bottom br.addCoords( 2, 2, -2, -2 ); } else { p->drawLine( br.x() + 1, br.y() + 2, br.x() + 1, br.y() + br.height() - 2 ); // left p->drawLine( br.x() + 1, br.y() + 1, br.x() + br.width() - 2, br.y() + 1 ); // top br.addCoords( 2, 2, -1, -1 ); } } else br.addCoords( 1, 1, -1, -1 ); // fill if ( useGrad && APPEARANCE_FLAT != appearance ) { drawBevelGradient( fill.dark( 100 ), !sunken, 0, p, QRect( br.left() - 1, br.top() - 1, br.width() + 2, br.height() + 2 ), flags & Style_Horizontal, sunken ? SHADE_BEVEL_BUTTON_GRAD_LIGHT( appearance ) : SHADE_BEVEL_BUTTON_GRAD_LIGHT( appearance ), sunken ? SHADE_BEVEL_BUTTON_GRAD_DARK( appearance ) : SHADE_BEVEL_BUTTON_GRAD_DARK( appearance ) ); } else p->fillRect( br, fill ); if ( borderButton ) if ( rounded && ROUNDED_NONE != round ) { bool wide = r.width() >= QTC_MIN_BTN_SIZE, tall = r.height() >= QTC_MIN_BTN_SIZE; QColor border( flags & Style_ButtonDefault && IND_FONT_COLOUR == defBtnIndicator & flags & Style_Enabled ? cg.text() : custom ? custom[ 5 ] : gray[ 5 ] ); p->setPen( border.light(80) ); switch ( round ) { case ROUNDED_ALL: p->drawLine( r.x() + 2, r.y(), r.x() + r.width() - 3, r.y() ); p->drawLine( r.x() + 2, r.y() + r.height() - 1, r.x() + r.width() - 3, r.y() + r.height() - 1 ); p->drawLine( r.x(), r.y() + 2, r.x(), r.y() + r.height() - 3 ); p->drawLine( r.x() + r.width() - 1, r.y() + 2, r.x() + r.width() - 1, r.y() + r.height() - 3 ); if ( tall && wide ) { p->drawPoint( r.x() + r.width() - 2, r.y() + 1 ); p->drawPoint( r.x() + 1, r.y() + r.height() - 2 ); p->drawPoint( r.x() + r.width() - 2, r.y() + r.height() - 2 ); p->drawPoint( r.x() + 1, r.y() + 1 ); p->setPen( midColor( border, cg.background() ) ); } if ( !formMode || !( tall && wide ) ) { p->drawLine( r.x(), r.y() + 1, r.x() + 1, r.y() ); p->drawLine( r.x() + r.width() - 2, r.y(), r.x() + r.width() - 1, r.y() + 1 ); p->drawLine( r.x(), r.y() + r.height() - 2, r.x() + 1, r.y() + r.height() - 1 ); p->drawLine( r.x() + r.width() - 2, r.y() + r.height() - 1, r.x() + r.width() - 1, r.y() + r.height() - 2 ); } if ( !formMode ) { if ( tall && wide ) p->setPen( cg.background() ); else p->setPen( midColor( custom ? custom[ 3 ] : gray[ 3 ], cg.background() ) ); p->drawPoint( r.x(), r.y() ); p->drawPoint( r.x() + r.width() - 1, r.y() ); p->drawPoint( r.x(), r.y() + r.height() - 1 ); p->drawPoint( r.x() + r.width() - 1, r.y() + r.height() - 1 ); } break; case ROUNDED_TOP: p->drawLine( r.x() + 2, r.y(), r.x() + r.width() - 3, r.y() ); p->drawLine( r.x() + 1, r.y() + r.height() - 1, r.x() + r.width() - 2, r.y() + r.height() - 1 ); p->drawLine( r.x(), r.y() + 2, r.x(), r.y() + r.height() - 1 ); p->drawLine( r.x() + r.width() - 1, r.y() + 2, r.x() + r.width() - 1, r.y() + r.height() - 1 ); if ( wide ) { p->drawPoint( r.x() + r.width() - 2, r.y() + 1 ); p->drawPoint( r.x() + 1, r.y() + 1 ); p->setPen( midColor( border, cg.background() ) ); } if ( !formMode || !wide ) { p->drawLine( r.x(), r.y() + 1, r.x() + 1, r.y() ); p->drawLine( r.x() + r.width() - 2, r.y(), r.x() + r.width() - 1, r.y() + 1 ); } if ( !formMode ) { if ( wide ) p->setPen( cg.background() ); else p->setPen( midColor( custom ? custom[ 3 ] : gray[ 3 ], cg.background() ) ); p->drawPoint( r.x(), r.y() ); p->drawPoint( r.x() + r.width() - 1, r.y() ); } break; case ROUNDED_BOTTOM: p->drawLine( r.x() + 1, r.y(), r.x() + r.width() - 2, r.y() ); p->drawLine( r.x() + 2, r.y() + r.height() - 1, r.x() + r.width() - 3, r.y() + r.height() - 1 ); p->drawLine( r.x(), r.y(), r.x(), r.y() + r.height() - 3 ); p->drawLine( r.x() + r.width() - 1, r.y(), r.x() + r.width() - 1, r.y() + r.height() - 3 ); if ( wide ) { p->drawPoint( r.x() + 1, r.y() + r.height() - 2 ); p->drawPoint( r.x() + r.width() - 2, r.y() + r.height() - 2 ); p->setPen( midColor( border, cg.background() ) ); } if ( !formMode || !wide ) { p->drawLine( r.x(), r.y() + r.height() - 2, r.x() + 1, r.y() + r.height() - 1 ); p->drawLine( r.x() + r.width() - 2, r.y() + r.height() - 1, r.x() + r.width() - 1, r.y() + r.height() - 2 ); } if ( !formMode ) { if ( wide ) p->setPen( cg.background() ); else p->setPen( midColor( custom ? custom[ 3 ] : gray[ 3 ], cg.background() ) ); p->drawPoint( r.x(), r.y() + r.height() - 1 ); p->drawPoint( r.x() + r.width() - 1, r.y() + r.height() - 1 ); } break; case ROUNDED_LEFT: p->drawLine( r.x() + 2, r.y(), r.x() + r.width() - 2, r.y() ); p->drawLine( r.x() + 2, r.y() + r.height() - 1, r.x() + r.width() - 2, r.y() + r.height() - 1 ); p->drawLine( r.x(), r.y() + 2, r.x(), r.y() + r.height() - 3 ); p->drawLine( r.x() + r.width() - 1, r.y(), r.x() + r.width() - 1, r.y() + r.height() - 1 ); if ( tall ) { p->drawPoint( r.x() + 1, r.y() + r.height() - 2 ); p->drawPoint( r.x() + 1, r.y() + 1 ); p->setPen( midColor( border, cg.background() ) ); } if ( !formMode || !tall ) { p->drawLine( r.x(), r.y() + 1, r.x() + 1, r.y() ); p->drawLine( r.x(), r.y() + r.height() - 2, r.x() + 1, r.y() + r.height() - 1 ); } if ( !formMode ) { if ( tall ) p->setPen( cg.background() ); else p->setPen( midColor( custom ? custom[ 3 ] : gray[ 3 ], cg.background() ) ); p->drawPoint( r.x(), r.y() ); p->drawPoint( r.x(), r.y() + r.height() - 1 ); } break; case ROUNDED_RIGHT: p->drawLine( r.x() + 1, r.y(), r.x() + r.width() - 3, r.y() ); p->drawLine( r.x() + 1, r.y() + r.height() - 1, r.x() + r.width() - 3, r.y() + r.height() - 1 ); p->drawLine( r.x(), r.y(), r.x(), r.y() + r.height() - 1 ); p->drawLine( r.x() + r.width() - 1, r.y() + 2, r.x() + r.width() - 1, r.y() + r.height() - 3 ); if ( tall ) { p->drawPoint( r.x() + r.width() - 2, r.y() + 1 ); p->drawPoint( r.x() + r.width() - 2, r.y() + r.height() - 2 ); p->setPen( midColor( border, cg.background() ) ); } if ( !formMode || !tall ) { p->drawLine( r.x() + r.width() - 2, r.y(), r.x() + r.width() - 1, r.y() + 1 ); p->drawLine( r.x() + r.width() - 2, r.y() + r.height() - 1,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -