2017-06-07 10:09:24 +02:00
|
|
|
#pragma once
|
2016-12-29 17:31:07 +01:00
|
|
|
|
2017-01-22 12:46:35 +01:00
|
|
|
#include <QPropertyAnimation>
|
2017-01-15 16:38:30 +01:00
|
|
|
#include <QWidget>
|
2017-01-28 22:35:23 +01:00
|
|
|
#include <boost/property_tree/ptree.hpp>
|
2017-02-02 02:46:33 +01:00
|
|
|
#include <boost/signals2.hpp>
|
|
|
|
#include <boost/signals2/connection.hpp>
|
2016-12-29 17:31:07 +01:00
|
|
|
|
2017-01-18 21:30:23 +01:00
|
|
|
namespace chatterino {
|
2017-06-26 16:41:20 +02:00
|
|
|
|
|
|
|
class ColorScheme;
|
|
|
|
|
2017-01-18 21:30:23 +01:00
|
|
|
namespace widgets {
|
|
|
|
|
2016-12-29 18:02:13 +01:00
|
|
|
class Notebook;
|
2016-12-30 18:00:25 +01:00
|
|
|
class NotebookPage;
|
2016-12-29 18:02:13 +01:00
|
|
|
|
2016-12-29 17:31:07 +01:00
|
|
|
class NotebookTab : public QWidget
|
|
|
|
{
|
2017-01-11 18:52:09 +01:00
|
|
|
Q_OBJECT
|
2016-12-29 17:31:07 +01:00
|
|
|
|
|
|
|
public:
|
2017-04-12 17:46:44 +02:00
|
|
|
enum HighlightStyle { HighlightNone, HighlightHighlighted, HighlightNewMessage };
|
2017-01-15 16:38:30 +01:00
|
|
|
|
2017-04-12 17:46:44 +02:00
|
|
|
explicit NotebookTab(Notebook *_notebook);
|
2017-01-22 05:58:23 +01:00
|
|
|
~NotebookTab();
|
2016-12-30 12:20:26 +01:00
|
|
|
|
2017-06-26 16:41:20 +02:00
|
|
|
ColorScheme &colorScheme;
|
|
|
|
|
2016-12-30 18:00:25 +01:00
|
|
|
void calcSize();
|
|
|
|
|
2017-01-11 18:52:09 +01:00
|
|
|
NotebookPage *page;
|
2016-12-30 18:00:25 +01:00
|
|
|
|
2017-04-12 17:46:44 +02:00
|
|
|
const QString &getTitle() const;
|
|
|
|
void setTitle(const QString &title);
|
|
|
|
bool getSelected();
|
|
|
|
void setSelected(bool value);
|
2017-01-01 02:30:42 +01:00
|
|
|
|
2017-04-12 17:46:44 +02:00
|
|
|
HighlightStyle getHighlightStyle() const;
|
|
|
|
void setHighlightStyle(HighlightStyle style);
|
2017-01-01 02:30:42 +01:00
|
|
|
|
2017-01-26 05:26:21 +01:00
|
|
|
void moveAnimated(QPoint pos, bool animated = true);
|
|
|
|
|
2017-04-12 17:46:44 +02:00
|
|
|
QRect getDesiredRect() const;
|
|
|
|
void hideTabXChanged(bool);
|
2017-02-02 02:46:33 +01:00
|
|
|
|
2016-12-30 12:20:26 +01:00
|
|
|
protected:
|
2017-01-22 05:58:23 +01:00
|
|
|
void paintEvent(QPaintEvent *) override;
|
2016-12-30 12:20:26 +01:00
|
|
|
|
2017-01-22 05:58:23 +01:00
|
|
|
void mousePressEvent(QMouseEvent *event) override;
|
|
|
|
void mouseReleaseEvent(QMouseEvent *event) override;
|
|
|
|
void enterEvent(QEvent *) override;
|
|
|
|
void leaveEvent(QEvent *) override;
|
2016-12-30 12:20:26 +01:00
|
|
|
|
2017-01-22 05:58:23 +01:00
|
|
|
void dragEnterEvent(QDragEnterEvent *event) override;
|
|
|
|
|
|
|
|
void mouseMoveEvent(QMouseEvent *event) override;
|
2017-01-01 02:30:42 +01:00
|
|
|
|
2016-12-29 17:31:07 +01:00
|
|
|
private:
|
2017-04-12 17:46:44 +02:00
|
|
|
boost::signals2::connection _hideXConnection;
|
2017-02-02 02:46:33 +01:00
|
|
|
|
2017-04-12 17:46:44 +02:00
|
|
|
QPropertyAnimation _posAnimation;
|
2017-06-26 16:41:20 +02:00
|
|
|
bool _posAnimated = false;
|
2017-04-12 17:46:44 +02:00
|
|
|
QPoint _posAnimationDesired;
|
2017-01-22 12:46:35 +01:00
|
|
|
|
2017-04-12 17:46:44 +02:00
|
|
|
Notebook *_notebook;
|
2017-01-15 16:38:30 +01:00
|
|
|
|
2017-06-26 16:41:20 +02:00
|
|
|
QString _title = "<no title>";
|
2016-12-30 12:20:26 +01:00
|
|
|
|
2017-06-26 16:41:20 +02:00
|
|
|
bool _selected = false;
|
|
|
|
bool _mouseOver = false;
|
|
|
|
bool _mouseDown = false;
|
|
|
|
bool _mouseOverX = false;
|
|
|
|
bool _mouseDownX = false;
|
2017-01-22 05:58:23 +01:00
|
|
|
|
2017-06-26 16:41:20 +02:00
|
|
|
HighlightStyle _highlightStyle = HighlightStyle::HighlightNone;
|
2017-01-22 05:58:23 +01:00
|
|
|
|
2017-04-12 17:46:44 +02:00
|
|
|
QRect getXRect()
|
2017-01-22 05:58:23 +01:00
|
|
|
{
|
|
|
|
return QRect(this->width() - 20, 4, 16, 16);
|
|
|
|
}
|
|
|
|
|
2017-01-28 22:35:23 +01:00
|
|
|
public:
|
|
|
|
void load(const boost::property_tree::ptree &tree);
|
|
|
|
boost::property_tree::ptree save();
|
2016-12-29 17:31:07 +01:00
|
|
|
};
|
2017-01-28 22:35:23 +01:00
|
|
|
|
2017-04-14 17:52:22 +02:00
|
|
|
} // namespace widgets
|
|
|
|
} // namespace chatterino
|