forked from qt-creator/qt-creator
QmlDesigner: Modify the style of slider for panelwidgets
Task-number: QDS-9134 Change-Id: Ie1a6ab94a546247e0cdd35798fc8085be005d13c Reviewed-by: Henning Gründl <henning.gruendl@qt.io>
This commit is contained in:
@@ -425,7 +425,7 @@ PaletteWindowTextDisabled=textDisabled
|
|||||||
PaletteBaseDisabled=backgroundColorDisabled
|
PaletteBaseDisabled=backgroundColorDisabled
|
||||||
PaletteTextDisabled=textDisabled
|
PaletteTextDisabled=textDisabled
|
||||||
PaletteMid=ffa0a0a0
|
PaletteMid=ffa0a0a0
|
||||||
PalettePlaceholderText=ff8d8d8d
|
PalettePlaceholderText=slateGrey
|
||||||
|
|
||||||
QmlDesigner_BackgroundColor=qmlDesignerButtonColor
|
QmlDesigner_BackgroundColor=qmlDesignerButtonColor
|
||||||
QmlDesigner_HighlightColor=ff46a2da
|
QmlDesigner_HighlightColor=ff46a2da
|
||||||
|
@@ -89,11 +89,6 @@ bool panelWidget(const QWidget *widget)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool isDSSlider(const QWidget *widget)
|
|
||||||
{
|
|
||||||
return (widget && widget->property("DSSlider").toBool());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Consider making this a QStyle state
|
// Consider making this a QStyle state
|
||||||
static bool isQmlEditorMenu(const QWidget *widget)
|
static bool isQmlEditorMenu(const QWidget *widget)
|
||||||
{
|
{
|
||||||
@@ -496,7 +491,7 @@ QRect ManhattanStyle::subControlRect(ComplexControl control, const QStyleOptionC
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
QRect retval = QProxyStyle::subControlRect(control, option, subControl, widget);;
|
QRect retval = QProxyStyle::subControlRect(control, option, subControl, widget);;
|
||||||
if (isDSSlider(widget)) {
|
if (panelWidget(widget)) {
|
||||||
if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(option)) {
|
if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(option)) {
|
||||||
switch (subControl) {
|
switch (subControl) {
|
||||||
case SubControl::SC_SliderGroove:
|
case SubControl::SC_SliderGroove:
|
||||||
@@ -1649,7 +1644,7 @@ void ManhattanStyle::drawComplexControl(ComplexControl control, const QStyleOpti
|
|||||||
QPainter *painter, const QWidget *widget) const
|
QPainter *painter, const QWidget *widget) const
|
||||||
{
|
{
|
||||||
if (!panelWidget(widget))
|
if (!panelWidget(widget))
|
||||||
return QProxyStyle::drawComplexControl(control, option, painter, widget);
|
return QProxyStyle::drawComplexControl(control, option, painter, widget);
|
||||||
|
|
||||||
QRect rect = option->rect;
|
QRect rect = option->rect;
|
||||||
switch (control) {
|
switch (control) {
|
||||||
@@ -1792,11 +1787,6 @@ void ManhattanStyle::drawComplexControl(ComplexControl control, const QStyleOpti
|
|||||||
break;
|
break;
|
||||||
case CC_Slider:
|
case CC_Slider:
|
||||||
if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(option)) {
|
if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(option)) {
|
||||||
if (!isDSSlider(widget)) {
|
|
||||||
QProxyStyle::drawComplexControl(control, option, painter, widget);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
QRect groove = proxy()->subControlRect(CC_Slider, option, SC_SliderGroove, widget);
|
QRect groove = proxy()->subControlRect(CC_Slider, option, SC_SliderGroove, widget);
|
||||||
QRect handle = proxy()->subControlRect(CC_Slider, option, SC_SliderHandle, widget);
|
QRect handle = proxy()->subControlRect(CC_Slider, option, SC_SliderHandle, widget);
|
||||||
|
|
||||||
@@ -1804,26 +1794,40 @@ void ManhattanStyle::drawComplexControl(ComplexControl control, const QStyleOpti
|
|||||||
bool ticksAbove = slider->tickPosition & QSlider::TicksAbove;
|
bool ticksAbove = slider->tickPosition & QSlider::TicksAbove;
|
||||||
bool ticksBelow = slider->tickPosition & QSlider::TicksBelow;
|
bool ticksBelow = slider->tickPosition & QSlider::TicksBelow;
|
||||||
bool enabled = option->state & QStyle::State_Enabled;
|
bool enabled = option->state & QStyle::State_Enabled;
|
||||||
|
bool grooveHover = slider->activeSubControls & SC_SliderGroove;
|
||||||
|
bool handleHover = slider->activeSubControls & SC_SliderHandle;
|
||||||
|
bool interaction = option->state & State_Sunken;
|
||||||
bool activeFocus = option->state & State_HasFocus && option->state & State_KeyboardFocusChange;
|
bool activeFocus = option->state & State_HasFocus && option->state & State_KeyboardFocusChange;
|
||||||
|
|
||||||
int sliderPaintingOffset = horizontal
|
int sliderPaintingOffset = horizontal
|
||||||
? handle.center().x()
|
? handle.center().x()
|
||||||
: handle.center().y();
|
: handle.center().y();
|
||||||
|
|
||||||
|
int borderRadius = 4;
|
||||||
|
|
||||||
painter->save();
|
painter->save();
|
||||||
painter->setRenderHint(QPainter::RenderHint::Antialiasing);
|
painter->setRenderHint(QPainter::RenderHint::Antialiasing);
|
||||||
|
|
||||||
int lineWidth = pixelMetric(QStyle::PM_DefaultFrameWidth, option, widget);
|
int lineWidth = pixelMetric(QStyle::PM_DefaultFrameWidth, option, widget);
|
||||||
Theme::Color themeframeColor = enabled
|
Theme::Color themeframeColor = enabled
|
||||||
? activeFocus
|
? interaction
|
||||||
? Theme::DSstateBackgroundColor_hover
|
? Theme::DSstateControlBackgroundColor_hover // Pressed
|
||||||
: Theme::DSBackgroundColorAlternate
|
: grooveHover
|
||||||
: Theme::DScontrolBackgroundDisabled;
|
? Theme::DSstateSeparatorColor // GrooveHover
|
||||||
|
: Theme::DSpopupBackground // Idle
|
||||||
|
: Theme::DSpopupBackground; // Disabled
|
||||||
|
|
||||||
QColor frameColor = creatorTheme()->color(themeframeColor);
|
QColor frameColor = creatorTheme()->color(themeframeColor);
|
||||||
|
|
||||||
if ((option->subControls & SC_SliderGroove) && groove.isValid()) {
|
if ((option->subControls & SC_SliderGroove) && groove.isValid()) {
|
||||||
Theme::Color bgPlusColor = enabled ? Theme::DSBackgroundColorAlternate : Theme::DScontrolOutlineDisabled;
|
Theme::Color bgPlusColor = enabled
|
||||||
Theme::Color bgMinusColor = enabled ? Theme::DScontrolBackground : Theme::DScontrolOutlineDisabled;
|
? interaction
|
||||||
|
? Theme::DSstateControlBackgroundColor_hover // Pressed
|
||||||
|
: grooveHover
|
||||||
|
? Theme::DSstateSeparatorColor // GrooveHover
|
||||||
|
: Theme::DStoolbarBackground // Idle
|
||||||
|
: Theme::DStoolbarBackground; // Disabled
|
||||||
|
Theme::Color bgMinusColor = Theme::DSpopupBackground;
|
||||||
|
|
||||||
QRect minusRect(groove);
|
QRect minusRect(groove);
|
||||||
QRect plusRect(groove);
|
QRect plusRect(groove);
|
||||||
@@ -1846,9 +1850,13 @@ void ManhattanStyle::drawComplexControl(ComplexControl control, const QStyleOpti
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
painter->save();
|
||||||
painter->setPen(Qt::NoPen);
|
painter->setPen(Qt::NoPen);
|
||||||
painter->fillRect(plusRect, creatorTheme()->color(bgPlusColor));
|
painter->setBrush(creatorTheme()->color(bgPlusColor));
|
||||||
painter->fillRect(minusRect, creatorTheme()->color(bgMinusColor));
|
painter->drawRoundedRect(plusRect, borderRadius, borderRadius);
|
||||||
|
painter->setBrush(creatorTheme()->color(bgMinusColor));
|
||||||
|
painter->drawRoundedRect(minusRect, borderRadius, borderRadius);
|
||||||
|
painter->restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (option->subControls & SC_SliderTickmarks) {
|
if (option->subControls & SC_SliderTickmarks) {
|
||||||
@@ -1916,17 +1924,18 @@ void ManhattanStyle::drawComplexControl(ComplexControl control, const QStyleOpti
|
|||||||
// draw handle
|
// draw handle
|
||||||
if ((option->subControls & SC_SliderHandle) ) {
|
if ((option->subControls & SC_SliderHandle) ) {
|
||||||
Theme::Color handleColor = enabled
|
Theme::Color handleColor = enabled
|
||||||
? slider->state & QStyle::State_Editing
|
? interaction
|
||||||
? Theme::DSsliderHandleInteraction
|
? Theme::DSinteraction // Interaction
|
||||||
: slider->activeSubControls & SC_SliderHandle
|
: grooveHover || handleHover
|
||||||
? Theme::DSsliderHandleHover
|
? Theme::DStabActiveText // Hover
|
||||||
: Theme::DSsliderHandle
|
: Theme::PalettePlaceholderText // Idle
|
||||||
: Theme::DSiconColorDisabled;
|
: Theme::DStoolbarIcon_blocked; // Disabled
|
||||||
|
|
||||||
int halfSliderThickness = horizontal
|
int halfSliderThickness = horizontal
|
||||||
? handle.width() / 2
|
? handle.width() / 2
|
||||||
: handle.height() / 2;
|
: handle.height() / 2;
|
||||||
painter->setBrush(creatorTheme()->color(handleColor));
|
painter->setBrush(creatorTheme()->color(handleColor));
|
||||||
|
painter->setPen(Qt::NoPen);
|
||||||
painter->drawRoundedRect(handle,
|
painter->drawRoundedRect(handle,
|
||||||
halfSliderThickness,
|
halfSliderThickness,
|
||||||
halfSliderThickness);
|
halfSliderThickness);
|
||||||
@@ -1935,7 +1944,7 @@ void ManhattanStyle::drawComplexControl(ComplexControl control, const QStyleOpti
|
|||||||
if (groove.isValid()) {
|
if (groove.isValid()) {
|
||||||
painter->setBrush(Qt::NoBrush);
|
painter->setBrush(Qt::NoBrush);
|
||||||
painter->setPen(QPen(frameColor, lineWidth));
|
painter->setPen(QPen(frameColor, lineWidth));
|
||||||
painter->drawRect(groove);
|
painter->drawRoundedRect(groove, borderRadius, borderRadius);
|
||||||
}
|
}
|
||||||
painter->restore();
|
painter->restore();
|
||||||
}
|
}
|
||||||
|
@@ -152,7 +152,6 @@ CurveEditorToolBar::CurveEditorToolBar(CurveEditorModel *model, QWidget* parent)
|
|||||||
|
|
||||||
m_zoomSlider = new QSlider(Qt::Horizontal);
|
m_zoomSlider = new QSlider(Qt::Horizontal);
|
||||||
m_zoomSlider->setRange(0, 100);
|
m_zoomSlider->setRange(0, 100);
|
||||||
m_zoomSlider->setProperty("DSSlider", true);
|
|
||||||
m_zoomSlider->setProperty("panelwidget", true);
|
m_zoomSlider->setProperty("panelwidget", true);
|
||||||
m_zoomSlider->setProperty("panelwidget_singlerow", true);
|
m_zoomSlider->setProperty("panelwidget_singlerow", true);
|
||||||
m_zoomSlider->setFixedWidth(120);
|
m_zoomSlider->setFixedWidth(120);
|
||||||
|
@@ -17,7 +17,6 @@ SeekerSlider::SeekerSlider(QWidget *parent)
|
|||||||
{
|
{
|
||||||
setProperty("panelwidget", true);
|
setProperty("panelwidget", true);
|
||||||
setProperty("panelwidget_singlerow", true);
|
setProperty("panelwidget_singlerow", true);
|
||||||
setProperty("DSSlider", true);
|
|
||||||
setOrientation(Qt::Horizontal);
|
setOrientation(Qt::Horizontal);
|
||||||
setFixedWidth(120);
|
setFixedWidth(120);
|
||||||
setMaxValue(30);
|
setMaxValue(30);
|
||||||
|
@@ -429,7 +429,6 @@ void TimelineToolBar::createRightControls()
|
|||||||
|
|
||||||
m_scale = new QSlider(this);
|
m_scale = new QSlider(this);
|
||||||
m_scale->setOrientation(Qt::Horizontal);
|
m_scale->setOrientation(Qt::Horizontal);
|
||||||
m_scale->setProperty("DSSlider", true);
|
|
||||||
m_scale->setProperty("panelwidget", true);
|
m_scale->setProperty("panelwidget", true);
|
||||||
m_scale->setProperty("panelwidget_singlerow", true);
|
m_scale->setProperty("panelwidget_singlerow", true);
|
||||||
m_scale->setMaximumWidth(200);
|
m_scale->setMaximumWidth(200);
|
||||||
|
@@ -249,6 +249,8 @@ void TransitionEditorToolBar::createRightControls()
|
|||||||
addSpacing(10);
|
addSpacing(10);
|
||||||
|
|
||||||
m_scale = new QSlider(this);
|
m_scale = new QSlider(this);
|
||||||
|
m_scale->setProperty("panelwidget", true);
|
||||||
|
m_scale->setProperty("panelwidget_singlerow", true);
|
||||||
m_scale->setOrientation(Qt::Horizontal);
|
m_scale->setOrientation(Qt::Horizontal);
|
||||||
m_scale->setMaximumWidth(200);
|
m_scale->setMaximumWidth(200);
|
||||||
m_scale->setMinimumWidth(100);
|
m_scale->setMinimumWidth(100);
|
||||||
|
Reference in New Issue
Block a user