Important! All QtWraps macros renamed! Qt 6 support Graphic export feature qad_types cross-Qt small changes
150 lines
4.4 KiB
C++
150 lines
4.4 KiB
C++
/*
|
|
QAD - Qt ADvanced
|
|
|
|
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU Lesser General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU Lesser General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Lesser General Public License
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#ifndef EMAINWINDOW_H
|
|
#define EMAINWINDOW_H
|
|
|
|
#include <QTranslator>
|
|
#include <QUrl>
|
|
#include <QInputDialog>
|
|
#include <QClipboard>
|
|
#include <QRadioButton>
|
|
#include <QThread>
|
|
#include <QColorDialog>
|
|
#include <QTime>
|
|
#include <QSplitter>
|
|
#include "session_manager.h"
|
|
#include "ribbon.h"
|
|
#include "qad_application_export.h"
|
|
|
|
|
|
class QAD_APPLICATION_EXPORT 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 QAD_APPLICATION_EXPORT 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);
|
|
void changeEvent(QEvent * 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);
|
|
bool saveFile() {return saveFile(false);}
|
|
bool saveAsFile();
|
|
void clearRecent();
|
|
|
|
signals:
|
|
|
|
};
|
|
|
|
#endif // MAINWINDOW_H
|