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/widget.cpp
src/widget/widget.h
src/widget/widgetstyle.h
src/widget/framestyle.h
src/widget/dialogstyle.h
)
if (${CMAKE_SYSTEM_NAME} MATCHES "Windows")

View File

@ -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);

View File

@ -20,11 +20,11 @@
#pragma once
#include <QTime>
#include <QWidget>
#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();

View File

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

View File

@ -20,8 +20,8 @@
#pragma once
#include "src/model/about/iaboutfriend.h"
#include "src/widget/dialogstyle.h"
#include <QDialog>
#include <QPointer>
#include <memory>
@ -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);

View File

@ -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;

View File

@ -19,8 +19,9 @@
#pragma once
#include <QWidget>
#include <memory>
#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();

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/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);

View File

@ -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 <QMenu>
#include <QWidget>
/**
* 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);

View File

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

View File

@ -19,9 +19,9 @@
#pragma once
#include "src/widget/widgetstyle.h"
#include <QWidget>
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();

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 "src/persistence/settings.h"
#include "src/widget/tool/croppinglabel.h"
#include "src/widget/gui.h"
#include <QVariant>
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

View File

@ -20,11 +20,11 @@
#pragma once
#include <QLabel>
#include "src/widget/framestyle.h"
#include <QFrame>
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;

View File

@ -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()
{

View File

@ -19,6 +19,7 @@
#include "searchform.h"
#include "form/searchsettingsform.h"
#include "src/widget/gui.h"
#include "src/widget/style.h"
#include <QVBoxLayout>
@ -35,7 +36,7 @@ static std::array<QString, 3> 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()

View File

@ -19,8 +19,8 @@
#pragma once
#include <QWidget>
#include <QLineEdit>
#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);

View File

@ -19,11 +19,13 @@
#include "activatedialog.h"
#include "src/widget/gui.h"
#include <QEvent>
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)

View File

@ -19,9 +19,9 @@
#pragma once
#include "src/widget/dialogstyle.h"
#include <QDialog>
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);
};

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