added window always on top option

This commit is contained in:
fourtf 2017-12-17 16:45:15 +01:00
parent c7feec20d8
commit 1ca4fb46d6
10 changed files with 63 additions and 27 deletions

View file

@ -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,9 +139,9 @@ 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.setHslF(color.hueF(), color.saturationF(),
color.lightnessF() +
sin((color.hueF() - 0.54444) / (0.8333 - 0.54444) * 3.14159) *
color.saturationF() * 0.2);
}
}

View file

@ -19,6 +19,8 @@ public:
return this->lightTheme;
}
static ColorScheme *instance;
QString InputStyleSheet;
QColor SystemMessageColor;

View file

@ -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();

View file

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

View file

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

View file

@ -21,6 +21,8 @@ public:
explicit BaseWidget(BaseWidget *parent);
explicit BaseWidget(QWidget *parent = nullptr);
ColorScheme &colorScheme;
float getDpiMultiplier();

View file

@ -6,13 +6,17 @@ 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);
@ -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,7 +43,8 @@ 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()});
this->close();

View file

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

View file

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

View file

@ -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();