Merge pull request #699 from opentx/dvogonen/cleaning_up_code

Cleaned up the action definitions in Companion.
This commit is contained in:
Kjell Kernen
2014-02-13 22:15:56 +01:00
2 changed files with 170 additions and 354 deletions
+141 -328
View File
@@ -118,12 +118,13 @@ MainWindow::MainWindow():
} }
restoreGeometry(settings.value("mainWindowGeometry").toByteArray()); restoreGeometry(settings.value("mainWindowGeometry").toByteArray());
createActions(); createActions();
createMenus(); createMenus();
createToolBars(); createToolBars();
createStatusBar(); createStatusBar();
updateMenus(); updateMenus();
readSettings(); readSettings();
setUnifiedTitleAndToolBarOnMac(true); setUnifiedTitleAndToolBarOnMac(true);
this->setWindowIcon(QIcon(":/icon.png")); this->setWindowIcon(QIcon(":/icon.png"));
this->setIconSize(QSize(32,32)); this->setIconSize(QSize(32,32));
@@ -681,7 +682,7 @@ void MainWindow::newFile()
child->show(); child->show();
} }
void MainWindow::openDocumentURL() void MainWindow::openDocURL()
{ {
QString link = "http://www.open-tx.org/documents.html"; QString link = "http://www.open-tx.org/documents.html";
QDesktopServices::openUrl(QUrl(link)); QDesktopServices::openUrl(QUrl(link));
@@ -788,14 +789,14 @@ void MainWindow::loadProfile()
} }
} }
void MainWindow::appPreferences() void MainWindow::appPrefs()
{ {
appPreferencesDialog *pd = new appPreferencesDialog(this); appPreferencesDialog *pd = new appPreferencesDialog(this);
pd->exec(); pd->exec();
updateMenus(); updateMenus();
} }
void MainWindow::fwPreferences() void MainWindow::fwPrefs()
{ {
fwPreferencesDialog *pd = new fwPreferencesDialog(this); fwPreferencesDialog *pd = new fwPreferencesDialog(this);
pd->exec(); pd->exec();
@@ -1123,7 +1124,7 @@ void MainWindow::burnFrom()
} }
} }
void MainWindow::burnExtenalToEEPROM() void MainWindow::burnExtToEEPROM()
{ {
QSettings settings; QSettings settings;
QString fileName; QString fileName;
@@ -1476,7 +1477,7 @@ void MainWindow::burnToFlash(QString fileToFlash)
} }
} }
void MainWindow::burnExtenalFromEEPROM() void MainWindow::burnExtFromEEPROM()
{ {
QSettings settings; QSettings settings;
QString fileName = QFileDialog::getSaveFileName(this, tr("Save transmitter Models and Settings to File"), settings.value("lastDir").toString(), tr(EXTERNAL_EEPROM_FILES_FILTER)); QString fileName = QFileDialog::getSaveFileName(this, tr("Save transmitter Models and Settings to File"), settings.value("lastDir").toString(), tr(EXTERNAL_EEPROM_FILES_FILTER));
@@ -1615,152 +1616,39 @@ MdiChild *MainWindow::createMdiChild()
return child; return child;
} }
QAction * MainWindow::addAct(QString icon, QString sName, QString lName, QKeySequence::StandardKey shortcut, const char *slot)
{
QAction * newAction = new QAction( this );
if (!icon.isEmpty())
newAction->setIcon(CompanionIcon(icon));
if (!sName.isEmpty())
newAction->setText(sName);
if (!lName.isEmpty())
newAction->setStatusTip(lName);
if (shortcut != 0)
newAction->setShortcuts(shortcut);
connect(newAction, SIGNAL(triggered()), this, slot);
return newAction;
}
QAction * MainWindow::addAct(QString icon, QString sName, QString lName, const char *slot)
{
return addAct(icon, sName, lName, QKeySequence::UnknownKey, slot);
}
QAction * MainWindow::addAct(QActionGroup *aGroup, QString sName, QString lName, const char *slot)
{
QAction *action = addAct("", sName, lName, QKeySequence::UnknownKey, slot);
action->setCheckable(true);
aGroup->addAction(action);
return action;
}
void MainWindow::createActions() void MainWindow::createActions()
{ {
newAct = new QAction(CompanionIcon("new.png"), tr("&New"), this);
newAct->setShortcuts(QKeySequence::New);
newAct->setStatusTip(tr("Create a new file"));
connect(newAct, SIGNAL(triggered()), this, SLOT(newFile()));
openAct = new QAction(CompanionIcon("open.png"), tr("&Open..."), this);
openAct->setShortcuts(QKeySequence::Open);
openAct->setStatusTip(tr("Open an existing file"));
connect(openAct, SIGNAL(triggered()), this, SLOT(openFile()));
loadbackupAct = new QAction(CompanionIcon("open.png"), tr("&loadBackup..."), this);
loadbackupAct->setStatusTip(tr("Load backup from file"));
connect(loadbackupAct, SIGNAL(triggered()), this, SLOT(loadBackup()));
saveAct = new QAction(CompanionIcon("save.png"), tr("&Save"), this);
saveAct->setShortcuts(QKeySequence::Save);
saveAct->setStatusTip(tr("Save the document to disk"));
connect(saveAct, SIGNAL(triggered()), this, SLOT(save()));
saveAsAct = new QAction(CompanionIcon("saveas.png"), tr("Save &As..."), this);
saveAsAct->setShortcuts(QKeySequence::SaveAs);
saveAsAct->setStatusTip(tr("Save the document under a new name"));
connect(saveAsAct, SIGNAL(triggered()), this, SLOT(saveAs()));
logsAct = new QAction(CompanionIcon("logs.png"), tr("Lo&gs"), this);
logsAct->setShortcut(tr("Ctrl+G"));
logsAct->setStatusTip(tr("Open log file"));
connect(logsAct, SIGNAL(triggered()), this, SLOT(logFile()));
appPreferencesAct = new QAction(CompanionIcon("apppreferences.png"), tr("&Setting..."), this);
appPreferencesAct->setStatusTip(tr("Edit Settings"));
connect(appPreferencesAct, SIGNAL(triggered()), this, SLOT(appPreferences()));
fwPreferencesAct = new QAction(CompanionIcon("fwpreferences.png"), tr("&Downloads..."), this);
fwPreferencesAct->setStatusTip(tr("Download firmware and voice files"));
connect(fwPreferencesAct, SIGNAL(triggered()), this, SLOT(fwPreferences()));
checkForUpdatesAct = new QAction(CompanionIcon("update.png"), tr("&Check for updates..."), this);
checkForUpdatesAct->setStatusTip(tr("Check for new version of Companion"));
connect(checkForUpdatesAct, SIGNAL(triggered()), this, SLOT(doUpdates()));
contributorsAct = new QAction(CompanionIcon("contributors.png"), tr("Contributors &List..."), this);
contributorsAct->setStatusTip(tr("Show Companion contributors list"));
connect(contributorsAct, SIGNAL(triggered()), this, SLOT(contributors()));
changelogAct = new QAction(CompanionIcon("changelog.png"), tr("ChangeLog..."), this);
changelogAct->setStatusTip(tr("Show Companion changelog"));
connect(changelogAct, SIGNAL(triggered()), this, SLOT(changelog()));
fwchangelogAct = new QAction(CompanionIcon("changelog.png"), tr("Firmware ChangeLog..."), this);
fwchangelogAct->setStatusTip(tr("Show firmware changelog"));
connect(fwchangelogAct, SIGNAL(triggered()), this, SLOT(fwchangelog()));
compareAct = new QAction(CompanionIcon("compare.png"), tr("Compare..."), this);
compareAct->setStatusTip(tr("Compare models"));
compareAct->setEnabled(false);
connect(compareAct, SIGNAL(triggered()), this, SLOT(compare()));
customizeSplashAct = new QAction(CompanionIcon("paintbrush.png"), tr("Configure transmitter start screen..."), this);
customizeSplashAct->setStatusTip(tr("Customize the splash screen of your TX"));
connect(customizeSplashAct, SIGNAL(triggered()), this, SLOT(customizeSplash()));
exitAct = new QAction(CompanionIcon("exit.png"), tr("E&xit"), this);
exitAct->setShortcuts(QKeySequence::Quit);
exitAct->setStatusTip(tr("Exit the application"));
connect(exitAct, SIGNAL(triggered()), qApp, SLOT(closeAllWindows()));
cutAct = new QAction(CompanionIcon("cut.png"), tr("Cu&t"), this);
cutAct->setShortcuts(QKeySequence::Cut);
cutAct->setStatusTip(tr("Cut the current selection's contents to the "
"clipboard"));
connect(cutAct, SIGNAL(triggered()), this, SLOT(cut()));
copyAct = new QAction(CompanionIcon("copy.png"), tr("&Copy"), this);
copyAct->setShortcuts(QKeySequence::Copy);
copyAct->setStatusTip(tr("Copy the current selection's contents to the "
"clipboard"));
connect(copyAct, SIGNAL(triggered()), this, SLOT(copy()));
pasteAct = new QAction(CompanionIcon("paste.png"), tr("&Paste"), this);
pasteAct->setShortcuts(QKeySequence::Paste);
pasteAct->setStatusTip(tr("Paste the clipboard's contents into the current "
"selection"));
connect(pasteAct, SIGNAL(triggered()), this, SLOT(paste()));
burnToAct = new QAction(CompanionIcon("write_eeprom.png"), tr("&Write Models and Settings To Tx"), this);
burnToAct->setShortcut(tr("Ctrl+Alt+W"));
burnToAct->setStatusTip(tr("Write Models and Settings to transmitter"));
connect(burnToAct,SIGNAL(triggered()),this,SLOT(burnTo()));
burnFromAct = new QAction(CompanionIcon("read_eeprom.png"), tr("&Read Models and Settings From Tx"), this);
burnFromAct->setShortcut(tr("Ctrl+Alt+R"));
burnFromAct->setStatusTip(tr("Read Models and Settings from transmitter"));
connect(burnFromAct,SIGNAL(triggered()),this,SLOT(burnFrom()));
burnToFlashAct = new QAction(CompanionIcon("write_flash.png"), tr("Write Firmware"), this);
burnToFlashAct->setStatusTip(tr("Write firmware to transmitter"));
connect(burnToFlashAct,SIGNAL(triggered()),this,SLOT(burnToFlash()));
burnExtenalToEEPROMAct = new QAction(CompanionIcon("write_eeprom_file.png"), tr("Write Models and Settings from file to Tx"), this);
burnExtenalToEEPROMAct->setStatusTip(tr("Write Models and Settings from file to transmitter"));
connect(burnExtenalToEEPROMAct,SIGNAL(triggered()),this,SLOT(burnExtenalToEEPROM()));
burnExtenalFromEEPROMAct = new QAction(CompanionIcon("read_eeprom_file.png"), tr("Save transmitter Models and Settings to file"), this);
burnExtenalFromEEPROMAct->setStatusTip(tr("Save the Models and Settings from the transmitter to a file"));
connect(burnExtenalFromEEPROMAct,SIGNAL(triggered()),this,SLOT(burnExtenalFromEEPROM()));
burnFromFlashAct = new QAction(CompanionIcon("read_flash.png"), tr("Read Firmware"), this);
burnFromFlashAct->setStatusTip(tr("Read firmware from transmitter"));
connect(burnFromFlashAct,SIGNAL(triggered()),this,SLOT(burnFromFlash()));
burnConfigAct = new QAction(CompanionIcon("configure.png"), tr("&Configure connection software..."), this);
burnConfigAct->setStatusTip(tr("Configure software for reading from and writing to the transmitter"));
connect(burnConfigAct,SIGNAL(triggered()),this,SLOT(burnConfig()));
EEPROMInterface *eepromInterface = GetEepromInterface();
if (!IS_ARM(eepromInterface->getBoard())) {
burnListAct = new QAction(CompanionIcon("list.png"), tr("&List programmers"), this);
burnListAct->setStatusTip(tr("List available programmers"));
connect(burnListAct,SIGNAL(triggered()),this,SLOT(burnList()));
burnFusesAct = new QAction(CompanionIcon("fuses.png"), tr("&Fuses..."), this);
burnFusesAct->setStatusTip(tr("Show fuses dialog"));
connect(burnFusesAct,SIGNAL(triggered()),this,SLOT(burnFuses()));
}
simulateAct = new QAction(CompanionIcon("simulate.png"), tr("&Simulate"), this);
simulateAct->setShortcut(tr("Alt+S"));
simulateAct->setStatusTip(tr("Simulate selected model."));
simulateAct->setEnabled(false);
connect(simulateAct,SIGNAL(triggered()),this,SLOT(simulate()));
printAct = new QAction(CompanionIcon("print.png"), tr("&Print"), this);
printAct->setShortcut(tr("Ctrl+P"));
printAct->setStatusTip(tr("Print current model."));
printAct->setEnabled(false);
connect(printAct,SIGNAL(triggered()),this,SLOT(print()));
separatorAct = new QAction(this); separatorAct = new QAction(this);
separatorAct->setSeparator(true); separatorAct->setSeparator(true);
aboutAct = new QAction(CompanionIcon("information.png"), tr("&About"), this);
aboutAct->setStatusTip(tr("Show the application's About box"));
connect(aboutAct, SIGNAL(triggered()), this, SLOT(about()));
for (int i = 0; i < MaxRecentFiles; ++i) { for (int i = 0; i < MaxRecentFiles; ++i) {
recentFileActs[i] = new QAction(this); recentFileActs[i] = new QAction(this);
recentFileActs[i]->setVisible(false); recentFileActs[i]->setVisible(false);
@@ -1769,7 +1657,6 @@ void MainWindow::createActions()
updateRecentFileActions(); updateRecentFileActions();
QActionGroup *profilesAlignmentGroup = new QActionGroup(this); QActionGroup *profilesAlignmentGroup = new QActionGroup(this);
for (int i=0; i<MAX_PROFILES; i++) { for (int i=0; i<MAX_PROFILES; i++) {
profileActs[i] = new QAction(this); profileActs[i] = new QAction(this);
profileActs[i]->setVisible(false); profileActs[i]->setVisible(false);
@@ -1778,142 +1665,70 @@ void MainWindow::createActions()
connect(profileActs[i], SIGNAL(triggered()), this, SLOT(loadProfile())); connect(profileActs[i], SIGNAL(triggered()), this, SLOT(loadProfile()));
} }
updateProfilesActions(); updateProfilesActions();
createProfileAct = new QAction(tr("New Profile"), this);
createProfileAct->setStatusTip(tr("Create a new Radio Setting Profile"));
connect(createProfileAct, SIGNAL(triggered()), this, SLOT(createProfile()));
QActionGroup *themeAlignmentGroup = new QActionGroup(this); newAct = addAct("new.png", tr("New"), tr("Create a new file"), QKeySequence::New, SLOT(newFile()));
openAct = addAct("open.png", tr("Open..."), tr("Open an existing file"), QKeySequence::Open, SLOT(openFile()));
saveAct = addAct("save.png", tr("Save..."), tr("Save the document to disk"), QKeySequence::Save, SLOT(save()));
saveAsAct = addAct("saveas.png", tr("Save As..."), tr("Save the document to disk"), QKeySequence::SaveAs, SLOT(saveAs()));
exitAct = addAct("exit.png", tr("Exit"), tr("Exit the application"), QKeySequence::Quit, SLOT(newFile()));
cutAct = addAct("cut.png", tr("Cut"), tr("Cut current selection to the clipboard"), QKeySequence::Cut, SLOT(cut()));
copyAct = addAct("copy.png", tr("Copy..."), tr("Copy current selection to the clipboard"), QKeySequence::Copy, SLOT(copy()));
pasteAct = addAct("paste.png", tr("Paste..."), tr("Paste clipboard into current selection"), QKeySequence::Paste, SLOT(paste()));
QActionGroup *themeAlignGroup = new QActionGroup(this);
classicThemeAct = addAct( themeAlignGroup, tr("Classical"), tr("The classical Companion icon theme"), SLOT(setClassicTheme()));
newThemeAct = addAct( themeAlignGroup, tr("New"), tr("The new Companion 2 icon theme"), SLOT(setNewTheme()));
monoThemeAct = addAct( themeAlignGroup, tr("Monochrome"), tr("A monochrome black icon theme"), SLOT(setMonochromeTheme()));
monoWhiteAct = addAct( themeAlignGroup, tr("MonoWhite"), tr("A monochrome white icon theme"), SLOT(setMonoWhiteTheme()));
monoBlueAct = addAct( themeAlignGroup, tr("MonoBlue"), tr("A monochrome blue icon theme"), SLOT(setMonoBlueTheme()));
classicThemeAct = new QAction(tr("Classical"), this); QActionGroup *iconAlignGroup = new QActionGroup(this);
classicThemeAct->setCheckable(true); smallIconAct = addAct( iconAlignGroup, tr("Small"), tr("Use small toolbar icons"), SLOT(setSmallIconThemeSize()));
classicThemeAct->setStatusTip(tr("The classical Companion icon theme")); normalIconAct = addAct( iconAlignGroup, tr("Normal"), tr("Use normal size toolbar icons"), SLOT(setNormalIconThemeSize()));
themeAlignmentGroup->addAction(classicThemeAct); bigIconAct = addAct( iconAlignGroup, tr("Big"), tr("Use big toolbar icons"), SLOT(setBigIconThemeSize()));
connect(classicThemeAct, SIGNAL(triggered()), this, SLOT(setClassicTheme())); hugeIconAct = addAct( iconAlignGroup, tr("Huge"), tr("Use huge toolbar icons"), SLOT(setHugeIconThemeSize()));
newThemeAct = new QAction(tr("New"), this); QActionGroup *langAlignGroup = new QActionGroup(this);
newThemeAct->setCheckable(true); sysLangAct = addAct( langAlignGroup, tr("System language"), tr("Use system language in menus"), SLOT(setSysLanguage()));
newThemeAct->setStatusTip(tr("The Companion 2.0 colored icon theme")); czechLangAct = addAct( langAlignGroup, tr("Czech"), tr("Use Czech in menus"), SLOT(setCZLanguage()));
themeAlignmentGroup->addAction(newThemeAct); germanLangAct = addAct( langAlignGroup, tr("German"), tr("Use German in menus"), SLOT(setDELanguage()));
connect(newThemeAct, SIGNAL(triggered()), this, SLOT(setNewTheme())); englishLangAct = addAct( langAlignGroup, tr("English"), tr("Use English in menus"), SLOT(setENLanguage()));
frenchLangAct = addAct( langAlignGroup, tr("French"), tr("Use French in menus"), SLOT(setFRLanguage()));
italianLangAct = addAct( langAlignGroup, tr("Italian"), tr("Use Italian in menus"), SLOT(setITLanguage()));
hebrewLangAct = addAct( langAlignGroup, tr("Hebrew"), tr("Use Hebrew in menus"), SLOT(setHELanguage()));
polishLangAct = addAct( langAlignGroup, tr("Polish"), tr("Use Polish in menus"), SLOT(setPLLanguage()));
portugueseLangAct = addAct( langAlignGroup, tr("Portuguese"), tr("Use Portuguese in menus"), SLOT(setPTLanguage()));
swedishLangAct = addAct( langAlignGroup, tr("Swedish"), tr("Use Swedish in menus"), SLOT(setSELanguage()));
russianLangAct = addAct( langAlignGroup, tr("Russian"), tr("Use Russian in menus"), SLOT(setRULanguage()));
monoThemeAct = new QAction("Monochrome",this); aboutAct = addAct("information.png", tr("About"), tr("Show the application's About box"), SLOT(about()));
monoThemeAct->setCheckable(true); printAct = addAct("print.png", tr("Print"), tr("Print current model"), SLOT(print()));
monoThemeAct->setStatusTip(tr("A monochrome black icon theme")); simulateAct = addAct("simulate.png", tr("Simulate"), tr("Simulate selected model"), SLOT(simulate()));
themeAlignmentGroup->addAction(monoThemeAct); loadbackupAct = addAct("open.png", tr("loadBackup..."), tr("Load backup from file"), SLOT(loadBackup()));
connect(monoThemeAct, SIGNAL(triggered()), this, SLOT(setMonochromeTheme())); logsAct = addAct("logs.png", tr("Logs"), tr("Open log file"), SLOT(logFile()));
appPrefsAct = addAct("apppreferences.png",tr("Setting..."), tr("Edit Settings"), SLOT(appPrefs()));
monoWhiteThemeAct = new QAction("MonoWhite",this); fwPrefsAct = addAct("fwpreferences.png", tr("Downloads..."), tr("Download firmware and voice files"), SLOT(fwPrefs()));
monoWhiteThemeAct->setCheckable(true); checkForUpdatesAct = addAct("update.png", tr("Check for updates..."), tr("Check for new version of Companion"), SLOT(doUpdates()));
monoWhiteThemeAct->setStatusTip(tr("A monochrome white icon theme")); changelogAct = addAct("changelog.png", tr("ChangeLog..."), tr("Show Companion changelog"), SLOT(changelog()));
themeAlignmentGroup->addAction(monoWhiteThemeAct); fwchangelogAct = addAct("changelog.png", tr("Firmware ChangeLog..."), tr("Show firmware changelog"), SLOT(fwchangelog()));
connect(monoWhiteThemeAct, SIGNAL(triggered()), this, SLOT(setMonoWhiteTheme())); compareAct = addAct("compare.png", tr("Compare..."), tr("Compare models"), SLOT(compare()));
editSplashAct = addAct("paintbrush.png", tr("Edit Tx Splash Image..."),tr("edit the splash screen of your TX"), SLOT(customizeSplash()));
monoBlueThemeAct = new QAction("MonoBlue",this); burnListAct = addAct("list.png", tr("List programmers"), tr("List available programmers"), SLOT(burnList()));
monoBlueThemeAct->setCheckable(true); burnFusesAct = addAct("fuses.png", tr("Fuses..."), tr("Show fuses dialog"), SLOT(burnFuses()));
monoBlueThemeAct->setStatusTip(tr("A monochrome blue icon theme")); burnFromFlashAct = addAct("read_flash.png", tr("Read Firmware"), tr("Read firmware from transmitter"), SLOT(burnFromFlash()));
themeAlignmentGroup->addAction(monoBlueThemeAct); burnToFlashAct = addAct("write_flash.png", tr("Write Firmware"), tr("Write firmware to transmitter"), SLOT(burnToFlash()));
connect(monoBlueThemeAct, SIGNAL(triggered()), this, SLOT(setMonoBlueTheme())); createProfileAct = addAct("", tr("New Profile"), tr("Create a new Radio Setting Profile"), SLOT(createProfile()));
openDocURLAct = addAct("", tr("Manuals and other Documents"), tr("Open the OpenTX document page in a web browser"), SLOT(openDocURL()));
QActionGroup *iconAlignmentGroup = new QActionGroup(this); burnToAct = addAct("write_eeprom.png", tr("Write Models and Settings To Tx"), tr("Write Models and Settings to transmitter"), SLOT(burnTo()));
burnFromAct = addAct("read_eeprom.png", tr("Read Models and Settings From Tx"), tr("Read Models and Settings from transmitter"), SLOT(burnFrom()));
smallIconAct = new QAction(tr("Small"),this); burnConfigAct = addAct("configure.png", tr("Configure connection software..."), tr("Configure software for reading from and writing to the transmitter"), SLOT(burnConfig()));
smallIconAct->setStatusTip(tr("Use small toolbar icons")); burnExtToEEPROMAct = addAct("write_eeprom_file.png", tr("Write Models and Settings from file to Tx"), tr("Write Models and Settings from file to transmitter"), SLOT(burnExtToEEPROM()));
smallIconAct->setCheckable(true); burnExtFromEEPROMAct = addAct("read_eeprom_file.png", tr("Save Tx Models and Settings to file"), tr("Save the Models and Settings from the transmitter to a file"), SLOT(burnExtFromEEPROM()));
iconAlignmentGroup->addAction(smallIconAct); contributorsAct = addAct("contributors.png", tr("Contributors"), tr("A tribute to those who have contributed to OpenTX and Companion"), SLOT(contributors()));
connect(smallIconAct, SIGNAL(triggered()), this, SLOT(setSmallIconThemeSize()));
compareAct->setEnabled(false);
normalIconAct = new QAction(this); simulateAct->setEnabled(false);
normalIconAct->setStatusTip(tr("Use normal size toolbar icons")); printAct->setEnabled(false);
normalIconAct->setText(tr("Normal"));
normalIconAct->setCheckable(true);
iconAlignmentGroup->addAction(normalIconAct);
connect(normalIconAct, SIGNAL(triggered()), this, SLOT(setNormalIconThemeSize()));
bigIconAct = new QAction(this);
bigIconAct->setStatusTip(tr("Use big toolbar icons"));
bigIconAct->setText(tr("Big"));
bigIconAct->setCheckable(true);
iconAlignmentGroup->addAction(bigIconAct);
connect(bigIconAct, SIGNAL(triggered()), this, SLOT(setBigIconThemeSize()));
hugeIconAct = new QAction(this);
hugeIconAct->setStatusTip(tr("Use huge toolbar icons"));
hugeIconAct->setText(tr("Huge"));
hugeIconAct->setCheckable(true);
iconAlignmentGroup->addAction(hugeIconAct);
connect(hugeIconAct, SIGNAL(triggered()), this, SLOT(setHugeIconThemeSize()));
QActionGroup *languageAlignmentGroup = new QActionGroup(this);
defaultLanguageAct = new QAction(tr("System default language"),this);
defaultLanguageAct->setStatusTip(tr("Use system default language in menus"));
defaultLanguageAct->setCheckable(true);
languageAlignmentGroup->addAction(defaultLanguageAct);
connect(defaultLanguageAct, SIGNAL(triggered()), this, SLOT(setDefaultLanguage()));
czechLanguageAct = new QAction(tr("Czech"),this);
czechLanguageAct->setStatusTip(tr("Use Czech in menus"));
czechLanguageAct->setCheckable(true);
languageAlignmentGroup->addAction(czechLanguageAct);
connect(czechLanguageAct, SIGNAL(triggered()), this, SLOT(setCZLanguage()));
germanLanguageAct = new QAction(tr("German"),this);
germanLanguageAct->setStatusTip(tr("Use German in menus"));
germanLanguageAct->setCheckable(true);
languageAlignmentGroup->addAction(germanLanguageAct);
connect(germanLanguageAct, SIGNAL(triggered()), this, SLOT(setDELanguage()));
englishLanguageAct = new QAction(tr("English"),this);
englishLanguageAct->setStatusTip(tr("Use English in menus"));
englishLanguageAct->setCheckable(true);
languageAlignmentGroup->addAction(englishLanguageAct);
connect(englishLanguageAct, SIGNAL(triggered()), this, SLOT(setENLanguage()));
frenchLanguageAct = new QAction(tr("French"),this);
frenchLanguageAct->setStatusTip(tr("Use French in menus"));
frenchLanguageAct->setCheckable(true);
languageAlignmentGroup->addAction(frenchLanguageAct);
connect(frenchLanguageAct, SIGNAL(triggered()), this, SLOT(setFRLanguage()));
italianLanguageAct = new QAction(tr("Italian"),this);
italianLanguageAct->setStatusTip(tr("Use Italian in menus"));
italianLanguageAct->setCheckable(true);
languageAlignmentGroup->addAction(italianLanguageAct);
connect(italianLanguageAct, SIGNAL(triggered()), this, SLOT(setITLanguage()));
hebrewLanguageAct = new QAction(tr("Hebrew"),this);
hebrewLanguageAct->setStatusTip(tr("Use Hebrew in menus"));
hebrewLanguageAct->setCheckable(true);
languageAlignmentGroup->addAction(hebrewLanguageAct);
connect(hebrewLanguageAct, SIGNAL(triggered()), this, SLOT(setHELanguage()));
polishLanguageAct = new QAction(tr("Polish"),this);
polishLanguageAct->setStatusTip(tr("Use Polish in menus"));
polishLanguageAct->setCheckable(true);
languageAlignmentGroup->addAction(polishLanguageAct);
connect(polishLanguageAct, SIGNAL(triggered()), this, SLOT(setPLLanguage()));
portugueseLanguageAct = new QAction(tr("Portuguese"),this);
portugueseLanguageAct->setStatusTip(tr("Use Portuguese in menus"));
portugueseLanguageAct->setCheckable(true);
languageAlignmentGroup->addAction(portugueseLanguageAct);
connect(portugueseLanguageAct, SIGNAL(triggered()), this, SLOT(setPTLanguage()));
swedishLanguageAct = new QAction(tr("Swedish"),this);
swedishLanguageAct->setStatusTip(tr("Use Swedish in menus"));
swedishLanguageAct->setCheckable(true);
languageAlignmentGroup->addAction(swedishLanguageAct);
connect(swedishLanguageAct, SIGNAL(triggered()), this, SLOT(setSELanguage()));
russianLanguageAct = new QAction(tr("Russian"),this);
russianLanguageAct->setStatusTip(tr("Use Russian in menus"));
russianLanguageAct->setCheckable(true);
languageAlignmentGroup->addAction(russianLanguageAct);
connect(russianLanguageAct, SIGNAL(triggered()), this, SLOT(setRULanguage()));
openDocumentURLAct = new QAction(tr("Manuals and other Documents"),this);
openDocumentURLAct->setStatusTip(tr("Open the OpenTX document page in a web browser"));
connect(openDocumentURLAct, SIGNAL(triggered()), this, SLOT(openDocumentURL()));
} }
void MainWindow::createMenus() void MainWindow::createMenus()
@@ -1923,8 +1738,8 @@ void MainWindow::createMenus()
QMenu *languageMenu=new QMenu(tr("Set Menu Language")); QMenu *languageMenu=new QMenu(tr("Set Menu Language"));
QMenu *themeMenu=new QMenu(tr("Set Icon Theme")); QMenu *themeMenu=new QMenu(tr("Set Icon Theme"));
QMenu *iconThemeSizeMenu=new QMenu(tr("Set Icon Size")); QMenu *iconThemeSizeMenu=new QMenu(tr("Set Icon Size"));
fileMenu = menuBar()->addMenu(tr("&File")); fileMenu = menuBar()->addMenu(tr("File"));
fileMenu->addAction(newAct); fileMenu->addAction(newAct);
fileMenu->addAction(openAct); fileMenu->addAction(openAct);
fileMenu->addAction(saveAct); fileMenu->addAction(saveAct);
@@ -1940,52 +1755,51 @@ void MainWindow::createMenus()
fileMenu->addAction(printAct); fileMenu->addAction(printAct);
fileMenu->addAction(compareAct); fileMenu->addAction(compareAct);
fileMenu->addSeparator(); fileMenu->addSeparator();
fileMenu->addAction(fwPreferencesAct); fileMenu->addAction(fwPrefsAct);
fileMenu->addMenu(createProfilesMenu()); fileMenu->addMenu(createProfilesMenu());
fileMenu->addAction(exitAct); fileMenu->addAction(exitAct);
editMenu = menuBar()->addMenu(tr("&Edit")); editMenu = menuBar()->addMenu(tr("Edit"));
editMenu->addAction(cutAct); editMenu->addAction(cutAct);
editMenu->addAction(copyAct); editMenu->addAction(copyAct);
editMenu->addAction(pasteAct); editMenu->addAction(pasteAct);
settingsMenu = menuBar()->addMenu(tr("&Settings")); settingsMenu = menuBar()->addMenu(tr("Settings"));
settingsMenu->addMenu(languageMenu); settingsMenu->addMenu(languageMenu);
languageMenu->addAction(defaultLanguageAct); languageMenu->addAction(sysLangAct);
languageMenu->addAction(englishLanguageAct); languageMenu->addAction(englishLangAct);
languageMenu->addAction(czechLanguageAct); languageMenu->addAction(czechLangAct);
languageMenu->addAction(germanLanguageAct); languageMenu->addAction(germanLangAct);
languageMenu->addAction(frenchLanguageAct); languageMenu->addAction(frenchLangAct);
languageMenu->addAction(hebrewLanguageAct); languageMenu->addAction(hebrewLangAct);
languageMenu->addAction(italianLanguageAct); languageMenu->addAction(italianLangAct);
languageMenu->addAction(polishLanguageAct); languageMenu->addAction(polishLangAct);
languageMenu->addAction(portugueseLanguageAct); languageMenu->addAction(portugueseLangAct);
languageMenu->addAction(swedishLanguageAct); languageMenu->addAction(swedishLangAct);
languageMenu->addAction(russianLanguageAct); languageMenu->addAction(russianLangAct);
settingsMenu->addMenu(themeMenu); settingsMenu->addMenu(themeMenu);
themeMenu->addAction(classicThemeAct); themeMenu->addAction(classicThemeAct);
themeMenu->addAction(newThemeAct); themeMenu->addAction(newThemeAct);
themeMenu->addAction(monoThemeAct); themeMenu->addAction(monoThemeAct);
themeMenu->addAction(monoBlueThemeAct); themeMenu->addAction(monoBlueAct);
themeMenu->addAction(monoWhiteThemeAct); themeMenu->addAction(monoWhiteAct);
settingsMenu->addMenu(iconThemeSizeMenu); settingsMenu->addMenu(iconThemeSizeMenu);
iconThemeSizeMenu->addAction(smallIconAct); iconThemeSizeMenu->addAction(smallIconAct);
iconThemeSizeMenu->addAction(normalIconAct); iconThemeSizeMenu->addAction(normalIconAct);
iconThemeSizeMenu->addAction(bigIconAct); iconThemeSizeMenu->addAction(bigIconAct);
iconThemeSizeMenu->addAction(hugeIconAct); iconThemeSizeMenu->addAction(hugeIconAct);
settingsMenu->addSeparator(); settingsMenu->addSeparator();
settingsMenu->addAction(appPreferencesAct); settingsMenu->addAction(appPrefsAct);
settingsMenu->addAction(customizeSplashAct); settingsMenu->addAction(editSplashAct);
settingsMenu->addAction(burnConfigAct); settingsMenu->addAction(burnConfigAct);
burnMenu = menuBar()->addMenu(tr("&Read/Write")); burnMenu = menuBar()->addMenu(tr("Read/Write"));
burnMenu->addAction(burnToAct); burnMenu->addAction(burnToAct);
burnMenu->addAction(burnFromAct); burnMenu->addAction(burnFromAct);
burnMenu->addSeparator(); burnMenu->addSeparator();
burnMenu->addAction(burnExtenalToEEPROMAct); burnMenu->addAction(burnExtToEEPROMAct);
burnMenu->addAction(burnExtenalFromEEPROMAct); burnMenu->addAction(burnExtFromEEPROMAct);
burnMenu->addSeparator(); burnMenu->addSeparator();
burnMenu->addAction(burnToFlashAct); burnMenu->addAction(burnToFlashAct);
burnMenu->addAction(burnFromFlashAct); burnMenu->addAction(burnFromFlashAct);
@@ -1997,13 +1811,12 @@ void MainWindow::createMenus()
burnMenu->addAction(burnListAct); burnMenu->addAction(burnListAct);
} }
menuBar()->addSeparator(); menuBar()->addSeparator();
helpMenu = menuBar()->addMenu(tr("Help"));
helpMenu = menuBar()->addMenu(tr("&Help"));
helpMenu->addSeparator(); helpMenu->addSeparator();
helpMenu->addAction(checkForUpdatesAct); helpMenu->addAction(checkForUpdatesAct);
helpMenu->addSeparator(); helpMenu->addSeparator();
helpMenu->addAction(aboutAct); helpMenu->addAction(aboutAct);
helpMenu->addAction(openDocumentURLAct); helpMenu->addAction(openDocURLAct);
helpMenu->addSeparator(); helpMenu->addSeparator();
helpMenu->addAction(changelogAct); helpMenu->addAction(changelogAct);
helpMenu->addAction(fwchangelogAct); helpMenu->addAction(fwchangelogAct);
@@ -2069,9 +1882,9 @@ void MainWindow::createToolBars()
fileToolBar->addAction(saveAct); fileToolBar->addAction(saveAct);
fileToolBar->addAction(logsAct); fileToolBar->addAction(logsAct);
fileToolBar->addSeparator(); fileToolBar->addSeparator();
fileToolBar->addAction(appPreferencesAct); fileToolBar->addAction(appPrefsAct);
fileToolBar->addAction(fwPreferencesAct); fileToolBar->addAction(fwPrefsAct);
fileToolBar->addAction(customizeSplashAct); fileToolBar->addAction(editSplashAct);
profileButton = new QToolButton; profileButton = new QToolButton;
profileButton->setPopupMode(QToolButton::InstantPopup); profileButton->setPopupMode(QToolButton::InstantPopup);
profileButton->setMenu(createProfilesMenu()); profileButton->setMenu(createProfilesMenu());
@@ -2097,8 +1910,8 @@ void MainWindow::createToolBars()
burnToolBar->addAction(burnToAct); burnToolBar->addAction(burnToAct);
burnToolBar->addAction(burnFromAct); burnToolBar->addAction(burnFromAct);
burnToolBar->addSeparator(); burnToolBar->addSeparator();
burnToolBar->addAction(burnExtenalToEEPROMAct); burnToolBar->addAction(burnExtToEEPROMAct);
burnToolBar->addAction(burnExtenalFromEEPROMAct); burnToolBar->addAction(burnExtFromEEPROMAct);
burnToolBar->addSeparator(); burnToolBar->addSeparator();
burnToolBar->addAction(burnToFlashAct); burnToolBar->addAction(burnToFlashAct);
burnToolBar->addAction(burnFromFlashAct); burnToolBar->addAction(burnFromFlashAct);
@@ -2193,27 +2006,27 @@ void MainWindow::updateLanguageActions()
QString langId = settings.value("locale","").toString(); QString langId = settings.value("locale","").toString();
if (langId=="") if (langId=="")
defaultLanguageAct->setChecked(true); sysLangAct->setChecked(true);
else if (langId=="cs_CZ") else if (langId=="cs_CZ")
czechLanguageAct->setChecked(true); czechLangAct->setChecked(true);
else if (langId=="de_DE") else if (langId=="de_DE")
germanLanguageAct->setChecked(true); germanLangAct->setChecked(true);
else if (langId=="en") else if (langId=="en")
englishLanguageAct->setChecked(true); englishLangAct->setChecked(true);
else if (langId=="fr_FR") else if (langId=="fr_FR")
frenchLanguageAct->setChecked(true); frenchLangAct->setChecked(true);
else if (langId=="it_IT") else if (langId=="it_IT")
italianLanguageAct->setChecked(true); italianLangAct->setChecked(true);
else if (langId=="he_IL") else if (langId=="he_IL")
hebrewLanguageAct->setChecked(true); hebrewLangAct->setChecked(true);
else if (langId=="pl_PL") else if (langId=="pl_PL")
polishLanguageAct->setChecked(true); polishLangAct->setChecked(true);
else if (langId=="pt_PT") else if (langId=="pt_PT")
portugueseLanguageAct->setChecked(true); portugueseLangAct->setChecked(true);
else if (langId=="ru_RU") else if (langId=="ru_RU")
russianLanguageAct->setChecked(true); russianLangAct->setChecked(true);
else if (langId=="sv_SE") else if (langId=="sv_SE")
swedishLanguageAct->setChecked(true); swedishLangAct->setChecked(true);
} }
void MainWindow::updateIconThemeActions() void MainWindow::updateIconThemeActions()
@@ -2221,11 +2034,11 @@ void MainWindow::updateIconThemeActions()
QSettings settings; QSettings settings;
int size = settings.value("theme","1").toInt(); int size = settings.value("theme","1").toInt();
switch (size){ switch (size){
case 0: classicThemeAct->setChecked(true); break; case 0: classicThemeAct->setChecked(true); break;
case 1: newThemeAct->setChecked(true); break; case 1: newThemeAct->setChecked(true); break;
case 2: monoWhiteThemeAct->setChecked(true); break; case 2: monoWhiteAct->setChecked(true); break;
case 3: monoThemeAct->setChecked(true); break; case 3: monoThemeAct->setChecked(true); break;
case 4: monoBlueThemeAct->setChecked(true); break; case 4: monoBlueAct->setChecked(true); break;
} }
} }
+29 -26
View File
@@ -81,10 +81,10 @@ public slots:
void downloadLatestFW(FirmwareInfo *firmware, const QString & firmwareId); void downloadLatestFW(FirmwareInfo *firmware, const QString & firmwareId);
private slots: private slots:
void openDocumentURL(); void openDocURL();
void setLanguage(QString langString); void setLanguage(QString langString);
void setDefaultLanguage() {setLanguage("");}; void setSysLanguage() {setLanguage("");};
void setCZLanguage() {setLanguage("cs_CZ");}; void setCZLanguage() {setLanguage("cs_CZ");};
void setDELanguage() {setLanguage("de_DE");}; void setDELanguage() {setLanguage("de_DE");};
void setENLanguage() {setLanguage("en");}; void setENLanguage() {setLanguage("en");};
@@ -131,8 +131,8 @@ private slots:
void burnFrom(); void burnFrom();
void burnToFlash(QString fileToFlash=""); void burnToFlash(QString fileToFlash="");
void burnFromFlash(); void burnFromFlash();
void burnExtenalToEEPROM(); void burnExtToEEPROM();
void burnExtenalFromEEPROM(); void burnExtFromEEPROM();
void burnConfig(); void burnConfig();
void burnList(); void burnList();
void burnFuses(); void burnFuses();
@@ -145,8 +145,8 @@ private slots:
void compare(); void compare();
void print(); void print();
void loadBackup(); void loadBackup();
void appPreferences(); void appPrefs();
void fwPreferences(); void fwPrefs();
void updateMenus(); void updateMenus();
void createProfile(); void createProfile();
MdiChild *createMdiChild(); MdiChild *createMdiChild();
@@ -157,6 +157,10 @@ private slots:
private: private:
void createActions(); void createActions();
QAction * addAct(QString, QString, QString, QKeySequence::StandardKey, const char *);
QAction * addAct(QActionGroup *, QString, QString, const char *);
QAction * addAct(QString, QString, QString, const char *);
void createMenus(); void createMenus();
void createToolBars(); void createToolBars();
void createStatusBar(); void createStatusBar();
@@ -201,7 +205,6 @@ private:
bool needRename; bool needRename;
bool showcheckForUpdatesResult; bool showcheckForUpdatesResult;
int MaxRecentFiles; int MaxRecentFiles;
// int ActiveProfile;
int currentFWrev; int currentFWrev;
int currentFWrev_temp; int currentFWrev_temp;
int NewFwRev; int NewFwRev;
@@ -226,14 +229,14 @@ private:
QAction *saveAct; QAction *saveAct;
QAction *saveAsAct; QAction *saveAsAct;
QAction *exitAct; QAction *exitAct;
QAction *appPreferencesAct; QAction *appPrefsAct;
QAction *fwPreferencesAct; QAction *fwPrefsAct;
QAction *checkForUpdatesAct; QAction *checkForUpdatesAct;
QAction *contributorsAct; QAction *contributorsAct;
QAction *changelogAct; QAction *changelogAct;
QAction *fwchangelogAct; QAction *fwchangelogAct;
QAction *compareAct; QAction *compareAct;
QAction *customizeSplashAct; QAction *editSplashAct;
QAction *cutAct; QAction *cutAct;
QAction *copyAct; QAction *copyAct;
QAction *pasteAct; QAction *pasteAct;
@@ -244,8 +247,8 @@ private:
QAction *burnFusesAct; QAction *burnFusesAct;
QAction *burnToFlashAct; QAction *burnToFlashAct;
QAction *burnFromFlashAct; QAction *burnFromFlashAct;
QAction *burnExtenalToEEPROMAct; QAction *burnExtToEEPROMAct;
QAction *burnExtenalFromEEPROMAct; QAction *burnExtFromEEPROMAct;
QAction *simulateAct; QAction *simulateAct;
QAction *separatorAct; QAction *separatorAct;
QAction *aboutAct; QAction *aboutAct;
@@ -258,24 +261,24 @@ private:
QAction *classicThemeAct; QAction *classicThemeAct;
QAction *newThemeAct; QAction *newThemeAct;
QAction *monoThemeAct; QAction *monoThemeAct;
QAction *monoBlueThemeAct; QAction *monoBlueAct;
QAction *monoWhiteThemeAct; QAction *monoWhiteAct;
QAction *smallIconAct; QAction *smallIconAct;
QAction *normalIconAct; QAction *normalIconAct;
QAction *bigIconAct; QAction *bigIconAct;
QAction *hugeIconAct; QAction *hugeIconAct;
QAction *defaultLanguageAct; QAction *sysLangAct;
QAction *englishLanguageAct; QAction *englishLangAct;
QAction *czechLanguageAct; QAction *czechLangAct;
QAction *germanLanguageAct; QAction *germanLangAct;
QAction *frenchLanguageAct; QAction *frenchLangAct;
QAction *italianLanguageAct; QAction *italianLangAct;
QAction *hebrewLanguageAct; QAction *hebrewLangAct;
QAction *polishLanguageAct; QAction *polishLangAct;
QAction *portugueseLanguageAct; QAction *portugueseLangAct;
QAction *swedishLanguageAct; QAction *swedishLangAct;
QAction *russianLanguageAct; QAction *russianLangAct;
QAction *openDocumentURLAct; QAction *openDocURLAct;
QString fwToUpdate; QString fwToUpdate;
QToolButton * profileButton; QToolButton * profileButton;
}; };