commit for hemirt

This commit is contained in:
fourtf 2017-01-01 18:43:52 +01:00
parent a290f88685
commit a75cfa61f7
13 changed files with 210 additions and 11 deletions

View file

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

View file

@ -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 +=

14
dialog.cpp Normal file
View file

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

22
dialog.h Normal file
View file

@ -0,0 +1,22 @@
#ifndef DIALOG_H
#define DIALOG_H
#include <QDialog>
namespace Ui {
class Dialog;
}
class Dialog : public QDialog
{
Q_OBJECT
public:
explicit Dialog(QWidget *parent = 0);
~Dialog();
private:
Ui::Dialog *ui;
};
#endif // DIALOG_H

55
dialog.ui Normal file
View file

@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog</class>
<widget class="QDialog" name="Dialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1031</width>
<height>625</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<property name="documentMode">
<bool>true</bool>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
<string>Tab 1</string>
</attribute>
</widget>
<widget class="QWidget" name="tab_2">
<attribute name="title">
<string>Tab 2</string>
</attribute>
</widget>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View file

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

View file

@ -24,6 +24,11 @@ public:
protected:
void resizeEvent(QResizeEvent *);
void settingsButtonMouseReleased(QMouseEvent *event);
public slots:
void settingsButtonClicked();
private:
QList<NotebookPage*> pages;

View file

@ -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)
{
if (event->button() == Qt::LeftButton)
{
mouseDown = true;
this->repaint();
}
}
void NotebookButton::mouseReleaseEvent(QMouseEvent *)
void NotebookButton::mouseReleaseEvent(QMouseEvent *event)
{
if (event->button() == Qt::LeftButton)
{
mouseDown = false;
this->repaint();
emit clicked();
}
}
void NotebookButton::enterEvent(QEvent *)

View file

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

7
settingsdialog.cpp Normal file
View file

@ -0,0 +1,7 @@
#include "settingsdialog.h"
SettingsDialog::SettingsDialog()
: tabs(this)
{
}

21
settingsdialog.h Normal file
View file

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

22
settingsdialogtab.cpp Normal file
View file

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

19
settingsdialogtab.h Normal file
View file

@ -0,0 +1,19 @@
#ifndef SETTINGSNOTEBOOKTAB_H
#define SETTINGSNOTEBOOKTAB_H
#include <QWidget>
#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