zuixin
This commit is contained in:
parent
165d7f85f1
commit
44d05e4032
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE QtCreatorProject>
|
||||
<!-- Written by QtCreator 4.15.0, 2023-09-04T07:38:38. -->
|
||||
<!-- Written by QtCreator 4.15.0, 2023-09-08T22:11:48. -->
|
||||
<qtcreator>
|
||||
<data>
|
||||
<variable>EnvironmentId</variable>
|
||||
|
|
|
@ -45,7 +45,7 @@ namespace Presents {
|
|||
* @param core
|
||||
* @param name
|
||||
*/
|
||||
virtual void applySetting(const QString &name) = 0;
|
||||
virtual void applySetting(const QString &name, const Config::Configration *cfg) = 0;
|
||||
|
||||
/**
|
||||
* @brief 使用此实例打开指定的路径文件,冲刷掉所有状态
|
||||
|
@ -98,6 +98,13 @@ namespace Presents {
|
|||
*/
|
||||
virtual void create(const QFileInfo &target) = 0;
|
||||
|
||||
/**
|
||||
* @brief 创建一个类型特化的配置面板
|
||||
* @param cfg_port
|
||||
* @return
|
||||
*/
|
||||
virtual QDialog *createTempConfigPanel(Config::Configration *cfg_port) = 0;
|
||||
|
||||
/**
|
||||
* @brief 生成一个新Present实例
|
||||
* @return
|
||||
|
|
|
@ -196,6 +196,16 @@ void MainWindow::build_view_menu(QMenu *view) {
|
|||
view->addSeparator();
|
||||
auto func = view->addMenu("功能视图");
|
||||
sync_kernel->widgetEnableSync(func, [this]() { return this->core_bind->pjtManager()->isOpenning(); });
|
||||
|
||||
auto fconfig = 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();
|
||||
});
|
||||
sync_kernel->actionEnableSync(fconfig, [this]() { return this->core_bind->pjtManager()->isOpenning(); });
|
||||
}
|
||||
|
||||
void MainWindow::build_tools_menu(QMenu *tool) {
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
#include "manager_docs.h"
|
||||
#include "DocsManager.h"
|
||||
#include "keywordshighlighter.h"
|
||||
#include "xapp.h"
|
||||
|
||||
using namespace Core;
|
||||
using namespace Config;
|
||||
using namespace Presents;
|
||||
|
||||
DocumentsManager::DocumentsManager(Project::ProjectManager *project) : pjtins(project) { initContentViewPlugins(); }
|
||||
DocumentsManager::DocumentsManager(XApp *host) : core_inst(host) { initContentViewPlugins(); }
|
||||
|
||||
void DocumentsManager::appendPresent(PresentHost *container) {
|
||||
if (present_ui.contains(container))
|
||||
|
@ -17,7 +18,7 @@ void DocumentsManager::appendPresent(PresentHost *container) {
|
|||
|
||||
void DocumentsManager::removePresent(PresentHost *container) {}
|
||||
|
||||
Project::ProjectManager *DocumentsManager::projectManager() const { return pjtins; }
|
||||
Project::ProjectManager *DocumentsManager::projectManager() const { return core_inst->pjtManager(); }
|
||||
|
||||
#include "srcedit_defaulttext.h"
|
||||
#include "srcedit_storyboard.h"
|
||||
|
@ -26,6 +27,18 @@ void DocumentsManager::initContentViewPlugins() {
|
|||
registPresentType(new StorySourceEditFactory);
|
||||
}
|
||||
|
||||
void DocumentsManager::loadViewConfigWidgets(QTabWidget *stacked) {
|
||||
if (!projectManager()->isOpenning())
|
||||
return;
|
||||
|
||||
auto keys = factory_map.keys();
|
||||
for (auto &it : keys) {
|
||||
auto panel = factory_map[it]->createTempConfigPanel(projectManager()->configraions());
|
||||
if (panel)
|
||||
stacked->addTab(panel, it + "配置");
|
||||
}
|
||||
}
|
||||
|
||||
QList<QString> DocumentsManager::fileTypes() const {
|
||||
QList<QString> all_types;
|
||||
for (auto &it : factory_map.keys())
|
||||
|
@ -33,7 +46,7 @@ QList<QString> DocumentsManager::fileTypes() const {
|
|||
return all_types;
|
||||
}
|
||||
|
||||
void DocumentsManager::createPackage(const Core::Route &link) { pjtins->operateAccess()->newPackage(link.links()); }
|
||||
void DocumentsManager::createPackage(const Core::Route &link) { core_inst->pjtManager()->operateAccess()->newPackage(link.links()); }
|
||||
|
||||
void DocumentsManager::createFile(const Core::Route &group_path, const QString &name, const QString &suffix) {
|
||||
auto all_types = fileTypes();
|
||||
|
@ -47,12 +60,12 @@ void DocumentsManager::createFile(const Core::Route &group_path, const QString &
|
|||
}
|
||||
|
||||
void DocumentsManager::renameNode(const Core::Route &node_path, const QString &name) {
|
||||
pjtins->operateAccess()->rename(convertPath(node_path), name);
|
||||
core_inst->pjtManager()->operateAccess()->rename(convertPath(node_path), name);
|
||||
|
||||
auto activie_file_nodes = actives();
|
||||
if (activie_file_nodes.contains(node_path)) {
|
||||
auto inst = convertPresent(node_path);
|
||||
inst->applySetting(name);
|
||||
inst->applySetting(name, core_inst->pjtManager()->configraions());
|
||||
doc_openning.remove(node_path);
|
||||
|
||||
auto old_link = node_path.links();
|
||||
|
@ -65,7 +78,7 @@ void DocumentsManager::renameNode(const Core::Route &node_path, const QString &n
|
|||
|
||||
void DocumentsManager::deleteNode(const Core::Route &node_path) {
|
||||
auto node_mindex = convertPath(node_path);
|
||||
auto file_nodes = pjtins->queryAccess()->filesGather(node_mindex);
|
||||
auto file_nodes = core_inst->pjtManager()->queryAccess()->filesGather(node_mindex);
|
||||
auto activie_file_nodes = actives();
|
||||
|
||||
QList<Core::Route> path_buff;
|
||||
|
@ -76,26 +89,26 @@ void DocumentsManager::deleteNode(const Core::Route &node_path) {
|
|||
}
|
||||
|
||||
closeFile(path_buff);
|
||||
pjtins->operateAccess()->deleteT(node_mindex);
|
||||
core_inst->pjtManager()->operateAccess()->deleteT(node_mindex);
|
||||
}
|
||||
|
||||
void DocumentsManager::openFile(const QList<Route> &doc_paths) {
|
||||
for (auto &it : doc_paths) {
|
||||
auto openning = actives();
|
||||
if (openning.contains(it)) {
|
||||
doc_openning[it]->applySetting(it.links().last());
|
||||
doc_openning[it]->applySetting(it.links().last(), core_inst->pjtManager()->configraions());
|
||||
active(it);
|
||||
continue;
|
||||
}
|
||||
|
||||
auto info = pjtins->queryAccess()->queryInfo(convertPath(it));
|
||||
auto info = core_inst->pjtManager()->queryAccess()->queryInfo(convertPath(it));
|
||||
if (!info.isFile())
|
||||
throw new SimpleException<QString>("打开文件错误", "指向的节点不是文件节点");
|
||||
|
||||
auto view = factory_map[info.suffix()]->newInst(this, it);
|
||||
doc_openning[it] = view;
|
||||
view->load(info);
|
||||
view->applySetting(it.links().last());
|
||||
view->applySetting(it.links().last(), core_inst->pjtManager()->configraions());
|
||||
|
||||
for (auto &con : present_ui)
|
||||
if (con->avaliable(view)) {
|
||||
|
@ -126,7 +139,7 @@ void DocumentsManager::closeFile(const QList<Core::Route> &doc_paths) {
|
|||
|
||||
QModelIndex DocumentsManager::convertPath(const Core::Route &path) {
|
||||
auto path_list = path.links();
|
||||
auto itor_node = pjtins->model()->item(0);
|
||||
auto itor_node = core_inst->pjtManager()->model()->item(0);
|
||||
while (path_list.size() > 1) {
|
||||
auto item = path_list.takeAt(1);
|
||||
int idx = 0;
|
||||
|
@ -145,7 +158,7 @@ QModelIndex DocumentsManager::convertPath(const Core::Route &path) {
|
|||
|
||||
Route DocumentsManager::convertPath(const QModelIndex &index) {
|
||||
Core::Route path;
|
||||
auto item = pjtins->model()->itemFromIndex(index);
|
||||
auto item = core_inst->pjtManager()->model()->itemFromIndex(index);
|
||||
while (item != nullptr) {
|
||||
path.prepend(item->text().trimmed());
|
||||
item = item->parent();
|
||||
|
@ -173,6 +186,10 @@ void DocumentsManager::save() {
|
|||
auto actives_paths = this->actives();
|
||||
for (auto &p : actives_paths)
|
||||
convertPresent(p)->saveAs();
|
||||
|
||||
// files
|
||||
auto pjt = core_inst->pjtManager();
|
||||
auto list = pjt->queryAccess()->filesWithEnds("storyboard");
|
||||
}
|
||||
|
||||
QString DocumentsManager::name() const { return NAME(DocumentsManager); }
|
||||
|
|
|
@ -53,7 +53,7 @@ namespace Presents {
|
|||
};
|
||||
|
||||
} // namespace Presents
|
||||
|
||||
class XApp;
|
||||
namespace Core {
|
||||
|
||||
/**
|
||||
|
@ -61,7 +61,7 @@ namespace Core {
|
|||
*/
|
||||
class DocumentsManager : public Schedule::AccessibleObject {
|
||||
public:
|
||||
DocumentsManager(Project::ProjectManager *project);
|
||||
DocumentsManager(XApp *host);
|
||||
virtual ~DocumentsManager() = default;
|
||||
|
||||
/**
|
||||
|
@ -81,6 +81,7 @@ namespace Core {
|
|||
* @brief 初始化内容视图插件
|
||||
*/
|
||||
void initContentViewPlugins();
|
||||
void loadViewConfigWidgets(QTabWidget *stacked);
|
||||
|
||||
// ==========================================================
|
||||
/**
|
||||
|
@ -188,7 +189,7 @@ namespace Core {
|
|||
virtual QString name() const override;
|
||||
|
||||
private:
|
||||
Project::ProjectManager *pjtins;
|
||||
XApp *const core_inst;
|
||||
QList<Presents::PresentHost *> present_ui;
|
||||
|
||||
QHash<QString, Presents::PresentFactory *> factory_map;
|
||||
|
|
|
@ -3,7 +3,9 @@
|
|||
#include <QComboBox>
|
||||
#include <QFont>
|
||||
#include <QGridLayout>
|
||||
#include <QLabel>
|
||||
#include <QMenu>
|
||||
#include <QPushButton>
|
||||
#include <QSpinBox>
|
||||
#include <QTextStream>
|
||||
#include <libConfig.h>
|
||||
|
@ -30,7 +32,7 @@ void DefaultTextEdit::beforeClose() { mgr_inst->save(); }
|
|||
|
||||
DocumentsManager *DefaultTextEdit::docsManager() const { return mgr_inst; }
|
||||
|
||||
void DefaultTextEdit::applySetting(const QString &name) { name_store = name; }
|
||||
void DefaultTextEdit::applySetting(const QString &name, const Configration *cfg) { name_store = name; }
|
||||
|
||||
QString DefaultTextEdit::name() const
|
||||
{
|
||||
|
@ -95,3 +97,13 @@ void DefaultTextEditFactory::create(const QFileInfo &target) {
|
|||
base_f.flush();
|
||||
base_f.close();
|
||||
}
|
||||
|
||||
QDialog *DefaultTextEditFactory::createTempConfigPanel(Config::Configration *cfg_port) {
|
||||
auto panel = new QDialog();
|
||||
panel->setWindowTitle("文本编辑器配置");
|
||||
auto layout = new QGridLayout(panel);
|
||||
layout->addWidget(new QLabel("选择字体", panel));
|
||||
layout->addWidget(new QPushButton("选择字体", panel));
|
||||
|
||||
return panel;
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include "DocsManager.h"
|
||||
#include <QSyntaxHighlighter>
|
||||
|
||||
#include <QDialog>
|
||||
#include <QFileInfo>
|
||||
#include <QTextEdit>
|
||||
|
||||
|
@ -30,7 +31,7 @@ namespace Presents {
|
|||
// FilePresent interface
|
||||
public:
|
||||
virtual QWidget *widget() const override;
|
||||
virtual void applySetting(const QString &name) override;
|
||||
virtual void applySetting(const QString &name, const Config::Configration *cfg) override;
|
||||
virtual QString name() const override;
|
||||
virtual void load(const QFileInfo &target_file) override;
|
||||
virtual void saveAs(const QString &path) override;
|
||||
|
@ -50,9 +51,13 @@ namespace Presents {
|
|||
public:
|
||||
virtual ~DefaultTextEditFactory() = default;
|
||||
|
||||
void setPresentFont(Config::Configration *ptr, const QFont &appoint);
|
||||
QFont getPresentFont(Config::Configration *ptr) const;
|
||||
|
||||
// PresentFactory interface
|
||||
public:
|
||||
virtual void create(const QFileInfo &target) override;
|
||||
virtual QDialog *createTempConfigPanel(Config::Configration *cfg_port) override;
|
||||
};
|
||||
} // namespace Presents
|
||||
|
||||
|
|
|
@ -83,7 +83,7 @@ bool StorySourceEdit::isModified() const
|
|||
return true;
|
||||
}
|
||||
|
||||
void StorySourceEdit::applySetting(const QString &name) { this->name_store = name; }
|
||||
void StorySourceEdit::applySetting(const QString &name, const Configration *cfg) { this->name_store = name; }
|
||||
|
||||
void StorySourceEdit::jumpTo(const QList<QString> &path) {
|
||||
// auto fpath = this->absoluteTargetPath();
|
||||
|
@ -119,3 +119,5 @@ void StorySourceEditFactory::create(const QFileInfo &target) {
|
|||
base_f.flush();
|
||||
base_f.close();
|
||||
}
|
||||
|
||||
QDialog *StorySourceEditFactory::createTempConfigPanel(Config::Configration *cfg_port) { return nullptr; }
|
||||
|
|
|
@ -37,7 +37,7 @@ namespace Presents {
|
|||
virtual QString relativeTargetPath(const QDir &base) const override;
|
||||
virtual QString absoluteTargetPath() const override;
|
||||
virtual bool isModified() const override;
|
||||
virtual void applySetting(const QString &name) override;
|
||||
virtual void applySetting(const QString &name, const Config::Configration *cfg) override;
|
||||
virtual void jumpTo(const QList<QString> &path) override;
|
||||
virtual void beforeClose() override;
|
||||
virtual Core::DocumentsManager *docsManager() const override;
|
||||
|
@ -49,6 +49,7 @@ namespace Presents {
|
|||
// PresentFactory interface
|
||||
public:
|
||||
virtual void create(const QFileInfo &target) override;
|
||||
virtual QDialog *createTempConfigPanel(Config::Configration *cfg_port) override;
|
||||
};
|
||||
|
||||
} // namespace Presents
|
||||
|
|
|
@ -22,7 +22,7 @@ DocumentsManager *WelcomePanel::docsManager() const { return nullptr; }
|
|||
|
||||
Route WelcomePanel::accessPath() const { return Route(); }
|
||||
|
||||
void WelcomePanel::applySetting(const QString &name) {}
|
||||
void WelcomePanel::applySetting(const QString &name, const Config::Configration *cfg) {}
|
||||
|
||||
void WelcomePanel::load(const QFileInfo &target_file) {}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace Presents {
|
|||
virtual Core::DocumentsManager *docsManager() const override;
|
||||
|
||||
virtual Core::Route accessPath() const override;
|
||||
virtual void applySetting(const QString &name) override;
|
||||
virtual void applySetting(const QString &name, const Config::Configration *cfg) override;
|
||||
virtual void load(const QFileInfo &target_file) override;
|
||||
virtual void saveAs(const QString &path) override;
|
||||
virtual QString relativeTargetPath(const QDir &base) const override;
|
||||
|
|
|
@ -15,7 +15,7 @@ XApp::XApp(int argc, char **argv)
|
|||
: QApplication(argc, argv),
|
||||
parse_service(new ParseBridge()),
|
||||
project_manager(new XMLProjectManager(this)),
|
||||
active_docscollect(new DocumentsManager(project_manager)) {
|
||||
active_docscollect(new DocumentsManager(this)) {
|
||||
gconfig->loadFile("./software.config");
|
||||
|
||||
init_commands(disp_core);
|
||||
|
|
Loading…
Reference in New Issue