QtNovelUI/WordsIDE/mainwindow.h

103 lines
2.8 KiB
C
Raw Normal View History

2022-11-06 00:37:50 +00:00
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
2022-11-15 08:07:02 +00:00
#include <QSplitter>
#include <QTableView>
2022-11-18 23:47:32 +00:00
#include <libProjectManager.h>
2022-11-15 12:58:12 +00:00
#include <StoryTool.h>
2022-11-15 08:07:02 +00:00
#include <QTreeView>
2022-11-18 05:43:27 +00:00
#include <QListView>
#include "SensitiveCore.h"
#include "messagepresent.h"
2022-11-18 05:43:27 +00:00
#include "storychainspresent.h"
2022-11-18 23:47:32 +00:00
#include "storyunitspresent.h"
#include "projectview.h"
#include "ContentPresent.h"
2022-11-25 01:18:54 +00:00
#include "storyboardspresent.h"
2022-11-29 03:47:12 +00:00
#include "storyconceptspresent.h"
2022-11-06 00:37:50 +00:00
2022-11-18 23:47:32 +00:00
class Run
{
public:
Run(bool manual_flag, std::function<bool()> judge, std::function<void(bool)> execution);
void exec();
private:
bool manual;
std::function<bool()> judgement;
std::function<void(bool)> execution;
};
class StatusSyncCore : public QObject
{
public:
explicit StatusSyncCore(QObject *p = nullptr);
virtual ~StatusSyncCore() = default;
void registerWidgetSync(QWidget* tar, std::function<bool()> proc);
void registerActionSync(QAction* tar, std::function<bool()> proc);
void registerAutoRun(std::function<bool()> judge, std::function<void(bool)> exec);
Run* registerManualRun(std::function<bool()> judge, std::function<void (bool)> exec);
void sync();
private:
QHash<QWidget*, std::function<bool()>> widget_trigger_map;
QHash<QAction*, std::function<bool()>> action_trigger_map;
QList<Run*> alltriggers;
};
2022-11-06 00:37:50 +00:00
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget *parent = nullptr);
~MainWindow();
void contentViewAppend(QWidget *widget, const QString &name);
2022-11-15 08:07:02 +00:00
private:
Core::AppCore *const app_core;
2022-11-18 23:47:32 +00:00
StatusSyncCore *const sync_kernel;
2022-11-15 08:07:02 +00:00
QSplitter *const horizontal_split;
QSplitter *const vertical_split;
QTabWidget *const left_funcs;
QTabWidget *const right_funcs;
QTabWidget *const center_funcs;
QTabWidget *const bottom_funcs;
Project::ProjectManager *const project_manager;
QListView *const current_projects;
2022-11-18 23:47:32 +00:00
Components::ProjectView *const project_structure;
2022-11-18 05:43:27 +00:00
Components::StoryChainsPresent *const chains_view;
2022-11-18 23:47:32 +00:00
Components::StoryUnitsPresent *const units_view;
Components::MessagePresent *const errors_present;
2022-11-25 01:18:54 +00:00
Components::StoryBoardsPresent *const boards_view;
2022-11-29 03:47:12 +00:00
Components::StoryConceptsPresent *const concept_view;
2022-11-15 12:58:12 +00:00
// 内部逻辑 ===========================================
void build_internal(bool all_from_disk = false);
2022-11-18 23:47:32 +00:00
void toggle_widget_visible(bool visible, QTabWidget *con, QWidget *target, const QString& title=QString());
void splitter_layout_save(const QList<QString> &path_type, const QList<int> &size);
void uilayout_save();
void uilayout_load();
// QWidget interface
protected:
virtual void closeEvent(QCloseEvent *event) override;
2022-11-18 23:47:32 +00:00
// QObject interface
public:
virtual bool eventFilter(QObject *watched, QEvent *event) override;
2022-11-06 00:37:50 +00:00
};
#endif // MAINWINDOW_H