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