Commit de6b7776 authored by kaniini's avatar kaniini

implement initial preferences window

parent 8b9d8a8c
......@@ -679,13 +679,16 @@ QWebSocket *Account::streamingSocket(QString stream)
auto event = env.object()["event"].toString();
if (event == "update")
{
QSettings settings;
QJsonDocument doc = QJsonDocument::fromJson(env.object()["payload"].toString().toLocal8Bit());
auto account_obj = doc.object()["account"].toObject ();
if (account_obj["acct"] == m_identity.m_acct)
return;
handleUpdate(doc, target_tl);
if (settings.value("Preferences/timeline_firehose", true).toBool ())
handleUpdate(doc, target_tl);
return;
}
else if (event == "notification")
......
......@@ -38,7 +38,8 @@ SOURCES += \
ui/timelinewidget.cc \
ui/notificationimpl.cc \
ui/threadwindow.cc \
ui/iconutils.cc
ui/iconutils.cc \
ui/preferenceswindow.cc
HEADERS += \
core/account.h \
......@@ -56,7 +57,8 @@ HEADERS += \
ui/timelinewidget.h \
ui/notificationimpl.h \
ui/threadwindow.h \
ui/iconutils.h
ui/iconutils.h \
ui/preferenceswindow.h
FORMS +=
......
......@@ -6,6 +6,7 @@
#include "onboardingwidget.h"
#include "composeform.h"
#include "iconutils.h"
#include "preferenceswindow.h"
MainWindow::MainWindow(QWidget *parent,
Michabo::AccountManager *manager)
......@@ -21,6 +22,7 @@ MainWindow::MainWindow(QWidget *parent,
m_compose_button(new QToolButton(m_toolbar)),
m_refresh_button(new QToolButton(m_toolbar)),
m_prefs_button(new QToolButton(m_toolbar)),
m_prefs_window(new PreferencesWindow()),
m_account_manager(manager)
{
// onboarding layout
......@@ -58,7 +60,7 @@ MainWindow::MainWindow(QWidget *parent,
":/embedded-assets/icons/action-preferences.svg",
Default, 24));
QObject::connect(m_prefs_button, &QToolButton::clicked, [=] () {
qDebug() << "Show preferences";
m_prefs_window->show();
});
QWidget * spacer = new QWidget;
......
......@@ -5,6 +5,7 @@
#include "onboardingwidget.h"
#include "identitywidget.h"
#include "timelineselectorwidget.h"
#include "preferenceswindow.h"
#include <QMainWindow>
#include <QWidget>
......@@ -34,6 +35,7 @@ private:
QToolButton *m_compose_button;
QToolButton *m_refresh_button;
QToolButton *m_prefs_button;
PreferencesWindow *m_prefs_window;
Michabo::AccountManager *m_account_manager;
void updateLayout();
......
#include "preferenceswindow.h"
PreferencesWindow::PreferencesWindow(QWidget * parent)
: QDialog (parent),
m_layout (new QVBoxLayout (this)),
m_prefs_label (new QLabel),
m_tl_firehose (new QCheckBox),
m_buttonbox (new QDialogButtonBox),
m_close_button (new QPushButton)
{
setWindowTitle (tr("Michabo Preferences"));
m_prefs_label->setText (tr ("<big>Preferences</big>"));
m_layout->addWidget (m_prefs_label);
m_tl_firehose->setText (tr ("Stream new posts onto the home timeline"));
m_layout->addWidget (m_tl_firehose);
m_close_button->setText (tr ("Close"));
m_close_button->setIcon (QIcon::fromTheme ("window-close"));
m_buttonbox->addButton (m_close_button, QDialogButtonBox::RejectRole);
m_layout->addWidget (m_buttonbox);
QSettings settings;
settings.beginGroup ("Preferences");
bool tl_firehose = settings.value ("timeline_firehose", true).toBool ();
m_tl_firehose->setChecked (tl_firehose);
settings.endGroup ();
QObject::connect (m_tl_firehose, &QCheckBox::toggled, [=] (bool checked) {
QSettings settings;
settings.beginGroup ("Preferences");
settings.setValue ("timeline_firehose", checked);
settings.endGroup ();
});
QObject::connect (m_close_button, &QPushButton::clicked, [=] () {
close ();
});
}
#ifndef PREFERENCESWINDOW_H
#define PREFERENCESWINDOW_H
#include <QWidget>
#include <QDialog>
#include <QVBoxLayout>
#include <QCheckBox>
#include <QDialogButtonBox>
#include <QLabel>
#include <QPushButton>
#include <QSettings>
class PreferencesWindow : public QDialog
{
public:
PreferencesWindow(QWidget * parent = nullptr);
private:
QVBoxLayout *m_layout;
QLabel *m_prefs_label;
QCheckBox *m_tl_firehose;
QDialogButtonBox *m_buttonbox;
QPushButton *m_close_button;
};
#endif // PREFERENCESWINDOW_H
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment