QtNovelUI/libSplitView/DockPanel.h

122 lines
3.7 KiB
C
Raw Normal View History

2023-08-26 12:40:57 +00:00
#ifndef BASEVIEW_H
#define BASEVIEW_H
2024-02-10 07:09:02 +00:00
#include "libSplitView.h"
2023-08-26 12:40:57 +00:00
#include <QFrame>
#include <QIcon>
#include <QLabel>
2024-01-27 01:47:02 +00:00
#include <QPushButton>
2023-08-26 12:40:57 +00:00
#include <QString>
2024-02-08 13:12:45 +00:00
namespace dock_panel {
2024-01-27 01:47:02 +00:00
class DockableView;
2023-08-26 12:40:57 +00:00
/**
* @brief
*/
2024-01-24 04:58:19 +00:00
class SPLITVIEW_EXPORT DragHeader : public QFrame {
2024-01-27 01:47:02 +00:00
Q_OBJECT
2023-08-26 12:40:57 +00:00
private:
2024-01-27 01:47:02 +00:00
DockableView *const bind_core;
QLabel *const icon_holder;
2024-01-27 01:47:02 +00:00
QLabel *const title_holder;
QPushButton *const close_btn, *const minimal_btn;
2023-08-26 12:40:57 +00:00
std::tuple<bool, QPointF> press_flag = std::make_tuple(false, QPointF());
2024-01-27 01:47:02 +00:00
signals:
/**
* @brief
*/
void closeRequest();
/**
* @brief
*/
void retrieveRequest();
/**
* @brief
* @param pos
*/
void adjustRequest(const QPoint &pos);
public:
DragHeader(const QString &title, DockableView *bind_core);
DragHeader(const QString &title, const QIcon &icon, DockableView *bind_core);
void setTitle(const QString &title);
void setTitle(const QString &title, const QIcon &icon);
void optConfig(bool retrieve, bool close);
2023-08-26 12:40:57 +00:00
// QWidget interface
protected:
virtual void mousePressEvent(QMouseEvent *event) override;
virtual void mouseReleaseEvent(QMouseEvent *event) override;
virtual void mouseMoveEvent(QMouseEvent *event) override;
};
/**
* @brief
*/
2024-02-08 13:12:45 +00:00
class SPLITVIEW_EXPORT DockableView : public QWidget, public split_frame::ViewBase {
2023-08-26 12:40:57 +00:00
public:
2024-01-27 01:47:02 +00:00
/**
* @brief
* @param present
* @param custom_header
*/
DockableView(split_frame::ResManager*mgr, QWidget *present);
2024-02-10 07:09:02 +00:00
virtual ~DockableView();
2024-01-27 01:47:02 +00:00
/**
* @brief
* @param replace
* @param close
* @param retrieve
*/
void viewConfig(bool replace, bool close, bool retrieve);
/**
* @brief
* @param title
*/
void setTitle(const QString &title);
void setTitle(const QIcon &icon, const QString &title);
2023-08-26 12:40:57 +00:00
2024-02-08 13:12:45 +00:00
2024-01-27 01:47:02 +00:00
void adjustAccept(const QPoint &pos);
void closeAccept();
void retrieveAccept();
2023-08-26 12:40:57 +00:00
2024-01-24 04:58:19 +00:00
private:
2024-01-27 01:47:02 +00:00
DragHeader *const title_header;
QWidget *const present_cube;
split_frame::ResManager *const manager_inst;
QIcon icon_store;
split_frame::SplitView *parent_res = nullptr;
2024-01-24 04:58:19 +00:00
bool m_replace = false, m_retrieve = false, m_close = false;
2023-08-26 12:40:57 +00:00
// ViewRes interface
public:
2023-12-30 05:04:51 +00:00
virtual split_frame::ResManager *splitManager() const override;
2024-01-27 01:47:02 +00:00
virtual split_frame::SplitView *parentRes() const override;
virtual void setParentRes(split_frame::SplitView *inst) override;
2023-12-30 05:04:51 +00:00
virtual QWidget *widget() const override;
2024-02-08 13:12:45 +00:00
virtual QSizeF stiffSize() const override;
virtual QRectF outlineRect() const override;
virtual void setOutline(const QRectF &rect) override;
2024-01-27 01:47:02 +00:00
virtual qulonglong hashCode() const override;
2024-02-08 13:12:45 +00:00
virtual void setVisible(bool state) override;
virtual bool isVisible() const override;
2023-08-26 12:40:57 +00:00
2023-12-30 05:04:51 +00:00
// ViewBase interface
2023-08-26 12:40:57 +00:00
public:
2023-12-30 05:04:51 +00:00
virtual QIcon icon() const override;
virtual QString title() const override;
2024-02-08 13:12:45 +00:00
virtual bool canRetrieve() const override;
virtual bool canClose() const override;
virtual bool canReplace() const override;
2023-08-26 12:40:57 +00:00
};
2024-01-27 01:47:02 +00:00
}
2023-08-26 12:40:57 +00:00
#endif // BASEVIEW_H