updated settingsdialog
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include "widgets/chatwidget.h"
|
||||
#include "channels.h"
|
||||
#include "colorscheme.h"
|
||||
#include "settings/settings.h"
|
||||
#include "widgets/textinputdialog.h"
|
||||
|
||||
#include <QFont>
|
||||
@@ -23,10 +24,6 @@ ChatWidget::ChatWidget(QWidget *parent)
|
||||
this->vbox.setSpacing(0);
|
||||
this->vbox.setMargin(1);
|
||||
|
||||
// header.setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
||||
// view.setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
||||
// input.setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum);
|
||||
|
||||
this->vbox.addWidget(&header);
|
||||
this->vbox.addWidget(&view, 1);
|
||||
this->vbox.addWidget(&input);
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define CHATWIDGET_H
|
||||
|
||||
#include "channel.h"
|
||||
#include "messages/word.h"
|
||||
#include "widgets/chatwidgetheader.h"
|
||||
#include "widgets/chatwidgetinput.h"
|
||||
#include "widgets/chatwidgetview.h"
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "widgets/chatwidgetinput.h"
|
||||
#include "colorscheme.h"
|
||||
#include "settings/settings.h"
|
||||
|
||||
#include <QPainter>
|
||||
|
||||
@@ -38,6 +39,20 @@ ChatWidgetInput::ChatWidgetInput()
|
||||
// this->emotesLabel.setMaximumSize(12, 12);
|
||||
|
||||
this->refreshTheme();
|
||||
|
||||
this->setMessageLengthVisisble(
|
||||
settings::Settings::getInstance().getShowMessageLength().get());
|
||||
|
||||
QObject::connect(&settings::Settings::getInstance().getShowMessageLength(),
|
||||
&settings::BoolSetting::valueChanged, this,
|
||||
&setMessageLengthVisisble);
|
||||
}
|
||||
|
||||
ChatWidgetInput::~ChatWidgetInput()
|
||||
{
|
||||
QObject::disconnect(
|
||||
&settings::Settings::getInstance().getShowMessageLength(),
|
||||
&settings::BoolSetting::valueChanged, this, &setMessageLengthVisisble);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -21,6 +21,7 @@ class ChatWidgetInput : public QWidget
|
||||
|
||||
public:
|
||||
ChatWidgetInput();
|
||||
~ChatWidgetInput();
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *);
|
||||
@@ -37,6 +38,11 @@ private:
|
||||
|
||||
private slots:
|
||||
void refreshTheme();
|
||||
void
|
||||
setMessageLengthVisisble(bool value)
|
||||
{
|
||||
this->textLengthLabel.setHidden(!value);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
#include "channels.h"
|
||||
#include "colorscheme.h"
|
||||
#include "messages/message.h"
|
||||
#include "messages/word.h"
|
||||
#include "messages/wordpart.h"
|
||||
#include "settings/settings.h"
|
||||
#include "widgets/chatwidget.h"
|
||||
|
||||
#include <math.h>
|
||||
@@ -22,6 +22,17 @@ ChatWidgetView::ChatWidgetView(ChatWidget *parent)
|
||||
auto scroll = QScroller::scroller(this);
|
||||
|
||||
scroll->scrollTo(QPointF(0, 100));
|
||||
|
||||
QObject::connect(&settings::Settings::getInstance(),
|
||||
&settings::Settings::wordTypeMaskChanged, this,
|
||||
&wordTypeMaskChanged);
|
||||
}
|
||||
|
||||
ChatWidgetView::~ChatWidgetView()
|
||||
{
|
||||
QObject::disconnect(&settings::Settings::getInstance(),
|
||||
&settings::Settings::wordTypeMaskChanged, this,
|
||||
&wordTypeMaskChanged);
|
||||
}
|
||||
|
||||
bool
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define CHATVIEW_H
|
||||
|
||||
#include "channel.h"
|
||||
#include "messages/word.h"
|
||||
#include "widgets/scrollbar.h"
|
||||
|
||||
#include <QPaintEvent>
|
||||
@@ -17,6 +18,7 @@ class ChatWidgetView : public QWidget
|
||||
|
||||
public:
|
||||
explicit ChatWidgetView(ChatWidget *parent);
|
||||
~ChatWidgetView();
|
||||
|
||||
bool layoutMessages();
|
||||
|
||||
@@ -29,6 +31,15 @@ private:
|
||||
ChatWidget *chatWidget;
|
||||
|
||||
ScrollBar scrollbar;
|
||||
|
||||
private slots:
|
||||
void
|
||||
wordTypeMaskChanged()
|
||||
{
|
||||
if (layoutMessages()) {
|
||||
repaint();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,10 +14,6 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
{
|
||||
setCentralWidget(&this->notebook);
|
||||
|
||||
this->notebook.addPage();
|
||||
this->notebook.addPage();
|
||||
this->notebook.addPage();
|
||||
|
||||
QPalette palette;
|
||||
palette.setColor(QPalette::Background,
|
||||
ColorScheme::instance().TabPanelBackground);
|
||||
|
||||
+47
-8
@@ -18,6 +18,7 @@ Notebook::Notebook(QWidget *parent)
|
||||
, addButton(this)
|
||||
, settingsButton(this)
|
||||
, userButton(this)
|
||||
, selectedPage(nullptr)
|
||||
{
|
||||
connect(&this->settingsButton, SIGNAL(clicked()), this,
|
||||
SLOT(settingsButtonClicked()));
|
||||
@@ -34,6 +35,8 @@ Notebook::Notebook(QWidget *parent)
|
||||
this->userButton.icon = NotebookButton::IconUser;
|
||||
|
||||
this->addButton.resize(24, 24);
|
||||
|
||||
this->addPage();
|
||||
}
|
||||
|
||||
NotebookPage *
|
||||
@@ -42,13 +45,15 @@ Notebook::addPage(bool select)
|
||||
auto tab = new NotebookTab(this);
|
||||
auto page = new NotebookPage(this, tab);
|
||||
|
||||
tab->show();
|
||||
|
||||
if (select || this->pages.count() == 0) {
|
||||
this->select(page);
|
||||
}
|
||||
|
||||
this->pages.append(page);
|
||||
|
||||
performLayout();
|
||||
this->performLayout();
|
||||
|
||||
return page;
|
||||
}
|
||||
@@ -56,20 +61,24 @@ Notebook::addPage(bool select)
|
||||
void
|
||||
Notebook::removePage(NotebookPage *page)
|
||||
{
|
||||
int index = pages.indexOf(page);
|
||||
int index = this->pages.indexOf(page);
|
||||
|
||||
if (pages.size() == 1) {
|
||||
select(NULL);
|
||||
this->select(NULL);
|
||||
} else if (index == pages.count() - 1) {
|
||||
select(pages[index - 1]);
|
||||
this->select(pages[index - 1]);
|
||||
} else {
|
||||
select(pages[index + 1]);
|
||||
this->select(pages[index + 1]);
|
||||
}
|
||||
|
||||
delete page->tab;
|
||||
delete page;
|
||||
|
||||
pages.removeOne(page);
|
||||
this->pages.removeOne(page);
|
||||
|
||||
if (this->pages.size() == 0) {
|
||||
addPage();
|
||||
}
|
||||
|
||||
performLayout();
|
||||
}
|
||||
@@ -95,6 +104,36 @@ Notebook::select(NotebookPage *page)
|
||||
performLayout();
|
||||
}
|
||||
|
||||
NotebookPage *
|
||||
Notebook::tabAt(QPoint point, int &index)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
for (auto *page : pages) {
|
||||
if (page->tab->geometry().contains(point)) {
|
||||
index = i;
|
||||
return page;
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
index = -1;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void
|
||||
Notebook::rearrangePage(NotebookPage *page, int index)
|
||||
{
|
||||
int i1 = pages.indexOf(page);
|
||||
|
||||
pages.move(pages.indexOf(page), index);
|
||||
|
||||
int i2 = pages.indexOf(page);
|
||||
|
||||
performLayout();
|
||||
}
|
||||
|
||||
void
|
||||
Notebook::performLayout()
|
||||
{
|
||||
@@ -109,10 +148,10 @@ Notebook::performLayout()
|
||||
(i == this->pages.last() ? tabHeight : 0) + x + i->tab->width() >
|
||||
width()) {
|
||||
y += i->tab->height();
|
||||
i->tab->move(0, y);
|
||||
i->tab->moveAnimated(QPoint(0, y));
|
||||
x = i->tab->width();
|
||||
} else {
|
||||
i->tab->move(x, y);
|
||||
i->tab->moveAnimated(QPoint(x, y));
|
||||
x += i->tab->width();
|
||||
}
|
||||
|
||||
|
||||
+4
-1
@@ -33,6 +33,9 @@ public:
|
||||
|
||||
void performLayout();
|
||||
|
||||
NotebookPage *tabAt(QPoint point, int &index);
|
||||
void rearrangePage(NotebookPage *page, int index);
|
||||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *);
|
||||
|
||||
@@ -50,7 +53,7 @@ private:
|
||||
NotebookButton settingsButton;
|
||||
NotebookButton userButton;
|
||||
|
||||
NotebookPage *selectedPage = nullptr;
|
||||
NotebookPage *selectedPage;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
+60
-24
@@ -10,6 +10,8 @@ namespace widgets {
|
||||
|
||||
NotebookTab::NotebookTab(Notebook *notebook)
|
||||
: QWidget(notebook)
|
||||
// , posAnimation(this, "pos")
|
||||
// , posAnimated(false)
|
||||
, notebook(notebook)
|
||||
, text("<no title>")
|
||||
, selected(false)
|
||||
@@ -19,36 +21,56 @@ NotebookTab::NotebookTab(Notebook *notebook)
|
||||
, mouseDownX(false)
|
||||
, highlightStyle(HighlightNone)
|
||||
{
|
||||
calcSize();
|
||||
this->calcSize();
|
||||
this->setAcceptDrops(true);
|
||||
|
||||
setAcceptDrops(true);
|
||||
|
||||
QObject::connect(&settings::Settings::getHideTabX(),
|
||||
SIGNAL(settings::BoolSetting::valueChanged(bool)), this,
|
||||
SLOT(NotebookTab::hideTabXChanged(bool)));
|
||||
|
||||
this->installEventFilter(this);
|
||||
QObject::connect(&settings::Settings::getInstance().getHideTabX(),
|
||||
&settings::BoolSetting::valueChanged, this,
|
||||
&NotebookTab::hideTabXChanged);
|
||||
|
||||
this->setMouseTracking(true);
|
||||
}
|
||||
|
||||
NotebookTab::~NotebookTab()
|
||||
{
|
||||
QObject::disconnect(&settings::Settings::getHideTabX(),
|
||||
SIGNAL(settings::BoolSetting::valueChanged(bool)), this,
|
||||
SLOT(NotebookTab::hideTabXChanged(bool)));
|
||||
QObject::disconnect(&settings::Settings::getInstance().getHideTabX(),
|
||||
&settings::BoolSetting::valueChanged, this,
|
||||
&NotebookTab::hideTabXChanged);
|
||||
}
|
||||
|
||||
void
|
||||
NotebookTab::calcSize()
|
||||
{
|
||||
if (settings::Settings::getHideTabX().get()) {
|
||||
if (settings::Settings::getInstance().getHideTabX().get()) {
|
||||
this->resize(this->fontMetrics().width(this->text) + 8, 24);
|
||||
} else {
|
||||
this->resize(this->fontMetrics().width(this->text) + 8 + 24, 24);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
NotebookTab::moveAnimated(QPoint pos)
|
||||
{
|
||||
move(pos);
|
||||
|
||||
// if (posAnimated == false) {
|
||||
// move(pos);
|
||||
|
||||
// posAnimated = true;
|
||||
// return;
|
||||
// }
|
||||
|
||||
// if (this->posAnimation.endValue() == pos) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
// this->posAnimation.stop();
|
||||
// this->posAnimation.setDuration(50);
|
||||
// this->posAnimation.setStartValue(this->pos());
|
||||
// this->posAnimation.setEndValue(pos);
|
||||
// this->posAnimation.start();
|
||||
}
|
||||
|
||||
void
|
||||
NotebookTab::paintEvent(QPaintEvent *)
|
||||
{
|
||||
@@ -77,25 +99,28 @@ NotebookTab::paintEvent(QPaintEvent *)
|
||||
|
||||
painter.setPen(fg);
|
||||
|
||||
QRect rect(0, 0,
|
||||
width() - (settings::Settings::getHideTabX().get() ? 0 : 16),
|
||||
height());
|
||||
QRect rect(
|
||||
0, 0,
|
||||
width() -
|
||||
(settings::Settings::getInstance().getHideTabX().get() ? 0 : 16),
|
||||
height());
|
||||
|
||||
painter.drawText(rect, this->text, QTextOption(Qt::AlignCenter));
|
||||
|
||||
if (!settings::Settings::getHideTabX().get() && (mouseOver || selected)) {
|
||||
if (mouseOverX) {
|
||||
painter.fillRect(getXRect(), QColor(0, 0, 0, 64));
|
||||
if (!settings::Settings::getInstance().getHideTabX().get() &&
|
||||
(this->mouseOver || this->selected)) {
|
||||
if (this->mouseOverX) {
|
||||
painter.fillRect(this->getXRect(), QColor(0, 0, 0, 64));
|
||||
|
||||
if (mouseDownX) {
|
||||
painter.fillRect(getXRect(), QColor(0, 0, 0, 64));
|
||||
if (this->mouseDownX) {
|
||||
painter.fillRect(this->getXRect(), QColor(0, 0, 0, 64));
|
||||
}
|
||||
}
|
||||
|
||||
painter.drawLine(getXRect().topLeft() + QPoint(4, 4),
|
||||
getXRect().bottomRight() + QPoint(-4, -4));
|
||||
painter.drawLine(getXRect().topRight() + QPoint(-4, 4),
|
||||
getXRect().bottomLeft() + QPoint(4, -4));
|
||||
painter.drawLine(this->getXRect().topLeft() + QPoint(4, 4),
|
||||
this->getXRect().bottomRight() + QPoint(-4, -4));
|
||||
painter.drawLine(this->getXRect().topRight() + QPoint(-4, 4),
|
||||
this->getXRect().bottomLeft() + QPoint(4, -4));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,6 +181,17 @@ NotebookTab::mouseMoveEvent(QMouseEvent *event)
|
||||
|
||||
this->repaint();
|
||||
}
|
||||
|
||||
if (this->mouseDown && !this->rect().contains(event->pos())) {
|
||||
QPoint relPoint = this->mapToParent(event->pos());
|
||||
|
||||
int index;
|
||||
NotebookPage *page = notebook->tabAt(relPoint, index);
|
||||
|
||||
if (page != nullptr && page != this->page) {
|
||||
notebook->rearrangePage(this->page, index);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#ifndef NOTEBOOKTAB_H
|
||||
#define NOTEBOOKTAB_H
|
||||
|
||||
#include <QPropertyAnimation>
|
||||
#include <QWidget>
|
||||
|
||||
namespace chatterino {
|
||||
@@ -20,7 +21,7 @@ public:
|
||||
HighlightNewMessage
|
||||
};
|
||||
|
||||
NotebookTab(Notebook *notebook);
|
||||
explicit NotebookTab(Notebook *notebook);
|
||||
~NotebookTab();
|
||||
|
||||
void calcSize();
|
||||
@@ -65,6 +66,8 @@ public:
|
||||
repaint();
|
||||
}
|
||||
|
||||
void moveAnimated(QPoint pos);
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *) override;
|
||||
|
||||
@@ -78,6 +81,9 @@ protected:
|
||||
void mouseMoveEvent(QMouseEvent *event) override;
|
||||
|
||||
private:
|
||||
// QPropertyAnimation posAnimation;
|
||||
// bool posAnimated;
|
||||
|
||||
Notebook *notebook;
|
||||
|
||||
QString text;
|
||||
@@ -98,7 +104,7 @@ private:
|
||||
|
||||
private slots:
|
||||
void
|
||||
hideTabXChanged(bool value)
|
||||
hideTabXChanged(bool)
|
||||
{
|
||||
calcSize();
|
||||
repaint();
|
||||
|
||||
+74
-11
@@ -54,6 +54,8 @@ SettingsDialog::SettingsDialog()
|
||||
void
|
||||
SettingsDialog::addTabs()
|
||||
{
|
||||
settings::Settings &settings = settings::Settings::getInstance();
|
||||
|
||||
QVBoxLayout *vbox;
|
||||
|
||||
// Appearance
|
||||
@@ -80,12 +82,17 @@ SettingsDialog::addTabs()
|
||||
auto group = new QGroupBox("Messages");
|
||||
|
||||
auto v = new QVBoxLayout();
|
||||
v->addWidget(createCheckbox("Show timestamp", ""));
|
||||
v->addWidget(createCheckbox("Show seconds in timestamp", ""));
|
||||
v->addWidget(
|
||||
createCheckbox("Show timestamp", settings.getShowTimestamps()));
|
||||
v->addWidget(createCheckbox("Show seconds in timestamp",
|
||||
settings.getShowTimestampSeconds()));
|
||||
v->addWidget(createCheckbox(
|
||||
"Allow sending duplicate messages (add a space at the end)", ""));
|
||||
v->addWidget(createCheckbox("Seperate messages", ""));
|
||||
v->addWidget(createCheckbox("Show message length", ""));
|
||||
"Allow sending duplicate messages (add a space at the end)",
|
||||
settings.getAllowDouplicateMessages()));
|
||||
v->addWidget(createCheckbox("Seperate messages",
|
||||
settings.getSeperateMessages()));
|
||||
v->addWidget(createCheckbox("Show message length",
|
||||
settings.getShowMessageLength()));
|
||||
|
||||
group->setLayout(v);
|
||||
|
||||
@@ -99,11 +106,15 @@ SettingsDialog::addTabs()
|
||||
// Behaviour
|
||||
vbox = new QVBoxLayout();
|
||||
|
||||
vbox->addWidget(createCheckbox("Hide input box if empty", ""));
|
||||
vbox->addWidget(createCheckbox("Hide input box if empty",
|
||||
settings.getHideEmptyInput()));
|
||||
vbox->addWidget(
|
||||
createCheckbox("Mention users with a @ (except in commands)", ""));
|
||||
vbox->addWidget(createCheckbox("Window always on top", ""));
|
||||
vbox->addWidget(createCheckbox("Show last read message indicator", ""));
|
||||
createCheckbox("Mention users with a @ (except in commands)",
|
||||
settings.getMentionUsersWithAt()));
|
||||
vbox->addWidget(
|
||||
createCheckbox("Window always on top", settings.getWindowTopMost()));
|
||||
vbox->addWidget(createCheckbox("Show last read message indicator",
|
||||
settings.getShowLastMessageIndicator()));
|
||||
|
||||
{
|
||||
auto v = new QVBoxLayout();
|
||||
@@ -128,14 +139,66 @@ SettingsDialog::addTabs()
|
||||
|
||||
addTab(vbox, "Commands", ":/images/CustomActionEditor_16x.png");
|
||||
|
||||
// Emotes
|
||||
vbox = new QVBoxLayout();
|
||||
|
||||
vbox->addWidget(createCheckbox("Enable Twitch Emotes",
|
||||
settings.getEnableTwitchEmotes()));
|
||||
vbox->addWidget(createCheckbox("Enable BetterTTV Emotes",
|
||||
settings.getEnableBttvEmotes()));
|
||||
vbox->addWidget(createCheckbox("Enable FrankerFaceZ Emotes",
|
||||
settings.getEnableFfzEmotes()));
|
||||
vbox->addWidget(
|
||||
createCheckbox("Enable Gif Emotes", settings.getEnableGifs()));
|
||||
vbox->addWidget(
|
||||
createCheckbox("Enable Emojis", settings.getEnableEmojis()));
|
||||
|
||||
vbox->addWidget(createCheckbox("Enable Twitch Emotes",
|
||||
settings.getEnableTwitchEmotes()));
|
||||
|
||||
vbox->addStretch(1);
|
||||
addTab(vbox, "Emotes", ":/images/Emoji_Color_1F60A_19.png");
|
||||
|
||||
// Ignored Users
|
||||
vbox = new QVBoxLayout();
|
||||
vbox->addStretch(1);
|
||||
addTab(vbox, "Ignored Users",
|
||||
":/images/StatusAnnotations_Blocked_16xLG_color.png");
|
||||
|
||||
// Ignored Messages
|
||||
vbox = new QVBoxLayout();
|
||||
vbox->addStretch(1);
|
||||
addTab(vbox, "Ignored Messages", ":/images/Filter_16x.png");
|
||||
|
||||
// Links
|
||||
vbox = new QVBoxLayout();
|
||||
vbox->addStretch(1);
|
||||
addTab(vbox, "Links", ":/images/VSO_Link_blue_16x.png");
|
||||
|
||||
// Highlighting
|
||||
vbox = new QVBoxLayout();
|
||||
vbox->addStretch(1);
|
||||
addTab(vbox, "Highlighting", ":/images/format_Bold_16xLG.png");
|
||||
|
||||
// Whispers
|
||||
vbox = new QVBoxLayout();
|
||||
vbox->addStretch(1);
|
||||
addTab(vbox, "Whispers", ":/images/Message_16xLG.png");
|
||||
|
||||
// Add stretch
|
||||
tabs.addStretch(1);
|
||||
}
|
||||
|
||||
QCheckBox *
|
||||
SettingsDialog::createCheckbox(QString title, QString settingsId)
|
||||
SettingsDialog::createCheckbox(const QString &title,
|
||||
settings::BoolSetting &setting)
|
||||
{
|
||||
return new QCheckBox(title);
|
||||
auto checkbox = new QCheckBox(title);
|
||||
|
||||
QObject::connect(checkbox, &QCheckBox::toggled, this,
|
||||
[&setting, this](bool state) { setting.set(state); });
|
||||
|
||||
return checkbox;
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#ifndef SETTINGSDIALOG_H
|
||||
#define SETTINGSDIALOG_H
|
||||
|
||||
#include "settings/settings.h"
|
||||
#include "widgets/settingsdialogtab.h"
|
||||
|
||||
#include <QButtonGroup>
|
||||
@@ -39,7 +40,8 @@ private:
|
||||
|
||||
SettingsDialogTab *selectedTab = NULL;
|
||||
|
||||
QCheckBox *createCheckbox(QString title, QString settingsId);
|
||||
QCheckBox *createCheckbox(const QString &title,
|
||||
settings::BoolSetting &setting);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user