diff --git a/cuttlefish/package/contents/ui/SvgGrid.qml b/cuttlefish/package/contents/ui/SvgGrid.qml deleted file mode 100644 --- a/cuttlefish/package/contents/ui/SvgGrid.qml +++ /dev/null @@ -1,114 +0,0 @@ -/*************************************************************************** - * * - * Copyright 2014-2015 Sebastian Kügler * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU 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 General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * - * * - ***************************************************************************/ - -import QtQuick 2.2 -import QtQuick.Controls 2.5 as QQC2 -import QtQuick.Layouts 1.0 - -import org.kde.kirigami 2.8 as Kirigami - -GridView { - id: iconGrid - - focus: true - - cellWidth: iconSize + units.gridUnit - cellHeight: cellWidth + units.gridUnit - - cacheBuffer: 10000 - highlightMoveDuration: 0 - - model: iconModel.svgIcons - - highlight: Rectangle { - color: theme.highlightColor - //height: parent.height + units.gridUnit * 3 - anchors.bottomMargin: -units.gridUnit * 2 - } - - delegate: MouseArea { - id: delegateRoot - width: iconSize - height: iconSize + units.gridUnit - hoverEnabled: hoveredHighlight - - function setAsPreview() { - print("preview() " + modelData.iconName + " " + modelData.fileName); - preview.iconName = modelData.iconName - - } - - Rectangle { - color: theme.highlightColor - opacity: iconGrid.currentIndex == index ? 1.0 : 0 - Behavior on opacity { NumberAnimation { duration: units.shortDuration } } - anchors { - bottomMargin: -units.gridUnit - leftMargin: -units.gridUnit / 2 - rightMargin: -units.gridUnit / 2 - fill: parent - } - } - - Kirigami.Icon { - id: delegateIcon - width: iconSize - height: width - source: modelData.iconName - anchors { - top: parent.top - horizontalCenter: parent.horizontalCenter - } - } - - QQC2.Label { - font.pointSize: iconSize > 96 ? theme.defaultFont.pointSize : theme.smallestFont.pointSize - text: modelData.fileName + " " + modelData.iconName - wrapMode: QQC2.Text.Wrap - maximumLineCount: 3 - horizontalAlignment: QQC2.Text.AlignHCenter - opacity: iconGrid.currentIndex == index ? 1.0 : 0.7 - anchors { - left: parent.left - right: parent.right - top: delegateIcon.bottom - margins: Math.round(-units.gridUnit / 4) - } - } - - Connections { - target: iconGrid - onCurrentIndexChanged: { - if (delegateRoot.GridView.isCurrentItem) { - print("index changed" + modelData.iconName + " " + modelData.fileName) - delegateRoot.setAsPreview(); - } - } - } - onClicked: { - iconGrid.currentIndex = index; - iconGrid.forceActiveFocus(); - } - onEntered: { - setAsPreview(); - } - } -} diff --git a/cuttlefish/package/contents/ui/cuttlefish.qml b/cuttlefish/package/contents/ui/cuttlefish.qml --- a/cuttlefish/package/contents/ui/cuttlefish.qml +++ b/cuttlefish/package/contents/ui/cuttlefish.qml @@ -130,11 +130,6 @@ id: iconGrid anchors.fill: parent anchors.margins: Kirigami.Units.gridUnit - - footer: SvgGrid { - id: svgGrid - interactive: false - } } } Preview { diff --git a/cuttlefish/src/iconmodel.h b/cuttlefish/src/iconmodel.h --- a/cuttlefish/src/iconmodel.h +++ b/cuttlefish/src/iconmodel.h @@ -40,11 +40,7 @@ Q_PROPERTY(QString filter READ filter WRITE setFilter NOTIFY filterChanged) Q_PROPERTY(QString category READ category WRITE setCategory NOTIFY categoryChanged) - Q_PROPERTY(QString theme READ theme WRITE setTheme NOTIFY themeChanged) - Q_PROPERTY(QStringList themes READ themes CONSTANT) - Q_PROPERTY(QStringList plasmathemes READ plasmathemes CONSTANT) Q_PROPERTY(QStringList categories READ categories NOTIFY categoriesChanged) - Q_PROPERTY(QString plasmaTheme READ plasmaTheme WRITE setPlasmaTheme NOTIFY plasmaThemeChanged) Q_PROPERTY(bool loading READ loading NOTIFY loadingChanged); public: @@ -72,29 +68,19 @@ bool matchIcons(const QFileInfo &info); void add(const QFileInfo &info, const QString &cat); - void addSvgIcon(const QString &file, const QString &icon); void remove(const QString &iconFile); void setCategory(const QString &cat); QString category() const; void setFilter(const QString &filter); QString filter() const; - void setTheme(const QString &theme); - QString theme() const; - QStringList themes() const; - - void setPlasmaTheme(const QString &ptheme); - QString plasmaTheme() const; - QStringList plasmathemes() const; QStringList categories() const; QAbstractItemModel* colorschemes() const; bool loading(); - void svgIcons(); - void load(); Q_INVOKABLE void output(const QString &text); @@ -105,25 +91,17 @@ void filterChanged(); void categoryChanged(); void categoriesChanged(); - void themeChanged(); - void svgIconsChanged(); - void plasmaThemeChanged(); void loadingChanged(); private: QHash m_roleNames; QStringList m_icons; QString m_category; QStringList m_categories; - QString m_theme; QString m_filter; - QStringList m_themes; - QStringList m_plasmathemes; - QString m_plasmatheme; QHash m_data; QHash m_categoryTranslations; - QVariantMap m_svgIcons; bool m_loading; QString categoryFromPath(const QString &path); diff --git a/cuttlefish/src/iconmodel.cpp b/cuttlefish/src/iconmodel.cpp --- a/cuttlefish/src/iconmodel.cpp +++ b/cuttlefish/src/iconmodel.cpp @@ -39,8 +39,6 @@ #include #include -#include - #include #include #include @@ -50,8 +48,7 @@ static QTextStream cout(stdout); IconModel::IconModel(QObject *parent) : - QAbstractListModel(parent), - m_theme(QStringLiteral("breeze")) + QAbstractListModel(parent) , m_loading(false) { m_roleNames.insert(FileName, "fileName"); @@ -65,18 +62,6 @@ m_roleNames.insert(Type, "type"); connect(this, &IconModel::categoryChanged, this, &IconModel::load); - KConfigGroup cg(KSharedConfig::openConfig("cuttlefishrc"), "CuttleFish"); - const QString themeName = cg.readEntry("theme", "default"); - - Plasma::Theme theme; -// qDebug() << "Setting Plasma theme" << themeName; - theme.setUseGlobalSettings(false); - theme.setThemeName(themeName); // needs to happen after setUseGlobalSettings, since that clears themeName - - QList themepackages = KPackage::PackageLoader::self()->listPackages(QString(), "plasma/desktoptheme"); - foreach (const KPluginMetaData &pkg, themepackages) { - m_plasmathemes << pkg.pluginId(); - } m_categories = QStringList() << "all" \ << "actions" @@ -215,7 +200,6 @@ m_filter = filter; load(); emit filterChanged(); - emit svgIconsChanged(); } } @@ -254,7 +238,6 @@ } foreach (const QString &iconPath, searchPaths) { - QDirIterator cats(iconPath, nameFilters, QDir::Dirs, QDirIterator::NoIteratorFlags); while (cats.hasNext()) { cats.next(); @@ -273,12 +256,10 @@ } } - svgIcons(); - sort(); endResetModel(); - + m_loading = false; emit loadingChanged(); } @@ -308,79 +289,6 @@ return ok; } - -QStringList IconModel::themes() const -{ - return m_themes; -} - -QString IconModel::theme() const -{ - return m_theme; -} - -void IconModel::setTheme(const QString& theme) -{ - if (theme != m_theme) { - m_theme = theme; - load(); - emit themeChanged(); - } -} - -QString IconModel::plasmaTheme() const -{ - return m_plasmatheme; -} - -void IconModel::setPlasmaTheme(const QString& ptheme) -{ - if (m_plasmatheme != ptheme) { - m_plasmatheme = ptheme; - Plasma::Theme theme; - theme.setThemeName(ptheme); - load(); - emit plasmaThemeChanged(); - } -} - -QStringList IconModel::plasmathemes() const -{ - return m_plasmathemes; -} - -void IconModel::svgIcons() -{ - QVariantList out; - - foreach (const QString &file, m_svgIcons.keys()) { - foreach (const QString &icon, m_svgIcons[file].toStringList()) { - if (m_filter.isEmpty() || - (file.indexOf(m_filter) != -1 || icon.indexOf(m_filter) != -1)) { - - QVariantMap &data = m_data[icon]; - if (!m_icons.contains(icon)) { - - data["fullPath"] = ""; - data["iconName"] = icon; - data["fileName"] = file; - data["category"] = "system"; - data["type"] = QStringLiteral("svg"); - data["scalable"] = true; - data["iconTheme"] = m_plasmatheme; - - m_icons << icon; - } - QVariantMap vm; - vm["fileName"] = file; - vm["iconName"] = icon; - out << vm; - } - } - } - sort(); -} - QString IconModel::categoryFromPath(const QString& path) { QStringList cats;