Commit bd130c6b authored by David Redondo's avatar David Redondo 🏎

[Cuttlefish] Remove last traces of themes and plasma themes

Summary:
As far as I can tell plasma theme support was only used for a checkbox to override
icons with plasma icons from the current plasma theme. Also icons with names in
the plasma but not icon theme were shown at the bottom of the grid. This was
removed with 727fd286. Themeexplorer is probably
the right place anyways to view plasma theme icons. Different icon themes were
never supported?

Test Plan: No difference

Reviewers: #plasma, ngraham

Reviewed By: ngraham

Subscribers: ngraham, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D27136
parent 2d2e2a95
/***************************************************************************
* *
* Copyright 2014-2015 Sebastian Kügler <sebas@kde.org> *
* *
* 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();
}
}
}
......@@ -130,11 +130,6 @@ Kirigami.ApplicationWindow {
id: iconGrid
anchors.fill: parent
anchors.margins: Kirigami.Units.gridUnit
footer: SvgGrid {
id: svgGrid
interactive: false
}
}
}
Preview {
......
......@@ -39,8 +39,6 @@
#include <KSharedConfig>
#include <KPackage/PackageLoader>
#include <Plasma/Theme>
#include <algorithm>
#include <cstring>
#include <iostream>
......@@ -50,8 +48,7 @@ using namespace CuttleFish;
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 @@ IconModel::IconModel(QObject *parent) :
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<KPluginMetaData> 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 @@ void IconModel::setFilter(const QString &filter)
m_filter = filter;
load();
emit filterChanged();
emit svgIconsChanged();
}
}
......@@ -254,7 +238,6 @@ void IconModel::load()
}
foreach (const QString &iconPath, searchPaths) {
QDirIterator cats(iconPath, nameFilters, QDir::Dirs, QDirIterator::NoIteratorFlags);
while (cats.hasNext()) {
cats.next();
......@@ -273,12 +256,10 @@ void IconModel::load()
}
}
svgIcons();
sort();
endResetModel();
m_loading = false;
emit loadingChanged();
}
......@@ -308,79 +289,6 @@ bool IconModel::matchIcons(const QFileInfo& info)
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;
......
......@@ -40,11 +40,7 @@ class IconModel : public QAbstractListModel
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,7 +68,6 @@ public:
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);
......@@ -81,20 +76,11 @@ public:
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,9 +91,6 @@ Q_SIGNALS:
void filterChanged();
void categoryChanged();
void categoriesChanged();
void themeChanged();
void svgIconsChanged();
void plasmaThemeChanged();
void loadingChanged();
private:
......@@ -116,14 +99,9 @@ private:
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<QString, QVariantMap> m_data;
QHash<QString, QString> m_categoryTranslations;
QVariantMap m_svgIcons;
bool m_loading;
QString categoryFromPath(const QString &path);
......
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