128 lines
3.6 KiB
C++
128 lines
3.6 KiB
C++
#ifndef EMAINWINDOW_H
|
|
#define EMAINWINDOW_H
|
|
|
|
#include <QTranslator>
|
|
#include <QUrl>
|
|
#include <QDesktopWidget>
|
|
#include <QInputDialog>
|
|
#include <QClipboard>
|
|
#include <QRadioButton>
|
|
#include <QThread>
|
|
#include <QColorDialog>
|
|
#include <QTime>
|
|
#include <QSplitter>
|
|
#include "session_manager.h"
|
|
#include "ribbon.h"
|
|
|
|
class UAction: public QAction {
|
|
Q_OBJECT
|
|
public:
|
|
UAction(int ind,const QString & text, QObject * parent): QAction(text, parent) {
|
|
index = ind;
|
|
connect(this, SIGNAL(triggered()), this, SLOT(triggered()));
|
|
connect(this, SIGNAL(toggled(bool)), this, SLOT(toggled(bool)));
|
|
connect(this, SIGNAL(hovered()), this, SLOT(hovered()));
|
|
}
|
|
UAction(int ind, const QIcon & icon, const QString & text, QObject * parent): QAction(icon, text, parent) {
|
|
index = ind;
|
|
connect(this, SIGNAL(triggered()), this, SLOT(triggered()));
|
|
connect(this, SIGNAL(toggled(bool)), this, SLOT(toggled(bool)));
|
|
connect(this, SIGNAL(hovered()), this, SLOT(hovered()));
|
|
}
|
|
public slots:
|
|
void show() {setVisible(true);}
|
|
void hide() {setVisible(false);}
|
|
void setCheckedTrue() {setChecked(true);}
|
|
void setCheckedFalse() {setChecked(false);}
|
|
private:
|
|
int index;
|
|
private slots:
|
|
void triggered() {emit itriggered(this, index);}
|
|
void toggled(bool t) {emit itoggled(t, this, index);}
|
|
void hovered() {emit ihovered(this);}
|
|
signals:
|
|
void itriggered(QAction *, int);
|
|
void itoggled(bool, QAction *, int);
|
|
void ihovered(QAction * action);
|
|
};
|
|
|
|
|
|
class EMainWindow: public QMainWindow
|
|
{
|
|
Q_OBJECT
|
|
Q_PROPERTY(int maxRecentItems READ maxRecentItems WRITE setMaxRecentItems)
|
|
public:
|
|
EMainWindow(QWidget * parent = 0);
|
|
~EMainWindow();
|
|
|
|
virtual void reset(bool full = false) {}
|
|
virtual bool load(const QString & path) {return true;}
|
|
virtual bool save(const QString & path) {return true;}
|
|
|
|
void addSeparator() {}
|
|
void setRecentFiles(const QStringList & rl);
|
|
QStringList recentFiles() const;
|
|
void setRecentMenu(QMenu * m);
|
|
|
|
int maxRecentItems() const {return max_recent;}
|
|
|
|
protected:
|
|
// Qt`s overloaded
|
|
void showEvent(QShowEvent * );
|
|
void closeEvent(QCloseEvent * );
|
|
bool eventFilter(QObject * o, QEvent * e);
|
|
void timerEvent(QTimerEvent * e);
|
|
QMenu * createPopupMenu();
|
|
void addToRecent(const QString & path);
|
|
void prepareRecent();
|
|
|
|
void init(const QString & config) {session.setFile(config); initMenus(); initSession(); loadSession();} // unusable
|
|
void saveSession();
|
|
void loadSession();
|
|
virtual void savingSession(QPIConfig & conf) {}
|
|
virtual void loadingSession(QPIConfig & conf) {}
|
|
virtual QSize dockTabsIconSize() const {return iconSize();}
|
|
virtual QString loadFilter() {return "All files(*)";}
|
|
virtual QString saveFilter() {return "All files(*)";}
|
|
|
|
bool checkSave();
|
|
void setChanged(bool yes = true) {isChanged = yes; setWindowModified(yes);}
|
|
|
|
void initMenus();
|
|
void initSession();
|
|
|
|
QAction action_show_all_tools, action_hide_all_tools, action_show_all_docks, action_hide_all_docks;
|
|
QString file_name;
|
|
QList<QTabBar * > tbars;
|
|
QList<QDockWidget * > tdocks;
|
|
QList<QAction * > actions_recent;
|
|
QAction * action_clear_recent;
|
|
QMenu * menu_recent;
|
|
SessionManager session;
|
|
bool isChanged, first_show;
|
|
int tid, max_recent;
|
|
|
|
private slots:
|
|
void changedDock();
|
|
void sessionLoading(QPIConfig & conf) {loadingSession(conf);}
|
|
void sessionSaving(QPIConfig & conf) {savingSession(conf);}
|
|
// void changedDockClose(QObject * dock);
|
|
void closeDock(int index);
|
|
void recentTriggered();
|
|
|
|
public slots:
|
|
void setMaxRecentItems(int mr);
|
|
void changed() {setChanged(true);}
|
|
void newFile();
|
|
void openFile();
|
|
void openFiles();
|
|
bool saveFile(bool ask = false);
|
|
bool saveAsFile();
|
|
void clearRecent();
|
|
|
|
signals:
|
|
|
|
};
|
|
|
|
#endif // MAINWINDOW_H
|