diff --git a/src/main/KexiModeSelector.cpp b/src/main/KexiModeSelector.cpp index 932435321..7352caca1 100644 --- a/src/main/KexiModeSelector.cpp +++ b/src/main/KexiModeSelector.cpp @@ -1,111 +1,146 @@ /* This file is part of the KDE project Copyright (C) 2016 Jarosław Staniek This library 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 library 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 library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include "KexiModeSelector.h" #include -#include #include #include #include KexiModeSelectorModel::KexiModeSelectorModel(QObject *parent) : QAbstractListModel(parent) { } int KexiModeSelectorModel::rowCount(const QModelIndex &parent) const { Q_UNUSED(parent); return modes.count(); } QVariant KexiModeSelectorModel::data(const QModelIndex &index, int role) const { if (!index.isValid() || index.row() >= modes.size()) return QVariant(); if (role == Qt::DisplayRole) { return modes.at(index.row()).name; } else if (role == Qt::DecorationRole) { return modes.at(index.row()).icon; } return QVariant(); } // ---- KexiModeSelectorDelegate::KexiModeSelectorDelegate(QObject *parent) : KexiListViewDelegate(parent) { } void KexiModeSelectorDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { KexiListViewDelegate::paint(painter, option, index); KexiStyle::overpaintModeSelectorItem(painter, option, index); } // ---- KexiModeSelector::KexiModeSelector(QWidget *parent) : KexiListView(DontUseDelegate, parent) { KexiStyle::setupModeSelector(this); setSpacing(0); setContentsMargins(0, 0, 0, 0); setFocusPolicy(Qt::NoFocus); setEditTriggers(NoEditTriggers); setDropIndicatorShown(false); setSelectionBehavior(SelectRows); setSelectionRectVisible(false); setUniformItemSizes(true); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); setItemDelegate(new KexiModeSelectorDelegate(this)); - KexiMode welcomeMode; - welcomeMode.name = xi18n("Welcome"); - welcomeMode.icon = qApp->windowIcon(); - model.modes << welcomeMode; - KexiMode projectMode; - projectMode.name = xi18nc("Project mode", "Project"); - projectMode.icon = koIcon("project-development"); - model.modes << projectMode; - setModel(&model); + KexiStyledIconParameters param; + param.color = palette().color(QPalette::Text); + param.selectedColor = palette().color(QPalette::HighlightedText); + { + KexiMode welcomeMode; + welcomeMode.name = xi18nc("Welcome mode", "Welcome"); + param.context = KIconLoader::Action; + param.name = "mode-selector-welcome"; + welcomeMode.icon = KexiStyle::icon(param); + m_model.modes << welcomeMode; + } + { + KexiMode projectMode; + projectMode.name = xi18nc("Project mode", "Project"); + param.context = KIconLoader::Action; + param.name = "mode-selector-project"; + projectMode.icon = KexiStyle::icon(param); + m_model.modes << projectMode; + } + { + KexiMode dataMode; + dataMode.name = xi18nc("Data mode", "Data"); + param.context = KIconLoader::Action; + param.name = "mode-selector-data"; + dataMode.icon = KexiStyle::icon(param); + m_model.modes << dataMode; + } + { + KexiMode designMode; + designMode.name = xi18nc("Design mode", "Design"); + param.context = KIconLoader::Action; + param.name = "mode-selector-design"; + designMode.icon = KexiStyle::icon(param); + m_model.modes << designMode; + } + { + KexiMode helpMode; + helpMode.name = xi18nc("Help mode", "Help"); + param.context = KIconLoader::Action; + param.name = "mode-selector-help"; + helpMode.icon = KexiStyle::icon(param); + m_model.modes << helpMode; + } + setModel(&m_model); + selectionModel()->select(model()->index(0, 0), QItemSelectionModel::Select); } KexiModeSelector::~KexiModeSelector() { } void KexiModeSelector::paintEvent(QPaintEvent *event) { KexiListView::paintEvent(event); QRect selectedRect; if (!selectedIndexes().isEmpty()) { selectedRect = visualRect(selectedIndexes().first()); } QPainter painter(viewport()); KexiStyle::overpaintModeSelector(this, &painter, selectedRect); } diff --git a/src/main/KexiModeSelector.h b/src/main/KexiModeSelector.h index f3bd0ed67..3f2b5de09 100644 --- a/src/main/KexiModeSelector.h +++ b/src/main/KexiModeSelector.h @@ -1,75 +1,75 @@ /* This file is part of the KDE project Copyright (C) 2016 Jarosław Staniek This library 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 library 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 library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef KEXIMODESELECTOR_H #define KEXIMODESELECTOR_H #include class QPainter; //! @internal A single global mode class KexiMode { public: QString name; QIcon icon; }; //! @internal A model for KexiModeSelector, each item has name and icon class KexiModeSelectorModel : public QAbstractListModel { Q_OBJECT public: explicit KexiModeSelectorModel(QObject *parent = 0); int rowCount(const QModelIndex &parent = QModelIndex()) const; QVariant data(const QModelIndex &index, int role) const; QList modes; }; //! @internal A delegate for items of KexiModeSelector class KexiModeSelectorDelegate : public KexiListViewDelegate { Q_OBJECT public: explicit KexiModeSelectorDelegate(QObject *parent = 0); void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const Q_DECL_OVERRIDE; }; //! @internal Global mode selector class KexiModeSelector : public KexiListView { public: explicit KexiModeSelector(QWidget *parent = 0); virtual ~KexiModeSelector(); - KexiModeSelectorModel model; - protected: void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE; + + KexiModeSelectorModel m_model; }; #endif // KEXIMODESELECTOR_H diff --git a/src/pics/icons/breeze/actions/32/mode-selector-data.svg b/src/pics/icons/breeze/actions/32/mode-selector-data.svg new file mode 100644 index 000000000..3cc4168ed --- /dev/null +++ b/src/pics/icons/breeze/actions/32/mode-selector-data.svg @@ -0,0 +1,160 @@ + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + diff --git a/src/pics/icons/breeze/actions/32/mode-selector-design.svg b/src/pics/icons/breeze/actions/32/mode-selector-design.svg new file mode 100644 index 000000000..a97b5a746 --- /dev/null +++ b/src/pics/icons/breeze/actions/32/mode-selector-design.svg @@ -0,0 +1,243 @@ + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/pics/icons/breeze/actions/32/mode-selector-help.svg b/src/pics/icons/breeze/actions/32/mode-selector-help.svg new file mode 100644 index 000000000..148134f00 --- /dev/null +++ b/src/pics/icons/breeze/actions/32/mode-selector-help.svg @@ -0,0 +1,141 @@ + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + diff --git a/src/pics/icons/breeze/actions/32/mode-selector-project.svg b/src/pics/icons/breeze/actions/32/mode-selector-project.svg new file mode 100644 index 000000000..914381ff2 --- /dev/null +++ b/src/pics/icons/breeze/actions/32/mode-selector-project.svg @@ -0,0 +1,132 @@ + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + diff --git a/src/pics/icons/breeze/actions/32/mode-selector-welcome.svg b/src/pics/icons/breeze/actions/32/mode-selector-welcome.svg new file mode 100644 index 000000000..0d8f960dc --- /dev/null +++ b/src/pics/icons/breeze/actions/32/mode-selector-welcome.svg @@ -0,0 +1,147 @@ + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + diff --git a/src/pics/kexi_breeze_files.cmake b/src/pics/kexi_breeze_files.cmake index 47331ac88..4eaf4dc81 100644 --- a/src/pics/kexi_breeze_files.cmake +++ b/src/pics/kexi_breeze_files.cmake @@ -1,133 +1,138 @@ # 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-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-data.svg +icons/breeze/actions/32/mode-selector-design.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})