Commit 47cc24d8 authored by Boudewijn Rempt's avatar Boudewijn Rempt

Move the squeezedcombobox to widgetutils

And rename it to KisSqueezedComboBox.

WidgetUtils should contain all widgets that don't depend on any
of the pigment or flake or resource related parts of Krita.
parent b047a467
......@@ -46,7 +46,7 @@
#include <kis_image_config.h>
#include "widgets/kis_cmb_idlist.h"
#include <squeezedcombobox.h>
#include <KisSqueezedComboBox.h>
#include "kis_layer_utils.h"
......
......@@ -25,7 +25,7 @@
#include <KoColorSpaceRegistry.h>
#include <KoColorSpaceEngine.h>
#include <KoID.h>
#include <squeezedcombobox.h>
#include <KisSqueezedComboBox.h>
#include "kis_config.h"
KisDlgPngImport::KisDlgPngImport(const QString &path, const QString &colorModelID, const QString &colorDepthID, QWidget *parent)
......
......@@ -64,7 +64,7 @@
#include <KoResourcePaths.h>
#include "kis_action_registry.h"
#include <kis_image.h>
#include <squeezedcombobox.h>
#include <KisSqueezedComboBox.h>
#include "kis_clipboard.h"
#include "widgets/kis_cmb_idlist.h"
#include "KoColorSpace.h"
......@@ -514,7 +514,7 @@ ColorSettingsTab::ColorSettingsTab(QWidget *parent, const char *name)
for(int i = 0; i < QApplication::desktop()->screenCount(); ++i) {
QLabel *lbl = new QLabel(i18nc("The number of the screen", "Screen %1:", i + 1));
m_monitorProfileLabels << lbl;
SqueezedComboBox *cmb = new SqueezedComboBox();
KisSqueezedComboBox *cmb = new KisSqueezedComboBox();
cmb->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
monitorProfileGrid->addRow(lbl, cmb);
m_monitorProfileWidgets << cmb;
......
......@@ -31,7 +31,7 @@
#include <kis_config.h>
#include "kis_global.h"
#include <squeezedcombobox.h>
#include <KisSqueezedComboBox.h>
#include "ui_wdggeneralsettings.h"
#include "ui_wdgdisplaysettings.h"
......@@ -174,7 +174,7 @@ public:
WdgColorSettings *m_page;
QButtonGroup m_pasteBehaviourGroup;
QList<QLabel*> m_monitorProfileLabels;
QList<SqueezedComboBox*> m_monitorProfileWidgets;
QList<KisSqueezedComboBox*> m_monitorProfileWidgets;
};
//=======================
......
......@@ -43,7 +43,7 @@
#include "kis_config.h"
#include "kis_signal_compressor.h"
#include "widgets/kis_cmb_idlist.h"
#include <squeezedcombobox.h>
#include <KisSqueezedComboBox.h>
#include "kis_layer_utils.h"
#include <kis_ls_utils.h>
#include "kis_canvas_resource_provider.h"
......
......@@ -64,7 +64,7 @@
</widget>
</item>
<item>
<widget class="SqueezedComboBox" name="cmbProfile">
<widget class="KisSqueezedComboBox" name="cmbProfile">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
......@@ -137,9 +137,9 @@
</widget>
<customwidgets>
<customwidget>
<class>SqueezedComboBox</class>
<class>KisSqueezedComboBox</class>
<extends>QComboBox</extends>
<header>squeezedcombobox.h</header>
<header>KisSqueezedComboBox.h</header>
</customwidget>
</customwidgets>
<tabstops>
......
......@@ -75,7 +75,7 @@
</widget>
</item>
<item>
<widget class="SqueezedComboBox" name="cmbProfile">
<widget class="KisSqueezedComboBox" name="cmbProfile">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
......@@ -109,9 +109,9 @@
<header>widgets/kis_cmb_idlist.h</header>
</customwidget>
<customwidget>
<class>SqueezedComboBox</class>
<class>KisSqueezedComboBox</class>
<extends>QComboBox</extends>
<header>squeezedcombobox.h</header>
<header>KisSqueezedComboBox.h</header>
</customwidget>
</customwidgets>
<resources/>
......
......@@ -22,7 +22,7 @@
</widget>
</item>
<item row="1" column="1">
<widget class="SqueezedComboBox" name="cmbProfile">
<widget class="KisSqueezedComboBox" name="cmbProfile">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
......@@ -61,9 +61,9 @@
</widget>
<customwidgets>
<customwidget>
<class>SqueezedComboBox</class>
<class>KisSqueezedComboBox</class>
<extends>QComboBox</extends>
<header>squeezedcombobox.h</header>
<header>KisSqueezedComboBox.h</header>
</customwidget>
</customwidgets>
<resources/>
......
......@@ -57,7 +57,7 @@ KoID KisCompositeOpListWidget::selectedCompositeOp() const {
// ---- KisCompositeOpComboBox -------------------------------------------------------- //
KisCompositeOpComboBox::KisCompositeOpComboBox(QWidget* parent):
SqueezedComboBox(parent),
KisSqueezedComboBox(parent),
m_model(new KisSortedCompositeOpListModel(this)),
m_allowToHidePopup(true)
{
......
......@@ -23,7 +23,7 @@
#define KIS_COMPOSITEOP_WIDGETS_H_
#include <QComboBox>
#include <squeezedcombobox.h>
#include <KisSqueezedComboBox.h>
#include <kritaui_export.h>
#include "kis_categorized_list_view.h"
......@@ -45,7 +45,7 @@ private:
};
class KRITAUI_EXPORT KisCompositeOpComboBox: public SqueezedComboBox
class KRITAUI_EXPORT KisCompositeOpComboBox: public KisSqueezedComboBox
{
Q_OBJECT
public:
......
......@@ -61,7 +61,7 @@
#include "kis_clipboard.h"
#include "KisDocument.h"
#include "widgets/kis_cmb_idlist.h"
#include <squeezedcombobox.h>
#include <KisSqueezedComboBox.h>
KisCustomImageWidget::KisCustomImageWidget(QWidget* parent, qint32 defWidth, qint32 defHeight, double resolution, const QString& defColorModel, const QString& defColorDepth, const QString& defColorProfile, const QString& imageName)
......
......@@ -52,7 +52,7 @@
#include "kis_clipboard.h"
#include "KisDocument.h"
#include "widgets/kis_cmb_idlist.h"
#include <squeezedcombobox.h>
#include <KisSqueezedComboBox.h>
KisImageFromClipboard::KisImageFromClipboard(QWidget* parent, qint32 defWidth, qint32 defHeight, double resolution, const QString& defColorModel, const QString& defColorDepth, const QString& defColorProfile, const QString& imageName)
......
......@@ -76,8 +76,6 @@ set(kritawidgets_LIB_SRCS
KisColorSelectorInterface.cpp
KoAnchorSelectionWidget.cpp
squeezedcombobox.cpp
KisGradientSlider.cpp
KisGradientSliderWidget.cpp
......
......@@ -45,7 +45,7 @@
#include "kis_config_notifier.h"
#include "kis_color_input.h"
#include "kis_icon_utils.h"
#include "squeezedcombobox.h"
#include "KisSqueezedComboBox.h"
std::function<KisScreenColorPickerBase *(QWidget *)> KisDlgInternalColorSelector::s_screenColorPickerFactory = 0;
......
......@@ -29,7 +29,7 @@
#include "KisPaletteComboBox.h"
KisPaletteComboBox::KisPaletteComboBox(QWidget *parent)
: SqueezedComboBox(parent)
: KisSqueezedComboBox(parent)
, m_model(Q_NULLPTR)
{
setEditable(true);
......
......@@ -27,7 +27,7 @@
#include <QPixmap>
#include <QPair>
#include <QHash>
#include <squeezedcombobox.h>
#include <KisSqueezedComboBox.h>
#include <KisPaletteModel.h>
class KisPaletteView;
......@@ -37,7 +37,7 @@ class KisPaletteView;
* A combobox used with KisPaletteView
*
*/
class KRITAWIDGETS_EXPORT KisPaletteComboBox : public SqueezedComboBox
class KRITAWIDGETS_EXPORT KisPaletteComboBox : public KisSqueezedComboBox
{
Q_OBJECT
private /* typedef */:
......
......@@ -30,7 +30,7 @@
#include <QGridLayout>
#include <klocalizedstring.h>
#include <squeezedcombobox.h>
#include <KisSqueezedComboBox.h>
#include <KoIcon.h>
......@@ -41,7 +41,7 @@
class Q_DECL_HIDDEN KoTagChooserWidget::Private
{
public:
SqueezedComboBox* comboBox;
KisSqueezedComboBox* comboBox;
KoTagToolButton* tagToolButton;
QStringList readOnlyTags;
QStringList tags;
......@@ -50,7 +50,7 @@ public:
KoTagChooserWidget::KoTagChooserWidget(QWidget* parent): QWidget(parent)
, d(new Private())
{
d->comboBox = new SqueezedComboBox(this);
d->comboBox = new KisSqueezedComboBox(this);
d->comboBox->setToolTip(i18n("Tag"));
d->comboBox->setSizePolicy(QSizePolicy::MinimumExpanding , QSizePolicy::Fixed );
......
......@@ -11,7 +11,6 @@ include(KritaAddBrokenUnitTest)
ecm_add_tests(
zoomhandler_test.cpp
zoomcontroller_test.cpp
squeezedcombobox_test.cpp
KoResourceTaggingTest.cpp
kis_parse_spin_boxes_test.cpp
KoAnchorSelectionWidgetTest.cpp
......
......@@ -23,6 +23,7 @@ set(kritawidgetutils_LIB_SRCS
KoFileDialog.cpp
KoResourcePaths.cpp
KisKineticScroller.cpp
KisSqueezedComboBox.cpp
kis_num_parser.cpp
kis_spin_box_unit_manager.cpp
......
......@@ -17,8 +17,8 @@
*
* ============================================================ */
#include "squeezedcombobox.h"
/** @file squeezedcombobox.cpp */
#include "KisSqueezedComboBox.h"
/** @file KisSqueezedComboBox.cpp */
// Qt includes.
......@@ -29,7 +29,7 @@
#include <QApplication>
#include <QResizeEvent>
SqueezedComboBox::SqueezedComboBox(QWidget *parent, const char *name)
KisSqueezedComboBox::KisSqueezedComboBox(QWidget *parent, const char *name)
: QComboBox(parent)
{
setObjectName(name);
......@@ -40,12 +40,12 @@ SqueezedComboBox::SqueezedComboBox(QWidget *parent, const char *name)
SLOT(slotTimeOut()));
}
SqueezedComboBox::~SqueezedComboBox()
KisSqueezedComboBox::~KisSqueezedComboBox()
{
delete m_timer;
}
bool SqueezedComboBox::contains(const QString& _text) const
bool KisSqueezedComboBox::contains(const QString& _text) const
{
if (_text.isEmpty())
return false;
......@@ -59,7 +59,7 @@ bool SqueezedComboBox::contains(const QString& _text) const
return false;
}
qint32 SqueezedComboBox::findOriginalText(const QString& text) const
qint32 KisSqueezedComboBox::findOriginalText(const QString& text) const
{
for (int i = 0; i < m_originalItems.size(); i++) {
if(m_originalItems.value(i) == text) {
......@@ -69,12 +69,12 @@ qint32 SqueezedComboBox::findOriginalText(const QString& text) const
return -1;
}
QStringList SqueezedComboBox::originalTexts() const
QStringList KisSqueezedComboBox::originalTexts() const
{
return m_originalItems.values();
}
void SqueezedComboBox::resetOriginalTexts(const QStringList &texts)
void KisSqueezedComboBox::resetOriginalTexts(const QStringList &texts)
{
if (texts == m_originalItems.values()) return;
......@@ -86,7 +86,7 @@ void SqueezedComboBox::resetOriginalTexts(const QStringList &texts)
}
}
QSize SqueezedComboBox::sizeHint() const
QSize KisSqueezedComboBox::sizeHint() const
{
ensurePolished();
QFontMetrics fm = fontMetrics();
......@@ -101,29 +101,29 @@ QSize SqueezedComboBox::sizeHint() const
QSize(maxW, maxH), this).expandedTo(QApplication::globalStrut());
}
void SqueezedComboBox::insertSqueezedItem(const QString& newItem, int index, QVariant userData)
void KisSqueezedComboBox::insertSqueezedItem(const QString& newItem, int index, QVariant userData)
{
m_originalItems[index] = newItem;
QComboBox::insertItem(index, squeezeText(newItem, this), userData);
}
void SqueezedComboBox::insertSqueezedItem(const QIcon &icon, const QString &newItem, int index, QVariant userData)
void KisSqueezedComboBox::insertSqueezedItem(const QIcon &icon, const QString &newItem, int index, QVariant userData)
{
m_originalItems[index] = newItem;
QComboBox::insertItem(index, icon, squeezeText(newItem, this), userData);
}
void SqueezedComboBox::addSqueezedItem(const QString& newItem, QVariant userData)
void KisSqueezedComboBox::addSqueezedItem(const QString& newItem, QVariant userData)
{
insertSqueezedItem(newItem, count(), userData);
}
void SqueezedComboBox::addSqueezedItem(const QIcon &icon, const QString &newItem, QVariant userData)
void KisSqueezedComboBox::addSqueezedItem(const QIcon &icon, const QString &newItem, QVariant userData)
{
insertSqueezedItem(icon, newItem, count(), userData);
}
void SqueezedComboBox::setCurrent(const QString& itemText)
void KisSqueezedComboBox::setCurrent(const QString& itemText)
{
qint32 itemIndex = findOriginalText(itemText);
if (itemIndex >= 0) {
......@@ -131,12 +131,12 @@ void SqueezedComboBox::setCurrent(const QString& itemText)
}
}
void SqueezedComboBox::resizeEvent(QResizeEvent *)
void KisSqueezedComboBox::resizeEvent(QResizeEvent *)
{
m_timer->start(200);
}
void SqueezedComboBox::slotTimeOut()
void KisSqueezedComboBox::slotTimeOut()
{
for (QMap<int, QString>::iterator it = m_originalItems.begin() ; it != m_originalItems.end();
++it) {
......@@ -144,7 +144,7 @@ void SqueezedComboBox::slotTimeOut()
}
}
QString SqueezedComboBox::squeezeText(const QString& original, const QWidget *widget)
QString KisSqueezedComboBox::squeezeText(const QString& original, const QWidget *widget)
{
// not the complete widgetSize is usable. Need to compensate for that.
int widgetSize = widget->width() - 30;
......@@ -166,13 +166,13 @@ QString SqueezedComboBox::squeezeText(const QString& original, const QWidget *wi
return sqItem;
}
QString SqueezedComboBox::itemHighlighted()
QString KisSqueezedComboBox::itemHighlighted()
{
int curItem = currentIndex();
return m_originalItems[curItem];
}
void SqueezedComboBox::removeSqueezedItem(int index)
void KisSqueezedComboBox::removeSqueezedItem(int index)
{
removeItem(index);
m_originalItems.remove(index);
......
......@@ -17,10 +17,8 @@
*
* ============================================================ */
/** @file squeezedcombobox.h */
#ifndef SQUEEZEDCOMBOBOX_H
#define SQUEEZEDCOMBOBOX_H
#ifndef KISSQUEEZEDCOMBOBOX_H
#define KISSQUEEZEDCOMBOBOX_H
class QTimer;
class QResizeEvent;
......@@ -32,9 +30,9 @@ class QWidget;
#include <QWidget>
#include <QIcon>
#include "kritawidgets_export.h"
#include "kritawidgetutils_export.h"
/** @class SqueezedComboBox
/** @class KisSqueezedComboBox
*
* This widget is a QComboBox, but then a little bit
* different. It only shows the right part of the items
......@@ -42,10 +40,10 @@ class QWidget;
* possible to show the complete item, it will be shortened
* and "..." will be prepended.
*
* @image html squeezedcombobox.png "This is how it looks"
* @image html KisSqueezedComboBox.png "This is how it looks"
* @author Tom Albers
*/
class KRITAWIDGETS_EXPORT SqueezedComboBox : public QComboBox
class KRITAWIDGETUTILS_EXPORT KisSqueezedComboBox : public QComboBox
{
Q_OBJECT
......@@ -56,11 +54,11 @@ public:
* @param parent parent widget
* @param name name to give to the widget
*/
SqueezedComboBox(QWidget *parent = 0, const char *name = 0);
KisSqueezedComboBox(QWidget *parent = 0, const char *name = 0);
/**
* destructor
*/
~SqueezedComboBox() override;
~KisSqueezedComboBox() override;
/**
*
......
......@@ -11,7 +11,7 @@ ecm_add_tests(
KoPropertiesTest.cpp
kis_simple_math_parser_test.cpp # FIXME this test should be in the ui directory
TestKoProgressUpdater.cpp
TestSqueezedComboBox.cpp
NAME_PREFIX "libs-widgetutils-"
LINK_LIBRARIES kritawidgetutils kritaimage Qt5::Test
)
#include "squeezedcombobox_test.h"
#include "TestSqueezedComboBox.h"
#include <QTest>
#include <squeezedcombobox.h>
#include <KisSqueezedComboBox.h>
void SqueezedComboBoxTest::testContains()
void TestSqueezedComboBox::testContains()
{
SqueezedComboBox *comboBox = new SqueezedComboBox();
KisSqueezedComboBox *comboBox = new KisSqueezedComboBox();
const int comboBoxWidth = 10;
const int comboBoxHeight = 50;
......@@ -27,5 +27,5 @@ void SqueezedComboBoxTest::testContains()
QVERIFY(comboBox->contains(testItemText));
}
QTEST_MAIN(SqueezedComboBoxTest)
QTEST_MAIN(TestSqueezedComboBox)
......@@ -3,7 +3,7 @@
#include <QtTest>
class SqueezedComboBoxTest : public QObject
class TestSqueezedComboBox : public QObject
{
Q_OBJECT
......
......@@ -51,7 +51,7 @@
#include <kis_config_notifier.h>
#include <widgets/kis_double_widget.h>
#include <kis_image.h>
#include <squeezedcombobox.h>
#include <KisSqueezedComboBox.h>
#include "kis_signals_blocker.h"
#include "krita_utils.h"
......
......@@ -74,7 +74,7 @@
<number>2</number>
</property>
<item row="5" column="1">
<widget class="SqueezedComboBox" name="m_cmbView">
<widget class="KisSqueezedComboBox" name="m_cmbView">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
......@@ -110,7 +110,7 @@
</widget>
</item>
<item row="4" column="1">
<widget class="SqueezedComboBox" name="m_cmbDisplayDevice">
<widget class="KisSqueezedComboBox" name="m_cmbDisplayDevice">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
......@@ -120,7 +120,7 @@
</widget>
</item>
<item row="3" column="1">
<widget class="SqueezedComboBox" name="m_cmbInputColorSpace">
<widget class="KisSqueezedComboBox" name="m_cmbInputColorSpace">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
......@@ -241,7 +241,7 @@
</layout>
</item>
<item row="7" column="1">
<widget class="SqueezedComboBox" name="m_cmbComponents">
<widget class="KisSqueezedComboBox" name="m_cmbComponents">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
......@@ -326,7 +326,7 @@
</widget>
</item>
<item row="6" column="1">
<widget class="SqueezedComboBox" name="m_cmbLook">
<widget class="KisSqueezedComboBox" name="m_cmbLook">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
......@@ -418,9 +418,9 @@
</widget>
<customwidgets>
<customwidget>
<class>SqueezedComboBox</class>
<class>KisSqueezedComboBox</class>
<extends>QComboBox</extends>
<header>squeezedcombobox.h</header>
<header>KisSqueezedComboBox.h</header>
</customwidget>
<customwidget>
<class>KisDoubleWidget</class>
......
......@@ -33,7 +33,7 @@
#include <QFormLayout>
#include <QLineEdit>
#include <squeezedcombobox.h>
#include <KisSqueezedComboBox.h>
#include <klocalizedstring.h>
#include <KoResourceServerProvider.h>
#include <KoColorSpaceRegistry.h>
......
......@@ -26,7 +26,7 @@
#include <QMimeData>
#include <QDomDocument>
#include <QDomElement>
#include <squeezedcombobox.h>
#include <KisSqueezedComboBox.h>
#include <QWidgetAction>
#include <QMenu>
......
......@@ -14,7 +14,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="SqueezedComboBox" name="cmbCollections"/>
<widget class="KisSqueezedComboBox" name="cmbCollections"/>
</item>
<item>
<widget class="QToolButton" name="vectorPresetsConfigureButton">
......@@ -32,9 +32,9 @@
</widget>
<customwidgets>
<customwidget>
<class>SqueezedComboBox</class>
<class>KisSqueezedComboBox</class>
<extends>QComboBox</extends>
<header>squeezedcombobox.h</header>
<header>KisSqueezedComboBox.h</header>
</customwidget>
</customwidgets>
<resources/>
......
......@@ -34,7 +34,7 @@
#include "KoID.h"
#include "widgets/kis_cmb_idlist.h"
#include <squeezedcombobox.h>// TODO: add a label that would display if there isn't a good color conversion path (use KoColorConversionSystem::isGoodPath), all color spaces shipped with Calligra are expected to have a good path, but better warn the user in case
#include <KisSqueezedComboBox.h>// TODO: add a label that would display if there isn't a good color conversion path (use KoColorConversionSystem::isGoodPath), all color spaces shipped with Calligra are expected to have a good path, but better warn the user in case
DlgColorSpaceConversion::DlgColorSpaceConversion(QWidget * parent,
const char * name)
......
......@@ -219,7 +219,7 @@
</widget>
</item>
<item>
<widget class="SqueezedComboBox" name="cmbPalette"/>
<widget class="KisSqueezedComboBox" name="cmbPalette"/>
</item>
</layout>
</item>
......@@ -259,9 +259,9 @@
<header>kis_slider_spin_box.h</header>
</customwidget>
<customwidget>
<class>SqueezedComboBox</class>
<class>KisSqueezedComboBox</class>
<extends>QComboBox</extends>
<header>squeezedcombobox.h</header>
<header>KisSqueezedComboBox.h</header>
</customwidget>
<customwidget>
<class>KisIntParseSpinBox</class>
......
......@@ -21,7 +21,7 @@
#define KIS_FONT_FAMILY_COMBO_BOX_H
#include<QObject>
#include<squeezedcombobox.h>
#include<KisSqueezedComboBox.h>
#include<QList>
#include<QFont>
#include<QFontDatabase>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment