2023-02-26 16:22:44 +00:00
|
|
|
#include "default_textpresent.h"
|
2022-11-06 00:37:50 +00:00
|
|
|
#include "mainwindow.h"
|
2022-11-22 03:42:48 +00:00
|
|
|
#include "storyboardsourceedit.h"
|
2023-02-26 16:22:44 +00:00
|
|
|
#include "storychain_sourceeditor.h"
|
2022-11-22 03:42:48 +00:00
|
|
|
#include "storyunitsourceedit.h"
|
|
|
|
#include "storyvolumesourceedit.h"
|
2022-11-06 00:37:50 +00:00
|
|
|
|
2022-11-11 14:38:52 +00:00
|
|
|
#include <QLabel>
|
|
|
|
#include <QMenuBar>
|
|
|
|
#include <QStatusBar>
|
|
|
|
#include <QDebug>
|
|
|
|
#include <QDateTime>
|
|
|
|
#include <QTextEdit>
|
2022-11-15 08:07:02 +00:00
|
|
|
#include <QToolBar>
|
2022-11-18 23:47:32 +00:00
|
|
|
#include <xmlconfig.h>
|
2022-11-15 08:07:02 +00:00
|
|
|
#include <xmlprojectmanager.h>
|
|
|
|
#include <QFileDialog>
|
|
|
|
#include <QInputDialog>
|
2022-11-17 08:16:54 +00:00
|
|
|
#include <QApplication>
|
|
|
|
#include <QMessageBox>
|
2022-11-22 03:42:48 +00:00
|
|
|
#include <QList>
|
|
|
|
#include <QVBoxLayout>
|
2022-11-15 08:07:02 +00:00
|
|
|
|
|
|
|
using namespace Project;
|
2022-11-17 08:16:54 +00:00
|
|
|
using namespace MakeTools;
|
2022-11-15 12:58:12 +00:00
|
|
|
using namespace Parse::Result;
|
2022-11-17 08:16:54 +00:00
|
|
|
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;
|
2022-11-11 14:38:52 +00:00
|
|
|
|
2022-11-06 00:37:50 +00:00
|
|
|
MainWindow::MainWindow(QWidget *parent)
|
2022-11-15 08:07:02 +00:00
|
|
|
: QMainWindow(parent),
|
2022-11-22 03:42:48 +00:00
|
|
|
app_core(new AppCore(this)),
|
2022-11-18 23:47:32 +00:00
|
|
|
sync_kernel(new StatusSyncCore(this)),
|
2022-11-15 08:07:02 +00:00
|
|
|
horizontal_split(new QSplitter(Qt::Horizontal, this)),
|
|
|
|
vertical_split(new QSplitter(Qt::Vertical, this)),
|
|
|
|
left_funcs(new QTabWidget(this)),
|
|
|
|
right_funcs(new QTabWidget(this)),
|
|
|
|
center_funcs(new QTabWidget(this)),
|
|
|
|
bottom_funcs(new QTabWidget(this)),
|
2022-11-15 12:58:12 +00:00
|
|
|
project_manager(new XMLProjectManager(this)),
|
2022-11-22 03:42:48 +00:00
|
|
|
current_projects(new QListView(this)),
|
2023-02-26 14:44:00 +00:00
|
|
|
project_structure(new VisiableProjectController(app_core, project_manager, this)),
|
2022-11-22 03:42:48 +00:00
|
|
|
chains_view(new StoryChainsPresent(app_core, this)),
|
2022-11-22 06:15:36 +00:00
|
|
|
units_view(new StoryUnitsPresent(app_core, this)),
|
2022-12-31 13:05:58 +00:00
|
|
|
errors_present(new MessagePresent(app_core->getMakeCore(), this)),
|
2022-11-25 01:18:54 +00:00
|
|
|
boards_view(new StoryBoardsPresent(app_core, this)),
|
2022-12-08 19:43:42 +00:00
|
|
|
concept_view(new StoryConceptsPresent(app_core, this)),
|
|
|
|
fragments_order(new FragmentsOrderView(app_core, this))
|
2022-11-06 00:37:50 +00:00
|
|
|
{
|
2022-11-18 23:47:32 +00:00
|
|
|
QApplication::instance()->installEventFilter(this);
|
2022-11-22 03:42:48 +00:00
|
|
|
this->app_core->setCurrentProject(project_manager);
|
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
|
|
|
|
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-18 23:47:32 +00:00
|
|
|
project_structure->setVisible(false);
|
|
|
|
left_funcs->setVisible(false);
|
|
|
|
right_funcs->setVisible(false);
|
|
|
|
bottom_funcs->setVisible(false);
|
2022-11-15 08:07:02 +00:00
|
|
|
auto xtool = new QToolBar(this);
|
2022-11-18 23:47:32 +00:00
|
|
|
xtool->setVisible(false);
|
2022-11-15 08:07:02 +00:00
|
|
|
addToolBar(Qt::ToolBarArea::TopToolBarArea, xtool);
|
|
|
|
auto xstatus = statusBar();
|
2022-11-18 23:47:32 +00:00
|
|
|
xstatus->setVisible(false);
|
2022-11-15 08:07:02 +00:00
|
|
|
statusBar()->addWidget(new QLabel("文本消息", this));
|
|
|
|
|
2022-11-11 14:38:52 +00:00
|
|
|
auto mbar = menuBar();
|
|
|
|
// 项目菜单树
|
|
|
|
auto project = mbar->addMenu("项目");
|
2022-11-22 06:15:36 +00:00
|
|
|
auto pnew = project->addAction("新建路径", [this](){
|
2022-11-17 08:16:54 +00:00
|
|
|
auto packages = QInputDialog::getText(this, "输入包路径名称", "packagea#packageb#packagec");
|
|
|
|
if(packages == "")
|
|
|
|
return;
|
|
|
|
|
|
|
|
QList<QString> names;
|
|
|
|
QRegExp exp("([^#]+)");
|
|
|
|
auto idx=0;
|
|
|
|
while ((idx = exp.indexIn(packages, idx)) != -1) {
|
|
|
|
names << exp.capturedTexts()[1];
|
|
|
|
idx += names.last().length();
|
|
|
|
}
|
|
|
|
|
2023-02-26 14:44:00 +00:00
|
|
|
project_manager->newPackage(names);
|
2022-11-17 08:16:54 +00:00
|
|
|
});
|
2022-11-22 06:15:36 +00:00
|
|
|
sync_kernel->registerActionSync(pnew, [this]()->bool{return project_manager->isOpen();});
|
|
|
|
|
2022-11-17 08:16:54 +00:00
|
|
|
auto _xnew = project->addMenu("最后卷新建文件");
|
2022-11-22 03:42:48 +00:00
|
|
|
_xnew->addAction("小说章节");
|
|
|
|
_xnew->addSeparator();
|
2022-11-15 08:07:02 +00:00
|
|
|
_xnew->addAction("发展脉络");
|
2022-11-11 14:38:52 +00:00
|
|
|
_xnew->addAction("故事单元");
|
2022-11-15 08:07:02 +00:00
|
|
|
_xnew->addAction("故事大纲");
|
|
|
|
_xnew->addAction("叙事大纲");
|
2022-11-22 06:15:36 +00:00
|
|
|
sync_kernel->registerWidgetSync(_xnew, [this]()->bool{return project_manager->isOpen();});
|
|
|
|
|
2022-11-11 14:38:52 +00:00
|
|
|
project->addSeparator();
|
2022-11-15 08:07:02 +00:00
|
|
|
auto sav = project->addAction("保存");
|
2022-11-22 03:42:48 +00:00
|
|
|
sav->setShortcut(QKeySequence::StandardKey::Save);
|
2022-11-18 23:47:32 +00:00
|
|
|
sync_kernel->registerActionSync(sav, [this]()->bool{return project_manager->isOpen();});
|
2022-11-15 08:07:02 +00:00
|
|
|
connect(sav, &QAction::triggered, [this](){
|
|
|
|
this->project_manager->save();
|
2022-12-31 13:05:58 +00:00
|
|
|
app_core->getDocsManager()->saveAll();
|
2022-11-15 08:07:02 +00:00
|
|
|
});
|
|
|
|
project->addSeparator();
|
|
|
|
auto opnp = project->addAction("打开项目");
|
2022-11-18 23:47:32 +00:00
|
|
|
sync_kernel->registerActionSync(opnp, [this]()->bool{return !project_manager->isOpen();});
|
|
|
|
connect(opnp, &QAction::triggered, [this](){
|
2022-11-15 08:07:02 +00:00
|
|
|
auto file = QFileDialog::getOpenFileName(this, "打开项目", QString(), "小说项目(*.nsf)");
|
|
|
|
if(file == "")
|
|
|
|
return;
|
|
|
|
|
|
|
|
project_manager->openProject(file);
|
2022-11-17 08:16:54 +00:00
|
|
|
build_internal(true);
|
2022-11-15 08:07:02 +00:00
|
|
|
});
|
|
|
|
auto newp = project->addAction("新建项目");
|
2022-11-18 23:47:32 +00:00
|
|
|
sync_kernel->registerActionSync(newp, [this]()->bool{return !project_manager->isOpen();});
|
|
|
|
connect(newp, &QAction::triggered, [this](){
|
2022-11-15 08:07:02 +00:00
|
|
|
auto name = QInputDialog::getText(this, "输入项目名称", "项目名称");
|
|
|
|
if(name == "")
|
|
|
|
return;
|
|
|
|
auto dir_path = QFileDialog::getExistingDirectory(this, "指定项目存储路径");
|
|
|
|
if(dir_path == "")
|
|
|
|
return;
|
|
|
|
|
|
|
|
this->project_manager->newProject(dir_path, name);
|
|
|
|
});
|
|
|
|
auto clsp = project->addAction("关闭项目");
|
2022-11-18 23:47:32 +00:00
|
|
|
sync_kernel->registerActionSync(clsp, [this]()->bool{return project_manager->isOpen();});
|
|
|
|
connect(clsp, &QAction::triggered, [this](){
|
2022-11-15 08:07:02 +00:00
|
|
|
this->project_manager->closeProject();
|
2023-01-01 05:10:31 +00:00
|
|
|
this->app_core->getDocsManager()->closeAll();
|
|
|
|
this->refresh_views();
|
2022-11-15 08:07:02 +00:00
|
|
|
});
|
2022-11-11 14:38:52 +00:00
|
|
|
project->addSeparator();
|
2022-11-22 03:42:48 +00:00
|
|
|
auto pcfg = project->addAction("项目配置");
|
|
|
|
connect(pcfg, &QAction::triggered, [this](){
|
|
|
|
QDialog x(this);
|
|
|
|
auto layout = new QVBoxLayout(&x);
|
|
|
|
|
|
|
|
auto widget = new QTabWidget(&x);
|
|
|
|
widget->setTabPosition(QTabWidget::West);
|
|
|
|
layout->addWidget(widget);
|
|
|
|
|
2023-02-26 14:44:00 +00:00
|
|
|
// auto exts = app_core->extensions();
|
|
|
|
// for(auto &es : exts){
|
|
|
|
// auto cp = es->getNewPanel(app_core->currentProject()->configraions());
|
|
|
|
// if(cp)
|
|
|
|
// widget->addTab(cp, es->extensionName());
|
|
|
|
// }
|
2022-11-22 03:42:48 +00:00
|
|
|
x.exec();
|
|
|
|
});
|
|
|
|
sync_kernel->registerActionSync(pcfg, [this]()->bool{ return app_core->currentProject()->isOpen();});
|
|
|
|
auto scfg = project->addAction("软件配置");
|
|
|
|
connect(scfg, &QAction::triggered, [this](){
|
|
|
|
QDialog x(this);
|
|
|
|
auto layout = new QVBoxLayout(&x);
|
|
|
|
|
|
|
|
auto widget = new QTabWidget(&x);
|
|
|
|
widget->setTabPosition(QTabWidget::West);
|
|
|
|
layout->addWidget(widget);
|
|
|
|
|
|
|
|
auto exts = app_core->extensions();
|
2023-02-26 14:44:00 +00:00
|
|
|
// for(auto &es : exts){
|
|
|
|
// auto cp = es->getNewPanel(app_core->globalConfig());
|
|
|
|
// if(cp)
|
|
|
|
// widget->addTab(cp, es->extensionName());
|
|
|
|
// }
|
2022-11-22 03:42:48 +00:00
|
|
|
x.exec();
|
|
|
|
});
|
2022-11-11 14:38:52 +00:00
|
|
|
project->addSeparator();
|
2022-11-17 08:16:54 +00:00
|
|
|
project->addAction("退出", [](){ 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
|
|
|
|
2022-11-15 08:07:02 +00:00
|
|
|
auto act_tool = area->addAction("工具栏");
|
|
|
|
act_tool->setCheckable(true);
|
|
|
|
connect(act_tool, &QAction::triggered, [xtool](bool v){ xtool->setVisible(v); });
|
2022-11-22 03:42:48 +00:00
|
|
|
sync_kernel->registerAutoRun([xtool]()->bool{return xtool->isVisible();},
|
|
|
|
[act_tool](bool v){ if(v != act_tool->isChecked()) act_tool->setChecked(v); });
|
|
|
|
|
2022-11-15 08:07:02 +00:00
|
|
|
auto act_status = area->addAction("状态栏");
|
|
|
|
act_status->setCheckable(true);
|
|
|
|
connect(act_status,&QAction::triggered, [xstatus](bool v){xstatus->setVisible(v);});
|
2022-11-22 03:42:48 +00:00
|
|
|
sync_kernel->registerAutoRun([xstatus]()->bool{return xstatus->isVisible();},
|
|
|
|
[act_status](bool v){ if(v != act_status->isChecked()) act_status->setChecked(v); });
|
|
|
|
|
2022-11-15 08:07:02 +00:00
|
|
|
auto act_left = area->addAction("左侧功能区");
|
|
|
|
act_left->setCheckable(true);
|
|
|
|
connect(act_left, &QAction::triggered, [this](bool v){this->left_funcs->setVisible(v);});
|
2022-11-22 03:42:48 +00:00
|
|
|
sync_kernel->registerAutoRun([this]()->bool{return this->left_funcs->isVisible();},
|
|
|
|
[act_left](bool v){ if(v!= act_left->isChecked()) act_left->setChecked(v); });
|
|
|
|
|
2022-11-15 08:07:02 +00:00
|
|
|
auto act_right = area->addAction("右侧功能区");
|
|
|
|
act_right->setCheckable(true);
|
|
|
|
connect(act_right, &QAction::triggered, [this](bool v){this->right_funcs->setVisible(v);});
|
2022-11-22 03:42:48 +00:00
|
|
|
sync_kernel->registerAutoRun([this]()->bool{return this->right_funcs->isVisible();},
|
|
|
|
[act_right](bool v){if(v != act_right->isChecked()) act_right->setChecked(v);});
|
|
|
|
|
2022-11-15 08:07:02 +00:00
|
|
|
auto act_bottom = area->addAction("底部功能区");
|
|
|
|
act_bottom->setCheckable(true);
|
|
|
|
connect(act_bottom, &QAction::triggered, [this](bool v){this->bottom_funcs->setVisible(v);});
|
2022-11-22 03:42:48 +00:00
|
|
|
sync_kernel->registerAutoRun([this]()->bool{return this->bottom_funcs->isVisible();},
|
|
|
|
[act_bottom](bool v){ if(v!= act_bottom->isChecked()) act_bottom->setChecked(v);});
|
|
|
|
|
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("功能视图");
|
2022-11-18 23:47:32 +00:00
|
|
|
// 项目管理
|
|
|
|
{
|
|
|
|
auto project_v = func->addAction("项目管理", [this](bool v){
|
|
|
|
toggle_widget_visible(v, left_funcs, project_structure, "项目管理");
|
|
|
|
});
|
|
|
|
project_v->setCheckable(true);
|
|
|
|
sync_kernel->registerAutoRun([this]()->bool{return this->project_structure->isVisible();},
|
|
|
|
[project_v](bool v){ if(v != project_v->isChecked()) project_v->setChecked(v); });
|
|
|
|
}
|
2022-11-11 14:38:52 +00:00
|
|
|
func->addAction("引用统计");
|
|
|
|
func->addAction("脉络分蘖");
|
2022-11-18 23:47:32 +00:00
|
|
|
// 编译信息
|
|
|
|
{
|
2022-11-22 03:42:48 +00:00
|
|
|
auto msgs = func->addAction("编译输出", [this](bool v){
|
|
|
|
toggle_widget_visible(v, bottom_funcs, errors_present, "编译输出");
|
2022-11-18 23:47:32 +00:00
|
|
|
});
|
|
|
|
msgs->setCheckable(true);
|
2022-11-22 03:42:48 +00:00
|
|
|
sync_kernel->registerAutoRun([this]()->bool{return bottom_funcs->indexOf(errors_present) != -1;},
|
2022-11-18 23:47:32 +00:00
|
|
|
[msgs](bool v){if(v!=msgs->isChecked()) msgs->setChecked(v);});
|
|
|
|
}
|
|
|
|
// 脉络统计
|
|
|
|
{
|
|
|
|
auto chain_v = func->addAction("脉络统计", [this](bool v){
|
|
|
|
toggle_widget_visible(v, right_funcs, chains_view, "脉络统计");
|
|
|
|
});
|
|
|
|
chain_v->setCheckable(true);
|
2022-11-22 03:42:48 +00:00
|
|
|
sync_kernel->registerAutoRun([this]()->bool{return right_funcs->indexOf(chains_view) != -1;},
|
2022-11-18 23:47:32 +00:00
|
|
|
[chain_v](bool v){ if(v != chain_v->isChecked()) chain_v->setChecked(v);});
|
|
|
|
}
|
|
|
|
// 单元统计
|
|
|
|
{
|
|
|
|
auto unit_v = func->addAction("单元统计", [this](bool v){
|
|
|
|
toggle_widget_visible(v, right_funcs, units_view, "单元统计");
|
|
|
|
});
|
|
|
|
unit_v->setCheckable(true);
|
2022-11-22 03:42:48 +00:00
|
|
|
sync_kernel->registerAutoRun([this]()->bool{return right_funcs->indexOf(units_view)!=-1;},
|
2022-11-18 23:47:32 +00:00
|
|
|
[unit_v](bool v){if(v != unit_v->isChecked()) unit_v->setChecked(v);});
|
|
|
|
}
|
2022-11-25 01:18:54 +00:00
|
|
|
// 故事统计
|
|
|
|
{
|
|
|
|
auto board_v = func->addAction("故事统计", [this](bool v){
|
|
|
|
toggle_widget_visible(v, right_funcs, boards_view, "故事统计");
|
|
|
|
});
|
|
|
|
board_v->setCheckable(true);
|
|
|
|
sync_kernel->registerAutoRun([this]()->bool{return right_funcs->indexOf(boards_view)!=-1;},
|
|
|
|
[board_v](bool v){if(v!=board_v->isChecked()) board_v->setChecked(v);});
|
|
|
|
}
|
|
|
|
// 概念统计
|
|
|
|
{
|
|
|
|
auto concept_v = func->addAction("概念统计", [this](bool v){
|
|
|
|
toggle_widget_visible(v, right_funcs, concept_view, "概念统计");
|
|
|
|
});
|
|
|
|
concept_v->setCheckable(true);
|
|
|
|
sync_kernel->registerAutoRun([this]()->bool{return right_funcs->indexOf(concept_view)!=-1;},
|
|
|
|
[concept_v](bool v){if(v != concept_v->isChecked()) concept_v->setChecked(v);});
|
|
|
|
}
|
2022-12-08 19:43:42 +00:00
|
|
|
// 情节序列
|
|
|
|
{
|
|
|
|
auto fragments_v = func->addAction("情节序列", [this](bool v){
|
|
|
|
toggle_widget_visible(v, right_funcs, fragments_order, "情节序列");
|
|
|
|
});
|
|
|
|
fragments_v->setCheckable(true);
|
|
|
|
sync_kernel->registerAutoRun([this]()->bool{return right_funcs->indexOf(fragments_order)!=-1;},
|
|
|
|
[fragments_v](bool v){if(v != fragments_v->isChecked()) fragments_v->setChecked(v);});
|
|
|
|
}
|
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内容");
|
2022-11-22 03:42:48 +00:00
|
|
|
auto build = tool->addAction("编译", [this](){
|
2022-11-15 12:58:12 +00:00
|
|
|
this->build_internal();
|
|
|
|
});
|
2022-12-31 13:05:58 +00:00
|
|
|
sync_kernel->registerActionSync(build, [this]()->bool{ return project_manager->isOpen(); });
|
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-22 06:15:36 +00:00
|
|
|
setCentralWidget(this->vertical_split);
|
|
|
|
this->vertical_split->addWidget(this->horizontal_split);
|
|
|
|
this->vertical_split->addWidget(bottom_funcs);
|
2022-11-11 14:38:52 +00:00
|
|
|
|
2022-11-15 08:07:02 +00:00
|
|
|
this->horizontal_split->addWidget(left_funcs);
|
2022-11-22 06:15:36 +00:00
|
|
|
this->horizontal_split->addWidget(center_funcs);
|
2022-11-15 08:07:02 +00:00
|
|
|
this->horizontal_split->addWidget(right_funcs);
|
2022-11-22 06:15:36 +00:00
|
|
|
|
2022-11-18 23:47:32 +00:00
|
|
|
left_funcs->setTabsClosable(true);
|
|
|
|
connect(left_funcs, &QTabWidget::tabCloseRequested,
|
|
|
|
[this](int index){ toggle_widget_visible(false, left_funcs, left_funcs->widget(index)); });
|
|
|
|
bottom_funcs->setTabsClosable(true);
|
|
|
|
connect(bottom_funcs, &QTabWidget::tabCloseRequested,
|
|
|
|
[this](int index){ toggle_widget_visible(false, bottom_funcs, bottom_funcs->widget(index)); });
|
|
|
|
right_funcs->setTabsClosable(true);
|
|
|
|
connect(right_funcs, &QTabWidget::tabCloseRequested,
|
|
|
|
[this](int index){ toggle_widget_visible(false, right_funcs, right_funcs->widget(index)); });
|
|
|
|
center_funcs->setTabsClosable(true);
|
|
|
|
connect(center_funcs, &QTabWidget::tabCloseRequested,
|
2022-11-22 03:42:48 +00:00
|
|
|
[this](int index){
|
|
|
|
auto view = center_funcs->widget(index);
|
|
|
|
toggle_widget_visible(false, center_funcs, view);
|
2022-12-31 13:05:58 +00:00
|
|
|
auto comp = app_core->getDocsManager()->queryTextComponent(view);
|
2022-11-22 03:42:48 +00:00
|
|
|
if(comp)
|
2023-02-26 14:44:00 +00:00
|
|
|
app_core->getDocsManager()->closeTextComponent(QFileInfo(comp->absulateTargetPath()));
|
2022-11-22 03:42:48 +00:00
|
|
|
});
|
2022-11-18 23:47:32 +00:00
|
|
|
|
2023-02-26 14:44:00 +00:00
|
|
|
connect(project_structure, &VisiableProjectController::aboutToBoDelete,
|
2022-11-29 03:47:12 +00:00
|
|
|
[this](QList<QFileInfo> infos){
|
|
|
|
for(auto &key : infos){
|
2022-12-31 13:05:58 +00:00
|
|
|
auto comp = app_core->getDocsManager()->queryTextComponent(key);
|
2022-11-29 03:47:12 +00:00
|
|
|
if(comp){
|
2023-02-26 14:44:00 +00:00
|
|
|
toggle_widget_visible(false, center_funcs, comp->widget());
|
2022-12-31 13:05:58 +00:00
|
|
|
app_core->getDocsManager()->closeTextComponent(key);
|
2022-11-29 03:47:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2022-12-31 13:05:58 +00:00
|
|
|
this->app_core->getDocsManager()->addProcTrigger([this](){
|
2023-01-01 05:10:31 +00:00
|
|
|
this->refresh_views();
|
2022-11-22 06:15:36 +00:00
|
|
|
});
|
2022-11-18 23:47:32 +00:00
|
|
|
|
2022-11-11 14:38:52 +00:00
|
|
|
|
2022-11-22 03:42:48 +00:00
|
|
|
center_funcs->addTab(current_projects, "欢迎界面");
|
2022-11-17 08:16:54 +00:00
|
|
|
|
2023-02-26 14:44:00 +00:00
|
|
|
connect(project_structure, &VisiableProjectController::activeDocument,
|
2022-12-31 13:05:58 +00:00
|
|
|
app_core->getDocsManager(), &MakeTools::DocsManager::openTextDocument);
|
2022-11-22 03:42:48 +00:00
|
|
|
|
|
|
|
uilayout_load();
|
|
|
|
|
|
|
|
connect(horizontal_split, &QSplitter::splitterMoved, [this](){
|
|
|
|
splitter_layout_save({"uilayout","split-policy-h","lens"}, horizontal_split->sizes());
|
|
|
|
});
|
|
|
|
connect(vertical_split, &QSplitter::splitterMoved, [this](){
|
|
|
|
splitter_layout_save({"uilayout", "split-policy-v", "lens"}, vertical_split->sizes());
|
|
|
|
});
|
2022-11-06 00:37:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
MainWindow::~MainWindow()
|
|
|
|
{
|
|
|
|
}
|
2022-11-15 12:58:12 +00:00
|
|
|
|
2022-11-22 04:00:53 +00:00
|
|
|
void MainWindow::contentViewAppend(QWidget *widget, const QString &name)
|
|
|
|
{
|
|
|
|
for(auto idx=0; idx<center_funcs->count(); ++idx){
|
|
|
|
if(center_funcs->widget(idx) == widget){
|
|
|
|
center_funcs->setCurrentWidget(widget);
|
2022-11-29 03:47:12 +00:00
|
|
|
return;
|
2022-11-22 04:00:53 +00:00
|
|
|
}
|
|
|
|
}
|
2022-11-29 03:47:12 +00:00
|
|
|
center_funcs->addTab(widget, name);
|
|
|
|
center_funcs->setCurrentWidget(widget);
|
2022-11-22 04:00:53 +00:00
|
|
|
}
|
|
|
|
|
2023-01-01 05:10:31 +00:00
|
|
|
void MainWindow::contentViewClose(QWidget *widget)
|
|
|
|
{
|
|
|
|
for(auto idx=0; idx<center_funcs->count(); ++idx){
|
|
|
|
if(center_funcs->widget(idx) == widget){
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::refresh_views()
|
|
|
|
{
|
|
|
|
errors_present->refresh();
|
|
|
|
chains_view->refresh();
|
|
|
|
units_view->refresh();
|
|
|
|
boards_view->refresh();
|
|
|
|
concept_view->refresh();
|
|
|
|
fragments_order->refresh();
|
|
|
|
}
|
|
|
|
|
2022-11-17 08:16:54 +00:00
|
|
|
void MainWindow::build_internal(bool all_from_disk)
|
2022-11-15 12:58:12 +00:00
|
|
|
{
|
2022-11-17 08:16:54 +00:00
|
|
|
if(!all_from_disk)
|
2022-12-31 13:05:58 +00:00
|
|
|
app_core->getDocsManager()->saveAll();
|
2022-11-17 08:16:54 +00:00
|
|
|
|
2022-11-15 12:58:12 +00:00
|
|
|
auto chains = project_manager->filesWithEnds("storychain");
|
|
|
|
for(auto &it : chains)
|
2023-02-26 14:44:00 +00:00
|
|
|
app_core->getMakeCore()->compile(std::get<0>(it), std::get<0>(it));
|
2022-11-15 12:58:12 +00:00
|
|
|
|
|
|
|
auto units = project_manager->filesWithEnds("storyunit");
|
|
|
|
for(auto &it : units)
|
2023-02-26 14:44:00 +00:00
|
|
|
app_core->getMakeCore()->compile(std::get<0>(it), std::get<0>(it));
|
2022-11-15 12:58:12 +00:00
|
|
|
|
|
|
|
auto storys = project_manager->filesWithEnds("storyboard");
|
|
|
|
for(auto &it : storys)
|
2023-02-26 14:44:00 +00:00
|
|
|
app_core->getMakeCore()->compile(std::get<0>(it), std::get<0>(it));
|
2022-11-15 12:58:12 +00:00
|
|
|
|
|
|
|
auto volumes = project_manager->filesWithEnds("storyvolume");
|
|
|
|
for(auto &it : volumes)
|
2023-02-26 14:44:00 +00:00
|
|
|
app_core->getMakeCore()->compile(std::get<0>(it), std::get<0>(it));
|
2022-11-17 08:16:54 +00:00
|
|
|
|
2022-11-25 01:18:54 +00:00
|
|
|
auto concepts = project_manager->filesWithEnds("storyconcept");
|
|
|
|
for(auto &it : concepts)
|
2023-02-26 14:44:00 +00:00
|
|
|
app_core->getMakeCore()->compile(std::get<0>(it), std::get<0>(it));
|
2022-11-25 01:18:54 +00:00
|
|
|
|
2023-01-01 05:10:31 +00:00
|
|
|
refresh_views();
|
2022-11-18 23:47:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::toggle_widget_visible(bool visible, QTabWidget *con, QWidget *target, const QString &title)
|
|
|
|
{
|
|
|
|
if(visible && con->indexOf(target) == -1){
|
|
|
|
target->setVisible(true);
|
2022-11-29 03:47:12 +00:00
|
|
|
con->addTab(target, title);
|
2022-11-18 23:47:32 +00:00
|
|
|
}else if(!visible && con->indexOf(target) != -1){
|
|
|
|
target->setVisible(false);
|
|
|
|
con->removeTab(con->indexOf(target));
|
|
|
|
}
|
2022-11-17 08:16:54 +00:00
|
|
|
}
|
|
|
|
|
2022-11-22 03:42:48 +00:00
|
|
|
void MainWindow::splitter_layout_save(const QList<QString> &path_type, const QList<int> &size)
|
|
|
|
{
|
|
|
|
auto convert = [](QList<int> sizes)->QStringList{
|
|
|
|
QStringList size_strs;
|
|
|
|
for(auto i : sizes)
|
|
|
|
size_strs << QString("%1").arg(i);
|
|
|
|
return size_strs;
|
|
|
|
};
|
|
|
|
app_core->globalConfig()->setList(path_type, convert(size));
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::uilayout_save()
|
|
|
|
{
|
|
|
|
auto global = app_core->globalConfig();
|
|
|
|
|
|
|
|
auto xvisible_save = [global](QWidget *ins, const QString &name){
|
|
|
|
global->setConfig({"uilayout", "visible", name}, QString("%1").arg(ins->isVisible()));
|
|
|
|
};
|
|
|
|
|
|
|
|
xvisible_save(left_funcs, "area-left");
|
|
|
|
xvisible_save(right_funcs, "area-right");
|
|
|
|
xvisible_save(bottom_funcs, "area-bottom");
|
2022-11-29 03:47:12 +00:00
|
|
|
// xvisible_save(project_structure, "project_tree");
|
|
|
|
// xvisible_save(errors_present, "message-view");
|
|
|
|
// xvisible_save(chains_view, "chains-sum");
|
|
|
|
// xvisible_save(units_view, "units-sum");
|
2022-11-22 03:42:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::uilayout_load()
|
|
|
|
{
|
|
|
|
auto global = app_core->globalConfig();
|
|
|
|
|
|
|
|
auto xvisible_load = [global](QWidget *ins, const QString &name){
|
|
|
|
auto visible = Config::ConfigHelper::getConfigAsDefault(global, {"uilayout","visible",name}, QString("%1").arg(false));
|
|
|
|
ins->setVisible(visible.toInt());
|
|
|
|
};
|
|
|
|
|
|
|
|
xvisible_load(left_funcs, "area-left");
|
|
|
|
xvisible_load(right_funcs, "area-right");
|
|
|
|
xvisible_load(bottom_funcs, "area-bottom");
|
2022-11-29 03:47:12 +00:00
|
|
|
// xvisible_load(project_structure, "project_tree");
|
|
|
|
// xvisible_load(errors_present, "message-view");
|
|
|
|
// xvisible_load(chains_view, "chains-sum");
|
|
|
|
// xvisible_load(units_view, "units-sum");
|
2022-11-22 03:42:48 +00:00
|
|
|
|
|
|
|
auto convert = [](QStringList in)->QList<int>{
|
|
|
|
QList<int> size;
|
|
|
|
for(auto &s : in)
|
|
|
|
size << s.toInt();
|
|
|
|
return size;
|
|
|
|
};
|
|
|
|
|
|
|
|
auto strings = global->getList({"uilayout", "split-policy-h", "lens"});
|
|
|
|
horizontal_split->setSizes(convert(strings));
|
|
|
|
strings = global->getList({"uilayout", "split-policy-v", "lens"});
|
|
|
|
vertical_split->setSizes(convert(strings));
|
|
|
|
}
|
|
|
|
|
2022-11-17 08:16:54 +00:00
|
|
|
void MainWindow::closeEvent(QCloseEvent *event)
|
|
|
|
{
|
|
|
|
// 关闭事件
|
|
|
|
if(project_manager->isOpen()){
|
|
|
|
project_manager->save();
|
2023-01-01 05:10:31 +00:00
|
|
|
app_core->getDocsManager()->closeAll();
|
2022-11-17 08:16:54 +00:00
|
|
|
}
|
|
|
|
|
2022-11-22 03:42:48 +00:00
|
|
|
uilayout_save();
|
|
|
|
app_core->save();
|
|
|
|
|
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
|
|
|
|
|
|
|
bool MainWindow::eventFilter(QObject *watched, QEvent *event)
|
|
|
|
{
|
|
|
|
auto ev = event->type();
|
|
|
|
switch(ev){
|
2022-11-29 03:47:12 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|