2024-02-14 05:27:15 +00:00
|
|
|
//#include "mainwindow.h"
|
|
|
|
//#include "srcedit_defaulttext.h"
|
|
|
|
//#include "srcedit_storyboard.h"
|
|
|
|
//#include "xapp.h"
|
|
|
|
|
|
|
|
//#include <QApplication>
|
|
|
|
//#include <QDateTime>
|
|
|
|
//#include <QDebug>
|
|
|
|
//#include <QFileDialog>
|
|
|
|
//#include <QInputDialog>
|
|
|
|
//#include <QLabel>
|
|
|
|
//#include <QList>
|
|
|
|
//#include <QMenuBar>
|
|
|
|
//#include <QMessageBox>
|
|
|
|
//#include <QStatusBar>
|
|
|
|
//#include <QTextEdit>
|
|
|
|
//#include <QToolBar>
|
|
|
|
//#include <QVBoxLayout>
|
|
|
|
//#include <xmlconfig.h>
|
|
|
|
//#include <xmlprojectmanager.h>
|
|
|
|
|
|
|
|
//#include "command_list.h"
|
|
|
|
|
|
|
|
//using namespace Project;
|
|
|
|
//using namespace Components;
|
|
|
|
//using namespace Core;
|
|
|
|
//using namespace CommandList;
|
|
|
|
//using namespace bridge;
|
|
|
|
|
|
|
|
//MainWindow::MainWindow(XApp *core, const QString &layout, QWidget *parent)
|
|
|
|
// : QMainWindow(parent),
|
|
|
|
// layout_name_store(layout),
|
|
|
|
// core_bind(core),
|
|
|
|
// present_host(new SplitFrame::SplitPanel(this)),
|
|
|
|
// session_service(new ViewSession(XApp::gconfig, this)),
|
|
|
|
// actions_stack(new QToolBar(this)),
|
|
|
|
// views_bar(new ViewStackedBar(present_host, this)),
|
|
|
|
// center_frame(new PresentContainer(present_host)),
|
|
|
|
// project_present(new ProjectView(present_host, XApp::disp_core, core->docsManager())) {
|
|
|
|
// setMinimumSize(1000, 600);
|
|
|
|
// setWindowTitle(tr("提线木偶"));
|
|
|
|
|
|
|
|
// QApplication::instance()->installEventFilter(this);
|
|
|
|
// auto mbar = menuBar();
|
|
|
|
// initial_menubar(mbar);
|
|
|
|
|
|
|
|
// setCentralWidget(present_host->bind());
|
|
|
|
// addToolBar(Qt::LeftToolBarArea, views_bar);
|
|
|
|
// present_host->addListener(views_bar);
|
|
|
|
|
|
|
|
// session_service->initPresentView(center_frame, project_present, core->parseService()->errorsPresentModel());
|
|
|
|
|
|
|
|
// project_present->setVisible(true);
|
|
|
|
// core->docsManager()->appendPresent(center_frame);
|
|
|
|
|
|
|
|
// session_service->viewStatesRestore(this, present_host);
|
|
|
|
//}
|
|
|
|
|
|
|
|
//MainWindow::~MainWindow() { core_bind->docsManager()->removePresent(center_frame); }
|
|
|
|
|
|
|
|
//SplitFrame::SplitPanel *MainWindow::bindPresent() const { return present_host; }
|
|
|
|
|
|
|
|
//QString MainWindow::layoutName() const { return layout_name_store; }
|
|
|
|
|
|
|
|
//void MainWindow::resetLayoutName(const QString &name) { layout_name_store = name; }
|
|
|
|
|
|
|
|
//void MainWindow::initial_menubar(QMenuBar *mbar) {
|
|
|
|
|
|
|
|
// // 项目菜单树
|
|
|
|
// project = mbar->addMenu("项目");
|
|
|
|
// this->build_project_menu(project);
|
|
|
|
|
|
|
|
// // 编辑菜单
|
|
|
|
// edit = mbar->addMenu("编辑");
|
|
|
|
// this->build_edit_menu(edit);
|
|
|
|
|
|
|
|
// // 视图菜单
|
|
|
|
// view = mbar->addMenu("视图");
|
|
|
|
// build_view_menu(view);
|
|
|
|
|
|
|
|
// // 工具菜单
|
|
|
|
// tool = mbar->addMenu("工具");
|
|
|
|
// build_tools_menu(tool);
|
|
|
|
|
|
|
|
// // 窗口菜单
|
|
|
|
// window = mbar->addMenu("窗口");
|
|
|
|
// build_window_menu(window);
|
|
|
|
|
|
|
|
// // 系统
|
|
|
|
// system = mbar->addMenu("系统");
|
|
|
|
// system_active = system->addAction("软件激活");
|
|
|
|
// system_info = system->addAction("系统信息");
|
|
|
|
// system->addSeparator();
|
|
|
|
// system_about = system->addAction("关于……");
|
|
|
|
//}
|
|
|
|
|
|
|
|
//auto action_sync = [](bool enable, const QList<QAction*> &same_state){
|
|
|
|
// for(auto &a : same_state)
|
|
|
|
// a->setEnabled(enable);
|
|
|
|
//};
|
|
|
|
|
|
|
|
//void MainWindow::build_project_menu(QMenu *project) {
|
|
|
|
// project_open = project->addAction("打开项目", [this]() {
|
|
|
|
// auto file = QFileDialog::getOpenFileName(this, "打开项目", QString(), "小说项目(*.nsf)");
|
|
|
|
// if (file == "")
|
|
|
|
// return;
|
|
|
|
|
|
|
|
// XApp::disp_core->postCommand(OpenProject(file));
|
|
|
|
// });
|
|
|
|
|
|
|
|
// project_new = project->addAction("新建项目", [this]() {
|
|
|
|
// auto name = QInputDialog::getText(this, "输入项目名称", "项目名称");
|
|
|
|
// if (name == "")
|
|
|
|
// return;
|
|
|
|
// auto dir_path = QFileDialog::getExistingDirectory(this, "指定项目存储路径");
|
|
|
|
// if (dir_path == "")
|
|
|
|
// return;
|
|
|
|
|
|
|
|
// XApp::disp_core->postCommand(NewProject(QDir(dir_path), name));
|
|
|
|
// });
|
|
|
|
|
|
|
|
// project_close = project->addAction("关闭项目", []() { XApp::disp_core->postCommand(CloseProject()); });
|
|
|
|
|
|
|
|
// project->addSeparator();
|
|
|
|
|
|
|
|
// project_newpath = project->addAction("新建路径", [this]() {
|
|
|
|
// auto packages = QInputDialog::getText(this, "输入包路径名称/PackA/PackB/PackC", "包路径:");
|
|
|
|
// if (packages != "")
|
|
|
|
// XApp::disp_core->postCommand(NewPackage(packages));
|
|
|
|
// });
|
|
|
|
|
|
|
|
// project_newfile = project->addMenu("新建文件");
|
|
|
|
// auto types = core_bind->docsManager()->fileTypes();
|
|
|
|
// for (auto &t : types) {
|
|
|
|
// project_newfile->addAction(t, [this, &t]() {
|
|
|
|
// auto name = QInputDialog::getText(this, "输入名称", "名称:");
|
|
|
|
// if (name == "")
|
|
|
|
// return;
|
|
|
|
|
|
|
|
// auto idx = project_present->currentIndex();
|
|
|
|
// if (!idx.isValid())
|
|
|
|
// idx = core_bind->pjtManager()->model()->item(0)->index();
|
|
|
|
|
|
|
|
// auto group_path = core_bind->docsManager()->convertPath(idx);
|
|
|
|
// XApp::disp_core->postCommand(NewFile(group_path, name, t));
|
|
|
|
// });
|
|
|
|
// }
|
|
|
|
|
|
|
|
// project->addSeparator();
|
|
|
|
|
|
|
|
// project_save = project->addAction("保存全部", []() { XApp::disp_core->postCommand(SaveAll()); });
|
|
|
|
// project_save->setShortcut(QKeySequence::StandardKey::Save);
|
|
|
|
|
|
|
|
// project->addSeparator();
|
|
|
|
|
|
|
|
// software_exit = project->addAction("退出", []() {
|
|
|
|
// XApp::disp_core->postCommand(SaveAll());
|
|
|
|
// QApplication::exit(0);
|
|
|
|
// });
|
|
|
|
|
|
|
|
// this->hasBeenCLOSE();
|
|
|
|
//}
|
|
|
|
|
|
|
|
//void MainWindow::build_edit_menu(QMenu *edit) {
|
|
|
|
// edit_undo = edit->addAction("撤销一步");
|
|
|
|
// edit_redo = edit->addAction("重做一步");
|
|
|
|
// edit->addSeparator();
|
|
|
|
// edit_find = edit->addAction("查找关键词");
|
|
|
|
// edit_replace = edit->addAction("替换关键词");
|
|
|
|
//}
|
|
|
|
|
|
|
|
//void MainWindow::build_view_menu(QMenu *view) {
|
|
|
|
// view_area = view->addMenu("区域管理");
|
|
|
|
|
|
|
|
// actions_stack->setMovable(false);
|
|
|
|
// addToolBar(Qt::ToolBarArea::TopToolBarArea, actions_stack);
|
|
|
|
|
|
|
|
// view_area_toolbar = view_area->addAction("工具栏");
|
|
|
|
|
|
|
|
// connect(view_area_toolbar, &QAction::triggered, [this](bool v) { actions_stack->setVisible(v); });
|
|
|
|
|
|
|
|
// auto xstatus = statusBar();
|
|
|
|
// xstatus->setVisible(false);
|
|
|
|
// xstatus->addWidget(new QLabel("文本消息", this));
|
|
|
|
// view_area_statusbar = view_area->addAction("状态栏");
|
|
|
|
|
|
|
|
// connect(view_area_statusbar, &QAction::triggered, [xstatus](bool v) { xstatus->setVisible(v); });
|
|
|
|
|
|
|
|
// view_config = view->addAction("视图配置", [this]() {
|
|
|
|
// auto dialog = new QDialog();
|
|
|
|
// auto tabs = new QTabWidget(dialog);
|
|
|
|
// auto layout = new QVBoxLayout(dialog);
|
|
|
|
// layout->addWidget(tabs);
|
|
|
|
// core_bind->docsManager()->loadViewConfigWidgets(tabs);
|
|
|
|
// dialog->exec();
|
|
|
|
// });
|
|
|
|
//}
|
|
|
|
|
|
|
|
//void MainWindow::build_tools_menu(QMenu *tool) {
|
|
|
|
// tool_console = tool->addAction("控制台");
|
|
|
|
|
|
|
|
// tool->addSeparator();
|
|
|
|
|
|
|
|
// tool_wcheck = tool->addMenu("敏感词检测");
|
|
|
|
// tool_wcheck_setting = tool_wcheck->addAction("工具配置");
|
|
|
|
// tool_wcheck_wordslist = tool_wcheck->addAction("敏感词编辑");
|
|
|
|
|
|
|
|
// tool_version = tool->addMenu("版本管理");
|
|
|
|
// tool_version_setting = tool_version->addAction("工具配置");
|
|
|
|
// tool_version_enable = tool_version->addAction("启用");
|
|
|
|
// tool_version_commit = tool_version->addAction("提交版本");
|
|
|
|
// tool_version_rollback = tool_version->addAction("版本回滚");
|
|
|
|
|
|
|
|
// tool_inout = tool->addMenu("导入导出");
|
|
|
|
// tool_inout_outline_in = tool_inout->addAction("导入WsOutlines");
|
|
|
|
// tool_inout->addSeparator();
|
|
|
|
// tool_inout_outline_out = tool_inout->addAction("导出WsOutlines");
|
|
|
|
// tool_inout_outline_webout = tool_inout->addAction("导出Web大纲");
|
|
|
|
// tool_inout->addSeparator();
|
|
|
|
// tool_inout_storytxt_out = tool_inout->addAction("导出TXT故事");
|
|
|
|
// tool_inout_storyepub_out = tool_inout->addAction("导出EQUP故事");
|
|
|
|
//}
|
|
|
|
|
|
|
|
//QList<QString> layout_peak_path = {"sys-configs", "foreground", "view-layouts"};
|
|
|
|
//void MainWindow::build_window_menu(QMenu *window) {
|
|
|
|
// window_winnew = window->addMenu("新建窗口");
|
|
|
|
// connect(window_winnew, &QMenu::aboutToShow, [this]() {
|
|
|
|
// auto names = XApp::gconfig->getList(layout_peak_path);
|
|
|
|
// if (!names.size()) {
|
|
|
|
// names << "default";
|
|
|
|
// XApp::gconfig->setList(layout_peak_path, names);
|
|
|
|
// }
|
|
|
|
|
|
|
|
// window_winnew->clear();
|
|
|
|
|
|
|
|
// for (auto &n : names)
|
|
|
|
// window_winnew->addAction(n);
|
|
|
|
// });
|
|
|
|
// connect(window_winnew, &QMenu::triggered, [this](QAction *s) {
|
|
|
|
// auto layout = s->text();
|
|
|
|
// auto newone = new MainWindow(this->core_bind, layout);
|
|
|
|
// newone->show();
|
|
|
|
// });
|
|
|
|
|
|
|
|
// window_winclose = window->addAction("关闭窗口", [this]() {
|
|
|
|
// XApp::disp_core->postCommand(SaveAll());
|
|
|
|
// this->close();
|
|
|
|
// });
|
|
|
|
|
|
|
|
// window->addSeparator();
|
|
|
|
// window_layout_store = window->addAction("保存当前布局", [this]() {
|
|
|
|
// auto new_name = QInputDialog::getText(this, "输入新布局名称", "名称:");
|
|
|
|
// if (new_name.isEmpty())
|
|
|
|
// return;
|
|
|
|
|
|
|
|
// auto names = XApp::gconfig->getList(layout_peak_path);
|
|
|
|
// if (names.contains(new_name)) {
|
|
|
|
// QMessageBox::critical(this, "数据校验", "输入错误,输入了重复的布局名称!");
|
|
|
|
// return;
|
|
|
|
// }
|
|
|
|
// names << new_name;
|
|
|
|
// XApp::gconfig->setList(layout_peak_path, names);
|
|
|
|
|
|
|
|
// this->resetLayoutName(new_name);
|
|
|
|
// session_service->viewStatesSave(this, this->present_host);
|
|
|
|
// });
|
|
|
|
|
|
|
|
// window_layout_load = window->addMenu("布局切换");
|
|
|
|
// window_layout_del = window->addMenu("布局删除");
|
|
|
|
//}
|
|
|
|
|
|
|
|
//void MainWindow::closeEvent(QCloseEvent *event) {
|
|
|
|
// // 关闭事件
|
|
|
|
// if (core_bind->pjtManager()->isOpenning()) {
|
|
|
|
// XApp::disp_core->postCommand(CloseProject());
|
|
|
|
// }
|
|
|
|
|
|
|
|
// session_service->viewStatesSave(this, present_host);
|
|
|
|
// XApp::gconfig->save();
|
|
|
|
// QMainWindow::closeEvent(event);
|
|
|
|
//}
|
|
|
|
|
|
|
|
//bool MainWindow::eventFilter(QObject *watched, QEvent *event) {
|
|
|
|
// auto ev = event->type();
|
|
|
|
// 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:
|
|
|
|
// break;
|
|
|
|
// default:
|
|
|
|
// break;
|
|
|
|
// }
|
|
|
|
// return QMainWindow::eventFilter(watched, event);
|
|
|
|
//}
|
|
|
|
|
|
|
|
//void MainWindow::ProjectNEW(const QString &) {}
|
|
|
|
|
|
|
|
//void MainWindow::ProjectOPEN(const QString &project_file) {
|
|
|
|
// action_sync(false, {project_new, project_open});
|
|
|
|
// action_sync(true, {project_close, project_newpath, project_save});
|
|
|
|
// project_newfile->setEnabled(true);
|
|
|
|
|
|
|
|
// this->setWindowTitle(QString("WordIDE::%1 - %2").arg(this->core_bind->pjtManager()->name()).arg(project_file));
|
|
|
|
//}
|
|
|
|
|
|
|
|
//void MainWindow::hasBeenSAVE() {}
|
|
|
|
|
|
|
|
//void MainWindow::hasBeenCLOSE() {
|
|
|
|
// action_sync(true, {project_open, project_new});
|
|
|
|
// action_sync(false, {project_close, project_newpath, project_save});
|
|
|
|
// project_newfile->setEnabled(false);
|
|
|
|
|
|
|
|
// this->setWindowTitle("WordIDE");
|
|
|
|
//}
|
|
|
|
|
|
|
|
//void MainWindow::hasBeenRENAME(const QModelIndex &path, const QString &new_name) {}
|
|
|
|
|
|
|
|
//void MainWindow::hasBeenAPPEND(const QModelIndex &new_path) {}
|
|
|
|
|
|
|
|
//void MainWindow::hasBeenMOVE(const QModelIndex &new_path) {}
|
|
|
|
|
|
|
|
//void MainWindow::aboutToBeSAVE() {}
|
|
|
|
|
|
|
|
//void MainWindow::aboutToBeCLOSE() {}
|
|
|
|
|
|
|
|
//void MainWindow::aboutToBeDELETE(const QModelIndex &path) {}
|
|
|
|
|
|
|
|
//void MainWindow::aboutToBeMOVE(const QModelIndex &old_path) {}
|