Now the KColorSchemeManager has QML API ColorSchemer is unnescessary so remove it.
This commit is contained in:
@@ -144,8 +144,6 @@ add_library(neochat STATIC
|
|||||||
roomlastmessageprovider.h
|
roomlastmessageprovider.h
|
||||||
chatbarcache.cpp
|
chatbarcache.cpp
|
||||||
chatbarcache.h
|
chatbarcache.h
|
||||||
colorschemer.cpp
|
|
||||||
colorschemer.h
|
|
||||||
models/notificationsmodel.cpp
|
models/notificationsmodel.cpp
|
||||||
models/notificationsmodel.h
|
models/notificationsmodel.h
|
||||||
models/timelinemodel.cpp
|
models/timelinemodel.cpp
|
||||||
|
|||||||
@@ -1,48 +0,0 @@
|
|||||||
// SPDX-FileCopyrightText: 2021 Carl Schwan <carlschwan@kde.org>
|
|
||||||
// SPDX-License-Identifier: LGPL-2.1-or-later
|
|
||||||
|
|
||||||
#include <KColorSchemeManager>
|
|
||||||
#include <QAbstractItemModel>
|
|
||||||
|
|
||||||
#include "colorschemer.h"
|
|
||||||
|
|
||||||
ColorSchemer::ColorSchemer(QObject *parent)
|
|
||||||
: QObject(parent)
|
|
||||||
, c(new KColorSchemeManager(this))
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
ColorSchemer::~ColorSchemer()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
QAbstractItemModel *ColorSchemer::model() const
|
|
||||||
{
|
|
||||||
return c->model();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ColorSchemer::apply(int idx)
|
|
||||||
{
|
|
||||||
c->activateScheme(c->model()->index(idx, 0));
|
|
||||||
}
|
|
||||||
|
|
||||||
void ColorSchemer::apply(const QString &name)
|
|
||||||
{
|
|
||||||
c->activateScheme(c->indexForScheme(name));
|
|
||||||
}
|
|
||||||
|
|
||||||
int ColorSchemer::indexForScheme(const QString &name) const
|
|
||||||
{
|
|
||||||
auto index = c->indexForScheme(name).row();
|
|
||||||
if (index == -1) {
|
|
||||||
index = 0;
|
|
||||||
}
|
|
||||||
return index;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString ColorSchemer::nameForIndex(int index) const
|
|
||||||
{
|
|
||||||
return c->model()->data(c->model()->index(index, 0), Qt::DisplayRole).toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
#include "moc_colorschemer.cpp"
|
|
||||||
@@ -1,65 +0,0 @@
|
|||||||
// SPDX-FileCopyrightText: 2021 Carl Schwan <carlschwan@kde.org>
|
|
||||||
// SPDX-License-Identifier: LGPL-2.1-or-later
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <QObject>
|
|
||||||
#include <QQmlEngine>
|
|
||||||
|
|
||||||
class QAbstractItemModel;
|
|
||||||
class KColorSchemeManager;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @class ColorSchemer
|
|
||||||
*
|
|
||||||
* A class to provide a wrapper around KColorSchemeManager to make it available in
|
|
||||||
* QML.
|
|
||||||
*
|
|
||||||
* @sa KColorSchemeManager
|
|
||||||
*/
|
|
||||||
class ColorSchemer : public QObject
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
QML_ELEMENT
|
|
||||||
QML_SINGLETON
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief A QAbstractItemModel of all available color schemes.
|
|
||||||
*
|
|
||||||
* @sa QAbstractItemModel
|
|
||||||
*/
|
|
||||||
Q_PROPERTY(QAbstractItemModel *model READ model CONSTANT)
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit ColorSchemer(QObject *parent = nullptr);
|
|
||||||
~ColorSchemer();
|
|
||||||
|
|
||||||
QAbstractItemModel *model() const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Activates the KColorScheme identified by the provided index.
|
|
||||||
*
|
|
||||||
* @sa KColorScheme
|
|
||||||
*/
|
|
||||||
Q_INVOKABLE void apply(int idx);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Activates the KColorScheme with the given name.
|
|
||||||
*
|
|
||||||
* @sa KColorScheme
|
|
||||||
*/
|
|
||||||
Q_INVOKABLE void apply(const QString &name);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Returns the index for the scheme with the given name.
|
|
||||||
*/
|
|
||||||
Q_INVOKABLE int indexForScheme(const QString &name) const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Returns the name for the scheme with the given index.
|
|
||||||
*/
|
|
||||||
Q_INVOKABLE QString nameForIndex(int index) const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
KColorSchemeManager *c;
|
|
||||||
};
|
|
||||||
@@ -37,6 +37,7 @@
|
|||||||
#include <KCrash>
|
#include <KCrash>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <KColorSchemeManager>
|
||||||
#include <KLocalizedContext>
|
#include <KLocalizedContext>
|
||||||
#include <KLocalizedString>
|
#include <KLocalizedString>
|
||||||
|
|
||||||
@@ -45,7 +46,6 @@
|
|||||||
#include <Quotient/networkaccessmanager.h>
|
#include <Quotient/networkaccessmanager.h>
|
||||||
|
|
||||||
#include "blurhashimageprovider.h"
|
#include "blurhashimageprovider.h"
|
||||||
#include "colorschemer.h"
|
|
||||||
#include "controller.h"
|
#include "controller.h"
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
#include "neochatconfig.h"
|
#include "neochatconfig.h"
|
||||||
@@ -184,10 +184,7 @@ int main(int argc, char *argv[])
|
|||||||
QStringLiteral("/var/config/fontconfig/conf.d/99-noto-mono-color-emoji.conf"));
|
QStringLiteral("/var/config/fontconfig/conf.d/99-noto-mono-color-emoji.conf"));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ColorSchemer colorScheme;
|
KColorSchemeManager::instance();
|
||||||
if (!NeoChatConfig::self()->colorScheme().isEmpty()) {
|
|
||||||
colorScheme.apply(NeoChatConfig::self()->colorScheme());
|
|
||||||
}
|
|
||||||
|
|
||||||
QCommandLineParser parser;
|
QCommandLineParser parser;
|
||||||
parser.setApplicationDescription(i18n("Client for the matrix communication protocol"));
|
parser.setApplicationDescription(i18n("Client for the matrix communication protocol"));
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import QtQuick
|
|||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
|
|
||||||
import org.kde.kirigamiaddons.formcard as FormCard
|
import org.kde.kirigamiaddons.formcard as FormCard
|
||||||
|
import org.kde.colorscheme
|
||||||
|
|
||||||
import org.kde.neochat
|
import org.kde.neochat
|
||||||
|
|
||||||
@@ -14,11 +15,7 @@ FormCard.FormComboBoxDelegate {
|
|||||||
text: i18n("Color theme")
|
text: i18n("Color theme")
|
||||||
textRole: "display"
|
textRole: "display"
|
||||||
valueRole: "display"
|
valueRole: "display"
|
||||||
model: ColorSchemer.model
|
model: ColorSchemeManager.model
|
||||||
Component.onCompleted: currentIndex = ColorSchemer.indexForScheme(NeoChatConfig.colorScheme)
|
Component.onCompleted: currentIndex = ColorSchemeManager.rowForCurrentScheme
|
||||||
onCurrentValueChanged: {
|
onCurrentValueChanged: ColorSchemeManager.rowForCurrentScheme = currentIndex;
|
||||||
ColorSchemer.apply(currentIndex);
|
|
||||||
NeoChatConfig.colorScheme = ColorSchemer.nameForIndex(currentIndex);
|
|
||||||
NeoChatConfig.save();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user