parent
17335aca05
commit
2af38a4937
|
@ -54,6 +54,14 @@ void DragHeader::setTitle(const QString &title, const QIcon &icon)
|
|||
this->title_holder->setPixmap(icon.pixmap(22, 22));
|
||||
}
|
||||
|
||||
void DragHeader::optConfig(bool retrieve, bool close)
|
||||
{
|
||||
this->minimal_btn->setVisible(retrieve);
|
||||
this->minimal_btn->setEnabled(retrieve);
|
||||
this->close_btn->setVisible(close);
|
||||
this->close_btn->setEnabled(close);
|
||||
}
|
||||
|
||||
void DragHeader::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
QFrame::mousePressEvent(event);
|
||||
|
@ -82,15 +90,11 @@ void DragHeader::mouseMoveEvent(QMouseEvent *event)
|
|||
|
||||
// ===============================================================================
|
||||
|
||||
DockableView::DockableView(split_frame::ResManager *mgr, QWidget *present, bool drag_header)
|
||||
DockableView::DockableView(split_frame::ResManager *mgr, QWidget *present)
|
||||
: title_header(new DragHeader("未命名", this)),
|
||||
present_cube(present),
|
||||
manager_inst(mgr)
|
||||
{
|
||||
if(!drag_header){
|
||||
this->title_header->setVisible(false);
|
||||
}
|
||||
|
||||
auto layout = new QVBoxLayout(this);
|
||||
layout->addWidget(title_header);
|
||||
if(present_cube){
|
||||
|
@ -102,6 +106,8 @@ DockableView::DockableView(split_frame::ResManager *mgr, QWidget *present, bool
|
|||
|
||||
layout->setSpacing(0);
|
||||
layout->setContentsMargins(0, 2, 0, 0);
|
||||
|
||||
this->title_header->setVisible(true);
|
||||
this->title_header->setMinimumHeight(26);
|
||||
this->title_header->setMaximumHeight(26);
|
||||
this->title_header->setFrameShape(QFrame::Shape::Panel);
|
||||
|
@ -123,6 +129,8 @@ void DockableView::viewConfig(bool replace, bool close, bool retrieve)
|
|||
this->m_replace = replace;
|
||||
this->m_retrieve = retrieve;
|
||||
this->m_close = close;
|
||||
|
||||
this->title_header->optConfig(retrieve, close);
|
||||
}
|
||||
|
||||
void DockableView::setTitle(const QString &title)
|
||||
|
|
|
@ -44,6 +44,8 @@ namespace dock_panel {
|
|||
void setTitle(const QString &title);
|
||||
void setTitle(const QString &title, const QIcon &icon);
|
||||
|
||||
void optConfig(bool retrieve, bool close);
|
||||
|
||||
// QWidget interface
|
||||
protected:
|
||||
virtual void mousePressEvent(QMouseEvent *event) override;
|
||||
|
@ -61,7 +63,7 @@ namespace dock_panel {
|
|||
* @param present 内容视图实例
|
||||
* @param custom_header 是否添加标题栏
|
||||
*/
|
||||
DockableView(split_frame::ResManager*mgr, QWidget *present, bool drag_header = false);
|
||||
DockableView(split_frame::ResManager*mgr, QWidget *present);
|
||||
virtual ~DockableView();
|
||||
/**
|
||||
* @brief 配置视图基本特性
|
||||
|
|
|
@ -220,7 +220,7 @@ void SplitPanel::splitter_adjust(const QPoint &pos)
|
|||
auto theight = split_member.first->stiffSize().height();
|
||||
auto bheight = split_member.second->stiffSize().height();
|
||||
if(pos.y() >= theight && pos.y() <= this->height() - bheight - std::get<2>(split_info))
|
||||
this->split_info = std::make_tuple(std::get<0>(split_info), pos.y()/this->height(), std::get<2>(split_info));
|
||||
this->split_info = std::make_tuple(std::get<0>(split_info), pos.y()/(float)this->height(), std::get<2>(split_info));
|
||||
}break;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,8 +18,13 @@ using namespace split_window;
|
|||
using namespace split_frame;
|
||||
|
||||
SplitWindow::SplitWindow(QWidget *parent)
|
||||
: QMainWindow(parent), active(true), accept_port(new accept_panel::AcceptPanel(this, this)), view_root(nullptr) {
|
||||
: QMainWindow(parent),
|
||||
active(true),
|
||||
unused_stack(new QToolBar(this)),
|
||||
accept_port(new accept_panel::AcceptPanel(this, this)),
|
||||
view_root(nullptr) {
|
||||
accept_port->setVisible(false);
|
||||
this->addToolBar(Qt::ToolBarArea::LeftToolBarArea, unused_stack);
|
||||
}
|
||||
|
||||
SplitWindow::~SplitWindow() {this->active = false;}
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <QMainWindow>
|
||||
#include <QWidget>
|
||||
#include <libConfig.h>
|
||||
#include <QToolBar>
|
||||
|
||||
namespace split_window {
|
||||
|
||||
|
@ -19,6 +20,7 @@ namespace split_window {
|
|||
|
||||
private:
|
||||
bool active = false;
|
||||
QToolBar *const unused_stack;
|
||||
QList<split_frame::FreedomViewsListener*> listener_list;
|
||||
|
||||
QHash<qulonglong, split_frame::ViewBase*> presents_store;
|
||||
|
|
|
@ -20,8 +20,9 @@ int main(int argc, char *argv[]) {
|
|||
|
||||
split_window::SplitWindow w;
|
||||
auto spb = new split_panel::SplitPanel(&w, split_frame::SplitType::SPLIT_H_LFIRST);
|
||||
auto bview = new dock_panel::DockableView(&w, new QWidget, true);
|
||||
auto dview = new dock_panel::DockableView(&w, new QWidget, true);
|
||||
auto bview = new dock_panel::DockableView(&w, new QWidget);
|
||||
auto dview = new dock_panel::DockableView(&w, new QWidget);
|
||||
dview->viewConfig(true, false, false);
|
||||
spb->initViews(bview, dview);
|
||||
|
||||
w.setPresentTarget(spb);
|
||||
|
|
Loading…
Reference in New Issue