diff --git a/companion/src/mainwindow.cpp b/companion/src/mainwindow.cpp index 03202b25b..94196807d 100644 --- a/companion/src/mainwindow.cpp +++ b/companion/src/mainwindow.cpp @@ -77,81 +77,79 @@ MainWindow::MainWindow(): downloadDialog_forWait(NULL), checkForUpdatesState(0) { - mdiArea = new QMdiArea(this); - mdiArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); - mdiArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); - setCentralWidget(mdiArea); - connect(mdiArea, SIGNAL(subWindowActivated(QMdiSubWindow*)), this, SLOT(updateMenus())); - windowMapper = new QSignalMapper(this); - connect(windowMapper, SIGNAL(mapped(QWidget*)), this, SLOT(setActiveSubWindow(QWidget*))); + mdiArea = new QMdiArea(this); + mdiArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); + mdiArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); + setCentralWidget(mdiArea); + connect(mdiArea, SIGNAL(subWindowActivated(QMdiSubWindow*)), this, SLOT(updateMenus())); + windowMapper = new QSignalMapper(this); + connect(windowMapper, SIGNAL(mapped(QWidget*)), this, SLOT(setActiveSubWindow(QWidget*))); - createActions(); - createMenus(); - createToolBars(); - createStatusBar(); - updateMenus(); + createActions(); + createMenus(); + createToolBars(); + createStatusBar(); + updateMenus(); - restoreState(g.mainWinState()); - restoreGeometry(g.mainWinGeo()); + restoreState(g.mainWinState()); + restoreGeometry(g.mainWinGeo()); - // setUnifiedTitleAndToolBarOnMac(true); - this->setWindowIcon(QIcon(":/icon.png")); - this->setIconSize(QSize(32, 32)); - QNetworkProxyFactory::setUseSystemConfiguration(true); - setAcceptDrops(true); + // setUnifiedTitleAndToolBarOnMac(true); + this->setWindowIcon(QIcon(":/icon.png")); + this->setIconSize(QSize(32, 32)); + QNetworkProxyFactory::setUseSystemConfiguration(true); + setAcceptDrops(true); - // give time to the splash to disappear and main window to open before starting updates - int updateDelay = 1000; - bool showSplash = g.showSplash(); - if (showSplash) { - updateDelay += (SPLASH_TIME*1000); + // give time to the splash to disappear and main window to open before starting updates + int updateDelay = 1000; + bool showSplash = g.showSplash(); + if (showSplash) { + updateDelay += (SPLASH_TIME*1000); + } + QTimer::singleShot(updateDelay, this, SLOT(doAutoUpdates())); + QTimer::singleShot(updateDelay, this, SLOT(displayWarnings())); + + QStringList strl = QApplication::arguments(); + QString str; + QString printfilename; + int printing = strl.contains("--print"); + int model = -1; + int count = 0; + foreach(QString arg, strl) { + count++; + if (arg.contains("--model")) { + model = strl[count].toInt() - 1; } - QTimer::singleShot(updateDelay, this, SLOT(doAutoUpdates())); - QTimer::singleShot(updateDelay, this, SLOT(displayWarnings())); - - QStringList strl = QApplication::arguments(); - QString str; - QString printfilename; - int printing=false; - int model=-1; - if (strl.contains("--print")) - printing=true; - int count=0; - foreach(QString arg, strl) { - count++; - if (arg.contains("--model")) { - model=strl[count].toInt()-1; - } - if (arg.contains("--filename")) { - printfilename=strl[count]; - } + if (arg.contains("--filename")) { + printfilename = strl[count]; } - if (strl.count()>1) str = strl[1]; - if (!str.isEmpty()) { - int fileType = getStorageType(str); + } + if (strl.count()>1) str = strl[1]; + if (!str.isEmpty()) { + int fileType = getStorageType(str); - if (fileType==STORAGE_TYPE_HEX) { - writeFlash(str); - } + if (fileType==STORAGE_TYPE_HEX) { + writeFlash(str); + } - if (fileType==STORAGE_TYPE_EEPE || fileType==STORAGE_TYPE_EEPM || fileType==STORAGE_TYPE_BIN) { - MdiChild * child = createMdiChild(); - if (child->loadFile(str)) { - if (!(printing && model >= 0 && (getCurrentFirmware()->getCapability(Models) == 0 || modelgetCapability(Models)) && !printfilename.isEmpty())) { - statusBar()->showMessage(tr("File loaded"), 2000); - child->show(); - } - else { - child->show(); - child->print(model, printfilename); - child->close(); - } + if (fileType==STORAGE_TYPE_EEPE || fileType==STORAGE_TYPE_EEPM || fileType==STORAGE_TYPE_BIN) { + MdiChild * child = createMdiChild(); + if (child->loadFile(str)) { + if (!(printing && model >= 0 && (getCurrentFirmware()->getCapability(Models) == 0 || modelgetCapability(Models)) && !printfilename.isEmpty())) { + statusBar()->showMessage(tr("File loaded"), 2000); + child->show(); + } + else { + child->show(); + child->print(model, printfilename); + child->close(); } } } - if (printing) { - QTimer::singleShot(0, this, SLOT(autoClose())); - } + } + if (printing) { + QTimer::singleShot(0, this, SLOT(autoClose())); + } } void MainWindow::displayWarnings() @@ -275,221 +273,221 @@ QString MainWindow::seekCodeString(const QByteArray & qba, const QString & label void MainWindow::checkForCompanionUpdateFinished(QNetworkReply * reply) { - QByteArray qba = reply->readAll(); - QString version = seekCodeString(qba, "VERSION"); - if (version.isNull()) - return onUpdatesError(); + QByteArray qba = reply->readAll(); + QString version = seekCodeString(qba, "VERSION"); + if (version.isNull()) + return onUpdatesError(); - int vnum = version2index(version); + int vnum = version2index(version); - QString c9xversion = QString(VERSION); - int c9xver = version2index(c9xversion); + QString c9xversion = QString(VERSION); + int c9xver = version2index(c9xversion); - if (c9xver < vnum) { + if (c9xver < vnum) { #if defined WIN32 || !defined __GNUC__ // || defined __APPLE__ // OSX should only notify of updates since no update packages are available. - int ret = QMessageBox::question(this, "Companion", tr("A new version of Companion is available (version %1)
" - "Would you like to download it?").arg(version) , - QMessageBox::Yes | QMessageBox::No); + int ret = QMessageBox::question(this, "Companion", tr("A new version of Companion is available (version %1)
" + "Would you like to download it?").arg(version) , + QMessageBox::Yes | QMessageBox::No); - if (ret == QMessageBox::Yes) { - QDir dir(g.updatesDir()); - QString fileName = QFileDialog::getSaveFileName(this, tr("Save As"), dir.absoluteFilePath(QString(COMPANION_INSTALLER).arg(version)), tr("Executable (*.exe)")); - if (!fileName.isEmpty()) { - g.updatesDir(QFileInfo(fileName).dir().absolutePath()); - downloadDialog * dd = new downloadDialog(this, QString("%1/%2").arg(getCompanionUpdateBaseUrl()).arg(QString(COMPANION_INSTALLER).arg(version)), fileName); - installer_fileName = fileName; - connect(dd, SIGNAL(accepted()), this, SLOT(updateDownloaded())); - dd->exec(); + if (ret == QMessageBox::Yes) { + QDir dir(g.updatesDir()); + QString fileName = QFileDialog::getSaveFileName(this, tr("Save As"), dir.absoluteFilePath(QString(COMPANION_INSTALLER).arg(version)), tr("Executable (*.exe)")); + if (!fileName.isEmpty()) { + g.updatesDir(QFileInfo(fileName).dir().absolutePath()); + downloadDialog * dd = new downloadDialog(this, QString("%1/%2").arg(getCompanionUpdateBaseUrl()).arg(QString(COMPANION_INSTALLER).arg(version)), fileName); + installer_fileName = fileName; + connect(dd, SIGNAL(accepted()), this, SLOT(updateDownloaded())); + dd->exec(); + } + } +#else + QMessageBox::warning(this, tr("New release available"), tr("A new release of Companion is available, please check the OpenTX website!")); +#endif + } + else { + if (downloadDialog_forWait && checkForUpdatesState==0) { + QMessageBox::information(this, "Companion", tr("No updates available at this time.")); + } + } + + checkForUpdates(); +} + +void MainWindow::updateDownloaded() +{ + int ret = QMessageBox::question(this, "Companion", tr("Would you like to launch the installer?") , + QMessageBox::Yes | QMessageBox::No); + if (ret == QMessageBox::Yes) { + if (QDesktopServices::openUrl(QUrl::fromLocalFile(installer_fileName))) + QApplication::exit(); + } +} + +void MainWindow::firmwareDownloadAccepted() +{ + QString errormsg; + QFile file(g.profile[g.id()].fwName()); + if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { //reading HEX TEXT file + QMessageBox::critical(this, tr("Error"), + tr("Error opening file %1:\n%2.") + .arg(g.profile[g.id()].fwName()) + .arg(file.errorString())); + return; + } + file.reset(); + QTextStream inputStream(&file); + QString hline = inputStream.readLine(); + if (hline.startsWith("ERROR:")) { + int errnum = hline.mid(6).toInt(); + switch(errnum) { + case 1: + errormsg = tr("Not enough flash available on this board for all the selected options"); + break; + case 2: + errormsg = tr("Compilation server temporary failure, try later"); + break; + case 3: + errormsg = tr("Compilation server too busy, try later"); + break; + case 4: + errormsg = tr("Compilation error"); + break; + case 5: + errormsg = tr("Invalid firmware"); + break; + case 6: + errormsg = tr("Invalid board"); + break; + case 7: + errormsg = tr("Invalid language"); + break; + default: + errormsg = tr("Unknown server failure, try later"); + break; + } + file.close(); + QMessageBox::critical(this, tr("Error"), errormsg); + return; + } + file.close(); + g.fwRev.set(current_firmware_variant->getId(), version2index(firmwareVersionString)); + if (g.profile[g.id()].burnFirmware()) { + int ret = QMessageBox::question(this, "Companion", tr("Do you want to write the firmware to the radio now ?"), QMessageBox::Yes | QMessageBox::No); + if (ret == QMessageBox::Yes) { + writeFlash(g.profile[g.id()].fwName()); + } + } +} + +void MainWindow::checkForFirmwareUpdateFinished(QNetworkReply * reply) +{ + bool download = false; + bool ignore = false; + + QByteArray qba = reply->readAll(); + QString versionString = seekCodeString(qba, "VERSION"); + QString dateString = seekCodeString(qba, "DATE"); + if (versionString.isNull() || dateString.isNull()) + return onUpdatesError(); + + long version = version2index(versionString); + if (version <= 0) + return onUpdatesError(); + + QString fullVersionString = QString("%1 (%2)").arg(versionString).arg(dateString); + + if (checkForUpdatesState & AUTOMATIC_DOWNLOAD) { + checkForUpdatesState -= AUTOMATIC_DOWNLOAD; + download = true; + } + else { + int currentVersion = g.fwRev.get(current_firmware_variant->getId()); + QString currentVersionString = index2version(currentVersion); + + QMessageBox msgBox; + msgBox.setWindowTitle("Companion"); + QSpacerItem * horizontalSpacer = new QSpacerItem(500, 0, QSizePolicy::Minimum, QSizePolicy::Expanding); + QGridLayout * layout = (QGridLayout*)msgBox.layout(); + layout->addItem(horizontalSpacer, layout->rowCount(), 0, 1, layout->columnCount()); + + if (currentVersion == 0) { + QString rn = getCurrentFirmware()->getReleaseNotesUrl(); + QAbstractButton *rnButton = NULL; + msgBox.setText(tr("Firmware %1 does not seem to have ever been downloaded.\nRelease %2 is available.\nDo you want to download it now?\n\nWe recommend you view the release notes using the button below to learn about any changes that may be important to you.").arg(current_firmware_variant->getId()).arg(fullVersionString)); + QAbstractButton *YesButton = msgBox.addButton(trUtf8("Yes"), QMessageBox::YesRole); + msgBox.addButton(trUtf8("No"), QMessageBox::NoRole); + if (!rn.isEmpty()) { + rnButton = msgBox.addButton(trUtf8("Release Notes"), QMessageBox::ActionRole); + } + msgBox.setIcon(QMessageBox::Question); + msgBox.resize(0, 0); + msgBox.exec(); + if (msgBox.clickedButton() == rnButton) { + ReleaseNotesFirmwareDialog * dialog = new ReleaseNotesFirmwareDialog(this, rn); + dialog->exec(); + int ret2 = QMessageBox::question(this, "Companion", tr("Do you want to download release %1 now ?").arg(fullVersionString), QMessageBox::Yes | QMessageBox::No); + if (ret2 == QMessageBox::Yes) + download = true; + else + ignore = true; + } + else if (msgBox.clickedButton() == YesButton ) { + download = true; + } + else { + ignore = true; + } + } + else if (version > currentVersion) { + QString rn = getCurrentFirmware()->getReleaseNotesUrl(); + QAbstractButton *rnButton = NULL; + msgBox.setText(tr("A new version of %1 firmware is available:\n - current is %2\n - newer is %3\n\nDo you want to download it now?\n\nWe recommend you view the release notes using the button below to learn about any changes that may be important to you.").arg(current_firmware_variant->getId()).arg(currentVersionString).arg(fullVersionString)); + QAbstractButton *YesButton = msgBox.addButton(trUtf8("Yes"), QMessageBox::YesRole); + msgBox.addButton(trUtf8("No"), QMessageBox::NoRole); + if (!rn.isEmpty()) { + rnButton = msgBox.addButton(trUtf8("Release Notes"), QMessageBox::ActionRole); + } + msgBox.setIcon(QMessageBox::Question); + msgBox.resize(0,0); + msgBox.exec(); + if( msgBox.clickedButton() == rnButton ) { + ReleaseNotesFirmwareDialog * dialog = new ReleaseNotesFirmwareDialog(this, rn); + dialog->exec(); + int ret2 = QMessageBox::question(this, "Companion", tr("Do you want to download release %1 now ?").arg(fullVersionString), + QMessageBox::Yes | QMessageBox::No); + if (ret2 == QMessageBox::Yes) { + download = true; + } + else { + ignore = true; } } -#else - QMessageBox::warning(this, tr("New release available"), tr("A new release of Companion is available, please check the OpenTX website!")); -#endif + else if (msgBox.clickedButton() == YesButton ) { + download = true; + } + else { + ignore = true; + } } else { if (downloadDialog_forWait && checkForUpdatesState==0) { QMessageBox::information(this, "Companion", tr("No updates available at this time.")); } } + } - checkForUpdates(); -} - -void MainWindow::updateDownloaded() -{ - int ret = QMessageBox::question(this, "Companion", tr("Would you like to launch the installer?") , - QMessageBox::Yes | QMessageBox::No); - if (ret == QMessageBox::Yes) { - if (QDesktopServices::openUrl(QUrl::fromLocalFile(installer_fileName))) - QApplication::exit(); + if (ignore) { + int res = QMessageBox::question(this, "Companion", tr("Ignore this release %1?").arg(fullVersionString), QMessageBox::Yes | QMessageBox::No); + if (res==QMessageBox::Yes) { + g.fwRev.set(current_firmware_variant->getId(), version); } -} + } + else if (download == true) { + firmwareVersionString = versionString; + startFirmwareDownload(); + } -void MainWindow::firmwareDownloadAccepted() -{ - QString errormsg; - QFile file(g.profile[g.id()].fwName()); - if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { //reading HEX TEXT file - QMessageBox::critical(this, tr("Error"), - tr("Error opening file %1:\n%2.") - .arg(g.profile[g.id()].fwName()) - .arg(file.errorString())); - return; - } - file.reset(); - QTextStream inputStream(&file); - QString hline = inputStream.readLine(); - if (hline.startsWith("ERROR:")) { - int errnum = hline.mid(6).toInt(); - switch(errnum) { - case 1: - errormsg = tr("Not enough flash available on this board for all the selected options"); - break; - case 2: - errormsg = tr("Compilation server temporary failure, try later"); - break; - case 3: - errormsg = tr("Compilation server too busy, try later"); - break; - case 4: - errormsg = tr("Compilation error"); - break; - case 5: - errormsg = tr("Invalid firmware"); - break; - case 6: - errormsg = tr("Invalid board"); - break; - case 7: - errormsg = tr("Invalid language"); - break; - default: - errormsg = tr("Unknown server failure, try later"); - break; - } - file.close(); - QMessageBox::critical(this, tr("Error"), errormsg); - return; - } - file.close(); - g.fwRev.set(current_firmware_variant->getId(), version2index(firmwareVersionString)); - if (g.profile[g.id()].burnFirmware()) { - int ret = QMessageBox::question(this, "Companion", tr("Do you want to write the firmware to the radio now ?"), QMessageBox::Yes | QMessageBox::No); - if (ret == QMessageBox::Yes) { - writeFlash(g.profile[g.id()].fwName()); - } - } -} - -void MainWindow::checkForFirmwareUpdateFinished(QNetworkReply * reply) -{ - bool download = false; - bool ignore = false; - - QByteArray qba = reply->readAll(); - QString versionString = seekCodeString(qba, "VERSION"); - QString dateString = seekCodeString(qba, "DATE"); - if (versionString.isNull() || dateString.isNull()) - return onUpdatesError(); - - long version = version2index(versionString); - if (version <= 0) - return onUpdatesError(); - - QString fullVersionString = QString("%1 (%2)").arg(versionString).arg(dateString); - - if (checkForUpdatesState & AUTOMATIC_DOWNLOAD) { - checkForUpdatesState -= AUTOMATIC_DOWNLOAD; - download = true; - } - else { - int currentVersion = g.fwRev.get(current_firmware_variant->getId()); - QString currentVersionString = index2version(currentVersion); - - QMessageBox msgBox; - msgBox.setWindowTitle("Companion"); - QSpacerItem * horizontalSpacer = new QSpacerItem(500, 0, QSizePolicy::Minimum, QSizePolicy::Expanding); - QGridLayout * layout = (QGridLayout*)msgBox.layout(); - layout->addItem(horizontalSpacer, layout->rowCount(), 0, 1, layout->columnCount()); - - if (currentVersion == 0) { - QString rn = getCurrentFirmware()->getReleaseNotesUrl(); - QAbstractButton *rnButton = NULL; - msgBox.setText(tr("Firmware %1 does not seem to have ever been downloaded.\nRelease %2 is available.\nDo you want to download it now?\n\nWe recommend you view the release notes using the button below to learn about any changes that may be important to you.").arg(current_firmware_variant->getId()).arg(fullVersionString)); - QAbstractButton *YesButton = msgBox.addButton(trUtf8("Yes"), QMessageBox::YesRole); - msgBox.addButton(trUtf8("No"), QMessageBox::NoRole); - if (!rn.isEmpty()) { - rnButton = msgBox.addButton(trUtf8("Release Notes"), QMessageBox::ActionRole); - } - msgBox.setIcon(QMessageBox::Question); - msgBox.resize(0, 0); - msgBox.exec(); - if (msgBox.clickedButton() == rnButton) { - ReleaseNotesFirmwareDialog * dialog = new ReleaseNotesFirmwareDialog(this, rn); - dialog->exec(); - int ret2 = QMessageBox::question(this, "Companion", tr("Do you want to download release %1 now ?").arg(fullVersionString), QMessageBox::Yes | QMessageBox::No); - if (ret2 == QMessageBox::Yes) - download = true; - else - ignore = true; - } - else if (msgBox.clickedButton() == YesButton ) { - download = true; - } - else { - ignore = true; - } - } - else if (version > currentVersion) { - QString rn = getCurrentFirmware()->getReleaseNotesUrl(); - QAbstractButton *rnButton = NULL; - msgBox.setText(tr("A new version of %1 firmware is available:\n - current is %2\n - newer is %3\n\nDo you want to download it now?\n\nWe recommend you view the release notes using the button below to learn about any changes that may be important to you.").arg(current_firmware_variant->getId()).arg(currentVersionString).arg(fullVersionString)); - QAbstractButton *YesButton = msgBox.addButton(trUtf8("Yes"), QMessageBox::YesRole); - msgBox.addButton(trUtf8("No"), QMessageBox::NoRole); - if (!rn.isEmpty()) { - rnButton = msgBox.addButton(trUtf8("Release Notes"), QMessageBox::ActionRole); - } - msgBox.setIcon(QMessageBox::Question); - msgBox.resize(0,0); - msgBox.exec(); - if( msgBox.clickedButton() == rnButton ) { - ReleaseNotesFirmwareDialog * dialog = new ReleaseNotesFirmwareDialog(this, rn); - dialog->exec(); - int ret2 = QMessageBox::question(this, "Companion", tr("Do you want to download release %1 now ?").arg(fullVersionString), - QMessageBox::Yes | QMessageBox::No); - if (ret2 == QMessageBox::Yes) { - download = true; - } - else { - ignore = true; - } - } - else if (msgBox.clickedButton() == YesButton ) { - download = true; - } - else { - ignore = true; - } - } - else { - if (downloadDialog_forWait && checkForUpdatesState==0) { - QMessageBox::information(this, "Companion", tr("No updates available at this time.")); - } - } - } - - if (ignore) { - int res = QMessageBox::question(this, "Companion", tr("Ignore this release %1?").arg(fullVersionString), QMessageBox::Yes | QMessageBox::No); - if (res==QMessageBox::Yes) { - g.fwRev.set(current_firmware_variant->getId(), version); - } - } - else if (download == true) { - firmwareVersionString = versionString; - startFirmwareDownload(); - } - - checkForUpdates(); + checkForUpdates(); } void MainWindow::startFirmwareDownload() @@ -515,15 +513,15 @@ void MainWindow::startFirmwareDownload() void MainWindow::closeEvent(QCloseEvent *event) { - g.mainWinGeo(saveGeometry()); - g.mainWinState(saveState()); - mdiArea->closeAllSubWindows(); - if (mdiArea->currentSubWindow()) { - event->ignore(); - } - else { - event->accept(); - } + g.mainWinGeo(saveGeometry()); + g.mainWinState(saveState()); + mdiArea->closeAllSubWindows(); + if (mdiArea->currentSubWindow()) { + event->ignore(); + } + else { + event->accept(); + } } void MainWindow::setLanguage(const QString & langString) @@ -581,14 +579,14 @@ void MainWindow::openFile() void MainWindow::save() { - if (activeMdiChild() && activeMdiChild()->save()) - statusBar()->showMessage(tr("File saved"), 2000); + if (activeMdiChild() && activeMdiChild()->save()) + statusBar()->showMessage(tr("File saved"), 2000); } void MainWindow::saveAs() { - if (activeMdiChild() && activeMdiChild()->saveAs()) - statusBar()->showMessage(tr("File saved"), 2000); + if (activeMdiChild() && activeMdiChild()->saveAs()) + statusBar()->showMessage(tr("File saved"), 2000); } void MainWindow::openRecentFile() @@ -692,50 +690,43 @@ void MainWindow::customizeSplash() void MainWindow::cut() { - if (activeMdiChild()) { - activeMdiChild()->cut(); - updateMenus(); - } + if (activeMdiChild()) { + activeMdiChild()->cut(); + updateMenus(); + } } void MainWindow::copy() { - if (activeMdiChild()) { - activeMdiChild()->copy(); - updateMenus(); - } + if (activeMdiChild()) { + activeMdiChild()->copy(); + updateMenus(); + } } void MainWindow::paste() { - if (activeMdiChild()) - activeMdiChild()->paste(); + if (activeMdiChild()) activeMdiChild()->paste(); } void MainWindow::writeEeprom() { - if (activeMdiChild()) - activeMdiChild()->writeEeprom(); + if (activeMdiChild()) activeMdiChild()->writeEeprom(); } void MainWindow::simulate() { - if (activeMdiChild()) { - activeMdiChild()->radioSimulate(); - } + if (activeMdiChild()) activeMdiChild()->radioSimulate(); } - void MainWindow::print() { - if (activeMdiChild()) - activeMdiChild()->print(); + if (activeMdiChild()) activeMdiChild()->print(); } void MainWindow::loadBackup() { - if (activeMdiChild()) - activeMdiChild()->loadBackup(); + if (activeMdiChild()) activeMdiChild()->loadBackup(); } void MainWindow::readEeprom() @@ -860,52 +851,53 @@ void MainWindow::logFile() void MainWindow::about() { - QString aboutStr = "

