diff --git a/src/kexiutils/style/KexiPropertyPaneLineEditStyle.cpp b/src/kexiutils/style/KexiPropertyPaneLineEditStyle.cpp index 96a774f01..8576acc82 100644 --- a/src/kexiutils/style/KexiPropertyPaneLineEditStyle.cpp +++ b/src/kexiutils/style/KexiPropertyPaneLineEditStyle.cpp @@ -1,200 +1,211 @@ /* This file is part of the KDE project Copyright (C) 2016 Jarosław Staniek This program is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this program; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include "KexiPropertyPaneLineEditStyle.h" +#include +#include "KexiStyle.h" #include #include #include #include #include #include #include #include #include static int MenuButton_IndicatorWidth = 20; //! A style modification for KexiPropertyPaneLineEdit to allow minimal size class KexiPropertyPaneLineEditProxyStyle : public QProxyStyle { public: explicit KexiPropertyPaneLineEditProxyStyle(QStyle *s = nullptr) : QProxyStyle(s) , m_viewFocusBrush(KColorScheme::View, KColorScheme::FocusColor) { } int pixelMetric(PixelMetric metric, const QStyleOption* option, const QWidget* widget) const Q_DECL_OVERRIDE { const QLineEdit* lineEdit = qobject_cast(widget); if (lineEdit) { switch( metric ) { // frame width case PM_DefaultFrameWidth: return 0; case PM_ComboBoxFrameWidth: return 0; default: break; } } return QProxyStyle::pixelMetric(metric, option, widget); } QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *widget) const Q_DECL_OVERRIDE { if (cc == CC_ComboBox) { if (sc == SC_ComboBoxEditField) { //qDebug() << opt->rect; QRect r(opt->rect); r.adjust(1, 0, -MenuButton_IndicatorWidth, 0); return visualRect(opt->direction, opt->rect, r); } } return QProxyStyle::subControlRect(cc, opt, sc, widget); } QSize sizeFromContents(ContentsType type, const QStyleOption *option, const QSize &size, const QWidget *widget) const Q_DECL_OVERRIDE { if (type == CT_ComboBox) { return size; } else if (type == CT_LineEdit) { return size - QSize(MenuButton_IndicatorWidth, 0); } return QProxyStyle::sizeFromContents(type, option, size, widget); } void drawPrimitive(PrimitiveElement element, const QStyleOption* option, QPainter* painter, const QWidget* widget ) const Q_DECL_OVERRIDE { switch (element) { case PE_FrameLineEdit: { //qDebug() << "**" << option->rect; return; } case PE_PanelLineEdit: { const bool enabled(option->state & State_Enabled); const bool hasFocus(enabled && (option->state & State_HasFocus)); const QComboBox* combo = qobject_cast(widget->parentWidget()); const bool popupVisible = combo && combo->view()->isVisible(); if (hasFocus || popupVisible) { //normal: QColor outline(KColorUtils::mix(option->palette.color(QPalette::Window), // option->palette.color( QPalette::WindowText ), 0.25)); const QColor outline = m_viewFocusBrush.brush(option->palette).color(); const QColor background(option->palette.color(QPalette::Base)); QRectF frameRect(option->rect); if (outline.isValid()) { painter->setPen(outline); frameRect.adjust(0.5, 0.5, -0.5, -0.5); } else { painter->setPen(Qt::NoPen); } if (combo) { frameRect.adjust(-MenuButton_IndicatorWidth - 1, 0, MenuButton_IndicatorWidth - 1, 0); } painter->setBrush(background.isValid() ? background : Qt::NoBrush); const qreal radius = 1.5; painter->setRenderHint(QPainter::Antialiasing); //painter->setClipRect(option->rect.adjusted(-MenuButton_IndicatorWidth, 0, MenuButton_IndicatorWidth, 0)); painter->drawRoundedRect(frameRect, radius, radius); return; } } default: break; } QProxyStyle::drawPrimitive(element, option, painter, widget); } void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p, const QWidget *widget) const { if (element == CE_ComboBoxLabel) { const QStyleOptionComboBox *cb = qstyleoption_cast(opt); if (cb) { QStyleOptionComboBox cbNew(*cb); cbNew.palette.setBrush(QPalette::Base, QBrush()); QProxyStyle::drawControl(element, &cbNew, p, widget); return; } //return; } QProxyStyle::drawControl(element, opt, p, widget); } void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget = nullptr) const Q_DECL_OVERRIDE { QProxyStyle::drawComplexControl(cc, option, painter, widget); const bool enabled(option->state & State_Enabled); const bool hasFocus(enabled && (option->state & State_HasFocus)); const QComboBox* combo = qobject_cast(widget); const bool popupVisible = combo && combo->view()->isVisible(); if (cc == CC_ComboBox && (hasFocus || popupVisible)) { const qreal radius = 1.5; QRectF frameRect(option->rect); const QColor outline = m_viewFocusBrush.brush(option->palette).color(); if (outline.isValid()) { painter->setPen(outline); frameRect.adjust(0.5, 0.5, -0.5, -0.5); } else { painter->setPen(Qt::NoPen); } painter->setBrush(Qt::NoBrush); //qDebug() << frameRect << "frameRect"; painter->drawRoundedRect(frameRect, radius, radius); } } + QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *option = nullptr, + const QWidget *widget = nullptr) const Q_DECL_OVERRIDE + { + if (standardIcon == SP_LineEditClearButton) { + return koDarkIcon("edit-clear-small"); + } + return QProxyStyle::standardIcon(standardIcon, option, widget); + } + private: KStatefulBrush m_viewFocusBrush; }; class Filter : public QObject { public: Filter(QObject *parent) : QObject(parent) { parent->installEventFilter(this); } bool eventFilter(QObject *watched, QEvent *event) Q_DECL_OVERRIDE { if (event->type() == QEvent::StyleChange) { return true; } return QObject::eventFilter(watched, event); } }; class KexiPropertyPaneLineEditProxyStyleGlobal { public: void alterStyle(QWidget *w) { KexiPropertyPaneLineEditProxyStyle *s = new KexiPropertyPaneLineEditProxyStyle(w->style()); (void)new Filter(w); w->setStyle(s); } QScopedPointer style; }; Q_GLOBAL_STATIC(KexiPropertyPaneLineEditProxyStyleGlobal, s_style); void alterPropertyPaneLineEditProxyStyle(QWidget *w) { if (w) { s_style->alterStyle(w); } } diff --git a/src/pics/icons/breeze/actions/16/edit-clear-small.svg b/src/pics/icons/breeze/actions/16/edit-clear-small.svg new file mode 100644 index 000000000..c27920981 --- /dev/null +++ b/src/pics/icons/breeze/actions/16/edit-clear-small.svg @@ -0,0 +1,96 @@ + + + + + + image/svg+xml + + + + + + + + + + + + diff --git a/src/pics/kexi_breeze_files.cmake b/src/pics/kexi_breeze_files.cmake index 9ea1cfc0f..4abc9f10e 100644 --- a/src/pics/kexi_breeze_files.cmake +++ b/src/pics/kexi_breeze_files.cmake @@ -1,138 +1,139 @@ # List of project's own icon files # This file is generated by update_kexi_breeze_list.sh # WARNING! All changes made in this file will be lost! set(_PNG_FILES calligra-logo-black-glow.png calligra-logo-white-glow.png icons/breeze/actions/16/add-field.png icons/breeze/actions/16/autofield.png icons/breeze/actions/16/database-relations.png icons/breeze/actions/16/data-view.png icons/breeze/actions/16/design-view.png icons/breeze/actions/16/form-action.png icons/breeze/actions/16/lineedit.png icons/breeze/actions/16/multiple-objects.png icons/breeze/actions/16/radiobutton.png icons/breeze/actions/16/sql-view.png icons/breeze/actions/16/textedit.png icons/breeze/actions/16/unknown-widget.png icons/breeze/actions/16/widgets.png icons/breeze/actions/22/autofield.png icons/breeze/actions/22/database-relations.png icons/breeze/actions/22/data-view.png icons/breeze/actions/22/dateedit.png icons/breeze/actions/22/datetimeedit.png icons/breeze/actions/22/design-view.png icons/breeze/actions/22/form-action.png icons/breeze/actions/22/label.png icons/breeze/actions/22/lineedit.png icons/breeze/actions/22/multiple-objects.png icons/breeze/actions/22/progressbar.png icons/breeze/actions/22/radiobutton.png icons/breeze/actions/22/slider.png icons/breeze/actions/22/spinbox.png icons/breeze/actions/22/sql-view.png icons/breeze/actions/22/textedit.png icons/breeze/actions/22/timeedit.png icons/breeze/actions/22/unknown-widget.png icons/breeze/actions/22/widgets.png icons/breeze/actions/32/data-view.png icons/breeze/actions/32/form-action.png icons/breeze/actions/32/sql-view.png kexi-autonumber.png kexi-tableview-pen.png kexi-tableview-plus.png kexi-tableview-pointer.png ) set(_SVG_OBJECT_FILES icons/breeze/actions/16/form.svg icons/breeze/actions/16/macro.svg icons/breeze/actions/16/query.svg icons/breeze/actions/16/report.svg icons/breeze/actions/16/script.svg icons/breeze/actions/16/table.svg icons/breeze/actions/22/form.svg icons/breeze/actions/22/macro.svg icons/breeze/actions/22/query.svg icons/breeze/actions/22/report.svg icons/breeze/actions/22/script.svg icons/breeze/actions/22/table.svg icons/breeze/actions/32/form.svg icons/breeze/actions/32/macro.svg icons/breeze/actions/32/query.svg icons/breeze/actions/32/report.svg icons/breeze/actions/32/script.svg icons/breeze/actions/32/table.svg ) set(_SVG_FILES icons/breeze/actions/16/button.svg icons/breeze/actions/16/checkbox.svg icons/breeze/actions/16/combobox.svg icons/breeze/actions/16/database-key.svg icons/breeze/actions/16/data-source-tag.svg +icons/breeze/actions/16/edit-clear-small.svg icons/breeze/actions/16/edit-table-clear.svg icons/breeze/actions/16/edit-table-delete-row.svg icons/breeze/actions/16/edit-table-insert-row.svg icons/breeze/actions/16/file-database.svg icons/breeze/actions/16/frame.svg icons/breeze/actions/16/groupbox.svg icons/breeze/actions/16/imagebox.svg icons/breeze/actions/16/line-horizontal.svg icons/breeze/actions/16/line-vertical.svg icons/breeze/actions/16/network-server-database.svg icons/breeze/actions/16/tabwidget-page.svg icons/breeze/actions/16/tabwidget.svg icons/breeze/actions/16/validate.svg icons/breeze/actions/22/button.svg icons/breeze/actions/22/checkbox.svg icons/breeze/actions/22/combobox.svg icons/breeze/actions/22/database-import.svg icons/breeze/actions/22/database-key.svg icons/breeze/actions/22/data-source-tag.svg icons/breeze/actions/22/document-empty.svg icons/breeze/actions/22/edit-table-clear.svg icons/breeze/actions/22/edit-table-delete-row.svg icons/breeze/actions/22/edit-table-insert-row.svg icons/breeze/actions/22/file-database.svg icons/breeze/actions/22/frame.svg icons/breeze/actions/22/groupbox.svg icons/breeze/actions/22/imagebox.svg icons/breeze/actions/22/line-horizontal.svg icons/breeze/actions/22/line-vertical.svg icons/breeze/actions/22/network-server-database.svg icons/breeze/actions/22/tabwidget-page.svg icons/breeze/actions/22/tabwidget.svg icons/breeze/actions/22/validate.svg icons/breeze/actions/32/button.svg icons/breeze/actions/32/checkbox.svg icons/breeze/actions/32/combobox.svg icons/breeze/actions/32/database-key.svg icons/breeze/actions/32/data-source-tag.svg icons/breeze/actions/32/document-empty.svg icons/breeze/actions/32/edit-table-clear.svg icons/breeze/actions/32/edit-table-delete-row.svg icons/breeze/actions/32/edit-table-insert-row.svg icons/breeze/actions/32/file-database.svg icons/breeze/actions/32/frame.svg icons/breeze/actions/32/groupbox.svg icons/breeze/actions/32/imagebox.svg icons/breeze/actions/32/line-horizontal.svg icons/breeze/actions/32/line-vertical.svg icons/breeze/actions/32/mode-selector-design.svg icons/breeze/actions/32/mode-selector-edit.svg icons/breeze/actions/32/mode-selector-help.svg icons/breeze/actions/32/mode-selector-project.svg icons/breeze/actions/32/mode-selector-welcome.svg icons/breeze/actions/32/network-server-database.svg icons/breeze/actions/32/tabwidget-page.svg icons/breeze/actions/32/tabwidget.svg icons/breeze/actions/32/validate.svg icons/breeze/apps/16/kexi.svg icons/breeze/apps/32/kexi.svg icons/breeze/apps/48/kexi.svg ) set(_FILES ${_PNG_FILES} ${_SVG_OBJECT_FILES} ${_SVG_FILES})