Apply changed status colors without restart
This commit is contained in:
parent
96dc7a535c
commit
0e7cc8ba9b
|
@ -66,6 +66,9 @@ void SyncthingFileItemActionStaticData::initialize()
|
||||||
connect(&m_connection, &SyncthingConnection::statusChanged, this, &SyncthingFileItemActionStaticData::logConnectionStatus);
|
connect(&m_connection, &SyncthingConnection::statusChanged, this, &SyncthingFileItemActionStaticData::logConnectionStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// use default icon settings
|
||||||
|
IconManager::instance().applySettings(StatusIconSettings());
|
||||||
|
|
||||||
m_initialized = true;
|
m_initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -351,6 +351,11 @@ void SyncthingDeviceModel::devStatusChanged(const SyncthingDev &, int index)
|
||||||
emit dataChanged(this->index(0, 0, modelIndex1), this->index(5, 0, modelIndex1), modelRoles4);
|
emit dataChanged(this->index(0, 0, modelIndex1), this->index(5, 0, modelIndex1), modelRoles4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SyncthingDeviceModel::handleStatusIconsChanged()
|
||||||
|
{
|
||||||
|
emit dataChanged(index(0, 0), index(static_cast<int>(m_devs.size()) - 1, 0), QVector<int>({ Qt::DecorationRole }));
|
||||||
|
}
|
||||||
|
|
||||||
QString SyncthingDeviceModel::devStatusString(const SyncthingDev &dev)
|
QString SyncthingDeviceModel::devStatusString(const SyncthingDev &dev)
|
||||||
{
|
{
|
||||||
if (dev.paused) {
|
if (dev.paused) {
|
||||||
|
|
|
@ -41,6 +41,7 @@ public Q_SLOTS:
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void devStatusChanged(const SyncthingDev &, int index);
|
void devStatusChanged(const SyncthingDev &, int index);
|
||||||
|
void handleStatusIconsChanged() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static QString devStatusString(const SyncthingDev &dev);
|
static QString devStatusString(const SyncthingDev &dev);
|
||||||
|
|
|
@ -441,6 +441,11 @@ void SyncthingDirectoryModel::handleNewConfigAvailable()
|
||||||
endResetModel();
|
endResetModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SyncthingDirectoryModel::handleStatusIconsChanged()
|
||||||
|
{
|
||||||
|
emit dataChanged(index(0, 0), index(static_cast<int>(m_dirs.size()) - 1, 0), QVector<int>({ Qt::DecorationRole }));
|
||||||
|
}
|
||||||
|
|
||||||
QString SyncthingDirectoryModel::dirStatusString(const SyncthingDir &dir)
|
QString SyncthingDirectoryModel::dirStatusString(const SyncthingDir &dir)
|
||||||
{
|
{
|
||||||
if (dir.paused && dir.status != SyncthingDirStatus::OutOfSync) {
|
if (dir.paused && dir.status != SyncthingDirStatus::OutOfSync) {
|
||||||
|
|
|
@ -44,6 +44,7 @@ private Q_SLOTS:
|
||||||
void dirStatusChanged(const SyncthingDir &dir, int index);
|
void dirStatusChanged(const SyncthingDir &dir, int index);
|
||||||
void handleConfigInvalidated() override;
|
void handleConfigInvalidated() override;
|
||||||
void handleNewConfigAvailable() override;
|
void handleNewConfigAvailable() override;
|
||||||
|
void handleStatusIconsChanged() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static QString dirStatusString(const SyncthingDir &dir);
|
static QString dirStatusString(const SyncthingDir &dir);
|
||||||
|
|
|
@ -260,16 +260,16 @@ FontAwesomeIcons::FontAwesomeIcons(const QColor &color, const QSize &size, int m
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
IconManager::IconManager(const StatusIconSettings *settings)
|
IconManager::IconManager()
|
||||||
: m_statusIcons(settings ? *settings : StatusIconSettings())
|
: m_statusIcons()
|
||||||
, m_fontAwesomeIconsForLightTheme(QColor(10, 10, 10), QSize(64, 64), 8)
|
, m_fontAwesomeIconsForLightTheme(QColor(10, 10, 10), QSize(64, 64), 8)
|
||||||
, m_fontAwesomeIconsForDarkTheme(Qt::white, QSize(64, 64), 8)
|
, m_fontAwesomeIconsForDarkTheme(Qt::white, QSize(64, 64), 8)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
IconManager &IconManager::instance(const StatusIconSettings *settingsForFirstTimeSetup)
|
IconManager &IconManager::instance()
|
||||||
{
|
{
|
||||||
static IconManager iconManager(settingsForFirstTimeSetup);
|
static IconManager iconManager;
|
||||||
return iconManager;
|
return iconManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -81,7 +81,8 @@ struct LIB_SYNCTHING_MODEL_EXPORT StatusIconSettings {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct StatusIcons {
|
struct StatusIcons {
|
||||||
StatusIcons(const StatusIconSettings &settings = StatusIconSettings());
|
StatusIcons();
|
||||||
|
StatusIcons(const StatusIconSettings &settings);
|
||||||
QIcon disconnected;
|
QIcon disconnected;
|
||||||
QIcon idling;
|
QIcon idling;
|
||||||
QIcon scanninig;
|
QIcon scanninig;
|
||||||
|
@ -94,6 +95,10 @@ struct StatusIcons {
|
||||||
QIcon newItem;
|
QIcon newItem;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
inline StatusIcons::StatusIcons()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
struct FontAwesomeIcons {
|
struct FontAwesomeIcons {
|
||||||
FontAwesomeIcons(const QColor &color, const QSize &size, int margin);
|
FontAwesomeIcons(const QColor &color, const QSize &size, int margin);
|
||||||
QIcon hashtag;
|
QIcon hashtag;
|
||||||
|
@ -117,17 +122,21 @@ struct FontAwesomeIcons {
|
||||||
QIcon tag;
|
QIcon tag;
|
||||||
};
|
};
|
||||||
|
|
||||||
class LIB_SYNCTHING_MODEL_EXPORT IconManager {
|
class LIB_SYNCTHING_MODEL_EXPORT IconManager : public QObject {
|
||||||
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
static IconManager &instance(const StatusIconSettings *settingsForFirstTimeSetup = nullptr);
|
static IconManager &instance();
|
||||||
|
|
||||||
void applySettings(const StatusIconSettings &settings);
|
void applySettings(const StatusIconSettings &settings);
|
||||||
const StatusIcons &statusIcons() const;
|
const StatusIcons &statusIcons() const;
|
||||||
const FontAwesomeIcons &fontAwesomeIconsForLightTheme() const;
|
const FontAwesomeIcons &fontAwesomeIconsForLightTheme() const;
|
||||||
const FontAwesomeIcons &fontAwesomeIconsForDarkTheme() const;
|
const FontAwesomeIcons &fontAwesomeIconsForDarkTheme() const;
|
||||||
|
|
||||||
|
Q_SIGNALS:
|
||||||
|
void statusIconsChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
IconManager(const StatusIconSettings *settings = nullptr);
|
IconManager();
|
||||||
|
|
||||||
StatusIcons m_statusIcons;
|
StatusIcons m_statusIcons;
|
||||||
FontAwesomeIcons m_fontAwesomeIconsForLightTheme;
|
FontAwesomeIcons m_fontAwesomeIconsForLightTheme;
|
||||||
|
@ -137,6 +146,7 @@ private:
|
||||||
inline void IconManager::applySettings(const StatusIconSettings &settings)
|
inline void IconManager::applySettings(const StatusIconSettings &settings)
|
||||||
{
|
{
|
||||||
m_statusIcons = StatusIcons(settings);
|
m_statusIcons = StatusIcons(settings);
|
||||||
|
emit statusIconsChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const StatusIcons &IconManager::statusIcons() const
|
inline const StatusIcons &IconManager::statusIcons() const
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include "./syncthingmodel.h"
|
#include "./syncthingmodel.h"
|
||||||
|
#include "./syncthingicons.h"
|
||||||
|
|
||||||
#include "../connector/syncthingconnection.h"
|
#include "../connector/syncthingconnection.h"
|
||||||
|
|
||||||
|
@ -11,6 +12,7 @@ SyncthingModel::SyncthingModel(SyncthingConnection &connection, QObject *parent)
|
||||||
{
|
{
|
||||||
connect(&m_connection, &SyncthingConnection::newConfig, this, &SyncthingModel::handleConfigInvalidated);
|
connect(&m_connection, &SyncthingConnection::newConfig, this, &SyncthingModel::handleConfigInvalidated);
|
||||||
connect(&m_connection, &SyncthingConnection::newConfigApplied, this, &SyncthingModel::handleNewConfigAvailable);
|
connect(&m_connection, &SyncthingConnection::newConfigApplied, this, &SyncthingModel::handleNewConfigAvailable);
|
||||||
|
connect(&IconManager::instance(), &IconManager::statusIconsChanged, this, &SyncthingModel::handleStatusIconsChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
const QVector<int> &SyncthingModel::colorRoles() const
|
const QVector<int> &SyncthingModel::colorRoles() const
|
||||||
|
@ -55,4 +57,8 @@ void SyncthingModel::handleNewConfigAvailable()
|
||||||
endResetModel();
|
endResetModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SyncthingModel::handleStatusIconsChanged()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Data
|
} // namespace Data
|
||||||
|
|
|
@ -27,6 +27,7 @@ protected:
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
virtual void handleConfigInvalidated();
|
virtual void handleConfigInvalidated();
|
||||||
virtual void handleNewConfigAvailable();
|
virtual void handleNewConfigAvailable();
|
||||||
|
virtual void handleStatusIconsChanged();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Data::SyncthingConnection &m_connection;
|
Data::SyncthingConnection &m_connection;
|
||||||
|
|
|
@ -102,6 +102,7 @@ void SyncthingApplet::init()
|
||||||
connect(&m_dbusNotifier, &DBusStatusNotifier::showNotificationsRequested, this, &SyncthingApplet::showNotificationsDialog);
|
connect(&m_dbusNotifier, &DBusStatusNotifier::showNotificationsRequested, this, &SyncthingApplet::showNotificationsDialog);
|
||||||
connect(&m_dbusNotifier, &DBusStatusNotifier::errorDetailsRequested, this, &SyncthingApplet::showInternalErrorsDialog);
|
connect(&m_dbusNotifier, &DBusStatusNotifier::errorDetailsRequested, this, &SyncthingApplet::showInternalErrorsDialog);
|
||||||
connect(&m_dbusNotifier, &DBusStatusNotifier::webUiRequested, this, &SyncthingApplet::showWebUI);
|
connect(&m_dbusNotifier, &DBusStatusNotifier::webUiRequested, this, &SyncthingApplet::showWebUI);
|
||||||
|
connect(&IconManager::instance(), &IconManager::statusIconsChanged, this, &SyncthingApplet::connectionStatusChanged);
|
||||||
|
|
||||||
// restore settings
|
// restore settings
|
||||||
Settings::restore();
|
Settings::restore();
|
||||||
|
|
|
@ -96,6 +96,7 @@ TrayIcon::TrayIcon(const QString &connectionConfig, QObject *parent)
|
||||||
connect(&connection, &SyncthingConnection::statusChanged, this, &TrayIcon::updateStatusIconAndText);
|
connect(&connection, &SyncthingConnection::statusChanged, this, &TrayIcon::updateStatusIconAndText);
|
||||||
connect(&connection, &SyncthingConnection::newDevices, this, &TrayIcon::updateStatusIconAndText);
|
connect(&connection, &SyncthingConnection::newDevices, this, &TrayIcon::updateStatusIconAndText);
|
||||||
connect(&connection, &SyncthingConnection::devStatusChanged, this, &TrayIcon::updateStatusIconAndText);
|
connect(&connection, &SyncthingConnection::devStatusChanged, this, &TrayIcon::updateStatusIconAndText);
|
||||||
|
connect(&IconManager::instance(), &IconManager::statusIconsChanged, this, &TrayIcon::updateStatusIconAndText);
|
||||||
#ifdef QT_UTILITIES_SUPPORT_DBUS_NOTIFICATIONS
|
#ifdef QT_UTILITIES_SUPPORT_DBUS_NOTIFICATIONS
|
||||||
connect(&m_dbusNotifier, &DBusStatusNotifier::connectRequested, &connection,
|
connect(&m_dbusNotifier, &DBusStatusNotifier::connectRequested, &connection,
|
||||||
static_cast<void (SyncthingConnection::*)(void)>(&SyncthingConnection::connect));
|
static_cast<void (SyncthingConnection::*)(void)>(&SyncthingConnection::connect));
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>390</width>
|
<width>538</width>
|
||||||
<height>167</height>
|
<height>167</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
@ -70,13 +70,6 @@
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="infoLabel">
|
|
||||||
<property name="text">
|
|
||||||
<string>Requires (so far) a restart to be applied.</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<spacer name="horizontalSpacer">
|
<spacer name="horizontalSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
|
@ -96,7 +89,8 @@
|
||||||
<string>Restore previous settings</string>
|
<string>Restore previous settings</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset theme="edit-undo"/>
|
<iconset theme="edit-undo">
|
||||||
|
<normaloff>.</normaloff>.</iconset>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|
Loading…
Reference in New Issue