* [Companion] Refactor MdiChild & TreeModel, restore drag/drop, and more:
* Add full drag-and-drop functions to the models list, including model copy, move, and insert actions (also between windows);
* Add general radio settings copy/paste across file windows;
* Full MIME support with distinct types for various data (eg. models vs. general settings), also add new type for metadata (header);
* Copied/cut models can now be inserted in any spot (similar to drop-insert);
* Deleted/cut models can now be removed entirely (including the empty slot) for all radio types (any models after the removed one move up, like for Horus) (may need to make this an option);
* Empty model slots can now also be removed (any models after the removed slot move up) (but total # of slots is still maintained);
* Default model can be deleted (new default is picked);
* Completely revamp the actions system (copy/paste/edit/etc) to make it fully functional:
* Actions exist in the window, not just context menu, therefore all keyboard shortcuts actually work, w/out any duplicated code;
* Provides access from MainWindow in a comprehensive manner: all actions are available and properly updated based on selections in current editor window, w/out awkward event monitoring;
* More actions available from context menu, and somewhat reorganized;
* Also show all actions on mini toolbars right in the MDI window (possibly make optional later);
* Updated English localization file to account for plurals usage in new action item names (other languages need to be updated);
* Keyboard navigation in the model list now works/practical;
* MDI window uses all available height by default;
* Newly added models/categories are selected and highlighted; Category names are immediately editable; Model editor is/can be launched if wizard is not (need to make option);
* MainWindow updates:
* Edit toolbar and menu now showing all available edit actions, with proper context;
* File menu properly updates with all "general" radio actions: edit/copy/paste settings and simulate radio;
* Added Windows menu showing list of open windows (eg. to switch when full screen) and tabbed window option (need to make persistent setting);
* Immediate update of icon size preference;
* Do not delete toolbars when re-translating UI (they don't lose assigned position);
* [Companion] Restore model compare functionality by using new MIME data exchange system; Add ability to compare any number of models at a time; Multi-model printer now shows custom hardware settings for each dropped model (even from different radios).
* [Companion] Add missing monoblue & monowhite theme sdsync icons.
* [Companion] Model wizard starts with default model name populated.
* [Companion] Properly re-translate UI instead of recreating all the actions/etc.; Tell Mac specifically where to put our actions (seems to make it happier too).
* [Companion] Further improve handling of Window menu items/detection of sub-window changes.
* [Companion] Add file-close action.
* [Companion] Add user options and save preferences:
* Option to use wizard, open editor, or do nothing on new model creation;
* Option to remove empty model slots when deleting/moving models (in non-Horus radios);
* Options to hide toolbars in document windows (r-click on TBs);
* Save/restore size of document windows, and maximized/tabbed state;
* Save/restore size/position of model compare window;
* Add shortcuts for model compare, FW download, log viewer;
* [Companion] Disable being able to "delete" empty model slots (more awkward than helpful).
229 lines
6.3 KiB
C++
229 lines
6.3 KiB
C++
/*
|
|
* Copyright (C) OpenTX
|
|
*
|
|
* Based on code named
|
|
* th9x - http://code.google.com/p/th9x
|
|
* er9x - http://code.google.com/p/er9x
|
|
* gruvin9x - http://code.google.com/p/gruvin9x
|
|
*
|
|
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
* published by the Free Software Foundation.
|
|
*
|
|
* 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 General Public License for more details.
|
|
*/
|
|
|
|
#ifndef _MAINWINDOW_H_
|
|
#define _MAINWINDOW_H_
|
|
|
|
#include <QtWidgets>
|
|
#include <QDateTime>
|
|
#include "downloaddialog.h"
|
|
#include "eeprominterface.h"
|
|
|
|
#define SPLASH_TIME 5
|
|
|
|
class MdiChild;
|
|
QT_BEGIN_NAMESPACE
|
|
class QAction;
|
|
class QMenu;
|
|
class QMdiArea;
|
|
class QMdiSubWindow;
|
|
class QSignalMapper;
|
|
QT_END_NAMESPACE
|
|
|
|
#define CHECK_COMPANION 1
|
|
#define CHECK_FIRMWARE 2
|
|
#define SHOW_DIALOG_WAIT 4
|
|
#define AUTOMATIC_DOWNLOAD 8
|
|
|
|
class MainWindow : public QMainWindow
|
|
{
|
|
friend class FirmwarePreferencesDialog;
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
MainWindow();
|
|
~MainWindow();
|
|
|
|
signals:
|
|
void firmwareChanged();
|
|
|
|
protected:
|
|
QString getCompanionUpdateBaseUrl();
|
|
QString seekCodeString(const QByteArray & qba, const QString & label);
|
|
|
|
protected slots:
|
|
void dowloadLastFirmwareUpdate();
|
|
void startFirmwareDownload();
|
|
virtual void closeEvent(QCloseEvent *event);
|
|
virtual void changeEvent(QEvent *e);
|
|
virtual void dragEnterEvent(QDragEnterEvent *event);
|
|
virtual void dropEvent(QDropEvent *event);
|
|
|
|
private slots:
|
|
void openDocURL();
|
|
void retranslateUi(bool showMsg = false);
|
|
|
|
void setLanguage(const QString & langString);
|
|
void onLanguageChanged(QAction * act);
|
|
void setTheme(int index);
|
|
void onThemeChanged(QAction * act);
|
|
void setIconThemeSize(int index);
|
|
void onIconSizeChanged(QAction * act);
|
|
void setTabbedWindows(bool on);
|
|
void onChangeWindowAction(QAction * act);
|
|
void updateWindowActions();
|
|
void updateWindowActionTitle(const QMdiSubWindow * win, QAction * act = NULL);
|
|
void onSubwindowTitleChanged();
|
|
void onSubwindowModified();
|
|
|
|
void checkForUpdates();
|
|
void checkForFirmwareUpdate();
|
|
|
|
void checkForCompanionUpdateFinished(QNetworkReply * reply);
|
|
void checkForFirmwareUpdateFinished(QNetworkReply * reply);
|
|
|
|
void displayWarnings();
|
|
void doAutoUpdates();
|
|
void doUpdates();
|
|
void updateDownloaded();
|
|
void firmwareDownloadAccepted();
|
|
void newFile();
|
|
void openFile();
|
|
void save();
|
|
void saveAs();
|
|
void closeFile();
|
|
void openRecentFile();
|
|
void loadProfileId(const unsigned pid);
|
|
void loadProfile();
|
|
void logFile();
|
|
void writeEeprom();
|
|
void readEeprom();
|
|
void writeFlash(QString fileToFlash="");
|
|
void readFlash();
|
|
void writeBackup();
|
|
void readBackup();
|
|
void burnConfig();
|
|
void burnList();
|
|
void burnFuses();
|
|
void contributors();
|
|
void sdsync();
|
|
void changelog();
|
|
void fwchangelog();
|
|
void customizeSplash();
|
|
void about();
|
|
void compare();
|
|
void appPrefs();
|
|
void fwPrefs();
|
|
void updateMenus();
|
|
void createProfile();
|
|
void copyProfile();
|
|
void deleteProfile(const int pid);
|
|
void deleteCurrentProfile();
|
|
void autoClose();
|
|
|
|
void closeUpdatesWaitDialog();
|
|
void onUpdatesError();
|
|
void openFile(const QString & fileName, bool updateLastUsedDir = false);
|
|
|
|
private:
|
|
QAction * addAct(const QString & icon, const char * slot = NULL, const QKeySequence & shortcut = 0, QObject * slotObj = NULL, const char * signal = NULL);
|
|
QAction * addActToGroup(QActionGroup * aGroup, const QString & sName, const QString & lName, const char * propName = 0,
|
|
const QVariant & propValue = QVariant(), const QVariant & dfltValue = QVariant(), const QKeySequence & shortcut = 0);
|
|
void trAct(QAction * act, const QString & text, const QString & descript);
|
|
|
|
QMenu * createLanguageMenu(QWidget * parent = Q_NULLPTR);
|
|
|
|
void createActions();
|
|
void createMenus();
|
|
void createToolBars();
|
|
void showReadyStatus();
|
|
void updateRecentFileActions();
|
|
void updateProfilesActions();
|
|
|
|
int newProfile(bool loadProfile = true);
|
|
QString strippedName(const QString & fullFileName);
|
|
|
|
MdiChild * createMdiChild();
|
|
MdiChild * activeMdiChild();
|
|
QMdiSubWindow * findMdiChild(const QString & fileName);
|
|
|
|
bool readEepromFromRadio(const QString & filename);
|
|
bool readFirmwareFromRadio(const QString & filename);
|
|
|
|
QMdiArea *mdiArea;
|
|
QSignalMapper *windowMapper;
|
|
|
|
QString installer_fileName;
|
|
downloadDialog * downloadDialog_forWait;
|
|
unsigned int checkForUpdatesState;
|
|
QString firmwareVersionString;
|
|
|
|
QNetworkAccessManager *networkManager;
|
|
|
|
QVector<QAction *> recentFileActs;
|
|
QVector<QAction *> profileActs;
|
|
QList<QAction *> fileWindowActions;
|
|
|
|
QMenu *fileMenu;
|
|
QMenu *editMenu;
|
|
QMenu *settingsMenu;
|
|
QMenu *burnMenu;
|
|
QMenu *helpMenu;
|
|
QMenu *windowMenu;
|
|
QMenu *iconThemeSizeMenu;
|
|
QMenu *themeMenu;
|
|
QMenu *recentFilesMenu;
|
|
QMenu *profilesMenu;
|
|
QActionGroup * windowsListActions;
|
|
QToolBar *fileToolBar;
|
|
QToolBar *editToolBar;
|
|
QToolBar *burnToolBar;
|
|
QToolBar *helpToolBar;
|
|
QAction *newAct;
|
|
QAction *openAct;
|
|
QAction *saveAct;
|
|
QAction *saveAsAct;
|
|
QAction *closeAct;
|
|
QAction *recentFilesAct;
|
|
QAction *exitAct;
|
|
QAction *appPrefsAct;
|
|
QAction *fwPrefsAct;
|
|
QAction *checkForUpdatesAct;
|
|
QAction *contributorsAct;
|
|
QAction *sdsyncAct;
|
|
QAction *changelogAct;
|
|
QAction *fwchangelogAct;
|
|
QAction *compareAct;
|
|
QAction *editSplashAct;
|
|
QAction *writeEepromAct;
|
|
QAction *readEepromAct;
|
|
QAction *burnConfigAct;
|
|
QAction *burnListAct;
|
|
QAction *burnFusesAct;
|
|
QAction *writeFlashAct;
|
|
QAction *readFlashAct;
|
|
QAction *writeBUToRadioAct;
|
|
QAction *readBUToFileAct;
|
|
QAction *aboutAct;
|
|
QAction *logsAct;
|
|
QAction *profilesMenuAct;
|
|
QAction *createProfileAct;
|
|
QAction *copyProfileAct;
|
|
QAction *deleteProfileAct;
|
|
QAction *openDocURLAct;
|
|
QAction *actTabbedWindows;
|
|
QAction *actTileWindows;
|
|
QAction *actCascadeWindows;
|
|
QAction *actCloseAllWindows;
|
|
};
|
|
|
|
#endif // _MAINWINDOW_H_
|