From cf26f10b80300af5613963bf8017c23d2d0c21b4 Mon Sep 17 00:00:00 2001 From: fourtf Date: Wed, 21 Nov 2018 21:37:41 +0100 Subject: [PATCH] initial appbase integration --- chatterino.pro | 118 +---------------- dependencies/boost.pri | 21 ---- dependencies/rapidjson.pri | 2 - dependencies/serialize.pri | 2 - dependencies/settings.pri | 8 -- src/singletons/WindowManager.cpp | 7 +- src/singletons/WindowManager.hpp | 3 +- src/util/InitUpdateButton.cpp | 2 +- src/widgets/BaseWidget.cpp | 153 ----------------------- src/widgets/BaseWidget.hpp | 57 --------- src/widgets/BaseWindow.cpp | 8 +- src/widgets/BaseWindow.hpp | 4 +- src/widgets/Label.cpp | 8 +- src/widgets/Notebook.cpp | 10 +- src/widgets/Scrollbar.cpp | 6 +- src/widgets/TooltipWidget.cpp | 2 +- src/widgets/Window.cpp | 6 +- src/widgets/dialogs/SettingsDialog.cpp | 2 +- src/widgets/helper/Button.cpp | 2 +- src/widgets/helper/ChannelView.cpp | 14 +-- src/widgets/helper/NotebookTab.cpp | 8 +- src/widgets/helper/SettingsDialogTab.cpp | 2 +- src/widgets/splits/SplitContainer.cpp | 2 +- src/widgets/splits/SplitHeader.cpp | 2 +- src/widgets/splits/SplitInput.cpp | 24 ++-- src/widgets/splits/SplitOverlay.cpp | 2 +- 26 files changed, 63 insertions(+), 412 deletions(-) delete mode 100644 dependencies/boost.pri delete mode 100644 dependencies/rapidjson.pri delete mode 100644 dependencies/serialize.pri delete mode 100644 dependencies/settings.pri delete mode 100644 src/widgets/BaseWidget.cpp delete mode 100644 src/widgets/BaseWidget.hpp diff --git a/chatterino.pro b/chatterino.pro index f17b0ba82..d94cc1dbf 100644 --- a/chatterino.pro +++ b/chatterino.pro @@ -6,34 +6,20 @@ message(----) +# define project shit QT += widgets core gui network multimedia svg concurrent CONFIG += communi COMMUNI += core model util -macx { - # osx - CONFIG += c++14 - DEFINES += PAJLADA_SETTINGS_BOOST_OPTIONAL -} else { - CONFIG += c++17 - win32-msvc* { - # win32 msvc - QMAKE_CXXFLAGS += /std:c++17 - } else { - # clang/gcc on linux or win32 - QMAKE_CXXFLAGS += -std=c++17 - } -} + INCLUDEPATH += src/ TARGET = chatterino TEMPLATE = app -DEFINES += QT_DEPRECATED_WARNINGS PRECOMPILED_HEADER = src/PrecompiledHeader.hpp CONFIG += precompile_header - -debug { - DEFINES += QT_DEBUG -} +# include appbase +include(../appbase/appbase/main/main.pro) +INCLUDEPATH += ../appbase/appbase/main useBreakpad { LIBS += -L$$PWD/lib/qBreakpad/handler/build @@ -50,23 +36,17 @@ equals(QMAKE_CXX, "clang++")|equals(QMAKE_CXX, "g++") { #macx:ICON = resources/images/chatterino2.icns win32:RC_FILE = resources/windows.rc - macx { LIBS += -L/usr/local/lib } # Submodules -include(dependencies/rapidjson.pri) -include(dependencies/serialize.pri) -include(dependencies/settings.pri) -include(dependencies/signals.pri) include(dependencies/humanize.pri) include(dependencies/fmt.pri) DEFINES += IRC_NAMESPACE=Communi include(dependencies/libcommuni.pri) include(dependencies/websocketpp.pri) include(dependencies/openssl.pri) -include(dependencies/boost.pri) include(dependencies/wintoast.pri) # Optional feature: QtWebEngine @@ -76,43 +56,6 @@ include(dependencies/wintoast.pri) # DEFINES += "USEWEBENGINE" #} -linux { - LIBS += -lrt -} - -win32 { - LIBS += -luser32 -} - -# OSX include directory -macx { - INCLUDEPATH += /usr/local/include - INCLUDEPATH += /usr/local/opt/openssl/include - LIBS += -L/usr/local/opt/openssl/lib -} - -# Optional dependency on Windows SDK 7 -!contains(QMAKE_TARGET.arch, x86_64) { - win32:exists(C:\Program Files\Microsoft SDKs\Windows\v7.1\Include\Windows.h) { - LIBS += -L"C:\Program Files\Microsoft SDKs\Windows\v7.1\Lib" \ - -ldwmapi - - DEFINES += "USEWINSDK" - message(Using Windows SDK 7) - } -} - -# Optional dependency on Windows SDK 10 -contains(QMAKE_TARGET.arch, x86_64) { - WIN_SDK_VERSION = $$(WindowsSDKVersion) - !isEmpty(WIN_SDK_VERSION) { - !equals(WIN_SDK_VERSION, "\\") { - DEFINES += "USEWINSDK" - message(Using Windows SDK 10) - } - } -} - werr { QMAKE_CXXFLAGS += -Werror @@ -184,7 +127,6 @@ SOURCES += \ src/widgets/AccountSwitchPopupWidget.cpp \ src/widgets/AccountSwitchWidget.cpp \ src/widgets/AttachedWindow.cpp \ - src/widgets/BaseWidget.cpp \ src/widgets/BaseWindow.cpp \ src/widgets/dialogs/EmotePopup.cpp \ src/widgets/dialogs/LastRunCrashDialog.cpp \ @@ -381,7 +323,6 @@ HEADERS += \ src/widgets/AccountSwitchPopupWidget.hpp \ src/widgets/AccountSwitchWidget.hpp \ src/widgets/AttachedWindow.hpp \ - src/widgets/BaseWidget.hpp \ src/widgets/BaseWindow.hpp \ src/widgets/dialogs/EmotePopup.hpp \ src/widgets/dialogs/LastRunCrashDialog.hpp \ @@ -497,56 +438,7 @@ DISTFILES += FORMS += -# Define warning flags for Chatterino -win32-msvc* { - QMAKE_CXXFLAGS_WARN_ON = /W4 - # 4714 - function marked as __forceinline not inlined - # 4996 - occurs when the compiler encounters a function or variable that is marked as deprecated. - # These functions may have a different preferred name, may be insecure or have - # a more secure variant, or may be obsolete. - # 4505 - unreferenced local version has been removed - # 4127 - conditional expression is constant - # 4503 - decorated name length exceeded, name was truncated - # 4100 - unreferences formal parameter - # 4305 - possible truncation of data - # 4267 - possible loss of data in return - QMAKE_CXXFLAGS_WARN_ON += /wd4714 - QMAKE_CXXFLAGS_WARN_ON += /wd4996 - QMAKE_CXXFLAGS_WARN_ON += /wd4505 - QMAKE_CXXFLAGS_WARN_ON += /wd4127 - QMAKE_CXXFLAGS_WARN_ON += /wd4503 - QMAKE_CXXFLAGS_WARN_ON += /wd4100 - QMAKE_CXXFLAGS_WARN_ON += /wd4305 - QMAKE_CXXFLAGS_WARN_ON += /wd4267 - -} else { - QMAKE_CXXFLAGS_WARN_ON = -Wall - QMAKE_CXXFLAGS_WARN_ON += -Wno-unused-function - QMAKE_CXXFLAGS_WARN_ON += -Wno-switch - QMAKE_CXXFLAGS_WARN_ON += -Wno-deprecated-declarations - QMAKE_CXXFLAGS_WARN_ON += -Wno-sign-compare - QMAKE_CXXFLAGS_WARN_ON += -Wno-unused-variable - - # Disabling strict-aliasing warnings for now, although we probably want to re-enable this in the future - QMAKE_CXXFLAGS_WARN_ON += -Wno-strict-aliasing - - QMAKE_CXXFLAGS_WARN_ON += -Werror=return-type - - equals(QMAKE_CXX, "clang++") { - QMAKE_CXXFLAGS_WARN_ON += -Wno-unused-local-typedef - QMAKE_CXXFLAGS_WARN_ON += -Wno-unused-private-field - } else { - QMAKE_CXXFLAGS_WARN_ON += -Wno-class-memaccess - } -} - # do not use windows min/max macros #win32 { # DEFINES += NOMINMAX #} - -#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 - -linux { - QMAKE_LFLAGS += -lrt -} diff --git a/dependencies/boost.pri b/dependencies/boost.pri deleted file mode 100644 index 044de1de7..000000000 --- a/dependencies/boost.pri +++ /dev/null @@ -1,21 +0,0 @@ -pajlada { - BOOST_DIRECTORY = C:\dev\projects\boost_1_66_0\ -} - -win32 { - isEmpty(BOOST_DIRECTORY) { - message(Using default boost directory C:\\local\\boost\\) - BOOST_DIRECTORY = C:\local\boost\ - } - - INCLUDEPATH += $$BOOST_DIRECTORY - - isEmpty(BOOST_LIB_SUFFIX) { - message(Using default boost lib directory suffix lib) - BOOST_LIB_SUFFIX = lib - } - - LIBS += -L$$BOOST_DIRECTORY\\$$BOOST_LIB_SUFFIX -} else { - LIBS += -lboost_system -lboost_filesystem -} diff --git a/dependencies/rapidjson.pri b/dependencies/rapidjson.pri deleted file mode 100644 index 2573a8580..000000000 --- a/dependencies/rapidjson.pri +++ /dev/null @@ -1,2 +0,0 @@ -# rapidjson -INCLUDEPATH += $$PWD/../lib/rapidjson/include/ diff --git a/dependencies/serialize.pri b/dependencies/serialize.pri deleted file mode 100644 index fd23c7642..000000000 --- a/dependencies/serialize.pri +++ /dev/null @@ -1,2 +0,0 @@ -# serialize -INCLUDEPATH += $$PWD/../lib/serialize/include/ diff --git a/dependencies/settings.pri b/dependencies/settings.pri deleted file mode 100644 index 329f9e14f..000000000 --- a/dependencies/settings.pri +++ /dev/null @@ -1,8 +0,0 @@ -# settings -DEFINES += PAJLADA_SETTINGS_BOOST_FILESYSTEM - -SOURCES += \ - $$PWD/../lib/settings/src/settings/settingdata.cpp \ - $$PWD/../lib/settings/src/settings/settingmanager.cpp - -INCLUDEPATH += $$PWD/../lib/settings/include/ diff --git a/src/singletons/WindowManager.cpp b/src/singletons/WindowManager.cpp index 71277d556..b468e47bc 100644 --- a/src/singletons/WindowManager.cpp +++ b/src/singletons/WindowManager.cpp @@ -84,9 +84,10 @@ WindowManager::WindowManager() this->wordFlagsListener_.addSetting(settings->enableTwitchEmotes); this->wordFlagsListener_.addSetting(settings->boldUsernames); this->wordFlagsListener_.addSetting(settings->lowercaseDomains); - this->wordFlagsListener_.cb = [this](auto) { - this->updateWordTypeMask(); // - }; + // REMOVED + // this->wordFlagsListener_.cb = [this](auto) { + // this->updateWordTypeMask(); // + //}; this->saveTimer = new QTimer; diff --git a/src/singletons/WindowManager.hpp b/src/singletons/WindowManager.hpp index 522729c7d..a9f88355c 100644 --- a/src/singletons/WindowManager.hpp +++ b/src/singletons/WindowManager.hpp @@ -3,6 +3,7 @@ #include "common/Channel.hpp" #include "common/FlagsEnum.hpp" #include "common/Singleton.hpp" +#include "pajlada/settings/settinglistener.hpp" #include "widgets/splits/SplitContainer.hpp" namespace chatterino { @@ -99,7 +100,7 @@ private: Window *selectedWindow_{}; MessageElementFlags wordFlags_{}; - pajlada::Settings::SettingListener wordFlagsListener_; + pajlada::SettingListener wordFlagsListener_; QTimer *saveTimer; }; diff --git a/src/util/InitUpdateButton.cpp b/src/util/InitUpdateButton.cpp index f2506720c..f86cc5b32 100644 --- a/src/util/InitUpdateButton.cpp +++ b/src/util/InitUpdateButton.cpp @@ -15,7 +15,7 @@ void initUpdateButton(Button &button, auto dialog = new UpdateDialog(); dialog->setActionOnFocusLoss(BaseWindow::Delete); dialog->move(button.mapToGlobal( - QPoint(int(-100 * button.getScale()), button.height()))); + QPoint(int(-100 * button.scale()), button.height()))); dialog->show(); dialog->raise(); diff --git a/src/widgets/BaseWidget.cpp b/src/widgets/BaseWidget.cpp deleted file mode 100644 index 7437f48d5..000000000 --- a/src/widgets/BaseWidget.cpp +++ /dev/null @@ -1,153 +0,0 @@ -#include "widgets/BaseWidget.hpp" - -#include "Application.hpp" -#include "debug/Log.hpp" -#include "singletons/Settings.hpp" -#include "singletons/Theme.hpp" -#include "widgets/BaseWindow.hpp" - -#include -#include -#include -#include -#include - -namespace chatterino { - -BaseWidget::BaseWidget(QWidget *parent, Qt::WindowFlags f) - : QWidget(parent, f) -{ - this->theme = getApp()->themes; - - this->signalHolder_.managedConnect(this->theme->updated, [this]() { - this->themeChangedEvent(); - - this->update(); - }); -} - -float BaseWidget::getScale() const -{ - if (this->overrideScale_) - { - return this->overrideScale_.get(); - } - - BaseWidget *baseWidget = dynamic_cast(this->window()); - - if (baseWidget == nullptr) - { - return 1.f; - } - - return baseWidget->scale_; -} - -void BaseWidget::setScale(float value) -{ - // update scale value - this->scale_ = value; - - this->scaleChangedEvent(this->getScale()); - this->scaleChanged.invoke(this->getScale()); - - this->setScaleIndependantSize(this->getScaleIndependantSize()); -} - -void BaseWidget::setOverrideScale(boost::optional value) -{ - this->overrideScale_ = value; - this->setScale(this->getScale()); -} - -boost::optional BaseWidget::getOverrideScale() const -{ - return this->overrideScale_; -} - -QSize BaseWidget::getScaleIndependantSize() const -{ - return this->scaleIndependantSize_; -} - -int BaseWidget::getScaleIndependantWidth() const -{ - return this->scaleIndependantSize_.width(); -} - -int BaseWidget::getScaleIndependantHeight() const -{ - return this->scaleIndependantSize_.height(); -} - -void BaseWidget::setScaleIndependantSize(int width, int height) -{ - this->setScaleIndependantSize(QSize(width, height)); -} - -void BaseWidget::setScaleIndependantSize(QSize size) -{ - this->scaleIndependantSize_ = size; - - if (size.width() > 0) - { - this->setFixedWidth((int)(size.width() * this->getScale())); - } - if (size.height() > 0) - { - this->setFixedHeight((int)(size.height() * this->getScale())); - } -} - -void BaseWidget::setScaleIndependantWidth(int value) -{ - this->setScaleIndependantSize( - QSize(value, this->scaleIndependantSize_.height())); -} - -void BaseWidget::setScaleIndependantHeight(int value) -{ - this->setScaleIndependantSize( - QSize(this->scaleIndependantSize_.height(), value)); -} - -void BaseWidget::childEvent(QChildEvent *event) -{ - if (event->added()) - { - BaseWidget *widget = dynamic_cast(event->child()); - - if (widget != nullptr) - { - this->widgets_.push_back(widget); - } - } - else if (event->removed()) - { - for (auto it = this->widgets_.begin(); it != this->widgets_.end(); it++) - { - if (*it == event->child()) - { - this->widgets_.erase(it); - break; - } - } - } -} - -void BaseWidget::showEvent(QShowEvent *) -{ - this->setScale(this->getScale()); - this->themeChangedEvent(); -} - -void BaseWidget::scaleChangedEvent(float newDpi) -{ -} - -void BaseWidget::themeChangedEvent() -{ - // Do any color scheme updates here -} - -} // namespace chatterino diff --git a/src/widgets/BaseWidget.hpp b/src/widgets/BaseWidget.hpp deleted file mode 100644 index ebdbe6532..000000000 --- a/src/widgets/BaseWidget.hpp +++ /dev/null @@ -1,57 +0,0 @@ -#pragma once - -#include -#include -#include -#include - -namespace chatterino { - -class Theme; -class BaseWindow; - -class BaseWidget : public QWidget -{ - Q_OBJECT - -public: - explicit BaseWidget(QWidget *parent, Qt::WindowFlags f = Qt::WindowFlags()); - - virtual float getScale() const; - pajlada::Signals::Signal scaleChanged; - - void setOverrideScale(boost::optional); - boost::optional getOverrideScale() const; - - QSize getScaleIndependantSize() const; - int getScaleIndependantWidth() const; - int getScaleIndependantHeight() const; - void setScaleIndependantSize(int width, int height); - void setScaleIndependantSize(QSize); - void setScaleIndependantWidth(int value); - void setScaleIndependantHeight(int value); - -protected: - virtual void childEvent(QChildEvent *) override; - virtual void showEvent(QShowEvent *) override; - - virtual void scaleChangedEvent(float newScale); - virtual void themeChangedEvent(); - - void setScale(float value); - - Theme *theme; - -private: - float scale_ = 1.f; - boost::optional overrideScale_ = boost::none; - QSize scaleIndependantSize_; - - std::vector widgets_; - - pajlada::Signals::SignalHolder signalHolder_; - - friend class BaseWindow; -}; - -} // namespace chatterino diff --git a/src/widgets/BaseWindow.cpp b/src/widgets/BaseWindow.cpp index ae578cfd2..1b48bd68c 100644 --- a/src/widgets/BaseWindow.cpp +++ b/src/widgets/BaseWindow.cpp @@ -68,9 +68,9 @@ BaseWindow::BaseWindow(QWidget *parent, Flags _flags) // QTimer::this->scaleChangedEvent(this->getScale()); } -float BaseWindow::getScale() const +float BaseWindow::scale() const { - return this->getOverrideScale().value_or(this->scale_); + return this->overrideScale().value_or(this->scale_); } BaseWindow::Flags BaseWindow::getFlags() @@ -597,7 +597,7 @@ void BaseWindow::calcButtonsSizes() return; } - if ((this->width() / this->getScale()) < 300) + if ((this->width() / this->scale()) < 300) { if (this->ui_.minButton) this->ui_.minButton->setScaleIndependantSize(30, 30); @@ -729,7 +729,7 @@ bool BaseWindow::handleSIZE(MSG *msg) { if (msg->wParam == SIZE_MAXIMIZED) { - auto offset = int(this->getScale() * 8); + auto offset = int(this->scale() * 8); this->ui_.windowLayout->setContentsMargins(offset, offset, offset, offset); diff --git a/src/widgets/BaseWindow.hpp b/src/widgets/BaseWindow.hpp index 25b12025a..6a61cc984 100644 --- a/src/widgets/BaseWindow.hpp +++ b/src/widgets/BaseWindow.hpp @@ -1,6 +1,6 @@ #pragma once -#include "BaseWidget.hpp" +#include "widgets/BaseWidget.hpp" #include #include @@ -48,7 +48,7 @@ public: void moveTo(QWidget *widget, QPoint point, bool offset = true); - virtual float getScale() const override; + virtual float scale() const override; Flags getFlags(); diff --git a/src/widgets/Label.cpp b/src/widgets/Label.cpp index 4106e4dee..466410c63 100644 --- a/src/widgets/Label.cpp +++ b/src/widgets/Label.cpp @@ -90,10 +90,10 @@ void Label::paintEvent(QPaintEvent *) QPainter painter(this); QFontMetrics metrics = app->fonts->getFontMetrics( - this->getFontStyle(), this->getScale() * 96.f / this->logicalDpiX() * + this->getFontStyle(), this->scale() * 96.f / this->logicalDpiX() * this->devicePixelRatioF()); painter.setFont(app->fonts->getFont( - this->getFontStyle(), this->getScale() * 96.f / this->logicalDpiX() * + this->getFontStyle(), this->scale() * 96.f / this->logicalDpiX() * this->devicePixelRatioF())); int offset = this->getOffset(); @@ -121,7 +121,7 @@ void Label::updateSize() auto app = getApp(); QFontMetrics metrics = - app->fonts->getFontMetrics(this->fontStyle_, this->getScale()); + app->fonts->getFontMetrics(this->fontStyle_, this->scale()); int width = metrics.width(this->text_) + (2 * this->getOffset()); int height = metrics.height(); @@ -132,7 +132,7 @@ void Label::updateSize() int Label::getOffset() { - return this->hasOffset_ ? int(8 * this->getScale()) : 0; + return this->hasOffset_ ? int(8 * this->scale()) : 0; } } // namespace chatterino diff --git a/src/widgets/Notebook.cpp b/src/widgets/Notebook.cpp index 48bc558fe..8e2017bb0 100644 --- a/src/widgets/Notebook.cpp +++ b/src/widgets/Notebook.cpp @@ -283,7 +283,7 @@ QWidget *Notebook::tabAt(QPoint point, int &index, int maxWidth) for (auto &item : this->items_) { auto rect = item.tab->getDesiredRect(); - rect.setHeight(int(this->getScale() * 24)); + rect.setHeight(int(this->scale() * 24)); rect.setWidth(std::min(maxWidth, rect.width())); @@ -334,7 +334,7 @@ void Notebook::setShowAddButton(bool value) void Notebook::scaleChangedEvent(float scale) { - float h = (NOTEBOOK_TAB_HEIGHT - 1) * this->getScale(); + float h = (NOTEBOOK_TAB_HEIGHT - 1) * this->scale(); this->addButton_->setFixedSize(h, h); @@ -351,8 +351,8 @@ void Notebook::resizeEvent(QResizeEvent *) void Notebook::performLayout(bool animated) { - const auto left = int(2 * this->getScale()); - const auto scale = this->getScale(); + const auto left = int(2 * this->scale()); + const auto scale = this->scale(); const auto tabHeight = int(NOTEBOOK_TAB_HEIGHT * scale); const auto addButtonWidth = this->showAddButton_ ? tabHeight : 0; @@ -449,7 +449,7 @@ void Notebook::paintEvent(QPaintEvent *event) BaseWidget::paintEvent(event); QPainter painter(this); - painter.fillRect(0, this->lineY_, this->width(), int(2 * this->getScale()), + painter.fillRect(0, this->lineY_, this->width(), int(2 * this->scale()), this->theme->tabs.bottomLine); } diff --git a/src/widgets/Scrollbar.cpp b/src/widgets/Scrollbar.cpp index 62e5848e6..a202dcd5c 100644 --- a/src/widgets/Scrollbar.cpp +++ b/src/widgets/Scrollbar.cpp @@ -20,7 +20,7 @@ Scrollbar::Scrollbar(ChannelView *parent) : BaseWidget(parent) , currentValueAnimation_(this, "currentValue_") { - resize(int(16 * this->getScale()), 100); + resize(int(16 * this->scale()), 100); this->currentValueAnimation_.setDuration(150); this->currentValueAnimation_.setEasingCurve( QEasingCurve(QEasingCurve::OutCubic)); @@ -237,7 +237,7 @@ void Scrollbar::printCurrentState(const QString &prefix) const void Scrollbar::paintEvent(QPaintEvent *) { bool mouseOver = this->mouseOverIndex_ != -1; - int xOffset = mouseOver ? 0 : width() - int(4 * this->getScale()); + int xOffset = mouseOver ? 0 : width() - int(4 * this->scale()); QPainter painter(this); painter.fillRect(rect(), this->theme->scrollbars.background); @@ -320,7 +320,7 @@ void Scrollbar::paintEvent(QPaintEvent *) void Scrollbar::resizeEvent(QResizeEvent *) { - this->resize(int(16 * this->getScale()), this->height()); + this->resize(int(16 * this->scale()), this->height()); } void Scrollbar::mouseMoveEvent(QMouseEvent *event) diff --git a/src/widgets/TooltipWidget.cpp b/src/widgets/TooltipWidget.cpp index 2d528c4d8..9f4f87c85 100644 --- a/src/widgets/TooltipWidget.cpp +++ b/src/widgets/TooltipWidget.cpp @@ -80,7 +80,7 @@ void TooltipWidget::updateFont() auto app = getApp(); this->setFont( - app->fonts->getFont(FontStyle::ChatMediumSmall, this->getScale())); + app->fonts->getFont(FontStyle::ChatMediumSmall, this->scale())); } void TooltipWidget::setText(QString text) diff --git a/src/widgets/Window.cpp b/src/widgets/Window.cpp index 5e21e8d0d..977913f31 100644 --- a/src/widgets/Window.cpp +++ b/src/widgets/Window.cpp @@ -50,11 +50,11 @@ Window::Window(WindowType type) if (type == WindowType::Main) { - this->resize(int(600 * this->getScale()), int(500 * this->getScale())); + this->resize(int(600 * this->scale()), int(500 * this->scale())); } else { - this->resize(int(300 * this->getScale()), int(500 * this->getScale())); + this->resize(int(300 * this->scale()), int(500 * this->scale())); } } @@ -192,7 +192,7 @@ void Window::addCustomTitlebarButtons() getApp()->windows->showAccountSelectPopup(this->userLabel_->mapToGlobal( this->userLabel_->rect().bottomLeft())); }); - this->userLabel_->setMinimumWidth(20 * getScale()); + this->userLabel_->setMinimumWidth(20 * scale()); } void Window::addDebugStuff() diff --git a/src/widgets/dialogs/SettingsDialog.cpp b/src/widgets/dialogs/SettingsDialog.cpp index a25aa2ff6..6623b1123 100644 --- a/src/widgets/dialogs/SettingsDialog.cpp +++ b/src/widgets/dialogs/SettingsDialog.cpp @@ -33,7 +33,7 @@ SettingsDialog::SettingsDialog() this->initUi(); this->addTabs(); - this->scaleChangedEvent(this->getScale()); + this->scaleChangedEvent(this->scale()); this->overrideBackgroundColor_ = QColor("#111111"); this->themeChangedEvent(); diff --git a/src/widgets/helper/Button.cpp b/src/widgets/helper/Button.cpp index c45a8a059..98a7cedb7 100644 --- a/src/widgets/helper/Button.cpp +++ b/src/widgets/helper/Button.cpp @@ -120,7 +120,7 @@ void Button::paintEvent(QPaintEvent *) } QRect rect = this->rect(); - int s = this->enableMargin_ ? int(6 * this->getScale()) : 0; + int s = this->enableMargin_ ? int(6 * this->scale()) : 0; rect.moveLeft(s); rect.setRight(rect.right() - s - s); diff --git a/src/widgets/helper/ChannelView.cpp b/src/widgets/helper/ChannelView.cpp index 215a2d96d..81041bc0e 100644 --- a/src/widgets/helper/ChannelView.cpp +++ b/src/widgets/helper/ChannelView.cpp @@ -336,7 +336,7 @@ void ChannelView::layoutVisibleMessages( auto message = messages[i]; redrawRequired |= - message->layout(layoutWidth, this->getScale(), flags); + message->layout(layoutWidth, this->scale(), flags); y += message->getHeight(); } @@ -366,7 +366,7 @@ void ChannelView::updateScrollbar( { auto *message = messages[i].get(); - message->layout(layoutWidth, this->getScale(), flags); + message->layout(layoutWidth, this->scale(), flags); h -= message->getHeight(); @@ -784,7 +784,7 @@ void ChannelView::paintEvent(QPaintEvent * /*event*/) // draw paused sign if (this->paused()) { - auto a = this->getScale() * 16; + auto a = this->scale() * 16; auto brush = QBrush(QColor(127, 127, 127, 63)); painter.fillRect(QRectF(this->width() - a, a / 4, a / 4, a), brush); painter.fillRect(QRectF(this->width() - a / 2, a / 4, a / 4, a), brush); @@ -918,7 +918,7 @@ void ChannelView::wheelEvent(QWheelEvent *event) else { snapshot[i - 1]->layout(this->getLayoutWidth(), - this->getScale(), this->getFlags()); + this->scale(), this->getFlags()); scrollFactor = 1; currentScrollLeft = snapshot[i - 1]->getHeight(); } @@ -952,7 +952,7 @@ void ChannelView::wheelEvent(QWheelEvent *event) else { snapshot[i + 1]->layout(this->getLayoutWidth(), - this->getScale(), this->getFlags()); + this->scale(), this->getFlags()); scrollFactor = 1; currentScrollLeft = snapshot[i + 1]->getHeight(); @@ -1605,7 +1605,7 @@ void ChannelView::showUserInfoPopup(const QString &userName) auto *userPopup = new UserInfoPopup; userPopup->setData(userName, this->channel_); userPopup->setActionOnFocusLoss(BaseWindow::Delete); - QPoint offset(int(150 * this->getScale()), int(70 * this->getScale())); + QPoint offset(int(150 * this->scale()), int(70 * this->scale())); userPopup->move(QCursor::pos() - offset); userPopup->show(); } @@ -1684,7 +1684,7 @@ bool ChannelView::tryGetMessageAt(QPoint p, int ChannelView::getLayoutWidth() const { if (this->scrollBar_->isVisible()) - return int(this->width() - 8 * this->getScale()); + return int(this->width() - 8 * this->scale()); return this->width(); } diff --git a/src/widgets/helper/NotebookTab.cpp b/src/widgets/helper/NotebookTab.cpp index f09f550c5..ca8f2d75b 100644 --- a/src/widgets/helper/NotebookTab.cpp +++ b/src/widgets/helper/NotebookTab.cpp @@ -84,12 +84,12 @@ void NotebookTab::themeChangedEvent() void NotebookTab::updateSize() { - float scale = getScale(); + float scale = this->scale(); int width; QFontMetrics metrics = getApp()->fonts->getFontMetrics( FontStyle::UiTabs, - float(qreal(this->getScale()) * this->devicePixelRatioF())); + float(qreal(this->scale()) * this->devicePixelRatioF())); if (this->hasXButton()) { @@ -267,7 +267,7 @@ void NotebookTab::paintEvent(QPaintEvent *) { auto app = getApp(); QPainter painter(this); - float scale = this->getScale(); + float scale = this->scale(); painter.setFont(getApp()->fonts->getFont( FontStyle::UiTabs, @@ -572,7 +572,7 @@ QRect NotebookTab::getXRect() // return QRect(); // } - float s = this->getScale(); + float s = this->scale(); return QRect(this->width() - static_cast(20 * s), static_cast(9 * s), static_cast(16 * s), static_cast(16 * s)); diff --git a/src/widgets/helper/SettingsDialogTab.cpp b/src/widgets/helper/SettingsDialogTab.cpp index 1319b6796..0474126cc 100644 --- a/src/widgets/helper/SettingsDialogTab.cpp +++ b/src/widgets/helper/SettingsDialogTab.cpp @@ -48,7 +48,7 @@ void SettingsDialogTab::paintEvent(QPaintEvent *) this->style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter, this); - int a = (this->height() - (20 * this->getScale())) / 2; + int a = (this->height() - (20 * this->scale())) / 2; QPixmap pixmap = this->ui_.icon.pixmap( QSize(this->height() - a * 2, this->height() - a * 2)); diff --git a/src/widgets/splits/SplitContainer.cpp b/src/widgets/splits/SplitContainer.cpp index 9b18f8047..6b94dd838 100644 --- a/src/widgets/splits/SplitContainer.cpp +++ b/src/widgets/splits/SplitContainer.cpp @@ -406,7 +406,7 @@ void SplitContainer::layout() std::vector _resizeRects; this->baseNode_.layout( Split::modifierStatus == showAddSplitRegions || this->isDragging_, - this->getScale(), _dropRects, _resizeRects); + this->scale(), _dropRects, _resizeRects); this->dropRects_ = _dropRects; diff --git a/src/widgets/splits/SplitHeader.cpp b/src/widgets/splits/SplitHeader.cpp index ff944260a..0cb71429e 100644 --- a/src/widgets/splits/SplitHeader.cpp +++ b/src/widgets/splits/SplitHeader.cpp @@ -560,7 +560,7 @@ void SplitHeader::mouseMoveEvent(QMouseEvent *event) { if (this->dragging_) { - if (distance(this->dragStart_, event->pos()) > 15 * this->getScale()) + if (distance(this->dragStart_, event->pos()) > 15 * this->scale()) { this->split_->drag(); this->dragging_ = false; diff --git a/src/widgets/splits/SplitInput.cpp b/src/widgets/splits/SplitInput.cpp index 704df6aa6..54519de3f 100644 --- a/src/widgets/splits/SplitInput.cpp +++ b/src/widgets/splits/SplitInput.cpp @@ -40,7 +40,7 @@ SplitInput::SplitInput(Split *_chatWidget) // misc this->installKeyPressedEvent(); - this->scaleChangedEvent(this->getScale()); + this->scaleChangedEvent(this->scale()); } void SplitInput::initLayout() @@ -76,11 +76,11 @@ void SplitInput::initLayout() // set edit font this->ui_.textEdit->setFont( - app->fonts->getFont(FontStyle::ChatMedium, this->getScale())); + app->fonts->getFont(FontStyle::ChatMedium, this->scale())); this->managedConnections_.push_back(app->fonts->fontChanged.connect([=]() { this->ui_.textEdit->setFont( - app->fonts->getFont(FontStyle::ChatMedium, this->getScale())); + app->fonts->getFont(FontStyle::ChatMedium, this->scale())); })); // open emote popup @@ -111,9 +111,9 @@ void SplitInput::scaleChangedEvent(float scale) this->updateEmoteButton(); // set maximum height - this->setMaximumHeight(int(150 * this->getScale())); + this->setMaximumHeight(int(150 * this->scale())); this->ui_.textEdit->setFont( - getApp()->fonts->getFont(FontStyle::ChatMedium, this->getScale())); + getApp()->fonts->getFont(FontStyle::ChatMedium, this->scale())); } void SplitInput::themeChangedEvent() @@ -128,14 +128,14 @@ void SplitInput::themeChangedEvent() this->ui_.textEdit->setStyleSheet(this->theme->splits.input.styleSheet); this->ui_.hbox->setMargin( - int((this->theme->isLightTheme() ? 4 : 2) * this->getScale())); + int((this->theme->isLightTheme() ? 4 : 2) * this->scale())); this->ui_.emoteButton->getLabel().setStyleSheet("color: #000"); } void SplitInput::updateEmoteButton() { - float scale = this->getScale(); + float scale = this->scale(); QString text = ""; text.replace("xD", QString::number(int(12 * scale))); @@ -172,8 +172,8 @@ void SplitInput::openEmotePopup() }); } - this->emotePopup_->resize(int(300 * this->emotePopup_->getScale()), - int(500 * this->emotePopup_->getScale())); + this->emotePopup_->resize(int(300 * this->emotePopup_->scale()), + int(500 * this->emotePopup_->scale())); this->emotePopup_->loadChannel(this->split_->getChannel()); this->emotePopup_->show(); this->emotePopup_->activateWindow(); @@ -428,7 +428,7 @@ void SplitInput::editTextChanged() if (text.length() > 0 && getSettings()->showMessageLength) { - labelText = QString::number(text.length()); + labelText = QString::number(text.length()); } else { @@ -444,7 +444,7 @@ void SplitInput::paintEvent(QPaintEvent *) if (this->theme->isLightTheme()) { - int s = int(3 * this->getScale()); + int s = int(3 * this->scale()); QRect rect = this->rect().marginsRemoved(QMargins(s - 1, s - 1, s, s)); painter.fillRect(rect, this->theme->splits.input.background); @@ -454,7 +454,7 @@ void SplitInput::paintEvent(QPaintEvent *) } else { - int s = int(1 * this->getScale()); + int s = int(1 * this->scale()); QRect rect = this->rect().marginsRemoved(QMargins(s - 1, s - 1, s, s)); painter.fillRect(rect, this->theme->splits.input.background); diff --git a/src/widgets/splits/SplitOverlay.cpp b/src/widgets/splits/SplitOverlay.cpp index 8bb17349c..07f79d141 100644 --- a/src/widgets/splits/SplitOverlay.cpp +++ b/src/widgets/splits/SplitOverlay.cpp @@ -149,7 +149,7 @@ void SplitOverlay::paintEvent(QPaintEvent *) void SplitOverlay::resizeEvent(QResizeEvent *event) { - float _scale = this->getScale(); + float _scale = this->scale(); bool wideEnough = event->size().width() > 150 * _scale; bool highEnough = event->size().height() > 150 * _scale;