"; - aboutStr.append(tr("OpenTX Home Page: %1").arg("http://www.open-tx.org")); - aboutStr.append("

"); - aboutStr.append(tr("The OpenTX Companion project was originally forked from eePe").arg("http://code.google.com/p/eepe")); - aboutStr.append("

"); - aboutStr.append(tr("If you've found this program useful, please support by donating").arg(DONATE_STR)); - aboutStr.append("

"); - aboutStr.append(QString("Version %1, %2").arg(VERSION).arg(__DATE__)); - aboutStr.append("

"); - aboutStr.append(tr("Copyright OpenTX Team") + "
© 2011-2016
"); - QMessageBox msgBox(this); - msgBox.setWindowIcon(CompanionIcon("information.png")); - msgBox.setWindowTitle(tr("About Companion")); - msgBox.setText(aboutStr); - msgBox.exec(); + QString aboutStr = "

"; + aboutStr.append(tr("OpenTX Home Page: %1").arg("http://www.open-tx.org")); + aboutStr.append("

"); + aboutStr.append(tr("The OpenTX Companion project was originally forked from eePe").arg("http://code.google.com/p/eepe")); + aboutStr.append("

"); + aboutStr.append(tr("If you've found this program useful, please support by donating").arg(DONATE_STR)); + aboutStr.append("

