1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

refactor: delete classes that were used to reload theme

This commit is contained in:
TriKriSta 2020-01-16 17:18:35 +02:00 committed by Anthony Bilinski
parent 3bf3128a4f
commit b11a09d3e4
No known key found for this signature in database
GPG Key ID: 2AA8E0DA1B31FB3C
21 changed files with 61 additions and 94 deletions

View File

@ -482,9 +482,6 @@ set(${PROJECT_NAME}_SOURCES
src/widget/translator.h src/widget/translator.h
src/widget/widget.cpp src/widget/widget.cpp
src/widget/widget.h src/widget/widget.h
src/widget/widgetstyle.h
src/widget/framestyle.h
src/widget/dialogstyle.h
) )
if (${CMAKE_SYSTEM_NAME} MATCHES "Windows") if (${CMAKE_SYSTEM_NAME} MATCHES "Windows")

View File

@ -48,7 +48,7 @@
// downloaded to. // downloaded to.
FileTransferWidget::FileTransferWidget(QWidget* parent, CoreFile& _coreFile, ToxFile file) FileTransferWidget::FileTransferWidget(QWidget* parent, CoreFile& _coreFile, ToxFile file)
: WidgetStyle(parent) : QWidget(parent)
, coreFile{_coreFile} , coreFile{_coreFile}
, ui(new Ui::FileTransferWidget) , ui(new Ui::FileTransferWidget)
, fileInfo(file) , fileInfo(file)
@ -90,6 +90,8 @@ FileTransferWidget::FileTransferWidget(QWidget* parent, CoreFile& _coreFile, Tox
connect(ui->previewButton, &QPushButton::clicked, this, connect(ui->previewButton, &QPushButton::clicked, this,
&FileTransferWidget::onPreviewButtonClicked); &FileTransferWidget::onPreviewButtonClicked);
connect(&GUI::getInstance(), &GUI::themeReload, this, &FileTransferWidget::reloadTheme);
// Set lastStatus to anything but the file's current value, this forces an update // Set lastStatus to anything but the file's current value, this forces an update
lastStatus = file.status == ToxFile::FINISHED ? ToxFile::INITIALIZING : ToxFile::FINISHED; lastStatus = file.status == ToxFile::FINISHED ? ToxFile::INITIALIZING : ToxFile::FINISHED;
updateWidget(file); updateWidget(file);

View File

@ -20,11 +20,11 @@
#pragma once #pragma once
#include <QTime> #include <QTime>
#include <QWidget>
#include "src/chatlog/chatlinecontent.h" #include "src/chatlog/chatlinecontent.h"
#include "src/chatlog/toxfileprogress.h" #include "src/chatlog/toxfileprogress.h"
#include "src/core/toxfile.h" #include "src/core/toxfile.h"
#include "src/widget/widgetstyle.h"
class CoreFile; class CoreFile;
@ -35,7 +35,7 @@ class FileTransferWidget;
class QVariantAnimation; class QVariantAnimation;
class QPushButton; class QPushButton;
class FileTransferWidget : public WidgetStyle class FileTransferWidget : public QWidget
{ {
Q_OBJECT Q_OBJECT
@ -65,7 +65,7 @@ protected:
void paintEvent(QPaintEvent*) final; void paintEvent(QPaintEvent*) final;
public slots: public slots:
void reloadTheme() override; void reloadTheme();
private slots: private slots:
void onLeftButtonClicked(); void onLeftButtonClicked();

View File

@ -27,7 +27,7 @@
#include <QMessageBox> #include <QMessageBox>
AboutFriendForm::AboutFriendForm(std::unique_ptr<IAboutFriend> _about, QWidget* parent) AboutFriendForm::AboutFriendForm(std::unique_ptr<IAboutFriend> _about, QWidget* parent)
: DialogStyle(parent) : QDialog(parent)
, ui(new Ui::AboutFriendForm) , ui(new Ui::AboutFriendForm)
, about{std::move(_about)} , about{std::move(_about)}
{ {
@ -67,6 +67,8 @@ AboutFriendForm::AboutFriendForm(std::unique_ptr<IAboutFriend> _about, QWidget*
ui->statusMessage->setText(about->getStatusMessage()); ui->statusMessage->setText(about->getStatusMessage());
ui->avatar->setPixmap(about->getAvatar()); ui->avatar->setPixmap(about->getAvatar());
connect(&GUI::getInstance(), &GUI::themeReload, this, &AboutFriendForm::reloadTheme);
reloadTheme(); reloadTheme();
} }

View File

@ -20,8 +20,8 @@
#pragma once #pragma once
#include "src/model/about/iaboutfriend.h" #include "src/model/about/iaboutfriend.h"
#include "src/widget/dialogstyle.h"
#include <QDialog>
#include <QPointer> #include <QPointer>
#include <memory> #include <memory>
@ -30,7 +30,7 @@ namespace Ui {
class AboutFriendForm; class AboutFriendForm;
} }
class AboutFriendForm : public DialogStyle class AboutFriendForm : public QDialog
{ {
Q_OBJECT Q_OBJECT
@ -46,7 +46,7 @@ signals:
void histroyRemoved(); void histroyRemoved();
public slots: public slots:
void reloadTheme() override; void reloadTheme();
private slots: private slots:
void onAutoAcceptDirChanged(const QString& path); void onAutoAcceptDirChanged(const QString& path);

View File

@ -19,6 +19,7 @@
#include "chatformheader.h" #include "chatformheader.h"
#include "src/widget/gui.h"
#include "src/widget/maskablepixmapwidget.h" #include "src/widget/maskablepixmapwidget.h"
#include "src/widget/style.h" #include "src/widget/style.h"
#include "src/widget/tool/callconfirmwidget.h" #include "src/widget/tool/callconfirmwidget.h"
@ -105,7 +106,7 @@ void setStateName(QAbstractButton* btn, State state)
} }
ChatFormHeader::ChatFormHeader(QWidget* parent) ChatFormHeader::ChatFormHeader(QWidget* parent)
: WidgetStyle(parent) : QWidget(parent)
, mode{Mode::AV} , mode{Mode::AV}
, callState{CallButtonState::Disabled} , callState{CallButtonState::Disabled}
, videoState{CallButtonState::Disabled} , videoState{CallButtonState::Disabled}
@ -154,6 +155,8 @@ ChatFormHeader::ChatFormHeader(QWidget* parent)
updateButtonsView(); updateButtonsView();
Translator::registerHandler(std::bind(&ChatFormHeader::retranslateUi, this), this); Translator::registerHandler(std::bind(&ChatFormHeader::retranslateUi, this), this);
connect(&GUI::getInstance(), &GUI::themeReload, this, &ChatFormHeader::reloadTheme);
} }
ChatFormHeader::~ChatFormHeader() = default; ChatFormHeader::~ChatFormHeader() = default;

View File

@ -19,8 +19,9 @@
#pragma once #pragma once
#include <QWidget>
#include <memory> #include <memory>
#include "src/widget/widgetstyle.h"
class MaskablePixmapWidget; class MaskablePixmapWidget;
class QVBoxLayout; class QVBoxLayout;
@ -29,7 +30,7 @@ class QPushButton;
class QToolButton; class QToolButton;
class CallConfirmWidget; class CallConfirmWidget;
class ChatFormHeader : public WidgetStyle class ChatFormHeader : public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
@ -76,7 +77,7 @@ public:
void addStretch(); void addStretch();
public slots: public slots:
void reloadTheme() override; void reloadTheme();
signals: signals:
void callTriggered(); void callTriggered();

View File

@ -1,21 +0,0 @@
#ifndef DIALOGSTYLE_H
#define DIALOGSTYLE_H
#include <QDialog>
#include "src/widget/gui.h"
class DialogStyle : public QDialog {
Q_OBJECT
public:
DialogStyle(QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags()) : QDialog(parent, f)
{
connect(&GUI::getInstance(), &GUI::themeReload, this, &DialogStyle::reloadTheme);
}
virtual ~DialogStyle() {}
public slots:
virtual void reloadTheme() {}
};
#endif //DIALOGSTYLE_H

View File

@ -36,6 +36,7 @@
#include "src/widget/contentlayout.h" #include "src/widget/contentlayout.h"
#include "src/widget/emoticonswidget.h" #include "src/widget/emoticonswidget.h"
#include "src/widget/form/chatform.h" #include "src/widget/form/chatform.h"
#include "src/widget/gui.h"
#include "src/widget/maskablepixmapwidget.h" #include "src/widget/maskablepixmapwidget.h"
#include "src/widget/searchform.h" #include "src/widget/searchform.h"
#include "src/widget/style.h" #include "src/widget/style.h"
@ -210,7 +211,7 @@ ChatLogIdx firstItemAfterDate(QDate date, const IChatLog& chatLog)
GenericChatForm::GenericChatForm(const Core& _core, const Contact* contact, IChatLog& chatLog, GenericChatForm::GenericChatForm(const Core& _core, const Contact* contact, IChatLog& chatLog,
IMessageDispatcher& messageDispatcher, QWidget* parent) IMessageDispatcher& messageDispatcher, QWidget* parent)
: WidgetStyle(parent, Qt::Window) : QWidget(parent, Qt::Window)
, core{_core} , core{_core}
, audioInputFlag(false) , audioInputFlag(false)
, audioOutputFlag(false) , audioOutputFlag(false)
@ -335,6 +336,8 @@ GenericChatForm::GenericChatForm(const Core& _core, const Contact* contact, ICha
connect(msgEdit, &ChatTextEdit::enterPressed, this, &GenericChatForm::onSendTriggered); connect(msgEdit, &ChatTextEdit::enterPressed, this, &GenericChatForm::onSendTriggered);
connect(&GUI::getInstance(), &GUI::themeReload, this, &GenericChatForm::reloadTheme);
reloadTheme(); reloadTheme();
fileFlyout->setFixedSize(FILE_FLYOUT_SIZE); fileFlyout->setFixedSize(FILE_FLYOUT_SIZE);

View File

@ -24,9 +24,9 @@
#include "src/model/ichatlog.h" #include "src/model/ichatlog.h"
#include "src/widget/form/loadhistorydialog.h" #include "src/widget/form/loadhistorydialog.h"
#include "src/widget/searchtypes.h" #include "src/widget/searchtypes.h"
#include "src/widget/widgetstyle.h"
#include <QMenu> #include <QMenu>
#include <QWidget>
/** /**
* Spacing in px inserted when the author of the last message changes * Spacing in px inserted when the author of the last message changes
@ -65,7 +65,7 @@ class SpellCheckDecorator;
} }
#endif #endif
class GenericChatForm : public WidgetStyle class GenericChatForm : public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
@ -90,7 +90,7 @@ public slots:
void focusInput(); void focusInput();
void onChatMessageFontChanged(const QFont& font); void onChatMessageFontChanged(const QFont& font);
void setColorizedNames(bool enable); void setColorizedNames(bool enable);
void reloadTheme() override; virtual void reloadTheme();
protected slots: protected slots:
void onChatContextMenuRequested(QPoint pos); void onChatContextMenuRequested(QPoint pos);

View File

@ -18,6 +18,7 @@
*/ */
#include "genericsettings.h" #include "genericsettings.h"
#include "src/widget/gui.h"
#include <QCheckBox> #include <QCheckBox>
#include <QComboBox> #include <QComboBox>
@ -34,6 +35,7 @@
GenericForm::GenericForm(const QPixmap& icon) GenericForm::GenericForm(const QPixmap& icon)
: formIcon(icon) : formIcon(icon)
{ {
connect(&GUI::getInstance(), &GUI::themeReload, this, &GenericForm::reloadTheme);
} }
QPixmap GenericForm::getFormIcon() QPixmap GenericForm::getFormIcon()

View File

@ -19,9 +19,9 @@
#pragma once #pragma once
#include "src/widget/widgetstyle.h" #include <QWidget>
class GenericForm : public WidgetStyle class GenericForm : public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
@ -33,6 +33,9 @@ public:
virtual QString getFormName() = 0; virtual QString getFormName() = 0;
QPixmap getFormIcon(); QPixmap getFormIcon();
public slots:
virtual void reloadTheme() {}
protected: protected:
bool eventFilter(QObject* o, QEvent* e) final; bool eventFilter(QObject* o, QEvent* e) final;
void eventsInit(); void eventsInit();

View File

@ -1,21 +0,0 @@
#ifndef FRAMESTYLE_H
#define FRAMESTYLE_H
#include <QFrame>
#include "src/widget/gui.h"
class FrameStyle : public QFrame {
Q_OBJECT
public:
FrameStyle(QWidget* parent = nullptr) : QFrame(parent)
{
connect(&GUI::getInstance(), &GUI::themeReload, this, &FrameStyle::reloadTheme);
}
virtual ~FrameStyle() {}
public slots:
virtual void reloadTheme() {}
};
#endif //FRAMESTYLE_H

View File

@ -20,10 +20,11 @@
#include "genericchatitemwidget.h" #include "genericchatitemwidget.h"
#include "src/persistence/settings.h" #include "src/persistence/settings.h"
#include "src/widget/tool/croppinglabel.h" #include "src/widget/tool/croppinglabel.h"
#include "src/widget/gui.h"
#include <QVariant> #include <QVariant>
GenericChatItemWidget::GenericChatItemWidget(bool compact, QWidget* parent) GenericChatItemWidget::GenericChatItemWidget(bool compact, QWidget* parent)
: FrameStyle(parent) : QFrame(parent)
, compact(false) , compact(false)
{ {
setProperty("compact", compact); setProperty("compact", compact);
@ -31,6 +32,8 @@ GenericChatItemWidget::GenericChatItemWidget(bool compact, QWidget* parent)
nameLabel = new CroppingLabel(this); nameLabel = new CroppingLabel(this);
nameLabel->setObjectName("name"); nameLabel->setObjectName("name");
nameLabel->setTextFormat(Qt::PlainText); nameLabel->setTextFormat(Qt::PlainText);
connect(&GUI::getInstance(), &GUI::themeReload, this, &GenericChatItemWidget::reloadTheme);
} }
bool GenericChatItemWidget::isCompact() const bool GenericChatItemWidget::isCompact() const

View File

@ -20,11 +20,11 @@
#pragma once #pragma once
#include <QLabel> #include <QLabel>
#include "src/widget/framestyle.h" #include <QFrame>
class CroppingLabel; class CroppingLabel;
class GenericChatItemWidget : public FrameStyle class GenericChatItemWidget : public QFrame
{ {
Q_OBJECT Q_OBJECT
public: public:
@ -46,6 +46,9 @@ public:
Q_PROPERTY(bool compact READ isCompact WRITE setCompact) Q_PROPERTY(bool compact READ isCompact WRITE setCompact)
public slots:
virtual void reloadTheme() {}
protected: protected:
CroppingLabel* nameLabel; CroppingLabel* nameLabel;
QLabel statusPic; QLabel statusPic;

View File

@ -94,6 +94,9 @@ void GUI::setWindowTitle(const QString& title)
/** /**
* @brief Reloads the application theme and redraw the window. * @brief Reloads the application theme and redraw the window.
*
* For reload theme need connect signal themeReload() to function for reload
* For example: connect(&GUI::getInstance(), &GUI::themeReload, this, &SomeClass::reloadTheme);
*/ */
void GUI::reloadTheme() void GUI::reloadTheme()
{ {

View File

@ -19,6 +19,7 @@
#include "searchform.h" #include "searchform.h"
#include "form/searchsettingsform.h" #include "form/searchsettingsform.h"
#include "src/widget/gui.h"
#include "src/widget/style.h" #include "src/widget/style.h"
#include <QVBoxLayout> #include <QVBoxLayout>
@ -35,7 +36,7 @@ static std::array<QString, 3> STATE_NAME = {
QStringLiteral("red"), QStringLiteral("red"),
}; };
SearchForm::SearchForm(QWidget* parent) : WidgetStyle(parent) SearchForm::SearchForm(QWidget* parent) : QWidget(parent)
{ {
QVBoxLayout* layout = new QVBoxLayout(); QVBoxLayout* layout = new QVBoxLayout();
QHBoxLayout* layoutNavigation = new QHBoxLayout(); QHBoxLayout* layoutNavigation = new QHBoxLayout();
@ -91,6 +92,8 @@ SearchForm::SearchForm(QWidget* parent) : WidgetStyle(parent)
connect(settingsButton, &QPushButton::clicked, this, &SearchForm::clickedSearch); connect(settingsButton, &QPushButton::clicked, this, &SearchForm::clickedSearch);
connect(settings, &SearchSettingsForm::updateSettings, this, &SearchForm::changedState); connect(settings, &SearchSettingsForm::updateSettings, this, &SearchForm::changedState);
connect(&GUI::getInstance(), &GUI::themeReload, this, &SearchForm::reloadTheme);
} }
void SearchForm::removeSearchPhrase() void SearchForm::removeSearchPhrase()

View File

@ -19,8 +19,8 @@
#pragma once #pragma once
#include <QWidget>
#include <QLineEdit> #include <QLineEdit>
#include "src/widget/widgetstyle.h"
#include "searchtypes.h" #include "searchtypes.h"
class QPushButton; class QPushButton;
@ -28,7 +28,7 @@ class QLabel;
class LineEdit; class LineEdit;
class SearchSettingsForm; class SearchSettingsForm;
class SearchForm final : public WidgetStyle class SearchForm final : public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
@ -83,7 +83,7 @@ private slots:
public slots: public slots:
void showMessageNotFound(SearchDirection direction); void showMessageNotFound(SearchDirection direction);
void reloadTheme() override; void reloadTheme();
signals: signals:
void searchInBegin(const QString& phrase, const ParameterSearch& parameter); void searchInBegin(const QString& phrase, const ParameterSearch& parameter);

View File

@ -19,11 +19,13 @@
#include "activatedialog.h" #include "activatedialog.h"
#include "src/widget/gui.h"
#include <QEvent> #include <QEvent>
ActivateDialog::ActivateDialog(QWidget* parent, Qt::WindowFlags f) ActivateDialog::ActivateDialog(QWidget* parent, Qt::WindowFlags f)
: DialogStyle(parent, f) : QDialog(parent, f)
{ {
connect(&GUI::getInstance(), &GUI::themeReload, this, &ActivateDialog::reloadTheme);
} }
bool ActivateDialog::event(QEvent* event) bool ActivateDialog::event(QEvent* event)

View File

@ -19,9 +19,9 @@
#pragma once #pragma once
#include "src/widget/dialogstyle.h" #include <QDialog>
class ActivateDialog : public DialogStyle class ActivateDialog : public QDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
@ -32,6 +32,9 @@ public:
#endif #endif
bool event(QEvent* event) override; bool event(QEvent* event) override;
public slots:
virtual void reloadTheme() {}
signals: signals:
void windowStateChanged(Qt::WindowStates state); void windowStateChanged(Qt::WindowStates state);
}; };

View File

@ -1,21 +0,0 @@
#ifndef WIDGETSTYLE_H
#define WIDGETSTYLE_H
#include <QWidget>
#include "src/widget/gui.h"
class WidgetStyle : public QWidget {
Q_OBJECT
public:
WidgetStyle(QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags()) : QWidget(parent, f)
{
connect(&GUI::getInstance(), &GUI::themeReload, this, &WidgetStyle::reloadTheme);
}
virtual ~WidgetStyle() {}
public slots:
virtual void reloadTheme() {}
};
#endif //WIDGETSTYLE_H