make a few settings into pajlada::Settings::Settings

Add setting to hide badges

Give focus to text input if you click anywhere in a chat widget
This commit is contained in:
Rasmus Karlsson
2017-06-11 20:53:43 +02:00
parent 945ca5d17a
commit 7c3cd930f3
11 changed files with 71 additions and 27 deletions
+5
View File
@@ -188,6 +188,11 @@ void ChatWidget::updateGifEmotes()
this->view.updateGifEmotes();
}
void ChatWidget::giveFocus()
{
this->input.textInput.setFocus();
}
void ChatWidget::paintEvent(QPaintEvent *)
{
// color the background of the chat
+2
View File
@@ -47,6 +47,8 @@ public:
void layoutMessages();
void updateGifEmotes();
void giveFocus();
protected:
void paintEvent(QPaintEvent *) override;
+3 -1
View File
@@ -29,7 +29,7 @@ protected:
virtual void resizeEvent(QResizeEvent *) override;
private:
ChatWidget *chatWidget;
ChatWidget *const chatWidget;
QHBoxLayout hbox;
QVBoxLayout vbox;
@@ -46,6 +46,8 @@ private slots:
}
void editTextChanged();
// void editKeyPressed(QKeyEvent *event);
friend class ChatWidget;
};
} // namespace widgets
+2
View File
@@ -336,6 +336,8 @@ void ChatWidgetView::mousePressEvent(QMouseEvent *event)
{
this->isMouseDown = true;
this->lastPressPosition = event->screenPos();
this->chatWidget->giveFocus();
}
void ChatWidgetView::mouseReleaseEvent(QMouseEvent *event)
+1 -1
View File
@@ -49,7 +49,7 @@ private:
std::vector<GifEmoteData> gifEmotes;
ChatWidget *chatWidget;
ChatWidget *const chatWidget;
ScrollBar scrollBar;
+18
View File
@@ -5,6 +5,7 @@
#include "windowmanager.hpp"
#include <QComboBox>
#include <QDebug>
#include <QFile>
#include <QFormLayout>
#include <QGroupBox>
@@ -166,6 +167,7 @@ void SettingsDialog::addTabs()
auto v = new QVBoxLayout();
v->addWidget(createCheckbox("Show timestamp", settings.showTimestamps));
v->addWidget(createCheckbox("Show seconds in timestamp", settings.showTimestampSeconds));
v->addWidget(createCheckbox("Show badges", settings.showBadges));
v->addWidget(createCheckbox("Allow sending duplicate messages (add a space at the end)",
settings.allowDouplicateMessages));
v->addWidget(createCheckbox("Seperate messages", settings.seperateMessages));
@@ -323,6 +325,22 @@ QCheckBox *SettingsDialog::createCheckbox(const QString &title, Setting<bool> &s
return checkbox;
}
QCheckBox *SettingsDialog::createCheckbox(const QString &title,
pajlada::Settings::Setting<bool> &setting)
{
auto checkbox = new QCheckBox(title);
// Set checkbox initial state
checkbox->setChecked(setting.getValue());
QObject::connect(checkbox, &QCheckBox::toggled, this, [&setting](bool state) {
qDebug() << "update checkbox value";
setting = state; //
});
return checkbox;
}
void SettingsDialog::okButtonClicked()
{
this->close();
+2
View File
@@ -14,6 +14,7 @@
#include <QStackedLayout>
#include <QVBoxLayout>
#include <QWidget>
#include <pajlada/settings/setting.hpp>
namespace chatterino {
namespace widgets {
@@ -46,6 +47,7 @@ private:
/// Widget creation helpers
QCheckBox *createCheckbox(const QString &title, Setting<bool> &setting);
QCheckBox *createCheckbox(const QString &title, pajlada::Settings::Setting<bool> &setting);
void okButtonClicked();
void cancelButtonClicked();