mirror-chatterino2/src/widgets/helper/NotebookTab.hpp
nerix 5179567334
Use QEnterEvent for QWidget::enterEvent on Qt 6 (#4365)
* fix: use concrete QEnterEvent on Qt 6

* chore: add changelog entry
2023-02-11 18:13:29 +01:00

116 lines
2.8 KiB
C++

#pragma once
#include "common/Common.hpp"
#include "widgets/helper/Button.hpp"
#include "widgets/Notebook.hpp"
#include <pajlada/settings/setting.hpp>
#include <pajlada/signals/signalholder.hpp>
#include <QMenu>
#include <QPropertyAnimation>
namespace chatterino {
#define NOTEBOOK_TAB_HEIGHT 28
class SplitContainer;
class NotebookTab : public Button
{
Q_OBJECT
public:
explicit NotebookTab(Notebook *notebook);
void updateSize();
QWidget *page;
void setCustomTitle(const QString &title);
void resetCustomTitle();
bool hasCustomTitle() const;
const QString &getCustomTitle() const;
void setDefaultTitle(const QString &title);
const QString &getDefaultTitle() const;
const QString &getTitle() const;
bool isSelected() const;
void setSelected(bool value);
void setInLastRow(bool value);
void setTabLocation(NotebookTabLocation location);
void setLive(bool isLive);
void setHighlightState(HighlightState style);
void setHighlightsEnabled(const bool &newVal);
bool hasHighlightsEnabled() const;
void moveAnimated(QPoint pos, bool animated = true);
QRect getDesiredRect() const;
void hideTabXChanged();
void growWidth(int width);
int normalTabWidth();
protected:
virtual void themeChangedEvent() override;
virtual void paintEvent(QPaintEvent *) override;
virtual void mousePressEvent(QMouseEvent *event) override;
virtual void mouseReleaseEvent(QMouseEvent *event) override;
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
virtual void leaveEvent(QEvent *) override;
virtual void dragEnterEvent(QDragEnterEvent *event) override;
virtual void mouseMoveEvent(QMouseEvent *event) override;
virtual void wheelEvent(QWheelEvent *event) override;
private:
void showRenameDialog();
bool hasXButton();
bool shouldDrawXButton();
QRect getXRect();
void titleUpdated();
QPropertyAnimation positionChangedAnimation_;
bool positionChangedAnimationRunning_ = false;
QPoint positionAnimationDesiredPoint_;
Notebook *notebook_;
QString customTitle_;
QString defaultTitle_;
bool selected_{};
bool mouseOver_{};
bool mouseDown_{};
bool mouseOverX_{};
bool mouseDownX_{};
bool isInLastRow_{};
int mouseWheelDelta_ = 0;
NotebookTabLocation tabLocation_ = NotebookTabLocation::Top;
HighlightState highlightState_ = HighlightState::None;
bool highlightEnabled_ = true;
QAction *highlightNewMessagesAction_;
bool isLive_{};
int growWidth_ = 0;
QMenu menu_;
pajlada::Signals::SignalHolder managedConnections_;
};
} // namespace chatterino