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>
|
2022-11-17 08:16:54 +00:00
|
|
|
#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"
|
2022-11-17 08:16:54 +00:00
|
|
|
#include "projectview.h"
|
2022-11-22 03:42:48 +00:00
|
|
|
#include "ContentPresent.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();
|
2022-11-11 14:38:52 +00:00
|
|
|
|
2022-11-15 08:07:02 +00:00
|
|
|
private:
|
2022-11-22 03:42:48 +00:00
|
|
|
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;
|
2022-11-17 08:16:54 +00:00
|
|
|
|
2022-11-22 03:42:48 +00:00
|
|
|
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;
|
2022-11-17 08:16:54 +00:00
|
|
|
Components::MessagePresent *const errors_present;
|
|
|
|
|
2022-11-15 12:58:12 +00:00
|
|
|
// 内部逻辑 ===========================================
|
2022-11-17 08:16:54 +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());
|
|
|
|
|
2022-11-22 03:42:48 +00:00
|
|
|
void splitter_layout_save(const QList<QString> &path_type, const QList<int> &size);
|
|
|
|
|
|
|
|
void uilayout_save();
|
|
|
|
void uilayout_load();
|
|
|
|
|
2022-11-17 08:16:54 +00:00
|
|
|
// 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
|