From 9dfffbf64127cbfe9f8c2694b13bc967482c576a Mon Sep 17 00:00:00 2001 From: Kjell Kernen Date: Mon, 3 Mar 2014 16:30:01 +0100 Subject: [PATCH] Changed logics for opening model edit windows. Double clicking an empty slot always opens wizard. Clicking en existing always opens model edit. By using right click menu either can be specified. --- companion/src/appdata.cpp | 8 +- companion/src/appdata.h | 4 - companion/src/apppreferencesdialog.cpp | 2 - companion/src/apppreferencesdialog.ui | 890 ++++++++++++------------- companion/src/mainwindow.cpp | 6 +- companion/src/mdichild.cpp | 87 +-- companion/src/mdichild.h | 7 +- companion/src/modelslist.cpp | 11 +- companion/src/modelslist.h | 1 + 9 files changed, 512 insertions(+), 504 deletions(-) diff --git a/companion/src/appdata.cpp b/companion/src/appdata.cpp index ec634da4d..1c3e2dae3 100644 --- a/companion/src/appdata.cpp +++ b/companion/src/appdata.cpp @@ -490,7 +490,6 @@ bool AppData::snapToClpbrd() { return _snapToClpbrd; } bool AppData::autoCheckApp() { return _autoCheckApp; } bool AppData::autoCheckFw() { return _autoCheckFw; } bool AppData::simuSW() { return _simuSW; } -bool AppData::enableWizard() { return _enableWizard; } int AppData::backLight() { return _backLight; } int AppData::embedSplashes() { return _embedSplashes; } @@ -499,7 +498,6 @@ int AppData::generalEditTab() { return _generalEditTab; } int AppData::iconSize() { return _iconSize; } int AppData::historySize() { return _historySize; } int AppData::jsCtrl() { return _jsCtrl; } -int AppData::modelEditTab() { return _modelEditTab; } int AppData::id() { return _id; } int AppData::theme() { return _theme; } int AppData::warningId() { return _warningId; } @@ -544,7 +542,6 @@ void AppData::snapToClpbrd (const bool x) { store(x, _snapToClpbrd, void AppData::autoCheckApp (const bool x) { store(x, _autoCheckApp, "startup_check_companion" );} void AppData::autoCheckFw (const bool x) { store(x, _autoCheckFw, "startup_check_fw" );} void AppData::simuSW (const bool x) { store(x, _simuSW, "simuSW" );} -void AppData::enableWizard (const bool x) { store(x, _enableWizard, "wizardEnable" );} void AppData::backLight (const int x) { store(x, _backLight, "backLight" );} void AppData::embedSplashes (const int x) { store(x, _embedSplashes, "embedded_splashes" );} @@ -553,7 +550,6 @@ void AppData::generalEditTab (const int x) { store(x, _generalEditTab, void AppData::iconSize (const int x) { store(x, _iconSize, "icon_size" );} void AppData::historySize (const int x) { store(x, _historySize, "history_size" );} void AppData::jsCtrl (const int x) { store(x, _jsCtrl, "js_ctrl" );} -void AppData::modelEditTab (const int x) { store(x, _modelEditTab, "modelEditTab" );} void AppData::id (const int x) { store(x, _id, "profileId" );} void AppData::theme (const int x) { store(x, _theme, "theme" );} void AppData::warningId (const int x) { store(x, _warningId, "warningId" );} @@ -611,12 +607,14 @@ AppData::AppData() settings.remove("default_mode"); settings.remove("firmware"); settings.remove("lastFw"); + settings.remove("modelEditTab"); settings.remove("Name"); settings.remove("patchImage"); settings.remove("rename_firmware_files"); settings.remove("sdPath"); settings.remove("SplashFileName"); settings.remove("startup_check_companion9x"); + settings.remove("wizardEnable"); // Select the new default profile as current profile id( 0 ); @@ -662,7 +660,6 @@ AppData::AppData() getset( _autoCheckApp, "startup_check_companion" ,true ); getset( _autoCheckFw, "startup_check_fw" ,true ); getset( _simuSW, "simuSW" ,false ); - getset( _enableWizard, "wizardEnable" ,true ); getset( _backLight, "backLight" ,0 ); getset( _embedSplashes, "embedded_splashes" ,0 ); @@ -671,7 +668,6 @@ AppData::AppData() getset( _iconSize, "icon_size" ,2 ); getset( _jsCtrl, "js_ctrl" ,0 ); getset( _historySize, "history_size" ,10 ); - getset( _modelEditTab, "modelEditTab" ,0 ); getset( _id, "profileId" ,0 ); getset( _theme, "theme" ,1 ); getset( _warningId, "warningId" ,0 ); diff --git a/companion/src/appdata.h b/companion/src/appdata.h index 443f6bab2..52cff32c9 100644 --- a/companion/src/appdata.h +++ b/companion/src/appdata.h @@ -221,7 +221,6 @@ class AppData: protected CompStoreObj bool _autoCheckApp; bool _autoCheckFw; bool _simuSW; - bool _enableWizard; int _backLight; int _embedSplashes; @@ -230,7 +229,6 @@ class AppData: protected CompStoreObj int _iconSize; int _jsCtrl; int _historySize; - int _modelEditTab; int _id; int _theme; int _warningId; @@ -277,7 +275,6 @@ class AppData: protected CompStoreObj bool autoCheckApp(); bool autoCheckFw(); bool simuSW(); - bool enableWizard(); int backLight(); int embedSplashes(); @@ -286,7 +283,6 @@ class AppData: protected CompStoreObj int iconSize(); int historySize(); int jsCtrl(); - int modelEditTab(); // This variable is unused an can be removed int id(); int theme(); int warningId(); diff --git a/companion/src/apppreferencesdialog.cpp b/companion/src/apppreferencesdialog.cpp index 17787f9c0..a29752dbe 100644 --- a/companion/src/apppreferencesdialog.cpp +++ b/companion/src/apppreferencesdialog.cpp @@ -38,7 +38,6 @@ void appPreferencesDialog::writeValues() { g.autoCheckApp(ui->startupCheck_companion9x->isChecked()); g.autoCheckFw(ui->startupCheck_fw->isChecked()); - g.enableWizard(ui->wizardEnable_ChkB->isChecked()); g.showSplash(ui->showSplash->isChecked()); g.simuSW(ui->simuSW->isChecked()); g.historySize(ui->historySize->value()); @@ -101,7 +100,6 @@ void appPreferencesDialog::initSettings() } ui->startupCheck_companion9x->setChecked(g.autoCheckApp()); ui->startupCheck_fw->setChecked(g.autoCheckFw()); - ui->wizardEnable_ChkB->setChecked(g.enableWizard()); ui->showSplash->setChecked(g.showSplash()); ui->historySize->setValue(g.historySize()); ui->backLightColor->setCurrentIndex(g.backLight()); diff --git a/companion/src/apppreferencesdialog.ui b/companion/src/apppreferencesdialog.ui index f5d4b9deb..de381395b 100644 --- a/companion/src/apppreferencesdialog.ui +++ b/companion/src/apppreferencesdialog.ui @@ -26,12 +26,21 @@ Edit Settings + + 6 + + + 6 + + + 6 + + + 6 + 2 - - 6 - @@ -47,450 +56,9 @@ 0 - - - Application Settings - - - - - - Qt::Horizontal - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Automatic Backup Folder - - - - - - - - 40 - 0 - - - - - 50 - 16777215 - - - - 15 - - - 10 - - - - - - - - 0 - 0 - - - - User Splash Screens - - - - - - - - 0 - 0 - - - - - Only show user splash images - - - - - Show user and companion splash images - - - - - - - - Google Earth Executable - - - - - - - Automatic check for OpenTX firmware updates - - - true - - - - - - - - 350 - 0 - - - - true - - - - - - - Open Folder - - - - - - - Qt::Horizontal - - - - - - - - 350 - 0 - - - - true - - - - - - - Find Executable - - - - - - - - 0 - 0 - - - - Files to keep - - - - - - - - 0 - 0 - - - - Splash Screen Library - - - - - - - Enable automatic backup before writing firmware - - - - - - - Open Folder - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - Qt::Horizontal - - - - - - - Automatic check for Companion updates - - - true - - - - - - - Qt::Horizontal - - - - - - - Offer to use wizard for new models - - - true - - - - - - - Show splash screen when Companion starts - - - true - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - true - - - true - - - - - - - - Simulator Settings - - - - - - - 0 - 0 - - - - Simulator BackLight - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - - Enable - - - - - - - Open Folder - - - false - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 100 - 16777215 - - - - - Blue - - - - - Green - - - - - Red - - - - - Orange - - - - - Yellow - - - - - - - - - 0 - 0 - - - - Joystick - - - - - - - Only capture to clipboard - - - - - - - - 0 - 0 - - - - - - - - Calibrate - - - - - - - Remember simulator switch values - - - - - - - Simulator capture folder - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - true - - - - 350 - 0 - - - - true - - - - - - Radio Settings Profile + Radio Profile @@ -989,6 +557,437 @@ This is used by the templated to determine which channel goes to what number out + + + Application Settings + + + + + + + 350 + 0 + + + + true + + + + + + + Qt::Horizontal + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Automatic Backup Folder + + + + + + + + 40 + 0 + + + + + 50 + 16777215 + + + + 15 + + + 10 + + + + + + + + 0 + 0 + + + + User Splash Screens + + + + + + + + 0 + 0 + + + + + Only show user splash images + + + + + Show user and companion splash images + + + + + + + + Google Earth Executable + + + + + + + Automatic check for OpenTX firmware updates + + + true + + + + + + + + 350 + 0 + + + + true + + + + + + + Open Folder + + + + + + + Qt::Horizontal + + + + + + + Find Executable + + + + + + + + 0 + 0 + + + + Files to keep + + + + + + + + 0 + 0 + + + + Splash Screen Library + + + + + + + Enable automatic backup before writing firmware + + + + + + + Open Folder + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Qt::Horizontal + + + + + + + Automatic check for Companion updates + + + true + + + + + + + Qt::Horizontal + + + + + + + Show splash screen when Companion starts + + + true + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + true + + + true + + + + + + + + Simulator Settings + + + + + + + 0 + 0 + + + + Simulator BackLight + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + Enable + + + + + + + Open Folder + + + false + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 100 + 16777215 + + + + + Blue + + + + + Green + + + + + Red + + + + + Orange + + + + + Yellow + + + + + + + + + 0 + 0 + + + + Joystick + + + + + + + Only capture to clipboard + + + + + + + + 0 + 0 + + + + + + + + Calibrate + + + + + + + Remember simulator switch values + + + + + + + Simulator capture folder + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + true + + + + 350 + 0 + + + + true + + + + + @@ -1001,7 +1000,6 @@ This is used by the templated to determine which channel goes to what number out showSplash startupCheck_fw startupCheck_companion9x - wizardEnable_ChkB backupPath backupPathButton backupEnable diff --git a/companion/src/mainwindow.cpp b/companion/src/mainwindow.cpp index 0f8d36389..3570dbd34 100644 --- a/companion/src/mainwindow.cpp +++ b/companion/src/mainwindow.cpp @@ -1750,7 +1750,7 @@ QMenu *MainWindow::createRecentFileMenu() QMenu *MainWindow::createProfilesMenu() { - QMenu *profilesMenu=new QMenu(tr("Radio Settings Profile")); + QMenu *profilesMenu=new QMenu(tr("Radio Profile")); int i; for ( i = 0; i < MAX_PROFILES; ++i) { profilesMenu->addAction(profileActs[i]); @@ -1809,8 +1809,8 @@ void MainWindow::createToolBars() profileButton->setFocusPolicy(Qt::NoFocus); profileButton->setMenu(createProfilesMenu()); profileButton->setIcon(CompanionIcon("profiles.png")); - profileButton->setToolTip(tr("Radio Settings Profile")); - profileButton->setStatusTip(tr("Show a selection list of radio settings profiles")); + profileButton->setToolTip(tr("Radio Profile")); + profileButton->setStatusTip(tr("Show a selection list of radio profiles")); fileToolBar->addWidget(profileButton); fileToolBar->addAction(editSplashAct); diff --git a/companion/src/mdichild.cpp b/companion/src/mdichild.cpp index 9bde8a9f7..aa6dc1a3d 100644 --- a/companion/src/mdichild.cpp +++ b/companion/src/mdichild.cpp @@ -110,11 +110,6 @@ void MdiChild::copy() ui->modelsList->copy(); } -void MdiChild::openWizard() -{ - WizardDialog *wizard = new WizardDialog(this); - wizard->show(); -} void MdiChild::paste() { @@ -152,47 +147,63 @@ void MdiChild::on_SimulateTxButton_clicked() startSimulation(this, radioData, -1); } -void MdiChild::OpenEditWindow() +void MdiChild::checkAndInitModel( int row ) +{ + ModelData &model = radioData.models[row - 1]; + if (model.isempty()) { + model.setDefault(row - 1); + setModified(); + } +} + +void MdiChild::generalEdit() +{ + GeneralEdit *t = new GeneralEdit(radioData, this); + connect(t, SIGNAL(modelValuesChanged()), this, SLOT(setModified())); + t->show(); +} + +void MdiChild::modelEdit() { int row = ui->modelsList->currentRow(); - bool wizard=false; - if (row) { - //TODO error checking - bool isNew = false; + if (row == 0){ + generalEdit(); + } + else { + checkAndInitModel( row ); ModelData &model = radioData.models[row - 1]; - - if (model.isempty()) { - model.setDefault(row - 1); - isNew = true; //modeledit - clear mixes, apply first template - setModified(); - } - if (isNew) { - int ret; - if (g.enableWizard()) { - ret = QMessageBox::question(this, tr("Companion"), tr("Do you want to use model wizard? "), QMessageBox::Yes | QMessageBox::No); - if (ret == QMessageBox::Yes) { - wizard=true; - } else { - qSleep(500); - ret = QMessageBox::question(this, tr("Companion"), tr("Ask this question again ? "), QMessageBox::Yes | QMessageBox::No); - if (ret == QMessageBox::No) { - g.enableWizard( false ); - } - } - } - } - ModelEdit *t = new ModelEdit(radioData, (row - 1), wizard, this); - // TODO if (isNew && !wizard) t->applyBaseTemplate(); + ModelEdit *t = new ModelEdit(radioData, (row - 1), false, this); t->setWindowTitle(tr("Editing model %1: ").arg(row) + model.name); connect(t, SIGNAL(modified()), this, SLOT(setModified())); - //t->exec(); t->show(); } - else { - GeneralEdit *t = new GeneralEdit(radioData, this); - connect(t, SIGNAL(modelValuesChanged()), this, SLOT(setModified())); - t->show(); +} + +void MdiChild::wizardEdit() +{ + int row = ui->modelsList->currentRow(); + if (row > 0) { + checkAndInitModel(row); + WizardDialog *wizard = new WizardDialog(this); + wizard->show(); + } +} + +void MdiChild::openEditWindow() +{ + int row = ui->modelsList->currentRow(); + if (row == 0){ + generalEdit(); + } + else{ + ModelData &model = radioData.models[row - 1]; + if (model.isempty()) { + wizardEdit(); + } + else { + modelEdit(); + } } } diff --git a/companion/src/mdichild.h b/companion/src/mdichild.h index 9aaaa7c2c..1ff1730cc 100644 --- a/companion/src/mdichild.h +++ b/companion/src/mdichild.h @@ -89,11 +89,14 @@ private slots: void qSleep(int ms); public slots: - void OpenEditWindow(); + void checkAndInitModel(int row); + void generalEdit(); + void modelEdit(); + void wizardEdit(); + void openEditWindow(); void cut(); void copy(); - void openWizard(); void paste(); void writeEeprom(); void simulate(); diff --git a/companion/src/modelslist.cpp b/companion/src/modelslist.cpp index 19300c5f8..65996ce51 100644 --- a/companion/src/modelslist.cpp +++ b/companion/src/modelslist.cpp @@ -85,7 +85,7 @@ void ModelsListWidget::ShowContextMenu(const QPoint& pos) bool hasData = mimeData->hasFormat("application/x-companion"); QMenu contextMenu; - contextMenu.addAction(CompanionIcon("edit.png"), tr("&Edit"),this,SLOT(OpenEditWindow())); + contextMenu.addAction(CompanionIcon("edit.png"), tr("&Edit"),this,SLOT(EditModel())); contextMenu.addAction(CompanionIcon("open.png"), tr("&Restore from backup"),this,SLOT(LoadBackup())); contextMenu.addAction(CompanionIcon("wizard.png"), tr("&Model Wizard"),this,SLOT(OpenWizard())); contextMenu.addSeparator(); @@ -103,14 +103,19 @@ void ModelsListWidget::ShowContextMenu(const QPoint& pos) contextMenu.exec(globalPos); } +void ModelsListWidget::EditModel() +{ + ((MdiChild *)parent())->modelEdit(); +} + void ModelsListWidget::OpenEditWindow() { - ((MdiChild *)parent())->OpenEditWindow(); + ((MdiChild *)parent())->openEditWindow(); } void ModelsListWidget::OpenWizard() { - ((MdiChild *)parent())->openWizard(); + ((MdiChild *)parent())->wizardEdit(); } void ModelsListWidget::LoadBackup() diff --git a/companion/src/modelslist.h b/companion/src/modelslist.h index 8d6e73e83..b21d4914b 100644 --- a/companion/src/modelslist.h +++ b/companion/src/modelslist.h @@ -81,6 +81,7 @@ public slots: void copy(); void paste(); void print(); + void EditModel(); void OpenEditWindow(); void LoadBackup(); void OpenWizard();