"); + aboutStr.append(QString("Version %1, %2").arg(VERSION).arg(__DATE__)); + aboutStr.append("

"); + aboutStr.append(tr("Copyright OpenTX Team") + "
© 2011-2016
"); + QMessageBox msgBox(this); + msgBox.setWindowIcon(CompanionIcon("information.png")); + msgBox.setWindowTitle(tr("About Companion")); + msgBox.setText(aboutStr); + msgBox.exec(); } void MainWindow::updateMenus() { - bool hasMdiChild = (activeMdiChild() != 0); - bool hasSelection = (activeMdiChild() && activeMdiChild()->hasSelection()); - - newAct->setEnabled(true); - openAct->setEnabled(true); - saveAct->setEnabled(hasMdiChild); - saveAsAct->setEnabled(hasMdiChild); - cutAct->setEnabled(hasSelection); - copyAct->setEnabled(hasSelection); - pasteAct->setEnabled(hasMdiChild ? activeMdiChild()->hasPasteData() : false); - writeEepromAct->setEnabled(hasMdiChild); - readEepromAct->setEnabled(true); - writeBackupToRadioAct->setEnabled(true); - readBackupToFileAct->setEnabled(true); - for (int i=0; isetEnabled(true); - separatorAct->setVisible(hasMdiChild); - simulateAct->setEnabled(hasSelection); - printAct->setEnabled(hasSelection); - loadbackupAct->setEnabled(hasMdiChild); - compareAct->setEnabled(activeMdiChild()); - updateRecentFileActions(); - updateProfilesActions(); - updateLanguageActions(); - updateIconSizeActions(); - updateIconThemeActions(); - setWindowTitle(tr("OpenTX Companion %1 - Radio: %2 - Profile: %3").arg(VERSION).arg(getCurrentFirmware()->getName()).arg(g.profile[g.id()].name())); + bool hasMdiChild = (activeMdiChild() != 0); + bool hasSelection = (activeMdiChild() && activeMdiChild()->hasSelection()); + + newAct->setEnabled(true); + openAct->setEnabled(true); + saveAct->setEnabled(hasMdiChild); + saveAsAct->setEnabled(hasMdiChild); + cutAct->setEnabled(hasSelection); + copyAct->setEnabled(hasSelection); + pasteAct->setEnabled(hasMdiChild ? activeMdiChild()->hasPasteData() : false); + writeEepromAct->setEnabled(hasMdiChild); + readEepromAct->setEnabled(true); + writeBackupToRadioAct->setEnabled(true); + readBackupToFileAct->setEnabled(true); + for (int i=0; isetEnabled(true); + } + separatorAct->setVisible(hasMdiChild); + simulateAct->setEnabled(hasSelection); + printAct->setEnabled(hasSelection); + loadbackupAct->setEnabled(hasMdiChild); + compareAct->setEnabled(activeMdiChild()); + updateRecentFileActions(); + updateProfilesActions(); + updateLanguageActions(); + updateIconSizeActions(); + updateIconThemeActions(); + setWindowTitle(tr("OpenTX Companion %1 - Radio: %2 - Profile: %3").arg(VERSION).arg(getCurrentFirmware()->getName()).arg(g.profile[g.id()].name())); } MdiChild * MainWindow::createMdiChild() @@ -961,359 +953,356 @@ QAction * MainWindow::addAct(QActionGroup *aGroup, const QString & sName, const void MainWindow::createActions() { - separatorAct = new QAction(this); - separatorAct->setSeparator(true); + separatorAct = new QAction(this); + separatorAct->setSeparator(true); - for (int i = 0; i < MAX_RECENT; ++i) { - recentFileActs[i] = new QAction(this); - recentFileActs[i]->setVisible(false); - connect(recentFileActs[i], SIGNAL(triggered()), this, SLOT(openRecentFile())); - } - updateRecentFileActions(); + for (int i = 0; i < MAX_RECENT; ++i) { + recentFileActs[i] = new QAction(this); + recentFileActs[i]->setVisible(false); + connect(recentFileActs[i], SIGNAL(triggered()), this, SLOT(openRecentFile())); + } + updateRecentFileActions(); - QActionGroup *profilesAlignmentGroup = new QActionGroup(this); - for (int i=0; isetVisible(false); - profileActs[i]->setCheckable(true); - profilesAlignmentGroup->addAction(profileActs[i]); - connect(profileActs[i], SIGNAL(triggered()), this, SLOT(loadProfile())); - } - updateProfilesActions(); + QActionGroup *profilesAlignmentGroup = new QActionGroup(this); + for (int i=0; isetVisible(false); + profileActs[i]->setCheckable(true); + profilesAlignmentGroup->addAction(profileActs[i]); + connect(profileActs[i], SIGNAL(triggered()), this, SLOT(loadProfile())); + } + updateProfilesActions(); - newAct = addAct("new.png", tr("New"), tr("Create a new Models and Settings file"), QKeySequence::New, SLOT(newFile())); - openAct = addAct("open.png", tr("Open..."), tr("Open Models and Settings file"), QKeySequence::Open, SLOT(openFile())); - saveAct = addAct("save.png", tr("Save"), tr("Save Models and Settings file"), QKeySequence::Save, SLOT(save())); - saveAsAct = addAct("saveas.png", tr("Save As..."), tr("Save Models and Settings file"), QKeySequence::SaveAs, SLOT(saveAs())); - exitAct = addAct("exit.png", tr("Exit"), tr("Exit the application"), QKeySequence::Quit, SLOT(closeAllWindows()), qApp); - cutAct = addAct("cut.png", tr("Cut Model"), tr("Cut current model to the clipboard"), QKeySequence::Cut, SLOT(cut())); - copyAct = addAct("copy.png", tr("Copy Model"), tr("Copy current model to the clipboard"), QKeySequence::Copy, SLOT(copy())); - pasteAct = addAct("paste.png", tr("Paste Model"), tr("Paste model from clipboard"), QKeySequence::Paste, SLOT(paste())); + newAct = addAct("new.png", tr("New"), tr("Create a new Models and Settings file"), QKeySequence::New, SLOT(newFile())); + openAct = addAct("open.png", tr("Open..."), tr("Open Models and Settings file"), QKeySequence::Open, SLOT(openFile())); + saveAct = addAct("save.png", tr("Save"), tr("Save Models and Settings file"), QKeySequence::Save, SLOT(save())); + saveAsAct = addAct("saveas.png", tr("Save As..."), tr("Save Models and Settings file"), QKeySequence::SaveAs, SLOT(saveAs())); + exitAct = addAct("exit.png", tr("Exit"), tr("Exit the application"), QKeySequence::Quit, SLOT(closeAllWindows()), qApp); + cutAct = addAct("cut.png", tr("Cut Model"), tr("Cut current model to the clipboard"), QKeySequence::Cut, SLOT(cut())); + copyAct = addAct("copy.png", tr("Copy Model"), tr("Copy current model to the clipboard"), QKeySequence::Copy, SLOT(copy())); + pasteAct = addAct("paste.png", tr("Paste Model"), tr("Paste model from clipboard"), QKeySequence::Paste, SLOT(paste())); - QActionGroup *themeAlignGroup = new QActionGroup(this); - classicThemeAct = addAct( themeAlignGroup, tr("Classical"), tr("The classic companion9x icon theme"), SLOT(setClassicTheme())); - yericoThemeAct = addAct( themeAlignGroup, tr("Yerico"), tr("Yellow round honey sweet icon theme"), SLOT(setYericoTheme())); - 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())); + QActionGroup *themeAlignGroup = new QActionGroup(this); + classicThemeAct = addAct( themeAlignGroup, tr("Classical"), tr("The classic companion9x icon theme"), SLOT(setClassicTheme())); + yericoThemeAct = addAct( themeAlignGroup, tr("Yerico"), tr("Yellow round honey sweet icon theme"), SLOT(setYericoTheme())); + 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())); - 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())); + 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())); - 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())); - finnishLangAct = addAct( langAlignGroup, tr("Finnish"), tr("Use Finnish in menus"), SLOT(setFILanguage())); - frenchLangAct = addAct( langAlignGroup, tr("French"), tr("Use French in menus"), SLOT(setFRLanguage())); - italianLangAct = addAct( langAlignGroup, tr("Italian"), tr("Use Italian in menus"), SLOT(setITLanguage())); + 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())); + finnishLangAct = addAct( langAlignGroup, tr("Finnish"), tr("Use Finnish in menus"), SLOT(setFILanguage())); + 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())); + polishLangAct = addAct( langAlignGroup, tr("Polish"), tr("Use Polish in menus"), SLOT(setPLLanguage())); // portugueseLangAct = addAct( langAlignGroup, tr("Portuguese"), tr("Use Portuguese in menus"), SLOT(setPTLanguage())); - spanishLangAct = addAct( langAlignGroup, tr("Spanish"), tr("Use Spanish in menus"), SLOT(setESLanguage())); - swedishLangAct = addAct( langAlignGroup, tr("Swedish"), tr("Use Swedish in menus"), SLOT(setSELanguage())); + spanishLangAct = addAct( langAlignGroup, tr("Spanish"), tr("Use Spanish in menus"), SLOT(setESLanguage())); + swedishLangAct = addAct( langAlignGroup, tr("Swedish"), tr("Use Swedish in menus"), SLOT(setSELanguage())); // russianLangAct = addAct( langAlignGroup, tr("Russian"), tr("Use Russian in menus"), SLOT(setRULanguage())); // dutchLangAct = addAct( langAlignGroup, tr("Dutch"), tr("Use Dutch in menus"), SLOT(setNLLanguage())); - chineseLangAct = addAct( langAlignGroup, tr("Chinese"), tr("Use Chinese in menus"), SLOT(setCNLanguage())); + chineseLangAct = addAct( langAlignGroup, tr("Chinese"), tr("Use Chinese in menus"), SLOT(setCNLanguage())); - 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"), QKeySequence::Print, SLOT(print())); - simulateAct = addAct("simulate.png", tr("Simulate..."), tr("Simulate current model"), QKeySequence(tr("Alt+S")), SLOT(simulate())); - loadbackupAct = addAct("open.png", tr("Load Backup..."), tr("Load backup from file"), SLOT(loadBackup())); - logsAct = addAct("logs.png", tr("View Log File..."), tr("Open and view log file"), SLOT(logFile())); - appPrefsAct = addAct("apppreferences.png",tr("Settings..."), tr("Edit Settings"), SLOT(appPrefs())); - fwPrefsAct = addAct("fwpreferences.png", tr("Download..."), tr("Download firmware and voice files"), SLOT(fwPrefs())); - checkForUpdatesAct = addAct("update.png", tr("Check for Updates..."), tr("Check OpenTX and Companion updates"), SLOT(doUpdates())); - changelogAct = addAct("changelog.png", tr("Companion Changes..."), tr("Show Companion change log"), SLOT(changelog())); - fwchangelogAct = addAct("changelog.png", tr("Firmware Changes..."), tr("Show firmware change log"), SLOT(fwchangelog())); - compareAct = addAct("compare.png", tr("Compare Models..."), tr("Compare models"), SLOT(compare())); - editSplashAct = addAct("paintbrush.png", tr("Edit Radio Splash Image..."), tr("Edit the splash image of your Radio"), 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())); - readFlashAct = addAct("read_flash.png", tr("Read Firmware from Radio"),tr("Read firmware from Radio"), SLOT(readFlash())); - writeFlashAct = addAct("write_flash.png", tr("Write Firmware to Radio"), tr("Write firmware to Radio"), SLOT(writeFlash())); - createProfileAct = addAct("", tr("Add Radio 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())); - writeEepromAct = addAct("write_eeprom.png", tr("Write Models and Settings To Radio"), tr("Write Models and Settings to Radio"), SLOT(writeEeprom())); - readEepromAct = addAct("read_eeprom.png", tr("Read Models and Settings From Radio"), tr("Read Models and Settings from Radio"), SLOT(readEeprom())); - burnConfigAct = addAct("configure.png", tr("Configure Communications..."), tr("Configure software for communicating with the Radio"), SLOT(burnConfig())); - writeBackupToRadioAct = addAct("write_eeprom_file.png", tr("Write Backup to Radio"), tr("Write Backup from file to Radio"), SLOT(writeBackup())); - readBackupToFileAct = addAct("read_eeprom_file.png", tr("Backup Radio to File"), tr("Save a complete backup file of all settings and model data in the Radio"), SLOT(readBackup())); - contributorsAct = addAct("contributors.png", tr("Contributors..."), tr("A tribute to those who have contributed to OpenTX and Companion"), SLOT(contributors())); - sdsyncAct = addAct("sdsync.png", tr("Synchronize SD"), tr("SD card synchronization"), SLOT(sdsync())); + 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"), QKeySequence::Print, SLOT(print())); + simulateAct = addAct("simulate.png", tr("Simulate..."), tr("Simulate current model"), QKeySequence(tr("Alt+S")), SLOT(simulate())); + loadbackupAct = addAct("open.png", tr("Load Backup..."), tr("Load backup from file"), SLOT(loadBackup())); + logsAct = addAct("logs.png", tr("View Log File..."), tr("Open and view log file"), SLOT(logFile())); + appPrefsAct = addAct("apppreferences.png",tr("Settings..."), tr("Edit Settings"), SLOT(appPrefs())); + fwPrefsAct = addAct("fwpreferences.png", tr("Download..."), tr("Download firmware and voice files"), SLOT(fwPrefs())); + checkForUpdatesAct = addAct("update.png", tr("Check for Updates..."), tr("Check OpenTX and Companion updates"), SLOT(doUpdates())); + changelogAct = addAct("changelog.png", tr("Companion Changes..."), tr("Show Companion change log"), SLOT(changelog())); + fwchangelogAct = addAct("changelog.png", tr("Firmware Changes..."), tr("Show firmware change log"), SLOT(fwchangelog())); + compareAct = addAct("compare.png", tr("Compare Models..."), tr("Compare models"), SLOT(compare())); + editSplashAct = addAct("paintbrush.png", tr("Edit Radio Splash Image..."), tr("Edit the splash image of your Radio"), 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())); + readFlashAct = addAct("read_flash.png", tr("Read Firmware from Radio"),tr("Read firmware from Radio"), SLOT(readFlash())); + writeFlashAct = addAct("write_flash.png", tr("Write Firmware to Radio"), tr("Write firmware to Radio"), SLOT(writeFlash())); + createProfileAct = addAct("", tr("Add Radio 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())); + writeEepromAct = addAct("write_eeprom.png", tr("Write Models and Settings To Radio"), tr("Write Models and Settings to Radio"), SLOT(writeEeprom())); + readEepromAct = addAct("read_eeprom.png", tr("Read Models and Settings From Radio"), tr("Read Models and Settings from Radio"), SLOT(readEeprom())); + burnConfigAct = addAct("configure.png", tr("Configure Communications..."), tr("Configure software for communicating with the Radio"), SLOT(burnConfig())); + writeBackupToRadioAct = addAct("write_eeprom_file.png", tr("Write Backup to Radio"), tr("Write Backup from file to Radio"), SLOT(writeBackup())); + readBackupToFileAct = addAct("read_eeprom_file.png", tr("Backup Radio to File"), tr("Save a complete backup file of all settings and model data in the Radio"), SLOT(readBackup())); + contributorsAct = addAct("contributors.png", tr("Contributors..."), tr("A tribute to those who have contributed to OpenTX and Companion"), SLOT(contributors())); + sdsyncAct = addAct("sdsync.png", tr("Synchronize SD"), tr("SD card synchronization"), SLOT(sdsync())); - compareAct->setEnabled(false); - simulateAct->setEnabled(false); - printAct->setEnabled(false); + compareAct->setEnabled(false); + simulateAct->setEnabled(false); + printAct->setEnabled(false); } void MainWindow::createMenus() { - QMenu *recentFileMenu = new QMenu(tr("Recent Files"), this); - QMenu *languageMenu = new QMenu(tr("Set Menu Language"), this); - QMenu *themeMenu = new QMenu(tr("Set Icon Theme"), this); - QMenu *iconThemeSizeMenu = new QMenu(tr("Set Icon Size"), this); + QMenu *recentFileMenu = new QMenu(tr("Recent Files"), this); + QMenu *languageMenu = new QMenu(tr("Set Menu Language"), this); + QMenu *themeMenu = new QMenu(tr("Set Icon Theme"), this); + QMenu *iconThemeSizeMenu = new QMenu(tr("Set Icon Size"), this); - fileMenu = menuBar()->addMenu(tr("File")); - fileMenu->addAction(newAct); - fileMenu->addAction(openAct); - fileMenu->addAction(saveAct); - fileMenu->addAction(saveAsAct); - fileMenu->addMenu(recentFileMenu); - recentFileMenu->setIcon(CompanionIcon("recentdocument.png")); - for (int i=0; iaddAction(recentFileActs[i]); - fileMenu->addSeparator(); - fileMenu->addAction(logsAct); - fileMenu->addAction(fwPrefsAct); - fileMenu->addSeparator(); - fileMenu->addAction(simulateAct); - fileMenu->addAction(printAct); - fileMenu->addAction(compareAct); - fileMenu->addAction(sdsyncAct); - fileMenu->addSeparator(); - fileMenu->addAction(exitAct); + fileMenu = menuBar()->addMenu(tr("File")); + fileMenu->addAction(newAct); + fileMenu->addAction(openAct); + fileMenu->addAction(saveAct); + fileMenu->addAction(saveAsAct); + fileMenu->addMenu(recentFileMenu); + recentFileMenu->setIcon(CompanionIcon("recentdocument.png")); + for (int i=0; iaddAction(recentFileActs[i]); + } + fileMenu->addSeparator(); + fileMenu->addAction(logsAct); + fileMenu->addAction(fwPrefsAct); + fileMenu->addSeparator(); + fileMenu->addAction(simulateAct); + fileMenu->addAction(printAct); + fileMenu->addAction(compareAct); + fileMenu->addAction(sdsyncAct); + fileMenu->addSeparator(); + fileMenu->addAction(exitAct); - editMenu = menuBar()->addMenu(tr("Edit")); - editMenu->addAction(cutAct); - editMenu->addAction(copyAct); - editMenu->addAction(pasteAct); + editMenu = menuBar()->addMenu(tr("Edit")); + editMenu->addAction(cutAct); + editMenu->addAction(copyAct); + editMenu->addAction(pasteAct); - settingsMenu = menuBar()->addMenu(tr("Settings")); - settingsMenu->addMenu(languageMenu); - languageMenu->addAction(sysLangAct); - languageMenu->addAction(englishLangAct); - languageMenu->addAction(czechLangAct); - languageMenu->addAction(germanLangAct); - languageMenu->addAction(finnishLangAct); - languageMenu->addAction(frenchLangAct); - languageMenu->addAction(italianLangAct); + settingsMenu = menuBar()->addMenu(tr("Settings")); + settingsMenu->addMenu(languageMenu); + languageMenu->addAction(sysLangAct); + languageMenu->addAction(englishLangAct); + languageMenu->addAction(czechLangAct); + languageMenu->addAction(germanLangAct); + languageMenu->addAction(finnishLangAct); + languageMenu->addAction(frenchLangAct); + languageMenu->addAction(italianLangAct); // languageMenu->addAction(hebrewLangAct); - languageMenu->addAction(polishLangAct); + languageMenu->addAction(polishLangAct); // languageMenu->addAction(portugueseLangAct); - languageMenu->addAction(spanishLangAct); - languageMenu->addAction(swedishLangAct); + languageMenu->addAction(spanishLangAct); + languageMenu->addAction(swedishLangAct); // languageMenu->addAction(russianLangAct); // languageMenu->addAction(dutchLangAct); - languageMenu->addAction(chineseLangAct); + languageMenu->addAction(chineseLangAct); - settingsMenu->addMenu(themeMenu); - themeMenu->addAction(classicThemeAct); - themeMenu->addAction(yericoThemeAct); - themeMenu->addAction(monoThemeAct); - 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(appPrefsAct); - settingsMenu->addMenu(createProfilesMenu()); - settingsMenu->addAction(editSplashAct); - settingsMenu->addAction(burnConfigAct); + settingsMenu->addMenu(themeMenu); + themeMenu->addAction(classicThemeAct); + themeMenu->addAction(yericoThemeAct); + themeMenu->addAction(monoThemeAct); + 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(appPrefsAct); + settingsMenu->addMenu(createProfilesMenu()); + settingsMenu->addAction(editSplashAct); + settingsMenu->addAction(burnConfigAct); - burnMenu = menuBar()->addMenu(tr("Read/Write")); - burnMenu->addAction(writeEepromAct); - burnMenu->addAction(readEepromAct); - burnMenu->addSeparator(); - burnMenu->addAction(writeBackupToRadioAct); - burnMenu->addAction(readBackupToFileAct); - burnMenu->addSeparator(); - burnMenu->addAction(writeFlashAct); - burnMenu->addAction(readFlashAct); - burnMenu->addSeparator(); - burnMenu->addSeparator(); - if (!IS_ARM(getCurrentBoard())) { - burnMenu->addAction(burnFusesAct); - burnMenu->addAction(burnListAct); - } - menuBar()->addSeparator(); - helpMenu = menuBar()->addMenu(tr("Help")); - helpMenu->addSeparator(); - helpMenu->addAction(checkForUpdatesAct); - helpMenu->addSeparator(); - helpMenu->addAction(aboutAct); - helpMenu->addAction(openDocURLAct); - helpMenu->addSeparator(); - helpMenu->addAction(changelogAct); - helpMenu->addAction(fwchangelogAct); - helpMenu->addSeparator(); - helpMenu->addAction(contributorsAct); + burnMenu = menuBar()->addMenu(tr("Read/Write")); + burnMenu->addAction(writeEepromAct); + burnMenu->addAction(readEepromAct); + burnMenu->addSeparator(); + burnMenu->addAction(writeBackupToRadioAct); + burnMenu->addAction(readBackupToFileAct); + burnMenu->addSeparator(); + burnMenu->addAction(writeFlashAct); + burnMenu->addAction(readFlashAct); + burnMenu->addSeparator(); + burnMenu->addSeparator(); + if (!IS_ARM(getCurrentBoard())) { + burnMenu->addAction(burnFusesAct); + burnMenu->addAction(burnListAct); + } + menuBar()->addSeparator(); + helpMenu = menuBar()->addMenu(tr("Help")); + helpMenu->addSeparator(); + helpMenu->addAction(checkForUpdatesAct); + helpMenu->addSeparator(); + helpMenu->addAction(aboutAct); + helpMenu->addAction(openDocURLAct); + helpMenu->addSeparator(); + helpMenu->addAction(changelogAct); + helpMenu->addAction(fwchangelogAct); + helpMenu->addSeparator(); + helpMenu->addAction(contributorsAct); } QMenu *MainWindow::createRecentFileMenu() { - QMenu *recentFileMenu = new QMenu(this); - for ( int i = 0; i < MAX_RECENT; ++i) - recentFileMenu->addAction(recentFileActs[i]); - return recentFileMenu; + QMenu *recentFileMenu = new QMenu(this); + for ( int i = 0; i < MAX_RECENT; ++i) { + recentFileMenu->addAction(recentFileActs[i]); + } + return recentFileMenu; } QMenu *MainWindow::createProfilesMenu() { - QMenu *profilesMenu=new QMenu(tr("Radio Profile"), this); - int i; - for ( i = 0; i < MAX_PROFILES; ++i) { - profilesMenu->addAction(profileActs[i]); - } - profilesMenu->addSeparator(); + QMenu *profilesMenu=new QMenu(tr("Radio Profile"), this); + for (int i = 0; i < MAX_PROFILES; ++i) { + profilesMenu->addAction(profileActs[i]); + } + profilesMenu->addSeparator(); - profilesMenu->addAction(createProfileAct); - profilesMenu->setIcon(CompanionIcon("profiles.png")); - return profilesMenu; + profilesMenu->addAction(createProfileAct); + profilesMenu->setIcon(CompanionIcon("profiles.png")); + return profilesMenu; } void MainWindow::createToolBars() { - QSize size; - switch(g.iconSize()) { - case 0: - size=QSize(16,16); - break; - case 1: - size=QSize(24,24); - break; - case 2: - size=QSize(32,32); - break; - case 3: - size=QSize(48,48); - break; - default: - size=QSize(24,24); - break; - } - fileToolBar = addToolBar(tr("File")); - fileToolBar->setIconSize(size); - fileToolBar->setObjectName("File"); - fileToolBar->addAction(newAct); - fileToolBar->addAction(openAct); + QSize size; + switch(g.iconSize()) { + case 0: + size=QSize(16,16); + break; + case 1: + size=QSize(24,24); + break; + case 2: + size=QSize(32,32); + break; + case 3: + size=QSize(48,48); + break; + default: + size=QSize(24,24); + break; + } + fileToolBar = addToolBar(tr("File")); + fileToolBar->setIconSize(size); + fileToolBar->setObjectName("File"); + fileToolBar->addAction(newAct); + fileToolBar->addAction(openAct); - QToolButton * recentToolButton = new QToolButton; - recentToolButton->setPopupMode(QToolButton::InstantPopup); - recentToolButton->setFocusPolicy(Qt::NoFocus); - recentToolButton->setMenu(createRecentFileMenu()); - recentToolButton->setIcon(CompanionIcon("recentdocument.png")); - recentToolButton->setToolTip(tr("Recent Models+Settings")); - recentToolButton->setStatusTip(tr("Show recent Models+Settings documents")); + QToolButton * recentToolButton = new QToolButton; + recentToolButton->setPopupMode(QToolButton::InstantPopup); + recentToolButton->setFocusPolicy(Qt::NoFocus); + recentToolButton->setMenu(createRecentFileMenu()); + recentToolButton->setIcon(CompanionIcon("recentdocument.png")); + recentToolButton->setToolTip(tr("Recent Models+Settings")); + recentToolButton->setStatusTip(tr("Show recent Models+Settings documents")); - fileToolBar->addWidget(recentToolButton); - fileToolBar->addAction(saveAct); - fileToolBar->addSeparator(); - fileToolBar->addAction(logsAct); - fileToolBar->addAction(fwPrefsAct); - fileToolBar->addSeparator(); - fileToolBar->addAction(appPrefsAct); + fileToolBar->addWidget(recentToolButton); + fileToolBar->addAction(saveAct); + fileToolBar->addSeparator(); + fileToolBar->addAction(logsAct); + fileToolBar->addAction(fwPrefsAct); + fileToolBar->addSeparator(); + fileToolBar->addAction(appPrefsAct); - QToolButton * profileButton = new QToolButton; - profileButton->setPopupMode(QToolButton::InstantPopup); - profileButton->setFocusPolicy(Qt::NoFocus); - profileButton->setMenu(createProfilesMenu()); - profileButton->setIcon(CompanionIcon("profiles.png")); - profileButton->setToolTip(tr("Radio Profile")); - profileButton->setStatusTip(tr("Show the list of radio profiles")); + QToolButton * profileButton = new QToolButton; + profileButton->setPopupMode(QToolButton::InstantPopup); + profileButton->setFocusPolicy(Qt::NoFocus); + profileButton->setMenu(createProfilesMenu()); + profileButton->setIcon(CompanionIcon("profiles.png")); + profileButton->setToolTip(tr("Radio Profile")); + profileButton->setStatusTip(tr("Show the list of radio profiles")); - fileToolBar->addWidget(profileButton); - fileToolBar->addAction(editSplashAct); - fileToolBar->addSeparator(); - fileToolBar->addAction(simulateAct); - fileToolBar->addAction(printAct); - fileToolBar->addAction(compareAct); - fileToolBar->addAction(sdsyncAct); + fileToolBar->addWidget(profileButton); + fileToolBar->addAction(editSplashAct); + fileToolBar->addSeparator(); + fileToolBar->addAction(simulateAct); + fileToolBar->addAction(printAct); + fileToolBar->addAction(compareAct); + fileToolBar->addAction(sdsyncAct); - editToolBar = addToolBar(tr("Edit")); - editToolBar->setIconSize(size); - editToolBar->setObjectName("Edit"); - editToolBar->addAction(cutAct); - editToolBar->addAction(copyAct); - editToolBar->addAction(pasteAct); + editToolBar = addToolBar(tr("Edit")); + editToolBar->setIconSize(size); + editToolBar->setObjectName("Edit"); + editToolBar->addAction(cutAct); + editToolBar->addAction(copyAct); + editToolBar->addAction(pasteAct); - burnToolBar = new QToolBar(tr("Write")); - addToolBar( Qt::LeftToolBarArea, burnToolBar ); - burnToolBar->setIconSize(size); - burnToolBar->setObjectName("Write"); - burnToolBar->addAction(writeEepromAct); - burnToolBar->addAction(readEepromAct); - burnToolBar->addSeparator(); - burnToolBar->addAction(writeBackupToRadioAct); - burnToolBar->addAction(readBackupToFileAct); - burnToolBar->addSeparator(); - burnToolBar->addAction(writeFlashAct); - burnToolBar->addAction(readFlashAct); - burnToolBar->addSeparator(); - burnToolBar->addAction(burnConfigAct); + burnToolBar = new QToolBar(tr("Write")); + addToolBar( Qt::LeftToolBarArea, burnToolBar ); + burnToolBar->setIconSize(size); + burnToolBar->setObjectName("Write"); + burnToolBar->addAction(writeEepromAct); + burnToolBar->addAction(readEepromAct); + burnToolBar->addSeparator(); + burnToolBar->addAction(writeBackupToRadioAct); + burnToolBar->addAction(readBackupToFileAct); + burnToolBar->addSeparator(); + burnToolBar->addAction(writeFlashAct); + burnToolBar->addAction(readFlashAct); + burnToolBar->addSeparator(); + burnToolBar->addAction(burnConfigAct); - helpToolBar = addToolBar(tr("Help")); - helpToolBar->setIconSize(size); - helpToolBar->setObjectName("Help"); - helpToolBar->addAction(checkForUpdatesAct); - helpToolBar->addAction(aboutAct); + helpToolBar = addToolBar(tr("Help")); + helpToolBar->setIconSize(size); + helpToolBar->setObjectName("Help"); + helpToolBar->addAction(checkForUpdatesAct); + helpToolBar->addAction(aboutAct); } void MainWindow::createStatusBar() { - statusBar()->showMessage(tr("Ready")); + statusBar()->showMessage(tr("Ready")); } MdiChild *MainWindow::activeMdiChild() { - if (QMdiSubWindow *activeSubWindow = mdiArea->activeSubWindow()) - return qobject_cast(activeSubWindow->widget()); - return 0; + if (QMdiSubWindow *activeSubWindow = mdiArea->activeSubWindow()) + return qobject_cast(activeSubWindow->widget()); + return 0; } QMdiSubWindow *MainWindow::findMdiChild(const QString &fileName) { - QString canonicalFilePath = QFileInfo(fileName).canonicalFilePath(); + QString canonicalFilePath = QFileInfo(fileName).canonicalFilePath(); - foreach (QMdiSubWindow *window, mdiArea->subWindowList()) { - MdiChild *mdiChild = qobject_cast(window->widget()); - if (mdiChild->currentFile() == canonicalFilePath) - return window; - } - return 0; + foreach (QMdiSubWindow *window, mdiArea->subWindowList()) { + MdiChild *mdiChild = qobject_cast(window->widget()); + if (mdiChild->currentFile() == canonicalFilePath) + return window; + } + return 0; } void MainWindow::setActiveSubWindow(QWidget *window) { - if (!window) - return; - mdiArea->setActiveSubWindow(qobject_cast(window)); + if (!window) return; + mdiArea->setActiveSubWindow(qobject_cast(window)); } void MainWindow::updateRecentFileActions() { - int i, numRecentFiles; + // Hide all document slots + for (int i=0 ; isetVisible(false); + } - // Hide all document slots - for ( i=0 ; i < g.historySize(); i++) - recentFileActs[i]->setVisible(false); + // Fill slots with content and unhide them + QStringList files = g.recentFiles(); + int numRecentFiles = qMin(files.size(), g.historySize()); - // Fill slots with content and unhide them - QStringList files = g.recentFiles(); - numRecentFiles = qMin(files.size(), g.historySize()); - - for ( i = 0; i < numRecentFiles; i++) { - QString text = strippedName(files[i]); - if (!text.trimmed().isEmpty()) - { - recentFileActs[i]->setText(text); - recentFileActs[i]->setData(files[i]); - recentFileActs[i]->setVisible(true); - } + for (int i=0; isetText(text); + recentFileActs[i]->setData(files[i]); + recentFileActs[i]->setVisible(true); } + } } void MainWindow::updateIconSizeActions() { - switch (g.iconSize()) - { + switch (g.iconSize()) { case 0: smallIconAct->setChecked(true); break; case 1: normalIconAct->setChecked(true); break; case 2: bigIconAct->setChecked(true); break; @@ -1359,8 +1348,7 @@ void MainWindow::updateLanguageActions() void MainWindow::updateIconThemeActions() { - switch (g.theme()) - { + switch (g.theme()) { case 0: classicThemeAct->setChecked(true); break; case 1: yericoThemeAct->setChecked(true); break; case 2: monoWhiteAct->setChecked(true); break; @@ -1371,10 +1359,8 @@ void MainWindow::updateIconThemeActions() void MainWindow::updateProfilesActions() { - for (int i=0; isetText(text); profileActs[i]->setData(i); @@ -1382,8 +1368,7 @@ void MainWindow::updateProfilesActions() if (i == g.id()) profileActs[i]->setChecked(true); } - else - { + else { profileActs[i]->setVisible(false); } } @@ -1392,8 +1377,7 @@ void MainWindow::updateProfilesActions() void MainWindow::createProfile() { int i; - for (i=0; imimeData()->hasFormat("text/uri-list")) - event->acceptProposedAction(); + if (event->mimeData()->hasFormat("text/uri-list")) + event->acceptProposedAction(); } void MainWindow::dropEvent(QDropEvent *event) { - if(getCurrentBoard()== BOARD_HORUS) - return; - QList urls = event->mimeData()->urls(); - if (urls.isEmpty()) - return; + if(getCurrentBoard()== BOARD_HORUS) + return; + QList urls = event->mimeData()->urls(); + if (urls.isEmpty()) + return; - QString fileName = urls.first().toLocalFile(); - if (fileName.isEmpty()) - return; - g.eepromDir(QFileInfo(fileName).dir().absolutePath()); + QString fileName = urls.first().toLocalFile(); + if (fileName.isEmpty()) + return; + g.eepromDir(QFileInfo(fileName).dir().absolutePath()); - QMdiSubWindow *existing = findMdiChild(fileName); - if (existing) { - mdiArea->setActiveSubWindow(existing); - return; - } + QMdiSubWindow *existing = findMdiChild(fileName); + if (existing) { + mdiArea->setActiveSubWindow(existing); + return; + } - MdiChild *child = createMdiChild(); - if (child->loadFile(fileName)) { - statusBar()->showMessage(tr("File loaded"), 2000); - child->show(); - } + MdiChild *child = createMdiChild(); + if (child->loadFile(fileName)) { + statusBar()->showMessage(tr("File loaded"), 2000); + child->show(); + } } void MainWindow::autoClose() { - this->close(); + this->close(); }