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

Separate context menu for "General Settings", cosmetics

This commit is contained in:
Damjan Adamic 2015-08-16 09:28:43 +02:00
parent 3469fa5c93
commit 154572e547
3 changed files with 99 additions and 87 deletions

View file

@ -170,7 +170,7 @@ void MdiChild::generalEdit()
void MdiChild::modelEdit()
{
int row = ui->modelsList->currentRow();
int row = getCurrentRow();
if (row == 0){
generalEdit();
@ -189,7 +189,7 @@ void MdiChild::modelEdit()
void MdiChild::wizardEdit()
{
int row = ui->modelsList->currentRow();
int row = getCurrentRow();
if (row > 0) {
checkAndInitModel(row);
WizardDialog * wizard = new WizardDialog(radioData.generalSettings, row, this);
@ -203,7 +203,7 @@ void MdiChild::wizardEdit()
void MdiChild::openEditWindow()
{
int row = ui->modelsList->currentRow();
int row = getCurrentRow();
if (row == 0){
generalEdit();
}
@ -529,8 +529,8 @@ void MdiChild::writeEeprom() // write to Tx
void MdiChild::simulate()
{
if (ui->modelsList->currentRow() >= 1) {
startSimulation(this, radioData, ui->modelsList->currentRow()-1);
if (getCurrentRow() > 0) {
startSimulation(this, radioData, getCurrentRow()-1);
}
}
@ -541,8 +541,8 @@ void MdiChild::print(int model, QString filename)
if (model>=0 && !filename.isEmpty()) {
pd = new PrintDialog(this, GetCurrentFirmware()/*firmware*/, &radioData.generalSettings, &radioData.models[model], filename);
}
else if (ui->modelsList->currentRow() > 0) {
pd = new PrintDialog(this, GetCurrentFirmware()/*firmware*/, &radioData.generalSettings, &radioData.models[ui->modelsList->currentRow()-1]);
else if (getCurrentRow() > 0) {
pd = new PrintDialog(this, GetCurrentFirmware()/*firmware*/, &radioData.generalSettings, &radioData.models[getCurrentRow()-1]);
}
if (pd) {
@ -561,6 +561,11 @@ void MdiChild::setEEpromAvail(int eavail)
EEPromAvail=eavail;
}
int MdiChild::getCurrentRow() const
{
return ui->modelsList->currentRow();
}
bool MdiChild::loadBackup()
{
QString fileName = QFileDialog::getOpenFileName(this, tr("Open backup Models and Settings file"), g.eepromDir(),tr(EEPROM_FILES_FILTER));
@ -572,8 +577,8 @@ bool MdiChild::loadBackup()
QMessageBox::critical(this, tr("Error"), tr("Unable to find file %1!").arg(fileName));
return false;
}
if(ui->modelsList->currentRow()<1) return false;
int index=ui->modelsList->currentRow()-1;
if(getCurrentRow() < 1) return false;
int index = getCurrentRow() - 1;
int eeprom_size = file.size();
if (!file.open(QFile::ReadOnly)) { //reading binary file - TODO HEX support

View file

@ -77,6 +77,7 @@ class MdiChild : public QWidget
void viableModelSelected(bool viable);
void eepromInterfaceChanged();
void setEEpromAvail(int eavail);
int getCurrentRow() const;
signals:
void copyAvailable(bool val);

View file

@ -79,12 +79,13 @@ ModelsListWidget::ModelsListWidget(QWidget *parent):
void ModelsListWidget::ShowContextMenu(const QPoint& pos)
{
QPoint globalPos = this->mapToGlobal(pos);
QMenu contextMenu;
if (((MdiChild *)parent())->getCurrentRow() > 0) {
// context menu for model
const QClipboard *clipboard = QApplication::clipboard();
const QMimeData *mimeData = clipboard->mimeData();
bool hasData = mimeData->hasFormat("application/x-companion");
QMenu contextMenu;
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()));
@ -100,6 +101,11 @@ void ModelsListWidget::ShowContextMenu(const QPoint& pos)
contextMenu.addAction(CompanionIcon("print.png"), tr("P&rint model"),this, SLOT(print()),QKeySequence(tr("Ctrl+P")));
contextMenu.addSeparator();
contextMenu.addAction(CompanionIcon("simulate.png"), tr("&Simulate model"),this, SLOT(simulate()),tr("Alt+S"));
}
else {
// context menu for radio settings
contextMenu.addAction(CompanionIcon("edit.png"), tr("&Edit"),this,SLOT(EditModel()));
}
contextMenu.exec(globalPos);
}