Merge branch 'master' into fix/stop_windows_code_from_abort()ing_our_process

This commit is contained in:
pajlada 2023-12-03 13:01:16 +01:00 committed by GitHub
commit ca97fa4d76
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
40 changed files with 301 additions and 117 deletions

View file

@ -37,7 +37,6 @@ jobs:
plugins: false plugins: false
skip-artifact: false skip-artifact: false
skip-crashpad: false skip-crashpad: false
clang-tidy-review: false
# Ubuntu 22.04, Qt 5.15 # Ubuntu 22.04, Qt 5.15
- os: ubuntu-22.04 - os: ubuntu-22.04
qt-version: 5.15.2 qt-version: 5.15.2
@ -45,7 +44,6 @@ jobs:
plugins: false plugins: false
skip-artifact: false skip-artifact: false
skip-crashpad: false skip-crashpad: false
clang-tidy-review: true
# Ubuntu 22.04, Qt 6.2.4 - tests LTO & plugins # Ubuntu 22.04, Qt 6.2.4 - tests LTO & plugins
- os: ubuntu-22.04 - os: ubuntu-22.04
qt-version: 6.2.4 qt-version: 6.2.4
@ -53,7 +51,6 @@ jobs:
plugins: true plugins: true
skip-artifact: false skip-artifact: false
skip-crashpad: false skip-crashpad: false
clang-tidy-review: false
# macOS # macOS
- os: macos-latest - os: macos-latest
qt-version: 5.15.2 qt-version: 5.15.2
@ -61,7 +58,6 @@ jobs:
plugins: false plugins: false
skip-artifact: false skip-artifact: false
skip-crashpad: false skip-crashpad: false
clang-tidy-review: false
# Windows # Windows
- os: windows-latest - os: windows-latest
qt-version: 6.5.0 qt-version: 6.5.0
@ -69,7 +65,6 @@ jobs:
plugins: false plugins: false
skip-artifact: false skip-artifact: false
skip-crashpad: false skip-crashpad: false
clang-tidy-review: false
# Windows 7/8 # Windows 7/8
- os: windows-latest - os: windows-latest
qt-version: 5.15.2 qt-version: 5.15.2
@ -77,7 +72,6 @@ jobs:
plugins: false plugins: false
skip-artifact: false skip-artifact: false
skip-crashpad: true skip-crashpad: true
clang-tidy-review: false
fail-fast: false fail-fast: false
@ -329,38 +323,6 @@ jobs:
make -j"$(nproc)" make -j"$(nproc)"
shell: bash 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) - name: Package - AppImage (Ubuntu)
if: startsWith(matrix.os, 'ubuntu-20.04') && !matrix.skip-artifact if: startsWith(matrix.os, 'ubuntu-20.04') && !matrix.skip-artifact
run: | run: |

148
.github/workflows/clang-tidy.yml vendored Normal file
View file

@ -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

View file

@ -3,13 +3,15 @@ name: Post clang-tidy review comments
on: on:
workflow_run: workflow_run:
workflows: ["Build"] workflows: ["clang-tidy"]
types: types:
- completed - completed
jobs: jobs:
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
# Only when a build succeeds
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps: steps:
- uses: ZedThree/clang-tidy-review/post@v0.14.0 - uses: ZedThree/clang-tidy-review/post@v0.14.0

View file

