1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168
|
#pragma once
#include <QMainWindow>
#include <QTabBar>
#include <QStackedWidget>
#include "../../SyntopiaCore/GLEngine/EngineWidget.h"
#include "../../SyntopiaCore/Misc/Version.h"
#include "VariableEditor.h"
#include "TemplateExportDialog.h"
#include "../Model/Rendering/TemplateRenderer.h"
class QAction;
class QMenu;
class QTextEdit;
namespace StructureSynth {
namespace GUI {
struct TabInfo {
TabInfo() {};
TabInfo(QString filename, QTextEdit* textEdit) : filename(filename), unsaved(false), textEdit(textEdit), hasBeenSavedOnce(false) {};
TabInfo(QString filename, QTextEdit* textEdit, bool unsaved, bool hasBeenSavedOnce=false) : filename(filename), unsaved(unsaved), textEdit(textEdit), hasBeenSavedOnce(hasBeenSavedOnce) {};
QString filename;
bool unsaved;
QTextEdit* textEdit;
bool hasBeenSavedOnce;
};
/// The main window of the application.
/// As of now a SDI interface, but at some point tabs will be added.
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow();
MainWindow(const QString &fileName);
void setSeed(int randomSeed);
int getSeed();
void templateRender(const QString& fileName, Model::Rendering::Template* myTemplate, int width = 0, int height = 0, bool postModify = false);
static QString getExamplesDir();
static QString getMiscDir();
static QString getTemplateDir();
protected:
void dragEnterEvent(QDragEnterEvent *ev);
void dropEvent(QDropEvent *ev);
void closeEvent(QCloseEvent* ev);
void keyReleaseEvent(QKeyEvent* ev);
private slots:
void templateExport();
void closeTab(int id);
void cut();
void copy();
void paste();
void insertCameraSettings();
void cursorPositionChanged();
void seedChanged();
void tabChanged(int index);
void makeScreenshot();
void closeTab();
void launchSfHome();
void fastRotateChanged();
void launchGallery();
void launchReferenceHome();
void templateRender();
void templateRenderToFile();
void templateRender(const QString& fileName);
void openFile();
void newFile();
void open();
bool save();
bool saveAs();
void about();
void documentWasModified();
void render();
void resetView();
void toggleFullScreen();
private:
void setRecentFile(const QString &fileName);
void parseEaster(QString text);
void parseJavaScript(QString scripture);
void insertTabPage(QString filename);
QTextEdit* getTextEdit();
void init();
void createActions();
void createMenus();
void createToolBars();
void createStatusBar();
void readSettings();
void writeSettings();
void updateRandom();
void loadFile(const QString &fileName);
bool saveFile(const QString &fileName);
QString strippedName(const QString &fullFileName);
void createOpenGLContextMenu();
bool hasBeenResized;
QSpinBox* seedSpinBox;
QCheckBox* autoIncrementCheckbox;
QDockWidget* dockLog;
QAction* fullScreenAction;
QAction* insertCameraSettingsAction;
QAction* screenshotAction;
QAction* sfHomeAction;
QAction* referenceAction;
QAction* galleryAction;
QMenu *fileMenu;
QMenu *editMenu;
QMenu *renderMenu;
QMenu *helpMenu;
QToolBar *fileToolBar;
QToolBar *renderToolBar;
QToolBar *editToolBar;
QToolBar *randomToolBar;
QAction *newAction;
QAction *openAction;
QAction *saveAction;
QAction *saveAsAction;
QAction *closeAction;
QAction *exitAction;
QAction *cutAction;
QAction *copyAction;
QAction *pasteAction;
QAction *aboutAction;
QAction *renderAction;
QAction *exportAction;
QAction *panicAction;
SyntopiaCore::GLEngine::EngineWidget* engine;
QTabBar* tabBar;
SyntopiaCore::Misc::Version version;
QMenu* openGLContextMenu;
bool fullScreenEnabled;
QStackedWidget *stackedTextEdits;
QVector<TabInfo> tabInfo;
int oldDirtyPosition;
QVBoxLayout* frameMainWindow;
QCheckBox* fastRotateCheckbox;
VariableEditor* variableEditor;
QDockWidget* editorDockWidget;
QVector<QAction*> recentFileActions;
QAction* recentFileSeparator;
};
}
}
|