From e327ed416685c4de067dbf7e4498e63a8c67a447 Mon Sep 17 00:00:00 2001 From: pajlada Date: Fri, 1 Dec 2023 15:03:04 +0100 Subject: [PATCH 1/4] Update magic_enum from v0.9.3 to v0.9.5 (#4992) * Fix include path for magic enum * Update .clang-format to ensure magic enum is caught as a third party library --- CHANGELOG.md | 1 + benchmarks/.clang-format | 9 +++------ cmake/FindMagicEnum.cmake | 2 +- lib/magic_enum | 2 +- mocks/.clang-format | 9 +++------ src/.clang-format | 9 +++------ src/common/ChatterinoSetting.hpp | 2 +- src/controllers/plugins/LuaUtilities.hpp | 2 +- src/controllers/plugins/Plugin.cpp | 2 +- src/providers/seventv/SeventvCosmetics.hpp | 2 +- src/providers/seventv/eventapi/Message.hpp | 2 +- src/providers/seventv/eventapi/Subscription.hpp | 2 +- src/providers/twitch/api/Helix.cpp | 2 +- src/providers/twitch/pubsubmessages/AutoMod.hpp | 2 +- src/providers/twitch/pubsubmessages/Base.hpp | 2 +- src/providers/twitch/pubsubmessages/ChannelPoints.hpp | 2 +- .../twitch/pubsubmessages/ChatModeratorAction.hpp | 2 +- src/providers/twitch/pubsubmessages/Whisper.hpp | 2 +- src/widgets/settingspages/GeneralPage.cpp | 2 +- tests/.clang-format | 9 +++------ 20 files changed, 28 insertions(+), 39 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 845d117b4..5cf1e8662 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -61,6 +61,7 @@ - Dev: Add a compile-time flag `CHATTERINO_UPDATER` which can be turned off to disable update checks. (#4854) - Dev: Add a compile-time flag `USE_SYSTEM_MINIAUDIO` which can be turned on to use the system miniaudio. (#4867) - Dev: Update vcpkg to use Qt6. (#4872) +- Dev: Update `magic_enum` to v0.9.5. (#4992) - Dev: Replace `boost::optional` with `std::optional`. (#4877) - Dev: Improve performance of selecting text. (#4889, #4911) - Dev: Removed direct dependency on Qt 5 compatibility module. (#4906) diff --git a/benchmarks/.clang-format b/benchmarks/.clang-format index 7bae09f2c..0feaad9dc 100644 --- a/benchmarks/.clang-format +++ b/benchmarks/.clang-format @@ -32,9 +32,6 @@ IncludeCategories: # Project includes - Regex: '^"[a-zA-Z\._-]+(/[a-zA-Z0-9\._-]+)*"$' Priority: 1 - # Third party library includes - - Regex: '<[[:alnum:].]+/[a-zA-Z0-9\._\/-]+>' - Priority: 3 # Qt includes - Regex: '^$' Priority: 3 @@ -42,12 +39,12 @@ IncludeCategories: # LibCommuni includes - Regex: "^$" Priority: 3 - # Misc libraries - - Regex: '^<[a-zA-Z_0-9]+\.h(pp)?>$' - Priority: 3 # Standard library includes - Regex: "^<[a-zA-Z_]+>$" Priority: 4 + # Third party library includes + - Regex: "^<([a-zA-Z_0-9-]+/)*[a-zA-Z_0-9-]+.h(pp)?>$" + Priority: 3 NamespaceIndentation: Inner PointerBindsToType: false SpacesBeforeTrailingComments: 2 diff --git a/cmake/FindMagicEnum.cmake b/cmake/FindMagicEnum.cmake index 0a77bd279..b595075ca 100644 --- a/cmake/FindMagicEnum.cmake +++ b/cmake/FindMagicEnum.cmake @@ -1,6 +1,6 @@ include(FindPackageHandleStandardArgs) -find_path(MagicEnum_INCLUDE_DIR magic_enum.hpp HINTS ${CMAKE_SOURCE_DIR}/lib/magic_enum/include) +find_path(MagicEnum_INCLUDE_DIR magic_enum/magic_enum.hpp HINTS ${CMAKE_SOURCE_DIR}/lib/magic_enum/include) find_package_handle_standard_args(MagicEnum DEFAULT_MSG MagicEnum_INCLUDE_DIR) diff --git a/lib/magic_enum b/lib/magic_enum index e1a68e9dd..e55b9b54d 160000 --- a/lib/magic_enum +++ b/lib/magic_enum @@ -1 +1 @@ -Subproject commit e1a68e9dd3d2e9180b04c8aeacd4975db745e6b8 +Subproject commit e55b9b54d5cf61f8e117cafb17846d7d742dd3b4 diff --git a/mocks/.clang-format b/mocks/.clang-format index 7bae09f2c..0feaad9dc 100644 --- a/mocks/.clang-format +++ b/mocks/.clang-format @@ -32,9 +32,6 @@ IncludeCategories: # Project includes - Regex: '^"[a-zA-Z\._-]+(/[a-zA-Z0-9\._-]+)*"$' Priority: 1 - # Third party library includes - - Regex: '<[[:alnum:].]+/[a-zA-Z0-9\._\/-]+>' - Priority: 3 # Qt includes - Regex: '^$' Priority: 3 @@ -42,12 +39,12 @@ IncludeCategories: # LibCommuni includes - Regex: "^$" Priority: 3 - # Misc libraries - - Regex: '^<[a-zA-Z_0-9]+\.h(pp)?>$' - Priority: 3 # Standard library includes - Regex: "^<[a-zA-Z_]+>$" Priority: 4 + # Third party library includes + - Regex: "^<([a-zA-Z_0-9-]+/)*[a-zA-Z_0-9-]+.h(pp)?>$" + Priority: 3 NamespaceIndentation: Inner PointerBindsToType: false SpacesBeforeTrailingComments: 2 diff --git a/src/.clang-format b/src/.clang-format index 7bae09f2c..0feaad9dc 100644 --- a/src/.clang-format +++ b/src/.clang-format @@ -32,9 +32,6 @@ IncludeCategories: # Project includes - Regex: '^"[a-zA-Z\._-]+(/[a-zA-Z0-9\._-]+)*"$' Priority: 1 - # Third party library includes - - Regex: '<[[:alnum:].]+/[a-zA-Z0-9\._\/-]+>' - Priority: 3 # Qt includes - Regex: '^$' Priority: 3 @@ -42,12 +39,12 @@ IncludeCategories: # LibCommuni includes - Regex: "^$" Priority: 3 - # Misc libraries - - Regex: '^<[a-zA-Z_0-9]+\.h(pp)?>$' - Priority: 3 # Standard library includes - Regex: "^<[a-zA-Z_]+>$" Priority: 4 + # Third party library includes + - Regex: "^<([a-zA-Z_0-9-]+/)*[a-zA-Z_0-9-]+.h(pp)?>$" + Priority: 3 NamespaceIndentation: Inner PointerBindsToType: false SpacesBeforeTrailingComments: 2 diff --git a/src/common/ChatterinoSetting.hpp b/src/common/ChatterinoSetting.hpp index 6c9d8ec47..2f5a0cac4 100644 --- a/src/common/ChatterinoSetting.hpp +++ b/src/common/ChatterinoSetting.hpp @@ -1,6 +1,6 @@ #pragma once -#include +#include #include #include diff --git a/src/controllers/plugins/LuaUtilities.hpp b/src/controllers/plugins/LuaUtilities.hpp index 6a75b774a..f88f2a928 100644 --- a/src/controllers/plugins/LuaUtilities.hpp +++ b/src/controllers/plugins/LuaUtilities.hpp @@ -4,7 +4,7 @@ # include # include -# include +# include # include # include diff --git a/src/controllers/plugins/Plugin.cpp b/src/controllers/plugins/Plugin.cpp index 3fdc8e4dc..0e9a20d63 100644 --- a/src/controllers/plugins/Plugin.cpp +++ b/src/controllers/plugins/Plugin.cpp @@ -4,7 +4,7 @@ # include "controllers/commands/CommandController.hpp" # include -# include +# include # include # include diff --git a/src/providers/seventv/SeventvCosmetics.hpp b/src/providers/seventv/SeventvCosmetics.hpp index 0d521ac03..6302c51f4 100644 --- a/src/providers/seventv/SeventvCosmetics.hpp +++ b/src/providers/seventv/SeventvCosmetics.hpp @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace chatterino::seventv { diff --git a/src/providers/seventv/eventapi/Message.hpp b/src/providers/seventv/eventapi/Message.hpp index 5dbc848b7..4227f6839 100644 --- a/src/providers/seventv/eventapi/Message.hpp +++ b/src/providers/seventv/eventapi/Message.hpp @@ -2,7 +2,7 @@ #include "providers/seventv/eventapi/Subscription.hpp" -#include +#include #include #include #include diff --git a/src/providers/seventv/eventapi/Subscription.hpp b/src/providers/seventv/eventapi/Subscription.hpp index 1a36811a5..65cf03544 100644 --- a/src/providers/seventv/eventapi/Subscription.hpp +++ b/src/providers/seventv/eventapi/Subscription.hpp @@ -1,6 +1,6 @@ #pragma once -#include +#include #include #include #include diff --git a/src/providers/twitch/api/Helix.cpp b/src/providers/twitch/api/Helix.cpp index 758efe9ff..8e4c73fc5 100644 --- a/src/providers/twitch/api/Helix.cpp +++ b/src/providers/twitch/api/Helix.cpp @@ -6,7 +6,7 @@ #include "common/QLogging.hpp" #include "util/CancellationToken.hpp" -#include +#include #include namespace { diff --git a/src/providers/twitch/pubsubmessages/AutoMod.hpp b/src/providers/twitch/pubsubmessages/AutoMod.hpp index 400169ac7..9f40d39da 100644 --- a/src/providers/twitch/pubsubmessages/AutoMod.hpp +++ b/src/providers/twitch/pubsubmessages/AutoMod.hpp @@ -1,6 +1,6 @@ #pragma once -#include +#include #include #include #include diff --git a/src/providers/twitch/pubsubmessages/Base.hpp b/src/providers/twitch/pubsubmessages/Base.hpp index ce190ee06..fed0112e7 100644 --- a/src/providers/twitch/pubsubmessages/Base.hpp +++ b/src/providers/twitch/pubsubmessages/Base.hpp @@ -1,6 +1,6 @@ #pragma once -#include +#include #include #include #include diff --git a/src/providers/twitch/pubsubmessages/ChannelPoints.hpp b/src/providers/twitch/pubsubmessages/ChannelPoints.hpp index c5a3ffe88..be8d1bd68 100644 --- a/src/providers/twitch/pubsubmessages/ChannelPoints.hpp +++ b/src/providers/twitch/pubsubmessages/ChannelPoints.hpp @@ -1,6 +1,6 @@ #pragma once -#include +#include #include #include diff --git a/src/providers/twitch/pubsubmessages/ChatModeratorAction.hpp b/src/providers/twitch/pubsubmessages/ChatModeratorAction.hpp index 5f29673e3..e04019cb7 100644 --- a/src/providers/twitch/pubsubmessages/ChatModeratorAction.hpp +++ b/src/providers/twitch/pubsubmessages/ChatModeratorAction.hpp @@ -1,6 +1,6 @@ #pragma once -#include +#include #include #include diff --git a/src/providers/twitch/pubsubmessages/Whisper.hpp b/src/providers/twitch/pubsubmessages/Whisper.hpp index ef96cd62b..979cb6a1e 100644 --- a/src/providers/twitch/pubsubmessages/Whisper.hpp +++ b/src/providers/twitch/pubsubmessages/Whisper.hpp @@ -1,6 +1,6 @@ #pragma once -#include +#include #include #include #include diff --git a/src/widgets/settingspages/GeneralPage.cpp b/src/widgets/settingspages/GeneralPage.cpp index d2b5c9908..338219976 100644 --- a/src/widgets/settingspages/GeneralPage.cpp +++ b/src/widgets/settingspages/GeneralPage.cpp @@ -21,7 +21,7 @@ #include "widgets/settingspages/GeneralPageView.hpp" #include "widgets/splits/SplitInput.hpp" -#include +#include #include #include #include diff --git a/tests/.clang-format b/tests/.clang-format index 7bae09f2c..0feaad9dc 100644 --- a/tests/.clang-format +++ b/tests/.clang-format @@ -32,9 +32,6 @@ IncludeCategories: # Project includes - Regex: '^"[a-zA-Z\._-]+(/[a-zA-Z0-9\._-]+)*"$' Priority: 1 - # Third party library includes - - Regex: '<[[:alnum:].]+/[a-zA-Z0-9\._\/-]+>' - Priority: 3 # Qt includes - Regex: '^$' Priority: 3 @@ -42,12 +39,12 @@ IncludeCategories: # LibCommuni includes - Regex: "^$" Priority: 3 - # Misc libraries - - Regex: '^<[a-zA-Z_0-9]+\.h(pp)?>$' - Priority: 3 # Standard library includes - Regex: "^<[a-zA-Z_]+>$" Priority: 4 + # Third party library includes + - Regex: "^<([a-zA-Z_0-9-]+/)*[a-zA-Z_0-9-]+.h(pp)?>$" + Priority: 3 NamespaceIndentation: Inner PointerBindsToType: false SpacesBeforeTrailingComments: 2 From c4c94473ae4f7b3d01c4852105412f11f2575187 Mon Sep 17 00:00:00 2001 From: nerix Date: Sat, 2 Dec 2023 12:56:03 +0100 Subject: [PATCH 2/4] Do bounds-checking on more windows (#4797) Co-authored-by: pajlada --- CHANGELOG.md | 1 + src/singletons/WindowManager.cpp | 3 +-- src/util/InitUpdateButton.cpp | 2 +- src/util/WidgetHelpers.cpp | 13 +++++++++++ src/util/WidgetHelpers.hpp | 10 ++++++++ src/widgets/BaseWindow.cpp | 11 +++++++++ src/widgets/BaseWindow.hpp | 23 ++++++++++++------- src/widgets/dialogs/ColorPickerDialog.cpp | 9 ++++++-- src/widgets/dialogs/QualityPopup.cpp | 8 +++++-- src/widgets/dialogs/SelectChannelDialog.cpp | 11 ++++++--- src/widgets/dialogs/SettingsDialog.cpp | 15 ++++++++---- .../dialogs/switcher/QuickSwitcherPopup.cpp | 11 ++++++--- src/widgets/helper/ChannelView.cpp | 4 ++-- src/widgets/helper/SearchPopup.cpp | 10 ++++++-- src/widgets/settingspages/AboutPage.cpp | 10 +++++--- src/widgets/settingspages/FiltersPage.cpp | 5 ++-- src/widgets/splits/Split.cpp | 12 +++++++--- 17 files changed, 120 insertions(+), 38 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5cf1e8662..1ee1403f8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,6 +43,7 @@ - Bugfix: Fixed lookahead/-behind not working in _Ignores_. (#4965) - Bugfix: Fixed Image Uploader accidentally deleting images with some hosts when link resolver was enabled. (#4971) - Bugfix: Fixed rare crash with Image Uploader when closing a split right after starting an upload. (#4971) +- Bugfix: Fixed some windows appearing between screens. (#4797) - Dev: Run miniaudio in a separate thread, and simplify it to not manage the device ourselves. There's a chance the simplification is a bad idea. (#4978) - Dev: Change clang-format from v14 to v16. (#4929) - Dev: Fixed UTF16 encoding of `modes` file for the installer. (#4791) diff --git a/src/singletons/WindowManager.cpp b/src/singletons/WindowManager.cpp index a86fdbc5a..be352588c 100644 --- a/src/singletons/WindowManager.cpp +++ b/src/singletons/WindowManager.cpp @@ -87,8 +87,7 @@ void WindowManager::showAccountSelectPopup(QPoint point) w->refresh(); - QPoint buttonPos = point; - w->move(buttonPos.x() - 30, buttonPos.y()); + w->moveTo(point - QPoint(30, 0), widgets::BoundsChecking::CursorPosition); w->show(); w->setFocus(); } diff --git a/src/util/InitUpdateButton.cpp b/src/util/InitUpdateButton.cpp index 7d687b667..b381af01e 100644 --- a/src/util/InitUpdateButton.cpp +++ b/src/util/InitUpdateButton.cpp @@ -24,7 +24,7 @@ void initUpdateButton(Button &button, globalPoint.setX(0); } - dialog->move(globalPoint); + dialog->moveTo(globalPoint, widgets::BoundsChecking::DesiredPosition); dialog->show(); dialog->raise(); diff --git a/src/util/WidgetHelpers.cpp b/src/util/WidgetHelpers.cpp index 7e6872760..b5e6fa9a3 100644 --- a/src/util/WidgetHelpers.cpp +++ b/src/util/WidgetHelpers.cpp @@ -79,4 +79,17 @@ void moveWindowTo(QWidget *window, QPoint position, BoundsChecking mode) } } +void showAndMoveWindowTo(QWidget *window, QPoint position, BoundsChecking mode) +{ +#ifdef Q_OS_WINDOWS + window->show(); + + moveWindowTo(window, position, mode); +#else + moveWindowTo(window, position, mode); + + window->show(); +#endif +} + } // namespace chatterino::widgets diff --git a/src/util/WidgetHelpers.hpp b/src/util/WidgetHelpers.hpp index 7f57ad393..b09e93d0b 100644 --- a/src/util/WidgetHelpers.hpp +++ b/src/util/WidgetHelpers.hpp @@ -26,4 +26,14 @@ enum class BoundsChecking { void moveWindowTo(QWidget *window, QPoint position, BoundsChecking mode = BoundsChecking::DesiredPosition); +/// Moves the `window` to the (global) `position` +/// while doing bounds-checking according to `mode` to ensure the window stays on one screen. +/// Will also call show on the `window`, order is dependant on platform. +/// +/// @param window The window to move. +/// @param position The global position to move the window to. +/// @param mode The desired bounds checking. +void showAndMoveWindowTo(QWidget *window, QPoint position, + BoundsChecking mode = BoundsChecking::DesiredPosition); + } // namespace chatterino::widgets diff --git a/src/widgets/BaseWindow.cpp b/src/widgets/BaseWindow.cpp index ad12fe185..a98ab8da8 100644 --- a/src/widgets/BaseWindow.cpp +++ b/src/widgets/BaseWindow.cpp @@ -508,6 +508,11 @@ void BaseWindow::moveTo(QPoint point, widgets::BoundsChecking mode) widgets::moveWindowTo(this, point, mode); } +void BaseWindow::showAndMoveTo(QPoint point, widgets::BoundsChecking mode) +{ + widgets::showAndMoveWindowTo(this, point, mode); +} + void BaseWindow::resizeEvent(QResizeEvent *) { // Queue up save because: Window resized @@ -559,6 +564,12 @@ void BaseWindow::closeEvent(QCloseEvent *) void BaseWindow::showEvent(QShowEvent *) { +#ifdef Q_OS_WIN + if (this->flags_.has(BoundsCheckOnShow)) + { + this->moveTo(this->pos(), widgets::BoundsChecking::CursorPosition); + } +#endif } #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) diff --git a/src/widgets/BaseWindow.hpp b/src/widgets/BaseWindow.hpp index 197618657..3b46aea6b 100644 --- a/src/widgets/BaseWindow.hpp +++ b/src/widgets/BaseWindow.hpp @@ -27,14 +27,15 @@ class BaseWindow : public BaseWidget public: enum Flags { None = 0, - EnableCustomFrame = 1, - Frameless = 2, - TopMost = 4, - DisableCustomScaling = 8, - FramelessDraggable = 16, - DontFocus = 32, - Dialog = 64, - DisableLayoutSave = 128, + EnableCustomFrame = 1 << 0, + Frameless = 1 << 1, + TopMost = 1 << 2, + DisableCustomScaling = 1 << 3, + FramelessDraggable = 1 << 4, + DontFocus = 1 << 5, + Dialog = 1 << 6, + DisableLayoutSave = 1 << 7, + BoundsCheckOnShow = 1 << 8, }; enum ActionOnFocusLoss { Nothing, Delete, Close, Hide }; @@ -57,6 +58,12 @@ public: void moveTo(QPoint point, widgets::BoundsChecking mode); + /** + * Moves the window to the given point and does bounds checking according to `mode` + * Depending on the platform, either the move or the show will take place first + **/ + void showAndMoveTo(QPoint point, widgets::BoundsChecking mode); + float scale() const override; float qtFontScale() const; diff --git a/src/widgets/dialogs/ColorPickerDialog.cpp b/src/widgets/dialogs/ColorPickerDialog.cpp index c15e4b16a..5d1096d81 100644 --- a/src/widgets/dialogs/ColorPickerDialog.cpp +++ b/src/widgets/dialogs/ColorPickerDialog.cpp @@ -13,8 +13,13 @@ namespace chatterino { ColorPickerDialog::ColorPickerDialog(const QColor &initial, QWidget *parent) - : BasePopup({BaseWindow::EnableCustomFrame, BaseWindow::DisableLayoutSave}, - parent) + : BasePopup( + { + BaseWindow::EnableCustomFrame, + BaseWindow::DisableLayoutSave, + BaseWindow::BoundsCheckOnShow, + }, + parent) , color_() , dialogConfirmed_(false) { diff --git a/src/widgets/dialogs/QualityPopup.cpp b/src/widgets/dialogs/QualityPopup.cpp index 9c7d519db..f090bee3d 100644 --- a/src/widgets/dialogs/QualityPopup.cpp +++ b/src/widgets/dialogs/QualityPopup.cpp @@ -9,8 +9,12 @@ namespace chatterino { QualityPopup::QualityPopup(const QString &channelURL, QStringList options) - : BasePopup({BaseWindow::DisableLayoutSave}, - static_cast(&(getApp()->windows->getMainWindow()))) + : BasePopup( + { + BaseWindow::DisableLayoutSave, + BaseWindow::BoundsCheckOnShow, + }, + static_cast(&(getApp()->windows->getMainWindow()))) , channelURL_(channelURL) { this->ui_.selector = new QComboBox(this); diff --git a/src/widgets/dialogs/SelectChannelDialog.cpp b/src/widgets/dialogs/SelectChannelDialog.cpp index 4c1dba085..c74bfcc2c 100644 --- a/src/widgets/dialogs/SelectChannelDialog.cpp +++ b/src/widgets/dialogs/SelectChannelDialog.cpp @@ -31,9 +31,14 @@ namespace chatterino { SelectChannelDialog::SelectChannelDialog(QWidget *parent) - : BaseWindow({BaseWindow::Flags::EnableCustomFrame, - BaseWindow::Flags::Dialog, BaseWindow::DisableLayoutSave}, - parent) + : BaseWindow( + { + BaseWindow::Flags::EnableCustomFrame, + BaseWindow::Flags::Dialog, + BaseWindow::DisableLayoutSave, + BaseWindow::BoundsCheckOnShow, + }, + parent) , selectedChannel_(Channel::getEmpty()) { this->setWindowTitle("Select a channel to join"); diff --git a/src/widgets/dialogs/SettingsDialog.cpp b/src/widgets/dialogs/SettingsDialog.cpp index 1ee94b4cf..2fcfa3166 100644 --- a/src/widgets/dialogs/SettingsDialog.cpp +++ b/src/widgets/dialogs/SettingsDialog.cpp @@ -6,6 +6,7 @@ #include "controllers/hotkeys/HotkeyController.hpp" #include "singletons/Settings.hpp" #include "util/LayoutCreator.hpp" +#include "widgets/BaseWindow.hpp" #include "widgets/helper/Button.hpp" #include "widgets/helper/SettingsDialogTab.hpp" #include "widgets/settingspages/AboutPage.hpp" @@ -29,9 +30,14 @@ namespace chatterino { SettingsDialog::SettingsDialog(QWidget *parent) - : BaseWindow({BaseWindow::Flags::DisableCustomScaling, - BaseWindow::Flags::Dialog, BaseWindow::DisableLayoutSave}, - parent) + : BaseWindow( + { + BaseWindow::Flags::DisableCustomScaling, + BaseWindow::Flags::Dialog, + BaseWindow::DisableLayoutSave, + BaseWindow::BoundsCheckOnShow, + }, + parent) { this->setObjectName("SettingsDialog"); this->setWindowTitle("Chatterino Settings"); @@ -380,9 +386,10 @@ void SettingsDialog::themeChangedEvent() this->setPalette(palette); } -void SettingsDialog::showEvent(QShowEvent *) +void SettingsDialog::showEvent(QShowEvent *e) { this->ui_.search->setText(""); + BaseWindow::showEvent(e); } ///// Widget creation helpers diff --git a/src/widgets/dialogs/switcher/QuickSwitcherPopup.cpp b/src/widgets/dialogs/switcher/QuickSwitcherPopup.cpp index 5110b51e3..7841d06b4 100644 --- a/src/widgets/dialogs/switcher/QuickSwitcherPopup.cpp +++ b/src/widgets/dialogs/switcher/QuickSwitcherPopup.cpp @@ -37,9 +37,14 @@ QList openPages(Window *window) namespace chatterino { QuickSwitcherPopup::QuickSwitcherPopup(Window *parent) - : BasePopup({BaseWindow::Flags::Frameless, BaseWindow::Flags::TopMost, - BaseWindow::DisableLayoutSave}, - parent) + : BasePopup( + { + BaseWindow::Flags::Frameless, + BaseWindow::Flags::TopMost, + BaseWindow::DisableLayoutSave, + BaseWindow::BoundsCheckOnShow, + }, + parent) , switcherModel_(this) , window(parent) { diff --git a/src/widgets/helper/ChannelView.cpp b/src/widgets/helper/ChannelView.cpp index ff180f01c..c0f1f5212 100644 --- a/src/widgets/helper/ChannelView.cpp +++ b/src/widgets/helper/ChannelView.cpp @@ -2914,8 +2914,8 @@ void ChannelView::showReplyThreadPopup(const MessagePtr &message) popup->setThread(message->replyThread); QPoint offset(int(150 * this->scale()), int(70 * this->scale())); - popup->move(QCursor::pos() - offset); - popup->show(); + popup->showAndMoveTo(QCursor::pos() - offset, + widgets::BoundsChecking::CursorPosition); popup->giveFocus(Qt::MouseFocusReason); } diff --git a/src/widgets/helper/SearchPopup.cpp b/src/widgets/helper/SearchPopup.cpp index f768bdd1e..329dff068 100644 --- a/src/widgets/helper/SearchPopup.cpp +++ b/src/widgets/helper/SearchPopup.cpp @@ -63,7 +63,12 @@ ChannelPtr SearchPopup::filter(const QString &text, const QString &channelName, } SearchPopup::SearchPopup(QWidget *parent, Split *split) - : BasePopup({BaseWindow::DisableLayoutSave}, parent) + : BasePopup( + { + BaseWindow::DisableLayoutSave, + BaseWindow::BoundsCheckOnShow, + }, + parent) , split_(split) { this->initLayout(); @@ -180,9 +185,10 @@ void SearchPopup::updateWindowTitle() this->setWindowTitle("Searching in " + historyName + " history"); } -void SearchPopup::showEvent(QShowEvent *) +void SearchPopup::showEvent(QShowEvent *e) { this->search(); + BaseWindow::showEvent(e); } bool SearchPopup::eventFilter(QObject *object, QEvent *event) diff --git a/src/widgets/settingspages/AboutPage.cpp b/src/widgets/settingspages/AboutPage.cpp index affea98cd..87c5caa7e 100644 --- a/src/widgets/settingspages/AboutPage.cpp +++ b/src/widgets/settingspages/AboutPage.cpp @@ -227,9 +227,13 @@ void AboutPage::addLicense(QFormLayout *form, const QString &name, auto *b = new QLabel("show license"); QObject::connect( b, &QLabel::linkActivated, [parent = this, name, licenseLink] { - auto window = new BasePopup({BaseWindow::Flags::EnableCustomFrame, - BaseWindow::DisableLayoutSave}, - parent); + auto *window = new BasePopup( + { + BaseWindow::EnableCustomFrame, + BaseWindow::DisableLayoutSave, + BaseWindow::BoundsCheckOnShow, + }, + parent); window->setWindowTitle("Chatterino - License for " + name); window->setAttribute(Qt::WA_DeleteOnClose); auto layout = new QVBoxLayout(); diff --git a/src/widgets/settingspages/FiltersPage.cpp b/src/widgets/settingspages/FiltersPage.cpp index d367a3e32..c66b139be 100644 --- a/src/widgets/settingspages/FiltersPage.cpp +++ b/src/widgets/settingspages/FiltersPage.cpp @@ -45,9 +45,8 @@ FiltersPage::FiltersPage() }); // We can safely ignore this signal connection since we own the view - std::ignore = view->addButtonPressed.connect([] { - ChannelFilterEditorDialog d( - static_cast(&(getApp()->windows->getMainWindow()))); + std::ignore = view->addButtonPressed.connect([this] { + ChannelFilterEditorDialog d(this->window()); if (d.exec() == QDialog::Accepted) { getSettings()->filterRecords.append( diff --git a/src/widgets/splits/Split.cpp b/src/widgets/splits/Split.cpp index 7d1a2b91e..046b905ae 100644 --- a/src/widgets/splits/Split.cpp +++ b/src/widgets/splits/Split.cpp @@ -192,8 +192,12 @@ namespace { void showTutorialVideo(QWidget *parent, const QString &source, const QString &title, const QString &description) { - auto window = - new BasePopup(BaseWindow::Flags::EnableCustomFrame, parent); + auto *window = new BasePopup( + { + BaseWindow::EnableCustomFrame, + BaseWindow::BoundsCheckOnShow, + }, + parent); window->setWindowTitle("Chatterino - " + title); window->setAttribute(Qt::WA_DeleteOnClose); auto layout = new QVBoxLayout(); @@ -1393,7 +1397,9 @@ void Split::showChatterList() multiWidget->setLayout(dockVbox); chatterDock->setWidget(multiWidget); chatterDock->setFloating(true); - chatterDock->show(); + widgets::showAndMoveWindowTo( + chatterDock, this->mapToGlobal(QPoint{0, this->header_->height()}), + widgets::BoundsChecking::CursorPosition); chatterDock->activateWindow(); } From 0fd4e8ffd60a969d6f3ae2d77ca95c21138f0141 Mon Sep 17 00:00:00 2001 From: pajlada Date: Sat, 2 Dec 2023 13:35:55 +0100 Subject: [PATCH 3/4] fix: typo in debug log for hotkeys (#4997) --- src/controllers/hotkeys/HotkeyController.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/controllers/hotkeys/HotkeyController.cpp b/src/controllers/hotkeys/HotkeyController.cpp index 0fc85f97e..ea618d99a 100644 --- a/src/controllers/hotkeys/HotkeyController.cpp +++ b/src/controllers/hotkeys/HotkeyController.cpp @@ -56,7 +56,7 @@ std::vector HotkeyController::shortcutsForCategory( { qCDebug(chatterinoHotkeys) << qPrintable(parent->objectName()) - << "Unimplemeneted hotkey action:" << hotkey->action() << "in " + << "Unimplemented hotkey action:" << hotkey->action() << "in" << hotkey->getCategory(); continue; } From 584a7c86fcd8f9f35354b320ef58293af3beb5e6 Mon Sep 17 00:00:00 2001 From: pajlada Date: Sat, 2 Dec 2023 14:04:43 +0100 Subject: [PATCH 4/4] Move clang-tidy to its own CI job (#4996) * Only run the `post-clang-tidy-review` if the `clang-tidy` build succeeded --- .github/workflows/build.yml | 38 ----- .github/workflows/clang-tidy.yml | 148 +++++++++++++++++++ .github/workflows/post-clang-tidy-review.yml | 4 +- CHANGELOG.md | 1 + 4 files changed, 152 insertions(+), 39 deletions(-) create mode 100644 .github/workflows/clang-tidy.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 308707978..70a952134 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -37,7 +37,6 @@ jobs: plugins: false skip-artifact: false skip-crashpad: false - clang-tidy-review: false # Ubuntu 22.04, Qt 5.15 - os: ubuntu-22.04 qt-version: 5.15.2 @@ -45,7 +44,6 @@ jobs: plugins: false skip-artifact: false skip-crashpad: false - clang-tidy-review: true # Ubuntu 22.04, Qt 6.2.4 - tests LTO & plugins - os: ubuntu-22.04 qt-version: 6.2.4 @@ -53,7 +51,6 @@ jobs: plugins: true skip-artifact: false skip-crashpad: false - clang-tidy-review: false # macOS - os: macos-latest qt-version: 5.15.2 @@ -61,7 +58,6 @@ jobs: plugins: false skip-artifact: false skip-crashpad: false - clang-tidy-review: false # Windows - os: windows-latest qt-version: 6.5.0 @@ -69,7 +65,6 @@ jobs: plugins: false skip-artifact: false skip-crashpad: false - clang-tidy-review: false # Windows 7/8 - os: windows-latest qt-version: 5.15.2 @@ -77,7 +72,6 @@ jobs: plugins: false skip-artifact: false skip-crashpad: true - clang-tidy-review: false fail-fast: false @@ -329,38 +323,6 @@ jobs: make -j"$(nproc)" shell: bash - - name: clang-tidy review - if: matrix.clang-tidy-review && github.event_name == 'pull_request' - timeout-minutes: 10 - uses: ZedThree/clang-tidy-review@v0.14.0 - with: - build_dir: build-clang-tidy - config_file: ".clang-tidy" - split_workflow: true - exclude: "lib/*" - cmake_command: >- - cmake -S. -Bbuild-clang-tidy - -DCMAKE_BUILD_TYPE=Release - -DPAJLADA_SETTINGS_USE_BOOST_FILESYSTEM=On - -DUSE_PRECOMPILED_HEADERS=OFF - -DCMAKE_EXPORT_COMPILE_COMMANDS=On - -DCHATTERINO_LTO=Off - -DCHATTERINO_PLUGINS=On - -DBUILD_WITH_QT6=Off - -DBUILD_TESTS=On - -DBUILD_BENCHMARKS=On - apt_packages: >- - qttools5-dev, qt5-image-formats-plugins, libqt5svg5-dev, - libsecret-1-dev, - libboost-dev, libboost-system-dev, libboost-filesystem-dev, - libssl-dev, - rapidjson-dev, - libbenchmark-dev - - - name: clang-tidy-review upload - if: matrix.clang-tidy-review && github.event_name == 'pull_request' - uses: ZedThree/clang-tidy-review/upload@v0.14.0 - - name: Package - AppImage (Ubuntu) if: startsWith(matrix.os, 'ubuntu-20.04') && !matrix.skip-artifact run: | diff --git a/.github/workflows/clang-tidy.yml b/.github/workflows/clang-tidy.yml new file mode 100644 index 000000000..96468c137 --- /dev/null +++ b/.github/workflows/clang-tidy.yml @@ -0,0 +1,148 @@ +--- +name: clang-tidy + +on: + pull_request: + +concurrency: + group: clang-tidy-${{ github.ref }} + cancel-in-progress: true + +env: + CHATTERINO_REQUIRE_CLEAN_GIT: On + C2_BUILD_WITH_QT6: Off + +jobs: + build: + name: "clang-tidy ${{ matrix.os }}, Qt ${{ matrix.qt-version }})" + runs-on: ${{ matrix.os }} + strategy: + matrix: + include: + # Ubuntu 22.04, Qt 5.15 + - os: ubuntu-22.04 + qt-version: 5.15.2 + plugins: false + + fail-fast: false + + steps: + - name: Enable plugin support + if: matrix.plugins + run: | + echo "C2_PLUGINS=ON" >> "$GITHUB_ENV" + shell: bash + + - name: Set BUILD_WITH_QT6 + if: startsWith(matrix.qt-version, '6.') + run: | + echo "C2_BUILD_WITH_QT6=ON" >> "$GITHUB_ENV" + shell: bash + + - uses: actions/checkout@v4 + with: + submodules: recursive + fetch-depth: 0 # allows for tags access + + - name: Install Qt5 + if: startsWith(matrix.qt-version, '5.') + uses: jurplel/install-qt-action@v3.3.0 + with: + cache: true + cache-key-prefix: ${{ runner.os }}-QtCache-${{ matrix.qt-version }}-v2 + version: ${{ matrix.qt-version }} + + - name: Install Qt 6.5.3 imageformats + if: startsWith(matrix.qt-version, '6.') + uses: jurplel/install-qt-action@v3.3.0 + with: + cache: false + modules: qtimageformats + set-env: false + version: 6.5.3 + extra: --noarchives + + - name: Install Qt6 + if: startsWith(matrix.qt-version, '6.') + uses: jurplel/install-qt-action@v3.3.0 + with: + cache: true + cache-key-prefix: ${{ runner.os }}-QtCache-${{ matrix.qt-version }}-v2 + modules: qt5compat qtimageformats + version: ${{ matrix.qt-version }} + + # LINUX + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get -y install \ + cmake \ + virtualenv \ + rapidjson-dev \ + libfuse2 \ + libssl-dev \ + libboost-dev \ + libxcb-randr0-dev \ + libboost-system-dev \ + libboost-filesystem-dev \ + libpulse-dev \ + libxkbcommon-x11-0 \ + build-essential \ + libgl1-mesa-dev \ + libxcb-icccm4 \ + libxcb-image0 \ + libxcb-keysyms1 \ + libxcb-render-util0 \ + libxcb-xinerama0 + + - name: Apply Qt5 patches + if: startsWith(matrix.qt-version, '5.') + run: | + patch "$Qt5_DIR/include/QtConcurrent/qtconcurrentthreadengine.h" .patches/qt5-on-newer-gcc.patch + shell: bash + + - name: Build + run: | + mkdir build + cd build + CXXFLAGS=-fno-sized-deallocation cmake \ + -DCMAKE_INSTALL_PREFIX=appdir/usr/ \ + -DCMAKE_BUILD_TYPE=Release \ + -DPAJLADA_SETTINGS_USE_BOOST_FILESYSTEM=On \ + -DUSE_PRECOMPILED_HEADERS=OFF \ + -DCMAKE_EXPORT_COMPILE_COMMANDS=On \ + -DCHATTERINO_LTO="$C2_ENABLE_LTO" \ + -DCHATTERINO_PLUGINS="$C2_PLUGINS" \ + -DBUILD_WITH_QT6="$C2_BUILD_WITH_QT6" \ + .. + shell: bash + + - name: clang-tidy review + timeout-minutes: 20 + uses: ZedThree/clang-tidy-review@v0.14.0 + with: + build_dir: build-clang-tidy + config_file: ".clang-tidy" + split_workflow: true + exclude: "lib/*" + cmake_command: >- + cmake -S. -Bbuild-clang-tidy + -DCMAKE_BUILD_TYPE=Release + -DPAJLADA_SETTINGS_USE_BOOST_FILESYSTEM=On + -DUSE_PRECOMPILED_HEADERS=OFF + -DCMAKE_EXPORT_COMPILE_COMMANDS=On + -DCHATTERINO_LTO=Off + -DCHATTERINO_PLUGINS=On + -DBUILD_WITH_QT6=Off + -DBUILD_TESTS=On + -DBUILD_BENCHMARKS=On + apt_packages: >- + qttools5-dev, qt5-image-formats-plugins, libqt5svg5-dev, + libsecret-1-dev, + libboost-dev, libboost-system-dev, libboost-filesystem-dev, + libssl-dev, + rapidjson-dev, + libbenchmark-dev + + - name: clang-tidy-review upload + uses: ZedThree/clang-tidy-review/upload@v0.14.0 diff --git a/.github/workflows/post-clang-tidy-review.yml b/.github/workflows/post-clang-tidy-review.yml index e611a24f0..92ef0820c 100644 --- a/.github/workflows/post-clang-tidy-review.yml +++ b/.github/workflows/post-clang-tidy-review.yml @@ -3,13 +3,15 @@ name: Post clang-tidy review comments on: workflow_run: - workflows: ["Build"] + workflows: ["clang-tidy"] types: - completed jobs: build: runs-on: ubuntu-latest + # Only when a build succeeds + if: ${{ github.event.workflow_run.conclusion == 'success' }} steps: - uses: ZedThree/clang-tidy-review/post@v0.14.0 diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ee1403f8..89bd46229 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -75,6 +75,7 @@ - Dev: `Details` file properties tab is now populated on Windows. (#4912) - Dev: Removed `Outcome` from network requests. (#4959) - Dev: Added Tests for Windows and MacOS in CI. (#4970) +- Dev: Move `clang-tidy` checker to its own CI job. (#4996) - Dev: Refactored the Image Uploader feature. (#4971) - Dev: Fixed deadlock and use-after-free in tests. (#4981)