PlasmaLnfViewStep.cpp
PlasmaLnfPage.cpp
PlasmaLnfJob.cpp
+ ThemeInfo.cpp
ThemeWidget.cpp
RESOURCES
page_plasmalnf.qrc
#include "Config.h"
#include "PlasmaLnfJob.h"
+#include "ThemeInfo.h"
#include "utils/CalamaresUtilsSystem.h"
#include "utils/Logger.h"
#include <KSharedConfig>
#endif
-#include <KPackage/Package>
-#include <KPackage/PackageLoader>
-
-#include <QAbstractListModel>
-#include <QList>
-
-class ThemesModel : public QAbstractListModel
-{
- Q_OBJECT
-
-public:
- enum
- {
- LabelRole = Qt::DisplayRole,
- KeyRole = Qt::UserRole
- };
-
- explicit ThemesModel( QObject* parent );
-
- int rowCount( const QModelIndex& = QModelIndex() ) const override;
- QVariant data( const QModelIndex& index, int role ) const override;
-
- QHash< int, QByteArray > roleNames() const override;
-
-private:
- QList< KPluginMetaData > m_themes;
-};
-
-ThemesModel::ThemesModel( QObject* parent )
- : QAbstractListModel( parent )
- , m_themes( KPackage::PackageLoader::self()->listPackages( "Plasma/LookAndFeel" ) )
-{
-}
-
-int
-ThemesModel::rowCount( const QModelIndex& ) const
-{
- return m_themes.count();
-}
-
-QVariant
-ThemesModel::data( const QModelIndex& index, int role ) const
-{
- if ( !index.isValid() )
- {
- return QVariant();
- }
- if ( index.row() < 0 || index.row() >= m_themes.count() )
- {
- return QVariant();
- }
-
- const auto& item = m_themes.at( index.row() );
- switch ( role )
- {
- case LabelRole:
- return item.name();
- case KeyRole:
- return item.pluginId();
- default:
- return QVariant();
- }
- __builtin_unreachable();
-}
-
-QHash< int, QByteArray >
-ThemesModel::roleNames() const
-{
- return { { LabelRole, "label" }, { KeyRole, "key" } };
-}
-
-
static QString
currentPlasmaTheme()
{
}
emit themeChanged( id );
}
-
-#include "utils/moc-warnings.h"
-
-#include "Config.moc"
#include "Job.h"
-#include <QObject>
+#include "ThemeInfo.h"
-class QAbstractItemModel;
+#include <QObject>
class Config : public QObject
{
QString m_preselectThemeId;
QString m_themeId; // Id of selected theme
- QAbstractItemModel* m_themeModel = nullptr;
+ ThemesModel* m_themeModel = nullptr;
};
#endif
#include <KPackage/Package>
#include <KPackage/PackageLoader>
-ThemeInfo::ThemeInfo( const KPluginMetaData& data )
- : id( data.pluginId() )
- , name( data.name() )
- , description( data.description() )
- , widget( nullptr )
-{
-}
-
static ThemeInfoList
plasma_themes()
{
--- /dev/null
+/* === This file is part of Calamares - <https://calamares.io> ===
+ *
+ * SPDX-FileCopyrightText: 2020 Adriaan de Groot <groot@kde.org>
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ *
+ * Calamares is Free Software: see the License-Identifier above.
+ *
+ */
+#include "ThemeInfo.h"
+
+#include <KPackage/Package>
+#include <KPackage/PackageLoader>
+
+ThemesModel::ThemesModel( QObject* parent )
+ : QAbstractListModel( parent )
+{
+ auto packages = KPackage::PackageLoader::self()->listPackages( "Plasma/LookAndFeel" );
+ m_themes.reserve( packages.length() );
+
+ for ( const auto& p : packages )
+ {
+ m_themes.append( ThemeInfo { p } );
+ }
+}
+
+int
+ThemesModel::rowCount( const QModelIndex& ) const
+{
+ return m_themes.count();
+}
+
+QVariant
+ThemesModel::data( const QModelIndex& index, int role ) const
+{
+ if ( !index.isValid() )
+ {
+ return QVariant();
+ }
+ if ( index.row() < 0 || index.row() >= m_themes.count() )
+ {
+ return QVariant();
+ }
+
+ const auto& item = m_themes.at( index.row() );
+ switch ( role )
+ {
+ case LabelRole:
+ return item.name;
+ case KeyRole:
+ return item.id;
+ default:
+ return QVariant();
+ }
+ __builtin_unreachable();
+}
+
+QHash< int, QByteArray >
+ThemesModel::roleNames() const
+{
+ return { { LabelRole, "label" }, { KeyRole, "key" } };
+}
+
+ThemeInfo::ThemeInfo( const KPluginMetaData& data )
+ : id( data.pluginId() )
+ , name( data.name() )
+ , description( data.description() )
+ , widget( nullptr )
+{
+}
#ifndef PLASMALNF_THEMEINFO_H
#define PLASMALNF_THEMEINFO_H
+#include <QAbstractListModel>
#include <QList>
#include <QString>
{
}
- // Defined in PlasmaLnfPage.cpp
explicit ThemeInfo( const KPluginMetaData& );
bool isValid() const { return !id.isEmpty(); }
bool contains( const QString& id ) const { return findById( id ) != nullptr; }
};
+class ThemesModel : public QAbstractListModel
+{
+ Q_OBJECT
+
+public:
+ enum
+ {
+ LabelRole = Qt::DisplayRole,
+ KeyRole = Qt::UserRole
+ };
+
+ explicit ThemesModel( QObject* parent );
+
+ int rowCount( const QModelIndex& = QModelIndex() ) const override;
+ QVariant data( const QModelIndex& index, int role ) const override;
+
+ QHash< int, QByteArray > roleNames() const override;
+
+ const ThemeInfo* findById( const QString& id ) const { return m_themes.findById( id ); }
+
+private:
+ ThemeInfoList m_themes;
+};
+
+
#endif