2017-06-07 10:09:24 +02:00
|
|
|
#pragma once
|
2016-12-29 17:31:07 +01:00
|
|
|
|
2018-06-26 15:33:51 +02:00
|
|
|
#include "common/Common.hpp"
|
2018-06-26 14:09:39 +02:00
|
|
|
#include "widgets/BaseWidget.hpp"
|
2018-08-08 15:35:54 +02:00
|
|
|
#include "widgets/helper/Button.hpp"
|
2017-08-13 16:10:53 +02:00
|
|
|
|
2017-08-13 16:52:16 +02:00
|
|
|
#include <QMenu>
|
2017-01-22 12:46:35 +01:00
|
|
|
#include <QPropertyAnimation>
|
2017-12-22 14:44:31 +01:00
|
|
|
#include <pajlada/settings/setting.hpp>
|
2017-12-17 03:37:46 +01:00
|
|
|
#include <pajlada/signals/connection.hpp>
|
2016-12-29 17:31:07 +01:00
|
|
|
|
2017-01-18 21:30:23 +01:00
|
|
|
namespace chatterino {
|
|
|
|
|
2018-05-23 04:22:17 +02:00
|
|
|
#define NOTEBOOK_TAB_HEIGHT 28
|
|
|
|
|
|
|
|
// class Notebook;
|
2018-05-23 11:59:37 +02:00
|
|
|
class Notebook;
|
2017-11-12 17:21:50 +01:00
|
|
|
class SplitContainer;
|
2016-12-29 18:02:13 +01:00
|
|
|
|
2018-08-08 15:35:54 +02:00
|
|
|
class NotebookTab : public Button
|
2018-04-18 09:12:29 +02:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2018-07-06 19:23:47 +02:00
|
|
|
explicit NotebookTab(Notebook *notebook);
|
2018-04-18 09:12:29 +02:00
|
|
|
|
|
|
|
void updateSize();
|
|
|
|
|
|
|
|
QWidget *page;
|
|
|
|
|
2018-06-01 16:01:49 +02:00
|
|
|
void setCustomTitle(const QString &title);
|
|
|
|
void resetCustomTitle();
|
|
|
|
bool hasCustomTitle() const;
|
|
|
|
const QString &getCustomTitle() const;
|
|
|
|
void setDefaultTitle(const QString &title);
|
|
|
|
const QString &getDefaultTitle() const;
|
2018-04-18 09:12:29 +02:00
|
|
|
const QString &getTitle() const;
|
2018-06-01 16:01:49 +02:00
|
|
|
|
2018-04-18 09:12:29 +02:00
|
|
|
bool isSelected() const;
|
|
|
|
void setSelected(bool value);
|
|
|
|
|
2018-10-21 12:13:09 +02:00
|
|
|
void setInLastRow(bool value);
|
|
|
|
|
2018-10-13 14:20:06 +02:00
|
|
|
void setLive(bool isLive);
|
2018-04-18 09:12:29 +02:00
|
|
|
void setHighlightState(HighlightState style);
|
2018-09-30 15:02:30 +02:00
|
|
|
void setHighlightsEnabled(const bool &newVal);
|
|
|
|
bool hasHighlightsEnabled() const;
|
2018-04-18 09:12:29 +02:00
|
|
|
|
|
|
|
void moveAnimated(QPoint pos, bool animated = true);
|
|
|
|
|
|
|
|
QRect getDesiredRect() const;
|
2018-11-03 13:00:07 +01:00
|
|
|
void hideTabXChanged();
|
2018-04-18 09:12:29 +02:00
|
|
|
|
|
|
|
protected:
|
2018-07-06 17:11:37 +02:00
|
|
|
virtual void themeChangedEvent() override;
|
2018-04-18 09:12:29 +02:00
|
|
|
|
|
|
|
virtual void paintEvent(QPaintEvent *) override;
|
|
|
|
|
|
|
|
virtual void mousePressEvent(QMouseEvent *event) override;
|
|
|
|
virtual void mouseReleaseEvent(QMouseEvent *event) override;
|
2018-10-22 19:57:02 +02:00
|
|
|
virtual void mouseDoubleClickEvent(QMouseEvent *event) override;
|
2018-04-18 09:12:29 +02:00
|
|
|
virtual void enterEvent(QEvent *) override;
|
|
|
|
virtual void leaveEvent(QEvent *) override;
|
|
|
|
|
|
|
|
virtual void dragEnterEvent(QDragEnterEvent *event) override;
|
|
|
|
|
|
|
|
virtual void mouseMoveEvent(QMouseEvent *event) override;
|
2018-10-01 02:32:20 +02:00
|
|
|
virtual void wheelEvent(QWheelEvent *event) override;
|
2018-04-18 09:12:29 +02:00
|
|
|
|
|
|
|
private:
|
2018-10-22 19:57:02 +02:00
|
|
|
void showRenameDialog();
|
|
|
|
|
2018-07-06 19:23:47 +02:00
|
|
|
bool hasXButton();
|
|
|
|
bool shouldDrawXButton();
|
|
|
|
QRect getXRect();
|
|
|
|
void titleUpdated();
|
2018-04-18 09:12:29 +02:00
|
|
|
|
2018-06-01 14:57:18 +02:00
|
|
|
QPropertyAnimation positionChangedAnimation_;
|
|
|
|
bool positionChangedAnimationRunning_ = false;
|
|
|
|
QPoint positionAnimationDesiredPoint_;
|
2018-04-18 09:12:29 +02:00
|
|
|
|
2018-06-01 14:57:18 +02:00
|
|
|
Notebook *notebook_;
|
2018-04-18 09:12:29 +02:00
|
|
|
|
2018-06-01 16:01:49 +02:00
|
|
|
QString customTitle_;
|
|
|
|
QString defaultTitle_;
|
2018-04-18 09:12:29 +02:00
|
|
|
|
2018-10-21 12:13:09 +02:00
|
|
|
bool selected_{};
|
|
|
|
bool mouseOver_{};
|
|
|
|
bool mouseDown_{};
|
|
|
|
bool mouseOverX_{};
|
|
|
|
bool mouseDownX_{};
|
|
|
|
bool isInLastRow_{};
|
2018-04-18 09:12:29 +02:00
|
|
|
|
2018-06-01 14:57:18 +02:00
|
|
|
HighlightState highlightState_ = HighlightState::None;
|
2018-09-30 14:31:00 +02:00
|
|
|
bool highlightEnabled_ = true;
|
2018-09-30 15:02:30 +02:00
|
|
|
QAction *highlightNewMessagesAction_;
|
2017-01-22 05:58:23 +01:00
|
|
|
|
2018-10-13 14:20:06 +02:00
|
|
|
bool isLive_{};
|
|
|
|
|
2018-06-01 14:57:18 +02:00
|
|
|
QMenu menu_;
|
2017-08-13 16:52:16 +02:00
|
|
|
|
2018-07-06 19:23:47 +02:00
|
|
|
std::vector<pajlada::Signals::ScopedConnection> managedConnections_;
|
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 chatterino
|