1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-26 17:55:19 +03:00

Companion menu selections are now marked the propper way for each operating system. Previously they were marked in nonstandard ways or not at all.

This commit is contained in:
Kjell Kernen 2014-02-13 00:05:22 +01:00
parent 26d9455b8a
commit 6f807b007b
2 changed files with 142 additions and 28 deletions

View file

@ -1583,8 +1583,7 @@ void MainWindow::updateMenus()
burnToAct->setEnabled(hasMdiChild); burnToAct->setEnabled(hasMdiChild);
separatorAct->setVisible(hasMdiChild); separatorAct->setVisible(hasMdiChild);
bool hasSelection = (activeMdiChild() && bool hasSelection = (activeMdiChild() && activeMdiChild()->hasSelection());
activeMdiChild()->hasSelection());
cutAct->setEnabled(hasSelection); cutAct->setEnabled(hasSelection);
copyAct->setEnabled(hasSelection); copyAct->setEnabled(hasSelection);
simulateAct->setEnabled(hasSelection); simulateAct->setEnabled(hasSelection);
@ -1593,6 +1592,9 @@ void MainWindow::updateMenus()
compareAct->setEnabled(activeMdiChild()); compareAct->setEnabled(activeMdiChild());
updateRecentFileActions(); updateRecentFileActions();
updateProfilesActions(); updateProfilesActions();
updateLanguageActions();
updateIconSizeActions();
updateIconThemeActions();
QSettings settings; QSettings settings;
setWindowTitle(tr("OpenTX Companion - FW: %1 - Profile: %2").arg(GetCurrentFirmware()->name).arg(settings.value("profileId").toString())); setWindowTitle(tr("OpenTX Companion - FW: %1 - Profile: %2").arg(GetCurrentFirmware()->name).arg(settings.value("profileId").toString()));
@ -1766,9 +1768,13 @@ void MainWindow::createActions()
} }
updateRecentFileActions(); updateRecentFileActions();
QActionGroup *profilesAlignmentGroup = new QActionGroup(this);
for (int i=0; i<MAX_PROFILES; i++) { for (int i=0; i<MAX_PROFILES; i++) {
profileActs[i] = new QAction(this); profileActs[i] = new QAction(this);
profileActs[i]->setVisible(false); profileActs[i]->setVisible(false);
profileActs[i]->setCheckable(true);
profilesAlignmentGroup->addAction(profileActs[i]);
connect(profileActs[i], SIGNAL(triggered()), this, SLOT(loadProfile())); connect(profileActs[i], SIGNAL(triggered()), this, SLOT(loadProfile()));
} }
updateProfilesActions(); updateProfilesActions();
@ -1776,86 +1782,138 @@ void MainWindow::createActions()
createProfileAct->setStatusTip(tr("Create a new Radio Setting Profile")); createProfileAct->setStatusTip(tr("Create a new Radio Setting Profile"));
connect(createProfileAct, SIGNAL(triggered()), this, SLOT(createProfile())); connect(createProfileAct, SIGNAL(triggered()), this, SLOT(createProfile()));
QActionGroup *themeAlignmentGroup = new QActionGroup(this);
classicThemeAct = new QAction(tr("Classical"), this); classicThemeAct = new QAction(tr("Classical"), this);
classicThemeAct->setCheckable(true);
classicThemeAct->setStatusTip(tr("The classical Companion icon theme")); classicThemeAct->setStatusTip(tr("The classical Companion icon theme"));
themeAlignmentGroup->addAction(classicThemeAct);
connect(classicThemeAct, SIGNAL(triggered()), this, SLOT(setClassicTheme())); connect(classicThemeAct, SIGNAL(triggered()), this, SLOT(setClassicTheme()));
newThemeAct = new QAction(tr("New"), this); newThemeAct = new QAction(tr("New"), this);
newThemeAct->setCheckable(true);
newThemeAct->setStatusTip(tr("The Companion 2.0 colored icon theme")); newThemeAct->setStatusTip(tr("The Companion 2.0 colored icon theme"));
themeAlignmentGroup->addAction(newThemeAct);
connect(newThemeAct, SIGNAL(triggered()), this, SLOT(setNewTheme())); connect(newThemeAct, SIGNAL(triggered()), this, SLOT(setNewTheme()));
monoThemeAct = new QAction("Monochrome",this); monoThemeAct = new QAction("Monochrome",this);
monoThemeAct->setCheckable(true);
monoThemeAct->setStatusTip(tr("A monochrome black icon theme")); monoThemeAct->setStatusTip(tr("A monochrome black icon theme"));
themeAlignmentGroup->addAction(monoThemeAct);
connect(monoThemeAct, SIGNAL(triggered()), this, SLOT(setMonochromeTheme())); connect(monoThemeAct, SIGNAL(triggered()), this, SLOT(setMonochromeTheme()));
monoWhiteThemeAct = new QAction("MonoWhite",this); monoWhiteThemeAct = new QAction("MonoWhite",this);
monoWhiteThemeAct->setCheckable(true);
monoWhiteThemeAct->setStatusTip(tr("A monochrome white icon theme")); monoWhiteThemeAct->setStatusTip(tr("A monochrome white icon theme"));
themeAlignmentGroup->addAction(monoWhiteThemeAct);
connect(monoWhiteThemeAct, SIGNAL(triggered()), this, SLOT(setMonoWhiteTheme())); connect(monoWhiteThemeAct, SIGNAL(triggered()), this, SLOT(setMonoWhiteTheme()));
monoBlueThemeAct = new QAction("MonoBlue",this); monoBlueThemeAct = new QAction("MonoBlue",this);
monoBlueThemeAct->setCheckable(true);
monoBlueThemeAct->setStatusTip(tr("A monochrome blue icon theme")); monoBlueThemeAct->setStatusTip(tr("A monochrome blue icon theme"));
themeAlignmentGroup->addAction(monoBlueThemeAct);
connect(monoBlueThemeAct, SIGNAL(triggered()), this, SLOT(setMonoBlueTheme())); connect(monoBlueThemeAct, SIGNAL(triggered()), this, SLOT(setMonoBlueTheme()));
QActionGroup *iconAlignmentGroup = new QActionGroup(this);
smallIconAct = new QAction(tr("Small"),this); smallIconAct = new QAction(tr("Small"),this);
smallIconAct->setStatusTip(tr("Use small toolbar icons")); smallIconAct->setStatusTip(tr("Use small toolbar icons"));
smallIconAct->setCheckable(true);
iconAlignmentGroup->addAction(smallIconAct);
connect(smallIconAct, SIGNAL(triggered()), this, SLOT(setSmallIconThemeSize())); connect(smallIconAct, SIGNAL(triggered()), this, SLOT(setSmallIconThemeSize()));
normalIconAct = new QAction(this); normalIconAct = new QAction(this);
normalIconAct->setStatusTip(tr("Use normal size toolbar icons")); normalIconAct->setStatusTip(tr("Use normal size toolbar icons"));
normalIconAct->setText(tr("Normal")); normalIconAct->setText(tr("Normal"));
normalIconAct->setCheckable(true);
iconAlignmentGroup->addAction(normalIconAct);
connect(normalIconAct, SIGNAL(triggered()), this, SLOT(setNormalIconThemeSize())); connect(normalIconAct, SIGNAL(triggered()), this, SLOT(setNormalIconThemeSize()));
bigIconAct = new QAction(this); bigIconAct = new QAction(this);
bigIconAct->setStatusTip(tr("Use big toolbar icons")); bigIconAct->setStatusTip(tr("Use big toolbar icons"));
bigIconAct->setText(tr("Big")); bigIconAct->setText(tr("Big"));
bigIconAct->setCheckable(true);
iconAlignmentGroup->addAction(bigIconAct);
connect(bigIconAct, SIGNAL(triggered()), this, SLOT(setBigIconThemeSize())); connect(bigIconAct, SIGNAL(triggered()), this, SLOT(setBigIconThemeSize()));
hugeIconAct = new QAction(this); hugeIconAct = new QAction(this);
hugeIconAct->setStatusTip(tr("Use huge toolbar icons")); hugeIconAct->setStatusTip(tr("Use huge toolbar icons"));
hugeIconAct->setText(tr("Huge")); hugeIconAct->setText(tr("Huge"));
hugeIconAct->setCheckable(true);
iconAlignmentGroup->addAction(hugeIconAct);
connect(hugeIconAct, SIGNAL(triggered()), this, SLOT(setHugeIconThemeSize())); connect(hugeIconAct, SIGNAL(triggered()), this, SLOT(setHugeIconThemeSize()));
QActionGroup *languageAlignmentGroup = new QActionGroup(this);
defaultLanguageAct = new QAction(tr("System default language"),this); defaultLanguageAct = new QAction(tr("System default language"),this);
defaultLanguageAct->setStatusTip(tr("Use system default language in menus")); defaultLanguageAct->setStatusTip(tr("Use system default language in menus"));
defaultLanguageAct->setCheckable(true);
languageAlignmentGroup->addAction(defaultLanguageAct);
connect(defaultLanguageAct, SIGNAL(triggered()), this, SLOT(setDefaultLanguage())); connect(defaultLanguageAct, SIGNAL(triggered()), this, SLOT(setDefaultLanguage()));
czechLanguageAct = new QAction(tr("Czech"),this); czechLanguageAct = new QAction(tr("Czech"),this);
czechLanguageAct->setStatusTip(tr("Use Czech in menus")); czechLanguageAct->setStatusTip(tr("Use Czech in menus"));
czechLanguageAct->setCheckable(true);
languageAlignmentGroup->addAction(czechLanguageAct);
connect(czechLanguageAct, SIGNAL(triggered()), this, SLOT(setCZLanguage())); connect(czechLanguageAct, SIGNAL(triggered()), this, SLOT(setCZLanguage()));
germanLanguageAct = new QAction(tr("German"),this); germanLanguageAct = new QAction(tr("German"),this);
germanLanguageAct->setStatusTip(tr("Use German in menus")); germanLanguageAct->setStatusTip(tr("Use German in menus"));
germanLanguageAct->setCheckable(true);
languageAlignmentGroup->addAction(germanLanguageAct);
connect(germanLanguageAct, SIGNAL(triggered()), this, SLOT(setDELanguage())); connect(germanLanguageAct, SIGNAL(triggered()), this, SLOT(setDELanguage()));
englishLanguageAct = new QAction(tr("English"),this); englishLanguageAct = new QAction(tr("English"),this);
englishLanguageAct->setStatusTip(tr("Use English in menus")); englishLanguageAct->setStatusTip(tr("Use English in menus"));
englishLanguageAct->setCheckable(true);
languageAlignmentGroup->addAction(englishLanguageAct);
connect(englishLanguageAct, SIGNAL(triggered()), this, SLOT(setENLanguage())); connect(englishLanguageAct, SIGNAL(triggered()), this, SLOT(setENLanguage()));
frenchLanguageAct = new QAction(tr("French"),this); frenchLanguageAct = new QAction(tr("French"),this);
frenchLanguageAct->setStatusTip(tr("Use French in menus")); frenchLanguageAct->setStatusTip(tr("Use French in menus"));
frenchLanguageAct->setCheckable(true);
languageAlignmentGroup->addAction(frenchLanguageAct);
connect(frenchLanguageAct, SIGNAL(triggered()), this, SLOT(setFRLanguage())); connect(frenchLanguageAct, SIGNAL(triggered()), this, SLOT(setFRLanguage()));
italianLanguageAct = new QAction(tr("Italian"),this); italianLanguageAct = new QAction(tr("Italian"),this);
italianLanguageAct->setStatusTip(tr("Use Italian in menus")); italianLanguageAct->setStatusTip(tr("Use Italian in menus"));
italianLanguageAct->setCheckable(true);
languageAlignmentGroup->addAction(italianLanguageAct);
connect(italianLanguageAct, SIGNAL(triggered()), this, SLOT(setITLanguage())); connect(italianLanguageAct, SIGNAL(triggered()), this, SLOT(setITLanguage()));
hebrewLanguageAct = new QAction(tr("Hebrew"),this); hebrewLanguageAct = new QAction(tr("Hebrew"),this);
hebrewLanguageAct->setStatusTip(tr("Use Hebrew in menus")); hebrewLanguageAct->setStatusTip(tr("Use Hebrew in menus"));
hebrewLanguageAct->setCheckable(true);
languageAlignmentGroup->addAction(hebrewLanguageAct);
connect(hebrewLanguageAct, SIGNAL(triggered()), this, SLOT(setHELanguage())); connect(hebrewLanguageAct, SIGNAL(triggered()), this, SLOT(setHELanguage()));
polishLanguageAct = new QAction(tr("Polish"),this); polishLanguageAct = new QAction(tr("Polish"),this);
polishLanguageAct->setStatusTip(tr("Use Polish in menus")); polishLanguageAct->setStatusTip(tr("Use Polish in menus"));
polishLanguageAct->setCheckable(true);
languageAlignmentGroup->addAction(polishLanguageAct);
connect(polishLanguageAct, SIGNAL(triggered()), this, SLOT(setPLLanguage())); connect(polishLanguageAct, SIGNAL(triggered()), this, SLOT(setPLLanguage()));
portugueseLanguageAct = new QAction(tr("Portuguese"),this); portugueseLanguageAct = new QAction(tr("Portuguese"),this);
portugueseLanguageAct->setStatusTip(tr("Use Portuguese in menus")); portugueseLanguageAct->setStatusTip(tr("Use Portuguese in menus"));
portugueseLanguageAct->setCheckable(true);
languageAlignmentGroup->addAction(portugueseLanguageAct);
connect(portugueseLanguageAct, SIGNAL(triggered()), this, SLOT(setPTLanguage())); connect(portugueseLanguageAct, SIGNAL(triggered()), this, SLOT(setPTLanguage()));
swedishLanguageAct = new QAction(tr("Swedish"),this); swedishLanguageAct = new QAction(tr("Swedish"),this);
swedishLanguageAct->setStatusTip(tr("Use Swedish in menus")); swedishLanguageAct->setStatusTip(tr("Use Swedish in menus"));
swedishLanguageAct->setCheckable(true);
languageAlignmentGroup->addAction(swedishLanguageAct);
connect(swedishLanguageAct, SIGNAL(triggered()), this, SLOT(setSELanguage())); connect(swedishLanguageAct, SIGNAL(triggered()), this, SLOT(setSELanguage()));
russianLanguageAct = new QAction(tr("Russian"),this); russianLanguageAct = new QAction(tr("Russian"),this);
russianLanguageAct->setStatusTip(tr("Use Russian in menus")); russianLanguageAct->setStatusTip(tr("Use Russian in menus"));
russianLanguageAct->setCheckable(true);
languageAlignmentGroup->addAction(russianLanguageAct);
connect(russianLanguageAct, SIGNAL(triggered()), this, SLOT(setRULanguage())); connect(russianLanguageAct, SIGNAL(triggered()), this, SLOT(setRULanguage()));
openDocumentURLAct = new QAction(tr("Manuals and other Documents"),this); openDocumentURLAct = new QAction(tr("Manuals and other Documents"),this);
openDocumentURLAct->setStatusTip(tr("Open the OpenTX document page in a web browser")); openDocumentURLAct->setStatusTip(tr("Open the OpenTX document page in a web browser"));
connect(openDocumentURLAct, SIGNAL(triggered()), this, SLOT(openDocumentURL())); connect(openDocumentURLAct, SIGNAL(triggered()), this, SLOT(openDocumentURL()));
} }
void MainWindow::createMenus() void MainWindow::createMenus()
@ -1904,6 +1962,8 @@ void MainWindow::createMenus()
languageMenu->addAction(portugueseLanguageAct); languageMenu->addAction(portugueseLanguageAct);
languageMenu->addAction(swedishLanguageAct); languageMenu->addAction(swedishLanguageAct);
languageMenu->addAction(russianLanguageAct); languageMenu->addAction(russianLanguageAct);
settingsMenu->addMenu(themeMenu); settingsMenu->addMenu(themeMenu);
themeMenu->addAction(classicThemeAct); themeMenu->addAction(classicThemeAct);
themeMenu->addAction(newThemeAct); themeMenu->addAction(newThemeAct);
@ -2113,12 +2173,64 @@ void MainWindow::updateRecentFileActions()
} }
for ( j = numRecentFiles; j < MaxRecentFiles; ++j) for ( j = numRecentFiles; j < MaxRecentFiles; ++j)
recentFileActs[j]->setVisible(false); recentFileActs[j]->setVisible(false);
}
// separatorAct->setVisible(numRecentFiles > 0); void MainWindow::updateIconSizeActions()
{
QSettings settings;
int size = settings.value("icon_size","0").toInt();
switch (size){
case 0: smallIconAct->setChecked(true); break;
case 1: normalIconAct->setChecked(true); break;
case 2: bigIconAct->setChecked(true); break;
case 3: hugeIconAct->setChecked(true); break;
}
}
void MainWindow::updateLanguageActions()
{
QSettings settings;
QString langId = settings.value("locale","").toString();
if (langId=="")
defaultLanguageAct->setChecked(true);
else if (langId=="cs_CZ")
czechLanguageAct->setChecked(true);
else if (langId=="de_DE")
germanLanguageAct->setChecked(true);
else if (langId=="en")
englishLanguageAct->setChecked(true);
else if (langId=="fr_FR")
frenchLanguageAct->setChecked(true);
else if (langId=="it_IT")
italianLanguageAct->setChecked(true);
else if (langId=="he_IL")
hebrewLanguageAct->setChecked(true);
else if (langId=="pl_PL")
polishLanguageAct->setChecked(true);
else if (langId=="pt_PT")
portugueseLanguageAct->setChecked(true);
else if (langId=="ru_RU")
russianLanguageAct->setChecked(true);
else if (langId=="sv_SE")
swedishLanguageAct->setChecked(true);
}
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;
}
} }
void MainWindow::updateProfilesActions() void MainWindow::updateProfilesActions()
{ {
int i; int i;
QSettings settings; QSettings settings;
int activeProfile = settings.value("profileId").toInt(); int activeProfile = settings.value("profileId").toInt();
@ -2134,11 +2246,9 @@ void MainWindow::updateProfilesActions()
profileActs[i]->setData(i+1); profileActs[i]->setData(i+1);
profileActs[i]->setVisible(true); profileActs[i]->setVisible(true);
if ((i+1) == activeProfile) if ((i+1) == activeProfile)
profileActs[i]->setIcon(CompanionIcon("arrow-right.png")); profileActs[i]->setChecked(true);
else }
profileActs[i]->setIcon(CompanionIcon("")); else {
} else {
profileActs[i]->setVisible(false); profileActs[i]->setVisible(false);
} }
settings.endGroup(); settings.endGroup();

View file

@ -163,6 +163,10 @@ private:
void readSettings(); void readSettings();
void updateRecentFileActions(); void updateRecentFileActions();
void updateProfilesActions(); void updateProfilesActions();
void updateIconSizeActions();
void updateLanguageActions();
void updateIconThemeActions();
int getFileType(const QString &fullFileName); int getFileType(const QString &fullFileName);
QString FindTaranisPath(); QString FindTaranisPath();
QString Theme; QString Theme;