mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
added window always on top option
This commit is contained in:
parent
c7feec20d8
commit
1ca4fb46d6
10 changed files with 63 additions and 27 deletions
|
@ -28,10 +28,14 @@ double getMultiplierByTheme(const std::string &themeName)
|
|||
|
||||
} // namespace detail
|
||||
|
||||
ColorScheme *ColorScheme::instance = nullptr;
|
||||
|
||||
ColorScheme::ColorScheme(WindowManager &windowManager)
|
||||
: themeName("/appearance/theme/name", "Dark")
|
||||
, themeHue("/appearance/theme/hue", 0.0)
|
||||
{
|
||||
ColorScheme::instance = this;
|
||||
|
||||
this->update();
|
||||
|
||||
this->themeName.connectSimple([this](auto) { this->update(); });
|
||||
|
@ -135,10 +139,10 @@ void ColorScheme::normalizeColor(QColor &color)
|
|||
}
|
||||
|
||||
if (color.lightnessF() < 0.6f && color.hueF() > 0.54444 && color.hueF() < 0.83333) {
|
||||
color.setHslF(
|
||||
color.hueF(), color.saturationF(),
|
||||
color.lightnessF() + sin((color.hueF() - 0.54444) / (0.8333 - 0.54444) * 3.14159) *
|
||||
color.saturationF() * 0.2);
|
||||
color.setHslF(color.hueF(), color.saturationF(),
|
||||
color.lightnessF() +
|
||||
sin((color.hueF() - 0.54444) / (0.8333 - 0.54444) * 3.14159) *
|
||||
color.saturationF() * 0.2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,8 @@ public:
|
|||
return this->lightTheme;
|
||||
}
|
||||
|
||||
static ColorScheme *instance;
|
||||
|
||||
QString InputStyleSheet;
|
||||
|
||||
QColor SystemMessageColor;
|
||||
|
|
|
@ -19,15 +19,16 @@ namespace chatterino {
|
|||
namespace widgets {
|
||||
|
||||
AccountPopupWidget::AccountPopupWidget(std::shared_ptr<Channel> channel)
|
||||
: QWidget(nullptr)
|
||||
: BaseWidget()
|
||||
, _ui(new Ui::AccountPopup)
|
||||
, _channel(channel)
|
||||
{
|
||||
_ui->setupUi(this);
|
||||
|
||||
resize(0, 0);
|
||||
|
||||
setWindowFlags(Qt::FramelessWindowHint);
|
||||
this->initAsWindow();
|
||||
|
||||
resize(0, 0);
|
||||
|
||||
SettingsManager &settings = SettingsManager::getInstance();
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include "basewidget.hpp"
|
||||
#include "concurrentmap.hpp"
|
||||
#include "twitch/twitchchannel.hpp"
|
||||
|
||||
|
@ -18,7 +19,7 @@ class Channel;
|
|||
|
||||
namespace widgets {
|
||||
|
||||
class AccountPopupWidget : public QWidget
|
||||
class AccountPopupWidget : public BaseWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "widgets/basewidget.hpp"
|
||||
#include "colorscheme.hpp"
|
||||
#include "settingsmanager.hpp"
|
||||
|
||||
//#include <QApplication>
|
||||
#include <QDebug>
|
||||
|
@ -28,6 +29,12 @@ BaseWidget::BaseWidget(BaseWidget *parent)
|
|||
this->init();
|
||||
}
|
||||
|
||||
BaseWidget::BaseWidget(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, colorScheme(*ColorScheme::instance)
|
||||
{
|
||||
}
|
||||
|
||||
float BaseWidget::getDpiMultiplier()
|
||||
{
|
||||
BaseWidget *baseWidget = dynamic_cast<BaseWidget *>(this->window());
|
||||
|
@ -60,6 +67,10 @@ void BaseWidget::initAsWindow()
|
|||
this->dpiMultiplier = dpi.value() / 96.f;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (SettingsManager::getInstance().windowTopMost.getValue()) {
|
||||
this->setWindowFlags(this->windowFlags() | Qt::WindowStaysOnTopHint);
|
||||
}
|
||||
}
|
||||
|
||||
void BaseWidget::refreshTheme()
|
||||
|
|
|
@ -21,6 +21,8 @@ public:
|
|||
|
||||
explicit BaseWidget(BaseWidget *parent);
|
||||
|
||||
explicit BaseWidget(QWidget *parent = nullptr);
|
||||
|
||||
ColorScheme &colorScheme;
|
||||
|
||||
float getDpiMultiplier();
|
||||
|
|
|
@ -6,15 +6,19 @@ namespace chatterino {
|
|||
namespace widgets {
|
||||
|
||||
QualityPopup::QualityPopup(const QString &channel, const QString &path, QStringList options)
|
||||
: channel(channel)
|
||||
: BaseWidget()
|
||||
, channel(channel)
|
||||
, path(path)
|
||||
{
|
||||
this->initAsWindow();
|
||||
|
||||
this->ui.okButton.setText("OK");
|
||||
this->ui.cancelButton.setText("Cancel");
|
||||
|
||||
QObject::connect(&this->ui.okButton, &QPushButton::clicked, this, &QualityPopup::okButtonClicked);
|
||||
QObject::connect(&this->ui.okButton, &QPushButton::clicked, this,
|
||||
&QualityPopup::okButtonClicked);
|
||||
QObject::connect(&this->ui.cancelButton, &QPushButton::clicked, this,
|
||||
&QualityPopup::cancelButtonClicked);
|
||||
&QualityPopup::cancelButtonClicked);
|
||||
|
||||
this->ui.buttonBox.addButton(&this->ui.okButton, QDialogButtonBox::ButtonRole::AcceptRole);
|
||||
this->ui.buttonBox.addButton(&this->ui.cancelButton, QDialogButtonBox::ButtonRole::RejectRole);
|
||||
|
@ -29,7 +33,8 @@ QualityPopup::QualityPopup(const QString &channel, const QString &path, QStringL
|
|||
this->setLayout(&this->ui.vbox);
|
||||
}
|
||||
|
||||
void QualityPopup::showDialog(const QString &channel, const QString &path, QStringList options) {
|
||||
void QualityPopup::showDialog(const QString &channel, const QString &path, QStringList options)
|
||||
{
|
||||
static QualityPopup *instance = new QualityPopup(channel, path, options);
|
||||
|
||||
instance->show();
|
||||
|
@ -38,9 +43,10 @@ void QualityPopup::showDialog(const QString &channel, const QString &path, QStri
|
|||
instance->setFocus();
|
||||
}
|
||||
|
||||
void QualityPopup::okButtonClicked() {
|
||||
void QualityPopup::okButtonClicked()
|
||||
{
|
||||
QProcess::startDetached(this->path,
|
||||
{"twitch.tv/" + this->channel, this->ui.selector.currentText()});
|
||||
{"twitch.tv/" + this->channel, this->ui.selector.currentText()});
|
||||
this->close();
|
||||
}
|
||||
|
||||
|
@ -49,5 +55,5 @@ void QualityPopup::cancelButtonClicked()
|
|||
this->close();
|
||||
}
|
||||
|
||||
} // namespace widgets
|
||||
} // namespace chatterino
|
||||
} // namespace widgets
|
||||
} // namespace chatterino
|
||||
|
|
|
@ -1,22 +1,25 @@
|
|||
#ifndef QUALITYPOPUP_H
|
||||
#define QUALITYPOPUP_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QComboBox>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QHBoxLayout>
|
||||
#include <QPushButton>
|
||||
#include <QVBoxLayout>
|
||||
#include <QWidget>
|
||||
|
||||
#include "basewidget.hpp"
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
namespace widgets {
|
||||
|
||||
class QualityPopup : public QWidget
|
||||
class QualityPopup : public BaseWidget
|
||||
{
|
||||
public:
|
||||
QualityPopup(const QString &channel, const QString &path, QStringList options);
|
||||
static void showDialog(const QString &channel, const QString &path, QStringList options);
|
||||
|
||||
private:
|
||||
struct {
|
||||
QVBoxLayout vbox;
|
||||
|
@ -33,7 +36,7 @@ private:
|
|||
void cancelButtonClicked();
|
||||
};
|
||||
|
||||
} // namespace widgets
|
||||
} // namespace chatterino
|
||||
} // namespace widgets
|
||||
} // namespace chatterino
|
||||
|
||||
#endif // QUALITYPOPUP_H
|
||||
#endif // QUALITYPOPUP_H
|
||||
|
|
|
@ -23,11 +23,14 @@ namespace chatterino {
|
|||
namespace widgets {
|
||||
|
||||
SettingsDialog::SettingsDialog()
|
||||
: snapshot(SettingsManager::getInstance().createSnapshot())
|
||||
: BaseWidget()
|
||||
, snapshot(SettingsManager::getInstance().createSnapshot())
|
||||
, usernameDisplayMode(
|
||||
"/appearance/messages/usernameDisplayMode",
|
||||
twitch::TwitchMessageBuilder::UsernameDisplayMode::UsernameAndLocalizedName)
|
||||
{
|
||||
this->initAsWindow();
|
||||
|
||||
QFile file(":/qss/settings.qss");
|
||||
file.open(QFile::ReadOnly);
|
||||
QString styleSheet = QLatin1String(file.readAll());
|
||||
|
@ -328,7 +331,8 @@ QVBoxLayout *SettingsDialog::createBehaviourTab()
|
|||
|
||||
auto form = new QFormLayout();
|
||||
|
||||
form->addRow("Window:", createCheckbox("Window always on top", settings.windowTopMost));
|
||||
form->addRow("Window:",
|
||||
createCheckbox("Window always on top (requires restart)", settings.windowTopMost));
|
||||
// form->addRow("Messages:", createCheckbox("Mention users with a @ (except in
|
||||
// commands)",
|
||||
// settings.mentionUsersWithAt));
|
||||
|
|
|
@ -18,11 +18,13 @@
|
|||
#include <QWidget>
|
||||
#include <pajlada/settings/setting.hpp>
|
||||
|
||||
#include "basewidget.hpp"
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
namespace widgets {
|
||||
|
||||
class SettingsDialog : public QWidget
|
||||
class SettingsDialog : public BaseWidget
|
||||
{
|
||||
public:
|
||||
SettingsDialog();
|
||||
|
|
Loading…
Reference in a new issue