mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
initial appbase integration
This commit is contained in:
parent
9472283d76
commit
cf26f10b80
26 changed files with 63 additions and 412 deletions
118
chatterino.pro
118
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
|
||||
}
|
||||
|
|
21
dependencies/boost.pri
vendored
21
dependencies/boost.pri
vendored
|
@ -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
|
||||
}
|
2
dependencies/rapidjson.pri
vendored
2
dependencies/rapidjson.pri
vendored
|
@ -1,2 +0,0 @@
|
|||
# rapidjson
|
||||
INCLUDEPATH += $$PWD/../lib/rapidjson/include/
|
2
dependencies/serialize.pri
vendored
2
dependencies/serialize.pri
vendored
|
@ -1,2 +0,0 @@
|
|||
# serialize
|
||||
INCLUDEPATH += $$PWD/../lib/serialize/include/
|
8
dependencies/settings.pri
vendored
8
dependencies/settings.pri
vendored
|
@ -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/
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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 <QChildEvent>
|
||||
#include <QDebug>
|
||||
#include <QIcon>
|
||||
#include <QLayout>
|
||||
#include <QtGlobal>
|
||||
|
||||
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<BaseWidget *>(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<float> value)
|
||||
{
|
||||
this->overrideScale_ = value;
|
||||
this->setScale(this->getScale());
|
||||
}
|
||||
|
||||
boost::optional<float> 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<BaseWidget *>(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
|
|
@ -1,57 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include <QWidget>
|
||||
#include <boost/optional.hpp>
|
||||
#include <pajlada/signals/signal.hpp>
|
||||
#include <pajlada/signals/signalholder.hpp>
|
||||
|
||||
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<float> scaleChanged;
|
||||
|
||||
void setOverrideScale(boost::optional<float>);
|
||||
boost::optional<float> 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<float> overrideScale_ = boost::none;
|
||||
QSize scaleIndependantSize_;
|
||||
|
||||
std::vector<BaseWidget *> widgets_;
|
||||
|
||||
pajlada::Signals::SignalHolder signalHolder_;
|
||||
|
||||
friend class BaseWindow;
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
|
@ -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);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include "BaseWidget.hpp"
|
||||
#include "widgets/BaseWidget.hpp"
|
||||
|
||||
#include <functional>
|
||||
#include <pajlada/signals/signalholder.hpp>
|
||||
|
@ -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();
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -33,7 +33,7 @@ SettingsDialog::SettingsDialog()
|
|||
this->initUi();
|
||||
this->addTabs();
|
||||
|
||||
this->scaleChangedEvent(this->getScale());
|
||||
this->scaleChangedEvent(this->scale());
|
||||
|
||||
this->overrideBackgroundColor_ = QColor("#111111");
|
||||
this->themeChangedEvent();
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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<int>(20 * s),
|
||||
static_cast<int>(9 * s), static_cast<int>(16 * s),
|
||||
static_cast<int>(16 * s));
|
||||
|
|
|
@ -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));
|
||||
|
||||
|
|
|
@ -406,7 +406,7 @@ void SplitContainer::layout()
|
|||
std::vector<ResizeRect> _resizeRects;
|
||||
this->baseNode_.layout(
|
||||
Split::modifierStatus == showAddSplitRegions || this->isDragging_,
|
||||
this->getScale(), _dropRects, _resizeRects);
|
||||
this->scale(), _dropRects, _resizeRects);
|
||||
|
||||
this->dropRects_ = _dropRects;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 = "<img src=':/buttons/emote.svg' width='xD' height='xD' />";
|
||||
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);
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in a new issue