mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
fix(ui): implement and connect reloadTheme in leaf classes
This allows leaf classes to update independently when the GUI has changed themes, without their parent having to call updateTheme() manually. Fix #5924 Fix #5592
This commit is contained in:
parent
0f5ba08fd2
commit
3bf3128a4f
|
@ -482,6 +482,9 @@ 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")
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include "chatlinecontentproxy.h"
|
||||
#include "chatmessage.h"
|
||||
#include "content/filetransferwidget.h"
|
||||
#include "src/widget/gui.h"
|
||||
#include "src/widget/translator.h"
|
||||
#include "src/widget/style.h"
|
||||
|
||||
|
@ -121,6 +122,9 @@ ChatLog::ChatLog(QWidget* parent)
|
|||
copySelectedText(true);
|
||||
});
|
||||
|
||||
connect(&GUI::getInstance(), &GUI::themeReload, this, &ChatLog::reloadTheme);
|
||||
|
||||
reloadTheme();
|
||||
retranslateUi();
|
||||
Translator::registerHandler(std::bind(&ChatLog::retranslateUi, this), this);
|
||||
}
|
||||
|
@ -718,6 +722,7 @@ void ChatLog::fontChanged(const QFont& font)
|
|||
|
||||
void ChatLog::reloadTheme()
|
||||
{
|
||||
setStyleSheet(Style::getStylesheet("chatArea/chatArea.css"));
|
||||
setBackgroundBrush(QBrush(Style::getColor(Style::GroundBase), Qt::SolidPattern));
|
||||
selectionRectColor = Style::getColor(Style::SelectText);
|
||||
selGraphItem->setBrush(QBrush(selectionRectColor));
|
||||
|
|
|
@ -56,7 +56,6 @@ public:
|
|||
void scrollToLine(ChatLine::Ptr line);
|
||||
void selectAll();
|
||||
void fontChanged(const QFont& font);
|
||||
void reloadTheme();
|
||||
void removeFirsts(const int num);
|
||||
void removeLasts(const int num);
|
||||
void setScroll(const bool scroll);
|
||||
|
@ -83,6 +82,7 @@ signals:
|
|||
|
||||
public slots:
|
||||
void forceRelayout();
|
||||
void reloadTheme();
|
||||
|
||||
private slots:
|
||||
void onSelectionTimerTimeout();
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
// downloaded to.
|
||||
|
||||
FileTransferWidget::FileTransferWidget(QWidget* parent, CoreFile& _coreFile, ToxFile file)
|
||||
: QWidget(parent)
|
||||
: WidgetStyle(parent)
|
||||
, coreFile{_coreFile}
|
||||
, ui(new Ui::FileTransferWidget)
|
||||
, fileInfo(file)
|
||||
|
@ -227,6 +227,11 @@ void FileTransferWidget::paintEvent(QPaintEvent*)
|
|||
}
|
||||
}
|
||||
|
||||
void FileTransferWidget::reloadTheme()
|
||||
{
|
||||
updateBackgroundColor(lastStatus);
|
||||
}
|
||||
|
||||
QString FileTransferWidget::getHumanReadableSize(qint64 size)
|
||||
{
|
||||
static const char* suffix[] = {"B", "KiB", "MiB", "GiB", "TiB"};
|
||||
|
@ -245,23 +250,7 @@ void FileTransferWidget::updateWidgetColor(ToxFile const& file)
|
|||
return;
|
||||
}
|
||||
|
||||
switch (file.status) {
|
||||
case ToxFile::INITIALIZING:
|
||||
case ToxFile::PAUSED:
|
||||
case ToxFile::TRANSMITTING:
|
||||
setBackgroundColor(Style::getColor(Style::TransferMiddle), false);
|
||||
break;
|
||||
case ToxFile::BROKEN:
|
||||
case ToxFile::CANCELED:
|
||||
setBackgroundColor(Style::getColor(Style::TransferBad), true);
|
||||
break;
|
||||
case ToxFile::FINISHED:
|
||||
setBackgroundColor(Style::getColor(Style::TransferGood), true);
|
||||
break;
|
||||
default:
|
||||
qCritical() << "Invalid file status";
|
||||
assert(false);
|
||||
}
|
||||
updateBackgroundColor(file.status);
|
||||
}
|
||||
|
||||
void FileTransferWidget::updateWidgetText(ToxFile const& file)
|
||||
|
@ -623,3 +612,24 @@ void FileTransferWidget::updateWidget(ToxFile const& file)
|
|||
update();
|
||||
}
|
||||
}
|
||||
|
||||
void FileTransferWidget::updateBackgroundColor(const ToxFile::FileStatus status)
|
||||
{
|
||||
switch (status) {
|
||||
case ToxFile::INITIALIZING:
|
||||
case ToxFile::PAUSED:
|
||||
case ToxFile::TRANSMITTING:
|
||||
setBackgroundColor(Style::getColor(Style::TransferMiddle), false);
|
||||
break;
|
||||
case ToxFile::BROKEN:
|
||||
case ToxFile::CANCELED:
|
||||
setBackgroundColor(Style::getColor(Style::TransferBad), true);
|
||||
break;
|
||||
case ToxFile::FINISHED:
|
||||
setBackgroundColor(Style::getColor(Style::TransferGood), true);
|
||||
break;
|
||||
default:
|
||||
qCritical() << "Invalid file status";
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 QWidget
|
||||
class FileTransferWidget : public WidgetStyle
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
@ -64,6 +64,9 @@ protected:
|
|||
|
||||
void paintEvent(QPaintEvent*) final;
|
||||
|
||||
public slots:
|
||||
void reloadTheme() override;
|
||||
|
||||
private slots:
|
||||
void onLeftButtonClicked();
|
||||
void onRightButtonClicked();
|
||||
|
@ -76,6 +79,7 @@ private:
|
|||
static bool tryRemoveFile(const QString &filepath);
|
||||
|
||||
void updateWidget(ToxFile const& file);
|
||||
void updateBackgroundColor(const ToxFile::FileStatus status);
|
||||
|
||||
private:
|
||||
CoreFile& coreFile;
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#include <QMessageBox>
|
||||
|
||||
AboutFriendForm::AboutFriendForm(std::unique_ptr<IAboutFriend> _about, QWidget* parent)
|
||||
: QDialog(parent)
|
||||
: DialogStyle(parent)
|
||||
, ui(new Ui::AboutFriendForm)
|
||||
, about{std::move(_about)}
|
||||
{
|
||||
|
@ -67,7 +67,7 @@ AboutFriendForm::AboutFriendForm(std::unique_ptr<IAboutFriend> _about, QWidget*
|
|||
ui->statusMessage->setText(about->getStatusMessage());
|
||||
ui->avatar->setPixmap(about->getAvatar());
|
||||
|
||||
setStyleSheet(Style::getStylesheet("window/general.css"));
|
||||
reloadTheme();
|
||||
}
|
||||
|
||||
static QString getAutoAcceptDir(const QString& dir)
|
||||
|
@ -90,6 +90,11 @@ void AboutFriendForm::onAutoAcceptDirClicked()
|
|||
about->setAutoAcceptDir(dir);
|
||||
}
|
||||
|
||||
void AboutFriendForm::reloadTheme()
|
||||
{
|
||||
setStyleSheet(Style::getStylesheet("window/general.css"));
|
||||
}
|
||||
|
||||
void AboutFriendForm::onAutoAcceptDirChanged(const QString& path)
|
||||
{
|
||||
const bool enabled = !path.isNull();
|
||||
|
|
|
@ -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 QDialog
|
||||
class AboutFriendForm : public DialogStyle
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
@ -45,6 +45,9 @@ private:
|
|||
signals:
|
||||
void histroyRemoved();
|
||||
|
||||
public slots:
|
||||
void reloadTheme() override;
|
||||
|
||||
private slots:
|
||||
void onAutoAcceptDirChanged(const QString& path);
|
||||
void onAcceptedClicked();
|
||||
|
|
|
@ -105,7 +105,7 @@ void setStateName(QAbstractButton* btn, State state)
|
|||
}
|
||||
|
||||
ChatFormHeader::ChatFormHeader(QWidget* parent)
|
||||
: QWidget(parent)
|
||||
: WidgetStyle(parent)
|
||||
, mode{Mode::AV}
|
||||
, callState{CallButtonState::Disabled}
|
||||
, videoState{CallButtonState::Disabled}
|
||||
|
@ -283,6 +283,7 @@ QSize ChatFormHeader::getAvatarSize() const
|
|||
|
||||
void ChatFormHeader::reloadTheme()
|
||||
{
|
||||
setStyleSheet(Style::getStylesheet("chatArea/chatHead.css"));
|
||||
callButton->setStyleSheet(Style::getStylesheet(STYLE_PATH));
|
||||
videoButton->setStyleSheet(Style::getStylesheet(STYLE_PATH));
|
||||
volButton->setStyleSheet(Style::getStylesheet(STYLE_PATH));
|
||||
|
|
|
@ -19,9 +19,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
#include <memory>
|
||||
#include "src/widget/widgetstyle.h"
|
||||
|
||||
class MaskablePixmapWidget;
|
||||
class QVBoxLayout;
|
||||
|
@ -30,7 +29,7 @@ class QPushButton;
|
|||
class QToolButton;
|
||||
class CallConfirmWidget;
|
||||
|
||||
class ChatFormHeader : public QWidget
|
||||
class ChatFormHeader : public WidgetStyle
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
@ -71,13 +70,14 @@ public:
|
|||
void setAvatar(const QPixmap& img);
|
||||
QSize getAvatarSize() const;
|
||||
|
||||
void reloadTheme();
|
||||
|
||||
// TODO: Remove
|
||||
void addWidget(QWidget* widget, int stretch = 0, Qt::Alignment alignment = Qt::Alignment());
|
||||
void addLayout(QLayout* layout);
|
||||
void addStretch();
|
||||
|
||||
public slots:
|
||||
void reloadTheme() override;
|
||||
|
||||
signals:
|
||||
void callTriggered();
|
||||
void videoCallTriggered();
|
||||
|
|
|
@ -59,8 +59,7 @@ ContentDialog::ContentDialog(const Core &core, QWidget* parent)
|
|||
, videoSurfaceSize(QSize())
|
||||
, videoCount(0)
|
||||
{
|
||||
const Settings& s = Settings::getInstance();
|
||||
setStyleSheet(Style::getStylesheet("contentDialog/contentDialog.css"));
|
||||
const Settings& s = Settings::getInstance();
|
||||
|
||||
friendLayout->setMargin(0);
|
||||
friendLayout->setSpacing(0);
|
||||
|
@ -88,7 +87,6 @@ ContentDialog::ContentDialog(const Core &core, QWidget* parent)
|
|||
friendScroll->setFrameStyle(QFrame::NoFrame);
|
||||
friendScroll->setLayoutDirection(Qt::RightToLeft);
|
||||
friendScroll->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
friendScroll->setStyleSheet(Style::getStylesheet("friendList/friendList.css"));
|
||||
friendScroll->setWidgetResizable(true);
|
||||
friendScroll->setWidget(friendWidget);
|
||||
|
||||
|
@ -128,6 +126,8 @@ ContentDialog::ContentDialog(const Core &core, QWidget* parent)
|
|||
|
||||
setAcceptDrops(true);
|
||||
|
||||
reloadTheme();
|
||||
|
||||
new QShortcut(Qt::CTRL + Qt::Key_Q, this, SLOT(close()));
|
||||
new QShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_Tab, this, SLOT(previousContact()));
|
||||
new QShortcut(Qt::CTRL + Qt::Key_Tab, this, SLOT(nextContact()));
|
||||
|
@ -435,6 +435,12 @@ void ContentDialog::setUsername(const QString& newName)
|
|||
updateTitleAndStatusIcon();
|
||||
}
|
||||
|
||||
void ContentDialog::reloadTheme()
|
||||
{
|
||||
setStyleSheet(Style::getStylesheet("contentDialog/contentDialog.css"));
|
||||
splitter->widget(0)->setStyleSheet(Style::getStylesheet("friendList/friendList.css"));
|
||||
}
|
||||
|
||||
bool ContentDialog::event(QEvent* event)
|
||||
{
|
||||
switch (event->type()) {
|
||||
|
|
|
@ -90,6 +90,7 @@ public slots:
|
|||
void previousContact();
|
||||
void nextContact();
|
||||
void setUsername(const QString& newName);
|
||||
void reloadTheme() override;
|
||||
|
||||
protected:
|
||||
bool event(QEvent* event) final;
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "contentlayout.h"
|
||||
#include "style.h"
|
||||
#include "src/persistence/settings.h"
|
||||
#include "src/widget/gui.h"
|
||||
#include <QFrame>
|
||||
#include <QStyleFactory>
|
||||
|
||||
|
@ -118,6 +119,8 @@ void ContentLayout::init()
|
|||
mainContent->setStyle(QStyleFactory::create(Settings::getInstance().getStyle()));
|
||||
}
|
||||
|
||||
connect(&GUI::getInstance(), &GUI::themeReload, this, &ContentLayout::reloadTheme);
|
||||
|
||||
reloadTheme();
|
||||
|
||||
mainHLineLayout.addSpacing(4);
|
||||
|
|
|
@ -29,7 +29,6 @@ public:
|
|||
explicit ContentLayout(QWidget* parent);
|
||||
~ContentLayout();
|
||||
|
||||
void reloadTheme();
|
||||
void clear();
|
||||
|
||||
QFrame mainHLine;
|
||||
|
@ -37,6 +36,9 @@ public:
|
|||
QWidget* mainContent;
|
||||
QWidget* mainHead;
|
||||
|
||||
public slots:
|
||||
void reloadTheme();
|
||||
|
||||
private:
|
||||
void init();
|
||||
};
|
||||
|
|
21
src/widget/dialogstyle.h
Normal file
21
src/widget/dialogstyle.h
Normal file
|
@ -0,0 +1,21 @@
|
|||
#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
|
|
@ -53,7 +53,6 @@ public:
|
|||
void setFriendTyping(bool isTyping);
|
||||
|
||||
void show(ContentLayout* contentLayout) final;
|
||||
void reloadTheme() final;
|
||||
|
||||
static const QString ACTION_PREFIX;
|
||||
|
||||
|
@ -76,6 +75,7 @@ public slots:
|
|||
void clearChatArea();
|
||||
void onShowMessagesClicked();
|
||||
void onSplitterMoved(int pos, int index);
|
||||
void reloadTheme() final;
|
||||
|
||||
private slots:
|
||||
void updateFriendActivityForFile(const ToxFile& file);
|
||||
|
|
|
@ -210,7 +210,7 @@ ChatLogIdx firstItemAfterDate(QDate date, const IChatLog& chatLog)
|
|||
|
||||
GenericChatForm::GenericChatForm(const Core& _core, const Contact* contact, IChatLog& chatLog,
|
||||
IMessageDispatcher& messageDispatcher, QWidget* parent)
|
||||
: QWidget(parent, Qt::Window)
|
||||
: WidgetStyle(parent, Qt::Window)
|
||||
, core{_core}
|
||||
, audioInputFlag(false)
|
||||
, audioOutputFlag(false)
|
||||
|
@ -414,12 +414,6 @@ void GenericChatForm::reloadTheme()
|
|||
msgEdit->setStyleSheet(Style::getStylesheet("msgEdit/msgEdit.css")
|
||||
+ fontToCss(s.getChatMessageFont(), "QTextEdit"));
|
||||
|
||||
chatWidget->setStyleSheet(Style::getStylesheet("chatArea/chatArea.css"));
|
||||
headWidget->setStyleSheet(Style::getStylesheet("chatArea/chatHead.css"));
|
||||
chatWidget->reloadTheme();
|
||||
headWidget->reloadTheme();
|
||||
searchForm->reloadTheme();
|
||||
|
||||
emoteButton->setStyleSheet(Style::getStylesheet(STYLE_PATH));
|
||||
fileButton->setStyleSheet(Style::getStylesheet(STYLE_PATH));
|
||||
screenshotButton->setStyleSheet(Style::getStylesheet(STYLE_PATH));
|
||||
|
|
|
@ -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 QWidget
|
||||
class GenericChatForm : public WidgetStyle
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
@ -75,7 +75,6 @@ public:
|
|||
|
||||
void setName(const QString& newName);
|
||||
virtual void show(ContentLayout* contentLayout);
|
||||
virtual void reloadTheme();
|
||||
|
||||
void addSystemInfoMessage(const QString& message, ChatMessage::SystemMessageType type,
|
||||
const QDateTime& datetime);
|
||||
|
@ -91,6 +90,7 @@ public slots:
|
|||
void focusInput();
|
||||
void onChatMessageFontChanged(const QFont& font);
|
||||
void setColorizedNames(bool enable);
|
||||
void reloadTheme() override;
|
||||
|
||||
protected slots:
|
||||
void onChatContextMenuRequested(QPoint pos);
|
||||
|
|
|
@ -182,6 +182,11 @@ void AboutForm::onUpdateCheckFailed()
|
|||
bodyUI->updateStack->setCurrentIndex(static_cast<int>(updateIndex::failed));
|
||||
}
|
||||
|
||||
void AboutForm::reloadTheme()
|
||||
{
|
||||
replaceVersions();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Creates hyperlink with specific style.
|
||||
* @param path The URL of the page the link goes to.
|
||||
|
|
|
@ -47,6 +47,7 @@ public slots:
|
|||
void onUpdateAvailable(QString latestVersion, QUrl link);
|
||||
void onUpToDate();
|
||||
void onUpdateCheckFailed();
|
||||
void reloadTheme() override;
|
||||
|
||||
private:
|
||||
void retranslateUi();
|
||||
|
|
|
@ -19,9 +19,9 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <QWidget>
|
||||
#include "src/widget/widgetstyle.h"
|
||||
|
||||
class GenericForm : public QWidget
|
||||
class GenericForm : public WidgetStyle
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
|
21
src/widget/framestyle.h
Normal file
21
src/widget/framestyle.h
Normal file
|
@ -0,0 +1,21 @@
|
|||
#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
|
|
@ -19,12 +19,11 @@
|
|||
|
||||
#include "genericchatitemwidget.h"
|
||||
#include "src/persistence/settings.h"
|
||||
#include "src/widget/style.h"
|
||||
#include "src/widget/tool/croppinglabel.h"
|
||||
#include <QVariant>
|
||||
|
||||
GenericChatItemWidget::GenericChatItemWidget(bool compact, QWidget* parent)
|
||||
: QFrame(parent)
|
||||
: FrameStyle(parent)
|
||||
, compact(false)
|
||||
{
|
||||
setProperty("compact", compact);
|
||||
|
|
|
@ -19,12 +19,12 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <QFrame>
|
||||
#include <QLabel>
|
||||
#include "src/widget/framestyle.h"
|
||||
|
||||
class CroppingLabel;
|
||||
|
||||
class GenericChatItemWidget : public QFrame
|
||||
class GenericChatItemWidget : public FrameStyle
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
|
|
@ -60,10 +60,9 @@ public slots:
|
|||
QString getStatusMsg() const;
|
||||
QString getTitle() const;
|
||||
|
||||
void reloadTheme();
|
||||
|
||||
void activate();
|
||||
void compactChange(bool compact);
|
||||
void reloadTheme() override;
|
||||
|
||||
signals:
|
||||
void chatroomWidgetClicked(GenericChatroomWidget* widget);
|
||||
|
|
|
@ -98,9 +98,9 @@ void GUI::setWindowTitle(const QString& title)
|
|||
void GUI::reloadTheme()
|
||||
{
|
||||
if (QThread::currentThread() == qApp->thread()) {
|
||||
getInstance()._reloadTheme();
|
||||
getInstance().themeReload();
|
||||
} else {
|
||||
QMetaObject::invokeMethod(&getInstance(), "_reloadTheme", Qt::BlockingQueuedConnection);
|
||||
QMetaObject::invokeMethod(&getInstance(), "themeReload", Qt::BlockingQueuedConnection);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -224,13 +224,6 @@ void GUI::_setWindowTitle(const QString& title)
|
|||
w->setWindowTitle("qTox - " + title);
|
||||
}
|
||||
|
||||
void GUI::_reloadTheme()
|
||||
{
|
||||
Widget* w = Nexus::getDesktopGUI();
|
||||
if (w)
|
||||
w->reloadTheme();
|
||||
}
|
||||
|
||||
void GUI::_showInfo(const QString& title, const QString& msg)
|
||||
{
|
||||
QMessageBox messageBox(QMessageBox::Information, title, msg, QMessageBox::Ok, getMainWidget());
|
||||
|
|
|
@ -50,7 +50,6 @@ private slots:
|
|||
// Private implementation, those must be called from the GUI thread
|
||||
void _setEnabled(bool state);
|
||||
void _setWindowTitle(const QString& title);
|
||||
void _reloadTheme();
|
||||
void _showInfo(const QString& title, const QString& msg);
|
||||
void _showWarning(const QString& title, const QString& msg);
|
||||
void _showError(const QString& title, const QString& msg);
|
||||
|
@ -58,4 +57,7 @@ private slots:
|
|||
bool warning = true, bool yesno = true);
|
||||
bool _askQuestion(const QString& title, const QString& msg, const QString& button1,
|
||||
const QString& button2, bool defaultAns = false, bool warning = true);
|
||||
|
||||
signals:
|
||||
void themeReload();
|
||||
};
|
||||
|
|
|
@ -35,7 +35,7 @@ static std::array<QString, 3> STATE_NAME = {
|
|||
QStringLiteral("red"),
|
||||
};
|
||||
|
||||
SearchForm::SearchForm(QWidget* parent) : QWidget(parent)
|
||||
SearchForm::SearchForm(QWidget* parent) : WidgetStyle(parent)
|
||||
{
|
||||
QVBoxLayout* layout = new QVBoxLayout();
|
||||
QHBoxLayout* layoutNavigation = new QHBoxLayout();
|
||||
|
|
|
@ -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 QWidget
|
||||
class SearchForm final : public WidgetStyle
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
@ -44,7 +44,6 @@ public:
|
|||
ParameterSearch getParameterSearch();
|
||||
void setFocusEditor();
|
||||
void insertEditor(const QString &text);
|
||||
void reloadTheme();
|
||||
|
||||
protected:
|
||||
void showEvent(QShowEvent* event) final;
|
||||
|
@ -84,6 +83,7 @@ private slots:
|
|||
|
||||
public slots:
|
||||
void showMessageNotFound(SearchDirection direction);
|
||||
void reloadTheme() override;
|
||||
|
||||
signals:
|
||||
void searchInBegin(const QString& phrase, const ParameterSearch& parameter);
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include <QEvent>
|
||||
|
||||
ActivateDialog::ActivateDialog(QWidget* parent, Qt::WindowFlags f)
|
||||
: QDialog(parent, f)
|
||||
: DialogStyle(parent, f)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -19,9 +19,9 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <QDialog>
|
||||
#include "src/widget/dialogstyle.h"
|
||||
|
||||
class ActivateDialog : public QDialog
|
||||
class ActivateDialog : public DialogStyle
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
|
|
@ -463,6 +463,8 @@ void Widget::init()
|
|||
connect(&settings, &Settings::groupchatPositionChanged, contactListWidget,
|
||||
&FriendListWidget::onGroupchatPositionChanged);
|
||||
|
||||
connect(&GUI::getInstance(), &GUI::themeReload, this, &Widget::reloadTheme);
|
||||
|
||||
reloadTheme();
|
||||
updateIcons();
|
||||
retranslateUi();
|
||||
|
@ -1825,7 +1827,7 @@ ContentLayout* Widget::createContentDialog(DialogType type) const
|
|||
Translator::registerHandler(std::bind(&Dialog::retranslateUi, this), this);
|
||||
retranslateUi();
|
||||
setWindowIcon(QIcon(":/img/icons/qtox.svg"));
|
||||
setStyleSheet(Style::getStylesheet("window/general.css"));
|
||||
reloadTheme();
|
||||
|
||||
connect(core, &Core::usernameSet, this, &Dialog::retranslateUi);
|
||||
}
|
||||
|
@ -1842,6 +1844,11 @@ ContentLayout* Widget::createContentDialog(DialogType type) const
|
|||
setWindowTitle(core->getUsername() + QStringLiteral(" - ") + Widget::fromDialogType(type));
|
||||
}
|
||||
|
||||
void reloadTheme() final
|
||||
{
|
||||
setStyleSheet(Style::getStylesheet("window/general.css"));
|
||||
}
|
||||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent* event) override
|
||||
{
|
||||
|
@ -2404,27 +2411,6 @@ void Widget::reloadTheme()
|
|||
contactListWidget->reDraw();
|
||||
|
||||
profilePicture->setStyleSheet(Style::getStylesheet("window/profile.css"));
|
||||
|
||||
if (contentLayout != nullptr) {
|
||||
contentLayout->reloadTheme();
|
||||
}
|
||||
|
||||
for (Friend* f : FriendList::getAllFriends()) {
|
||||
friendWidgets[f->getPublicKey()]->reloadTheme();
|
||||
}
|
||||
|
||||
for (Group* g : GroupList::getAllGroups()) {
|
||||
groupWidgets[g->getPersistentId()]->reloadTheme();
|
||||
}
|
||||
|
||||
|
||||
for (auto f : FriendList::getAllFriends()) {
|
||||
chatForms[f->getPublicKey()]->reloadTheme();
|
||||
}
|
||||
|
||||
for (auto g : GroupList::getAllGroups()) {
|
||||
groupChatForms[g->getPersistentId()]->reloadTheme();
|
||||
}
|
||||
}
|
||||
|
||||
void Widget::nextContact()
|
||||
|
|
|
@ -142,7 +142,6 @@ public:
|
|||
|
||||
void clearAllReceipts();
|
||||
|
||||
void reloadTheme();
|
||||
static inline QIcon prepareIcon(QString path, int w = 0, int h = 0);
|
||||
|
||||
bool groupsVisible() const;
|
||||
|
@ -150,6 +149,7 @@ public:
|
|||
void resetIcon();
|
||||
|
||||
public slots:
|
||||
void reloadTheme();
|
||||
void onShowSettings();
|
||||
void onSeparateWindowClicked(bool separate);
|
||||
void onSeparateWindowChanged(bool separate, bool clicked);
|
||||
|
|
21
src/widget/widgetstyle.h
Normal file
21
src/widget/widgetstyle.h
Normal file
|
@ -0,0 +1,21 @@
|
|||
#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
|
Loading…
Reference in New Issue
Block a user