1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-24 00:35:18 +03:00

Refactoring to have messages in Companion when opening eeprom.

This commit is contained in:
Grieb 2015-08-27 14:54:45 -03:00
parent 14967b6a94
commit 6d52039266
17 changed files with 433 additions and 226 deletions

View file

@ -115,12 +115,12 @@ MainWindow::MainWindow():
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);
updateDelay += (SPLASH_TIME*1000);
}
QTimer::singleShot(updateDelay, this, SLOT(doAutoUpdates()));
QTimer::singleShot(updateDelay, this, SLOT(displayWarnings()));
@ -158,13 +158,13 @@ MainWindow::MainWindow():
child->show();
}
else {
child->show();
child->show();
child->print(model,printfilename);
child->close();
}
}
}
}
}
if (printing) {
QTimer::singleShot(0, this, SLOT(autoClose()));
}
@ -185,7 +185,7 @@ void MainWindow::displayWarnings()
}
}
else if (warnId==0) {
g.warningId(WARNING_ID);
g.warningId(WARNING_ID);
}
}
@ -292,15 +292,15 @@ void MainWindow::checkForCompanionUpdateFinished(QNetworkReply * reply)
int c9xver = version2index(c9xversion);
if (c9xver < vnum) {
#if defined WIN32 || !defined __GNUC__ // || defined __APPLE__ // OSX should only notify of updates since no update packages are available.
#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)<br>"
"Would you like to download it?").arg(version) ,
QMessageBox::Yes | QMessageBox::No);
if (ret == QMessageBox::Yes) {
#if defined __APPLE__
#if defined __APPLE__
QString fileName = QFileDialog::getSaveFileName(this, tr("Save As"), g.updatesDir() + QString(COMPANION_INSTALLER).arg(version));
#else
#else
QString fileName = QFileDialog::getSaveFileName(this, tr("Save As"), g.updatesDir() + QString(COMPANION_INSTALLER).arg(version), tr("Executable (*.exe)"));
#endif
if (!fileName.isEmpty()) {
@ -313,7 +313,7 @@ void MainWindow::checkForCompanionUpdateFinished(QNetworkReply * reply)
}
#else
QMessageBox::warning(this, tr("New release available"), tr("A new release of Companion is available, please check the OpenTX website!"));
#endif
#endif
}
else {
if (downloadDialog_forWait && checkForUpdatesState==0) {
@ -539,19 +539,19 @@ void MainWindow::closeEvent(QCloseEvent *event)
}
void MainWindow::setLanguage(const QString & langString)
{
{
g.locale(langString);
QMessageBox::information(this, tr("Companion"), tr("The selected language will be used the next time you start Companion."));
}
void MainWindow::setTheme(int index)
{
{
g.theme(index);
QMessageBox::information(this, tr("Companion"), tr("The new theme will be loaded the next time you start Companion."));
}
void MainWindow::setIconThemeSize(int index)
{
{
g.iconSize(index);
QMessageBox::information(this, tr("Companion"), tr("The icon size will be used the next time you start Companion."));
}
@ -705,7 +705,7 @@ void MainWindow::fwchangelog()
}
void MainWindow::customizeSplash()
{
{
customizeSplashDialog * dialog = new customizeSplashDialog(this);
dialog->exec();
}
@ -763,7 +763,7 @@ void MainWindow::readEeprom()
EEPROMInterface *eepromInterface = GetEepromInterface();
if (IS_ARM(eepromInterface->getBoard()))
if (IS_ARM(eepromInterface->getBoard()))
tempFile = generateProcessUniqueTempFileName("temp.bin");
else
tempFile += generateProcessUniqueTempFileName("temp.hex");
@ -920,7 +920,7 @@ void MainWindow::updateMenus()
pasteAct->setEnabled(hasMdiChild ? activeMdiChild()->hasPasteData() : false);
writeEepromAct->setEnabled(hasMdiChild);
separatorAct->setVisible(hasMdiChild);
bool hasSelection = (activeMdiChild() && activeMdiChild()->hasSelection());
cutAct->setEnabled(hasSelection);
copyAct->setEnabled(hasSelection);
@ -962,7 +962,7 @@ QAction * MainWindow::addAct(const QString & icon, const QString & sName, const
QAction * newAction = new QAction( this );
if (!icon.isEmpty())
newAction->setIcon(CompanionIcon(icon));
if (!sName.isEmpty())
if (!sName.isEmpty())
newAction->setText(sName);
if (!lName.isEmpty())
newAction->setStatusTip(lName);
@ -983,7 +983,7 @@ QAction * MainWindow::addAct(QActionGroup *aGroup, const QString & sName, const
{
QAction *action = addAct("", sName, lName, QKeySequence::UnknownKey, slot);
action->setCheckable(true);
aGroup->addAction(action);
aGroup->addAction(action);
return action;
}
@ -1017,7 +1017,7 @@ void MainWindow::createActions()
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()));
@ -1072,7 +1072,7 @@ void MainWindow::createActions()
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);
@ -1156,7 +1156,7 @@ void MainWindow::createMenus()
burnMenu->addSeparator();
burnMenu->addSeparator();
EEPROMInterface *eepromInterface = GetEepromInterface();
if (!IS_ARM(eepromInterface->getBoard())) {
if (!IS_ARM(eepromInterface->getBoard())) {
burnMenu->addAction(burnFusesAct);
burnMenu->addAction(burnListAct);
}
@ -1173,7 +1173,7 @@ void MainWindow::createMenus()
helpMenu->addSeparator();
helpMenu->addAction(contributorsAct);
}
QMenu *MainWindow::createRecentFileMenu()
{
QMenu *recentFileMenu = new QMenu(this);
@ -1214,7 +1214,7 @@ void MainWindow::createToolBars()
break;
default:
size=QSize(24,24);
break;
break;
}
fileToolBar = addToolBar(tr("File"));
fileToolBar->setIconSize(size);
@ -1260,7 +1260,7 @@ void MainWindow::createToolBars()
editToolBar->addAction(cutAct);
editToolBar->addAction(copyAct);
editToolBar->addAction(pasteAct);
burnToolBar = new QToolBar(tr("Write"));
addToolBar( Qt::LeftToolBarArea, burnToolBar );
burnToolBar->setIconSize(size);
@ -1317,7 +1317,7 @@ void MainWindow::setActiveSubWindow(QWidget *window)
void MainWindow::updateRecentFileActions()
{
int i, numRecentFiles;
// Hide all document slots
for ( i=0 ; i < g.historySize(); i++)
recentFileActs[i]->setVisible(false);
@ -1325,7 +1325,7 @@ void MainWindow::updateRecentFileActions()
// 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())
@ -1352,33 +1352,33 @@ void MainWindow::updateLanguageActions()
{
QString langId = g.locale();
if (langId=="")
if (langId=="")
sysLangAct->setChecked(true);
else if (langId=="cs_CZ")
else if (langId=="cs_CZ")
czechLangAct->setChecked(true);
else if (langId=="de_DE")
else if (langId=="de_DE")
germanLangAct->setChecked(true);
else if (langId=="en")
else if (langId=="en")
englishLangAct->setChecked(true);
else if (langId=="fi_FI")
else if (langId=="fi_FI")
finnishLangAct->setChecked(true);
else if (langId=="fr_FR")
else if (langId=="fr_FR")
frenchLangAct->setChecked(true);
else if (langId=="it_IT")
else if (langId=="it_IT")
italianLangAct->setChecked(true);
// else if (langId=="he_IL")
// else if (langId=="he_IL")
// hebrewLangAct->setChecked(true);
else if (langId=="pl_PL")
else if (langId=="pl_PL")
polishLangAct->setChecked(true);
// else if (langId=="pt_PT")
// else if (langId=="pt_PT")
// portugueseLangAct->setChecked(true);
else if (langId=="es_ES")
spanishLangAct->setChecked(true);
else if (langId=="sv_SE")
else if (langId=="sv_SE")
swedishLangAct->setChecked(true);
// else if (langId=="ru_RU")
// else if (langId=="ru_RU")
// russianLangAct->setChecked(true);
// else if (langId=="nl_NL")
// else if (langId=="nl_NL")
// dutchLangAct->setChecked(true);
}
@ -1396,9 +1396,9 @@ void MainWindow::updateIconThemeActions()
void MainWindow::updateProfilesActions()
{
for (int i=0; i<MAX_PROFILES; i++)
for (int i=0; i<MAX_PROFILES; i++)
{
if (g.profile[i].existsOnDisk())
if (g.profile[i].existsOnDisk())
{
QString text = tr("%2").arg(g.profile[i].name());
profileActs[i]->setText(text);
@ -1406,8 +1406,8 @@ void MainWindow::updateProfilesActions()
profileActs[i]->setVisible(true);
if (i == g.id())
profileActs[i]->setChecked(true);
}
else
}
else
{
profileActs[i]->setVisible(false);
}
@ -1421,7 +1421,7 @@ void MainWindow::createProfile()
;
if (i==MAX_PROFILES) //Failed to find free slot
return;
// Copy current profile to new and give it a new name
g.profile[i] = g.profile[g.id()];
g.profile[i].name(tr("New Radio"));