added basic tabs

This commit is contained in:
fourtf
2016-12-30 12:20:26 +01:00
parent cfda4798d4
commit 2ce96a05bc
11 changed files with 240 additions and 27 deletions
+42 -3
View File
@@ -1,10 +1,49 @@
#include "notebook.h"
#include "notebooktab.h"
#include "notebookpage.h"
#include "QPainter"
NotebookTab::NotebookTab(QWidget *parent, Notebook *notebook, NotebookPage *page)
: QWidget(parent)
NotebookTab::NotebookTab(Notebook *notebook)
: QWidget(notebook)
{
this->notebook = notebook;
this->page = page;
resize(100, 24);
}
void NotebookTab::paintEvent(QPaintEvent *)
{
QPainter painter(this);
painter.setBrush(this->mouseDown ? QColor(0, 255, 0) : (this->mouseOver ? QColor(255, 0, 0) : QColor(0, 0, 255)));
painter.drawRect(0, 0, this->width(), this->height());
}
void NotebookTab::mousePressEvent(QMouseEvent *)
{
mouseDown = true;
this->repaint();
}
void NotebookTab::mouseReleaseEvent(QMouseEvent *)
{
mouseDown = false;
this->repaint();
}
void NotebookTab::enterEvent(QEvent *)
{
mouseOver = true;
this->repaint();
}
void NotebookTab::leaveEvent(QEvent *)
{
mouseOver = false;
this->repaint();
}