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

116 lines
2.8 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-08-08 15:35:54 +02:00
#include "widgets/helper/Button.hpp"
#include "widgets/Notebook.hpp"
2017-08-13 16:10:53 +02:00
#include <pajlada/settings/setting.hpp>
#include <pajlada/signals/signalholder.hpp>
#include <QMenu>
#include <QPropertyAnimation>
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
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);
void setTabLocation(NotebookTabLocation location);
2018-10-21 12:13:09 +02:00
2018-10-13 14:20:06 +02:00
void setLive(bool isLive);
2018-04-18 09:12:29 +02:00
void setHighlightState(HighlightState style);
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;
void hideTabXChanged();
2018-04-18 09:12:29 +02:00
void growWidth(int width);
int normalTabWidth();
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;
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
void enterEvent(QEnterEvent *event) override;
#else
void enterEvent(QEvent *event) override;
#endif
2018-04-18 09:12:29 +02:00
virtual void leaveEvent(QEvent *) override;
virtual void dragEnterEvent(QDragEnterEvent *event) override;
virtual void mouseMoveEvent(QMouseEvent *event) override;
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_{};
int mouseWheelDelta_ = 0;
NotebookTabLocation tabLocation_ = NotebookTabLocation::Top;
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;
QAction *highlightNewMessagesAction_;
2018-10-13 14:20:06 +02:00
bool isLive_{};
int growWidth_ = 0;
2018-06-01 14:57:18 +02:00
QMenu menu_;
pajlada::Signals::SignalHolder managedConnections_;
2016-12-29 17:31:07 +01:00
};
2017-04-14 17:52:22 +02:00
} // namespace chatterino