Merge pull request #684 from opentx/dvogonen/tabbed_preferences

Dvogonen/tabbed preferences
This commit is contained in:
Bertrand Songis
2014-02-11 08:47:19 +01:00
19 changed files with 2109 additions and 1472 deletions
-3
View File
@@ -155,7 +155,6 @@ SET( companion_SRCS
modelslist.cpp
mountlist.cpp
avroutputdialog.cpp
preferencesdialog.cpp
apppreferencesdialog.cpp
fwpreferencesdialog.cpp
burnconfigdialog.cpp
@@ -178,7 +177,6 @@ SET( companion_SRCS
SET( companion_MOC_HDRS
avroutputdialog.h
preferencesdialog.h
apppreferencesdialog.h
fwpreferencesdialog.h
burnconfigdialog.h
@@ -214,7 +212,6 @@ SET( companion_UIS
comparedialog.ui
fusesdialog.ui
logsdialog.ui
preferencesdialog.ui
apppreferencesdialog.ui
fwpreferencesdialog.ui
simulatordialog.ui
+168 -3
View File
@@ -14,7 +14,7 @@ appPreferencesDialog::appPreferencesDialog(QWidget *parent) :
ui(new Ui::appPreferencesDialog)
{
ui->setupUi(this);
setWindowIcon(CompanionIcon("preferences.png"));
setWindowIcon(CompanionIcon("apppreferences.png"));
initSettings();
connect(this, SIGNAL(accepted()), this, SLOT(writeValues()));
#ifndef JOYSTICKS
@@ -56,8 +56,17 @@ void appPreferencesDialog::writeValues()
settings.remove("js_ctrl");
}
MainWindow * mw = (MainWindow *)this->parent();
mw->unloadProfile();
settings.setValue("default_channel_order", ui->channelorderCB->currentIndex());
settings.setValue("default_mode", ui->stickmodeCB->currentIndex());
settings.setValue("rename_firmware_files", ui->renameFirmware->isChecked());
settings.setValue("burnFirmware", ui->burnFirmware->isChecked());
settings.setValue("profileId", ui->profileIndexLE->text());
settings.setValue("sdPath", ui->sdPath->text());
settings.setValue("SplashFileName", ui->SplashFileName->text());
if (!ui->SplashFileName->text().isEmpty())
settings.setValue("SplashImage", "");
saveProfile();
}
void appPreferencesDialog::on_snapshotPathButton_clicked()
@@ -75,6 +84,7 @@ void appPreferencesDialog::initSettings()
{
QSettings settings;
ui->snapshotClipboardCKB->setChecked(settings.value("snapshot_to_clipboard", false).toBool());
ui->burnFirmware->setChecked(settings.value("burnFirmware", true).toBool());
QString Path=settings.value("snapshotPath", "").toString();
if (QDir(Path).exists()) {
@@ -142,6 +152,24 @@ void appPreferencesDialog::initSettings()
ui->joystickcalButton->setDisabled(true);
}
#endif
// Profile Tab Inits
ui->channelorderCB->setCurrentIndex(settings.value("default_channel_order", 0).toInt());
ui->stickmodeCB->setCurrentIndex(settings.value("default_mode", 1).toInt());
ui->renameFirmware->setChecked(settings.value("rename_firmware_files", false).toBool());
Path=settings.value("sdPath", "").toString();
if (QDir(Path).exists()) {
ui->sdPath->setText(Path);
}
ui->profileIndexLE->setText(settings.value("profileId", "").toString());
QString fileName=settings.value("SplashFileName","").toString();
if (!fileName.isEmpty()) {
QFile file(fileName);
if (file.exists()){
ui->SplashFileName->setText(fileName);
displayImage( fileName );
}
}
}
void appPreferencesDialog::on_libraryPathButton_clicked()
@@ -222,3 +250,140 @@ void appPreferencesDialog::on_joystickcalButton_clicked() {
}
#endif
// ******** Profile tab functions
void appPreferencesDialog::on_sdPathButton_clicked()
{
QSettings settings;
QString fileName = QFileDialog::getExistingDirectory(this,tr("Select the folder replicating your SD structure"), settings.value("sdPath").toString());
if (!fileName.isEmpty()) {
ui->sdPath->setText(fileName);
}
}
void appPreferencesDialog::saveProfile()
{
QSettings settings;
QString profile=QString("profile") + settings.value("profileId").toString();
QString name=ui->ProfName_LE->text();
if (name.isEmpty()) {
name = profile;
ui->ProfName_LE->setText(name);
}
settings.beginGroup("Profiles");
settings.beginGroup(profile);
settings.setValue("Name",name);
settings.setValue("default_channel_order", ui->channelorderCB->currentIndex());
settings.setValue("default_mode", ui->stickmodeCB->currentIndex());
settings.setValue("burnFirmware", ui->burnFirmware->isChecked());
settings.setValue("rename_firmware_files", ui->renameFirmware->isChecked());
settings.setValue("sdPath", ui->sdPath->text());
settings.setValue("SplashFileName", ui->SplashFileName->text());
settings.endGroup();
settings.endGroup();
}
void appPreferencesDialog::loadProfileString(QString profile, QString label)
{
QSettings settings;
QString value;
settings.beginGroup("Profiles");
settings.beginGroup(profile);
value = settings.value(label).toString();
settings.endGroup();
settings.endGroup();
settings.setValue( label, value );
}
void appPreferencesDialog::loadProfile()
{
QSettings settings;
QString profile=QString("profile") + settings.value("profileId").toString();
loadProfileString( profile, "Name" );
loadProfileString( profile, "default_channel_order" );
loadProfileString( profile, "default_mode" );
loadProfileString( profile, "burnFirmware" );
loadProfileString( profile, "rename_firmware_files" );
loadProfileString( profile, "sdPath" );
loadProfileString( profile, "SplashFileName" );
}
void appPreferencesDialog::on_removeProfileButton_clicked()
{
QSettings settings;
QString profileId = settings.value("profileId").toString();
if ( profileId == "1" )
QMessageBox::information(this, tr("Not possible to remove profile"), tr("The default profile can not be removed."));
else
{
QString profile=QString("profile") + profileId;
settings.beginGroup("Profiles");
settings.remove(profile);
settings.endGroup();
settings.setValue("profileId", "1");
loadProfile();
initSettings();
}
}
bool appPreferencesDialog::displayImage( QString fileName )
{
QImage image(fileName);
if (image.isNull())
{
QMessageBox::critical(this, tr("Error"), tr("Cannot load %1.").arg(fileName));
return false;
}
int width=ui->imageLabel->width();
ui->imageLabel->setPixmap(QPixmap::fromImage(image.scaled(width, 64)));
if (width==212) {
image=image.convertToFormat(QImage::Format_RGB32);
QRgb col;
int gray, height = image.height();
for (int i = 0; i < width; ++i) {
for (int j = 0; j < height; ++j) {
col = image.pixel(i, j);
gray = qGray(col);
image.setPixel(i, j, qRgb(gray, gray, gray));
}
}
ui->imageLabel->setPixmap(QPixmap::fromImage(image));
}
else {
ui->imageLabel->setPixmap(QPixmap::fromImage(image.convertToFormat(QImage::Format_Mono)));
}
return true;
}
void appPreferencesDialog::on_SplashSelect_clicked()
{
QString supportedImageFormats;
for (int formatIndex = 0; formatIndex < QImageReader::supportedImageFormats().count(); formatIndex++) {
supportedImageFormats += QLatin1String(" *.") + QImageReader::supportedImageFormats()[formatIndex];
}
QSettings settings;
QString fileName = QFileDialog::getOpenFileName(this,
tr("Open Image to load"), settings.value("lastImagesDir").toString(), tr("Images (%1)").arg(supportedImageFormats));
if (!fileName.isEmpty()) {
settings.setValue("lastImagesDir", QFileInfo(fileName).dir().absolutePath());
if (displayImage(fileName))
ui->SplashFileName->setText(fileName);
}
}
void appPreferencesDialog::on_clearImageButton_clicked() {
ui->imageLabel->clear();
ui->SplashFileName->clear();
}
+10
View File
@@ -23,6 +23,10 @@ public:
private:
Ui::appPreferencesDialog *ui;
void initSettings();
bool displayImage( QString fileName );
void saveProfile();
void loadProfileString(QString profile, QString label);
void loadProfile();
private slots:
void writeValues();
@@ -31,6 +35,12 @@ private slots:
void on_snapshotClipboardCKB_clicked();
void on_backupPathButton_clicked();
void on_ge_pathButton_clicked();
void on_sdPathButton_clicked();
void on_removeProfileButton_clicked();
void on_SplashSelect_clicked();
void on_clearImageButton_clicked();
#ifdef JOYSTICKS
void on_joystickChkB_clicked();
void on_joystickcalButton_clicked();
File diff suppressed because it is too large Load Diff
+138 -105
View File
@@ -7,19 +7,128 @@
#include "splashlibrary.h"
#include "flashinterface.h"
//*** Side Class ***
Side::Side(){
imageLabel = 0;
fileNameEdit = 0;
saveButton = 0;
source=new Source;
*source = UNDEFINED;
saveToFileName = new QString("");
source = new Source(UNDEFINED);
}
void Side::copyImage( Side side ){
if ((*source!=UNDEFINED) && (*side.source!=UNDEFINED))
void Side::copyImage( Side side )
{
if ((*source!=UNDEFINED) && (*side.source!=UNDEFINED))
imageLabel->setPixmap(*side.imageLabel->pixmap());
}
bool Side::displayImage( QString fileName, Source pictSource )
{
QImage image;
if (fileName.isEmpty()) {
return false;
}
if (pictSource == FW ){
FlashInterface flash(fileName);
if (!flash.hasSplash())
return false;
else
image = flash.getSplash();
}
else {
image.load(fileName);
}
if (image.isNull()) {
return false;
}
if (imageLabel->width()==424) {
image=image.convertToFormat(QImage::Format_RGB32);
QRgb col;
int gray;
int width = image.width();
int height = image.height();
for (int i = 0; i < width; ++i) {
for (int j = 0; j < height; ++j) {
col = image.pixel(i, j);
gray = qGray(col);
image.setPixel(i, j, qRgb(gray, gray, gray));
}
}
imageLabel->setPixmap(QPixmap::fromImage(image.scaled(imageLabel->width()/2, imageLabel->height()/2)));
}
else {
imageLabel->setPixmap(QPixmap::fromImage(image.scaled(imageLabel->width()/2, imageLabel->height()/2).convertToFormat(QImage::Format_Mono)));
}
switch (pictSource){
case FW:
fileNameEdit->setText(QObject::tr("FW: %1").arg(fileName));
*saveToFileName = fileName;
*source=FW;
break;
case PICT:
fileNameEdit->setText(QObject::tr("Pict: %1").arg(fileName));
*saveToFileName = fileName;
*source=PICT;
break;
case PROFILE:
fileNameEdit->setText(QObject::tr("Profile image"));
*saveToFileName = fileName;
*source=PROFILE;
break;
default:
break;
}
saveButton->setEnabled(true);
libraryButton->setEnabled(true);
invertButton->setEnabled(true);
return true;
}
bool Side::refreshImage()
{
return displayImage( *saveToFileName, *source );
}
bool Side::saveImage()
{
QSettings settings;
if (*source == FW )
{
FlashInterface flash(*saveToFileName);
if (!flash.hasSplash()) {
return false;
}
QImage image = imageLabel->pixmap()->toImage().scaled(flash.getSplashWidth(), flash.getSplashHeight());
if (flash.setSplash(image) && (flash.saveFlash(*saveToFileName) > 0)) {
settings.setValue("lastFlashDir", QFileInfo(*saveToFileName).dir().absolutePath());
}
else {
return false;
}
}
else if (*source == PICT) {
QImage image = imageLabel->pixmap()->toImage().scaled(imageLabel->width()/2, imageLabel->height()/2).convertToFormat(QImage::Format_Indexed8);
if (image.save(*saveToFileName)) {
settings.setValue("lastImagesDir", QFileInfo(*saveToFileName).dir().absolutePath());
}
else {
return false;
}
}
else if (*source == PROFILE) {
QImage image = imageLabel->pixmap()->toImage().scaled(imageLabel->width()/2, imageLabel->height()/2).convertToFormat(QImage::Format_Indexed8);
if (!image.save(*saveToFileName)) {
return false;
}
}
return true;
}
//*** customizeSplashDialog Class ***
customizeSplashDialog::customizeSplashDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::customizeSplashDialog)
@@ -39,6 +148,7 @@ customizeSplashDialog::customizeSplashDialog(QWidget *parent) :
left.invertButton = ui->leftInvertButton;
right.invertButton = ui->rightInvertButton;
loadProfile(left);
resize(0,0);
}
@@ -62,25 +172,10 @@ void customizeSplashDialog::loadFirmware(Side side)
QSettings settings;
QString fileName = QFileDialog::getOpenFileName(this, tr("Open"), settings.value("lastFlashDir").toString(), FLASH_FILES_FILTER);
if (!fileName.isEmpty()) {
QFile file(fileName);
if (fileName.isEmpty() || !file.exists())
return;
FlashInterface flash(fileName);
if (!flash.hasSplash()) {
QMessageBox::information(this, tr("Error"), tr("Could not find bitmap to replace in file"));
return;
}
side.saveButton->setEnabled(true);
side.imageLabel->setPixmap(QPixmap::fromImage(flash.getSplash()));
side.imageLabel->setFixedSize(flash.getSplashWidth()*2,flash.getSplashHeight()*2);
side.fileNameEdit->setText(fileName);
if (!side.displayImage( fileName, FW ))
QMessageBox::critical(this, tr("Error"), tr("Cannot load embedded FW image from %1.").arg(fileName));
else
settings.setValue("lastFlashDir", QFileInfo(fileName).dir().absolutePath());
*side.source=FW;
side.saveButton->setEnabled(true);
side.libraryButton->setEnabled(true);
side.invertButton->setEnabled(true);
}
}
@@ -96,46 +191,25 @@ void customizeSplashDialog::loadPicture(Side side)
QString fileName = QFileDialog::getOpenFileName(this,
tr("Open Image to load"), settings.value("lastImagesDir").toString(), tr("Images (%1)").arg(supportedImageFormats));
if (fileName.isEmpty()){
return;
if (!fileName.isEmpty()) {
if (!side.displayImage( fileName, PICT ))
QMessageBox::critical(this, tr("Error"), tr("Cannot load the image file %1.").arg(fileName));
else
settings.setValue("lastImagesDir", QFileInfo(fileName).dir().absolutePath());
}
QImage image(fileName);
if (image.isNull()) {
QMessageBox::critical(this, tr("Error"), tr("Cannot load %1.").arg(fileName));
return;
}
if (side.imageLabel->width()==424) {
image=image.convertToFormat(QImage::Format_RGB32);
QRgb col;
int gray;
int width = image.width();
int height = image.height();
for (int i = 0; i < width; ++i)
{
for (int j = 0; j < height; ++j)
{
col = image.pixel(i, j);
gray = qGray(col);
image.setPixel(i, j, qRgb(gray, gray, gray));
}
}
side.imageLabel->setPixmap(QPixmap::fromImage(image.scaled(side.imageLabel->width()/2, side.imageLabel->height()/2)));
} else {
side.imageLabel->setPixmap(QPixmap::fromImage(image.scaled(side.imageLabel->width()/2, side.imageLabel->height()/2).convertToFormat(QImage::Format_Mono)));
}
settings.setValue("lastImagesDir", QFileInfo(fileName).dir().absolutePath());
side.fileNameEdit->setText(fileName);
*side.source=PICT;
side.saveButton->setEnabled(true);
side.libraryButton->setEnabled(true);
side.invertButton->setEnabled(true);
}
void customizeSplashDialog::on_leftLoadProfileButton_clicked() {loadProfile(left);}
void customizeSplashDialog::on_rightLoadProfileButton_clicked() {loadProfile(right);}
void customizeSplashDialog::loadProfile(Side side)
{
QSettings settings;
QString fileName=settings.value("SplashFileName","").toString();
if (!fileName.isEmpty()) {
if (!side.displayImage( fileName, PROFILE ))
QMessageBox::critical(this, tr("Error"), tr("Cannot load the profile image %1.").arg(fileName));
}
}
void customizeSplashDialog::on_leftLibraryButton_clicked(){libraryButton_clicked(left);}
@@ -143,67 +217,26 @@ void customizeSplashDialog::on_rightLibraryButton_clicked(){libraryButton_clicke
void customizeSplashDialog::libraryButton_clicked( Side side )
{
QString fileName;
splashLibrary *ld = new splashLibrary(this,&fileName);
ld->exec();
if (!fileName.isEmpty()) {
QImage image(fileName);
if (image.isNull()) {
QMessageBox::critical(this, tr("Error"), tr("Cannot load %1.").arg(fileName));
return;
}
if (side.imageLabel->width()==424) {
image=image.convertToFormat(QImage::Format_RGB32);
QRgb col;
int gray;
int width = image.width();
int height = image.height();
for (int i = 0; i < width; ++i)
{
for (int j = 0; j < height; ++j)
{
col = image.pixel(i, j);
gray = qGray(col);
image.setPixel(i, j, qRgb(gray, gray, gray));
}
}
side.imageLabel->setPixmap(QPixmap::fromImage(image.scaled(side.imageLabel->width()/2, side.imageLabel->height()/2)));
} else {
side.imageLabel->setPixmap(QPixmap::fromImage(image.scaled(side.imageLabel->width()/2, side.imageLabel->height()/2).convertToFormat(QImage::Format_Mono)));
}
if (!side.displayImage( fileName, UNDEFINED ))
QMessageBox::critical(this, tr("Error"), tr("Cannot load the library image %1.").arg(fileName));
}
}
void customizeSplashDialog::on_leftSaveButton_clicked(){saveButton_clicked(left);}
void customizeSplashDialog::on_rightSaveButton_clicked(){saveButton_clicked(right);}
void customizeSplashDialog::saveButton_clicked(Side side)
void customizeSplashDialog::saveButton_clicked( Side side )
{
QSettings settings;
QString fileName = side.fileNameEdit->text();
if (*side.source == FW)
{
FlashInterface flash(fileName);
if (!flash.hasSplash()) {
QMessageBox::critical(this, tr("Error"), tr("Could not store image in firmware file %1").arg(fileName));
return;
}
QImage image = side.imageLabel->pixmap()->toImage().scaled(flash.getSplashWidth(), flash.getSplashHeight());
if (flash.setSplash(image) && (flash.saveFlash(fileName) > 0))
settings.setValue("lastFlashDir", QFileInfo(fileName).dir().absolutePath());
else
QMessageBox::critical(this, tr("Error"), tr("Could not store image in firmware file %1").arg(fileName));
}
else if (*side.source == PICT)
{
if (!fileName.isEmpty()) {
QImage image = side.imageLabel->pixmap()->toImage().scaled(side.imageLabel->width()/2, side.imageLabel->height()/2).convertToFormat(QImage::Format_Indexed8);
if (image.save(fileName))
settings.setValue("lastImagesDir", QFileInfo(fileName).dir().absolutePath());
else
QMessageBox::critical(this, tr("Error"), tr("The image file %1 could not be stored").arg(fileName));
if (side.saveImage()){
QMessageBox::information(this, tr("File Saved"), tr("The image was saved to the file %1").arg(*side.saveToFileName));
if ( !side.refreshImage()){
QMessageBox::critical(this, tr("Image Refresh Error"), tr("Failed to refresh image from file %1").arg(*side.saveToFileName));
}
}
else
QMessageBox::critical(this, tr("File Save Error"), tr("Failed to write image to %1").arg(*side.saveToFileName));
}
void customizeSplashDialog::on_leftInvertButton_clicked(){invertButton_clicked(left);}
+6
View File
@@ -17,6 +17,9 @@ class Side
public:
Side();
void copyImage( Side );
bool displayImage( QString fileName, Source source );
bool saveImage();
bool refreshImage();
QLabel *imageLabel;
QLineEdit *fileNameEdit;
@@ -24,6 +27,9 @@ public:
QPushButton *invertButton;
QToolButton *libraryButton;
QString *saveToFileName;
private:
Source *source;
};
+25 -20
View File
@@ -254,6 +254,16 @@
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QPushButton" name="leftLoadProfileButton">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Load Profile</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="leftLoadFwButton">
<property name="text">
@@ -268,16 +278,6 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="leftLoadProfileButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Load Profile</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
@@ -550,6 +550,16 @@
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QPushButton" name="rightLoadProfileButton">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Load Profile</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="rightLoadFwButton">
<property name="enabled">
@@ -567,16 +577,6 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="rightLoadProfileButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Load Profile</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
@@ -625,12 +625,17 @@
<tabstops>
<tabstop>leftFileNameEdit</tabstop>
<tabstop>leftInvertButton</tabstop>
<tabstop>leftLibraryButton</tabstop>
<tabstop>leftLoadProfileButton</tabstop>
<tabstop>leftLoadFwButton</tabstop>
<tabstop>leftLoadPictButton</tabstop>
<tabstop>leftSaveButton</tabstop>
<tabstop>copyLeftToRightButton</tabstop>
<tabstop>copyRightToLeftButton</tabstop>
<tabstop>rightFileNameEdit</tabstop>
<tabstop>rightInvertButton</tabstop>
<tabstop>rightLibraryButton</tabstop>
<tabstop>rightLoadProfileButton</tabstop>
<tabstop>rightLoadFwButton</tabstop>
<tabstop>rightLoadPictButton</tabstop>
<tabstop>rightSaveButton</tabstop>
+1 -1
View File
@@ -734,7 +734,7 @@ GeneralSettings::GeneralSettings()
QSettings settings;
templateSetup = settings.value("default_channel_order", 0).toInt();
stickMode = settings.value("default_mode", 1).toInt();
int profile_id = settings.value("ActiveProfile", 0).toInt();
int profile_id = settings.value("profileId", 0).toInt();
if (profile_id>0) {
settings.beginGroup("Profiles");
QString profile=QString("profile%1").arg(profile_id);
+63 -238
View File
@@ -12,7 +12,7 @@ fwPreferencesDialog::fwPreferencesDialog(QWidget *parent) :
updateLock(false)
{
ui->setupUi(this);
setWindowIcon(CompanionIcon("preferences.png"));
setWindowIcon(CompanionIcon("fwpreferences.png"));
QCheckBox * OptionCheckBox[]= {
ui->optionCheckBox_1, ui->optionCheckBox_2, ui->optionCheckBox_3, ui->optionCheckBox_4, ui->optionCheckBox_5, ui->optionCheckBox_6, ui->optionCheckBox_7,
@@ -38,7 +38,7 @@ fwPreferencesDialog::fwPreferencesDialog(QWidget *parent) :
connect(ui->downloadVerCB, SIGNAL(currentIndexChanged(int)), this, SLOT(baseFirmwareChanged()));
connect(this, SIGNAL(accepted()), this, SLOT(writeValues()));
resize(0,0);
shrink();
}
@@ -47,32 +47,43 @@ fwPreferencesDialog::~fwPreferencesDialog()
delete ui;
}
void fwPreferencesDialog::showVoice(bool show)
{
if (show)
showVoice();
else
hideVoice();
}
void fwPreferencesDialog::showVoice()
{
ui->voiceLine->show();
ui->voiceLabel->show();
ui->voiceCombo->show();
ui->voice_dnld->show();
}
void fwPreferencesDialog::hideVoice()
{
ui->voiceLine->hide();
ui->voiceLabel->hide();
ui->voiceCombo->hide();
ui->voice_dnld->hide();
QTimer::singleShot(0, this, SLOT(shrink()));
}
void fwPreferencesDialog::shrink()
{
resize(0,0);
}
void fwPreferencesDialog::baseFirmwareChanged()
{
QVariant selected_firmware = ui->downloadVerCB->itemData(ui->downloadVerCB->currentIndex());
voice=NULL;
foreach(FirmwareInfo * firmware, firmwares) {
if (firmware->id == selected_firmware) {
if (firmware->voice) {
ui->voiceLabel->show();
ui->voiceCombo->show();
ui->voice_dnld->show();
ui->sdPathButton->show();
ui->sdPath->show();
ui->sdPathLabel->show();
ui->voiceLabel->setEnabled(true);
ui->voiceCombo->setEnabled(true);
ui->voice_dnld->setEnabled(true);
ui->sdPathButton->setEnabled(true);
ui->sdPath->setEnabled(true);
} else {
ui->voiceLabel->hide();
ui->voiceCombo->hide();
ui->voice_dnld->hide();
ui->sdPathButton->hide();
ui->sdPath->hide();
ui->sdPathLabel->hide();
}
showVoice(firmware->voice);
populateFirmwareOptions(firmware);
break;
}
@@ -109,11 +120,6 @@ FirmwareVariant fwPreferencesDialog::getFirmwareVariant()
return default_firmware_variant;
}
void fwPreferencesDialog::firmwareLangChanged()
{
firmwareChanged();
}
void fwPreferencesDialog::firmwareOptionChanged(bool state)
{
QCheckBox *cb = qobject_cast<QCheckBox*>(sender());
@@ -134,19 +140,7 @@ void fwPreferencesDialog::firmwareOptionChanged(bool state)
}
}
if (voice) {
if (voice->isChecked()) {
ui->voiceLabel->setEnabled(true);
ui->voiceCombo->setEnabled(true);
ui->voice_dnld->setEnabled(true);
ui->sdPathButton->setEnabled(true);
ui->sdPath->setEnabled(true);
} else {
ui->voiceLabel->setDisabled(true);
ui->voiceCombo->setDisabled(true);
ui->voice_dnld->setDisabled(true);
ui->sdPathButton->setDisabled(true);
ui->sdPath->setDisabled(true);
}
showVoice(voice->isChecked());
}
return firmwareChanged();
@@ -157,37 +151,24 @@ void fwPreferencesDialog::firmwareOptionChanged(bool state)
}
} else if (cb && !state) {
if (cb->text()=="voice") {
ui->voiceLabel->setDisabled(true);
ui->voiceCombo->setDisabled(true);
ui->voice_dnld->setDisabled(true);
ui->sdPathButton->setEnabled(true);
ui->sdPath->setEnabled(true);
hideVoice();
}
}
if (voice ) {
if (voice->isChecked()) {
ui->voiceLabel->setEnabled(true);
ui->voiceCombo->setEnabled(true);
ui->voice_dnld->setEnabled(true);
} else {
ui->voiceLabel->setDisabled(true);
ui->voiceCombo->setDisabled(true);
ui->voice_dnld->setDisabled(true);
ui->sdPathButton->setDisabled(true);
ui->sdPath->setDisabled(true);
}
if (voice) {
showVoice(voice->isChecked());
} else if (firmware) {
if (firmware->voice) {
ui->voiceLabel->setEnabled(true);
ui->voiceCombo->setEnabled(true);
ui->voice_dnld->setEnabled(true);
ui->sdPathButton->setEnabled(true);
ui->sdPath->setEnabled(true);
showVoice();
}
}
return firmwareChanged();
}
void fwPreferencesDialog::firmwareLangChanged()
{
firmwareChanged();
}
void fwPreferencesDialog::firmwareChanged()
{
if (updateLock)
@@ -233,21 +214,10 @@ void fwPreferencesDialog::firmwareChanged()
void fwPreferencesDialog::writeValues()
{
QSettings settings;
settings.setValue("default_channel_order", ui->channelorderCB->currentIndex());
settings.setValue("default_mode", ui->stickmodeCB->currentIndex());
settings.setValue("cpu_id", ui->CPU_ID_LE->text());
settings.setValue("rename_firmware_files", ui->renameFirmware->isChecked());
settings.setValue("burnFirmware", ui->burnFirmware->isChecked());
current_firmware_variant = getFirmwareVariant();
settings.setValue("firmware", current_firmware_variant.id);
settings.setValue("profileId", ui->ProfSlot_SB->value());
settings.setValue("sdPath", ui->sdPath->text());
settings.setValue("SplashFileName", ui->SplashFileName->text());
if (!ui->SplashFileName->text().isEmpty())
settings.setValue("SplashImage", "");
MainWindow * mw = (MainWindow *)this->parent();
mw->unloadProfile();
}
void fwPreferencesDialog::populateFirmwareOptions(const FirmwareInfo * firmware)
@@ -269,14 +239,7 @@ void fwPreferencesDialog::populateFirmwareOptions(const FirmwareInfo * firmware)
ui->voiceCombo->setCurrentIndex(ui->voiceCombo->count() - 1);
}
if (ui->langCombo->count()) {
ui->langCombo->show();
ui->langLabel->show();
}
else {
ui->langCombo->hide();
ui->langLabel->hide();
}
showVoice(ui->langCombo->count()!=0);
int index = 0;
foreach(QList<Option> opts, parent->opts) {
@@ -294,25 +257,7 @@ void fwPreferencesDialog::populateFirmwareOptions(const FirmwareInfo * firmware)
if (opt.name==QString("voice")) {
voice=cb;
ui->voiceLabel->show();
ui->voiceCombo->show();
ui->voice_dnld->show();
ui->sdPathButton->show();
ui->sdPath->show();
ui->sdPathLabel->show();
if (current_firmware_variant.id.contains(opt.name) ||firmware->voice) {
ui->voiceLabel->setEnabled(true);
ui->voiceCombo->setEnabled(true);
ui->voice_dnld->setEnabled(true);
ui->sdPathButton->setEnabled(true);
ui->sdPath->setEnabled(true);
} else {
ui->voiceLabel->setDisabled(true);
ui->voiceCombo->setDisabled(true);
ui->voice_dnld->setDisabled(true);
ui->sdPathButton->setDisabled(true);
ui->sdPath->setDisabled(true);
}
showVoice(current_firmware_variant.id.contains(opt.name) ||firmware->voice);
}
}
}
@@ -331,16 +276,8 @@ void fwPreferencesDialog::populateFirmwareOptions(const FirmwareInfo * firmware)
void fwPreferencesDialog::initSettings()
{
QSettings settings;
ui->channelorderCB->setCurrentIndex(settings.value("default_channel_order", 0).toInt());
ui->stickmodeCB->setCurrentIndex(settings.value("default_mode", 1).toInt());
ui->renameFirmware->setChecked(settings.value("rename_firmware_files", false).toBool());
ui->burnFirmware->setChecked(settings.value("burnFirmware", true).toBool());
ui->CPU_ID_LE->setText(settings.value("cpu_id", "").toString());
QString Path=settings.value("sdPath", "").toString();
if (QDir(Path).exists()) {
ui->sdPath->setText(Path);
}
ui->CPU_ID_LE->setText(settings.value("cpu_id", "").toString());
FirmwareInfo * current_firmware = GetCurrentFirmware();
foreach(FirmwareInfo * firmware, firmwares) {
@@ -351,27 +288,31 @@ void fwPreferencesDialog::initSettings()
}
baseFirmwareChanged();
ui->ProfSlot_SB->setValue(settings.value("profileId", 1).toInt());
on_ProfSlot_SB_valueChanged();
QString fileName=settings.value("SplashFileName","").toString();
if (!fileName.isEmpty()) {
QFile file(fileName);
if (file.exists()){
ui->SplashFileName->setText(fileName);
}
}
firmwareChanged();
}
void fwPreferencesDialog::on_checkFWUpdates_clicked()
{
QSettings settings;
FirmwareVariant variant = getFirmwareVariant();
if (settings.value("burnFirmware", true).toBool()) {
current_firmware_variant = variant;
settings.setValue("firmware", variant.id);
}
MainWindow * mw = (MainWindow *)this->parent();
mw->checkForUpdates(true, variant.id);
firmwareChanged();
}
void fwPreferencesDialog::on_fw_dnld_clicked()
{
QSettings settings;
MainWindow * mw = (MainWindow *)this->parent();
FirmwareVariant variant = getFirmwareVariant();
writeValues();
if (!variant.firmware->getUrl(variant.id).isNull()) {
if (ui->burnFirmware->isChecked()) {
QSettings settings;
if (settings.value("burnFirmware", true).toBool()) {
current_firmware_variant = getFirmwareVariant();
settings.setValue("firmware", current_firmware_variant.id);
}
@@ -382,126 +323,10 @@ void fwPreferencesDialog::on_fw_dnld_clicked()
void fwPreferencesDialog::on_voice_dnld_clicked()
{
ui->ProfSave_PB->setEnabled(true);
QString url="http://fw.opentx.it/voices/";
FirmwareVariant variant = getFirmwareVariant();
url.append(QString("%1/%2/").arg(variant.firmware->id).arg(ui->voiceCombo->currentText()));
QDesktopServices::openUrl(url);
}
void fwPreferencesDialog::on_sdPathButton_clicked()
{
QSettings settings;
QString fileName = QFileDialog::getExistingDirectory(this,tr("Select the folder replicating your SD structure"), settings.value("sdPath").toString());
if (!fileName.isEmpty()) {
ui->sdPath->setText(fileName);
}
ui->ProfSave_PB->setEnabled(true);
}
void fwPreferencesDialog::on_ProfSlot_SB_valueChanged()
{
QSettings settings;
settings.beginGroup("Profiles");
QString profile=QString("profile%1").arg(ui->ProfSlot_SB->value());
settings.beginGroup(profile);
QString name=settings.value("Name","").toString();
ui->ProfName_LE->setText(name);
/* if (!(name.isEmpty())) {
QString firmwarename=settings.value("firmware", default_firmware_id).toString();
FirmwareInfo * fw = getFirmware(firmwarename);
int i=0;
foreach(FirmwareInfo * firmware, firmwares) {
if (fw == firmware) {
qDebug() << fw->id;
qDebug() << firmware->id;
qDebug() << i;
ui->downloadVerCB->setCurrentIndex(i);
break;
}
i++;
}
baseFirmwareChanged();
populateFirmwareOptions(fw);
}*/
settings.endGroup();
settings.endGroup();
}
void fwPreferencesDialog::on_ProfSave_PB_clicked()
{
QSettings settings;
settings.beginGroup("Profiles");
QString profile=QString("profile%1").arg(ui->ProfSlot_SB->value());
QString name=ui->ProfName_LE->text();
if (name.isEmpty()) {
int ret = QMessageBox::question(this, "Companion",
tr("Profile name is empty, profile slot %1 will be deleted.<br>Are you sure ?").arg(ui->ProfSlot_SB->value()) ,
QMessageBox::Yes | QMessageBox::No);
if (ret==QMessageBox::Yes) {
settings.remove(profile);
} else {
settings.beginGroup(profile);
ui->ProfName_LE->setText(settings.value("Name","").toString());
}
} else {
settings.beginGroup(profile);
settings.setValue("Name",name);
settings.setValue("default_channel_order", ui->channelorderCB->currentIndex());
settings.setValue("default_mode", ui->stickmodeCB->currentIndex());
settings.setValue("burnFirmware", ui->burnFirmware->isChecked());
settings.setValue("rename_firmware_files", ui->renameFirmware->isChecked());
settings.setValue("sdPath", ui->sdPath->text());
settings.setValue("SplashFileName", ui->SplashFileName->text());
current_firmware_variant = getFirmwareVariant();
settings.setValue("firmware", current_firmware_variant.id);
settings.endGroup();
settings.endGroup();
}
}
void fwPreferencesDialog::on_SplashSelect_clicked()
{
QString supportedImageFormats;
for (int formatIndex = 0; formatIndex < QImageReader::supportedImageFormats().count(); formatIndex++) {
supportedImageFormats += QLatin1String(" *.") + QImageReader::supportedImageFormats()[formatIndex];
}
QSettings settings;
QString fileName = QFileDialog::getOpenFileName(this,
tr("Open Image to load"), settings.value("lastImagesDir").toString(), tr("Images (%1)").arg(supportedImageFormats));
if (!fileName.isEmpty()) {
settings.setValue("lastImagesDir", QFileInfo(fileName).dir().absolutePath());
QImage image(fileName);
if (image.isNull()) {
QMessageBox::critical(this, tr("Error"), tr("Cannot load %1.").arg(fileName));
return;
}
ui->SplashFileName->setText(fileName);
}
}
void fwPreferencesDialog::on_clearImageButton_clicked() {
ui->SplashFileName->clear();
}
void fwPreferencesDialog::on_checkFWUpdates_clicked()
{
FirmwareVariant variant = getFirmwareVariant();
if (ui->burnFirmware->isChecked()) {
QSettings settings;
current_firmware_variant = variant;
settings.setValue("firmware", variant.id);
}
MainWindow * mw = (MainWindow *)this->parent();
mw->checkForUpdates(true, variant.id);
firmwareChanged();
}
void fwPreferencesDialog::shrink()
{
resize(0,0);
}
+3 -5
View File
@@ -24,6 +24,9 @@ private:
QList<QCheckBox *> optionsCheckBoxes;
bool updateLock;
void showVoice(bool);
void showVoice();
void hideVoice();
void populateLocale();
void populateFirmwareOptions(const FirmwareInfo *);
FirmwareVariant getFirmwareVariant();
@@ -39,12 +42,7 @@ private slots:
void firmwareChanged();
void on_fw_dnld_clicked();
void on_voice_dnld_clicked();
void on_sdPathButton_clicked();
void on_checkFWUpdates_clicked();
void on_ProfSlot_SB_valueChanged();
void on_ProfSave_PB_clicked();
void on_SplashSelect_clicked();
void on_clearImageButton_clicked();
};
#endif // FWPREFERENCESDIALOG_H
+199 -576
View File
@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>620</width>
<height>658</height>
<height>437</height>
</rect>
</property>
<property name="sizePolicy">
@@ -32,181 +32,13 @@
<property name="margin">
<number>6</number>
</property>
<item row="21" column="5">
<widget class="QPushButton" name="voice_dnld">
<property name="text">
<string>Download Voice</string>
<item row="38" column="5">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="35" column="2" colspan="3">
<widget class="QCheckBox" name="burnFirmware">
<property name="text">
<string>Offer to write FW to Tx after download</string>
</property>
</widget>
</item>
<item row="10" column="2">
<widget class="QCheckBox" name="optionCheckBox_9">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>CheckBox</string>
</property>
</widget>
</item>
<item row="10" column="3">
<widget class="QCheckBox" name="optionCheckBox_10">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>CheckBox</string>
</property>
</widget>
</item>
<item row="18" column="5">
<widget class="QPushButton" name="fw_dnld">
<property name="text">
<string>Download FW</string>
</property>
</widget>
</item>
<item row="8" column="0" colspan="2">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Options</string>
</property>
</widget>
</item>
<item row="12" column="4">
<widget class="QCheckBox" name="optionCheckBox_19">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>CheckBox</string>
</property>
</widget>
</item>
<item row="9" column="5">
<widget class="QCheckBox" name="optionCheckBox_8">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>CheckBox</string>
</property>
</widget>
</item>
<item row="14" column="2">
<widget class="QCheckBox" name="optionCheckBox_25">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>CheckBox</string>
</property>
</widget>
</item>
<item row="9" column="4">
<widget class="QCheckBox" name="optionCheckBox_7">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>CheckBox</string>
</property>
</widget>
</item>
<item row="11" column="4">
<widget class="QCheckBox" name="optionCheckBox_15">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>CheckBox</string>
</property>
</widget>
</item>
<item row="8" column="4">
<widget class="QCheckBox" name="optionCheckBox_3">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>CheckBox</string>
</property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<widget class="QLabel" name="CPU_ID_LABEL">
<property name="text">
<string>Processor ID</string>
</property>
</widget>
</item>
<item row="17" column="4">
<widget class="QCheckBox" name="optionCheckBox_39">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>CheckBox</string>
</property>
</widget>
</item>
<item row="4" column="2" colspan="4">
<widget class="QLabel" name="FwInfo">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>FwInfo</string>
</property>
</widget>
</item>
<item row="17" column="5">
<widget class="QCheckBox" name="optionCheckBox_40">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>CheckBox</string>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
@@ -223,6 +55,19 @@
</property>
</widget>
</item>
<item row="15" column="5">
<widget class="QCheckBox" name="optionCheckBox_32">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>CheckBox</string>
</property>
</widget>
</item>
<item row="11" column="5">
<widget class="QCheckBox" name="optionCheckBox_16">
<property name="sizePolicy">
@@ -246,35 +91,6 @@
</property>
</widget>
</item>
<item row="32" column="0" colspan="2">
<widget class="QLabel" name="label_14">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Default Stick Mode</string>
</property>
</widget>
</item>
<item row="33" column="0" colspan="2">
<widget class="QLabel" name="label_13">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Channel Order</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="8" column="2">
<widget class="QCheckBox" name="optionCheckBox_2">
<property name="sizePolicy">
@@ -301,60 +117,6 @@
</property>
</widget>
</item>
<item row="32" column="2" colspan="2">
<widget class="QComboBox" name="stickmodeCB">
<property name="maximumSize">
<size>
<width>190</width>
<height>16777215</height>
</size>
</property>
<property name="whatsThis">
<string>Mode selection:
Mode 1:
Left stick: Elevator, Rudder
Right stick: Throttle, Aileron
Mode 2:
Left stick: Throttle, Rudder
Right stick: Elevator, Aileron
Mode 3:
Left stick: Elevator, Aileron
Right stick: Throttle, Rudder
Mode 4:
Left stick: Throttle, Aileron
Right stick: Elevator, Rudder
</string>
</property>
<property name="currentIndex">
<number>1</number>
</property>
<item>
<property name="text">
<string>Mode 1 (RUD ELE THR AIL)</string>
</property>
</item>
<item>
<property name="text">
<string>Mode 2 (RUD THR ELE AIL)</string>
</property>
</item>
<item>
<property name="text">
<string>Mode 3 (AIL ELE THR RUD)</string>
</property>
</item>
<item>
<property name="text">
<string>Mode 4 (AIL THR ELE RUD)</string>
</property>
</item>
</widget>
</item>
<item row="15" column="2">
<widget class="QCheckBox" name="optionCheckBox_29">
<property name="sizePolicy">
@@ -394,6 +156,9 @@ Mode 4:
</property>
</widget>
</item>
<item row="3" column="2" colspan="3">
<widget class="QComboBox" name="downloadVerCB"/>
</item>
<item row="7" column="2">
<widget class="QComboBox" name="langCombo">
<property name="sizePolicy">
@@ -410,8 +175,8 @@ Mode 4:
</property>
</widget>
</item>
<item row="3" column="2" colspan="3">
<widget class="QComboBox" name="downloadVerCB"/>
<item row="5" column="2" colspan="3">
<widget class="QLineEdit" name="CPU_ID_LE"/>
</item>
<item row="3" column="0" colspan="2">
<widget class="QLabel" name="label_6">
@@ -436,159 +201,6 @@ Mode 4:
</property>
</widget>
</item>
<item row="5" column="2" colspan="3">
<widget class="QLineEdit" name="CPU_ID_LE"/>
</item>
<item row="33" column="2" colspan="2">
<widget class="QComboBox" name="channelorderCB">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>75</width>
<height>16777215</height>
</size>
</property>
<property name="whatsThis">
<string>Channel order
This is used by the templated to determine which channel goes to what number output.</string>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<item>
<property name="text">
<string>R E T A</string>
</property>
</item>
<item>
<property name="text">
<string>R E A T</string>
</property>
</item>
<item>
<property name="text">
<string>R T E A</string>
</property>
</item>
<item>
<property name="text">
<string>R T A E</string>
</property>
</item>
<item>
<property name="text">
<string>R A E T</string>
</property>
</item>
<item>
<property name="text">
<string>R A T E</string>
</property>
</item>
<item>
<property name="text">
<string>E R T A</string>
</property>
</item>
<item>
<property name="text">
<string>E R A T</string>
</property>
</item>
<item>
<property name="text">
<string>E T R A</string>
</property>
</item>
<item>
<property name="text">
<string>E T A R</string>
</property>
</item>
<item>
<property name="text">
<string>E A R T</string>
</property>
</item>
<item>
<property name="text">
<string>E A T R</string>
</property>
</item>
<item>
<property name="text">
<string>T R E A</string>
</property>
</item>
<item>
<property name="text">
<string>T R A E</string>
</property>
</item>
<item>
<property name="text">
<string>T E R A</string>
</property>
</item>
<item>
<property name="text">
<string>T E A R</string>
</property>
</item>
<item>
<property name="text">
<string>T A R E</string>
</property>
</item>
<item>
<property name="text">
<string>T A E R</string>
</property>
</item>
<item>
<property name="text">
<string>A R E T</string>
</property>
</item>
<item>
<property name="text">
<string>A R T E</string>
</property>
</item>
<item>
<property name="text">
<string>A E R T</string>
</property>
</item>
<item>
<property name="text">
<string>A E T R</string>
</property>
</item>
<item>
<property name="text">
<string>A T R E</string>
</property>
</item>
<item>
<property name="text">
<string>A T E R</string>
</property>
</item>
</widget>
</item>
<item row="8" column="5">
<widget class="QCheckBox" name="optionCheckBox_4">
<property name="sizePolicy">
@@ -641,19 +253,6 @@ This is used by the templated to determine which channel goes to what number out
</property>
</widget>
</item>
<item row="15" column="5">
<widget class="QCheckBox" name="optionCheckBox_32">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>CheckBox</string>
</property>
</widget>
</item>
<item row="12" column="2">
<widget class="QCheckBox" name="optionCheckBox_17">
<property name="sizePolicy">
@@ -914,40 +513,6 @@ This is used by the templated to determine which channel goes to what number out
</property>
</widget>
</item>
<item row="34" column="2" colspan="3">
<widget class="QCheckBox" name="renameFirmware">
<property name="text">
<string>Append version number to FW file name</string>
</property>
</widget>
</item>
<item row="46" column="5">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
<item row="23" column="0">
<widget class="QLabel" name="label_16">
<property name="font">
<font>
<family>Sans Serif</family>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Profile</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="3" column="5">
<widget class="QPushButton" name="checkFWUpdates">
<property name="minimumSize">
@@ -961,37 +526,6 @@ This is used by the templated to determine which channel goes to what number out
</property>
</widget>
</item>
<item row="25" column="2" colspan="3">
<widget class="QLineEdit" name="SplashFileName">
<property name="enabled">
<bool>true</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="21" column="2">
<widget class="QComboBox" name="voiceCombo">
<property name="maximumSize">
<size>
<width>50</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Set language of voice.
May be different from firmware language</string>
</property>
</widget>
</item>
<item row="25" column="5">
<widget class="QPushButton" name="SplashSelect">
<property name="text">
<string>Open Image</string>
</property>
</widget>
</item>
<item row="21" column="0">
<widget class="QLabel" name="voiceLabel">
<property name="font">
@@ -1006,109 +540,202 @@ May be different from firmware language</string>
</property>
</widget>
</item>
<item row="25" column="0">
<widget class="QLabel" name="label_8">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Splash Screen</string>
</property>
</widget>
</item>
<item row="32" column="5">
<widget class="QPushButton" name="clearImageButton">
<property name="text">
<string>Clear Image</string>
</property>
</widget>
</item>
<item row="23" column="3" colspan="2">
<widget class="QLineEdit" name="ProfName_LE"/>
</item>
<item row="23" column="2">
<widget class="QSpinBox" name="ProfSlot_SB">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item row="21" column="2">
<widget class="QComboBox" name="voiceCombo">
<property name="maximumSize">
<size>
<width>16777215</width>
<width>50</width>
<height>16777215</height>
</size>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>10</number>
<property name="toolTip">
<string>Set language of voice.
May be different from firmware language</string>
</property>
</widget>
</item>
<item row="22" column="0" colspan="6">
<widget class="Line" name="line_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="20" column="0" colspan="6">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="45" column="0" colspan="6">
<widget class="Line" name="line_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="24" column="5">
<widget class="QPushButton" name="sdPathButton">
<item row="21" column="5">
<widget class="QPushButton" name="voice_dnld">
<property name="text">
<string>Open Folder</string>
<string>Download Voice</string>
</property>
</widget>
</item>
<item row="24" column="2" colspan="3">
<widget class="QLineEdit" name="sdPath">
<property name="enabled">
<bool>true</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="24" column="0">
<widget class="QLabel" name="sdPathLabel">
<item row="10" column="2">
<widget class="QCheckBox" name="optionCheckBox_9">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>SD Structure path</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
<string>CheckBox</string>
</property>
</widget>
</item>
<item row="35" column="5">
<widget class="QPushButton" name="ProfSave_PB">
<item row="10" column="3">
<widget class="QCheckBox" name="optionCheckBox_10">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Save Profile</string>
<string>CheckBox</string>
</property>
</widget>
</item>
<item row="18" column="5">
<widget class="QPushButton" name="fw_dnld">
<property name="text">
<string>Download FW</string>
</property>
</widget>
</item>
<item row="8" column="0" colspan="2">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Options</string>
</property>
</widget>
</item>
<item row="12" column="4">
<widget class="QCheckBox" name="optionCheckBox_19">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>CheckBox</string>
</property>
</widget>
</item>
<item row="9" column="5">
<widget class="QCheckBox" name="optionCheckBox_8">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>CheckBox</string>
</property>
</widget>
</item>
<item row="14" column="2">
<widget class="QCheckBox" name="optionCheckBox_25">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>CheckBox</string>
</property>
</widget>
</item>
<item row="9" column="4">
<widget class="QCheckBox" name="optionCheckBox_7">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>CheckBox</string>
</property>
</widget>
</item>
<item row="11" column="4">
<widget class="QCheckBox" name="optionCheckBox_15">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>CheckBox</string>
</property>
</widget>
</item>
<item row="8" column="4">
<widget class="QCheckBox" name="optionCheckBox_3">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>CheckBox</string>
</property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<widget class="QLabel" name="CPU_ID_LABEL">
<property name="text">
<string>Processor ID</string>
</property>
</widget>
</item>
<item row="17" column="4">
<widget class="QCheckBox" name="optionCheckBox_39">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>CheckBox</string>
</property>
</widget>
</item>
<item row="4" column="2" colspan="4">
<widget class="QLabel" name="FwInfo">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>FwInfo</string>
</property>
</widget>
</item>
<item row="17" column="5">
<widget class="QCheckBox" name="optionCheckBox_40">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>CheckBox</string>
</property>
</widget>
</item>
<item row="20" column="1" colspan="5">
<widget class="Line" name="voiceLine">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="37" column="1" colspan="5">
<widget class="Line" name="line_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
@@ -1161,10 +788,6 @@ May be different from firmware language</string>
<tabstop>optionCheckBox_40</tabstop>
<tabstop>optionCheckBox_41</tabstop>
<tabstop>optionCheckBox_42</tabstop>
<tabstop>stickmodeCB</tabstop>
<tabstop>channelorderCB</tabstop>
<tabstop>renameFirmware</tabstop>
<tabstop>burnFirmware</tabstop>
</tabstops>
<resources>
<include location="companion.qrc"/>
Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 17 KiB

+78 -111
View File
@@ -124,12 +124,6 @@ MainWindow::MainWindow():
updateMenus();
readSettings();
FirmwareInfo *firmware = GetCurrentFirmware();
if (ActiveProfile) {
setWindowTitle(tr("Companion - Models and Settings Editor - %1 - profile %2").arg(firmware->name).arg(ActiveProfileName));
} else {
setWindowTitle(tr("Companion - Models and Settings Editor - %1").arg(firmware->name));
}
setUnifiedTitleAndToolBarOnMac(true);
this->setWindowIcon(QIcon(":/icon.png"));
this->setIconSize(QSize(32,32));
@@ -758,11 +752,10 @@ void MainWindow::loadProfile()
if (action) {
int profnum=action->data().toInt();
QSettings settings;
settings.setValue("ActiveProfile",profnum);
settings.setValue("profileId",profnum);
settings.beginGroup("Profiles");
QString profile=QString("profile%1").arg(profnum);
settings.beginGroup(profile);
ActiveProfile=profnum;
ActiveProfileName=settings.value("Name", "").toString();
chord=settings.value("default_channel_order", 0).toInt();
defmod=settings.value("default_mode", 0).toInt();
@@ -785,46 +778,15 @@ void MainWindow::loadProfile()
settings.setValue("SplashFileName", SplashFileName);
settings.setValue("SplashImage", SplashImage);
settings.setValue("firmware", firmware_id);
settings.setValue("profileId", profnum);
current_firmware_variant = GetFirmwareVariant(firmware_id);
FirmwareInfo *firmware = GetCurrentFirmware();
setWindowTitle(tr("Companion - Models and Settings Editor - %1").arg(firmware->name));
// settings.setValue("lastDir", QFileInfo(fileName).dir().absolutePath());
foreach (QMdiSubWindow *window, mdiArea->subWindowList()) {
MdiChild *mdiChild = qobject_cast<MdiChild *>(window->widget());
mdiChild->eepromInterfaceChanged();
}
setWindowTitle(tr("Companion - Models and Settings Editor - %1 - profile %2").arg(firmware->name).arg(ActiveProfileName));
}
}
void MainWindow::unloadProfile()
{
ActiveProfile=0;
ActiveProfileName="";
QSettings settings;
settings.setValue("ActiveProfile", 0);
FirmwareInfo *firmware = GetCurrentFirmware();
setWindowTitle(tr("Companion - Models and Settings Editor - %1").arg(firmware->name));
}
void MainWindow::preferences()
{
preferencesDialog *pd = new preferencesDialog(this);
pd->exec();
FirmwareInfo *firmware = GetCurrentFirmware();
if (ActiveProfile) {
setWindowTitle(tr("Companion - Models and Settings Editor - %1 - profile %2").arg(firmware->name).arg(ActiveProfileName));
updateMenus();
}
else {
setWindowTitle(tr("Companion - Models and Settings Editor - %1").arg(firmware->name));
}
foreach (QMdiSubWindow *window, mdiArea->subWindowList()) {
MdiChild *mdiChild = qobject_cast<MdiChild *>(window->widget());
mdiChild->eepromInterfaceChanged();
}
updateMenus();
}
void MainWindow::appPreferences()
@@ -838,14 +800,6 @@ void MainWindow::fwPreferences()
{
fwPreferencesDialog *pd = new fwPreferencesDialog(this);
pd->exec();
FirmwareInfo *firmware = GetCurrentFirmware();
if (ActiveProfile) {
setWindowTitle(tr("Companion - Models and Settings Editor - %1 - profile %2").arg(firmware->name).arg(ActiveProfileName));
}
else {
setWindowTitle(tr("Companion - Models and Settings Editor - %1").arg(firmware->name));
}
foreach (QMdiSubWindow *window, mdiArea->subWindowList()) {
MdiChild *mdiChild = qobject_cast<MdiChild *>(window->widget());
mdiChild->eepromInterfaceChanged();
@@ -1640,19 +1594,9 @@ void MainWindow::updateMenus()
compareAct->setEnabled(activeMdiChild());
updateRecentFileActions();
updateProfilesActions();
bool notfound=true;
QSettings settings;
settings.beginGroup("Profiles");
for (int i=0; i<MAX_PROFILES; i++) {
QString profile=QString("profile%1").arg(i+1);
settings.beginGroup(profile);
QString name=settings.value("Name","").toString();
if (!name.isEmpty()) {
notfound=false;
}
settings.endGroup();
}
profileButton->setDisabled(notfound);
setWindowTitle(tr("OpenTX Companion - FW: %1 - Profile: %2").arg(GetCurrentFirmware()->name).arg(settings.value("profileId").toString()));
}
MdiChild *MainWindow::createMdiChild()
@@ -1701,16 +1645,12 @@ void MainWindow::createActions()
logsAct->setStatusTip(tr("Open log file"));
connect(logsAct, SIGNAL(triggered()), this, SLOT(logFile()));
preferencesAct = new QAction(tr("&Old Preferences Dialog..."), this);
preferencesAct->setStatusTip(tr("Used the old Preferences Dialog"));
connect(preferencesAct, SIGNAL(triggered()), this, SLOT(preferences()));
appPreferencesAct = new QAction(CompanionIcon("apppreferences.png"), tr("&Application Preferences..."), this);
appPreferencesAct->setStatusTip(tr("Edit application preferences"));
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 and Profiles..."), this);
fwPreferencesAct->setStatusTip(tr("Firmware and voice file downloads as well as profile definition."));
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);
@@ -1833,6 +1773,9 @@ 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()));
classicThemeAct = new QAction(tr("Classic"), this);
classicThemeAct->setStatusTip(tr("The multicolor classical Companion icon theme"));
@@ -1917,7 +1860,6 @@ void MainWindow::createMenus()
{
QMenu *recentFileMenu=new QMenu(tr("Recent Files"));
QMenu *profilesMenu=new QMenu(tr("Firmware Profiles"));
QMenu *languageMenu=new QMenu(tr("Set Menu Language"));
QMenu *themeMenu=new QMenu(tr("Set Icon Theme"));
QMenu *iconThemeSizeMenu=new QMenu(tr("Set Icon Size"));
@@ -1939,11 +1881,7 @@ void MainWindow::createMenus()
fileMenu->addAction(compareAct);
fileMenu->addSeparator();
fileMenu->addAction(fwPreferencesAct);
fileMenu->addMenu(profilesMenu);
profilesMenu->setIcon(CompanionIcon("profiles.png"));
for (int i=0; i<MAX_PROFILES; ++i)
profilesMenu->addAction(profileActs[i]);
fileMenu->addMenu(createProfilesMenu());
fileMenu->addAction(exitAct);
editMenu = menuBar()->addMenu(tr("&Edit"));
@@ -1977,7 +1915,6 @@ void MainWindow::createMenus()
settingsMenu->addSeparator();
settingsMenu->addAction(appPreferencesAct);
settingsMenu->addAction(customizeSplashAct);
settingsMenu->addAction(preferencesAct);
settingsMenu->addAction(burnConfigAct);
burnMenu = menuBar()->addMenu(tr("&Read/Write"));
@@ -2021,9 +1958,15 @@ QMenu *MainWindow::createRecentFileMenu()
QMenu *MainWindow::createProfilesMenu()
{
QMenu *profilesMenu = new QMenu(this);
for ( int i = 0; i < MAX_PROFILES; ++i)
QMenu *profilesMenu=new QMenu(tr("Radio Settings Profiles"));
int i;
for ( i = 0; i < MAX_PROFILES; ++i) {
profilesMenu->addAction(profileActs[i]);
}
if ( i>0 )
profilesMenu->addSeparator();
profilesMenu->addAction(createProfileAct);
profilesMenu->setIcon(CompanionIcon("profiles.png"));
return profilesMenu;
}
@@ -2039,11 +1982,14 @@ void MainWindow::createToolBars()
case 1:
size=QSize(24,24);
break;
case 2:
size=QSize(32,32);
break;
case 3:
size=QSize(48,48);
break;
default:
size=QSize(32,32);
size=QSize(24,24);
break;
}
fileToolBar = addToolBar(tr("File"));
@@ -2051,11 +1997,11 @@ void MainWindow::createToolBars()
fileToolBar->setObjectName("File");
fileToolBar->addAction(newAct);
fileToolBar->addAction(openAct);
QToolButton * recentToolButton = new QToolButton;
recentToolButton->setPopupMode(QToolButton::InstantPopup);
recentToolButton->setMenu(createRecentFileMenu());
recentToolButton->setIcon(CompanionIcon("recentdocument.png"));
recentToolButton->setToolTip(tr("Recent Files"));
QToolButton * recentToolButton = new QToolButton;
recentToolButton->setPopupMode(QToolButton::InstantPopup);
recentToolButton->setMenu(createRecentFileMenu());
recentToolButton->setIcon(CompanionIcon("recentdocument.png"));
recentToolButton->setToolTip(tr("Recent Files"));
fileToolBar->addWidget(recentToolButton);
fileToolBar->addAction(saveAct);
fileToolBar->addAction(logsAct);
@@ -2063,24 +2009,12 @@ void MainWindow::createToolBars()
fileToolBar->addAction(appPreferencesAct);
fileToolBar->addAction(fwPreferencesAct);
fileToolBar->addAction(customizeSplashAct);
profileButton = new QToolButton;
profileButton->setPopupMode(QToolButton::InstantPopup);
profileButton->setMenu(createProfilesMenu());
profileButton->setIcon(CompanionIcon("profiles.png"));
profileButton->setToolTip(tr("Firmware Profiles"));
profileButton = new QToolButton;
profileButton->setPopupMode(QToolButton::InstantPopup);
profileButton->setMenu(createProfilesMenu());
profileButton->setIcon(CompanionIcon("profiles.png"));
profileButton->setToolTip(tr("Firmware Profiles"));
fileToolBar->addWidget(profileButton);
bool notfound=true;
settings.beginGroup("Profiles");
for (int i=0; i<MAX_PROFILES; i++) {
QString profile=QString("profile%1").arg(i+1);
settings.beginGroup(profile);
QString name=settings.value("Name","").toString();
if (!name.isEmpty()) {
notfound=false;
}
settings.endGroup();
}
profileButton->setDisabled(notfound);
fileToolBar->addSeparator();
fileToolBar->addAction(simulateAct);
fileToolBar->addAction(printAct);
@@ -2092,7 +2026,6 @@ void MainWindow::createToolBars()
editToolBar->addAction(cutAct);
editToolBar->addAction(copyAct);
editToolBar->addAction(pasteAct);
burnToolBar = new QToolBar(tr("Write"));
addToolBar( Qt::LeftToolBarArea, burnToolBar );
@@ -2128,15 +2061,18 @@ void MainWindow::readSettings()
checkCompanion9x = settings.value("startup_check_companion", true).toBool();
checkFW = settings.value("startup_check_fw", true).toBool();
MaxRecentFiles =settings.value("history_size",10).toInt();
ActiveProfile=settings.value("activeprofile",0).toInt();
if (ActiveProfile) {
settings.beginGroup("Profiles");
QString profile=QString("profile%1").arg(ActiveProfile);
settings.beginGroup(profile);
ActiveProfileName=settings.value("Name","").toString();
settings.endGroup();
settings.endGroup();
if (settings.value("profileId",0).toInt() == 0)
{
createProfile();
settings.setValue("profileId", "1");
}
int activeProfile=settings.value("profileId",0).toInt();
settings.beginGroup("Profiles");
QString profile=QString("profile%1").arg(activeProfile);
settings.beginGroup(profile);
ActiveProfileName=settings.value("Name","").toString();
settings.endGroup();
settings.endGroup();
}
MdiChild *MainWindow::activeMdiChild()
@@ -2189,6 +2125,8 @@ void MainWindow::updateProfilesActions()
{
int i;
QSettings settings;
int activeProfile = settings.value("profileId").toInt();
settings.beginGroup("Profiles");
for (i=0; i<MAX_PROFILES; i++) {
QString profile=QString("profile%1").arg(i+1);
@@ -2199,14 +2137,43 @@ void MainWindow::updateProfilesActions()
profileActs[i]->setText(text);
profileActs[i]->setData(i+1);
profileActs[i]->setVisible(true);
if ((i+1) == activeProfile)
profileActs[i]->setIcon(CompanionIcon("arrow-right.png"));
else
profileActs[i]->setIcon(CompanionIcon(""));
} else {
profileActs[i]->setVisible(false);
}
settings.endGroup();
}
// separatorAct->setVisible(numRecentFiles > 0);
}
void MainWindow::createProfile()
{
int firstFreeIndex = 0;
QSettings settings;
settings.beginGroup("Profiles");
for (int i=0; firstFreeIndex ==0 && i<MAX_PROFILES; i++) {
QString profile=QString("profile%1").arg(i+1);
settings.beginGroup(profile);
QString name=settings.value("Name","").toString();
if (name.isEmpty())
firstFreeIndex = i+1;
settings.endGroup();
}
settings.endGroup();
if (firstFreeIndex == 0) // Could not find free index
return;
settings.beginGroup("Profiles");
settings.beginGroup(QString("profile%1").arg(firstFreeIndex));
settings.setValue("Name",QString("profile%1").arg(firstFreeIndex));
settings.endGroup();
settings.endGroup();
updateMenus();
}
QString MainWindow::strippedName(const QString &fullFileName)
{
+3 -5
View File
@@ -63,7 +63,6 @@ QT_END_NAMESPACE
class MainWindow : public QMainWindow
{
friend class preferencesDialog;
friend class fwPreferencesDialog;
friend class MdiChild; // TODO GetAvrdudeArgs could be external to this class
@@ -80,7 +79,6 @@ protected:
public slots:
void downloadLatestFW(FirmwareInfo *firmware, const QString & firmwareId);
void unloadProfile();
private slots:
void openDocumentURL();
@@ -146,10 +144,10 @@ private slots:
void compare();
void print();
void loadBackup();
void preferences();
void appPreferences();
void fwPreferences();
void updateMenus();
void createProfile();
MdiChild *createMdiChild();
void setActiveSubWindow(QWidget *window);
QMenu * createRecentFileMenu();
@@ -199,7 +197,7 @@ private:
bool needRename;
bool showcheckForUpdatesResult;
int MaxRecentFiles;
int ActiveProfile;
// int ActiveProfile;
int currentFWrev;
int currentFWrev_temp;
int NewFwRev;
@@ -224,7 +222,6 @@ private:
QAction *saveAct;
QAction *saveAsAct;
QAction *exitAct;
QAction *preferencesAct;
QAction *appPreferencesAct;
QAction *fwPreferencesAct;
QAction *checkForUpdatesAct;
@@ -253,6 +250,7 @@ private:
QAction *logsAct;
QAction *recentFileActs[MAX_RECENT];
QAction *profileActs[MAX_PROFILES];
QAction *createProfileAct;
QAction *classicThemeAct;
QAction *monoThemeAct;
QAction *monoBlueThemeAct;
+505
View File
@@ -0,0 +1,505 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>appPreferencesDialog</class>
<widget class="QDialog" name="appPreferencesDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>685</width>
<height>456</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>685</width>
<height>0</height>
</size>
</property>
<property name="windowTitle">
<string>Application Preferences</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="verticalSpacing">
<number>2</number>
</property>
<property name="margin">
<number>6</number>
</property>
<item row="20" column="8">
<widget class="QPushButton" name="libraryPathButton">
<property name="text">
<string>Open Folder</string>
</property>
</widget>
</item>
<item row="22" column="1" colspan="8">
<widget class="Line" name="line_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="1" column="1" colspan="8">
<widget class="Line" name="line_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="17" column="0">
<widget class="QLabel" name="label_11">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Joystick</string>
</property>
</widget>
</item>
<item row="13" column="0">
<widget class="QLabel" name="label_19">
<property name="text">
<string>Simulator capture folder</string>
</property>
</widget>
</item>
<item row="15" column="1" colspan="7">
<widget class="QCheckBox" name="simuSW">
<property name="text">
<string>Remember simulator switch values</string>
</property>
</widget>
</item>
<item row="20" column="0">
<widget class="QLabel" name="label_9">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>User Splash Screens</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_5">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Files to keep</string>
</property>
</widget>
</item>
<item row="8" column="1" colspan="7">
<widget class="QCheckBox" name="wizardEnable_ChkB">
<property name="text">
<string>Offer to use wizard for new models</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="18" column="1" colspan="8">
<widget class="Line" name="line_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="16" column="1">
<widget class="QComboBox" name="backLightColor">
<property name="maximumSize">
<size>
<width>100</width>
<height>16777215</height>
</size>
</property>
<item>
<property name="text">
<string>Blue</string>
</property>
</item>
<item>
<property name="text">
<string>Green</string>
</property>
</item>
<item>
<property name="text">
<string>Red</string>
</property>
</item>
<item>
<property name="text">
<string>Orange</string>
</property>
</item>
<item>
<property name="text">
<string>Yellow</string>
</property>
</item>
</widget>
</item>
<item row="7" column="1" colspan="7">
<widget class="QCheckBox" name="startupCheck_companion9x">
<property name="text">
<string>Automatic check for Companion updates</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="9" column="1" colspan="8">
<widget class="Line" name="line_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="13" column="1" colspan="7">
<widget class="QLineEdit" name="snapshotPath">
<property name="enabled">
<bool>true</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="14" column="1" colspan="7">
<widget class="QCheckBox" name="snapshotClipboardCKB">
<property name="text">
<string>Only capture to clipboard</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QSpinBox" name="historySize">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>40</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>50</width>
<height>16777215</height>
</size>
</property>
<property name="maximum">
<number>15</number>
</property>
<property name="value">
<number>10</number>
</property>
</widget>
</item>
<item row="12" column="1" colspan="8">
<widget class="Line" name="line_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="4" column="1" colspan="8">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="0" column="1" colspan="7">
<widget class="QLineEdit" name="ge_lineedit">
<property name="minimumSize">
<size>
<width>250</width>
<height>0</height>
</size>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="17" column="8">
<widget class="QPushButton" name="joystickcalButton">
<property name="text">
<string>Calibrate</string>
</property>
</widget>
</item>
<item row="10" column="0">
<widget class="QLabel" name="label_17">
<property name="text">
<string>Automatic Backup Folder</string>
</property>
</widget>
</item>
<item row="23" column="7" colspan="2">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
<item row="13" column="8">
<widget class="QPushButton" name="snapshotPathButton">
<property name="text">
<string>Open Folder</string>
</property>
<property name="flat">
<bool>false</bool>
</property>
</widget>
</item>
<item row="10" column="1" colspan="7">
<widget class="QLineEdit" name="backupPath">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="17" column="1">
<widget class="QComboBox" name="joystickCB">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="16" column="0">
<widget class="QLabel" name="label_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Simulator BackLight</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="11" column="1" colspan="7">
<widget class="QCheckBox" name="backupEnable">
<property name="text">
<string>Enable automatic backup before writing firmware</string>
</property>
</widget>
</item>
<item row="5" column="1" colspan="7">
<widget class="QCheckBox" name="showSplash">
<property name="text">
<string>Show splash screen when Companion starts</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="8">
<widget class="QPushButton" name="ge_pathButton">
<property name="text">
<string>Find Executable</string>
</property>
</widget>
</item>
<item row="10" column="8">
<widget class="QPushButton" name="backupPathButton">
<property name="text">
<string>Open Folder</string>
</property>
</widget>
</item>
<item row="17" column="4" colspan="4">
<widget class="QCheckBox" name="joystickChkB">
<property name="text">
<string>Enable</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="ge_label">
<property name="text">
<string>Google Earth Executable</string>
</property>
</widget>
</item>
<item row="6" column="1" colspan="7">
<widget class="QCheckBox" name="startupCheck_fw">
<property name="text">
<string>Automatic check for OpenTX firmware updates</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="19" column="1">
<widget class="QComboBox" name="splashincludeCB">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item>
<property name="text">
<string>Include companion splashes</string>
</property>
</item>
<item>
<property name="text">
<string>Only user defined splashes</string>
</property>
</item>
</widget>
</item>
<item row="19" column="0">
<widget class="QLabel" name="label_10">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Splash Screen Library</string>
</property>
</widget>
</item>
<item row="20" column="1" colspan="7">
<widget class="QLineEdit" name="libraryPath">
<property name="enabled">
<bool>true</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
<zorder>startupCheck_companion9x</zorder>
<zorder>backupEnable</zorder>
<zorder>line</zorder>
<zorder>backupPath</zorder>
<zorder>line_2</zorder>
<zorder>startupCheck_fw</zorder>
<zorder>wizardEnable_ChkB</zorder>
<zorder>ge_label</zorder>
<zorder>label_5</zorder>
<zorder>showSplash</zorder>
<zorder>line_3</zorder>
<zorder>ge_pathButton</zorder>
<zorder>line_4</zorder>
<zorder>backupPathButton</zorder>
<zorder>label_3</zorder>
<zorder>backLightColor</zorder>
<zorder>snapshotPath</zorder>
<zorder>snapshotPathButton</zorder>
<zorder>snapshotClipboardCKB</zorder>
<zorder>label_11</zorder>
<zorder>joystickCB</zorder>
<zorder>joystickcalButton</zorder>
<zorder>ge_lineedit</zorder>
<zorder>simuSW</zorder>
<zorder>buttonBox</zorder>
<zorder>line_5</zorder>
<zorder>joystickChkB</zorder>
<zorder>label_17</zorder>
<zorder>label_19</zorder>
<zorder>historySize</zorder>
<zorder>label_9</zorder>
<zorder>libraryPath</zorder>
<zorder>libraryPathButton</zorder>
<zorder>line_6</zorder>
<zorder>splashincludeCB</zorder>
<zorder>label_10</zorder>
</widget>
<tabstops>
<tabstop>buttonBox</tabstop>
<tabstop>ge_lineedit</tabstop>
<tabstop>ge_pathButton</tabstop>
<tabstop>historySize</tabstop>
<tabstop>showSplash</tabstop>
<tabstop>startupCheck_fw</tabstop>
<tabstop>startupCheck_companion9x</tabstop>
<tabstop>wizardEnable_ChkB</tabstop>
<tabstop>backupPath</tabstop>
<tabstop>backupPathButton</tabstop>
<tabstop>backupEnable</tabstop>
<tabstop>snapshotPath</tabstop>
<tabstop>snapshotPathButton</tabstop>
<tabstop>snapshotClipboardCKB</tabstop>
<tabstop>simuSW</tabstop>
<tabstop>backLightColor</tabstop>
<tabstop>joystickCB</tabstop>
<tabstop>joystickChkB</tabstop>
<tabstop>joystickcalButton</tabstop>
</tabstops>
<resources>
<include location="companion.qrc"/>
</resources>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>appPreferencesDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>376</x>
<y>596</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>appPreferencesDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>396</x>
<y>596</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 876 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB