Commit a273bee4 authored by Christoph Cullmann's avatar Christoph Cullmann 🐮
Browse files

remove KateColorSchemeChooser

we now rely on frameworks 5.90 and don't need our own implementation
any longer
parent b1e9413f
Pipeline #155406 passed with stage
in 6 minutes and 5 seconds
......@@ -75,7 +75,6 @@ target_sources(
kateapp.cpp
kateappadaptor.cpp
katecolorschemechooser.cpp
kateconfigdialog.cpp
kateconfigplugindialogpage.cpp
katedocmanager.cpp
......
/*************************************************************************************
* This file is part of KDevPlatform *
* SPDX-FileCopyrightText: 2016 Zhigalin Alexander <alexander@zhigalin.tk> *
* *
* SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*************************************************************************************/
#include "katecolorschemechooser.h"
#include <QActionGroup>
#include <QDirIterator>
#include <QFileInfo>
#include <QMenu>
#include <QModelIndex>
#include <QStandardPaths>
#include <QStringList>
#include <QtGlobal>
#include <KActionCollection>
#include <KActionMenu>
#include <KConfigGroup>
#include <KLocalizedString>
#include <KSharedConfig>
#include "katedebug.h"
#include "katemainwindow.h"
KateColorSchemeChooser::KateColorSchemeChooser(QObject *parent)
: QAction(parent)
{
auto manager = new KColorSchemeManager(parent);
const auto scheme(currentSchemeName());
qCDebug(LOG_KATE) << "Color scheme : " << scheme;
auto selectionMenu = manager->createSchemeSelectionMenu(scheme, this);
connect(selectionMenu->menu(), &QMenu::triggered, this, &KateColorSchemeChooser::slotSchemeChanged);
manager->activateScheme(manager->indexForScheme(scheme));
setMenu(selectionMenu->menu());
menu()->setIcon(QIcon::fromTheme(QStringLiteral("preferences-desktop-color")));
menu()->setTitle(i18n("&Color Scheme"));
}
QString KateColorSchemeChooser::loadCurrentScheme()
{
KSharedConfigPtr config = KSharedConfig::openConfig();
KConfigGroup cg(config, "UiSettings");
return cg.readEntry("ColorScheme", currentDesktopDefaultScheme());
}
void KateColorSchemeChooser::saveCurrentScheme(const QString &name)
{
KSharedConfigPtr config = KSharedConfig::openConfig();
KConfigGroup cg(config, "UiSettings");
cg.writeEntry("ColorScheme", name);
cg.sync();
}
QString KateColorSchemeChooser::currentDesktopDefaultScheme()
{
return QString();
}
QString KateColorSchemeChooser::currentSchemeName() const
{
if (!menu()) {
return loadCurrentScheme();
}
QAction *const action = menu()->activeAction();
if (action) {
return KLocalizedString::removeAcceleratorMarker(action->text());
}
return currentDesktopDefaultScheme();
}
void KateColorSchemeChooser::slotSchemeChanged(QAction *triggeredAction)
{
saveCurrentScheme(KLocalizedString::removeAcceleratorMarker(triggeredAction->text()));
}
/*************************************************************************************
* This file is part of KDevPlatform *
* SPDX-FileCopyrightText: 2016 Zhigalin Alexander <alexander@zhigalin.tk> *
* *
* SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*************************************************************************************/
#ifndef COLORSCHEMECHOOSER_H
#define COLORSCHEMECHOOSER_H
#include <QAction>
#include <QApplication>
#include <QObject>
#include <QString>
#include <KColorSchemeManager>
class KActionCollection;
/**
* Provides a menu that will offer to change the color scheme
*
* Furthermore, it will save the selection in the user configuration.
*/
class KateColorSchemeChooser : public QAction
{
public:
KateColorSchemeChooser(QObject *parent);
QString currentSchemeName() const;
private Q_SLOTS:
static void slotSchemeChanged(QAction *triggeredAction);
private:
static QString loadCurrentScheme();
static void saveCurrentScheme(const QString &name);
static QString currentDesktopDefaultScheme();
};
#endif // COLORSCHEMECHOOSER_H
......@@ -11,7 +11,6 @@
#include "katemainwindow.h"
#include "kateapp.h"
#include "katecolorschemechooser.h"
#include "katecommandbar.h"
#include "kateconfigdialog.h"
#include "kateconfigplugindialogpage.h"
......@@ -232,14 +231,9 @@ void KateMainWindow::setupImportantActions()
});
// Load themes
#if KCONFIGWIDGETS_VERSION < QT_VERSION_CHECK(5, 89, 0)
actionCollection()->addAction(QStringLiteral("colorscheme_menu"), new KateColorSchemeChooser(actionCollection()));
#else
const QString colorScheme = KConfigGroup(KSharedConfig::openConfig(), "UiSettings").readEntry("ColorScheme", QString());
KColorSchemeManager *manager = new KColorSchemeManager(this);
actionCollection()->addAction(QStringLiteral("colorscheme_menu"), manager->createSchemeSelectionMenu(colorScheme, this));
#endif
QAction *a = actionCollection()->addAction(KStandardAction::Back, QStringLiteral("view_prev_tab"));
a->setText(i18n("&Previous Tab"));
......
Supports Markdown
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