Skip to content

Commit

Permalink
Changed how Toolbuttons look when they are hovered over, to be closer…
Browse files Browse the repository at this point in the history
… to the QT3 theme
  • Loading branch information
MartinF99 committed Jun 9, 2023
1 parent 3619fcc commit 4b7aa9a
Show file tree
Hide file tree
Showing 15 changed files with 82 additions and 6,739 deletions.
25 changes: 0 additions & 25 deletions README

This file was deleted.

28 changes: 21 additions & 7 deletions qt5/QStyle/plastikstyle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
static const bool AnimateBusyProgressBar = true;
static const bool AnimateProgressBar = true;
#define QPlastique_MaskButtons
static const int ProgressBarFps = 25;
static const int ProgressBarFps = 30;
static const int blueFrameWidth = 2; // with of line edit focus frame

#include <qapplication.h>
Expand Down Expand Up @@ -861,7 +861,12 @@ static void qt_plastique_drawShadedPanel(QPainter *painter, const QStyleOption *
qt_plastique_draw_gradient(painter, rect.adjusted(1, 1, -1, -1),
option->palette.button().color().darker(114),
option->palette.button().color().darker(106));
} else {
}
else if((option->state & QStyle::State_MouseOver)) // paint a gradient when something is just hovered
{
qt_plastique_draw_gradient(painter, rect.adjusted(1,1,-1,-1), option->palette.button().color().darker(106), option->palette.button().color().darker(98));
}
else {
qt_plastique_draw_gradient(painter, rect.adjusted(1, 1, -1, -1),
base ? option->palette.window().color().lighter(105) : gradientStartColor,
base ? option->palette.window().color().darker(102) : gradientStopColor);
Expand Down Expand Up @@ -2947,7 +2952,7 @@ void PlastikStyle::drawControl(ControlElement element, const QStyleOption *optio
#ifndef QT_NO_MENUBAR
case CE_MenuBarItem:
// Draws a menu bar item; File, Edit, Help etc..
if ((option->state & State_Selected)) {
if ((option->state & State_Selected) || (option->state & State_MouseOver)) {
QPixmap cache;
QString pixmapName = QStyleHelper::uniqueName(QLatin1String("menubaritem"), option, option->rect.size());
if (!QPixmapCache::find(pixmapName, &cache)) {
Expand All @@ -2963,7 +2968,8 @@ void PlastikStyle::drawControl(ControlElement element, const QStyleOption *optio
qt_plastique_draw_gradient(&cachePainter, rect.adjusted(1, 1, -1, -1),
option->palette.button().color().darker(114),
option->palette.button().color().darker(106));
} else {
}
else {
qt_plastique_draw_gradient(&cachePainter, rect.adjusted(1, 1, -1, -1),
option->palette.window().color().lighter(105),
option->palette.window().color().darker(102));
Expand Down Expand Up @@ -3725,6 +3731,8 @@ void PlastikStyle::drawComplexControl(ComplexControl control, const QStyleOption
p->drawPoints(points, 4);
}
END_STYLE_PIXMAPCACHE
// TODO: make a new Pixmap clipRect, that is actually painted in the darker progressbar gradient, and drawn above slider
// TODO:This should allow us to highlight our slider position better. AKA slider highlight
}

if ((option->subControls & SC_SliderHandle) && handle.isValid()) {
Expand Down Expand Up @@ -5786,9 +5794,15 @@ bool PlastikStyle::eventFilter(QObject *watched, QEvent *event)
case QEvent::Paint:
case QEvent::Show:
if (QProgressBar *bar = qobject_cast<QProgressBar *>(watched)) {
// Animation by timer for progress bars that have their min and
// max values the same
startProgressAnimation(reinterpret_cast<QProgressBar *>(watched));
// Do we animate our progress bar?
// OR: Do we animate our busy ProgressBar and is our bar -> minimum == bar->maximum
if(AnimateProgressBar || (AnimateBusyProgressBar && bar->minimum() == bar->maximum()))
{
startProgressAnimation(reinterpret_cast<QProgressBar *>(watched));
break;
}
// stop the animation if not
stopProgressAnimation(reinterpret_cast<QProgressBar *>(watched));
}
break;
case QEvent::Destroy:
Expand Down
2 changes: 2 additions & 0 deletions qt6/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
if(ENABLE_QSTYLE)
add_subdirectory(QStyle)
endif()

add_subdirectory(QML)
Empty file added qt6/QML/CMakeLists.txt
Empty file.
41 changes: 41 additions & 0 deletions qt6/QML/plastik/Button.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import QtQuick
import QtQuick.Templates as T

T.Button {
id: control

implicitwidth: implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
implicitContentWidth + leftPadding + rightPadding)
implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
implicitContentHeight + topPadding + bottomPadding)
flat: false

hoverEnabled: Qt.styleHints.useHoverEffect

padding: 4
spacing: 6

iconWidth: 16
iconHeight: 16

contentItem: IconLabel {
spacing: control.spacing
mirrored: control.mirrored
display: control.display

icon: control.icon
text: control.text
font: control.font
color: control.palette.buttonText

}

background: ButtonPanel {
implicitWidth: 80
implicitHeight: 24

control: control
visible: !control.flat || control.down || control.checked || control.highlighted || control.visualFocus
|| (enabled && control.hovered)
}
}
2 changes: 2 additions & 0 deletions qt6/QML/plastik/qmldir
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module plastik
Button 2.15 Button.qml
22 changes: 16 additions & 6 deletions qt6/QStyle/plastikstyle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
static const bool AnimateBusyProgressBar = true;
static const bool AnimateProgressBar = true;
#define QPlastique_MaskButtons
static const int ProgressBarFps = 25;
static const int ProgressBarFps = 30; // is that a good idea? might be a bit bad ...
static const int blueFrameWidth = 2; // with of line edit focus frame

#include <QApplication>
Expand Down Expand Up @@ -863,7 +863,11 @@ static void qt_plastique_drawShadedPanel(QPainter *painter, const QStyleOption *
qt_plastique_draw_gradient(painter, rect.adjusted(1, 1, -1, -1),
option->palette.button().color().darker(114),
option->palette.button().color().darker(106));
} else {
}
else if((option->state & QStyle::State_MouseOver)){ // paint a graident on hover
qt_plastique_draw_gradient(painter, rect.adjusted(1,1,-1,-1), option->palette.button().color().darker(106), option->palette.button().color().darker(98));
}
else {
qt_plastique_draw_gradient(painter, rect.adjusted(1, 1, -1, -1),
base ? option->palette.window().color().lighter(105) : gradientStartColor,
base ? option->palette.window().color().darker(102) : gradientStopColor);
Expand Down Expand Up @@ -2951,7 +2955,7 @@ void PlastikStyle::drawControl(ControlElement element, const QStyleOption *optio
#ifndef QT_NO_MENUBAR
case CE_MenuBarItem:
// Draws a menu bar item; File, Edit, Help etc..
if ((option->state & State_Selected)) {
if ((option->state & State_Selected)|| (option->state & State_MouseOver)) {
QPixmap cache;
QString pixmapName = QStyleHelper::uniqueName(QLatin1String("menubaritem"), option, option->rect.size());
if (!QPixmapCache::find(pixmapName, &cache)) {
Expand All @@ -2967,7 +2971,8 @@ void PlastikStyle::drawControl(ControlElement element, const QStyleOption *optio
qt_plastique_draw_gradient(&cachePainter, rect.adjusted(1, 1, -1, -1),
option->palette.button().color().darker(114),
option->palette.button().color().darker(106));
} else {
}
else {
qt_plastique_draw_gradient(&cachePainter, rect.adjusted(1, 1, -1, -1),
option->palette.window().color().lighter(105),
option->palette.window().color().darker(102));
Expand Down Expand Up @@ -5808,8 +5813,13 @@ bool PlastikStyle::eventFilter(QObject *watched, QEvent *event)
case QEvent::Show:
if (QProgressBar *bar = qobject_cast<QProgressBar *>(watched)) {
// Animation by timer for progress bars that have their min and
// max values the same
startProgressAnimation(reinterpret_cast<QProgressBar *>(watched));
// max values the same and if progressbars should be animated in general
if((bar->minimum() == bar->maximum() && AnimateBusyProgressBar) || AnimateProgressBar){
startProgressAnimation(reinterpret_cast<QProgressBar *>(watched));
}
else{
stopProgressAnimation(reinterpret_cast<QProgressBar *>(watched));
}
}
break;
case QEvent::Destroy:
Expand Down
3 changes: 0 additions & 3 deletions qt6/plastik.json

This file was deleted.

Loading

0 comments on commit 4b7aa9a

Please sign in to comment.