mirror-chatterino2/src/widgets/helper/NotebookTab.hpp

92 lines
2.1 KiB
C++
Raw Normal View History

#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"
#include "widgets/helper/RippleEffectButton.hpp"
2017-08-13 16:10:53 +02:00
#include <QMenu>
2017-01-22 12:46:35 +01:00
#include <QPropertyAnimation>
#include <pajlada/settings/setting.hpp>
#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-06-11 21:57:17 +02:00
class NotebookTab : public RippleEffectButton
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);
void setHighlightState(HighlightState style);
void moveAnimated(QPoint pos, bool animated = true);
QRect getDesiredRect() const;
void hideTabXChanged(bool);
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;
virtual void enterEvent(QEvent *) override;
virtual void leaveEvent(QEvent *) override;
virtual void dragEnterEvent(QDragEnterEvent *event) override;
virtual void mouseMoveEvent(QMouseEvent *event) override;
private:
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-06-01 14:57:18 +02:00
bool selected_ = false;
bool mouseOver_ = false;
bool mouseDown_ = false;
bool mouseOverX_ = false;
bool mouseDownX_ = false;
2018-04-18 09:12:29 +02:00
2018-06-01 14:57:18 +02:00
HighlightState highlightState_ = HighlightState::None;
2018-06-01 14:57:18 +02:00
QMenu menu_;
2018-07-06 19:23:47 +02:00
std::vector<pajlada::Signals::ScopedConnection> managedConnections_;
2016-12-29 17:31:07 +01:00
};
2017-04-14 17:52:22 +02:00
} // namespace chatterino