diff --git a/chatterino.pro b/chatterino.pro index 40a87c57..83d81792 100644 --- a/chatterino.pro +++ b/chatterino.pro @@ -461,4 +461,4 @@ git_hash = $$str_member($$git_commit, 0, 8) # https://stackoverflow.com/questions/3348711/add-a-define-to-qmake-with-a-value/18343449#18343449 DEFINES += CHATTERINO_GIT_COMMIT=\\\"$$git_commit\\\" DEFINES += CHATTERINO_GIT_RELEASE=\\\"$$git_release\\\" -DEFINES += CHATTERINO_GIT_HASH=\\\"$$git_hash\\\" +DEFINES += CHATTERINO_GIT_HASH=\\\"$$git_hash\\\" \ No newline at end of file diff --git a/docs/ENV.md b/docs/ENV.md index 586aac35..727503ff 100644 --- a/docs/ENV.md +++ b/docs/ENV.md @@ -3,7 +3,7 @@ Below I have tried to list all environment variables that can be used to modify ### CHATTERINO2_RECENT_MESSAGES_URL Used to change the URL that Chatterino2 uses when trying to load historic Twitch chat messages (if the setting is enabled). -Default value: `https://recent-messages.robotty.de/api/v2/recent-messages/%1?clearchatToNotice=true` +Default value: `https://recent-messages.robotty.de/api/v2/recent-messages/%1?clearchatToNotice=true` (an [open-source service](https://github.com/robotty/recent-messages) written and currently run by [@RAnders00](https://github.com/RAnders00)) Arguments: - `%1` = Name of the Twitch channel diff --git a/lib/appbase/BaseSettings.cpp b/lib/appbase/BaseSettings.cpp index efcea6f7..78c17926 100644 --- a/lib/appbase/BaseSettings.cpp +++ b/lib/appbase/BaseSettings.cpp @@ -98,12 +98,12 @@ void AB_SETTINGS_CLASS::restoreSnapshot() float AB_SETTINGS_CLASS::getClampedUiScale() const { - return clamp(this->uiScale.getValue(), 0.1, 10); + return clamp(this->uiScale.getValue(), 0.2f, 10); } void AB_SETTINGS_CLASS::setClampedUiScale(float value) { - this->uiScale.setValue(clamp(value, 0.1, 10)); + this->uiScale.setValue(clamp(value, 0.2f, 10)); } #ifndef AB_CUSTOM_SETTINGS diff --git a/lib/appbase/singletons/Fonts.cpp b/lib/appbase/singletons/Fonts.cpp index e3ccf400..2cc29b0b 100644 --- a/lib/appbase/singletons/Fonts.cpp +++ b/lib/appbase/singletons/Fonts.cpp @@ -161,6 +161,8 @@ Fonts::FontData Fonts::createFontData(FontStyle type, float scale) {FontStyle::Tiny, {8, "Monospace", false, QFont::Normal}}, {FontStyle::UiMedium, {int(9 * multiplier), DEFAULT_FONT_FAMILY, false, QFont::Normal}}, + {FontStyle::UiMediumBold, + {int(9 * multiplier), DEFAULT_FONT_FAMILY, false, QFont::Bold}}, {FontStyle::UiTabs, {int(9 * multiplier), DEFAULT_FONT_FAMILY, false, QFont::Normal}}, }; diff --git a/lib/appbase/singletons/Fonts.hpp b/lib/appbase/singletons/Fonts.hpp index ff67bc3e..ad1fe8ca 100644 --- a/lib/appbase/singletons/Fonts.hpp +++ b/lib/appbase/singletons/Fonts.hpp @@ -28,6 +28,7 @@ enum class FontStyle : uint8_t { ChatVeryLarge, UiMedium, + UiMediumBold, UiTabs, // don't remove this value diff --git a/lib/appbase/widgets/BaseWindow.cpp b/lib/appbase/widgets/BaseWindow.cpp index d6ed1e8e..8f77d658 100644 --- a/lib/appbase/widgets/BaseWindow.cpp +++ b/lib/appbase/widgets/BaseWindow.cpp @@ -61,7 +61,12 @@ BaseWindow::BaseWindow(QWidget *parent, Flags _flags) this->init(); getSettings()->uiScale.connect( - [this]() { postToThread([this] { this->updateScale(); }); }, + [this]() { + postToThread([this] { + this->updateScale(); + this->updateScale(); + }); + }, this->connections_); this->updateScale(); @@ -72,6 +77,30 @@ BaseWindow::BaseWindow(QWidget *parent, Flags _flags) // QTimer::this->scaleChangedEvent(this->getScale()); this->resize(300, 150); + +#ifdef USEWINSDK + this->useNextBounds_.setSingleShot(true); + QObject::connect(&this->useNextBounds_, &QTimer::timeout, this, + [this]() { this->currentBounds_ = this->nextBounds_; }); +#endif +} + +void BaseWindow::setInitialBounds(const QRect &bounds) +{ +#ifdef USEWINSDK + this->initalBounds_ = bounds; +#else + this->setGeometry(bounds); +#endif +} + +QRect BaseWindow::getBounds() +{ +#ifdef USEWINSDK + return this->currentBounds_; +#else + return this->geometry(); +#endif } float BaseWindow::scale() const @@ -574,6 +603,11 @@ bool BaseWindow::nativeEvent(const QByteArray &eventType, void *message, returnValue = this->handleSIZE(msg); break; + case WM_MOVE: + returnValue = this->handleMOVE(msg); + *result = 0; + break; + case WM_NCHITTEST: returnValue = this->handleNCHITTEST(msg, result); break; @@ -704,12 +738,23 @@ bool BaseWindow::handleSHOWWINDOW(MSG *msg) this->updateScale(); } - if (!this->shown_ && this->isVisible() && this->hasCustomWindowFrame()) + if (!this->shown_ && this->isVisible()) { - this->shown_ = true; + if (this->hasCustomWindowFrame()) + { + this->shown_ = true; - const MARGINS shadow = {8, 8, 8, 8}; - DwmExtendFrameIntoClientArea(HWND(this->winId()), &shadow); + const MARGINS shadow = {8, 8, 8, 8}; + DwmExtendFrameIntoClientArea(HWND(this->winId()), &shadow); + } + if (!this->initalBounds_.isNull()) + { + ::SetWindowPos(msg->hwnd, nullptr, this->initalBounds_.x(), + this->initalBounds_.y(), this->initalBounds_.width(), + this->initalBounds_.height(), + SWP_NOZORDER | SWP_NOACTIVATE); + this->currentBounds_ = this->initalBounds_; + } } this->calcButtonsSizes(); @@ -770,6 +815,18 @@ bool BaseWindow::handleSIZE(MSG *msg) { this->ui_.windowLayout->setContentsMargins(0, 1, 0, 0); } + + this->isNotMinimizedOrMaximized_ = msg->wParam == SIZE_RESTORED; + + if (this->isNotMinimizedOrMaximized_) + { + RECT rect; + ::GetWindowRect(msg->hwnd, &rect); + this->currentBounds_ = + QRect(QPoint(rect.left, rect.top), + QPoint(rect.right - 1, rect.bottom - 1)); + } + this->useNextBounds_.stop(); } } return false; @@ -778,6 +835,22 @@ bool BaseWindow::handleSIZE(MSG *msg) #endif } +bool BaseWindow::handleMOVE(MSG *msg) +{ +#ifdef USEWINSDK + if (this->isNotMinimizedOrMaximized_) + { + RECT rect; + ::GetWindowRect(msg->hwnd, &rect); + this->nextBounds_ = QRect(QPoint(rect.left, rect.top), + QPoint(rect.right - 1, rect.bottom - 1)); + + this->useNextBounds_.start(10); + } +#endif + return false; +} + bool BaseWindow::handleNCHITTEST(MSG *msg, long *result) { #ifdef USEWINSDK diff --git a/lib/appbase/widgets/BaseWindow.hpp b/lib/appbase/widgets/BaseWindow.hpp index 577e722c..a54a3ba8 100644 --- a/lib/appbase/widgets/BaseWindow.hpp +++ b/lib/appbase/widgets/BaseWindow.hpp @@ -34,6 +34,9 @@ public: explicit BaseWindow(QWidget *parent = nullptr, Flags flags_ = None); + void setInitialBounds(const QRect &bounds); + QRect getBounds(); + QWidget *getLayoutContainer(); bool hasCustomWindowFrame(); TitleBarButton *addTitleBarButton(const TitleBarButtonStyle &style, @@ -95,6 +98,7 @@ private: bool handleSHOWWINDOW(MSG *msg); bool handleNCCALCSIZE(MSG *msg, long *result); bool handleSIZE(MSG *msg); + bool handleMOVE(MSG *msg); bool handleNCHITTEST(MSG *msg, long *result); bool enableCustomFrame_; @@ -116,6 +120,14 @@ private: std::vector