void ConfigDialog::on_removeProfilePushButton_clicked() { if (ui->profilesComboBox->count() < 2) return; QString profile = ui->profilesComboBox->currentText(); if (!getProfiles(m_strIniPath).contains(profile)) return; QString msg(tr("Are you sure you want to remove profile \"")); msg += profile + "\""; QMessageBox msgBox(QMessageBox::Warning, tr("Remove profile"), msg, QMessageBox::Yes | QMessageBox::Cancel, this); msgBox.setDefaultButton(QMessageBox::Cancel); msgBox.setButtonText(QMessageBox::Yes, tr("Yes")); msgBox.setButtonText(QMessageBox::Cancel, tr("Cancel")); if (msgBox.exec() == QMessageBox::Yes) { removeProfile(m_strIniPath, profile); ui->profilesComboBox->blockSignals(true); ui->profilesComboBox->removeItem(ui->profilesComboBox->currentIndex()); changeProfile(m_strIniPath, ui->profilesComboBox->itemText(ui->profilesComboBox->currentIndex())); ui->profilesComboBox->blockSignals(false); _init(); ui->removeProfilePushButton->setDisabled(ui->profilesComboBox->count() < 2); } }
void processRcStickPositions(rxConfig_t *rxConfig, throttleStatus_e throttleStatus, bool retarded_arm, bool disarm_kill_switch) { static uint8_t rcDelayCommand; // this indicates the number of time (multiple of RC measurement at 50Hz) the sticks must be maintained to run or switch off motors static uint8_t rcSticks; // this hold sticks position for command combos uint8_t stTmp = 0; int i; // ------------------ STICKS COMMAND HANDLER -------------------- // checking sticks positions for (i = 0; i < 4; i++) { stTmp >>= 2; if (rcData[i] > rxConfig->mincheck) stTmp |= 0x80; // check for MIN if (rcData[i] < rxConfig->maxcheck) stTmp |= 0x40; // check for MAX } if (stTmp == rcSticks) { if (rcDelayCommand < 250) rcDelayCommand++; } else rcDelayCommand = 0; rcSticks = stTmp; // perform actions if (!isUsingSticksToArm) { if (IS_RC_MODE_ACTIVE(BOXARM)) { // Arming via ARM BOX if (throttleStatus == THROTTLE_LOW) { if (ARMING_FLAG(OK_TO_ARM)) { mwArm(); } } } else { // Disarming via ARM BOX if (ARMING_FLAG(ARMED) && rxIsReceivingSignal() && !failsafeIsActive() ) { if (disarm_kill_switch) { mwDisarm(); } else if (throttleStatus == THROTTLE_LOW) { mwDisarm(); } } } } if (rcDelayCommand != 20) { return; } if (isUsingSticksToArm) { // Disarm on throttle down + yaw if (rcSticks == THR_LO + YAW_LO + PIT_CE + ROL_CE) { if (ARMING_FLAG(ARMED)) mwDisarm(); else { beeper(BEEPER_DISARM_REPEAT); // sound tone while stick held rcDelayCommand = 0; // reset so disarm tone will repeat } } // Disarm on roll (only when retarded_arm is enabled) if (retarded_arm && (rcSticks == THR_LO + YAW_CE + PIT_CE + ROL_LO)) { if (ARMING_FLAG(ARMED)) mwDisarm(); else { beeper(BEEPER_DISARM_REPEAT); // sound tone while stick held rcDelayCommand = 0; // reset so disarm tone will repeat } } } if (ARMING_FLAG(ARMED)) { // actions during armed return; } // actions during not armed i = 0; if (rcSticks == THR_LO + YAW_LO + PIT_LO + ROL_CE) { // GYRO calibration gyroSetCalibrationCycles(CALIBRATING_GYRO_CYCLES); #ifdef GPS if (feature(FEATURE_GPS)) { GPS_reset_home_position(); } #endif #ifdef BARO if (sensors(SENSOR_BARO)) baroSetCalibrationCycles(10); // calibrate baro to new ground level (10 * 25 ms = ~250 ms non blocking) #endif if (!sensors(SENSOR_MAG)) heading = 0; // reset heading to zero after gyro calibration return; } if (feature(FEATURE_INFLIGHT_ACC_CAL) && (rcSticks == THR_LO + YAW_LO + PIT_HI + ROL_HI)) { // Inflight ACC Calibration handleInflightCalibrationStickPosition(); return; } // Multiple configuration profiles if (rcSticks == THR_LO + YAW_LO + PIT_CE + ROL_LO) // ROLL left -> Profile 1 i = 1; else if (rcSticks == THR_LO + YAW_LO + PIT_HI + ROL_CE) // PITCH up -> Profile 2 i = 2; else if (rcSticks == THR_LO + YAW_LO + PIT_CE + ROL_HI) // ROLL right -> Profile 3 i = 3; if (i) { changeProfile(i - 1); return; } if (rcSticks == THR_LO + YAW_LO + PIT_LO + ROL_HI) { saveConfigAndNotify(); } if (isUsingSticksToArm) { if (rcSticks == THR_LO + YAW_HI + PIT_CE + ROL_CE) { // Arm via YAW mwArm(); return; } if (retarded_arm && (rcSticks == THR_LO + YAW_CE + PIT_CE + ROL_HI)) { // Arm via ROLL mwArm(); return; } } if (rcSticks == THR_HI + YAW_LO + PIT_LO + ROL_CE) { // Calibrating Acc accSetCalibrationCycles(CALIBRATING_ACC_CYCLES); return; } if (rcSticks == THR_HI + YAW_HI + PIT_LO + ROL_CE) { // Calibrating Mag ENABLE_STATE(CALIBRATE_MAG); return; } // Accelerometer Trim rollAndPitchTrims_t accelerometerTrimsDelta; memset(&accelerometerTrimsDelta, 0, sizeof(accelerometerTrimsDelta)); bool shouldApplyRollAndPitchTrimDelta = false; if (rcSticks == THR_HI + YAW_CE + PIT_HI + ROL_CE) { accelerometerTrimsDelta.values.pitch = 2; shouldApplyRollAndPitchTrimDelta = true; } else if (rcSticks == THR_HI + YAW_CE + PIT_LO + ROL_CE) { accelerometerTrimsDelta.values.pitch = -2; shouldApplyRollAndPitchTrimDelta = true; } else if (rcSticks == THR_HI + YAW_CE + PIT_CE + ROL_HI) { accelerometerTrimsDelta.values.roll = 2; shouldApplyRollAndPitchTrimDelta = true; } else if (rcSticks == THR_HI + YAW_CE + PIT_CE + ROL_LO) { accelerometerTrimsDelta.values.roll = -2; shouldApplyRollAndPitchTrimDelta = true; } if (shouldApplyRollAndPitchTrimDelta) { applyAndSaveAccelerometerTrimsDelta(&accelerometerTrimsDelta); rcDelayCommand = 0; // allow autorepetition return; } #ifdef DISPLAY if (rcSticks == THR_LO + YAW_CE + PIT_HI + ROL_LO) { displayDisablePageCycling(); } if (rcSticks == THR_LO + YAW_CE + PIT_HI + ROL_HI) { displayEnablePageCycling(); } #endif }
OptionsDialog::OptionsDialog(Juicer* juicer) : QDialog(juicer) { setupUi(this); this->juicer = juicer; #ifndef Q_WS_WIN handlerGroupBox->setHidden(true); #endif IconWidget* l = new IconWidget(":/options/core.png", tr("Core"), tr("Core Settings"), QBoxLayout::TopToBottom, listWidget); QListWidgetItem* item = new QListWidgetItem(listWidget); item->setSizeHint(l->size()); listWidget->setItemWidget(item, l); l = new IconWidget(":/options/limits.png", tr("Limits"), tr("Limitations"), QBoxLayout::TopToBottom, listWidget); item = new QListWidgetItem(listWidget); item->setSizeHint(l->size()); listWidget->setItemWidget(item, l); l = new IconWidget(":/options/appearance.png", tr("Appearance"), tr("Appearance of the GUI"), QBoxLayout::TopToBottom, listWidget); item = new QListWidgetItem(listWidget); item->setSizeHint(l->size()); listWidget->setItemWidget(item, l); l = new IconWidget(":/options/behaviour.png", tr("Behaviour"), tr("Behaviour of the GUI"), QBoxLayout::TopToBottom, listWidget); item = new QListWidgetItem(listWidget); item->setSizeHint(l->size()); listWidget->setItemWidget(item, l); l = new IconWidget(":/options/search.png", tr("Search"), tr("Search Settings"), QBoxLayout::TopToBottom, listWidget); item = new QListWidgetItem(listWidget); item->setSizeHint(l->size()); listWidget->setItemWidget(item, l); l = new IconWidget(":/options/launching.png", tr("Launching"), tr("Opening of Files"), QBoxLayout::TopToBottom, listWidget); item = new QListWidgetItem(listWidget); item->setSizeHint(l->size()); listWidget->setItemWidget(item, l); l = new IconWidget(":/options/ftp.png", tr("FTP"), tr("FTP Settings"), QBoxLayout::TopToBottom, listWidget); item = new QListWidgetItem(listWidget); item->setSizeHint(l->size()); listWidget->setItemWidget(item, l); l = new IconWidget(":/options/reset.png", tr("Reset"), tr("Configuration Reset"), QBoxLayout::TopToBottom, listWidget); item = new QListWidgetItem(listWidget); item->setSizeHint(l->size()); listWidget->setItemWidget(item, l); languageComboBox->addItem(QIcon(":/options/de.png"), "deutsch", "de"); languageComboBox->addItem(QIcon(":/options/gb.png"), "english", "en"); launchCombo->addItem(DEFAULT_LAUNCHER); if(DEFAULT_LAUNCHER == KDE_LAUNCHER) launchCombo->addItem(GNOME_LAUNCHER); specificRadioToggled(false); connect(incomingButton, SIGNAL(clicked()), this, SLOT(selectIncomingDir())); connect(tempButton, SIGNAL(clicked()), this, SLOT(selectTempDir())); connect(launcherButton, SIGNAL(clicked()), this, SLOT(selectLauncher())); connect(incomingSpecificButton, SIGNAL(clicked()), this, SLOT(selectIncomingDirSpecific())); connect(tempSpecificButton, SIGNAL(clicked()), this, SLOT(selectTempDirSpecific())); connect(specificRadio, SIGNAL(toggled(bool)), this, SLOT(specificRadioToggled(bool))); connect(listWidget, SIGNAL(currentRowChanged(int)), stackedWidget , SLOT(setCurrentIndex(int))); connect(jumpFtpButton, SIGNAL(clicked()), this , SLOT(jumpToFtpSlot())); connect(fontComboBox, SIGNAL(currentFontChanged(const QFont&)), this, SLOT(setFontSizes(const QFont&))); connect(this, SIGNAL(accepted()), this, SLOT(acceptedSlot())); connect(resetPushButton, SIGNAL(clicked()), this, SLOT(reset())); connect(profilesList, SIGNAL(itemSelectionChanged()), this, SLOT(profileSelectionChanged())); connect(addProfileButton, SIGNAL(clicked()), this, SLOT(addProfile())); connect(changeProfileButton, SIGNAL(clicked()), this, SLOT(changeProfile())); connect(removeProfileButton, SIGNAL(clicked()), this, SLOT(removeProfile())); profileChangeActive = true; profileChanged = false; listWidget->setCurrentRow(0); connect(downSpin, SIGNAL(valueChanged(int)), this, SLOT(limitsChanged())); connect(upSpin, SIGNAL(valueChanged(int)), this, SLOT(limitsChanged())); connect(slotSpin, SIGNAL(valueChanged(int)), this, SLOT(limitsChanged())); connect(sourcesSpin, SIGNAL(valueChanged(int)), this, SLOT(limitsChanged())); connect(connectionsSpin, SIGNAL(valueChanged(int)), this, SLOT(limitsChanged())); connect(newSpin, SIGNAL(valueChanged(int)), this, SLOT(limitsChanged())); }
MainForm::MainForm( QWidget* parent, const char* name, WFlags fl ) : QMainWindow( parent, name, fl ) { (void)statusBar(); if ( !name ) setName( "MainForm" ); setCentralWidget( new QWidget( this, "qt_central_widget" ) ); MainFormLayout = new QVBoxLayout( centralWidget(), 11, 6, "MainFormLayout"); listView = new QListView( centralWidget(), "listView" ); listView->addColumn( tr( "Type" ) ); listView->addColumn( tr( "Name" ) ); listView->addColumn( tr( "Login" ) ); listView->addColumn( tr( "Password" ) ); listView->addColumn( tr( "Description" ) ); listView->setResizeMode( QListView::AllColumns ); listView->setSorting(-1); MainFormLayout->addWidget( listView ); // actions createProfileAction = new QAction( this, "createProfileAction" ); createProfileAction->setIconSet( QPixmap::fromMimeSource("new.png") ); openProfileAction = new QAction(this, "openProfileAction" ); openProfileAction->setIconSet( QPixmap::fromMimeSource("open.png") ); tb_openProfileAction = new QAction(this, "tb_openProfileAction"); tb_openProfileAction->setIconSet( QPixmap::fromMimeSource("tb_open.png") ); closeProfileAction = new QAction( this, "closeProfileAction" ); closeProfileAction->setIconSet( QPixmap::fromMimeSource("close.png") ); tb_closeProfileAction = new QAction( this, "tb_closeProfileAction" ); tb_closeProfileAction->setIconSet( QPixmap::fromMimeSource("tb_close.png") ); deleteProfileAction = new QAction( this, "deleteProfileAction" ); deleteProfileAction->setIconSet( QPixmap::fromMimeSource("delete_all.png") ); changeProfileAction = new QAction( this, "changeProfileAction" ); fileQuitAction = new QAction( this, "fileQuitAction" ); fileSaveAction = new QAction( this, "fileSaveAction" ); fileSaveAction->setIconSet( QPixmap::fromMimeSource("save.png") ); tb_fileSaveAction = new QAction( this, "tb_fileSaveAction" ); tb_fileSaveAction->setIconSet( QPixmap::fromMimeSource("tb_save.png") ); editUndoAction = new QAction( this, "editUndoAction" ); editUndoAction->setIconSet( QPixmap::fromMimeSource("undo.png") ); tb_editUndoAction = new QAction( this, "editUndoAction" ); tb_editUndoAction->setIconSet( QPixmap::fromMimeSource("tb_undo.png") ); editRedoAction = new QAction( this, "editRedoAction" ); editRedoAction->setIconSet( QPixmap::fromMimeSource("redo.png") ); tb_editRedoAction = new QAction( this, "tb_editRedoAction" ); tb_editRedoAction->setIconSet( QPixmap::fromMimeSource("tb_redo.png") ); editNewField = new QAction( this, "editNewField" ); editNewField->setIconSet( QPixmap::fromMimeSource("new.png") ); editEditField = new QAction( this, "editEditField" ); editEditField->setIconSet( QPixmap::fromMimeSource("edit.png") ); tb_editEditField = new QAction( this, "tb_editEditField" ); tb_editEditField->setIconSet( QPixmap::fromMimeSource("tb_edit.png") ); tb_editNewField = new QAction( this, "tb_editNewField" ); tb_editNewField->setIconSet( QPixmap::fromMimeSource("tb_new.png") ); editDeleteField = new QAction( this, "editDeleteField" ); editDeleteField->setIconSet( QPixmap::fromMimeSource("delete.png") ); tb_editDeleteField = new QAction( this, "tb_editDeleteField" ); tb_editDeleteField->setIconSet( QPixmap::fromMimeSource("tb_delete.png") ); editDeleteAll = new QAction( this, "editDeleteAll" ); editDeleteAll->setIconSet( QPixmap::fromMimeSource("delete_all.png") ); helpAboutAction = new QAction( this, "helpAboutAction" ); // toolbars fileToolbar = new QToolBar( tr("File"), this, DockTop ); tb_openProfileAction->addTo( fileToolbar); tb_fileSaveAction->addTo( fileToolbar); tb_closeProfileAction->addTo( fileToolbar ); editToolbar = new QToolBar( tr("Edit"), this, DockTop ); tb_editUndoAction->addTo( editToolbar ); tb_editRedoAction->addTo( editToolbar ); editToolbar->addSeparator(); tb_editNewField->addTo( editToolbar ); tb_editEditField->addTo( editToolbar ); tb_editDeleteField->addTo( editToolbar ); // menubar MenuBarEditor = new QMenuBar( this, "MenuBarEditor" ); File = new QPopupMenu( this ); createProfileAction->addTo( File ); openProfileAction->addTo( File ); fileSaveAction->addTo( File ); closeProfileAction->addTo( File ); deleteProfileAction->addTo( File ); changeProfileAction->addTo( File ); File->insertSeparator(); fileQuitAction->addTo( File ); MenuBarEditor->insertItem( QString(""), File, 1 ); Edit = new QPopupMenu( this ); editUndoAction->addTo( Edit ); editRedoAction->addTo( Edit ); Edit->insertSeparator(); editNewField->addTo( Edit ); editEditField->addTo( Edit ); editDeleteField->addTo( Edit ); editDeleteAll->addTo(Edit); MenuBarEditor->insertItem( QString(""), Edit, 2 ); Help = new QPopupMenu( this ); helpAboutAction->addTo( Help ); MenuBarEditor->insertItem( QString(""), Help, 3 ); rmbMenu = new QPopupMenu( this ); editUndoAction->addTo( rmbMenu ); editRedoAction->addTo( rmbMenu ); rmbMenu->insertSeparator(); editNewField->addTo( rmbMenu ); editEditField->addTo( rmbMenu ); editDeleteField->addTo( rmbMenu ); languageChange(); resize( QSize(700, 400).expandedTo(minimumSizeHint()) ); clearWState( WState_Polished ); connect(createProfileAction, SIGNAL( activated() ), this, SLOT( createProfile() ) ); connect(openProfileAction, SIGNAL( activated() ), this, SLOT( openProfile() ) ); connect(tb_openProfileAction, SIGNAL( activated() ), this, SLOT( openProfile() ) ); connect(closeProfileAction, SIGNAL( activated() ), this, SLOT( closeProfile() ) ); connect(tb_closeProfileAction, SIGNAL( activated() ), this, SLOT( closeProfile() ) ); connect(deleteProfileAction, SIGNAL( activated() ), this, SLOT( deleteProfile() ) ); connect(changeProfileAction, SIGNAL( activated() ), this, SLOT( changeProfile() ) ); connect(fileSaveAction, SIGNAL( activated() ), this, SLOT( save() ) ); connect(tb_fileSaveAction, SIGNAL( activated() ), this, SLOT( save() ) ); connect(fileQuitAction, SIGNAL( activated() ), this, SLOT( close() ) ); connect(editUndoAction, SIGNAL( activated() ), this, SLOT( undo() ) ); connect(tb_editUndoAction, SIGNAL( activated() ), this, SLOT( undo() ) ); connect(editRedoAction, SIGNAL( activated() ), this, SLOT( redo() ) ); connect(tb_editRedoAction, SIGNAL( activated() ), this, SLOT( redo() ) ); connect(editNewField, SIGNAL( activated() ), this, SLOT( newField() ) ); connect(tb_editNewField, SIGNAL( activated() ), this, SLOT( newField() ) ); connect(editEditField, SIGNAL(activated() ), this, SLOT( editField() ) ); connect(tb_editEditField, SIGNAL(activated() ), this, SLOT( editField() ) ); connect(editDeleteField, SIGNAL( activated() ), this, SLOT( deleteField() ) ); connect(tb_editDeleteField, SIGNAL( activated() ), this, SLOT( deleteField() ) ); connect(editDeleteAll, SIGNAL( activated() ), this, SLOT( deleteAll() ) ); connect(helpAboutAction, SIGNAL( activated() ), this, SLOT( about() ) ); connect(listView, SIGNAL( doubleClicked(QListViewItem *) ), this, SLOT( edit(QListViewItem *) ) ); connect(listView, SIGNAL( contextMenuRequested( QListViewItem *, const QPoint&, int) ), this, SLOT( slotRMB( QListViewItem*, const QPoint &, int ) ) ); modified = false; Caption(); if(!ifProfileExists()) createProfile(); else setEnabledActions(1); }
void Window::createActions() { quitAction = new QAction(tr("&Quit"), this); quitAction->setIcon(QIcon(":/img/exit.png")); startAction = new QAction(tr("Sta&rt Logging"), this); startAction->setIcon(QIcon(":/img/start.png")); stopAction = new QAction(tr("&Stop Logging"), this); stopAction->setIcon(QIcon(":/img/stop.png")); profileAction = new QAction(tr("&Profile"), this); profileAction->setIcon(QIcon(":/img/profile.png")); histogramAction = new QAction(tr("Norm by &histogram"), this); histogramAction->setIcon(QIcon(":/img/histogram.png")); chiAction = new QAction(tr("&Chi-square probability count"), this); chiAction->setIcon(QIcon(":/img/chisquare.png")); medianAction = new QAction(tr("&Median filtering"), this); medianAction->setIcon(QIcon(":/img/filter16.png")); clearCleanAction = new QAction(tr("Delete clean logs"), this); clearCleanAction->setIcon(QIcon(":/img/filter_delete.png")); stopAction->setEnabled(false); //medianAction->setEnabled(false); quitAction->setShortcut(Qt::ALT + Qt::Key_Q); startAction->setShortcut(Qt::ALT + Qt::Key_R); stopAction->setShortcut(Qt::ALT + Qt::Key_S); profileAction->setShortcut(Qt::ALT + Qt::Key_P); histogramAction->setShortcut(Qt::ALT + Qt::Key_H); chiAction->setShortcut(Qt::ALT + Qt::Key_C); medianAction->setShortcut(Qt::ALT + Qt::Key_M); QObject::connect(profileAction, SIGNAL(triggered()), this, SLOT(changeProfile())); QObject::connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit())); QObject::connect(startAction, SIGNAL(triggered()), controller, SLOT(startLogging())); QObject::connect(stopAction, SIGNAL(triggered()), controller, SLOT(stopLogging())); QObject::connect(startAction, SIGNAL(triggered()), this, SLOT(startedLogging())); QObject::connect(stopAction, SIGNAL(triggered()), this, SLOT(stoppedLogging())); QObject::connect(controller, SIGNAL(showInfo(Log)), this, SLOT(appendLog(Log))); QObject::connect(controller, SIGNAL(showInfo(const QString&)), this, SLOT(appendLog(const QString&))); QObject::connect(histogramAction, SIGNAL(triggered()), this, SLOT(startHist())); QObject::connect(chiAction, SIGNAL(triggered()), this, SLOT(startChi())); QObject::connect(medianAction, SIGNAL(triggered()), this, SLOT(startMedian())); QObject::connect(clearCleanAction, SIGNAL(triggered()), this, SLOT(clearClean())); }
void ConfigDialog::on_profilesComboBox_currentIndexChanged(const QString &profile) { changeProfile(m_strIniPath, profile); _init(); }