Allow using bright custom color in Dolphin menu
to make it look better when using a dark theme
This commit is contained in:
parent
c103174609
commit
cd805e83ba
|
@ -46,4 +46,7 @@ include(TemplateFinder)
|
|||
find_template_file("${META_PROJECT_NAME}.desktop" "${META_PROJECT_NAME}" DESKTOP_TEMPLATE_FILE)
|
||||
set(DESKTOP_TARGET_FILE "${CMAKE_CURRENT_BINARY_DIR}/${META_TARGET_NAME}.desktop")
|
||||
configure_file("${DESKTOP_TEMPLATE_FILE}" "${DESKTOP_TARGET_FILE}")
|
||||
install(FILES "${DESKTOP_TARGET_FILE}" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/kservices5" COMPONENT desktop)
|
||||
install(
|
||||
FILES "${DESKTOP_TARGET_FILE}"
|
||||
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/kservices5"
|
||||
COMPONENT desktop)
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "./syncthingdiractions.h"
|
||||
#include "./syncthingfileitemactionstaticdata.h"
|
||||
|
||||
#include "../model/syncthingicons.h"
|
||||
|
||||
|
@ -7,17 +8,18 @@
|
|||
|
||||
using namespace Data;
|
||||
|
||||
SyncthingDirActions::SyncthingDirActions(const SyncthingDir &dir, QObject *parent)
|
||||
SyncthingDirActions::SyncthingDirActions(const SyncthingDir &dir, const SyncthingFileItemActionStaticData *data, QObject *parent)
|
||||
: QObject(parent)
|
||||
, m_dirId(dir.id)
|
||||
{
|
||||
const auto &icons = !data || !data->isUsingBrightCustomColors() ? fontAwesomeIconsForLightTheme() : fontAwesomeIconsForDarkTheme();
|
||||
m_infoAction.setSeparator(true);
|
||||
m_infoAction.setIcon(fontAwesomeIconsForLightTheme().folder);
|
||||
m_globalStatusAction.setIcon(fontAwesomeIconsForLightTheme().globe);
|
||||
m_localStatusAction.setIcon(fontAwesomeIconsForLightTheme().home);
|
||||
m_lastScanAction.setIcon(fontAwesomeIconsForLightTheme().clock);
|
||||
m_rescanIntervalAction.setIcon(fontAwesomeIconsForLightTheme().refresh);
|
||||
m_errorsAction.setIcon(fontAwesomeIconsForLightTheme().exclamationTriangle);
|
||||
m_infoAction.setIcon(icons.folder);
|
||||
m_globalStatusAction.setIcon(icons.globe);
|
||||
m_localStatusAction.setIcon(icons.home);
|
||||
m_lastScanAction.setIcon(icons.clock);
|
||||
m_rescanIntervalAction.setIcon(icons.refresh);
|
||||
m_errorsAction.setIcon(icons.exclamationTriangle);
|
||||
updateStatus(dir);
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
|
||||
#include "./syncthinginfoaction.h"
|
||||
|
||||
class SyncthingFileItemActionStaticData;
|
||||
|
||||
/*!
|
||||
* \brief The SyncthingDirActions class provides the read-only directory info actions.
|
||||
*/
|
||||
|
@ -13,7 +15,7 @@ class SyncthingDirActions : public QObject {
|
|||
friend QList<QAction *> &operator<<(QList<QAction *> &, SyncthingDirActions &);
|
||||
|
||||
public:
|
||||
explicit SyncthingDirActions(const Data::SyncthingDir &dir, QObject *parent = nullptr);
|
||||
explicit SyncthingDirActions(const Data::SyncthingDir &dir, const SyncthingFileItemActionStaticData *data = nullptr, QObject *parent = nullptr);
|
||||
|
||||
public Q_SLOTS:
|
||||
void updateStatus(const std::vector<Data::SyncthingDir> &dirs);
|
||||
|
|
|
@ -206,7 +206,7 @@ QList<QAction *> SyncthingFileItemAction::createActions(const KFileItemListPrope
|
|||
|
||||
// add actions to show further information about directory if the selection is only about one particular Syncthing dir
|
||||
if (lastDir && detectedDirs.size() + containingDirs.size() == 1) {
|
||||
auto *statusActions = new SyncthingDirActions(*lastDir, parent);
|
||||
auto *statusActions = new SyncthingDirActions(*lastDir, &data, parent);
|
||||
connect(&connection, &SyncthingConnection::newDirs, statusActions,
|
||||
static_cast<void (SyncthingDirActions::*)(const vector<SyncthingDir> &)>(&SyncthingDirActions::updateStatus));
|
||||
connect(&connection, &SyncthingConnection::dirStatusChanged, statusActions,
|
||||
|
@ -231,7 +231,12 @@ QList<QAction *> SyncthingFileItemAction::createActions(const KFileItemListPrope
|
|||
connect(&data, &SyncthingFileItemActionStaticData::currentErrorChanged, errorAction, &QAction::changed);
|
||||
actions << errorAction;
|
||||
|
||||
// add config file selection
|
||||
// add config items
|
||||
QAction *const brightCustomColorsAction = new QAction(QIcon::fromTheme(QStringLiteral("color-profile")), tr("Use bright custom colors"), parent);
|
||||
brightCustomColorsAction->setCheckable(true);
|
||||
brightCustomColorsAction->setChecked(data.isUsingBrightCustomColors());
|
||||
connect(brightCustomColorsAction, &QAction::triggered, &data, &SyncthingFileItemActionStaticData::handleBrightCustomColorsChanged);
|
||||
actions << brightCustomColorsAction;
|
||||
QAction *const configFileAction = new QAction(QIcon::fromTheme(QStringLiteral("settings-configure")), tr("Select Syncthing config ..."), parent);
|
||||
connect(configFileAction, &QAction::triggered, &data, &SyncthingFileItemActionStaticData::selectSyncthingConfig);
|
||||
actions << configFileAction;
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include <qtutilities/aboutdialog/aboutdialog.h>
|
||||
#include <qtutilities/resources/resources.h>
|
||||
|
||||
#include <QAction>
|
||||
#include <QFileDialog>
|
||||
#include <QInputDialog>
|
||||
#include <QMessageBox>
|
||||
|
@ -28,7 +29,8 @@ using namespace QtUtilities;
|
|||
using namespace Data;
|
||||
|
||||
SyncthingFileItemActionStaticData::SyncthingFileItemActionStaticData()
|
||||
: m_initialized(false)
|
||||
: m_useBrightCustomColors(false)
|
||||
, m_initialized(false)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -57,6 +59,10 @@ void SyncthingFileItemActionStaticData::initialize()
|
|||
}();
|
||||
applySyncthingConfiguration(m_configFilePath, settingsFile.value(QStringLiteral("syncthingApiKey")).toString(), true);
|
||||
|
||||
// apply icon settings
|
||||
applyBrightCustomColorsSetting(
|
||||
m_useBrightCustomColors = settingsFile.value(QStringLiteral("useBrightCustomColors"), m_useBrightCustomColors).toBool(), true);
|
||||
|
||||
// prevent unnecessary API calls (for the purpose of the context menu)
|
||||
m_connection.disablePolling();
|
||||
|
||||
|
@ -66,9 +72,6 @@ void SyncthingFileItemActionStaticData::initialize()
|
|||
connect(&m_connection, &SyncthingConnection::statusChanged, this, &SyncthingFileItemActionStaticData::logConnectionStatus);
|
||||
}
|
||||
|
||||
// use default icon settings
|
||||
IconManager::instance().applySettings();
|
||||
|
||||
m_initialized = true;
|
||||
}
|
||||
|
||||
|
@ -116,6 +119,11 @@ void SyncthingFileItemActionStaticData::selectSyncthingConfig()
|
|||
}
|
||||
}
|
||||
|
||||
void SyncthingFileItemActionStaticData::handleBrightCustomColorsChanged()
|
||||
{
|
||||
applyBrightCustomColorsSetting(qobject_cast<const QAction *>(QObject::sender())->isChecked(), false);
|
||||
}
|
||||
|
||||
void SyncthingFileItemActionStaticData::appendNoteToError(QString &errorMessage, const QString &newSyncthingConfigFilePath) const
|
||||
{
|
||||
if (!m_configFilePath.isEmpty() && m_configFilePath != newSyncthingConfigFilePath) {
|
||||
|
@ -192,6 +200,23 @@ bool SyncthingFileItemActionStaticData::applySyncthingConfiguration(
|
|||
return true;
|
||||
}
|
||||
|
||||
void SyncthingFileItemActionStaticData::applyBrightCustomColorsSetting(bool useBrightCustomColors, bool skipSavingConfig)
|
||||
{
|
||||
if (useBrightCustomColors) {
|
||||
static const auto settings = StatusIconSettings(StatusIconSettings::DarkTheme());
|
||||
IconManager::instance().applySettings(&settings);
|
||||
} else {
|
||||
static const auto settings = StatusIconSettings(StatusIconSettings::BrightTheme());
|
||||
IconManager::instance().applySettings(&settings);
|
||||
}
|
||||
|
||||
// save new config persistently
|
||||
if (!skipSavingConfig) {
|
||||
QSettings settings(QSettings::IniFormat, QSettings::UserScope, QStringLiteral(PROJECT_NAME));
|
||||
settings.setValue(QStringLiteral("useBrightCustomColors"), m_useBrightCustomColors = useBrightCustomColors);
|
||||
}
|
||||
}
|
||||
|
||||
void SyncthingFileItemActionStaticData::setCurrentError(const QString ¤tError)
|
||||
{
|
||||
if (m_currentError == currentError) {
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
class SyncthingFileItemActionStaticData : public QObject {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QString configPath READ configPath)
|
||||
Q_PROPERTY(bool useBrightCustomColors READ isUsingBrightCustomColors)
|
||||
Q_PROPERTY(QString currentError READ currentError WRITE setCurrentError NOTIFY currentErrorChanged RESET clearCurrentError)
|
||||
Q_PROPERTY(bool hasError READ hasError NOTIFY hasErrorChanged)
|
||||
Q_PROPERTY(bool initialized READ isInitialized)
|
||||
|
@ -21,6 +22,7 @@ public:
|
|||
Data::SyncthingConnection &connection();
|
||||
const Data::SyncthingConnection &connection() const;
|
||||
const QString &configPath() const;
|
||||
bool isUsingBrightCustomColors() const;
|
||||
const QString ¤tError() const;
|
||||
bool hasError() const;
|
||||
bool isInitialized() const;
|
||||
|
@ -28,11 +30,13 @@ public:
|
|||
public Q_SLOTS:
|
||||
void initialize();
|
||||
bool applySyncthingConfiguration(const QString &syncthingConfigFilePath, const QString &syncthingApiKey, bool skipSavingConfig);
|
||||
void applyBrightCustomColorsSetting(bool useBrightCustomColors, bool skipSavingConfig);
|
||||
void logConnectionStatus();
|
||||
void logConnectionError(const QString &errorMessage, Data::SyncthingErrorCategory errorCategory);
|
||||
void rescanDir(const QString &dirId, const QString &relpath = QString());
|
||||
static void showAboutDialog();
|
||||
void selectSyncthingConfig();
|
||||
void handleBrightCustomColorsChanged();
|
||||
void setCurrentError(const QString ¤tError);
|
||||
void clearCurrentError();
|
||||
|
||||
|
@ -46,6 +50,7 @@ private:
|
|||
Data::SyncthingConnection m_connection;
|
||||
QString m_configFilePath;
|
||||
QString m_currentError;
|
||||
bool m_useBrightCustomColors;
|
||||
bool m_initialized;
|
||||
};
|
||||
|
||||
|
@ -64,6 +69,11 @@ inline const QString &SyncthingFileItemActionStaticData::configPath() const
|
|||
return m_configFilePath;
|
||||
}
|
||||
|
||||
inline bool SyncthingFileItemActionStaticData::isUsingBrightCustomColors() const
|
||||
{
|
||||
return m_useBrightCustomColors;
|
||||
}
|
||||
|
||||
inline const QString &SyncthingFileItemActionStaticData::currentError() const
|
||||
{
|
||||
return m_currentError;
|
||||
|
|
|
@ -66,7 +66,7 @@ void SyncthingMenuAction::updateActionStatus()
|
|||
// handle case when already connected
|
||||
if (connection.isConnected()) {
|
||||
setText(tr("Syncthing"));
|
||||
setIcon(renderSvgImage(makeSyncthingIcon(), QSize(16, 16)));
|
||||
setIcon(statusIcons().idling);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -40,9 +40,16 @@ include(LibraryTarget)
|
|||
include(ConfigHeader)
|
||||
|
||||
# export some variable for further use in the overall plasmoid build script
|
||||
set(META_TARGET_NAME "${META_TARGET_NAME}" PARENT_SCOPE)
|
||||
set(META_ID "martchus.${META_TARGET_NAME}" PARENT_SCOPE)
|
||||
set(META_PROJECT_LICENSE "${META_PROJECT_LICENSE}" PARENT_SCOPE)
|
||||
set(META_TARGET_NAME
|
||||
"${META_TARGET_NAME}"
|
||||
PARENT_SCOPE)
|
||||
set(META_ID
|
||||
"martchus.${META_TARGET_NAME}"
|
||||
PARENT_SCOPE)
|
||||
set(META_PROJECT_LICENSE
|
||||
"${META_PROJECT_LICENSE}"
|
||||
PARENT_SCOPE)
|
||||
|
||||
# what ever this does, it is done
|
||||
kcoreaddons_desktop_to_json("${META_TARGET_NAME}" "${PLASMOID_CONFIG_TARGET_FILE}" DESKTOP_TO_JSON_OUTPUT_DIR "${PLASMOID_PACKAGE_DIR}")
|
||||
kcoreaddons_desktop_to_json("${META_TARGET_NAME}" "${PLASMOID_CONFIG_TARGET_FILE}" DESKTOP_TO_JSON_OUTPUT_DIR
|
||||
"${PLASMOID_PACKAGE_DIR}")
|
||||
|
|
Loading…
Reference in New Issue