@ -43,6 +43,7 @@
- Bugfix: Fixed lookahead/-behind not working in _Ignores_. (#4965) - 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 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 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: 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: Change clang-format from v14 to v16. (#4929)
- Dev: Fixed UTF16 encoding of `modes` file for the installer. (#4791) - Dev: Fixed UTF16 encoding of `modes` file for the installer. (#4791)
@ -61,6 +62,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 `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: 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 vcpkg to use Qt6. (#4872)
- Dev: Update `magic_enum` to v0.9.5. (#4992)
- Dev: Replace `boost::optional` with `std::optional`. (#4877) - Dev: Replace `boost::optional` with `std::optional`. (#4877)
- Dev: Improve performance of selecting text. (#4889, #4911) - Dev: Improve performance of selecting text. (#4889, #4911)
- Dev: Removed direct dependency on Qt 5 compatibility module. (#4906) - Dev: Removed direct dependency on Qt 5 compatibility module. (#4906)
@ -73,6 +75,7 @@
- Dev: `Details` file properties tab is now populated on Windows. (#4912) - Dev: `Details` file properties tab is now populated on Windows. (#4912)
- Dev: Removed `Outcome` from network requests. (#4959) - Dev: Removed `Outcome` from network requests. (#4959)
- Dev: Added Tests for Windows and MacOS in CI. (#4970) - 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: Refactored the Image Uploader feature. (#4971)
- Dev: Fixed deadlock and use-after-free in tests. (#4981) - Dev: Fixed deadlock and use-after-free in tests. (#4981)
- Dev: Cleanly exit Chatterino instead of force exiting. (#4993) - Dev: Cleanly exit Chatterino instead of force exiting. (#4993)

View file

@ -32,9 +32,6 @@ IncludeCategories:
# Project includes # Project includes
- Regex: '^"[a-zA-Z\._-]+(/[a-zA-Z0-9\._-]+)*"$' - Regex: '^"[a-zA-Z\._-]+(/[a-zA-Z0-9\._-]+)*"$'
Priority: 1 Priority: 1
# Third party library includes
- Regex: '<[[:alnum:].]+/[a-zA-Z0-9\._\/-]+>'
Priority: 3
# Qt includes # Qt includes
- Regex: '^<Q[a-zA-Z0-9\._\/-]+>$' - Regex: '^<Q[a-zA-Z0-9\._\/-]+>$'
Priority: 3 Priority: 3
@ -42,12 +39,12 @@ IncludeCategories:
# LibCommuni includes # LibCommuni includes
- Regex: "^<Irc[a-zA-Z]+>$" - Regex: "^<Irc[a-zA-Z]+>$"
Priority: 3 Priority: 3
# Misc libraries
- Regex: '^<[a-zA-Z_0-9]+\.h(pp)?>$'
Priority: 3
# Standard library includes # Standard library includes
- Regex: "^<[a-zA-Z_]+>$" - Regex: "^<[a-zA-Z_]+>$"
Priority: 4 Priority: 4
# Third party library includes
- Regex: "^<([a-zA-Z_0-9-]+/)*[a-zA-Z_0-9-]+.h(pp)?>$"
Priority: 3
NamespaceIndentation: Inner NamespaceIndentation: Inner
PointerBindsToType: false PointerBindsToType: false
SpacesBeforeTrailingComments: 2 SpacesBeforeTrailingComments: 2

View file

@ -1,6 +1,6 @@
include(FindPackageHandleStandardArgs) 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) find_package_handle_standard_args(MagicEnum DEFAULT_MSG MagicEnum_INCLUDE_DIR)

@ -1 +1 @@
Subproject commit e1a68e9dd3d2e9180b04c8aeacd4975db745e6b8 Subproject commit e55b9b54d5cf61f8e117cafb17846d7d742dd3b4

View file

@ -32,9 +32,6 @@ IncludeCategories:
# Project includes # Project includes
- Regex: '^"[a-zA-Z\._-]+(/[a-zA-Z0-9\._-]+)*"$' - Regex: '^"[a-zA-Z\._-]+(/[a-zA-Z0-9\._-]+)*"$'
Priority: 1 Priority: 1
# Third party library includes
- Regex: '<[[:alnum:].]+/[a-zA-Z0-9\._\/-]+>'
Priority: 3
# Qt includes # Qt includes
- Regex: '^<Q[a-zA-Z0-9\._\/-]+>$' - Regex: '^<Q[a-zA-Z0-9\._\/-]+>$'
Priority: 3 Priority: 3
@ -42,12 +39,12 @@ IncludeCategories:
# LibCommuni includes # LibCommuni includes
- Regex: "^<Irc[a-zA-Z]+>$" - Regex: "^<Irc[a-zA-Z]+>$"
Priority: 3 Priority: 3
# Misc libraries
- Regex: '^<[a-zA-Z_0-9]+\.h(pp)?>$'
Priority: 3
# Standard library includes # Standard library includes
- Regex: "^<[a-zA-Z_]+>$" - Regex: "^<[a-zA-Z_]+>$"
Priority: 4 Priority: 4
# Third party library includes
- Regex: "^<([a-zA-Z_0-9-]+/)*[a-zA-Z_0-9-]+.h(pp)?>$"
Priority: 3
NamespaceIndentation: Inner NamespaceIndentation: Inner
PointerBindsToType: false PointerBindsToType: false
SpacesBeforeTrailingComments: 2 SpacesBeforeTrailingComments: 2

View file

@ -32,9 +32,6 @@ IncludeCategories:
# Project includes # Project includes
- Regex: '^"[a-zA-Z\._-]+(/[a-zA-Z0-9\._-]+)*"$' - Regex: '^"[a-zA-Z\._-]+(/[a-zA-Z0-9\._-]+)*"$'
Priority: 1 Priority: 1
# Third party library includes
- Regex: '<[[:alnum:].]+/[a-zA-Z0-9\._\/-]+>'
Priority: 3
# Qt includes # Qt includes
- Regex: '^<Q[a-zA-Z0-9\._\/-]+>$' - Regex: '^<Q[a-zA-Z0-9\._\/-]+>$'
Priority: 3 Priority: 3
@ -42,12 +39,12 @@ IncludeCategories:
# LibCommuni includes # LibCommuni includes
- Regex: "^<Irc[a-zA-Z]+>$" - Regex: "^<Irc[a-zA-Z]+>$"
Priority: 3 Priority: 3
# Misc libraries
- Regex: '^<[a-zA-Z_0-9]+\.h(pp)?>$'
Priority: 3
# Standard library includes # Standard library includes
- Regex: "^<[a-zA-Z_]+>$" - Regex: "^<[a-zA-Z_]+>$"
Priority: 4 Priority: 4
# Third party library includes
- Regex: "^<([a-zA-Z_0-9-]+/)*[a-zA-Z_0-9-]+.h(pp)?>$"
Priority: 3
NamespaceIndentation: Inner NamespaceIndentation: Inner
PointerBindsToType: false PointerBindsToType: false
SpacesBeforeTrailingComments: 2 SpacesBeforeTrailingComments: 2

View file

@ -1,6 +1,6 @@
#pragma once #pragma once
#include <magic_enum.hpp> #include <magic_enum/magic_enum.hpp>
#include <pajlada/settings.hpp> #include <pajlada/settings.hpp>
#include <QString> #include <QString>

View file

@ -56,7 +56,7 @@ std::vector<QShortcut *> HotkeyController::shortcutsForCategory(
{ {
qCDebug(chatterinoHotkeys) qCDebug(chatterinoHotkeys)
<< qPrintable(parent->objectName()) << qPrintable(parent->objectName())
<< "Unimplemeneted hotkey action:" << hotkey->action() << "in " << "Unimplemented hotkey action:" << hotkey->action() << "in"
<< hotkey->getCategory(); << hotkey->getCategory();
continue; continue;
} }

View file

@ -4,7 +4,7 @@
# include <lua.h> # include <lua.h>
# include <lualib.h> # include <lualib.h>
# include <magic_enum.hpp> # include <magic_enum/magic_enum.hpp>
# include <QList> # include <QList>
# include <string> # include <string>

View file

@ -4,7 +4,7 @@
# include "controllers/commands/CommandController.hpp" # include "controllers/commands/CommandController.hpp"
# include <lua.h> # include <lua.h>
# include <magic_enum.hpp> # include <magic_enum/magic_enum.hpp>
# include <QJsonArray> # include <QJsonArray>
# include <QJsonObject> # include <QJsonObject>

View file

@ -1,6 +1,6 @@
#pragma once #pragma once
#include <magic_enum.hpp> #include <magic_enum/magic_enum.hpp>
namespace chatterino::seventv { namespace chatterino::seventv {

View file

@ -2,7 +2,7 @@
#include "providers/seventv/eventapi/Subscription.hpp" #include "providers/seventv/eventapi/Subscription.hpp"
#include <magic_enum.hpp> #include <magic_enum/magic_enum.hpp>
#include <QJsonDocument> #include <QJsonDocument>
#include <QJsonObject> #include <QJsonObject>
#include <QString> #include <QString>

View file

@ -1,6 +1,6 @@
#pragma once #pragma once
#include <magic_enum.hpp> #include <magic_enum/magic_enum.hpp>
#include <QByteArray> #include <QByteArray>
#include <QHash> #include <QHash>
#include <QJsonObject> #include <QJsonObject>

View file

@ -6,7 +6,7 @@
#include "common/QLogging.hpp" #include "common/QLogging.hpp"
#include "util/CancellationToken.hpp" #include "util/CancellationToken.hpp"
#include <magic_enum.hpp> #include <magic_enum/magic_enum.hpp>
#include <QJsonDocument> #include <QJsonDocument>
namespace { namespace {

View file

@ -1,6 +1,6 @@
#pragma once #pragma once
#include <magic_enum.hpp> #include <magic_enum/magic_enum.hpp>
#include <QColor> #include <QColor>
#include <QJsonObject> #include <QJsonObject>
#include <QString> #include <QString>

View file

@ -1,6 +1,6 @@
#pragma once #pragma once
#include <magic_enum.hpp> #include <magic_enum/magic_enum.hpp>
#include <QJsonDocument> #include <QJsonDocument>
#include <QJsonObject> #include <QJsonObject>
#include <QString> #include <QString>

View file

@ -1,6 +1,6 @@
#pragma once #pragma once
#include <magic_enum.hpp> #include <magic_enum/magic_enum.hpp>
#include <QJsonObject> #include <QJsonObject>
#include <QString> #include <QString>

View file

@ -1,6 +1,6 @@
#pragma once #pragma once
#include <magic_enum.hpp> #include <magic_enum/magic_enum.hpp>
#include <QJsonObject> #include <QJsonObject>
#include <QString> #include <QString>

View file

@ -1,6 +1,6 @@
#pragma once #pragma once
#include <magic_enum.hpp> #include <magic_enum/magic_enum.hpp>
#include <QColor> #include <QColor>
#include <QJsonObject> #include <QJsonObject>
#include <QString> #include <QString>

View file

@ -87,8 +87,7 @@ void WindowManager::showAccountSelectPopup(QPoint point)
w->refresh(); w->refresh();
QPoint buttonPos = point; w->moveTo(point - QPoint(30, 0), widgets::BoundsChecking::CursorPosition);
w->move(buttonPos.x() - 30, buttonPos.y());
w->show(); w->show();
w->setFocus(); w->setFocus();
} }

View file

@ -24,7 +24,7 @@ void initUpdateButton(Button &button,
globalPoint.setX(0); globalPoint.setX(0);
} }
dialog->move(globalPoint); dialog->moveTo(globalPoint, widgets::BoundsChecking::DesiredPosition);
dialog->show(); dialog->show();
dialog->raise(); dialog->raise();

View file

@ -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 } // namespace chatterino::widgets

View file

@ -26,4 +26,14 @@ enum class BoundsChecking {
void moveWindowTo(QWidget *window, QPoint position, void moveWindowTo(QWidget *window, QPoint position,
BoundsChecking mode = BoundsChecking::DesiredPosition); 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 } // namespace chatterino::widgets

View file

@ -508,6 +508,11 @@ void BaseWindow::moveTo(QPoint point, widgets::BoundsChecking mode)
widgets::moveWindowTo(this, point, mode); widgets::moveWindowTo(this, point, mode);
} }
void BaseWindow::showAndMoveTo(QPoint point, widgets::BoundsChecking mode)
{
widgets::showAndMoveWindowTo(this, point, mode);
}
void BaseWindow::resizeEvent(QResizeEvent *) void BaseWindow::resizeEvent(QResizeEvent *)
{ {
// Queue up save because: Window resized // Queue up save because: Window resized
@ -559,6 +564,12 @@ void BaseWindow::closeEvent(QCloseEvent *)
void BaseWindow::showEvent(QShowEvent *) 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) #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)

View file

@ -27,14 +27,15 @@ class BaseWindow : public BaseWidget
public: public:
enum Flags { enum Flags {
None = 0, None = 0,
EnableCustomFrame = 1, EnableCustomFrame = 1 << 0,
Frameless = 2, Frameless = 1 << 1,
TopMost = 4, TopMost = 1 << 2,
DisableCustomScaling = 8, DisableCustomScaling = 1 << 3,
FramelessDraggable = 16, FramelessDraggable = 1 << 4,
DontFocus = 32, DontFocus = 1 << 5,
Dialog = 64, Dialog = 1 << 6,
DisableLayoutSave = 128, DisableLayoutSave = 1 << 7,
BoundsCheckOnShow = 1 << 8,
}; };
enum ActionOnFocusLoss { Nothing, Delete, Close, Hide }; enum ActionOnFocusLoss { Nothing, Delete, Close, Hide };
@ -57,6 +58,12 @@ public:
void moveTo(QPoint point, widgets::BoundsChecking mode); 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 scale() const override;
float qtFontScale() const; float qtFontScale() const;

View file

@ -13,8 +13,13 @@
namespace chatterino { namespace chatterino {
ColorPickerDialog::ColorPickerDialog(const QColor &initial, QWidget *parent) ColorPickerDialog::ColorPickerDialog(const QColor &initial, QWidget *parent)
: BasePopup({BaseWindow::EnableCustomFrame, BaseWindow::DisableLayoutSave}, : BasePopup(
parent) {
BaseWindow::EnableCustomFrame,
BaseWindow::DisableLayoutSave,
BaseWindow::BoundsCheckOnShow,
},
parent)
, color_() , color_()
, dialogConfirmed_(false) , dialogConfirmed_(false)
{ {

View file

@ -9,8 +9,12 @@
namespace chatterino { namespace chatterino {
QualityPopup::QualityPopup(const QString &channelURL, QStringList options) QualityPopup::QualityPopup(const QString &channelURL, QStringList options)
: BasePopup({BaseWindow::DisableLayoutSave}, : BasePopup(
static_cast<QWidget *>(&(getApp()->windows->getMainWindow()))) {
BaseWindow::DisableLayoutSave,
BaseWindow::BoundsCheckOnShow,
},
static_cast<QWidget *>(&(getApp()->windows->getMainWindow())))
, channelURL_(channelURL) , channelURL_(channelURL)
{ {
this->ui_.selector = new QComboBox(this); this->ui_.selector = new QComboBox(this);

View file

@ -31,9 +31,14 @@
namespace chatterino { namespace chatterino {
SelectChannelDialog::SelectChannelDialog(QWidget *parent) SelectChannelDialog::SelectChannelDialog(QWidget *parent)
: BaseWindow({BaseWindow::Flags::EnableCustomFrame, : BaseWindow(
BaseWindow::Flags::Dialog, BaseWindow::DisableLayoutSave}, {
parent) BaseWindow::Flags::EnableCustomFrame,
BaseWindow::Flags::Dialog,
BaseWindow::DisableLayoutSave,
BaseWindow::BoundsCheckOnShow,
},
parent)
, selectedChannel_(Channel::getEmpty()) , selectedChannel_(Channel::getEmpty())
{ {
this->setWindowTitle("Select a channel to join"); this->setWindowTitle("Select a channel to join");

View file

@ -6,6 +6,7 @@
#include "controllers/hotkeys/HotkeyController.hpp" #include "controllers/hotkeys/HotkeyController.hpp"
#include "singletons/Settings.hpp" #include "singletons/Settings.hpp"
#include "util/LayoutCreator.hpp" #include "util/LayoutCreator.hpp"
#include "widgets/BaseWindow.hpp"
#include "widgets/helper/Button.hpp" #include "widgets/helper/Button.hpp"
#include "widgets/helper/SettingsDialogTab.hpp" #include "widgets/helper/SettingsDialogTab.hpp"
#include "widgets/settingspages/AboutPage.hpp" #include "widgets/settingspages/AboutPage.hpp"
@ -29,9 +30,14 @@
namespace chatterino { namespace chatterino {
SettingsDialog::SettingsDialog(QWidget *parent) SettingsDialog::SettingsDialog(QWidget *parent)
: BaseWindow({BaseWindow::Flags::DisableCustomScaling, : BaseWindow(
BaseWindow::Flags::Dialog, BaseWindow::DisableLayoutSave}, {
parent) BaseWindow::Flags::DisableCustomScaling,
BaseWindow::Flags::Dialog,
BaseWindow::DisableLayoutSave,
BaseWindow::BoundsCheckOnShow,
},
parent)
{ {
this->setObjectName("SettingsDialog"); this->setObjectName("SettingsDialog");
this->setWindowTitle("Chatterino Settings"); this->setWindowTitle("Chatterino Settings");
@ -380,9 +386,10 @@ void SettingsDialog::themeChangedEvent()
this->setPalette(palette); this->setPalette(palette);
} }
void SettingsDialog::showEvent(QShowEvent *) void SettingsDialog::showEvent(QShowEvent *e)
{ {
this->ui_.search->setText(""); this->ui_.search->setText("");
BaseWindow::showEvent(e);
} }
///// Widget creation helpers ///// Widget creation helpers

View file

@ -37,9 +37,14 @@ QList<SplitContainer *> openPages(Window *window)
namespace chatterino { namespace chatterino {
QuickSwitcherPopup::QuickSwitcherPopup(Window *parent) QuickSwitcherPopup::QuickSwitcherPopup(Window *parent)
: BasePopup({BaseWindow::Flags::Frameless, BaseWindow::Flags::TopMost, : BasePopup(
BaseWindow::DisableLayoutSave}, {
parent) BaseWindow::Flags::Frameless,
BaseWindow::Flags::TopMost,
BaseWindow::DisableLayoutSave,
BaseWindow::BoundsCheckOnShow,
},
parent)
, switcherModel_(this) , switcherModel_(this)
, window(parent) , window(parent)
{ {

View file

@ -2914,8 +2914,8 @@ void ChannelView::showReplyThreadPopup(const MessagePtr &message)
popup->setThread(message->replyThread); popup->setThread(message->replyThread);
QPoint offset(int(150 * this->scale()), int(70 * this->scale())); QPoint offset(int(150 * this->scale()), int(70 * this->scale()));
popup->move(QCursor::pos() - offset); popup->showAndMoveTo(QCursor::pos() - offset,
popup->show(); widgets::BoundsChecking::CursorPosition);
popup->giveFocus(Qt::MouseFocusReason); popup->giveFocus(Qt::MouseFocusReason);
} }

View file

@ -63,7 +63,12 @@ ChannelPtr SearchPopup::filter(const QString &text, const QString &channelName,
} }
SearchPopup::SearchPopup(QWidget *parent, Split *split) SearchPopup::SearchPopup(QWidget *parent, Split *split)
: BasePopup({BaseWindow::DisableLayoutSave}, parent) : BasePopup(
{
BaseWindow::DisableLayoutSave,
BaseWindow::BoundsCheckOnShow,
},
parent)
, split_(split) , split_(split)
{ {
this->initLayout(); this->initLayout();
@ -180,9 +185,10 @@ void SearchPopup::updateWindowTitle()
this->setWindowTitle("Searching in " + historyName + " history"); this->setWindowTitle("Searching in " + historyName + " history");
} }
void SearchPopup::showEvent(QShowEvent *) void SearchPopup::showEvent(QShowEvent *e)
{ {
this->search(); this->search();
BaseWindow::showEvent(e);
} }
bool SearchPopup::eventFilter(QObject *object, QEvent *event) bool SearchPopup::eventFilter(QObject *object, QEvent *event)

View file

@ -227,9 +227,13 @@ void AboutPage::addLicense(QFormLayout *form, const QString &name,
auto *b = new QLabel("<a href=\"" + licenseLink + "\">show license</a>"); auto *b = new QLabel("<a href=\"" + licenseLink + "\">show license</a>");
QObject::connect( QObject::connect(
b, &QLabel::linkActivated, [parent = this, name, licenseLink] { b, &QLabel::linkActivated, [parent = this, name, licenseLink] {
auto window = new BasePopup({BaseWindow::Flags::EnableCustomFrame, auto *window = new BasePopup(
BaseWindow::DisableLayoutSave}, {
parent); BaseWindow::EnableCustomFrame,
BaseWindow::DisableLayoutSave,
BaseWindow::BoundsCheckOnShow,
},
parent);
window->setWindowTitle("Chatterino - License for " + name); window->setWindowTitle("Chatterino - License for " + name);
window->setAttribute(Qt::WA_DeleteOnClose); window->setAttribute(Qt::WA_DeleteOnClose);
auto layout = new QVBoxLayout(); auto layout = new QVBoxLayout();

View file

@ -45,9 +45,8 @@ FiltersPage::FiltersPage()
}); });
// We can safely ignore this signal connection since we own the view // We can safely ignore this signal connection since we own the view
std::ignore = view->addButtonPressed.connect([] { std::ignore = view->addButtonPressed.connect([this] {
ChannelFilterEditorDialog d( ChannelFilterEditorDialog d(this->window());
static_cast<QWidget *>(&(getApp()->windows->getMainWindow())));
if (d.exec() == QDialog::Accepted) if (d.exec() == QDialog::Accepted)
{ {
getSettings()->filterRecords.append( getSettings()->filterRecords.append(

View file

@ -21,7 +21,7 @@
#include "widgets/settingspages/GeneralPageView.hpp" #include "widgets/settingspages/GeneralPageView.hpp"
#include "widgets/splits/SplitInput.hpp" #include "widgets/splits/SplitInput.hpp"
#include <magic_enum.hpp> #include <magic_enum/magic_enum.hpp>
#include <QDesktopServices> #include <QDesktopServices>
#include <QFileDialog> #include <QFileDialog>
#include <QFontDialog> #include <QFontDialog>

View file

@ -192,8 +192,12 @@ namespace {
void showTutorialVideo(QWidget *parent, const QString &source, void showTutorialVideo(QWidget *parent, const QString &source,
const QString &title, const QString &description) const QString &title, const QString &description)
{ {
auto window = auto *window = new BasePopup(
new BasePopup(BaseWindow::Flags::EnableCustomFrame, parent); {
BaseWindow::EnableCustomFrame,
BaseWindow::BoundsCheckOnShow,
},
parent);
window->setWindowTitle("Chatterino - " + title); window->setWindowTitle("Chatterino - " + title);
window->setAttribute(Qt::WA_DeleteOnClose); window->setAttribute(Qt::WA_DeleteOnClose);
auto layout = new QVBoxLayout(); auto layout = new QVBoxLayout();
@ -1393,7 +1397,9 @@ void Split::showChatterList()
multiWidget->setLayout(dockVbox); multiWidget->setLayout(dockVbox);
chatterDock->setWidget(multiWidget); chatterDock->setWidget(multiWidget);
chatterDock->setFloating(true); chatterDock->setFloating(true);
chatterDock->show(); widgets::showAndMoveWindowTo(
chatterDock, this->mapToGlobal(QPoint{0, this->header_->height()}),
widgets::BoundsChecking::CursorPosition);
chatterDock->activateWindow(); chatterDock->activateWindow();
} }

View file

@ -32,9 +32,6 @@ IncludeCategories:
# Project includes # Project includes
- Regex: '^"[a-zA-Z\._-]+(/[a-zA-Z0-9\._-]+)*"$' - Regex: '^"[a-zA-Z\._-]+(/[a-zA-Z0-9\._-]+)*"$'
Priority: 1 Priority: 1
# Third party library includes
- Regex: '<[[:alnum:].]+/[a-zA-Z0-9\._\/-]+>'
Priority: 3
# Qt includes # Qt includes
- Regex: '^<Q[a-zA-Z0-9\._\/-]+>$' - Regex: '^<Q[a-zA-Z0-9\._\/-]+>$'
Priority: 3 Priority: 3
@ -42,12 +39,12 @@ IncludeCategories:
# LibCommuni includes # LibCommuni includes
- Regex: "^<Irc[a-zA-Z]+>$" - Regex: "^<Irc[a-zA-Z]+>$"
Priority: 3 Priority: 3
# Misc libraries
- Regex: '^<[a-zA-Z_0-9]+\.h(pp)?>$'
Priority: 3
# Standard library includes # Standard library includes
- Regex: "^<[a-zA-Z_]+>$" - Regex: "^<[a-zA-Z_]+>$"
Priority: 4 Priority: 4
# Third party library includes
- Regex: "^<([a-zA-Z_0-9-]+/)*[a-zA-Z_0-9-]+.h(pp)?>$"
Priority: 3
NamespaceIndentation: Inner NamespaceIndentation: Inner
PointerBindsToType: false PointerBindsToType: false
SpacesBeforeTrailingComments: 2 SpacesBeforeTrailingComments: 2