diff --git a/kcms/colors/CMakeLists.txt b/kcms/colors/CMakeLists.txt --- a/kcms/colors/CMakeLists.txt +++ b/kcms/colors/CMakeLists.txt @@ -1,92 +1,99 @@ # KI18N Translation Domain for this library -add_definitions(-DTRANSLATION_DOMAIN=\"kcmcolors\") +add_definitions(-DTRANSLATION_DOMAIN=\"kcm_colors\") -set(scheme_editor_SRCS - kcolorschemeeditor.cpp - scmeditordialog.cpp - scmeditoroptions.cpp - scmeditorcolors.cpp - scmeditoreffects.cpp - previewwidget.cpp - setpreviewwidget.cpp - colorscm.cpp - ../krdb/krdb.cpp - ) +#set(scheme_editor_SRCS +# kcolorschemeeditor.cpp +# scmeditordialog.cpp +# scmeditoroptions.cpp +# scmeditorcolors.cpp +# scmeditoreffects.cpp +# previewwidget.cpp +# setpreviewwidget.cpp +# colorscm.cpp +# ../krdb/krdb.cpp +# ) set(klauncher_xml ${KINIT_DBUS_INTERFACES_DIR}/kf5_org.kde.KLauncher.xml) -ki18n_wrap_ui(scheme_editor_SRCS - colorsettings.ui - scmeditordialog.ui - scmeditoroptions.ui - scmeditorcolors.ui - scmeditoreffects.ui - preview.ui - setpreview.ui - ) - -qt5_add_dbus_interface(scheme_editor_SRCS ${klauncher_xml} klauncher_iface) - -add_executable(kcolorschemeeditor ${scheme_editor_SRCS}) - -target_link_libraries(kcolorschemeeditor - KF5::KCMUtils - KF5::GuiAddons - KF5::I18n - KF5::KIOCore - KF5::CoreAddons - KF5::NewStuff - KF5::WindowSystem - ) -if(X11_FOUND) - target_link_libraries(kcolorschemeeditor ${X11_LIBRARIES} Qt5::X11Extras) -endif() -install(TARGETS kcolorschemeeditor DESTINATION ${KDE_INSTALL_TARGETS_DEFAULT_ARGS}) -install(FILES org.kde.kcolorschemeeditor.desktop DESTINATION ${KDE_INSTALL_APPDIR}) +#ki18n_wrap_ui(scheme_editor_SRCS +# colorsettings.ui +# scmeditordialog.ui +# scmeditoroptions.ui +# scmeditorcolors.ui +# scmeditoreffects.ui +# preview.ui +# setpreview.ui +# ) +# +#qt5_add_dbus_interface(scheme_editor_SRCS ${klauncher_xml} klauncher_iface) +# +#add_executable(kcolorschemeeditor ${scheme_editor_SRCS}) +# +#target_link_libraries(kcolorschemeeditor +# KF5::KCMUtils +# KF5::GuiAddons +# KF5::I18n +# KF5::KIOCore +# KF5::CoreAddons +# KF5::NewStuff +# KF5::WindowSystem +# ) +#if(X11_FOUND) +# target_link_libraries(kcolorschemeeditor ${X11_LIBRARIES} Qt5::X11Extras) +#endif() +#install(TARGETS kcolorschemeeditor DESTINATION ${KDE_INSTALL_TARGETS_DEFAULT_ARGS}) +#install(FILES org.kde.kcolorschemeeditor.desktop DESTINATION ${KDE_INSTALL_APPDIR}) # ---------------- set(kcm_colors_SRCS ../krdb/krdb.cpp - colorscm.cpp - scmeditordialog.cpp - scmeditoroptions.cpp - scmeditorcolors.cpp - scmeditoreffects.cpp - previewwidget.cpp - setpreviewwidget.cpp + #colorscm.cpp + #scmeditordialog.cpp + #scmeditoroptions.cpp + #scmeditorcolors.cpp + #scmeditoreffects.cpp + #previewwidget.cpp + #setpreviewwidget.cpp + colors.cpp ) qt5_add_dbus_interface(kcm_colors_SRCS ${klauncher_xml} klauncher_iface) -ki18n_wrap_ui(kcm_colors_SRCS - colorsettings.ui - scmeditordialog.ui - scmeditoroptions.ui - scmeditorcolors.ui - scmeditoreffects.ui - preview.ui - setpreview.ui) +#ki18n_wrap_ui(kcm_colors_SRCS +# colorsettings.ui +# scmeditordialog.ui +# scmeditoroptions.ui +# scmeditorcolors.ui +# scmeditoreffects.ui +# preview.ui +# setpreview.ui) add_library(kcm_colors MODULE ${kcm_colors_SRCS}) target_link_libraries(kcm_colors + Qt5::DBus KF5::KCMUtils + KF5::CoreAddons + KF5::Declarative KF5::GuiAddons KF5::I18n KF5::KIOCore - KF5::CoreAddons - Qt5::DBus KF5::NewStuff + KF5::QuickAddons KF5::WindowSystem) if(X11_FOUND) target_link_libraries(kcm_colors ${X11_LIBRARIES} Qt5::X11Extras) endif() -install(TARGETS kcm_colors DESTINATION ${KDE_INSTALL_PLUGINDIR}) -install( FILES colors.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR} ) -install( FILES colorschemes.knsrc DESTINATION ${KDE_INSTALL_CONFDIR} ) +kcoreaddons_desktop_to_json(kcm_colors "kcm_colors.desktop") + +install(FILES kcm_colors.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR}) +install(TARGETS kcm_colors DESTINATION ${KDE_INSTALL_PLUGINDIR}/kcms) +install(FILES colorschemes.knsrc DESTINATION ${KDE_INSTALL_CONFDIR}) + +kpackage_install_package(package kcm_colors kcms) # built-in color schemes file(GLOB schemefiles schemes/*.colors) diff --git a/kcms/colors/Messages.sh b/kcms/colors/Messages.sh --- a/kcms/colors/Messages.sh +++ b/kcms/colors/Messages.sh @@ -1,4 +1,4 @@ #! /usr/bin/env bash $EXTRACTRC *.ui >> rc.cpp -$XGETTEXT *.cpp -o $podir/kcmcolors.pot +$XGETTEXT `find . -name "*.cpp" -o -name "*.qml"` -o $podir/kcm_colors.pot rm -f rc.cpp diff --git a/kcms/colors/colors.h b/kcms/colors/colors.h new file mode 100644 --- /dev/null +++ b/kcms/colors/colors.h @@ -0,0 +1,95 @@ +/* + * Copyright 2018 Kai Uwe Broulik + * + * 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) version 3 or any later version + * accepted by the membership of KDE e.V. (or its successor approved + * by the membership of KDE e.V.), which shall act as a proxy + * defined in Section 14 of version 3 of the license. + * + * 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, see . + */ + +#pragma once + +#include + +#include + +#include + +class QStandardItemModel; + +class KCMColors : public KQuickAddons::ConfigModule +{ + Q_OBJECT + + Q_PROPERTY(QStandardItemModel *colorsModel READ colorsModel CONSTANT) + Q_PROPERTY(QString selectedScheme READ selectedScheme WRITE setSelectedScheme NOTIFY selectedSchemeChanged) + Q_PROPERTY(int selectedSchemeIndex READ selectedSchemeIndex NOTIFY selectedSchemeIndexChanged) + +public: + KCMColors(QObject *parent, const QVariantList &args); + ~KCMColors() override; + + enum Roles { + SchemeNameRole = Qt::UserRole + 1, + PaletteRole, + EditableRole, + RemovableRole, + PendingDeletionRole + }; + + QStandardItemModel *colorsModel() const; + + QString selectedScheme() const; + void setSelectedScheme(const QString &scheme); + + int selectedSchemeIndex() const; + + Q_INVOKABLE void getNewStuff(QQuickItem *ctx); + Q_INVOKABLE void installSchemeFromFile(const QUrl &url); + + Q_INVOKABLE void setPendingDeletion(int index, bool pending); + + Q_INVOKABLE void editScheme(const QString &scheme); + +public Q_SLOTS: + void load(); + void save(); + void defaults(); + +Q_SIGNALS: + void selectedSchemeChanged(); + void selectedSchemeIndexChanged(); + + void showSuccessMessage(const QString &message); + void showErrorMessage(const QString &message); + +private: + void loadModel(); + + void saveColors(); + void processPendingDeletions(); + + QStandardItemModel *m_model; + + QString m_selectedScheme; + // so we avoid launching changeicon process when theme didn't change (but only e.g. pending deletions) + bool m_selectedSchemeDirty = false; + + bool m_applyToAlien; + + QPointer m_newStuffDialog; + + KSharedConfigPtr m_config; + +}; diff --git a/kcms/colors/colors.cpp b/kcms/colors/colors.cpp new file mode 100644 --- /dev/null +++ b/kcms/colors/colors.cpp @@ -0,0 +1,469 @@ +/* + * Copyright (C) 2007 Matthew Woehlke + * Copyright (C) 2007 Jeremy Whiting + * Copyright (C) 2016 Olivier Churlaud + * Copyright 2018 Kai Uwe Broulik + * + * 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) version 3 or any later version + * accepted by the membership of KDE e.V. (or its successor approved + * by the membership of KDE e.V.), which shall act as a proxy + * defined in Section 14 of version 3 of the license. + * + * 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, see . + */ + +#include "colors.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include + +#include + +#include + +#include "../krdb/krdb.h" + +//static const QString s_defaultThemeName = QStringLiteral("/DEFAULT/"); +//static const QString s_currentThemeName = QStringLiteral("/CURRENT/"); + +K_PLUGIN_FACTORY_WITH_JSON(KCMColorsFactory, "kcm_colors.json", registerPlugin();) + +KCMColors::KCMColors(QObject *parent, const QVariantList &args) + : KQuickAddons::ConfigModule(parent, args) + , m_selectedSchemeDirty(false) + , m_applyToAlien(true) + , m_config(KSharedConfig::openConfig(QStringLiteral("kdeglobals"))) +{ + qmlRegisterType(); + + KAboutData *about = new KAboutData(QStringLiteral("kcm_colors"), i18n("Configure color schemes"), + QStringLiteral("2.0"), QString(), KAboutLicense::GPL); + about->addAuthor(i18n("Kai Uwe Broulik"), QString(), QStringLiteral("kde@privat.broulik.de")); + setAboutData(about); + setButtons(Apply | Default); + + m_model = new QStandardItemModel(this); + m_model->setItemRoleNames({ + {Qt::DisplayRole, QByteArrayLiteral("display")}, + {SchemeNameRole, QByteArrayLiteral("schemeName")}, + {PaletteRole, QByteArrayLiteral("palette")}, + {EditableRole, QByteArrayLiteral("editable")}, + {RemovableRole, QByteArrayLiteral("removable")}, + {PendingDeletionRole, QByteArrayLiteral("pendingDeletion")} + }); +} + +KCMColors::~KCMColors() +{ + +} + +QStandardItemModel *KCMColors::colorsModel() const +{ + return m_model; +} + +QString KCMColors::selectedScheme() const +{ + return m_selectedScheme; +} + +void KCMColors::setSelectedScheme(const QString &scheme) +{ + if (m_selectedScheme == scheme) { + return; + } + + const bool firstTime = m_selectedScheme.isNull(); + m_selectedScheme = scheme; + emit selectedSchemeChanged(); + emit selectedSchemeIndexChanged(); + + if (!firstTime) { + setNeedsSave(true); + m_selectedSchemeDirty = true; + } +} + +int KCMColors::selectedSchemeIndex() const +{ + const auto results = m_model->match(m_model->index(0, 0), SchemeNameRole, m_selectedScheme); + if (results.count() == 1) { + return results.first().row(); + } + + return -1; +} + +void KCMColors::setPendingDeletion(int index, bool pending) +{ + QModelIndex idx = m_model->index(index, 0); + + m_model->setData(idx, pending, PendingDeletionRole); + + if (pending && selectedSchemeIndex() == index) { + // move to the next non-pending theme + const auto nonPending = m_model->match(idx, PendingDeletionRole, false); + setSelectedScheme(nonPending.first().data(SchemeNameRole).toString()); + } + + setNeedsSave(true); +} + + +void KCMColors::loadModel() +{ + m_model->clear(); + + QStringList schemeFiles; + + const QStringList schemeDirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QStringLiteral("color-schemes"), QStandardPaths::LocateDirectory); + for (const QString &dir : schemeDirs) { + const QStringList fileNames = QDir(dir).entryList(QStringList{QStringLiteral("*.colors")}); + for (const QString &file : fileNames) { + const QString suffixedFileName = QStringLiteral("color-schemes/") + file; + // can't use QSet because of the transform below (passing const QString as this argument discards qualifiers) + if (!schemeFiles.contains(suffixedFileName)) { + schemeFiles.append(suffixedFileName); + } + } + } + + std::transform(schemeFiles.begin(), schemeFiles.end(), schemeFiles.begin(), [](const QString &item) { + return QStandardPaths::locate(QStandardPaths::GenericDataLocation, item); + }); + + for (const QString &schemeFile : schemeFiles) { + const QFileInfo fi(schemeFile); + const QString baseName = fi.baseName(); + + KSharedConfigPtr config = KSharedConfig::openConfig(schemeFile, KConfig::SimpleConfig); + KConfigGroup group(config, "General"); + const QString name = group.readEntry("Name", baseName); + + QStandardItem *item = new QStandardItem(name); + item->setData(baseName, SchemeNameRole); + item->setData(true, EditableRole); + item->setData(fi.isWritable(), RemovableRole); + item->setData(false, PendingDeletionRole); + + item->setData(KColorScheme::createApplicationPalette(config), PaletteRole); + + m_model->appendRow(item); + } + + m_model->sort(0 /*column*/); + + // add default entry (do this here so that the current and default entry appear at the top) + /*QStandardItem *defaultItem = new QStandardItem(i18nc("Default color scheme", "Default")); + defaultItem->setData(s_defaultThemeName, SchemeNameRole); + defaultItem->setData(true, EditableRole); + defaultItem->setData(false, RemovableRole); + m_model->insertRow(0, defaultItem);*/ + + // add current scheme entry + /*QStandardItem *currentItem = new QStandardItem(i18nc("Current color scheme", "Current")); + currentItem->setData(s_currentThemeName, SchemeNameRole); + currentItem->setData(true, EditableRole); + currentItem->setData(false, RemovableRole); + m_model->insertRow(0, currentItem);*/ +} + +void KCMColors::getNewStuff(QQuickItem *ctx) +{ + if (!m_newStuffDialog) { + m_newStuffDialog = new KNS3::DownloadDialog(QStringLiteral("colorschemes.knsrc")); + m_newStuffDialog.data()->setWindowTitle(i18n("Download New Color Schemes")); + m_newStuffDialog->setWindowModality(Qt::WindowModal); + m_newStuffDialog->winId(); // so it creates the windowHandle(); + // TODO would be lovely to scroll to and select the newly installed scheme, if any + connect(m_newStuffDialog.data(), &KNS3::DownloadDialog::accepted, this, &KCMColors::loadModel); + } + + if (ctx && ctx->window()) { + m_newStuffDialog->windowHandle()->setTransientParent(ctx->window()); + } + + m_newStuffDialog.data()->show(); +} + +void KCMColors::installSchemeFromFile(const QUrl &url) +{ + // load the scheme + KSharedConfigPtr config = KSharedConfig::openConfig(url.toLocalFile(), KConfig::SimpleConfig); + + KConfigGroup group(config, "General"); + const QString name = group.readEntry("Name"); + + if (name.isEmpty()) { + emit showErrorMessage(i18n("The file is not a color scheme file.")); + return; + } + + // Do not overwrite another scheme + int increment = 0; + QString newName = name; + QString testpath; + do { + if (increment) { + newName = name + QString::number(increment); + } + testpath = QStandardPaths::locate(QStandardPaths::GenericDataLocation, + QStringLiteral("color-schemes/%1.colors").arg(newName)); + increment++; + } while (!testpath.isEmpty()); + + QString newPath = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1String("/color-schemes/"); + + if (!QDir().mkpath(newPath)) { + emit showErrorMessage(i18n("Failed to create 'color-scheme' data folder.")); + return; + } + + newPath += newName + QLatin1String(".colors"); + + if (!QFile::copy(url.toLocalFile(), newPath)) { + emit showErrorMessage(i18n("Failed to copy color scheme into 'color-scheme' data folder.")); + return; + } + + // Update name + KSharedConfigPtr config2 = KSharedConfig::openConfig(newPath, KConfig::SimpleConfig); + KConfigGroup group2(config2, "General"); + group2.writeEntry("Name", newName); + config2->sync(); + + loadModel(); + + const auto results = m_model->match(m_model->index(0, 0), SchemeNameRole, newName); + if (!results.isEmpty()) { + setSelectedScheme(newName); + } + + emit showSuccessMessage(i18n("Color scheme installed successfully.")); +} + +void KCMColors::editScheme(const QString &scheme) +{ + // TODO +} + +void KCMColors::load() +{ + loadModel(); + + m_config->markAsClean(); + m_config->reparseConfiguration(); + + KConfigGroup group(m_config, "General"); + setSelectedScheme(group.readEntry("ColorScheme")); + + { + KConfig cfg(QStringLiteral("kcmdisplayrc"), KConfig::NoGlobals); + group = KConfigGroup(&cfg, "X11"); + m_applyToAlien = group.readEntry("exportKDEColors", true); + } +} + +void KCMColors::save() +{ + if (m_selectedSchemeDirty) { + saveColors(); + } + + processPendingDeletions(); + + setNeedsSave(false); +} + +void KCMColors::saveColors() +{ + KConfigGroup grp(m_config, "General"); + grp.writeEntry("ColorScheme", m_selectedScheme); + + const QString path = QStandardPaths::locate(QStandardPaths::GenericDataLocation, + QStringLiteral("color-schemes/%1.colors").arg(m_selectedScheme)); + + KSharedConfigPtr config = KSharedConfig::openConfig(path); + + QStringList colorItemList; + colorItemList << "BackgroundNormal" + << "BackgroundAlternate" + << "ForegroundNormal" + << "ForegroundInactive" + << "ForegroundActive" + << "ForegroundLink" + << "ForegroundVisited" + << "ForegroundNegative" + << "ForegroundNeutral" + << "ForegroundPositive" + << "DecorationFocus" + << "DecorationHover"; + + QStringList colorSetGroupList; + colorSetGroupList << "Colors:View" + << "Colors:Window" + << "Colors:Button" + << "Colors:Selection" + << "Colors:Tooltip" + << "Colors:Complementary"; + + QList colorSchemes; + + colorSchemes.append(KColorScheme(QPalette::Active, KColorScheme::View, config)); + colorSchemes.append(KColorScheme(QPalette::Active, KColorScheme::Window, config)); + colorSchemes.append(KColorScheme(QPalette::Active, KColorScheme::Button, config)); + colorSchemes.append(KColorScheme(QPalette::Active, KColorScheme::Selection, config)); + colorSchemes.append(KColorScheme(QPalette::Active, KColorScheme::Tooltip, config)); + colorSchemes.append(KColorScheme(QPalette::Active, KColorScheme::Complementary, config)); + + for (int i = 0; i < colorSchemes.length(); ++i) + { + KConfigGroup group(m_config, colorSetGroupList.value(i)); + group.writeEntry("BackgroundNormal", colorSchemes[i].background(KColorScheme::NormalBackground).color()); + group.writeEntry("BackgroundAlternate", colorSchemes[i].background(KColorScheme::AlternateBackground).color()); + group.writeEntry("ForegroundNormal", colorSchemes[i].foreground(KColorScheme::NormalText).color()); + group.writeEntry("ForegroundInactive", colorSchemes[i].foreground(KColorScheme::InactiveText).color()); + group.writeEntry("ForegroundActive", colorSchemes[i].foreground(KColorScheme::ActiveText).color()); + group.writeEntry("ForegroundLink", colorSchemes[i].foreground(KColorScheme::LinkText).color()); + group.writeEntry("ForegroundVisited", colorSchemes[i].foreground(KColorScheme::VisitedText).color()); + group.writeEntry("ForegroundNegative", colorSchemes[i].foreground(KColorScheme::NegativeText).color()); + group.writeEntry("ForegroundNeutral", colorSchemes[i].foreground(KColorScheme::NeutralText).color()); + group.writeEntry("ForegroundPositive", colorSchemes[i].foreground(KColorScheme::PositiveText).color()); + group.writeEntry("DecorationFocus", colorSchemes[i].decoration(KColorScheme::FocusColor).color()); + group.writeEntry("DecorationHover", colorSchemes[i].decoration(KColorScheme::HoverColor).color()); + } + + KConfigGroup groupWMTheme(config, "WM"); + KConfigGroup groupWMOut(m_config, "WM"); + + QStringList colorItemListWM; + colorItemListWM << "activeBackground" + << "activeForeground" + << "inactiveBackground" + << "inactiveForeground" + << "activeBlend" + << "inactiveBlend"; + + QVector defaultWMColors; + defaultWMColors << QColor(71,80,87) + << QColor(239,240,241) + << QColor(239,240,241) + << QColor(189,195,199) + << QColor(255,255,255) + << QColor(75,71,67); + + int i = 0; + for (const QString &coloritem : colorItemListWM) + { + groupWMOut.writeEntry(coloritem, groupWMTheme.readEntry(coloritem, defaultWMColors.value(i))); + ++i; + } + + QStringList groupNameList; + groupNameList << "ColorEffects:Inactive" << "ColorEffects:Disabled"; + + QStringList effectList; + effectList << "Enable" + << "ChangeSelectionColor" + << "IntensityEffect" + << "IntensityAmount" + << "ColorEffect" + << "ColorAmount" + << "Color" + << "ContrastEffect" + << "ContrastAmount"; + + for (const QString &groupName : groupNameList) + { + + KConfigGroup groupEffectOut(m_config, groupName); + KConfigGroup groupEffectTheme(config, groupName); + + for (const QString &effect : effectList) { + groupEffectOut.writeEntry(effect, groupEffectTheme.readEntry(effect)); + } + } + + m_config->sync(); + + runRdb(KRdbExportQtColors | KRdbExportGtkTheme | (m_applyToAlien ? KRdbExportColors : 0)); + + QDBusMessage message = QDBusMessage::createSignal(QStringLiteral("/KGlobalSettings"), + QStringLiteral("org.kde.KGlobalSettings"), + QStringLiteral("notifyChange")); + message.setArguments({ + 0, //previous KGlobalSettings::PaletteChanged. This is now private API in khintsettings + 0 //unused in palette changed but needed for the DBus signature + }); + QDBusConnection::sessionBus().send(message); + + if (qApp->platformName() == QLatin1String("xcb")) { + // Send signal to all kwin instances + QDBusMessage message = QDBusMessage::createSignal(QStringLiteral("/KWin"), QStringLiteral("org.kde.KWin"), QStringLiteral("reloadConfig")); + QDBusConnection::sessionBus().send(message); + } + + m_selectedSchemeDirty = false; +} + +void KCMColors::processPendingDeletions() +{ + const auto pendingDeletions = m_model->match(m_model->index(0, 0), PendingDeletionRole, true, -1 /*all*/); + QVector persistentPendingDeletions; + // turn into persistent model index so we can delete as we go + std::transform(pendingDeletions.begin(), pendingDeletions.end(), + std::back_inserter(persistentPendingDeletions), [](const QModelIndex &idx) { + return QPersistentModelIndex(idx); + }); + + for (const QPersistentModelIndex &idx : persistentPendingDeletions) { + const QString schemeName = idx.data(SchemeNameRole).toString(); + + Q_ASSERT(schemeName != m_selectedScheme); + + const QString path = QStandardPaths::locate(QStandardPaths::GenericDataLocation, + QStringLiteral("color-schemes/%1.colors").arg(schemeName)); + + auto *job = KIO::del(QUrl::fromLocalFile(path), KIO::HideProgressInfo); + // needs to block for it to work on "OK" where the dialog (kcmshell) closes + job->exec(); + } + + // remove them in a separate loop after all the delete jobs for a smoother animation + for (const QPersistentModelIndex &idx : persistentPendingDeletions) { + m_model->removeRow(idx.row()); + } +} + +void KCMColors::defaults() +{ + // TODO restore default color + + setNeedsSave(true); +} + +#include "colors.moc" diff --git a/kcms/colors/colors.desktop b/kcms/colors/colors.desktop deleted file mode 100644 --- a/kcms/colors/colors.desktop +++ /dev/null @@ -1,194 +0,0 @@ -[Desktop Entry] -Exec=kcmshell5 colors -Icon=preferences-desktop-color -Type=Service -X-KDE-ServiceTypes=KCModule -X-DocPath=kcontrol/colors/index.html - -X-KDE-Library=kcm_colors -X-KDE-ParentApp=kcontrol - -X-KDE-System-Settings-Parent-Category=color -X-KDE-Weight=60 - -Name=Colors -Name[af]=Kleure -Name[ar]=الألوان -Name[be]=Колеры -Name[be@latin]=Kolery -Name[bg]=Цветове -Name[bn]=রং -Name[bn_IN]=রং -Name[br]=Livioù -Name[bs]=Boje -Name[ca]=Colors -Name[ca@valencia]=Colors -Name[cs]=Barvy -Name[csb]=Farwë -Name[cy]=Lliwiau -Name[da]=Farver -Name[de]=Farben -Name[el]=Χρώματα -Name[en_GB]=Colours -Name[eo]=Koloroj -Name[es]=Colores -Name[et]=Värvid -Name[eu]=Koloreak -Name[fa]=رنگها -Name[fi]=Värit -Name[fr]=Couleurs -Name[fy]=Kleuren -Name[ga]=Dathanna -Name[gl]=Cores -Name[gu]=રંગો -Name[he]=צבעים -Name[hi]=रंग -Name[hne]=रंग -Name[hr]=Boje -Name[hsb]=Barby -Name[hu]=Színek -Name[ia]=Colores -Name[id]=Warna -Name[is]=Litir -Name[it]=Colori -Name[ja]=色 -Name[ka]=ცვეტები -Name[kk]=Түстер -Name[km]=ពណ៌ -Name[kn]=ಬಣ್ಣಗಳು -Name[ko]=색상 -Name[ku]=Reng -Name[lt]=Spalvos -Name[lv]=Krāsas -Name[mai]=रँग -Name[mk]=Бои -Name[ml]=നിറങ്ങള്‍ -Name[mr]=रंग -Name[ms]=Warna -Name[nb]=Farger -Name[nds]=Klören -Name[ne]=रङ -Name[nl]=Kleuren -Name[nn]=Fargar -Name[oc]=Colors -Name[or]=ରଙ୍ଗ -Name[pa]=ਰੰਗ -Name[pl]=Kolory -Name[pt]=Cores -Name[pt_BR]=Cores -Name[ro]=Culori -Name[ru]=Цвета -Name[se]=Ivnnit -Name[si]=වර්‍ණ -Name[sk]=Farby -Name[sl]=Barve -Name[sr]=Боје -Name[sr@ijekavian]=Боје -Name[sr@ijekavianlatin]=Boje -Name[sr@latin]=Boje -Name[sv]=Färger -Name[ta]=வண்ணங்கள் -Name[te]=రంగులు -Name[tg]=Рангҳо -Name[th]=สี -Name[tr]=Renkler -Name[ug]=رەڭلەر -Name[uk]=Кольори -Name[uz]=Ranglar -Name[uz@cyrillic]=Ранглар -Name[vi]=Màu sắc -Name[wa]=Coleurs -Name[xh]=Imibala -Name[x-test]=xxColorsxx -Name[zh_CN]=颜色 -Name[zh_TW]=顏色 - -Comment=Application Color Scheme -Comment[ca]=Esquema de color de les aplicacions -Comment[ca@valencia]=Esquema de color de les aplicacions -Comment[cs]=Barevný motiv aplikací -Comment[da]=Farvetema til program -Comment[de]=Farbschema für Anwendungen -Comment[el]=Θέμα χρωμάτων εφαρμογής -Comment[en_GB]=Application Colour Scheme -Comment[es]=Esquema de color de las aplicaciones -Comment[eu]=Aplikazioen kolore-eskema -Comment[fi]=Ohjelmien väriteema -Comment[fr]=Thème de couleur des applications -Comment[gl]=Esquema de cores do aplicativo -Comment[he]=ערכות צבעים של יישומים -Comment[hu]=Alkalmazások színsémái -Comment[id]=Skema Warna Aplikasi -Comment[it]=Schema di colore delle applicazioni -Comment[ja]=アプリケーションカラースキーム -Comment[ko]=프로그램 색 배열 -Comment[lt]=Programos spalvų derinys -Comment[nb]=Fargeoppsett for program -Comment[nl]=Toepassing Kleurenschema -Comment[nn]=Fargeoppsett for program -Comment[pa]=ਐਪਲੀਕੇਸ਼ਨ ਰੰਗ ਸਕੀਮ -Comment[pl]=Zestaw kolorów programów -Comment[pt]=Esquema de Cores da Aplicação -Comment[pt_BR]=Esquema de cores do aplicativo -Comment[ru]=Цветовая схема для приложений -Comment[sk]=Farebná schéma aplikácie -Comment[sl]=Barvna shema programov -Comment[sr]=Шема боја у програмима -Comment[sr@ijekavian]=Шема боја у програмима -Comment[sr@ijekavianlatin]=Šema boja u programima -Comment[sr@latin]=Šema boja u programima -Comment[sv]=Programmets färgschema -Comment[tr]=Uygulama Renk Şeması -Comment[uk]=Схема кольорів вікон програм -Comment[x-test]=xxApplication Color Schemexx -Comment[zh_CN]=应用程序配色方案 -Comment[zh_TW]=應用程式色彩機制 - -X-KDE-Keywords=colors,colours,scheme,contrast,Widget colors,Color Scheme,color style,color theme -X-KDE-Keywords[ar]=لون,ألوان,مخطّط,مخطط,تباين,ألوان الودجات,مخطّط ألوان,مخطط ألوان,نمط اللون,سمة اللون -X-KDE-Keywords[bs]=boje,boje,tema,kontrast,dodatak bojama,tema u boji,stil boja,tema boja -X-KDE-Keywords[ca]=colors,esquema,contrast,colors d'estris,Esquema de color,estil de color, tema de color -X-KDE-Keywords[ca@valencia]=colors,esquema,contrast,colors d'estris,Esquema de color,estil de color, tema de color -X-KDE-Keywords[da]=farver,tema,kontrast,widget-farver,farvetema,farvestil,farveskema -X-KDE-Keywords[de]=Farben,Schema,Kontrast,Farbschema,Elemente -X-KDE-Keywords[el]=χρώματα,χρώματα,σχήμα,αντίθεση,χρώματα γραφικών συστατικών,χρωματικό σχήμα,χρωματικό στιλ,θέμα χρώματος -X-KDE-Keywords[en_GB]=colours,scheme,contrast,Widget colours,Colour Scheme,colour style,colour theme -X-KDE-Keywords[es]=colores,esquema,contraste,colores de elementos gráficos,Esquema de color,estilo de color,tema de color -X-KDE-Keywords[et]=värv,värvid,skeem,kontrast,vidina värvid,värviskeem,värvistiil,värviteema -X-KDE-Keywords[eu]=kolore,koloreak,eskema,kontraste,trepetaren koloreak,kolore-eskema,kolore-estilo, kolorearen gai -X-KDE-Keywords[fi]=värit,teema,kontrasti,käyttöliittymäelementtien värit,elementtien värit,väriteema,värityyli -X-KDE-Keywords[fr]=couleurs, couleurs, schéma, contraste, couleur des composants graphiques, schéma de couleur, style de couleur, thème de couleur -X-KDE-Keywords[ga]=dathanna,scéim,codarsnacht,dathanna Giuirléidí,Scéim Datha,téama datha -X-KDE-Keywords[gl]=cores,esquema,contraste,cores do trebello,esquema de cores, tema de cores -X-KDE-Keywords[he]=colors,colours,scheme,contrast,Widget colors,Color Scheme,color style,color theme,צבעים,ערכת נושא,צבע -X-KDE-Keywords[hu]=színek,színek,séma,kontraszt,Grafikai elemek színei,Színséma,színstílus,színtéma -X-KDE-Keywords[ia]=colores,colores,schema,contrasto,colores de Widget,Schema de Color,stilo de color, thema de color -X-KDE-Keywords[id]=warna,warna,skema,kontras,Widget warna,Skema Warna,gaya warna,tema warna -X-KDE-Keywords[it]=colori,schema,contrasto,colore degli oggetti,schema di colore,stile colore,tema colore -X-KDE-Keywords[kk]=colors,colours,scheme,contrast,Widget colors,Color Scheme,color style,color theme -X-KDE-Keywords[km]=colors,colours,scheme,contrast,Widget colors,Color Scheme,color style,color theme -X-KDE-Keywords[ko]=colors,colours,scheme,contrast,Widget colors,Color Scheme,color style,color theme,색,색 배열,고대비 -X-KDE-Keywords[mr]=रंग, रंग, योजना, कॉन्ट्रास्ट, विजेट रंग, रंगयोजना, रंगप्रकार, रंगशैली -X-KDE-Keywords[nb]=farger,oppsett,kontrast,elementfarger,fargeoppsett,fargestil,fargetema -X-KDE-Keywords[nds]=Klöör,Klören,Schema,Kontrast,Lüttprogramm-Klören,Klöörschema,Klöörstil,Klöörmuster -X-KDE-Keywords[nl]=colors,colours, kleuren,scheme,schema,contrast,Widget colors,Widgetkleuren,Color Scheme,kleurschema,kleurstijl,kleurthema -X-KDE-Keywords[nn]=fargar,oppsett,kontrast,elementfargar,fargeoppsett,fargestil,fargetema -X-KDE-Keywords[pa]=ਰੰਗ,ਸਕੀਮ,ਕਨਟਰਾਸਟ,ਵਿਜੈਟ ਰੰਗ,ਰੰਗ ਸਕੀ,ਰੰਗ ਸਟਾਈਲ,ਰੰਗ ਥੀਮ -X-KDE-Keywords[pl]=kolory,schemat,kontrast,kolory elementów interfejsu,zestaw kolorów,styl kolorów,motyw kolorów -X-KDE-Keywords[pt]=cores,esquema,contraste,cores dos elementos,esquema de cores,estilo de cores,tema de cores -X-KDE-Keywords[pt_BR]=cor,cores,esquema,contraste,Cores do widget,Esquema de cores,estilo de cores,tema de cores -X-KDE-Keywords[ru]=colors,colours,scheme,contrast,Widget colors,Color Scheme,color style,color theme,цвет,цвета,схема,контраст,цвета виджета,цветовая схема,цветовой стиль,цветовая тема -X-KDE-Keywords[sk]=farba,farby,schéma,kontrast,farby widgetov,Farebná schéma,štýl farieb,téma farieb -X-KDE-Keywords[sl]=barve,shema,tema,kontrast,barve gradnikov,barvna shema,barvna tema,barvni slog -X-KDE-Keywords[sr]=colors,colours,scheme,contrast,Widget colors,Color Scheme,color style,color theme,боје,шема,контраст,боје виџета,шема боја,стил боја,тема боја -X-KDE-Keywords[sr@ijekavian]=colors,colours,scheme,contrast,Widget colors,Color Scheme,color style,color theme,боје,шема,контраст,боје виџета,шема боја,стил боја,тема боја -X-KDE-Keywords[sr@ijekavianlatin]=colors,colours,scheme,contrast,Widget colors,Color Scheme,color style,color theme,boje,šema,kontrast,boje vidžeta,šema boja,stil boja,tema boja -X-KDE-Keywords[sr@latin]=colors,colours,scheme,contrast,Widget colors,Color Scheme,color style,color theme,boje,šema,kontrast,boje vidžeta,šema boja,stil boja,tema boja -X-KDE-Keywords[sv]=färger,schema,kontrast,Komponentfärger,Färgschema,färgstil,färgtema -X-KDE-Keywords[tr]=renkler,renk,şema,karşıtlık,kontrast,Gereç renkleri,RenkŞeması,renk biçemi,renk teması,renk biçimi -X-KDE-Keywords[uk]=кольори,кольори,схема,контраст,кольори віджетів,схема кольорів,стиль кольорів,тема кольорів,colors,colours,scheme,contrast,Widget colors,Color Scheme,color style,color theme -X-KDE-Keywords[x-test]=xxcolorsxx,xxcoloursxx,xxschemexx,xxcontrastxx,xxWidget colorsxx,xxColor Schemexx,xxcolor stylexx,xxcolor themexx -X-KDE-Keywords[zh_CN]=colors,colours,scheme,contrast,Widget colors,Color Scheme,color style,color theme,颜色,配色方案,对比度,部件颜色,颜色方案,颜色风格,颜色主题 -X-KDE-Keywords[zh_TW]=colors,colours,scheme,contrast,Widget colors,Color Scheme,color style,color theme - -Categories=Qt;KDE;X-KDE-settings-looknfeel; diff --git a/kcms/colors/colorscm.cpp b/kcms/colors/colorscm.cpp --- a/kcms/colors/colorscm.cpp +++ b/kcms/colors/colorscm.cpp @@ -46,8 +46,8 @@ #include #include -K_PLUGIN_FACTORY( KolorFactory, registerPlugin(); ) -K_EXPORT_PLUGIN( KolorFactory("kcmcolors") ) +//K_PLUGIN_FACTORY( KolorFactory, registerPlugin(); ) +//K_EXPORT_PLUGIN( KolorFactory("kcmcolors") ) KColorCm::KColorCm(QWidget *parent, const QVariantList &) : KCModule( parent ), diff --git a/kcms/colors/kcm_colors.desktop b/kcms/colors/kcm_colors.desktop new file mode 100644 --- /dev/null +++ b/kcms/colors/kcm_colors.desktop @@ -0,0 +1,194 @@ +[Desktop Entry] +Exec=kcmshell5 colors +Icon=preferences-desktop-color +Type=Service +X-KDE-ServiceTypes=KCModule +X-DocPath=kcontrol/colors/index.html + +X-KDE-Library=kcm_colors +X-KDE-ParentApp=kcontrol + +X-KDE-System-Settings-Parent-Category=color +X-KDE-Weight=60 + +Name=Colors +Name[af]=Kleure +Name[ar]=الألوان +Name[be]=Колеры +Name[be@latin]=Kolery +Name[bg]=Цветове +Name[bn]=রং +Name[bn_IN]=রং +Name[br]=Livioù +Name[bs]=Boje +Name[ca]=Colors +Name[ca@valencia]=Colors +Name[cs]=Barvy +Name[csb]=Farwë +Name[cy]=Lliwiau +Name[da]=Farver +Name[de]=Farben +Name[el]=Χρώματα +Name[en_GB]=Colours +Name[eo]=Koloroj +Name[es]=Colores +Name[et]=Värvid +Name[eu]=Koloreak +Name[fa]=رنگها +Name[fi]=Värit +Name[fr]=Couleurs +Name[fy]=Kleuren +Name[ga]=Dathanna +Name[gl]=Cores +Name[gu]=રંગો +Name[he]=צבעים +Name[hi]=रंग +Name[hne]=रंग +Name[hr]=Boje +Name[hsb]=Barby +Name[hu]=Színek +Name[ia]=Colores +Name[id]=Warna +Name[is]=Litir +Name[it]=Colori +Name[ja]=色 +Name[ka]=ცვეტები +Name[kk]=Түстер +Name[km]=ពណ៌ +Name[kn]=ಬಣ್ಣಗಳು +Name[ko]=색상 +Name[ku]=Reng +Name[lt]=Spalvos +Name[lv]=Krāsas +Name[mai]=रँग +Name[mk]=Бои +Name[ml]=നിറങ്ങള്‍ +Name[mr]=रंग +Name[ms]=Warna +Name[nb]=Farger +Name[nds]=Klören +Name[ne]=रङ +Name[nl]=Kleuren +Name[nn]=Fargar +Name[oc]=Colors +Name[or]=ରଙ୍ଗ +Name[pa]=ਰੰਗ +Name[pl]=Kolory +Name[pt]=Cores +Name[pt_BR]=Cores +Name[ro]=Culori +Name[ru]=Цвета +Name[se]=Ivnnit +Name[si]=වර්‍ණ +Name[sk]=Farby +Name[sl]=Barve +Name[sr]=Боје +Name[sr@ijekavian]=Боје +Name[sr@ijekavianlatin]=Boje +Name[sr@latin]=Boje +Name[sv]=Färger +Name[ta]=வண்ணங்கள் +Name[te]=రంగులు +Name[tg]=Рангҳо +Name[th]=สี +Name[tr]=Renkler +Name[ug]=رەڭلەر +Name[uk]=Кольори +Name[uz]=Ranglar +Name[uz@cyrillic]=Ранглар +Name[vi]=Màu sắc +Name[wa]=Coleurs +Name[xh]=Imibala +Name[x-test]=xxColorsxx +Name[zh_CN]=颜色 +Name[zh_TW]=顏色 + +Comment=Application Color Scheme +Comment[ca]=Esquema de color de les aplicacions +Comment[ca@valencia]=Esquema de color de les aplicacions +Comment[cs]=Barevný motiv aplikací +Comment[da]=Farvetema til program +Comment[de]=Farbschema für Anwendungen +Comment[el]=Θέμα χρωμάτων εφαρμογής +Comment[en_GB]=Application Colour Scheme +Comment[es]=Esquema de color de las aplicaciones +Comment[eu]=Aplikazioen kolore-eskema +Comment[fi]=Ohjelmien väriteema +Comment[fr]=Thème de couleur des applications +Comment[gl]=Esquema de cores do aplicativo +Comment[he]=ערכות צבעים של יישומים +Comment[hu]=Alkalmazások színsémái +Comment[id]=Skema Warna Aplikasi +Comment[it]=Schema di colore delle applicazioni +Comment[ja]=アプリケーションカラースキーム +Comment[ko]=프로그램 색 배열 +Comment[lt]=Programos spalvų derinys +Comment[nb]=Fargeoppsett for program +Comment[nl]=Toepassing Kleurenschema +Comment[nn]=Fargeoppsett for program +Comment[pa]=ਐਪਲੀਕੇਸ਼ਨ ਰੰਗ ਸਕੀਮ +Comment[pl]=Zestaw kolorów programów +Comment[pt]=Esquema de Cores da Aplicação +Comment[pt_BR]=Esquema de cores do aplicativo +Comment[ru]=Цветовая схема для приложений +Comment[sk]=Farebná schéma aplikácie +Comment[sl]=Barvna shema programov +Comment[sr]=Шема боја у програмима +Comment[sr@ijekavian]=Шема боја у програмима +Comment[sr@ijekavianlatin]=Šema boja u programima +Comment[sr@latin]=Šema boja u programima +Comment[sv]=Programmets färgschema +Comment[tr]=Uygulama Renk Şeması +Comment[uk]=Схема кольорів вікон програм +Comment[x-test]=xxApplication Color Schemexx +Comment[zh_CN]=应用程序配色方案 +Comment[zh_TW]=應用程式色彩機制 + +X-KDE-Keywords=colors,colours,scheme,contrast,Widget colors,Color Scheme,color style,color theme +X-KDE-Keywords[ar]=لون,ألوان,مخطّط,مخطط,تباين,ألوان الودجات,مخطّط ألوان,مخطط ألوان,نمط اللون,سمة اللون +X-KDE-Keywords[bs]=boje,boje,tema,kontrast,dodatak bojama,tema u boji,stil boja,tema boja +X-KDE-Keywords[ca]=colors,esquema,contrast,colors d'estris,Esquema de color,estil de color, tema de color +X-KDE-Keywords[ca@valencia]=colors,esquema,contrast,colors d'estris,Esquema de color,estil de color, tema de color +X-KDE-Keywords[da]=farver,tema,kontrast,widget-farver,farvetema,farvestil,farveskema +X-KDE-Keywords[de]=Farben,Schema,Kontrast,Farbschema,Elemente +X-KDE-Keywords[el]=χρώματα,χρώματα,σχήμα,αντίθεση,χρώματα γραφικών συστατικών,χρωματικό σχήμα,χρωματικό στιλ,θέμα χρώματος +X-KDE-Keywords[en_GB]=colours,scheme,contrast,Widget colours,Colour Scheme,colour style,colour theme +X-KDE-Keywords[es]=colores,esquema,contraste,colores de elementos gráficos,Esquema de color,estilo de color,tema de color +X-KDE-Keywords[et]=värv,värvid,skeem,kontrast,vidina värvid,värviskeem,värvistiil,värviteema +X-KDE-Keywords[eu]=kolore,koloreak,eskema,kontraste,trepetaren koloreak,kolore-eskema,kolore-estilo, kolorearen gai +X-KDE-Keywords[fi]=värit,teema,kontrasti,käyttöliittymäelementtien värit,elementtien värit,väriteema,värityyli +X-KDE-Keywords[fr]=couleurs, couleurs, schéma, contraste, couleur des composants graphiques, schéma de couleur, style de couleur, thème de couleur +X-KDE-Keywords[ga]=dathanna,scéim,codarsnacht,dathanna Giuirléidí,Scéim Datha,téama datha +X-KDE-Keywords[gl]=cores,esquema,contraste,cores do trebello,esquema de cores, tema de cores +X-KDE-Keywords[he]=colors,colours,scheme,contrast,Widget colors,Color Scheme,color style,color theme,צבעים,ערכת נושא,צבע +X-KDE-Keywords[hu]=színek,színek,séma,kontraszt,Grafikai elemek színei,Színséma,színstílus,színtéma +X-KDE-Keywords[ia]=colores,colores,schema,contrasto,colores de Widget,Schema de Color,stilo de color, thema de color +X-KDE-Keywords[id]=warna,warna,skema,kontras,Widget warna,Skema Warna,gaya warna,tema warna +X-KDE-Keywords[it]=colori,schema,contrasto,colore degli oggetti,schema di colore,stile colore,tema colore +X-KDE-Keywords[kk]=colors,colours,scheme,contrast,Widget colors,Color Scheme,color style,color theme +X-KDE-Keywords[km]=colors,colours,scheme,contrast,Widget colors,Color Scheme,color style,color theme +X-KDE-Keywords[ko]=colors,colours,scheme,contrast,Widget colors,Color Scheme,color style,color theme,색,색 배열,고대비 +X-KDE-Keywords[mr]=रंग, रंग, योजना, कॉन्ट्रास्ट, विजेट रंग, रंगयोजना, रंगप्रकार, रंगशैली +X-KDE-Keywords[nb]=farger,oppsett,kontrast,elementfarger,fargeoppsett,fargestil,fargetema +X-KDE-Keywords[nds]=Klöör,Klören,Schema,Kontrast,Lüttprogramm-Klören,Klöörschema,Klöörstil,Klöörmuster +X-KDE-Keywords[nl]=colors,colours, kleuren,scheme,schema,contrast,Widget colors,Widgetkleuren,Color Scheme,kleurschema,kleurstijl,kleurthema +X-KDE-Keywords[nn]=fargar,oppsett,kontrast,elementfargar,fargeoppsett,fargestil,fargetema +X-KDE-Keywords[pa]=ਰੰਗ,ਸਕੀਮ,ਕਨਟਰਾਸਟ,ਵਿਜੈਟ ਰੰਗ,ਰੰਗ ਸਕੀ,ਰੰਗ ਸਟਾਈਲ,ਰੰਗ ਥੀਮ +X-KDE-Keywords[pl]=kolory,schemat,kontrast,kolory elementów interfejsu,zestaw kolorów,styl kolorów,motyw kolorów +X-KDE-Keywords[pt]=cores,esquema,contraste,cores dos elementos,esquema de cores,estilo de cores,tema de cores +X-KDE-Keywords[pt_BR]=cor,cores,esquema,contraste,Cores do widget,Esquema de cores,estilo de cores,tema de cores +X-KDE-Keywords[ru]=colors,colours,scheme,contrast,Widget colors,Color Scheme,color style,color theme,цвет,цвета,схема,контраст,цвета виджета,цветовая схема,цветовой стиль,цветовая тема +X-KDE-Keywords[sk]=farba,farby,schéma,kontrast,farby widgetov,Farebná schéma,štýl farieb,téma farieb +X-KDE-Keywords[sl]=barve,shema,tema,kontrast,barve gradnikov,barvna shema,barvna tema,barvni slog +X-KDE-Keywords[sr]=colors,colours,scheme,contrast,Widget colors,Color Scheme,color style,color theme,боје,шема,контраст,боје виџета,шема боја,стил боја,тема боја +X-KDE-Keywords[sr@ijekavian]=colors,colours,scheme,contrast,Widget colors,Color Scheme,color style,color theme,боје,шема,контраст,боје виџета,шема боја,стил боја,тема боја +X-KDE-Keywords[sr@ijekavianlatin]=colors,colours,scheme,contrast,Widget colors,Color Scheme,color style,color theme,boje,šema,kontrast,boje vidžeta,šema boja,stil boja,tema boja +X-KDE-Keywords[sr@latin]=colors,colours,scheme,contrast,Widget colors,Color Scheme,color style,color theme,boje,šema,kontrast,boje vidžeta,šema boja,stil boja,tema boja +X-KDE-Keywords[sv]=färger,schema,kontrast,Komponentfärger,Färgschema,färgstil,färgtema +X-KDE-Keywords[tr]=renkler,renk,şema,karşıtlık,kontrast,Gereç renkleri,RenkŞeması,renk biçemi,renk teması,renk biçimi +X-KDE-Keywords[uk]=кольори,кольори,схема,контраст,кольори віджетів,схема кольорів,стиль кольорів,тема кольорів,colors,colours,scheme,contrast,Widget colors,Color Scheme,color style,color theme +X-KDE-Keywords[x-test]=xxcolorsxx,xxcoloursxx,xxschemexx,xxcontrastxx,xxWidget colorsxx,xxColor Schemexx,xxcolor stylexx,xxcolor themexx +X-KDE-Keywords[zh_CN]=colors,colours,scheme,contrast,Widget colors,Color Scheme,color style,color theme,颜色,配色方案,对比度,部件颜色,颜色方案,颜色风格,颜色主题 +X-KDE-Keywords[zh_TW]=colors,colours,scheme,contrast,Widget colors,Color Scheme,color style,color theme + +Categories=Qt;KDE;X-KDE-settings-looknfeel; diff --git a/kcms/colors/package/contents/ui/main.qml b/kcms/colors/package/contents/ui/main.qml new file mode 100644 --- /dev/null +++ b/kcms/colors/package/contents/ui/main.qml @@ -0,0 +1,203 @@ +/* + * Copyright 2018 Kai Uwe Broulik + * + * 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) version 3 or any later version + * accepted by the membership of KDE e.V. (or its successor approved + * by the membership of KDE e.V.), which shall act as a proxy + * defined in Section 14 of version 3 of the license. + * + * 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, see . + */ + +import QtQuick 2.6 +import QtQuick.Layouts 1.1 +import QtQuick.Window 2.2 +import QtQuick.Dialogs 1.0 as QtDialogs +import QtQuick.Controls 2.3 as QtControls +import org.kde.kirigami 2.4 as Kirigami +import org.kde.kcm 1.1 as KCM + +KCM.GridViewKCM { + KCM.ConfigModule.quickHelp: i18n("This module lets you configure the color scheme of applications.") + + view.model: kcm.colorsModel + view.currentIndex: kcm.selectedSchemeIndex + + DropArea { + anchors.fill: parent + onEntered: { + if (!drag.hasUrls) { + drag.accepted = false; + } + } + onDropped: kcm.installSchemeFromFile(drop.urls[0]) + } + + view.remove: Transition { + ParallelAnimation { + NumberAnimation { property: "scale"; to: 0.5; duration: Kirigami.Units.longDuration } + NumberAnimation { property: "opacity"; to: 0.0; duration: Kirigami.Units.longDuration } + } + } + + view.removeDisplaced: Transition { + SequentialAnimation { + // wait for the "remove" animation to finish + PauseAnimation { duration: Kirigami.Units.longDuration } + NumberAnimation { properties: "x,y"; duration: Kirigami.Units.longDuration } + } + } + + view.delegate: KCM.GridDelegate { + id: delegate + + text: model.display + + thumbnailAvailable: true + thumbnail: Item { + // FIXME needs a nicer live preview with some controls + // this GridLayout below was just a quick and dirty attempt trying + // to mimic the old thumbnail we had in the list + id: thumb + readonly property var itemPalette: model.palette + readonly property var colorKeys: ["window", "button", "highlight", "bright", "toolTip", ""] + + anchors.fill: parent + + opacity: model.pendingDeletion ? 0.3 : 1 + Behavior on opacity { + NumberAnimation { duration: Kirigami.Units.longDuration } + } + + GridLayout { + id: grid + anchors.fill: parent + columns: 3 + columnSpacing: 0 + rowSpacing: 0 + + Repeater { + model: [ + {background: "window", foreground: "windowText"}, + {background: "highlight", foreground: "highlightedText"}, + {background: "button", foreground: "buttonText"}, + {background: "toolTipBase", foreground: "toolTipText"}, + {background: "link", foreground: "linkVisited"}, + {background: "dark", foreground: "light"} + ] + + Rectangle { + Layout.fillWidth: true + Layout.fillHeight: true + color: thumb.itemPalette[modelData.background] + + // some comic style fake text + Rectangle { + anchors { + left: parent.left + top: parent.top + margins: Kirigami.Units.largeSpacing + } + width: Math.round(parent.width / 2) + height: Math.round(width / 5) + color: modelData.foreground ? thumb.itemPalette[modelData.foreground] : "" + visible: !!modelData.foreground + } + } + } + } + } + + actions: [ + Kirigami.Action { + iconName: "document-edit" + tooltip: i18n("Edit Color Scheme") + enabled: model.editable && !model.pendingDeletion + onTriggered: kcm.editScheme(model.schemeName) + }, + Kirigami.Action { + iconName: "edit-delete" + tooltip: i18n("Remove Color Scheme") + enabled: model.removable + visible: !model.pendingDeletion + onTriggered: kcm.setPendingDeletion(model.index, true); + }, + Kirigami.Action { + iconName: "edit-undo" + tooltip: i18n("Restore Color Scheme") + visible: model.pendingDeletion + onTriggered: kcm.setPendingDeletion(model.index, false); + } + ] + onClicked: { + kcm.selectedScheme = model.schemeName; + view.forceActiveFocus(); + } + } + + footer: ColumnLayout { + Kirigami.InlineMessage { + id: infoLabel + Layout.fillWidth: true + + showCloseButton: true + + Connections { + target: kcm + onShowSuccessMessage: { + infoLabel.type = Kirigami.MessageType.Positive; + infoLabel.text = message; + infoLabel.visible = true; + } + onShowErrorMessage: { + infoLabel.type = Kirigami.MessageType.Error; + infoLabel.text = message; + infoLabel.visible = true; + } + } + } + + RowLayout { + Layout.alignment: Qt.AlignRight + + QtControls.Button { + text: i18n("Install from File...") + icon.name: "document-import" + onClicked: fileDialogLoader.active = true + } + + QtControls.Button { + text: i18n("Get New Themes...") + icon.name: "get-hot-new-stuff" + onClicked: kcm.getNewStuff(this) + } + } + } + + Loader { + id: fileDialogLoader + active: false + sourceComponent: QtDialogs.FileDialog { + visible: true + title: i18n("Open Color Scheme") + folder: shortcuts.home + nameFilters: [ i18n("Color Scheme Files (*.colors)") ] + onAccepted: { + kcm.installSchemeFromFile(fileUrls[0]) + fileDialogLoader.active = false + } + onRejected: { + fileDialogLoader.active = false + } + } + } +} diff --git a/kcms/colors/package/metadata.desktop b/kcms/colors/package/metadata.desktop new file mode 100644 --- /dev/null +++ b/kcms/colors/package/metadata.desktop @@ -0,0 +1,16 @@ +[Desktop Entry] +Name=Colors +Comment=Application Color Scheme + +Icon=preferences-desktop-color +Type=Service +X-KDE-PluginInfo-Author=Kai Uwe Broulik +X-KDE-PluginInfo-Email=kde@privat.broulik.de +X-KDE-PluginInfo-License=GPL +X-KDE-PluginInfo-Name=kcm_colors +X-KDE-PluginInfo-Version= +X-KDE-PluginInfo-Website= +X-KDE-ServiceTypes=Plasma/Generic +X-Plasma-API=declarativeappletscript + +X-Plasma-MainScript=ui/main.qml