diff --git a/CMakeLists.txt b/CMakeLists.txt index cf494edf8..f807a9c8d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -482,9 +482,6 @@ set(${PROJECT_NAME}_SOURCES src/widget/translator.h src/widget/widget.cpp src/widget/widget.h - src/widget/widgetstyle.h - src/widget/framestyle.h - src/widget/dialogstyle.h ) if (${CMAKE_SYSTEM_NAME} MATCHES "Windows") diff --git a/src/chatlog/content/filetransferwidget.cpp b/src/chatlog/content/filetransferwidget.cpp index 436c74710..6e62d5a59 100644 --- a/src/chatlog/content/filetransferwidget.cpp +++ b/src/chatlog/content/filetransferwidget.cpp @@ -48,7 +48,7 @@ // downloaded to. FileTransferWidget::FileTransferWidget(QWidget* parent, CoreFile& _coreFile, ToxFile file) - : WidgetStyle(parent) + : QWidget(parent) , coreFile{_coreFile} , ui(new Ui::FileTransferWidget) , fileInfo(file) @@ -90,6 +90,8 @@ FileTransferWidget::FileTransferWidget(QWidget* parent, CoreFile& _coreFile, Tox connect(ui->previewButton, &QPushButton::clicked, this, &FileTransferWidget::onPreviewButtonClicked); + connect(&GUI::getInstance(), &GUI::themeReload, this, &FileTransferWidget::reloadTheme); + // Set lastStatus to anything but the file's current value, this forces an update lastStatus = file.status == ToxFile::FINISHED ? ToxFile::INITIALIZING : ToxFile::FINISHED; updateWidget(file); diff --git a/src/chatlog/content/filetransferwidget.h b/src/chatlog/content/filetransferwidget.h index c41f13ff2..88face59d 100644 --- a/src/chatlog/content/filetransferwidget.h +++ b/src/chatlog/content/filetransferwidget.h @@ -20,11 +20,11 @@ #pragma once #include +#include #include "src/chatlog/chatlinecontent.h" #include "src/chatlog/toxfileprogress.h" #include "src/core/toxfile.h" -#include "src/widget/widgetstyle.h" class CoreFile; @@ -35,7 +35,7 @@ class FileTransferWidget; class QVariantAnimation; class QPushButton; -class FileTransferWidget : public WidgetStyle +class FileTransferWidget : public QWidget { Q_OBJECT @@ -65,7 +65,7 @@ protected: void paintEvent(QPaintEvent*) final; public slots: - void reloadTheme() override; + void reloadTheme(); private slots: void onLeftButtonClicked(); diff --git a/src/widget/about/aboutfriendform.cpp b/src/widget/about/aboutfriendform.cpp index a00543cdc..ea27f22a0 100644 --- a/src/widget/about/aboutfriendform.cpp +++ b/src/widget/about/aboutfriendform.cpp @@ -27,7 +27,7 @@ #include AboutFriendForm::AboutFriendForm(std::unique_ptr _about, QWidget* parent) - : DialogStyle(parent) + : QDialog(parent) , ui(new Ui::AboutFriendForm) , about{std::move(_about)} { @@ -67,6 +67,8 @@ AboutFriendForm::AboutFriendForm(std::unique_ptr _about, QWidget* ui->statusMessage->setText(about->getStatusMessage()); ui->avatar->setPixmap(about->getAvatar()); + connect(&GUI::getInstance(), &GUI::themeReload, this, &AboutFriendForm::reloadTheme); + reloadTheme(); } diff --git a/src/widget/about/aboutfriendform.h b/src/widget/about/aboutfriendform.h index 7148bdc76..c9088c3d0 100644 --- a/src/widget/about/aboutfriendform.h +++ b/src/widget/about/aboutfriendform.h @@ -20,8 +20,8 @@ #pragma once #include "src/model/about/iaboutfriend.h" -#include "src/widget/dialogstyle.h" +#include #include #include @@ -30,7 +30,7 @@ namespace Ui { class AboutFriendForm; } -class AboutFriendForm : public DialogStyle +class AboutFriendForm : public QDialog { Q_OBJECT @@ -46,7 +46,7 @@ signals: void histroyRemoved(); public slots: - void reloadTheme() override; + void reloadTheme(); private slots: void onAutoAcceptDirChanged(const QString& path); diff --git a/src/widget/chatformheader.cpp b/src/widget/chatformheader.cpp index 4a108efa4..6cd708054 100644 --- a/src/widget/chatformheader.cpp +++ b/src/widget/chatformheader.cpp @@ -19,6 +19,7 @@ #include "chatformheader.h" +#include "src/widget/gui.h" #include "src/widget/maskablepixmapwidget.h" #include "src/widget/style.h" #include "src/widget/tool/callconfirmwidget.h" @@ -105,7 +106,7 @@ void setStateName(QAbstractButton* btn, State state) } ChatFormHeader::ChatFormHeader(QWidget* parent) - : WidgetStyle(parent) + : QWidget(parent) , mode{Mode::AV} , callState{CallButtonState::Disabled} , videoState{CallButtonState::Disabled} @@ -154,6 +155,8 @@ ChatFormHeader::ChatFormHeader(QWidget* parent) updateButtonsView(); Translator::registerHandler(std::bind(&ChatFormHeader::retranslateUi, this), this); + + connect(&GUI::getInstance(), &GUI::themeReload, this, &ChatFormHeader::reloadTheme); } ChatFormHeader::~ChatFormHeader() = default; diff --git a/src/widget/chatformheader.h b/src/widget/chatformheader.h index 31db65451..7e39a8f23 100644 --- a/src/widget/chatformheader.h +++ b/src/widget/chatformheader.h @@ -19,8 +19,9 @@ #pragma once +#include + #include -#include "src/widget/widgetstyle.h" class MaskablePixmapWidget; class QVBoxLayout; @@ -29,7 +30,7 @@ class QPushButton; class QToolButton; class CallConfirmWidget; -class ChatFormHeader : public WidgetStyle +class ChatFormHeader : public QWidget { Q_OBJECT public: @@ -76,7 +77,7 @@ public: void addStretch(); public slots: - void reloadTheme() override; + void reloadTheme(); signals: void callTriggered(); diff --git a/src/widget/dialogstyle.h b/src/widget/dialogstyle.h deleted file mode 100644 index c737e33b4..000000000 --- a/src/widget/dialogstyle.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef DIALOGSTYLE_H -#define DIALOGSTYLE_H - -#include -#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 diff --git a/src/widget/form/genericchatform.cpp b/src/widget/form/genericchatform.cpp index 68ca69f6d..10d974c1d 100644 --- a/src/widget/form/genericchatform.cpp +++ b/src/widget/form/genericchatform.cpp @@ -36,6 +36,7 @@ #include "src/widget/contentlayout.h" #include "src/widget/emoticonswidget.h" #include "src/widget/form/chatform.h" +#include "src/widget/gui.h" #include "src/widget/maskablepixmapwidget.h" #include "src/widget/searchform.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, IMessageDispatcher& messageDispatcher, QWidget* parent) - : WidgetStyle(parent, Qt::Window) + : QWidget(parent, Qt::Window) , core{_core} , audioInputFlag(false) , audioOutputFlag(false) @@ -335,6 +336,8 @@ GenericChatForm::GenericChatForm(const Core& _core, const Contact* contact, ICha connect(msgEdit, &ChatTextEdit::enterPressed, this, &GenericChatForm::onSendTriggered); + connect(&GUI::getInstance(), &GUI::themeReload, this, &GenericChatForm::reloadTheme); + reloadTheme(); fileFlyout->setFixedSize(FILE_FLYOUT_SIZE); diff --git a/src/widget/form/genericchatform.h b/src/widget/form/genericchatform.h index 4eb0160f9..01a2c1f8f 100644 --- a/src/widget/form/genericchatform.h +++ b/src/widget/form/genericchatform.h @@ -24,9 +24,9 @@ #include "src/model/ichatlog.h" #include "src/widget/form/loadhistorydialog.h" #include "src/widget/searchtypes.h" -#include "src/widget/widgetstyle.h" #include +#include /** * Spacing in px inserted when the author of the last message changes @@ -65,7 +65,7 @@ class SpellCheckDecorator; } #endif -class GenericChatForm : public WidgetStyle +class GenericChatForm : public QWidget { Q_OBJECT public: @@ -90,7 +90,7 @@ public slots: void focusInput(); void onChatMessageFontChanged(const QFont& font); void setColorizedNames(bool enable); - void reloadTheme() override; + virtual void reloadTheme(); protected slots: void onChatContextMenuRequested(QPoint pos); diff --git a/src/widget/form/settings/genericsettings.cpp b/src/widget/form/settings/genericsettings.cpp index dcd372a9d..383059bae 100644 --- a/src/widget/form/settings/genericsettings.cpp +++ b/src/widget/form/settings/genericsettings.cpp @@ -18,6 +18,7 @@ */ #include "genericsettings.h" +#include "src/widget/gui.h" #include #include @@ -34,6 +35,7 @@ GenericForm::GenericForm(const QPixmap& icon) : formIcon(icon) { + connect(&GUI::getInstance(), &GUI::themeReload, this, &GenericForm::reloadTheme); } QPixmap GenericForm::getFormIcon() diff --git a/src/widget/form/settings/genericsettings.h b/src/widget/form/settings/genericsettings.h index ef1467290..eeee88d5a 100644 --- a/src/widget/form/settings/genericsettings.h +++ b/src/widget/form/settings/genericsettings.h @@ -19,9 +19,9 @@ #pragma once -#include "src/widget/widgetstyle.h" +#include -class GenericForm : public WidgetStyle +class GenericForm : public QWidget { Q_OBJECT public: @@ -33,6 +33,9 @@ public: virtual QString getFormName() = 0; QPixmap getFormIcon(); +public slots: + virtual void reloadTheme() {} + protected: bool eventFilter(QObject* o, QEvent* e) final; void eventsInit(); diff --git a/src/widget/framestyle.h b/src/widget/framestyle.h deleted file mode 100644 index 7261a4c9a..000000000 --- a/src/widget/framestyle.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef FRAMESTYLE_H -#define FRAMESTYLE_H - -#include -#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 diff --git a/src/widget/genericchatitemwidget.cpp b/src/widget/genericchatitemwidget.cpp index 8e6262437..93ce36084 100644 --- a/src/widget/genericchatitemwidget.cpp +++ b/src/widget/genericchatitemwidget.cpp @@ -20,10 +20,11 @@ #include "genericchatitemwidget.h" #include "src/persistence/settings.h" #include "src/widget/tool/croppinglabel.h" +#include "src/widget/gui.h" #include GenericChatItemWidget::GenericChatItemWidget(bool compact, QWidget* parent) - : FrameStyle(parent) + : QFrame(parent) , compact(false) { setProperty("compact", compact); @@ -31,6 +32,8 @@ GenericChatItemWidget::GenericChatItemWidget(bool compact, QWidget* parent) nameLabel = new CroppingLabel(this); nameLabel->setObjectName("name"); nameLabel->setTextFormat(Qt::PlainText); + + connect(&GUI::getInstance(), &GUI::themeReload, this, &GenericChatItemWidget::reloadTheme); } bool GenericChatItemWidget::isCompact() const diff --git a/src/widget/genericchatitemwidget.h b/src/widget/genericchatitemwidget.h index 2adc2dbed..a1741eff7 100644 --- a/src/widget/genericchatitemwidget.h +++ b/src/widget/genericchatitemwidget.h @@ -20,11 +20,11 @@ #pragma once #include -#include "src/widget/framestyle.h" +#include class CroppingLabel; -class GenericChatItemWidget : public FrameStyle +class GenericChatItemWidget : public QFrame { Q_OBJECT public: @@ -46,6 +46,9 @@ public: Q_PROPERTY(bool compact READ isCompact WRITE setCompact) +public slots: + virtual void reloadTheme() {} + protected: CroppingLabel* nameLabel; QLabel statusPic; diff --git a/src/widget/gui.cpp b/src/widget/gui.cpp index 708cf5a1e..a3c5c6cc5 100644 --- a/src/widget/gui.cpp +++ b/src/widget/gui.cpp @@ -94,6 +94,9 @@ void GUI::setWindowTitle(const QString& title) /** * @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() { diff --git a/src/widget/searchform.cpp b/src/widget/searchform.cpp index 5c91b6387..d9f29482d 100644 --- a/src/widget/searchform.cpp +++ b/src/widget/searchform.cpp @@ -19,6 +19,7 @@ #include "searchform.h" #include "form/searchsettingsform.h" +#include "src/widget/gui.h" #include "src/widget/style.h" #include @@ -35,7 +36,7 @@ static std::array STATE_NAME = { QStringLiteral("red"), }; -SearchForm::SearchForm(QWidget* parent) : WidgetStyle(parent) +SearchForm::SearchForm(QWidget* parent) : QWidget(parent) { QVBoxLayout* layout = new QVBoxLayout(); QHBoxLayout* layoutNavigation = new QHBoxLayout(); @@ -91,6 +92,8 @@ SearchForm::SearchForm(QWidget* parent) : WidgetStyle(parent) connect(settingsButton, &QPushButton::clicked, this, &SearchForm::clickedSearch); connect(settings, &SearchSettingsForm::updateSettings, this, &SearchForm::changedState); + + connect(&GUI::getInstance(), &GUI::themeReload, this, &SearchForm::reloadTheme); } void SearchForm::removeSearchPhrase() diff --git a/src/widget/searchform.h b/src/widget/searchform.h index cf01de2dc..04d72dae2 100644 --- a/src/widget/searchform.h +++ b/src/widget/searchform.h @@ -19,8 +19,8 @@ #pragma once +#include #include -#include "src/widget/widgetstyle.h" #include "searchtypes.h" class QPushButton; @@ -28,7 +28,7 @@ class QLabel; class LineEdit; class SearchSettingsForm; -class SearchForm final : public WidgetStyle +class SearchForm final : public QWidget { Q_OBJECT public: @@ -83,7 +83,7 @@ private slots: public slots: void showMessageNotFound(SearchDirection direction); - void reloadTheme() override; + void reloadTheme(); signals: void searchInBegin(const QString& phrase, const ParameterSearch& parameter); diff --git a/src/widget/tool/activatedialog.cpp b/src/widget/tool/activatedialog.cpp index 5c347825a..2af70b086 100644 --- a/src/widget/tool/activatedialog.cpp +++ b/src/widget/tool/activatedialog.cpp @@ -19,11 +19,13 @@ #include "activatedialog.h" +#include "src/widget/gui.h" #include 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) diff --git a/src/widget/tool/activatedialog.h b/src/widget/tool/activatedialog.h index 29e87b99e..52a43ebd8 100644 --- a/src/widget/tool/activatedialog.h +++ b/src/widget/tool/activatedialog.h @@ -19,9 +19,9 @@ #pragma once -#include "src/widget/dialogstyle.h" +#include -class ActivateDialog : public DialogStyle +class ActivateDialog : public QDialog { Q_OBJECT public: @@ -32,6 +32,9 @@ public: #endif bool event(QEvent* event) override; +public slots: + virtual void reloadTheme() {} + signals: void windowStateChanged(Qt::WindowStates state); }; diff --git a/src/widget/widgetstyle.h b/src/widget/widgetstyle.h deleted file mode 100644 index ff468b163..000000000 --- a/src/widget/widgetstyle.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef WIDGETSTYLE_H -#define WIDGETSTYLE_H - -#include -#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