Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ set(client_SRCS
localactivitywidget.cpp
protocolitem.cpp
syncerrorwidget.cpp
activitysettings.cpp
selectivesyncwidget.cpp
tlserrordialog.cpp
syncrunfilelog.cpp
Expand Down
61 changes: 0 additions & 61 deletions src/gui/activitysettings.cpp

This file was deleted.

2 changes: 2 additions & 0 deletions src/gui/mainwindow/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@ target_sources(owncloudGui PRIVATE
settingsview.cpp
settingsview.h
settingsview.ui
colormanager.h
colormanager.cpp
)

48 changes: 48 additions & 0 deletions src/gui/mainwindow/colormanager.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright (C) Lisa Reese <lisa.reese@kiteworks.com>
*
* 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) any later version.
*
* 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.
*/

#include "colormanager.h"

#include <QAction>
#include <QGuiApplication>

#include "resources/iconresources.h"

namespace OCC {

ColorManager::ColorManager(QObject *parent)
: QObject{parent}
{
connect(qGuiApp->styleHints(), &QStyleHints::colorSchemeChanged, this, &ColorManager::updateColorScheme);
}

void ColorManager::addActionIcon(QAction *action, const QString &iconName)
{
connect(this, &ColorManager::refreshCoreIcons, action, [action, iconName]() { action->setIcon(IconResources::getCoreIcon(iconName)); });
}

void ColorManager::refresh()
{
updateColorScheme(qGuiApp->styleHints()->colorScheme());
}

void ColorManager::updateColorScheme(Qt::ColorScheme colorScheme)
{
Q_UNUSED(colorScheme);

IconResources::handleSystemStyleChanged();

emit refreshCoreIcons();
}
}
33 changes: 16 additions & 17 deletions src/gui/activitysettings.h → src/gui/mainwindow/colormanager.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) by Klaas Freitag <freitag@owncloud.com>
* Copyright (C) Lisa Reese <lisa.reese@kiteworks.com>
*
* 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
Expand All @@ -14,30 +14,29 @@

#pragma once

#include <QWidget>
#include <QHash>
#include <QObject>
#include <QStyleHints>

class QTabWidget;
class QAction;

namespace OCC {

/**
* @brief The ActivitySettings class
* @ingroup gui
*
* Implements a tab for the settings dialog, displaying lists of local activities and sync issues
*/
class ActivitySettings : public QWidget
class ColorManager : public QObject
{
Q_OBJECT

public:
explicit ActivitySettings(QWidget *parent = nullptr);
~ActivitySettings() override;
explicit ColorManager(QObject *parent);

private Q_SLOTS:
void slotShowIssueItemCount(int cnt);
void addActionIcon(QAction *action, const QString &iconName);
void refresh();

private:
QTabWidget *_tab = nullptr;
int _syncErrorTabId = -1;
signals:
void refreshCoreIcons();

protected:
void updateColorScheme(Qt::ColorScheme colorScheme);
};

}
13 changes: 10 additions & 3 deletions src/gui/mainwindow/mainwindowcontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@

#include "aboutview.h"
#include "application.h"
#include "iconresources.h"
#include "colormanager.h"
#include "guiutility.h"
#include "iconresources.h"
#include "localactivitywidget.h"
#include "mainwindow.h"
#include "modalwrapperwidget.h"
Expand All @@ -35,7 +36,10 @@ MainWindowController::MainWindowController(MainWindow *window, QObject *parent)
: QObject{parent}
, _window(window)
{
// this is going to move so it can be passed around by injection or connected externally, but starting with it here:
_colorManager = new ColorManager(this);
setup();
_colorManager->refresh();
}

void MainWindowController::setup()
Expand Down Expand Up @@ -118,7 +122,9 @@ void MainWindowController::buildMenuActions()
void MainWindowController::createSyncErrorsAction()
{
QAction *syncErrorsAction = new QAction(tr("Errors: %1").arg(0), this);
syncErrorsAction->setIcon(IconResources::getCoreIcon("states/error"));
// syncErrorsAction->setIcon(IconResources::getCoreIcon("states/error"));
_colorManager->addActionIcon(syncErrorsAction, "states/error");

syncErrorsAction->setObjectName("syncErrorsAction");
syncErrorsAction->setCheckable(true);
auto syncErrorWidget = new SyncErrorWidget(_window);
Expand All @@ -132,7 +138,8 @@ void MainWindowController::createSyncErrorsAction()
void MainWindowController::createActivityAction()
{
QAction *activityAction = new QAction(tr("Activity"), this);
activityAction->setIcon(IconResources::getCoreIcon("states/sync"));
// activityAction->setIcon(IconResources::getCoreIcon("states/sync"));
_colorManager->addActionIcon(activityAction, "states/sync");
activityAction->setObjectName("activityAction");
activityAction->setCheckable(true);
auto localActivityWidget = new LocalActivityWidget(_window);
Expand Down
2 changes: 2 additions & 0 deletions src/gui/mainwindow/mainwindowcontroller.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ namespace OCC {

class MainWindow;
class AccountsGuiController;
class ColorManager;

class MainWindowController : public QObject
{
Expand All @@ -48,5 +49,6 @@ class MainWindowController : public QObject
void onQuit();

MainWindow *_window = nullptr;
ColorManager *_colorManager = nullptr;
};
}