2022-11-06 00:37:50 +00:00
|
|
|
#include "mainwindow.h"
|
2023-03-17 13:58:38 +00:00
|
|
|
#include "srcedit_defaulttext.h"
|
2023-02-28 15:05:26 +00:00
|
|
|
#include "srcedit_storyboard.h"
|
2023-03-17 13:58:38 +00:00
|
|
|
#include "xapp.h"
|
2022-11-06 00:37:50 +00:00
|
|
|
|
2023-03-17 13:58:38 +00:00
|
|
|
#include <QApplication>
|
|
|
|
#include <QDateTime>
|
|
|
|
#include <QDebug>
|
|
|
|
#include <QFileDialog>
|
|
|
|
#include <QInputDialog>
|
2022-11-11 14:38:52 +00:00
|
|
|
#include <QLabel>
|
2023-03-17 13:58:38 +00:00
|
|
|
#include <QList>
|
2022-11-11 14:38:52 +00:00
|
|
|
#include <QMenuBar>
|
2023-03-17 13:58:38 +00:00
|
|
|
#include <QMessageBox>
|
2022-11-11 14:38:52 +00:00
|
|
|
#include <QStatusBar>
|
|
|
|
#include <QTextEdit>
|
2022-11-15 08:07:02 +00:00
|
|
|
#include <QToolBar>
|
2023-03-17 13:58:38 +00:00
|
|
|
#include <QVBoxLayout>
|
2022-11-18 23:47:32 +00:00
|
|
|
#include <xmlconfig.h>
|
2022-11-15 08:07:02 +00:00
|
|
|
#include <xmlprojectmanager.h>
|
|
|
|
|
2023-03-10 13:01:19 +00:00
|
|
|
#include "command_list.h"
|
|
|
|
|
2022-11-15 08:07:02 +00:00
|
|
|
using namespace Project;
|
2022-11-17 08:16:54 +00:00
|
|
|
using namespace MakeTools;
|
|
|
|
using namespace Components;
|
2022-11-22 03:42:48 +00:00
|
|
|
using namespace Core;
|
2022-12-01 13:54:04 +00:00
|
|
|
using namespace Tools;
|
2023-03-10 13:01:19 +00:00
|
|
|
using namespace CommandList;
|
2023-03-17 13:58:38 +00:00
|
|
|
using namespace DataModel;
|
2022-11-11 14:38:52 +00:00
|
|
|
|
2022-11-06 00:37:50 +00:00
|
|
|
MainWindow::MainWindow(QWidget *parent)
|
2023-03-17 13:58:38 +00:00
|
|
|
: QMainWindow(parent),
|
|
|
|
app_core(new AppCore(this)),
|
2022-11-18 23:47:32 +00:00
|
|
|
sync_kernel(new StatusSyncCore(this)),
|
2023-03-17 13:58:38 +00:00
|
|
|
split_first(new QSplitter(Qt::Horizontal, this)),
|
|
|
|
split_second(new QSplitter(Qt::Vertical, this)),
|
|
|
|
split_third(new QSplitter(Qt::Horizontal, this)),
|
2022-11-15 12:58:12 +00:00
|
|
|
project_manager(new XMLProjectManager(this)),
|
2023-03-17 13:58:38 +00:00
|
|
|
welcome_list(new WelcomePanel()),
|
|
|
|
errors_present(new MessagesPresent(app_core->getMakeCore(), this)),
|
2023-08-15 14:40:40 +00:00
|
|
|
project_present(new ProjectPresent(XApp::disp_core, docs_container, this)) {
|
2023-03-11 07:01:28 +00:00
|
|
|
|
2022-11-18 23:47:32 +00:00
|
|
|
QApplication::instance()->installEventFilter(this);
|
2023-03-17 13:58:38 +00:00
|
|
|
initial_commandlist(XApp::disp_core);
|
2023-03-11 07:01:28 +00:00
|
|
|
|
2023-03-17 13:58:38 +00:00
|
|
|
XApp::disp_core->registerMember(this->app_core);
|
2022-11-22 03:42:48 +00:00
|
|
|
this->app_core->setCurrentProject(project_manager);
|
2023-03-17 13:58:38 +00:00
|
|
|
XApp::disp_core->registerMember(docs_container);
|
|
|
|
XApp::disp_core->registerMember(fragments_model);
|
|
|
|
XApp::disp_core->registerMember(boards_model);
|
|
|
|
XApp::disp_core->registerMember(chains_model);
|
|
|
|
XApp::disp_core->registerMember(concepts_model);
|
|
|
|
XApp::disp_core->registerMember(units_model);
|
2022-11-18 23:47:32 +00:00
|
|
|
|
2022-11-11 14:38:52 +00:00
|
|
|
setMinimumSize(1000, 600);
|
2023-01-01 05:10:31 +00:00
|
|
|
setWindowTitle("提线木偶");
|
2022-11-11 14:38:52 +00:00
|
|
|
|
2023-03-17 13:58:38 +00:00
|
|
|
project_present->widget()->setVisible(false);
|
2022-11-18 23:47:32 +00:00
|
|
|
chains_view->setVisible(false);
|
|
|
|
units_view->setVisible(false);
|
|
|
|
errors_present->setVisible(false);
|
2022-11-25 01:18:54 +00:00
|
|
|
boards_view->setVisible(false);
|
|
|
|
concept_view->setVisible(false);
|
2022-12-08 19:43:42 +00:00
|
|
|
fragments_order->setVisible(false);
|
2022-11-15 08:07:02 +00:00
|
|
|
|
2022-11-11 14:38:52 +00:00
|
|
|
auto mbar = menuBar();
|
2023-03-10 13:01:19 +00:00
|
|
|
initial_menubar(mbar);
|
2022-11-17 08:16:54 +00:00
|
|
|
|
2023-03-17 13:58:38 +00:00
|
|
|
setCentralWidget(this->split_first);
|
|
|
|
this->split_first->addWidget(left_funcs->hostWidget());
|
|
|
|
this->split_first->addWidget(this->split_second);
|
2022-11-17 08:16:54 +00:00
|
|
|
|
2023-03-17 13:58:38 +00:00
|
|
|
this->split_second->addWidget(this->split_third);
|
|
|
|
this->split_second->addWidget(this->bottom_funcs->hostWidget());
|
2022-11-22 06:15:36 +00:00
|
|
|
|
2023-03-17 13:58:38 +00:00
|
|
|
this->split_third->addWidget(this->center_funcs->hostWidget());
|
|
|
|
this->split_third->addWidget(this->right_funcs->hostWidget());
|
2023-03-10 13:01:19 +00:00
|
|
|
|
2023-03-17 13:58:38 +00:00
|
|
|
connect(static_cast<PresentContainer *>(left_funcs), &PresentContainer::presentTransTo, this, &MainWindow::accept_view_transport);
|
|
|
|
connect(static_cast<PresentContainer *>(right_funcs), &PresentContainer::presentTransTo, this, &MainWindow::accept_view_transport);
|
|
|
|
connect(static_cast<PresentContainer *>(bottom_funcs), &PresentContainer::presentTransTo, this, &MainWindow::accept_view_transport);
|
|
|
|
connect(static_cast<PresentContainer *>(center_funcs), &PresentContainer::presentTransTo, this, &MainWindow::accept_view_transport);
|
2023-03-10 13:01:19 +00:00
|
|
|
}
|
|
|
|
|
2023-03-17 13:58:38 +00:00
|
|
|
MainWindow::~MainWindow() {}
|
|
|
|
|
|
|
|
void MainWindow::initial_menubar(QMenuBar *mbar) {
|
2023-03-10 13:01:19 +00:00
|
|
|
|
|
|
|
// 项目菜单树
|
|
|
|
auto project = mbar->addMenu("项目");
|
2023-03-17 13:58:38 +00:00
|
|
|
auto opnp = project->addAction("打开项目", [this]() {
|
2022-11-15 08:07:02 +00:00
|
|
|
auto file = QFileDialog::getOpenFileName(this, "打开项目", QString(), "小说项目(*.nsf)");
|
2023-03-17 13:58:38 +00:00
|
|
|
if (file == "")
|
2022-11-15 08:07:02 +00:00
|
|
|
return;
|
|
|
|
|
2023-03-17 13:58:38 +00:00
|
|
|
XApp::disp_core->postCommand(OpenProject(file));
|
|
|
|
build_internal(true);
|
|
|
|
});
|
2023-08-13 10:02:21 +00:00
|
|
|
sync_kernel->actionEnableSync(opnp, [this]() -> bool { return !project_manager->isOpenning(); });
|
2023-03-10 13:01:19 +00:00
|
|
|
|
2023-03-11 07:01:28 +00:00
|
|
|
auto newp = project->addAction("新建项目", [this]() {
|
2022-11-15 08:07:02 +00:00
|
|
|
auto name = QInputDialog::getText(this, "输入项目名称", "项目名称");
|
2023-03-17 13:58:38 +00:00
|
|
|
if (name == "")
|
2022-11-15 08:07:02 +00:00
|
|
|
return;
|
|
|
|
auto dir_path = QFileDialog::getExistingDirectory(this, "指定项目存储路径");
|
2023-03-17 13:58:38 +00:00
|
|
|
if (dir_path == "")
|
2022-11-15 08:07:02 +00:00
|
|
|
return;
|
|
|
|
|
2023-03-17 13:58:38 +00:00
|
|
|
XApp::disp_core->postCommand(NewProject(QDir(dir_path), name));
|
2023-03-11 07:01:28 +00:00
|
|
|
});
|
2023-08-13 10:02:21 +00:00
|
|
|
sync_kernel->actionEnableSync(newp, [this]() -> bool { return !project_manager->isOpenning(); });
|
2023-03-10 13:01:19 +00:00
|
|
|
|
2023-03-11 07:01:28 +00:00
|
|
|
auto clsp = project->addAction("关闭项目", [this]() {
|
2023-03-17 13:58:38 +00:00
|
|
|
XApp::disp_core->postCommand(CloseProject());
|
2023-03-11 07:01:28 +00:00
|
|
|
this->refresh_views();
|
|
|
|
});
|
2023-08-13 10:02:21 +00:00
|
|
|
sync_kernel->actionEnableSync(clsp, [this]() -> bool { return project_manager->isOpenning(); });
|
2022-11-11 14:38:52 +00:00
|
|
|
project->addSeparator();
|
2023-03-10 13:01:19 +00:00
|
|
|
|
2023-03-11 07:01:28 +00:00
|
|
|
auto pnew = project->addAction("新建路径", [this]() {
|
2023-03-10 13:01:19 +00:00
|
|
|
auto packages = QInputDialog::getText(this, "输入包路径名称/PackA/PackB/PackC", "包路径:");
|
2023-03-17 13:58:38 +00:00
|
|
|
if (packages != "")
|
|
|
|
XApp::disp_core->postCommand(NewPackage(packages));
|
2023-03-11 07:01:28 +00:00
|
|
|
});
|
2023-08-13 10:02:21 +00:00
|
|
|
sync_kernel->actionEnableSync(pnew, [this]() -> bool { return project_manager->isOpenning(); });
|
2023-03-10 13:01:19 +00:00
|
|
|
|
|
|
|
auto _xnew = project->addMenu("新建文件");
|
2023-08-13 10:02:21 +00:00
|
|
|
_xnew->setEnabled(project_manager->isOpenning());
|
2023-03-10 13:01:19 +00:00
|
|
|
auto types = docs_container->fileTypes();
|
2023-03-17 13:58:38 +00:00
|
|
|
for (auto &t : types) {
|
|
|
|
_xnew->addAction(t, [this, &t]() {
|
2023-03-10 13:01:19 +00:00
|
|
|
auto name = QInputDialog::getText(this, "输入名称", "名称:");
|
2023-03-17 13:58:38 +00:00
|
|
|
if (name == "")
|
2023-03-10 13:01:19 +00:00
|
|
|
return;
|
|
|
|
|
2023-03-17 13:58:38 +00:00
|
|
|
auto idx = project_present->currentIndex();
|
|
|
|
if (!idx.isValid())
|
2023-03-10 13:01:19 +00:00
|
|
|
idx = project_manager->model()->item(0)->index();
|
|
|
|
|
|
|
|
auto group_path = docs_container->converter(idx);
|
2023-03-17 13:58:38 +00:00
|
|
|
XApp::disp_core->postCommand(NewFile(group_path, name, t));
|
2023-03-10 13:01:19 +00:00
|
|
|
});
|
|
|
|
}
|
2023-08-13 10:02:21 +00:00
|
|
|
sync_kernel->widgetEnableSync(_xnew, [this]() -> bool { return project_manager->isOpenning(); });
|
2022-11-11 14:38:52 +00:00
|
|
|
project->addSeparator();
|
2023-03-10 13:01:19 +00:00
|
|
|
|
2023-03-17 13:58:38 +00:00
|
|
|
auto sav = project->addAction("保存全部", [this]() { XApp::disp_core->postCommand(SaveAll()); });
|
2023-03-10 13:01:19 +00:00
|
|
|
sav->setShortcut(QKeySequence::StandardKey::Save);
|
2023-08-13 10:02:21 +00:00
|
|
|
sync_kernel->actionEnableSync(sav, [this]() -> bool { return project_manager->isOpenning(); });
|
2023-03-10 13:01:19 +00:00
|
|
|
project->addSeparator();
|
|
|
|
|
2023-03-11 07:01:28 +00:00
|
|
|
project->addAction("退出", [this]() {
|
2023-03-17 13:58:38 +00:00
|
|
|
XApp::disp_core->postCommand(SaveAll());
|
2023-03-11 07:01:28 +00:00
|
|
|
QApplication::exit(0);
|
|
|
|
});
|
2022-11-11 14:38:52 +00:00
|
|
|
|
|
|
|
// 编辑菜单
|
|
|
|
auto edit = mbar->addMenu("编辑");
|
|
|
|
edit->addAction("撤销一步");
|
|
|
|
edit->addAction("重做一步");
|
|
|
|
edit->addSeparator();
|
|
|
|
edit->addAction("查找关键词");
|
|
|
|
edit->addAction("替换关键词");
|
|
|
|
|
|
|
|
// 视图菜单
|
|
|
|
auto view = mbar->addMenu("视图");
|
2022-11-15 08:07:02 +00:00
|
|
|
auto area = view->addMenu("区域管理");
|
2022-11-18 23:47:32 +00:00
|
|
|
|
2023-03-17 13:58:38 +00:00
|
|
|
auto xtool = new QToolBar(this);
|
|
|
|
xtool->setVisible(false);
|
|
|
|
addToolBar(Qt::ToolBarArea::TopToolBarArea, xtool);
|
2022-11-15 08:07:02 +00:00
|
|
|
auto act_tool = area->addAction("工具栏");
|
2023-03-17 13:58:38 +00:00
|
|
|
sync_kernel->actionCheckSync(act_tool, [xtool]() -> bool { return xtool->isVisible(); });
|
|
|
|
connect(act_tool, &QAction::triggered, [xtool](bool v) { xtool->setVisible(v); });
|
2022-11-22 03:42:48 +00:00
|
|
|
|
2023-03-17 13:58:38 +00:00
|
|
|
auto xstatus = statusBar();
|
|
|
|
xstatus->setVisible(false);
|
|
|
|
xstatus->addWidget(new QLabel("文本消息", this));
|
2022-11-15 08:07:02 +00:00
|
|
|
auto act_status = area->addAction("状态栏");
|
2023-03-17 13:58:38 +00:00
|
|
|
sync_kernel->actionCheckSync(act_status, [xstatus]() -> bool { return xstatus->isVisible(); });
|
|
|
|
connect(act_status, &QAction::triggered, [xstatus](bool v) { xstatus->setVisible(v); });
|
2022-11-22 03:42:48 +00:00
|
|
|
|
2022-11-15 08:07:02 +00:00
|
|
|
auto act_left = area->addAction("左侧功能区");
|
2023-03-17 13:58:38 +00:00
|
|
|
sync_kernel->actionCheckSync(act_left, [this]() -> bool { return this->left_funcs->visibleState(); });
|
|
|
|
connect(act_left, &QAction::triggered, [this](bool v) { this->left_funcs->setVisibleState(v); });
|
2022-11-22 03:42:48 +00:00
|
|
|
|
2022-11-15 08:07:02 +00:00
|
|
|
auto act_right = area->addAction("右侧功能区");
|
2023-03-17 13:58:38 +00:00
|
|
|
sync_kernel->actionCheckSync(act_right, [this]() -> bool { return this->right_funcs->visibleState(); });
|
|
|
|
connect(act_right, &QAction::triggered, [this](bool v) { this->right_funcs->setVisibleState(v); });
|
2022-11-22 03:42:48 +00:00
|
|
|
|
2022-11-15 08:07:02 +00:00
|
|
|
auto act_bottom = area->addAction("底部功能区");
|
2023-03-17 13:58:38 +00:00
|
|
|
sync_kernel->actionCheckSync(act_bottom, [this]() -> bool { return this->bottom_funcs->visibleState(); });
|
|
|
|
connect(act_bottom, &QAction::triggered, [this](bool v) { this->bottom_funcs->setVisibleState(v); });
|
2022-11-22 03:42:48 +00:00
|
|
|
|
2022-11-11 14:38:52 +00:00
|
|
|
view->addSeparator();
|
2022-11-15 08:07:02 +00:00
|
|
|
auto change = view->addMenu("内容切换");
|
2022-11-11 14:38:52 +00:00
|
|
|
change->addAction("序列视图");
|
|
|
|
change->addAction("编辑视图");
|
2022-11-15 08:07:02 +00:00
|
|
|
view->addSeparator();
|
2022-11-11 14:38:52 +00:00
|
|
|
auto func = view->addMenu("功能视图");
|
2023-08-13 10:02:21 +00:00
|
|
|
sync_kernel->widgetEnableSync(func, [this]() { return this->project_manager->isOpenning(); });
|
2023-03-17 13:58:38 +00:00
|
|
|
// 项目管理
|
|
|
|
{
|
|
|
|
auto project_v = func->addAction("项目管理", [this](bool v) { XApp::disp_core->postCommand(CompVisible(this, project_present, v)); });
|
|
|
|
sync_kernel->actionCheckSync(project_v, [this]() -> bool { return this->project_present->isVisible(); });
|
|
|
|
}
|
2022-11-11 14:38:52 +00:00
|
|
|
func->addAction("引用统计");
|
|
|
|
func->addAction("脉络分蘖");
|
2022-11-18 23:47:32 +00:00
|
|
|
// 编译信息
|
|
|
|
{
|
2023-03-17 13:58:38 +00:00
|
|
|
auto msgs = func->addAction("编译输出", [this](bool v) {
|
|
|
|
XApp::disp_core->postCommand(CompVisible(this, this->errors_present, true));
|
|
|
|
XApp::disp_core->postCommand(Build(false));
|
2022-11-18 23:47:32 +00:00
|
|
|
});
|
2023-08-15 14:14:00 +00:00
|
|
|
sync_kernel->actionCheckSync(msgs, [this]() -> bool { return bottom_funcs->contains(errors_present); });
|
2022-11-18 23:47:32 +00:00
|
|
|
}
|
|
|
|
// 脉络统计
|
|
|
|
{
|
2023-03-17 13:58:38 +00:00
|
|
|
auto chain_v = func->addAction("脉络统计", [this](bool v) { XApp::disp_core->postCommand(CompVisible(this, this->chains_view, v)); });
|
2022-11-18 23:47:32 +00:00
|
|
|
chain_v->setCheckable(true);
|
2023-08-15 14:14:00 +00:00
|
|
|
sync_kernel->registerTrigger([this]() -> bool { return right_funcs->contains(chains_view); },
|
2023-03-17 13:58:38 +00:00
|
|
|
[chain_v](bool v) {
|
|
|
|
if (v != chain_v->isChecked())
|
|
|
|
chain_v->setChecked(v);
|
|
|
|
});
|
2022-11-18 23:47:32 +00:00
|
|
|
}
|
|
|
|
// 单元统计
|
|
|
|
{
|
2023-03-17 13:58:38 +00:00
|
|
|
auto unit_v = func->addAction("单元统计", [this](bool v) { XApp::disp_core->postCommand(CompVisible(this, this->units_view, v)); });
|
2022-11-18 23:47:32 +00:00
|
|
|
unit_v->setCheckable(true);
|
2023-08-15 14:14:00 +00:00
|
|
|
sync_kernel->registerTrigger([this]() -> bool { return right_funcs->contains(units_view); },
|
2023-03-17 13:58:38 +00:00
|
|
|
[unit_v](bool v) {
|
|
|
|
if (v != unit_v->isChecked())
|
|
|
|
unit_v->setChecked(v);
|
|
|
|
});
|
2022-11-18 23:47:32 +00:00
|
|
|
}
|
2022-11-25 01:18:54 +00:00
|
|
|
// 故事统计
|
|
|
|
{
|
2023-03-17 13:58:38 +00:00
|
|
|
auto board_v = func->addAction("故事统计", [this](bool v) { XApp::disp_core->postCommand(CompVisible(this, boards_view, v)); });
|
2022-11-25 01:18:54 +00:00
|
|
|
board_v->setCheckable(true);
|
2023-08-15 14:14:00 +00:00
|
|
|
sync_kernel->registerTrigger([this]() -> bool { return right_funcs->contains(boards_view); },
|
2023-03-17 13:58:38 +00:00
|
|
|
[board_v](bool v) {
|
|
|
|
if (v != board_v->isChecked())
|
|
|
|
board_v->setChecked(v);
|
|
|
|
});
|
2022-11-25 01:18:54 +00:00
|
|
|
}
|
|
|
|
// 概念统计
|
|
|
|
{
|
2023-03-17 13:58:38 +00:00
|
|
|
auto concept_v = func->addAction("概念统计", [this](bool v) { XApp::disp_core->postCommand(CompVisible(this, concept_view, v)); });
|
2022-11-25 01:18:54 +00:00
|
|
|
concept_v->setCheckable(true);
|
2023-08-15 14:14:00 +00:00
|
|
|
sync_kernel->registerTrigger([this]() -> bool { return right_funcs->contains(concept_view); },
|
2023-03-17 13:58:38 +00:00
|
|
|
[concept_v](bool v) {
|
|
|
|
if (v != concept_v->isChecked())
|
|
|
|
concept_v->setChecked(v);
|
|
|
|
});
|
2022-11-25 01:18:54 +00:00
|
|
|
}
|
2022-12-08 19:43:42 +00:00
|
|
|
// 情节序列
|
|
|
|
{
|
2023-03-17 13:58:38 +00:00
|
|
|
auto fragments_v = func->addAction("情节序列", [this](bool v) { XApp::disp_core->postCommand(CompVisible(this, fragments_order, v)); });
|
2022-12-08 19:43:42 +00:00
|
|
|
fragments_v->setCheckable(true);
|
2023-08-15 14:14:00 +00:00
|
|
|
sync_kernel->registerTrigger([this]() -> bool { return right_funcs->contains(fragments_order); },
|
2023-03-17 13:58:38 +00:00
|
|
|
[fragments_v](bool v) {
|
|
|
|
if (v != fragments_v->isChecked())
|
|
|
|
fragments_v->setChecked(v);
|
|
|
|
});
|
2022-12-08 19:43:42 +00:00
|
|
|
}
|
2022-11-11 14:38:52 +00:00
|
|
|
|
|
|
|
// 工具菜单
|
|
|
|
auto tool = mbar->addMenu("工具");
|
|
|
|
auto word = tool->addMenu("敏感词检测");
|
|
|
|
word->addAction("工具配置");
|
|
|
|
word->addAction("敏感词编辑");
|
|
|
|
auto vcs = tool->addMenu("版本管理");
|
|
|
|
vcs->addAction("工具配置");
|
|
|
|
vcs->addAction("启用");
|
|
|
|
auto exp = tool->addMenu("导入导出");
|
2022-11-18 23:47:32 +00:00
|
|
|
exp->addAction("导入WsOutlines");
|
2022-11-11 14:38:52 +00:00
|
|
|
exp->addSeparator();
|
2022-11-15 08:07:02 +00:00
|
|
|
exp->addAction("导出TXT大纲");
|
2022-11-18 23:47:32 +00:00
|
|
|
exp->addAction("导出Web大纲");
|
|
|
|
exp->addAction("导出WsOutlines");
|
|
|
|
exp->addSeparator();
|
|
|
|
exp->addAction("导出TXT内容");
|
2023-03-17 13:58:38 +00:00
|
|
|
auto build = tool->addAction("编译", [this]() { this->build_internal(); });
|
2023-08-13 10:02:21 +00:00
|
|
|
sync_kernel->actionEnableSync(build, [this]() -> bool { return project_manager->isOpenning(); });
|
2022-11-11 14:38:52 +00:00
|
|
|
|
|
|
|
// 窗口菜单
|
|
|
|
auto window = mbar->addMenu("窗口");
|
|
|
|
window->addAction("新建窗口");
|
|
|
|
window->addAction("关闭窗口");
|
|
|
|
window->addSeparator();
|
|
|
|
window->addAction("布局管理");
|
|
|
|
window->addMenu("布局切换");
|
|
|
|
window->addMenu("窗口切换");
|
|
|
|
|
|
|
|
// 系统
|
|
|
|
auto sys = mbar->addMenu("系统");
|
|
|
|
sys->addAction("软件激活");
|
|
|
|
sys->addAction("系统信息");
|
|
|
|
sys->addSeparator();
|
|
|
|
sys->addAction("关于……");
|
2022-11-06 00:37:50 +00:00
|
|
|
}
|
2022-11-15 12:58:12 +00:00
|
|
|
|
2023-03-17 13:58:38 +00:00
|
|
|
void MainWindow::initial_commandlist(Schedule::CommandsDispatcher *host) {
|
|
|
|
host->registerCommand(new Build(true));
|
|
|
|
host->registerCommand(new CloseProject());
|
|
|
|
|
|
|
|
host->registerCommand(new CompVisible(this, welcome_list, true));
|
|
|
|
host->registerCommand(new CompVisible(this, errors_present, true));
|
|
|
|
host->registerCommand(new CompVisible(this, project_present, true));
|
|
|
|
host->registerCommand(new CompVisible(this, fragments_order, true));
|
|
|
|
host->registerCommand(new CompVisible(this, boards_view, true));
|
|
|
|
host->registerCommand(new CompVisible(this, chains_view, true));
|
|
|
|
host->registerCommand(new CompVisible(this, concept_view, true));
|
|
|
|
host->registerCommand(new CompVisible(this, units_view, true));
|
|
|
|
|
|
|
|
host->registerCommand(new NewFile(Route(), "", ""));
|
|
|
|
host->registerCommand(new NewPackage(""));
|
|
|
|
host->registerCommand(new NewProject(QDir(), ""));
|
|
|
|
host->registerCommand(new OpenFile(Route()));
|
|
|
|
host->registerCommand(new OpenProject(""));
|
|
|
|
host->registerCommand(new SaveAll());
|
|
|
|
host->registerCommand(new StoryboardDetailShow(QList<QString>()));
|
|
|
|
host->registerCommand(new StoryboardJumpTo(QList<QString>()));
|
|
|
|
host->registerCommand(new StorychainDetailShow(QList<QString>()));
|
|
|
|
host->registerCommand(new StorychainJumpTo(QList<QString>()));
|
|
|
|
host->registerCommand(new StoryconceptDetailShow(QList<QString>()));
|
|
|
|
host->registerCommand(new StoryconceptJumpTo(QList<QString>()));
|
|
|
|
host->registerCommand(new StoryunitDetailShow(QList<QString>()));
|
|
|
|
host->registerCommand(new StoryunitJumpTo(QList<QString>()));
|
2023-01-01 05:10:31 +00:00
|
|
|
}
|
|
|
|
|
2023-03-17 13:58:38 +00:00
|
|
|
void MainWindow::refresh_views() {
|
2023-01-01 05:10:31 +00:00
|
|
|
errors_present->refresh();
|
2023-03-17 13:58:38 +00:00
|
|
|
chains_model->refreshTree();
|
|
|
|
units_model->refreshTree();
|
|
|
|
boards_model->refresh();
|
|
|
|
concepts_model->refreshTree();
|
|
|
|
fragments_model->refreshTable();
|
2023-01-01 05:10:31 +00:00
|
|
|
}
|
|
|
|
|
2023-03-17 13:58:38 +00:00
|
|
|
void MainWindow::build_internal(bool all_from_disk) {
|
|
|
|
XApp::disp_core->postCommand(Build(all_from_disk));
|
2023-01-01 05:10:31 +00:00
|
|
|
refresh_views();
|
2022-11-18 23:47:32 +00:00
|
|
|
}
|
|
|
|
|
2023-03-17 13:58:38 +00:00
|
|
|
void MainWindow::splitter_layout_save(const QList<QString> &path_type, const QList<int> &size) {
|
|
|
|
auto convert = [](QList<int> sizes) -> QStringList {
|
2022-11-22 03:42:48 +00:00
|
|
|
QStringList size_strs;
|
2023-03-17 13:58:38 +00:00
|
|
|
for (auto i : sizes)
|
2022-11-22 03:42:48 +00:00
|
|
|
size_strs << QString("%1").arg(i);
|
|
|
|
return size_strs;
|
|
|
|
};
|
|
|
|
app_core->globalConfig()->setList(path_type, convert(size));
|
|
|
|
}
|
|
|
|
|
2023-03-17 13:58:38 +00:00
|
|
|
#define LEFT_SIDE "left"
|
|
|
|
#define RIGHT_SIDE "right"
|
|
|
|
#define BOTTOM_SIDE "bottom"
|
|
|
|
#define CENTER_SIDE "center"
|
2023-08-15 14:40:40 +00:00
|
|
|
void MainWindow::append(PresentBase *ins) {
|
2023-03-17 13:58:38 +00:00
|
|
|
auto cfg = project_manager->configraions();
|
|
|
|
auto pos_query = QList<QString>() << "unique-record"
|
|
|
|
<< "split-area"
|
|
|
|
<< "index-hash"
|
|
|
|
<< "store-point";
|
|
|
|
|
|
|
|
auto hash_pos = cfg->getMap(pos_query);
|
|
|
|
auto unique_key = unique.links().join("/");
|
|
|
|
auto pos = hash_pos[unique_key];
|
|
|
|
|
|
|
|
if (pos == "") {
|
|
|
|
pos = CENTER_SIDE;
|
|
|
|
hash_pos[unique_key] = pos;
|
|
|
|
cfg->setMap(pos_query, hash_pos);
|
|
|
|
}
|
2022-11-22 03:42:48 +00:00
|
|
|
|
2023-03-17 13:58:38 +00:00
|
|
|
if (pos == LEFT_SIDE) {
|
|
|
|
left_funcs->append(ins, unique);
|
|
|
|
} else if (pos == RIGHT_SIDE) {
|
|
|
|
right_funcs->append(ins, unique);
|
|
|
|
} else if (pos == BOTTOM_SIDE) {
|
|
|
|
bottom_funcs->append(ins, unique);
|
|
|
|
} else if (pos == CENTER_SIDE) {
|
|
|
|
center_funcs->append(ins, unique);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void MainWindow::accept_view_transport(const Core::Route &key, Components::GroupType type) {
|
|
|
|
auto cfg = project_manager->configraions();
|
|
|
|
auto pos_query = QList<QString>() << "unique-record"
|
|
|
|
<< "split-area"
|
|
|
|
<< "index-hash"
|
|
|
|
<< "store-point";
|
|
|
|
|
|
|
|
auto hash_pos = cfg->getMap(pos_query);
|
|
|
|
auto unique_key = key.links().join("/");
|
|
|
|
|
|
|
|
if (type == GroupType::LEFT)
|
|
|
|
hash_pos[unique_key] = LEFT_SIDE;
|
|
|
|
else if (type == GroupType::RIGHT)
|
|
|
|
hash_pos[unique_key] = RIGHT_SIDE;
|
|
|
|
else if (type == GroupType::BOTTOM)
|
|
|
|
hash_pos[unique_key] = BOTTOM_SIDE;
|
|
|
|
else
|
|
|
|
hash_pos[unique_key] = CENTER_SIDE;
|
|
|
|
cfg->setMap(pos_query, hash_pos);
|
|
|
|
|
|
|
|
auto xins = remove(key);
|
|
|
|
append(xins, key);
|
|
|
|
}
|
|
|
|
|
2023-08-15 14:40:40 +00:00
|
|
|
bool MainWindow::active(const PresentBase *ins) {
|
2023-03-17 13:58:38 +00:00
|
|
|
PresentHost *array[4] = {left_funcs, right_funcs, bottom_funcs, center_funcs};
|
|
|
|
for (auto &it : array)
|
2023-08-15 14:40:40 +00:00
|
|
|
it->active(ins);
|
2023-03-17 13:58:38 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2022-11-22 03:42:48 +00:00
|
|
|
|
2023-08-15 14:40:40 +00:00
|
|
|
void MainWindow::remove(const PresentBase *ins) {
|
2023-03-17 13:58:38 +00:00
|
|
|
PresentHost *array[4] = {left_funcs, right_funcs, bottom_funcs, center_funcs};
|
|
|
|
for (auto &it : array) {
|
|
|
|
auto ins = it->remove(unique);
|
|
|
|
if (ins)
|
|
|
|
return ins;
|
|
|
|
}
|
2022-11-22 03:42:48 +00:00
|
|
|
}
|
|
|
|
|
2023-08-15 14:40:40 +00:00
|
|
|
bool MainWindow::contains(const PresentBase *ins) const { return false; }
|
2022-11-22 03:42:48 +00:00
|
|
|
|
2023-03-17 13:58:38 +00:00
|
|
|
QWidget *MainWindow::hostWidget() const { return (QWidget *)this; }
|
2022-11-22 03:42:48 +00:00
|
|
|
|
2023-03-17 13:58:38 +00:00
|
|
|
void MainWindow::closeEvent(QCloseEvent *event) {
|
2022-11-17 08:16:54 +00:00
|
|
|
// 关闭事件
|
2023-08-13 10:02:21 +00:00
|
|
|
if (project_manager->isOpenning()) {
|
2023-03-17 13:58:38 +00:00
|
|
|
XApp::disp_core->postCommand(CloseProject());
|
2022-11-17 08:16:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QMainWindow::closeEvent(event);
|
2022-11-15 12:58:12 +00:00
|
|
|
}
|
2022-11-18 23:47:32 +00:00
|
|
|
|
2023-03-17 13:58:38 +00:00
|
|
|
bool MainWindow::eventFilter(QObject *watched, QEvent *event) {
|
2022-11-18 23:47:32 +00:00
|
|
|
auto ev = event->type();
|
2023-03-17 13:58:38 +00:00
|
|
|
switch (ev) {
|
|
|
|
case QEvent::Type::MouseButtonPress:
|
|
|
|
case QEvent::Type::MouseButtonRelease:
|
|
|
|
case QEvent::Type::Wheel:
|
|
|
|
case QEvent::Type::MouseMove:
|
|
|
|
case QEvent::Type::KeyPress:
|
|
|
|
case QEvent::Type::KeyRelease:
|
|
|
|
sync_kernel->sync();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2022-11-18 23:47:32 +00:00
|
|
|
}
|
|
|
|
return QMainWindow::eventFilter(watched, event);
|
|
|
|
}
|