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
|
#pragma once
#include <QMainWindow>
#include "ui_base_window.h"
class App;
class BaseWindow : public QMainWindow
{
public:
/*
* Constructs a MainWindow object.
*
* type is a string used in the window's title.
* n is a node which this window depends on:
* If this is a script window, it's the script's parent node
* If this is a canvas or viewport, it's the parent node of the
* target subgraph (or NULL if we're using the root graph)
*/
explicit BaseWindow(QString type);
virtual ~BaseWindow();
/*
* On close attempt, check to see if this is the last window
*/
void closeEvent(QCloseEvent *event) override;
public slots:
/*
* Adjusts the window's title based on filename
*/
void setFilename(QString file);
/*
* Sets the nested subgraph name
*/
void setSub(QString s);
/*
* Adjusts the window's title based on whether the file has been saved
*/
void setClean(bool changed);
/*
* Closes the window if there are no unsaved changes; asks otherwise
*/
void tryClose();
/*
* Returns true if the window should close (either because there are other
* windows open, there aren't unsaved changes, or the user accepts)
*/
bool askClose();
protected:
/*
* Connects menu actions to App slots.
*/
void connectActions(App* app);
/*
* Sets up main keyboard shortcuts
* (because Qt Designer doesn't have a good way to do so)
*/
void setShortcuts();
/*
* Changes the window's title based on filename, type, unsaved
*/
void updateTitle();
QString window_type;
QString filename="";
QString sub="";
bool clean=true;
QScopedPointer<Ui::BaseWindow> ui;
/* Global count of windows (used to warn when last closes) */
static int window_count;
};
|