1.修复了纵向分割无法调整的bug

2.删除了视图功能配置暂时不用的内容
This commit is contained in:
codeboss 2024-02-10 15:46:21 +08:00
parent 17335aca05
commit 2af38a4937
6 changed files with 28 additions and 10 deletions

View File

@ -54,6 +54,14 @@ void DragHeader::setTitle(const QString &title, const QIcon &icon)
this->title_holder->setPixmap(icon.pixmap(22, 22)); 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) void DragHeader::mousePressEvent(QMouseEvent *event)
{ {
QFrame::mousePressEvent(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)), : title_header(new DragHeader("未命名", this)),
present_cube(present), present_cube(present),
manager_inst(mgr) manager_inst(mgr)
{ {
if(!drag_header){
this->title_header->setVisible(false);
}
auto layout = new QVBoxLayout(this); auto layout = new QVBoxLayout(this);
layout->addWidget(title_header); layout->addWidget(title_header);
if(present_cube){ if(present_cube){
@ -102,6 +106,8 @@ DockableView::DockableView(split_frame::ResManager *mgr, QWidget *present, bool
layout->setSpacing(0); layout->setSpacing(0);
layout->setContentsMargins(0, 2, 0, 0); layout->setContentsMargins(0, 2, 0, 0);
this->title_header->setVisible(true);
this->title_header->setMinimumHeight(26); this->title_header->setMinimumHeight(26);
this->title_header->setMaximumHeight(26); this->title_header->setMaximumHeight(26);
this->title_header->setFrameShape(QFrame::Shape::Panel); 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_replace = replace;
this->m_retrieve = retrieve; this->m_retrieve = retrieve;
this->m_close = close; this->m_close = close;
this->title_header->optConfig(retrieve, close);
} }
void DockableView::setTitle(const QString &title) void DockableView::setTitle(const QString &title)

View File

@ -44,6 +44,8 @@ namespace dock_panel {
void setTitle(const QString &title); void setTitle(const QString &title);
void setTitle(const QString &title, const QIcon &icon); void setTitle(const QString &title, const QIcon &icon);
void optConfig(bool retrieve, bool close);
// QWidget interface // QWidget interface
protected: protected:
virtual void mousePressEvent(QMouseEvent *event) override; virtual void mousePressEvent(QMouseEvent *event) override;
@ -61,7 +63,7 @@ namespace dock_panel {
* @param present * @param present
* @param custom_header * @param custom_header
*/ */
DockableView(split_frame::ResManager*mgr, QWidget *present, bool drag_header = false); DockableView(split_frame::ResManager*mgr, QWidget *present);
virtual ~DockableView(); virtual ~DockableView();
/** /**
* @brief * @brief

View File

@ -220,7 +220,7 @@ void SplitPanel::splitter_adjust(const QPoint &pos)
auto theight = split_member.first->stiffSize().height(); auto theight = split_member.first->stiffSize().height();
auto bheight = split_member.second->stiffSize().height(); auto bheight = split_member.second->stiffSize().height();
if(pos.y() >= theight && pos.y() <= this->height() - bheight - std::get<2>(split_info)) 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; }break;
} }

View File

@ -18,8 +18,13 @@ using namespace split_window;
using namespace split_frame; using namespace split_frame;
SplitWindow::SplitWindow(QWidget *parent) 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); accept_port->setVisible(false);
this->addToolBar(Qt::ToolBarArea::LeftToolBarArea, unused_stack);
} }
SplitWindow::~SplitWindow() {this->active = false;} SplitWindow::~SplitWindow() {this->active = false;}

View File

@ -7,6 +7,7 @@
#include <QMainWindow> #include <QMainWindow>
#include <QWidget> #include <QWidget>
#include <libConfig.h> #include <libConfig.h>
#include <QToolBar>
namespace split_window { namespace split_window {
@ -19,6 +20,7 @@ namespace split_window {
private: private:
bool active = false; bool active = false;
QToolBar *const unused_stack;
QList<split_frame::FreedomViewsListener*> listener_list; QList<split_frame::FreedomViewsListener*> listener_list;
QHash<qulonglong, split_frame::ViewBase*> presents_store; QHash<qulonglong, split_frame::ViewBase*> presents_store;

View File

@ -20,8 +20,9 @@ int main(int argc, char *argv[]) {
split_window::SplitWindow w; split_window::SplitWindow w;
auto spb = new split_panel::SplitPanel(&w, split_frame::SplitType::SPLIT_H_LFIRST); auto spb = new split_panel::SplitPanel(&w, split_frame::SplitType::SPLIT_H_LFIRST);
auto bview = 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, true); auto dview = new dock_panel::DockableView(&w, new QWidget);
dview->viewConfig(true, false, false);
spb->initViews(bview, dview); spb->initViews(bview, dview);
w.setPresentTarget(spb); w.setPresentTarget(spb);