164 lines
2.3 KiB
C++
Executable File
164 lines
2.3 KiB
C++
Executable File
|
|
|
|
|
|
#pragma once
|
|
|
|
#include "lts_base.h"
|
|
#include "lts_widgets_export.h"
|
|
|
|
#include <QTabWidget>
|
|
#include <QMap>
|
|
#include <QAbstractButton>
|
|
|
|
|
|
namespace LtsWidgets
|
|
{
|
|
class LtsDialogHelper;
|
|
class LtsTabBar;
|
|
|
|
|
|
|
|
class LTSWIDGETS_EXPORT LtsTabWidget : public QTabWidget
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
|
|
|
|
explicit LtsTabWidget(QWidget *parent = nullptr, bool isSecondary = false);
|
|
~LtsTabWidget();
|
|
|
|
|
|
|
|
void setActuatorTabStyle(bool enable);
|
|
|
|
|
|
|
|
void clearAll();
|
|
|
|
|
|
void aboutToClose();
|
|
|
|
|
|
|
|
LtsTabBar *tabBar();
|
|
|
|
|
|
|
|
void setTabBar(LtsTabBar *tabbar);
|
|
|
|
|
|
|
|
bool focusTab(const QString &menuGroup, const QString &identifier);
|
|
|
|
|
|
|
|
void setSubTabsVisible(bool visible);
|
|
|
|
|
|
|
|
QWidget *getWidget(const QString &menuGroup, const QString &identifier);
|
|
|
|
|
|
|
|
static bool hasUnsavedChanges(LtsTabWidget *tabWidget);
|
|
|
|
|
|
|
|
signals:
|
|
|
|
|
|
void signalCheckTabBarVisibility();
|
|
|
|
|
|
public slots:
|
|
|
|
|
|
void addTab(const QString &menuGroup, const QString &identifier, QWidget *widget,
|
|
bool setClosable = true, bool focusNewTab = true);
|
|
|
|
|
|
|
|
bool removeWidget(QWidget * widget);
|
|
|
|
private slots:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void onRemoveTab(QObject *object);
|
|
|
|
|
|
|
|
void onCheckTabBarVisibility();
|
|
|
|
|
|
|
|
void slotTabCloseRequested(int index);
|
|
|
|
void slotCurrentChanged(int newIdx);
|
|
|
|
void slotMaximizeButtonClicked();
|
|
|
|
private:
|
|
|
|
|
|
void addWidget(const QString &fullName, QWidget *widget, bool setClosable, bool focusNewTab = true);
|
|
|
|
|
|
|
|
QWidget *getWidget(const QString &fullName);
|
|
|
|
|
|
|
|
bool focusWidget(const QString &fullName);
|
|
|
|
|
|
|
|
void slotWindowTitleChanged(const QString &title);
|
|
|
|
void closeRequestTabWidget(LtsTabWidget *tabWidget);
|
|
|
|
QPoint startPos;
|
|
LtsTabBar *m_tabbar = nullptr;
|
|
QPalette m_palette;
|
|
|
|
|
|
QMap<QString, QWidget *> m_tabMap;
|
|
|
|
|
|
bool m_hasSubTabs;
|
|
bool m_isSecondary;
|
|
|
|
QByteArray m_mainSplitterState;
|
|
};
|
|
|
|
|
|
class CloseButton : public QAbstractButton
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
using QAbstractButton::QAbstractButton;
|
|
|
|
void setFontColor(const QColor &fontColor) { m_fontColor = fontColor; }
|
|
QRectF cross() const;
|
|
QLineF line() const;
|
|
|
|
protected:
|
|
void mousePressEvent(QMouseEvent *e) override;
|
|
void mouseReleaseEvent(QMouseEvent *e) override;
|
|
void paintEvent(QPaintEvent *e) override;
|
|
QSize sizeHint() const override;
|
|
|
|
private:
|
|
QColor m_fontColor;
|
|
bool m_isPressed = false;
|
|
};
|
|
}
|