mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
Fix merge conflicts
This commit is contained in:
commit
b6f632701f
15 changed files with 74 additions and 65 deletions
|
@ -44,12 +44,12 @@
|
|||
|
||||
namespace AB_NAMESPACE {
|
||||
|
||||
BaseWindow::BaseWindow(QWidget *parent, Flags _flags)
|
||||
BaseWindow::BaseWindow(FlagsEnum<Flags> _flags, QWidget *parent)
|
||||
: BaseWidget(parent,
|
||||
Qt::Window | ((_flags & TopMost) ? Qt::WindowStaysOnTopHint
|
||||
: Qt::WindowFlags()))
|
||||
, enableCustomFrame_(_flags & EnableCustomFrame)
|
||||
, frameless_(_flags & Frameless)
|
||||
Qt::Window | (_flags.has(TopMost) ? Qt::WindowStaysOnTopHint
|
||||
: Qt::WindowFlags()))
|
||||
, enableCustomFrame_(_flags.has(EnableCustomFrame))
|
||||
, frameless_(_flags.has(Frameless))
|
||||
, flags_(_flags)
|
||||
{
|
||||
if (this->frameless_)
|
||||
|
@ -74,8 +74,6 @@ BaseWindow::BaseWindow(QWidget *parent, Flags _flags)
|
|||
createWindowShortcut(this, "CTRL+0",
|
||||
[] { getSettings()->uiScale.setValue(1); });
|
||||
|
||||
// QTimer::this->scaleChangedEvent(this->getScale());
|
||||
|
||||
this->resize(300, 150);
|
||||
|
||||
#ifdef USEWINSDK
|
||||
|
@ -113,11 +111,6 @@ float BaseWindow::qtFontScale() const
|
|||
return this->scale() / this->nativeScale_;
|
||||
}
|
||||
|
||||
BaseWindow::Flags BaseWindow::getFlags()
|
||||
{
|
||||
return this->flags_;
|
||||
}
|
||||
|
||||
void BaseWindow::init()
|
||||
{
|
||||
this->setWindowIcon(QIcon(":/images/icon.png"));
|
||||
|
@ -206,7 +199,7 @@ void BaseWindow::init()
|
|||
|
||||
#ifdef USEWINSDK
|
||||
// fourtf: don't ask me why we need to delay this
|
||||
if (!(this->flags_ & Flags::TopMost))
|
||||
if (!this->flags_.has(TopMost))
|
||||
{
|
||||
QTimer::singleShot(1, this, [this] {
|
||||
getSettings()->windowTopMost.connect(
|
||||
|
@ -370,7 +363,7 @@ void BaseWindow::onFocusLost()
|
|||
void BaseWindow::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
#ifndef Q_OS_WIN
|
||||
if (this->flags_ & FramelessDraggable)
|
||||
if (this->flags_.has(FramelessDraggable))
|
||||
{
|
||||
this->movingRelativePos = event->localPos();
|
||||
if (auto widget =
|
||||
|
@ -406,7 +399,7 @@ void BaseWindow::mousePressEvent(QMouseEvent *event)
|
|||
void BaseWindow::mouseReleaseEvent(QMouseEvent *event)
|
||||
{
|
||||
#ifndef Q_OS_WIN
|
||||
if (this->flags_ & FramelessDraggable)
|
||||
if (this->flags_.has(FramelessDraggable))
|
||||
{
|
||||
if (this->moving)
|
||||
{
|
||||
|
@ -422,7 +415,7 @@ void BaseWindow::mouseReleaseEvent(QMouseEvent *event)
|
|||
void BaseWindow::mouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
#ifndef Q_OS_WIN
|
||||
if (this->flags_ & FramelessDraggable)
|
||||
if (this->flags_.has(FramelessDraggable))
|
||||
{
|
||||
if (this->moving)
|
||||
{
|
||||
|
@ -541,6 +534,18 @@ void BaseWindow::closeEvent(QCloseEvent *)
|
|||
this->closing.invoke();
|
||||
}
|
||||
|
||||
void BaseWindow::showEvent(QShowEvent *)
|
||||
{
|
||||
if (this->frameless_)
|
||||
{
|
||||
this->moveIntoDesktopRect(this);
|
||||
qDebug() << "show";
|
||||
|
||||
QTimer::singleShot(30, this,
|
||||
[this] { this->moveIntoDesktopRect(this); });
|
||||
}
|
||||
}
|
||||
|
||||
void BaseWindow::moveIntoDesktopRect(QWidget *parent)
|
||||
{
|
||||
if (!this->stayInScreenRect_)
|
||||
|
@ -649,7 +654,7 @@ void BaseWindow::paintEvent(QPaintEvent *)
|
|||
void BaseWindow::updateScale()
|
||||
{
|
||||
auto scale =
|
||||
this->nativeScale_ * (this->flags_ & DisableCustomScaling
|
||||
this->nativeScale_ * (this->flags_.has(DisableCustomScaling)
|
||||
? 1
|
||||
: getABSettings()->getClampedUiScale());
|
||||
|
||||
|
@ -708,17 +713,11 @@ bool BaseWindow::handleDPICHANGED(MSG *msg)
|
|||
|
||||
float _scale = dpi / 96.f;
|
||||
|
||||
static bool firstResize = true;
|
||||
|
||||
if (!firstResize)
|
||||
{
|
||||
auto *prcNewWindow = reinterpret_cast<RECT *>(msg->lParam);
|
||||
SetWindowPos(msg->hwnd, nullptr, prcNewWindow->left, prcNewWindow->top,
|
||||
prcNewWindow->right - prcNewWindow->left,
|
||||
prcNewWindow->bottom - prcNewWindow->top,
|
||||
SWP_NOZORDER | SWP_NOACTIVATE);
|
||||
}
|
||||
firstResize = false;
|
||||
auto *prcNewWindow = reinterpret_cast<RECT *>(msg->lParam);
|
||||
SetWindowPos(msg->hwnd, nullptr, prcNewWindow->left, prcNewWindow->top,
|
||||
prcNewWindow->right - prcNewWindow->left,
|
||||
prcNewWindow->bottom - prcNewWindow->top,
|
||||
SWP_NOZORDER | SWP_NOACTIVATE);
|
||||
|
||||
this->nativeScale_ = _scale;
|
||||
this->updateScale();
|
||||
|
@ -953,7 +952,7 @@ bool BaseWindow::handleNCHITTEST(MSG *msg, long *result)
|
|||
|
||||
return true;
|
||||
}
|
||||
else if (this->flags_ & FramelessDraggable)
|
||||
else if (this->flags_.has(FramelessDraggable))
|
||||
{
|
||||
*result = 0;
|
||||
bool client = false;
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
#include <functional>
|
||||
#include <pajlada/signals/signalholder.hpp>
|
||||
#include "common/FlagsEnum.hpp"
|
||||
|
||||
class QHBoxLayout;
|
||||
struct tagMSG;
|
||||
|
@ -32,7 +33,8 @@ public:
|
|||
|
||||
enum ActionOnFocusLoss { Nothing, Delete, Close, Hide };
|
||||
|
||||
explicit BaseWindow(QWidget *parent = nullptr, Flags flags_ = None);
|
||||
explicit BaseWindow(FlagsEnum<Flags> flags_ = None,
|
||||
QWidget *parent = nullptr);
|
||||
|
||||
void setInitialBounds(const QRect &bounds);
|
||||
QRect getBounds();
|
||||
|
@ -54,8 +56,6 @@ public:
|
|||
virtual float scale() const override;
|
||||
float qtFontScale() const;
|
||||
|
||||
Flags getFlags();
|
||||
|
||||
pajlada::Signals::NoArgSignal closing;
|
||||
|
||||
static bool supportsCustomWindowFrame();
|
||||
|
@ -72,6 +72,7 @@ protected:
|
|||
virtual void resizeEvent(QResizeEvent *) override;
|
||||
virtual void moveEvent(QMoveEvent *) override;
|
||||
virtual void closeEvent(QCloseEvent *) override;
|
||||
virtual void showEvent(QShowEvent *) override;
|
||||
|
||||
virtual void themeChangedEvent() override;
|
||||
virtual bool event(QEvent *event) override;
|
||||
|
@ -106,7 +107,7 @@ private:
|
|||
bool frameless_;
|
||||
bool stayInScreenRect_ = false;
|
||||
bool shown_ = false;
|
||||
Flags flags_;
|
||||
FlagsEnum<Flags> flags_;
|
||||
float nativeScale_ = 1;
|
||||
|
||||
struct {
|
||||
|
|
|
@ -21,7 +21,7 @@ TooltipWidget *TooltipWidget::getInstance()
|
|||
}
|
||||
|
||||
TooltipWidget::TooltipWidget(BaseWidget *parent)
|
||||
: BaseWindow(parent, BaseWindow::TopMost)
|
||||
: BaseWindow(BaseWindow::TopMost, parent)
|
||||
, displayImage_(new QLabel())
|
||||
, displayText_(new QLabel())
|
||||
{
|
||||
|
|
|
@ -143,9 +143,21 @@ bool TwitchMessageBuilder::isIgnored() const
|
|||
return false;
|
||||
}
|
||||
|
||||
inline QMediaPlayer *getPlayer()
|
||||
{
|
||||
if (isGuiThread())
|
||||
{
|
||||
static auto player = new QMediaPlayer;
|
||||
return player;
|
||||
}
|
||||
else
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void TwitchMessageBuilder::triggerHighlights()
|
||||
{
|
||||
static auto player = new QMediaPlayer;
|
||||
static QUrl currentPlayerUrl;
|
||||
|
||||
if (this->historicalMessage_)
|
||||
|
@ -165,21 +177,24 @@ void TwitchMessageBuilder::triggerHighlights()
|
|||
|
||||
if (this->highlightSound_ && resolveFocus)
|
||||
{
|
||||
// update the media player url if necessary
|
||||
QUrl highlightSoundUrl =
|
||||
getSettings()->customHighlightSound
|
||||
? QUrl::fromLocalFile(
|
||||
getSettings()->pathHighlightSound.getValue())
|
||||
: QUrl("qrc:/sounds/ping2.wav");
|
||||
|
||||
if (currentPlayerUrl != highlightSoundUrl)
|
||||
if (auto player = getPlayer())
|
||||
{
|
||||
player->setMedia(highlightSoundUrl);
|
||||
// update the media player url if necessary
|
||||
QUrl highlightSoundUrl =
|
||||
getSettings()->customHighlightSound
|
||||
? QUrl::fromLocalFile(
|
||||
getSettings()->pathHighlightSound.getValue())
|
||||
: QUrl("qrc:/sounds/ping2.wav");
|
||||
|
||||
currentPlayerUrl = highlightSoundUrl;
|
||||
if (currentPlayerUrl != highlightSoundUrl)
|
||||
{
|
||||
player->setMedia(highlightSoundUrl);
|
||||
|
||||
currentPlayerUrl = highlightSoundUrl;
|
||||
}
|
||||
|
||||
player->play();
|
||||
}
|
||||
|
||||
player->play();
|
||||
}
|
||||
|
||||
if (this->highlightAlert_)
|
||||
|
|
|
@ -80,7 +80,6 @@ void WindowManager::showAccountSelectPopup(QPoint point)
|
|||
|
||||
QPoint buttonPos = point;
|
||||
w->move(buttonPos.x() - 30, buttonPos.y());
|
||||
|
||||
w->show();
|
||||
w->setFocus();
|
||||
}
|
||||
|
|
|
@ -11,8 +11,7 @@
|
|||
namespace chatterino {
|
||||
|
||||
AccountSwitchPopup::AccountSwitchPopup(QWidget *parent)
|
||||
: BaseWindow(parent,
|
||||
BaseWindow::Flags(BaseWindow::TopMost | BaseWindow::Frameless))
|
||||
: BaseWindow({BaseWindow::TopMost, BaseWindow::Frameless}, parent)
|
||||
{
|
||||
#ifdef Q_OS_LINUX
|
||||
this->setWindowFlag(Qt::Popup);
|
||||
|
@ -25,8 +24,6 @@ AccountSwitchPopup::AccountSwitchPopup(QWidget *parent)
|
|||
this->ui_.accountSwitchWidget->setFocusPolicy(Qt::NoFocus);
|
||||
vbox->addWidget(this->ui_.accountSwitchWidget);
|
||||
|
||||
// vbox->setSizeConstraint(QLayout::SetMinimumSize);
|
||||
|
||||
auto hbox = new QHBoxLayout();
|
||||
auto manageAccountsButton = new QPushButton(this);
|
||||
manageAccountsButton->setText("Manage Accounts");
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
namespace chatterino {
|
||||
|
||||
Window::Window(WindowType type)
|
||||
: BaseWindow(nullptr, BaseWindow::EnableCustomFrame)
|
||||
: BaseWindow(BaseWindow::EnableCustomFrame)
|
||||
, type_(type)
|
||||
, notebook_(new SplitNotebook(this))
|
||||
{
|
||||
|
|
|
@ -101,7 +101,7 @@ namespace {
|
|||
} // namespace
|
||||
|
||||
EmotePopup::EmotePopup(QWidget *parent)
|
||||
: BaseWindow(parent, BaseWindow::EnableCustomFrame)
|
||||
: BaseWindow(BaseWindow::EnableCustomFrame, parent)
|
||||
{
|
||||
auto layout = new QVBoxLayout(this);
|
||||
this->getLayoutContainer()->setLayout(layout);
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
namespace chatterino {
|
||||
|
||||
NotificationPopup::NotificationPopup()
|
||||
: BaseWindow((QWidget *)nullptr, BaseWindow::Frameless)
|
||||
: BaseWindow(BaseWindow::Frameless)
|
||||
, channel_(std::make_shared<Channel>("notifications", Channel::Type::None))
|
||||
|
||||
{
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
namespace chatterino {
|
||||
|
||||
SelectChannelDialog::SelectChannelDialog(QWidget *parent)
|
||||
: BaseWindow(parent, BaseWindow::EnableCustomFrame)
|
||||
: BaseWindow(BaseWindow::EnableCustomFrame, parent)
|
||||
, selectedChannel_(Channel::getEmpty())
|
||||
{
|
||||
this->setWindowTitle("Select a channel to join");
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace chatterino {
|
|||
SettingsDialog *SettingsDialog::handle = nullptr;
|
||||
|
||||
SettingsDialog::SettingsDialog()
|
||||
: BaseWindow(nullptr, BaseWindow::DisableCustomScaling)
|
||||
: BaseWindow(BaseWindow::DisableCustomScaling)
|
||||
{
|
||||
this->setWindowTitle("Chatterino Settings");
|
||||
|
||||
|
@ -41,7 +41,7 @@ SettingsDialog::SettingsDialog()
|
|||
|
||||
void SettingsDialog::initUi()
|
||||
{
|
||||
auto outerBox = LayoutCreator<SettingsDialog>(this)
|
||||
auto outerBox = LayoutCreator<QWidget>(this->getLayoutContainer())
|
||||
.setLayoutType<QVBoxLayout>()
|
||||
.withoutSpacing();
|
||||
|
||||
|
|
|
@ -11,9 +11,8 @@
|
|||
namespace chatterino {
|
||||
|
||||
UpdateDialog::UpdateDialog()
|
||||
: BaseWindow(nullptr,
|
||||
BaseWindow::Flags(BaseWindow::Frameless | BaseWindow::TopMost |
|
||||
BaseWindow::EnableCustomFrame))
|
||||
: BaseWindow({BaseWindow::Frameless, BaseWindow::TopMost,
|
||||
BaseWindow::EnableCustomFrame})
|
||||
{
|
||||
auto layout =
|
||||
LayoutCreator<UpdateDialog>(this).setLayoutType<QVBoxLayout>();
|
||||
|
|
|
@ -43,8 +43,7 @@ namespace {
|
|||
} // namespace
|
||||
|
||||
UserInfoPopup::UserInfoPopup()
|
||||
: BaseWindow(nullptr, BaseWindow::Flags(BaseWindow::Frameless |
|
||||
BaseWindow::FramelessDraggable))
|
||||
: BaseWindow({BaseWindow::Frameless, BaseWindow::FramelessDraggable})
|
||||
, hack_(new bool)
|
||||
{
|
||||
this->setStayInScreenRect(true);
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
namespace chatterino {
|
||||
|
||||
WelcomeDialog::WelcomeDialog()
|
||||
: BaseWindow(nullptr, BaseWindow::EnableCustomFrame)
|
||||
: BaseWindow(BaseWindow::EnableCustomFrame)
|
||||
{
|
||||
this->setWindowTitle("Chatterino quick setup");
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ namespace {
|
|||
const QString &title, const QString &description)
|
||||
{
|
||||
auto window =
|
||||
new BaseWindow(parent, BaseWindow::Flags::EnableCustomFrame);
|
||||
new BaseWindow(BaseWindow::Flags::EnableCustomFrame, parent);
|
||||
window->setWindowTitle("Chatterino - " + title);
|
||||
window->setAttribute(Qt::WA_DeleteOnClose);
|
||||
auto layout = new QVBoxLayout();
|
||||
|
|
Loading…
Reference in a new issue