From 3084ad12c5e8dbed86738a0377385fd42e3e19d3 Mon Sep 17 00:00:00 2001 From: Kjell Kernen Date: Thu, 13 Feb 2014 22:13:49 +0100 Subject: [PATCH] Cleaned up the action definitions. --- companion/src/mainwindow.cpp | 469 +++++++++++------------------------ companion/src/mainwindow.h | 55 ++-- 2 files changed, 170 insertions(+), 354 deletions(-) diff --git a/companion/src/mainwindow.cpp b/companion/src/mainwindow.cpp index 85eed8af1..fc4c4131a 100644 --- a/companion/src/mainwindow.cpp +++ b/companion/src/mainwindow.cpp @@ -118,12 +118,13 @@ MainWindow::MainWindow(): } restoreGeometry(settings.value("mainWindowGeometry").toByteArray()); createActions(); + createMenus(); createToolBars(); createStatusBar(); updateMenus(); - readSettings(); + setUnifiedTitleAndToolBarOnMac(true); this->setWindowIcon(QIcon(":/icon.png")); this->setIconSize(QSize(32,32)); @@ -681,7 +682,7 @@ void MainWindow::newFile() child->show(); } -void MainWindow::openDocumentURL() +void MainWindow::openDocURL() { QString link = "http://www.open-tx.org/documents.html"; QDesktopServices::openUrl(QUrl(link)); @@ -788,14 +789,14 @@ void MainWindow::loadProfile() } } -void MainWindow::appPreferences() +void MainWindow::appPrefs() { appPreferencesDialog *pd = new appPreferencesDialog(this); pd->exec(); updateMenus(); } -void MainWindow::fwPreferences() +void MainWindow::fwPrefs() { fwPreferencesDialog *pd = new fwPreferencesDialog(this); pd->exec(); @@ -1123,7 +1124,7 @@ void MainWindow::burnFrom() } } -void MainWindow::burnExtenalToEEPROM() +void MainWindow::burnExtToEEPROM() { QSettings settings; QString fileName; @@ -1476,7 +1477,7 @@ void MainWindow::burnToFlash(QString fileToFlash) } } -void MainWindow::burnExtenalFromEEPROM() +void MainWindow::burnExtFromEEPROM() { QSettings settings; 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; } +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() { - 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->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) { recentFileActs[i] = new QAction(this); recentFileActs[i]->setVisible(false); @@ -1769,7 +1657,6 @@ void MainWindow::createActions() updateRecentFileActions(); QActionGroup *profilesAlignmentGroup = new QActionGroup(this); - for (int i=0; isetVisible(false); @@ -1778,142 +1665,70 @@ void MainWindow::createActions() connect(profileActs[i], SIGNAL(triggered()), this, SLOT(loadProfile())); } 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); - classicThemeAct->setCheckable(true); - classicThemeAct->setStatusTip(tr("The classical Companion icon theme")); - themeAlignmentGroup->addAction(classicThemeAct); - connect(classicThemeAct, SIGNAL(triggered()), this, SLOT(setClassicTheme())); + QActionGroup *iconAlignGroup = new QActionGroup(this); + smallIconAct = addAct( iconAlignGroup, tr("Small"), tr("Use small toolbar icons"), SLOT(setSmallIconThemeSize())); + normalIconAct = addAct( iconAlignGroup, tr("Normal"), tr("Use normal size toolbar icons"), SLOT(setNormalIconThemeSize())); + bigIconAct = addAct( iconAlignGroup, tr("Big"), tr("Use big toolbar icons"), SLOT(setBigIconThemeSize())); + hugeIconAct = addAct( iconAlignGroup, tr("Huge"), tr("Use huge toolbar icons"), SLOT(setHugeIconThemeSize())); - newThemeAct = new QAction(tr("New"), this); - newThemeAct->setCheckable(true); - newThemeAct->setStatusTip(tr("The Companion 2.0 colored icon theme")); - themeAlignmentGroup->addAction(newThemeAct); - connect(newThemeAct, SIGNAL(triggered()), this, SLOT(setNewTheme())); + QActionGroup *langAlignGroup = new QActionGroup(this); + sysLangAct = addAct( langAlignGroup, tr("System language"), tr("Use system language in menus"), SLOT(setSysLanguage())); + czechLangAct = addAct( langAlignGroup, tr("Czech"), tr("Use Czech in menus"), SLOT(setCZLanguage())); + germanLangAct = addAct( langAlignGroup, tr("German"), tr("Use German in menus"), SLOT(setDELanguage())); + 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); - monoThemeAct->setCheckable(true); - monoThemeAct->setStatusTip(tr("A monochrome black icon theme")); - themeAlignmentGroup->addAction(monoThemeAct); - connect(monoThemeAct, SIGNAL(triggered()), this, SLOT(setMonochromeTheme())); - - monoWhiteThemeAct = new QAction("MonoWhite",this); - monoWhiteThemeAct->setCheckable(true); - monoWhiteThemeAct->setStatusTip(tr("A monochrome white icon theme")); - themeAlignmentGroup->addAction(monoWhiteThemeAct); - connect(monoWhiteThemeAct, SIGNAL(triggered()), this, SLOT(setMonoWhiteTheme())); - - monoBlueThemeAct = new QAction("MonoBlue",this); - monoBlueThemeAct->setCheckable(true); - monoBlueThemeAct->setStatusTip(tr("A monochrome blue icon theme")); - themeAlignmentGroup->addAction(monoBlueThemeAct); - connect(monoBlueThemeAct, SIGNAL(triggered()), this, SLOT(setMonoBlueTheme())); - - QActionGroup *iconAlignmentGroup = new QActionGroup(this); - - smallIconAct = new QAction(tr("Small"),this); - smallIconAct->setStatusTip(tr("Use small toolbar icons")); - smallIconAct->setCheckable(true); - iconAlignmentGroup->addAction(smallIconAct); - connect(smallIconAct, SIGNAL(triggered()), this, SLOT(setSmallIconThemeSize())); - - normalIconAct = new QAction(this); - normalIconAct->setStatusTip(tr("Use normal size toolbar icons")); - 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())); + aboutAct = addAct("information.png", tr("About"), tr("Show the application's About box"), SLOT(about())); + printAct = addAct("print.png", tr("Print"), tr("Print current model"), SLOT(print())); + simulateAct = addAct("simulate.png", tr("Simulate"), tr("Simulate selected model"), SLOT(simulate())); + loadbackupAct = addAct("open.png", tr("loadBackup..."), tr("Load backup from file"), SLOT(loadBackup())); + logsAct = addAct("logs.png", tr("Logs"), tr("Open log file"), SLOT(logFile())); + appPrefsAct = addAct("apppreferences.png",tr("Setting..."), tr("Edit Settings"), SLOT(appPrefs())); + fwPrefsAct = addAct("fwpreferences.png", tr("Downloads..."), tr("Download firmware and voice files"), SLOT(fwPrefs())); + checkForUpdatesAct = addAct("update.png", tr("Check for updates..."), tr("Check for new version of Companion"), SLOT(doUpdates())); + changelogAct = addAct("changelog.png", tr("ChangeLog..."), tr("Show Companion changelog"), SLOT(changelog())); + fwchangelogAct = addAct("changelog.png", tr("Firmware ChangeLog..."), tr("Show firmware changelog"), SLOT(fwchangelog())); + 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())); + burnListAct = addAct("list.png", tr("List programmers"), tr("List available programmers"), SLOT(burnList())); + burnFusesAct = addAct("fuses.png", tr("Fuses..."), tr("Show fuses dialog"), SLOT(burnFuses())); + burnFromFlashAct = addAct("read_flash.png", tr("Read Firmware"), tr("Read firmware from transmitter"), SLOT(burnFromFlash())); + burnToFlashAct = addAct("write_flash.png", tr("Write Firmware"), tr("Write firmware to transmitter"), SLOT(burnToFlash())); + 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())); + 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())); + burnConfigAct = addAct("configure.png", tr("Configure connection software..."), tr("Configure software for reading from and writing to the transmitter"), SLOT(burnConfig())); + 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())); + 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())); + contributorsAct = addAct("contributors.png", tr("Contributors"), tr("A tribute to those who have contributed to OpenTX and Companion"), SLOT(contributors())); + + compareAct->setEnabled(false); + simulateAct->setEnabled(false); + printAct->setEnabled(false); } void MainWindow::createMenus() @@ -1923,8 +1738,8 @@ void MainWindow::createMenus() QMenu *languageMenu=new QMenu(tr("Set Menu Language")); QMenu *themeMenu=new QMenu(tr("Set Icon Theme")); QMenu *iconThemeSizeMenu=new QMenu(tr("Set Icon Size")); - - fileMenu = menuBar()->addMenu(tr("&File")); + + fileMenu = menuBar()->addMenu(tr("File")); fileMenu->addAction(newAct); fileMenu->addAction(openAct); fileMenu->addAction(saveAct); @@ -1940,52 +1755,51 @@ void MainWindow::createMenus() fileMenu->addAction(printAct); fileMenu->addAction(compareAct); fileMenu->addSeparator(); - fileMenu->addAction(fwPreferencesAct); + fileMenu->addAction(fwPrefsAct); fileMenu->addMenu(createProfilesMenu()); fileMenu->addAction(exitAct); - editMenu = menuBar()->addMenu(tr("&Edit")); + editMenu = menuBar()->addMenu(tr("Edit")); editMenu->addAction(cutAct); editMenu->addAction(copyAct); editMenu->addAction(pasteAct); - settingsMenu = menuBar()->addMenu(tr("&Settings")); + settingsMenu = menuBar()->addMenu(tr("Settings")); settingsMenu->addMenu(languageMenu); - languageMenu->addAction(defaultLanguageAct); - languageMenu->addAction(englishLanguageAct); - languageMenu->addAction(czechLanguageAct); - languageMenu->addAction(germanLanguageAct); - languageMenu->addAction(frenchLanguageAct); - languageMenu->addAction(hebrewLanguageAct); - languageMenu->addAction(italianLanguageAct); - languageMenu->addAction(polishLanguageAct); - languageMenu->addAction(portugueseLanguageAct); - languageMenu->addAction(swedishLanguageAct); - languageMenu->addAction(russianLanguageAct); - + languageMenu->addAction(sysLangAct); + languageMenu->addAction(englishLangAct); + languageMenu->addAction(czechLangAct); + languageMenu->addAction(germanLangAct); + languageMenu->addAction(frenchLangAct); + languageMenu->addAction(hebrewLangAct); + languageMenu->addAction(italianLangAct); + languageMenu->addAction(polishLangAct); + languageMenu->addAction(portugueseLangAct); + languageMenu->addAction(swedishLangAct); + languageMenu->addAction(russianLangAct); settingsMenu->addMenu(themeMenu); themeMenu->addAction(classicThemeAct); themeMenu->addAction(newThemeAct); themeMenu->addAction(monoThemeAct); - themeMenu->addAction(monoBlueThemeAct); - themeMenu->addAction(monoWhiteThemeAct); + themeMenu->addAction(monoBlueAct); + themeMenu->addAction(monoWhiteAct); settingsMenu->addMenu(iconThemeSizeMenu); iconThemeSizeMenu->addAction(smallIconAct); iconThemeSizeMenu->addAction(normalIconAct); iconThemeSizeMenu->addAction(bigIconAct); iconThemeSizeMenu->addAction(hugeIconAct); settingsMenu->addSeparator(); - settingsMenu->addAction(appPreferencesAct); - settingsMenu->addAction(customizeSplashAct); + settingsMenu->addAction(appPrefsAct); + settingsMenu->addAction(editSplashAct); settingsMenu->addAction(burnConfigAct); - burnMenu = menuBar()->addMenu(tr("&Read/Write")); + burnMenu = menuBar()->addMenu(tr("Read/Write")); burnMenu->addAction(burnToAct); burnMenu->addAction(burnFromAct); burnMenu->addSeparator(); - burnMenu->addAction(burnExtenalToEEPROMAct); - burnMenu->addAction(burnExtenalFromEEPROMAct); + burnMenu->addAction(burnExtToEEPROMAct); + burnMenu->addAction(burnExtFromEEPROMAct); burnMenu->addSeparator(); burnMenu->addAction(burnToFlashAct); burnMenu->addAction(burnFromFlashAct); @@ -1997,13 +1811,12 @@ void MainWindow::createMenus() burnMenu->addAction(burnListAct); } menuBar()->addSeparator(); - - helpMenu = menuBar()->addMenu(tr("&Help")); + helpMenu = menuBar()->addMenu(tr("Help")); helpMenu->addSeparator(); helpMenu->addAction(checkForUpdatesAct); helpMenu->addSeparator(); helpMenu->addAction(aboutAct); - helpMenu->addAction(openDocumentURLAct); + helpMenu->addAction(openDocURLAct); helpMenu->addSeparator(); helpMenu->addAction(changelogAct); helpMenu->addAction(fwchangelogAct); @@ -2069,9 +1882,9 @@ void MainWindow::createToolBars() fileToolBar->addAction(saveAct); fileToolBar->addAction(logsAct); fileToolBar->addSeparator(); - fileToolBar->addAction(appPreferencesAct); - fileToolBar->addAction(fwPreferencesAct); - fileToolBar->addAction(customizeSplashAct); + fileToolBar->addAction(appPrefsAct); + fileToolBar->addAction(fwPrefsAct); + fileToolBar->addAction(editSplashAct); profileButton = new QToolButton; profileButton->setPopupMode(QToolButton::InstantPopup); profileButton->setMenu(createProfilesMenu()); @@ -2097,8 +1910,8 @@ void MainWindow::createToolBars() burnToolBar->addAction(burnToAct); burnToolBar->addAction(burnFromAct); burnToolBar->addSeparator(); - burnToolBar->addAction(burnExtenalToEEPROMAct); - burnToolBar->addAction(burnExtenalFromEEPROMAct); + burnToolBar->addAction(burnExtToEEPROMAct); + burnToolBar->addAction(burnExtFromEEPROMAct); burnToolBar->addSeparator(); burnToolBar->addAction(burnToFlashAct); burnToolBar->addAction(burnFromFlashAct); @@ -2193,27 +2006,27 @@ void MainWindow::updateLanguageActions() QString langId = settings.value("locale","").toString(); if (langId=="") - defaultLanguageAct->setChecked(true); + sysLangAct->setChecked(true); else if (langId=="cs_CZ") - czechLanguageAct->setChecked(true); + czechLangAct->setChecked(true); else if (langId=="de_DE") - germanLanguageAct->setChecked(true); + germanLangAct->setChecked(true); else if (langId=="en") - englishLanguageAct->setChecked(true); + englishLangAct->setChecked(true); else if (langId=="fr_FR") - frenchLanguageAct->setChecked(true); + frenchLangAct->setChecked(true); else if (langId=="it_IT") - italianLanguageAct->setChecked(true); + italianLangAct->setChecked(true); else if (langId=="he_IL") - hebrewLanguageAct->setChecked(true); + hebrewLangAct->setChecked(true); else if (langId=="pl_PL") - polishLanguageAct->setChecked(true); + polishLangAct->setChecked(true); else if (langId=="pt_PT") - portugueseLanguageAct->setChecked(true); + portugueseLangAct->setChecked(true); else if (langId=="ru_RU") - russianLanguageAct->setChecked(true); + russianLangAct->setChecked(true); else if (langId=="sv_SE") - swedishLanguageAct->setChecked(true); + swedishLangAct->setChecked(true); } void MainWindow::updateIconThemeActions() @@ -2221,11 +2034,11 @@ void MainWindow::updateIconThemeActions() QSettings settings; int size = settings.value("theme","1").toInt(); switch (size){ - case 0: classicThemeAct->setChecked(true); break; - case 1: newThemeAct->setChecked(true); break; - case 2: monoWhiteThemeAct->setChecked(true); break; - case 3: monoThemeAct->setChecked(true); break; - case 4: monoBlueThemeAct->setChecked(true); break; + case 0: classicThemeAct->setChecked(true); break; + case 1: newThemeAct->setChecked(true); break; + case 2: monoWhiteAct->setChecked(true); break; + case 3: monoThemeAct->setChecked(true); break; + case 4: monoBlueAct->setChecked(true); break; } } diff --git a/companion/src/mainwindow.h b/companion/src/mainwindow.h index e01b0e6c3..f1b0f9f9d 100644 --- a/companion/src/mainwindow.h +++ b/companion/src/mainwindow.h @@ -81,10 +81,10 @@ public slots: void downloadLatestFW(FirmwareInfo *firmware, const QString & firmwareId); private slots: - void openDocumentURL(); + void openDocURL(); void setLanguage(QString langString); - void setDefaultLanguage() {setLanguage("");}; + void setSysLanguage() {setLanguage("");}; void setCZLanguage() {setLanguage("cs_CZ");}; void setDELanguage() {setLanguage("de_DE");}; void setENLanguage() {setLanguage("en");}; @@ -131,8 +131,8 @@ private slots: void burnFrom(); void burnToFlash(QString fileToFlash=""); void burnFromFlash(); - void burnExtenalToEEPROM(); - void burnExtenalFromEEPROM(); + void burnExtToEEPROM(); + void burnExtFromEEPROM(); void burnConfig(); void burnList(); void burnFuses(); @@ -145,8 +145,8 @@ private slots: void compare(); void print(); void loadBackup(); - void appPreferences(); - void fwPreferences(); + void appPrefs(); + void fwPrefs(); void updateMenus(); void createProfile(); MdiChild *createMdiChild(); @@ -157,6 +157,10 @@ private slots: private: 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 createToolBars(); void createStatusBar(); @@ -201,7 +205,6 @@ private: bool needRename; bool showcheckForUpdatesResult; int MaxRecentFiles; -// int ActiveProfile; int currentFWrev; int currentFWrev_temp; int NewFwRev; @@ -226,14 +229,14 @@ private: QAction *saveAct; QAction *saveAsAct; QAction *exitAct; - QAction *appPreferencesAct; - QAction *fwPreferencesAct; + QAction *appPrefsAct; + QAction *fwPrefsAct; QAction *checkForUpdatesAct; QAction *contributorsAct; QAction *changelogAct; QAction *fwchangelogAct; QAction *compareAct; - QAction *customizeSplashAct; + QAction *editSplashAct; QAction *cutAct; QAction *copyAct; QAction *pasteAct; @@ -244,8 +247,8 @@ private: QAction *burnFusesAct; QAction *burnToFlashAct; QAction *burnFromFlashAct; - QAction *burnExtenalToEEPROMAct; - QAction *burnExtenalFromEEPROMAct; + QAction *burnExtToEEPROMAct; + QAction *burnExtFromEEPROMAct; QAction *simulateAct; QAction *separatorAct; QAction *aboutAct; @@ -258,24 +261,24 @@ private: QAction *classicThemeAct; QAction *newThemeAct; QAction *monoThemeAct; - QAction *monoBlueThemeAct; - QAction *monoWhiteThemeAct; + QAction *monoBlueAct; + QAction *monoWhiteAct; QAction *smallIconAct; QAction *normalIconAct; QAction *bigIconAct; QAction *hugeIconAct; - QAction *defaultLanguageAct; - QAction *englishLanguageAct; - QAction *czechLanguageAct; - QAction *germanLanguageAct; - QAction *frenchLanguageAct; - QAction *italianLanguageAct; - QAction *hebrewLanguageAct; - QAction *polishLanguageAct; - QAction *portugueseLanguageAct; - QAction *swedishLanguageAct; - QAction *russianLanguageAct; - QAction *openDocumentURLAct; + QAction *sysLangAct; + QAction *englishLangAct; + QAction *czechLangAct; + QAction *germanLangAct; + QAction *frenchLangAct; + QAction *italianLangAct; + QAction *hebrewLangAct; + QAction *polishLangAct; + QAction *portugueseLangAct; + QAction *swedishLangAct; + QAction *russianLangAct; + QAction *openDocURLAct; QString fwToUpdate; QToolButton * profileButton; };