2023-08-27 14:09:46 +00:00
|
|
|
#include "viewstackedbar.h"
|
|
|
|
|
|
|
|
#include <QLayout>
|
|
|
|
#include <QMainWindow>
|
|
|
|
|
|
|
|
using namespace Components;
|
|
|
|
using namespace SplitFrame;
|
|
|
|
|
2023-12-30 05:04:51 +00:00
|
|
|
ViewStackedBar::ViewStackedBar(SplitPanel *host, QWidget *parent) : QToolBar(parent), host_ptr(host) {
|
2023-08-27 14:09:46 +00:00
|
|
|
setToolButtonStyle(Qt::ToolButtonStyle::ToolButtonIconOnly);
|
|
|
|
setAllowedAreas(Qt::LeftToolBarArea | Qt::RightToolBarArea | Qt::TopToolBarArea | Qt::BottomToolBarArea);
|
|
|
|
setContextMenuPolicy(Qt::CustomContextMenu);
|
|
|
|
|
|
|
|
layout()->setMargin(0);
|
|
|
|
layout()->setSpacing(0);
|
|
|
|
setIconSize(QSize(30, 30));
|
|
|
|
}
|
|
|
|
|
|
|
|
void ViewStackedBar::freedomAppended(SplitFrame::RectCom *ins, const QIcon &icon, const QString &title) {
|
|
|
|
if (freedom_views.contains(ins))
|
|
|
|
return;
|
|
|
|
|
|
|
|
auto action = addAction(icon, title);
|
|
|
|
freedom_views[ins] = action;
|
|
|
|
|
|
|
|
connect(action, &QAction::triggered, [ins, this]() {
|
|
|
|
if (host_ptr->isTemporaryView(ins)) {
|
|
|
|
host_ptr->temporaryVisible(DockType::LEFT);
|
|
|
|
} else {
|
|
|
|
auto pinst = static_cast<QMainWindow *>(this->parent());
|
|
|
|
|
|
|
|
DockType position = DockType::LEFT;
|
|
|
|
switch (pinst->toolBarArea(this)) {
|
|
|
|
case Qt::ToolBarArea::BottomToolBarArea:
|
|
|
|
position = DockType::BOTTOM;
|
|
|
|
break;
|
|
|
|
case Qt::ToolBarArea::TopToolBarArea:
|
|
|
|
position = DockType::TOP;
|
|
|
|
break;
|
|
|
|
case Qt::ToolBarArea::LeftToolBarArea:
|
|
|
|
position = DockType::LEFT;
|
|
|
|
break;
|
|
|
|
case Qt::ToolBarArea::RightToolBarArea:
|
|
|
|
position = DockType::RIGHT;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
host_ptr->temporaryVisible(position, ins);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
void ViewStackedBar::freedomRemoved(SplitFrame::RectCom *ins) {
|
|
|
|
if (freedom_views.contains(ins)) {
|
|
|
|
auto action = freedom_views[ins];
|
|
|
|
removeAction(action);
|
|
|
|
freedom_views.remove(ins);
|
|
|
|
}
|
|
|
|
}
|