[graphics/krita/krita/5.0] libs: Make sure the chooser arrow for KisWidgetChooser is visible
Dmitry Kazakov
null at kde.org
Wed Nov 17 14:00:43 GMT 2021
Git commit 05c5c14c254686cc48423e80297e47c59afe9ad3 by Dmitry Kazakov, on behalf of Halla Rempt.
Committed on 17/11/2021 at 13:47.
Pushed by dkazakov into branch 'krita/5.0'.
Make sure the chooser arrow for KisWidgetChooser is visible
This fixes some layout issues, and places the chooser arrow before
the actual slider widget, because that way it says visible for as
long as possible.
CCMAIL:kimageshop at kde.org
M +0 -1 libs/ui/CMakeLists.txt
D +0 -74 libs/ui/forms/wdgmultipliersdoublesliderspinbox.ui
M +31 -22 libs/ui/widgets/kis_multipliers_double_slider_spinbox.cpp
M +4 -3 libs/ui/widgets/kis_multipliers_double_slider_spinbox_p.h
M +3 -6 libs/ui/widgets/kis_widget_chooser.cpp
M +0 -1 libs/widgetutils/kis_slider_spin_box.cpp
https://invent.kde.org/graphics/krita/commit/05c5c14c254686cc48423e80297e47c59afe9ad3
diff --git a/libs/ui/CMakeLists.txt b/libs/ui/CMakeLists.txt
index 0d33df3d41..f359205c1f 100644
--- a/libs/ui/CMakeLists.txt
+++ b/libs/ui/CMakeLists.txt
@@ -566,7 +566,6 @@ ki18n_wrap_ui(kritaui_LIB_SRCS
forms/wdgdlgfilelayer.ui
forms/wdgfilterselector.ui
forms/wdgfilternodecreation.ui
- forms/wdgmultipliersdoublesliderspinbox.ui
forms/wdgnodequerypatheditor.ui
forms/wdgpresetselectorstrip.ui
forms/wdgsavebrushpreset.ui
diff --git a/libs/ui/forms/wdgmultipliersdoublesliderspinbox.ui b/libs/ui/forms/wdgmultipliersdoublesliderspinbox.ui
deleted file mode 100644
index 09f5835b33..0000000000
--- a/libs/ui/forms/wdgmultipliersdoublesliderspinbox.ui
+++ /dev/null
@@ -1,74 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<ui version="4.0">
- <author>
- SPDX-FileCopyrightText: none
- SPDX-License-Identifier: GPL-3.0-or-later
- </author>
- <class>WdgMultipliersDoubleSliderSpinBox</class>
- <widget class="QWidget" name="WdgMultipliersDoubleSliderSpinBox">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>395</width>
- <height>25</height>
- </rect>
- </property>
- <layout class="QGridLayout" name="gridLayout">
- <property name="leftMargin">
- <number>0</number>
- </property>
- <property name="topMargin">
- <number>0</number>
- </property>
- <property name="rightMargin">
- <number>0</number>
- </property>
- <property name="bottomMargin">
- <number>0</number>
- </property>
- <property name="verticalSpacing">
- <number>0</number>
- </property>
- <item column="0" row="0">
- <widget class="KisDoubleSliderSpinBox" name="sliderSpinBox" native="true">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- </widget>
- </item>
- <item column="1" row="0">
- <widget class="QComboBox" name="comboBox">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Minimum" vsizetype="Minimum">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="maximumSize">
- <size>
- <width>52</width>
- <height>16777215</height>
- </size>
- </property>
- <property name="insertPolicy">
- <enum>QComboBox::InsertAlphabetically</enum>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- <customwidgets>
- <customwidget>
- <class>KisDoubleSliderSpinBox</class>
- <extends>QWidget</extends>
- <header location="global">kis_slider_spin_box.h</header>
- <container>1</container>
- </customwidget>
- </customwidgets>
- <resources/>
- <connections/>
-</ui>
\ No newline at end of file
diff --git a/libs/ui/widgets/kis_multipliers_double_slider_spinbox.cpp b/libs/ui/widgets/kis_multipliers_double_slider_spinbox.cpp
index 580f3b91d8..10e5d8c236 100644
--- a/libs/ui/widgets/kis_multipliers_double_slider_spinbox.cpp
+++ b/libs/ui/widgets/kis_multipliers_double_slider_spinbox.cpp
@@ -6,30 +6,39 @@
#include "kis_multipliers_double_slider_spinbox.h"
#include "kis_multipliers_double_slider_spinbox_p.h"
-
-#include "ui_wdgmultipliersdoublesliderspinbox.h"
-
-#include "kis_debug.h"
+#include <QHBoxLayout>
+#include <kis_debug.h>
+#include <klocalizedstring.h>
qreal KisMultipliersDoubleSliderSpinBox::Private::currentMultiplier()
{
- return form.comboBox->itemData(form.comboBox->currentIndex()).toDouble();
+ return cmbMultiplier->itemData(cmbMultiplier->currentIndex()).toDouble();
}
void KisMultipliersDoubleSliderSpinBox::Private::updateRange()
{
qreal m = currentMultiplier();
- form.sliderSpinBox->setRange(m * min, m * max, decimals);
+ slider->setRange(m * min, m * max, decimals);
}
KisMultipliersDoubleSliderSpinBox::KisMultipliersDoubleSliderSpinBox(QWidget* _parent)
: QWidget(_parent)
, d(new Private)
{
- d->form.setupUi(this);
+ QHBoxLayout *l = new QHBoxLayout(this);
+ l->setContentsMargins(0, 0, 0, 0);
+
+ d->slider = new KisDoubleSliderSpinBox(this);
+ d->slider->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
+ l->addWidget(d->slider);
+
+ d->cmbMultiplier = new QComboBox(this);
+ d->cmbMultiplier->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
+ l->addWidget(d->cmbMultiplier);
+
addMultiplier(1.0);
- connect(d->form.sliderSpinBox, SIGNAL(valueChanged(qreal)), SIGNAL(valueChanged(qreal)));
- connect(d->form.comboBox, SIGNAL(activated(int)), SLOT(updateRange()));
+ connect(d->slider, SIGNAL(valueChanged(qreal)), SIGNAL(valueChanged(qreal)));
+ connect(d->cmbMultiplier, SIGNAL(activated(int)), SLOT(updateRange()));
}
KisMultipliersDoubleSliderSpinBox::~KisMultipliersDoubleSliderSpinBox()
@@ -39,7 +48,7 @@ KisMultipliersDoubleSliderSpinBox::~KisMultipliersDoubleSliderSpinBox()
void KisMultipliersDoubleSliderSpinBox::addMultiplier(double v)
{
- d->form.comboBox->addItem(i18n("x%1", v), v);
+ d->cmbMultiplier->addItem(i18n("x%1", v), v);
}
void KisMultipliersDoubleSliderSpinBox::setRange(qreal minimum, qreal maximum, int decimals)
@@ -52,7 +61,7 @@ void KisMultipliersDoubleSliderSpinBox::setRange(qreal minimum, qreal maximum, i
qreal KisMultipliersDoubleSliderSpinBox::value()
{
- return d->form.sliderSpinBox->value();
+ return d->slider->value();
}
void KisMultipliersDoubleSliderSpinBox::setValue(qreal value)
@@ -60,48 +69,48 @@ void KisMultipliersDoubleSliderSpinBox::setValue(qreal value)
qreal m = d->currentMultiplier();
if (value < m * d->min || value > m * d->max) {
- for(int i = 0; i < d->form.comboBox->count(); ++i) {
- qreal m = d->form.comboBox->itemData(i).toDouble();
+ for(int i = 0; i < d->cmbMultiplier->count(); ++i) {
+ qreal m = d->cmbMultiplier->itemData(i).toDouble();
if (value >= m * d->min && value <= m * d->max) {
- d->form.comboBox->setCurrentIndex(i);
+ d->cmbMultiplier->setCurrentIndex(i);
d->updateRange();
break;
}
}
}
- d->form.sliderSpinBox->setValue(value);
+ d->slider->setValue(value);
}
void KisMultipliersDoubleSliderSpinBox::setExponentRatio(qreal dbl)
{
- d->form.sliderSpinBox->setExponentRatio(dbl);
+ d->slider->setExponentRatio(dbl);
}
void KisMultipliersDoubleSliderSpinBox::setPrefix(const QString& prefix)
{
- d->form.sliderSpinBox->setPrefix(prefix);
+ d->slider->setPrefix(prefix);
}
void KisMultipliersDoubleSliderSpinBox::setSuffix(const QString& suffix)
{
- d->form.sliderSpinBox->setSuffix(suffix);
+ d->slider->setSuffix(suffix);
}
void KisMultipliersDoubleSliderSpinBox::setBlockUpdateSignalOnDrag(bool block)
{
- d->form.sliderSpinBox->setBlockUpdateSignalOnDrag(block);
+ d->slider->setBlockUpdateSignalOnDrag(block);
}
void KisMultipliersDoubleSliderSpinBox::setSingleStep(qreal value)
{
- d->form.sliderSpinBox->setSingleStep(value);
+ d->slider->setSingleStep(value);
}
QSize KisMultipliersDoubleSliderSpinBox::sizeHint() const
{
- QSize sliderhint = d->form.sliderSpinBox->sizeHint();
- QSize comboboxhint = d->form.comboBox->sizeHint();
+ QSize sliderhint = d->slider->sizeHint();
+ QSize comboboxhint = d->cmbMultiplier->sizeHint();
sliderhint.setWidth(sliderhint.width() + comboboxhint.width() + 10);
sliderhint.setHeight(qMax(sliderhint.height(), comboboxhint.height()));
return sliderhint;
diff --git a/libs/ui/widgets/kis_multipliers_double_slider_spinbox_p.h b/libs/ui/widgets/kis_multipliers_double_slider_spinbox_p.h
index 69b7d3e0b1..a6591ce6aa 100644
--- a/libs/ui/widgets/kis_multipliers_double_slider_spinbox_p.h
+++ b/libs/ui/widgets/kis_multipliers_double_slider_spinbox_p.h
@@ -6,8 +6,8 @@
#ifndef kis_multipliers_double_slider_spinbox_p_h
#define kis_multipliers_double_slider_spinbox_p_h
-
-#include "ui_wdgmultipliersdoublesliderspinbox.h"
+#include <QComboBox>
+#include <kis_slider_spin_box.h>
#include "kis_debug.h"
@@ -16,7 +16,8 @@ struct KisMultipliersDoubleSliderSpinBox::Private {
/// Update the range of the slider depending on the currentMultiplier
void updateRange();
- Ui::WdgMultipliersDoubleSliderSpinBox form;
+ QComboBox *cmbMultiplier {0};
+ KisDoubleSliderSpinBox *slider{0};
qreal min, max;
int decimals;
};
diff --git a/libs/ui/widgets/kis_widget_chooser.cpp b/libs/ui/widgets/kis_widget_chooser.cpp
index ede2d30d9d..c72fa057d0 100644
--- a/libs/ui/widgets/kis_widget_chooser.cpp
+++ b/libs/ui/widgets/kis_widget_chooser.cpp
@@ -25,16 +25,14 @@ KisWidgetChooser::KisWidgetChooser(int id, QWidget* parent)
: QFrame(parent)
, m_chooserid(id)
{
-// QFrame::setFrameStyle(QFrame::StyledPanel|QFrame::Raised);
-
m_acceptIcon = KisIconUtils::loadIcon("list-add");
m_buttons = new QButtonGroup();
m_popup = new QFrame(0, Qt::Popup);
m_arrowButton = new QToolButton();
m_popup->setFrameStyle(QFrame::Panel|QFrame::Raised);
- m_arrowButton->setFixedWidth(m_arrowButton->sizeHint().height()/2);
- m_arrowButton->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum);
+ m_arrowButton->setFixedWidth(m_arrowButton->sizeHint().height());
+ m_arrowButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
m_arrowButton->setAutoRaise(true);
updateArrowIcon();
@@ -92,6 +90,7 @@ QLayout* KisWidgetChooser::createLayout()
QHBoxLayout* layout = new QHBoxLayout();
layout->setContentsMargins(0, 0, 0, 0);
layout->setSpacing(0);
+ layout->addWidget(m_arrowButton);
for(Iterator i=m_widgets.begin(); i!=m_widgets.end(); ++i) {
if(i->chosen) {
@@ -102,8 +101,6 @@ QLayout* KisWidgetChooser::createLayout()
break;
}
}
-
- layout->addWidget(m_arrowButton);
return layout;
}
diff --git a/libs/widgetutils/kis_slider_spin_box.cpp b/libs/widgetutils/kis_slider_spin_box.cpp
index 74af329c87..bc36401357 100644
--- a/libs/widgetutils/kis_slider_spin_box.cpp
+++ b/libs/widgetutils/kis_slider_spin_box.cpp
@@ -9,7 +9,6 @@
*/
#include <kis_slider_spin_box_p.h>
-
#include "kis_slider_spin_box.h"
KisSliderSpinBox::KisSliderSpinBox(QWidget * parent)
More information about the kimageshop
mailing list