diff --git a/channel.h b/channel.h index fdac16c04..1be23bd52 100644 --- a/channel.h +++ b/channel.h @@ -9,6 +9,9 @@ public: static const Channel whispers; static const Channel mentions; + static Channel addChannel(QString channel); + static void removeChannel(QString channel); + public: QString getSubLink(); QString getChannelLink(); diff --git a/chatterino.pro b/chatterino.pro index cac094e77..3d00946f7 100644 --- a/chatterino.pro +++ b/chatterino.pro @@ -35,7 +35,10 @@ SOURCES += main.cpp\ chatwidgetinput.cpp \ chatwidgetview.cpp \ notebookpagedroppreview.cpp \ - channel.cpp + channel.cpp \ + dialog.cpp \ + settingsdialog.cpp \ + settingsdialogtab.cpp HEADERS += mainwindow.h \ chatwidget.h \ @@ -48,9 +51,15 @@ HEADERS += mainwindow.h \ chatwidgetinput.h \ chatwidgetview.h \ notebookpagedroppreview.h \ - channel.h + channel.h \ + dialog.h \ + settingsdialog.h \ + settingsdialogtab.h -FORMS += +FORMS += \ + dialog.ui RESOURCES += \ resources.qrc + +DISTFILES += diff --git a/dialog.cpp b/dialog.cpp new file mode 100644 index 000000000..58c3e725e --- /dev/null +++ b/dialog.cpp @@ -0,0 +1,14 @@ +#include "dialog.h" +#include "ui_dialog.h" + +Dialog::Dialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::Dialog) +{ + ui->setupUi(this); +} + +Dialog::~Dialog() +{ + delete ui; +} diff --git a/dialog.h b/dialog.h new file mode 100644 index 000000000..1eaa6a99f --- /dev/null +++ b/dialog.h @@ -0,0 +1,22 @@ +#ifndef DIALOG_H +#define DIALOG_H + +#include + +namespace Ui { +class Dialog; +} + +class Dialog : public QDialog +{ + Q_OBJECT + +public: + explicit Dialog(QWidget *parent = 0); + ~Dialog(); + +private: + Ui::Dialog *ui; +}; + +#endif // DIALOG_H diff --git a/dialog.ui b/dialog.ui new file mode 100644 index 000000000..b9bd1506c --- /dev/null +++ b/dialog.ui @@ -0,0 +1,55 @@ + + + Dialog + + + + 0 + 0 + 1031 + 625 + + + + Dialog + + + + + + + + + + + 0 + + + true + + + + Tab 1 + + + + + Tab 2 + + + + + + + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + diff --git a/notebook.cpp b/notebook.cpp index 85932165c..3d61c4f9e 100644 --- a/notebook.cpp +++ b/notebook.cpp @@ -7,6 +7,7 @@ #include "notebookbutton.h" #include "QFormLayout" #include "colorscheme.h" +#include "dialog.h" Notebook::Notebook(QWidget *parent) : QWidget(parent), @@ -14,6 +15,8 @@ Notebook::Notebook(QWidget *parent) settingsButton(this), userButton(this) { + connect(&settingsButton, SIGNAL(clicked()), this, SLOT(settingsButtonClicked())); + settingsButton.resize(24, 24); settingsButton.icon = NotebookButton::IconSettings; userButton.resize(24, 24); @@ -22,6 +25,13 @@ Notebook::Notebook(QWidget *parent) addButton.resize(24, 24); } +void Notebook::settingsButtonClicked() +{ + auto a = new Dialog(); + + a->show(); +} + NotebookPage* Notebook::addPage() { auto tab = new NotebookTab(this); diff --git a/notebook.h b/notebook.h index c9d8c742e..982573290 100644 --- a/notebook.h +++ b/notebook.h @@ -24,6 +24,11 @@ public: protected: void resizeEvent(QResizeEvent *); + void settingsButtonMouseReleased(QMouseEvent *event); + +public slots: + void settingsButtonClicked(); + private: QList pages; diff --git a/notebookbutton.cpp b/notebookbutton.cpp index 8d67e829b..6fff73430 100644 --- a/notebookbutton.cpp +++ b/notebookbutton.cpp @@ -1,6 +1,7 @@ #include "notebookbutton.h" #include "QPainter" #include "QPainterPath" +#include "QMouseEvent" #include "colorscheme.h" NotebookButton::NotebookButton(QWidget *parent) @@ -86,18 +87,26 @@ void NotebookButton::paintEvent(QPaintEvent *) } } -void NotebookButton::mousePressEvent(QMouseEvent *) +void NotebookButton::mousePressEvent(QMouseEvent *event) { - mouseDown = true; + if (event->button() == Qt::LeftButton) + { + mouseDown = true; - this->repaint(); + this->repaint(); + } } -void NotebookButton::mouseReleaseEvent(QMouseEvent *) +void NotebookButton::mouseReleaseEvent(QMouseEvent *event) { - mouseDown = false; + if (event->button() == Qt::LeftButton) + { + mouseDown = false; - this->repaint(); + this->repaint(); + + emit clicked(); + } } void NotebookButton::enterEvent(QEvent *) diff --git a/notebookbutton.h b/notebookbutton.h index caacd3c11..c2bbeb7f3 100644 --- a/notebookbutton.h +++ b/notebookbutton.h @@ -16,11 +16,14 @@ public: NotebookButton(QWidget *parent); void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE; - void mousePressEvent(QMouseEvent *) Q_DECL_OVERRIDE; - void mouseReleaseEvent(QMouseEvent *) Q_DECL_OVERRIDE; + void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE; + void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE; void enterEvent(QEvent *) Q_DECL_OVERRIDE; void leaveEvent(QEvent *) Q_DECL_OVERRIDE; +signals: + void clicked(); + private: bool mouseOver = false; bool mouseDown = false; diff --git a/settingsdialog.cpp b/settingsdialog.cpp new file mode 100644 index 000000000..203f29125 --- /dev/null +++ b/settingsdialog.cpp @@ -0,0 +1,7 @@ +#include "settingsdialog.h" + +SettingsDialog::SettingsDialog() + : tabs(this) +{ + +} diff --git a/settingsdialog.h b/settingsdialog.h new file mode 100644 index 000000000..f5413de4f --- /dev/null +++ b/settingsdialog.h @@ -0,0 +1,21 @@ +#ifndef SETTINGSDIALOG_H +#define SETTINGSDIALOG_H + +#include "QWidget" +#include "QMainWindow" +#include "QHBoxLayout" +#include "QListView" + +class SettingsDialog : QMainWindow +{ +public: + SettingsDialog(); + +private: + QListView tabs; + QHBoxLayout hbox; + + void addTab(QWidget* widget, QString title, QString imageRes); +}; + +#endif // SETTINGSDIALOG_H diff --git a/settingsdialogtab.cpp b/settingsdialogtab.cpp new file mode 100644 index 000000000..3ac934169 --- /dev/null +++ b/settingsdialogtab.cpp @@ -0,0 +1,22 @@ +#include "settingsdialogtab.h" +#include "QPainter" + +SettingsDialogTab::SettingsDialogTab(QWidget *parent, QString label, QImage& image) + : QWidget(parent), + image(image) +{ + this->label = label; +} + +void SettingsDialogTab::paintEvent(QPaintEvent *) +{ + QPainter painter(this); + + int a = (height() - image.width()) / 2; + + painter.drawImage(a, a, image); + + a = a + a + image.width(); + + painter.drawText(QRect(a, 0, width() - a, height()), label, QTextOption(Qt::AlignLeft | Qt::AlignVCenter)); +} diff --git a/settingsdialogtab.h b/settingsdialogtab.h new file mode 100644 index 000000000..e928f758b --- /dev/null +++ b/settingsdialogtab.h @@ -0,0 +1,19 @@ +#ifndef SETTINGSNOTEBOOKTAB_H +#define SETTINGSNOTEBOOKTAB_H + +#include +#include "QPaintEvent" + +class SettingsDialogTab : public QWidget +{ + Q_OBJECT +public: + SettingsDialogTab(QWidget *parent, QString label, QImage& image); + +private: + void paintEvent(QPaintEvent *); + QString label; + QImage& image; +}; + +#endif // SETTINGSNOTEBOOKTAB_H