refactor: some Application & style things (#5561)

This commit is contained in:
pajlada
2024-08-25 15:33:07 +02:00
committed by GitHub
parent ac88730563
commit 627c735524
41 changed files with 733 additions and 678 deletions
+5 -3
View File
@@ -16,6 +16,7 @@
#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
# include <QStyleHints>
#endif
#include <QApplication>
#include <cmath>
@@ -301,8 +302,9 @@ Theme::Theme(const Paths &paths)
this->loadAvailableThemes(paths);
#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
QObject::connect(qApp->styleHints(), &QStyleHints::colorSchemeChanged,
&this->lifetime_, [this] {
QObject::connect(QApplication::styleHints(),
&QStyleHints::colorSchemeChanged, &this->lifetime_,
[this] {
if (this->isSystemTheme())
{
this->update();
@@ -320,7 +322,7 @@ void Theme::update()
#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
if (this->isSystemTheme())
{
switch (qApp->styleHints()->colorScheme())
switch (QApplication::styleHints()->colorScheme())
{
case Qt::ColorScheme::Light:
return this->lightSystemThemeName;
+7 -1
View File
@@ -46,12 +46,18 @@ const QString CHATTERINO_OS = u"unknown"_s;
namespace chatterino {
Updates::Updates(const Paths &paths_)
Updates::Updates(const Paths &paths_, Settings &settings)
: paths(paths_)
, currentVersion_(CHATTERINO_VERSION)
, updateGuideLink_("https://chatterino.com")
{
qCDebug(chatterinoUpdate) << "init UpdateManager";
settings.betaUpdates.connect(
[this] {
this->checkForUpdates();
},
this->managedConnections, false);
}
/// Checks if the online version is newer or older than the current version.
+9 -1
View File
@@ -1,11 +1,16 @@
#pragma once
#include <pajlada/signals/scoped-connection.hpp>
#include <pajlada/signals/signal.hpp>
#include <QString>
#include <memory>
#include <vector>
namespace chatterino {
class Paths;
class Settings;
/**
* To check for updates, use the `checkForUpdates` method.
@@ -16,7 +21,7 @@ class Updates
const Paths &paths;
public:
explicit Updates(const Paths &paths_);
Updates(const Paths &paths_, Settings &settings);
enum Status {
None,
@@ -59,6 +64,9 @@ private:
QString updateGuideLink_;
void setStatus_(Status status);
std::vector<std::unique_ptr<pajlada::Signals::ScopedConnection>>
managedConnections;
};
} // namespace chatterino
+1 -3
View File
@@ -664,8 +664,6 @@ IndirectChannel WindowManager::decodeChannel(const SplitDescriptor &descriptor)
{
assertInGuiThread();
auto *app = getApp();
if (descriptor.type_ == "twitch")
{
return getApp()->getTwitch()->getOrAddChannel(descriptor.channelName_);
@@ -753,7 +751,7 @@ void WindowManager::applyWindowLayout(const WindowLayout &layout)
// get geometry
{
// out of bounds windows
auto screens = qApp->screens();
auto screens = QApplication::screens();
bool outOfBounds =
!qEnvironmentVariableIsSet("I3SOCK") &&
std::none_of(screens.begin(), screens.end(),
+3 -1
View File
@@ -4,6 +4,8 @@
#include "singletons/Settings.hpp"
#include "singletons/WindowManager.hpp"
#include <QApplication>
namespace chatterino {
void GIFTimer::initialize()
@@ -24,7 +26,7 @@ void GIFTimer::initialize()
QObject::connect(&this->timer, &QTimer::timeout, [this] {
if (getSettings()->animationsWhenFocused &&
qApp->activeWindow() == nullptr)
QApplication::activeWindow() == nullptr)
{
return;
}