icon change EDockWidget improvements EMainWindow small refactoring Graphic now remember last loaded graphics style and restore it on setGraphicsCount
152 lines
4.2 KiB
C++
152 lines
4.2 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 "qad_application_export.h"
|
|
#include "ribbon.h"
|
|
#include "session_manager.h"
|
|
|
|
#include <QClipboard>
|
|
#include <QColorDialog>
|
|
#include <QInputDialog>
|
|
#include <QRadioButton>
|
|
#include <QSplitter>
|
|
#include <QThread>
|
|
#include <QTime>
|
|
#include <QTranslator>
|
|
#include <QUrl>
|
|
|
|
|
|
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; }
|
|
bool isChanged() const { return is_changed; }
|
|
|
|
protected:
|
|
void showEvent(QShowEvent *) override;
|
|
void closeEvent(QCloseEvent *) override;
|
|
bool eventFilter(QObject * o, QEvent * e) override;
|
|
void changeEvent(QEvent * e) override;
|
|
QMenu * createPopupMenu() override;
|
|
|
|
void saveSession();
|
|
void loadSession();
|
|
void setChanged(bool yes = true);
|
|
void addToRecent(const QString & path);
|
|
|
|
virtual void loadingSession(QPIConfig & conf) {}
|
|
virtual void savingSession(QPIConfig & conf) {}
|
|
virtual QSize dockTabsIconSize() const { return iconSize(); }
|
|
virtual QString loadFilter() { return "All files(*)"; }
|
|
virtual QString saveFilter() { return "All files(*)"; }
|
|
|
|
SessionManager session;
|
|
QString file_name;
|
|
|
|
private:
|
|
void prepareRecent();
|
|
|
|
bool checkSave();
|
|
|
|
void initMenus();
|
|
void initDocks();
|
|
void initSession();
|
|
|
|
QAction action_show_all_tools, action_hide_all_tools, action_show_all_docks, action_hide_all_docks;
|
|
QList<QTabBar *> tbars;
|
|
QList<QDockWidget *> tdocks;
|
|
QList<QAction *> actions_recent;
|
|
QAction * action_clear_recent;
|
|
QMenu * menu_recent;
|
|
bool is_changed;
|
|
int max_recent;
|
|
|
|
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();
|
|
|
|
private slots:
|
|
void changedDock();
|
|
void closeDock(int index);
|
|
void recentTriggered();
|
|
|
|
signals:
|
|
};
|
|
|
|
#endif // MAINWINDOW_H
|