PreFlightGliderPage::PreFlightGliderPage(QWidget *parent) : QWidget(parent), m_lastGlider(0) { setObjectName("PreFlightGliderPage"); setWindowFlags( Qt::Tool ); setWindowModality( Qt::WindowModal ); setAttribute(Qt::WA_DeleteOnClose); setWindowTitle( tr("PreFlight - Glider") ); if( parent ) { resize( parent->size() ); } QHBoxLayout *contentLayout = new QHBoxLayout; setLayout(contentLayout); QGridLayout* topLayout = new QGridLayout; topLayout->setMargin(5); contentLayout->addLayout(topLayout); int row = 0; QLabel* lblPilot = new QLabel(tr("Pilot:"), this); topLayout->addWidget(lblPilot, row, 0); Qt::InputMethodHints imh; m_edtPilot = new QLineEdit(this); imh = (m_edtPilot->inputMethodHints() | Qt::ImhNoPredictiveText); m_edtPilot->setInputMethodHints(imh); m_edtPilot->setText( GeneralConfig::instance()->getSurname() ); connect( m_edtPilot, SIGNAL(returnPressed()), MainWindow::mainWindow(), SLOT(slotCloseSip()) ); topLayout->addWidget(m_edtPilot, row, 1); QLabel* lblLoad = new QLabel(tr("Load corr:"), this); topLayout->addWidget(lblLoad, row, 2); m_edtLoad = new NumberEditor; m_edtLoad->setDecimalVisible( false ); m_edtLoad->setPmVisible( true ); m_edtLoad->setMaxLength(4); m_edtLoad->setSuffix(" kg"); m_edtLoad->setRange( -999, 999 ); m_edtLoad->setValue( 0 ); topLayout->addWidget(m_edtLoad, row, 3); row++; m_edtCoPilotLabel = new QLabel(tr("Copilot:"), this); topLayout->addWidget(m_edtCoPilotLabel, row, 0); m_edtCoPilot = new QLineEdit(this); m_edtCoPilot->setInputMethodHints(imh); connect( m_edtCoPilot, SIGNAL(returnPressed()), MainWindow::mainWindow(), SLOT(slotCloseSip()) ); topLayout->addWidget(m_edtCoPilot, row, 1); QLabel* lblWater = new QLabel(tr("Water ballast:"), this); topLayout->addWidget(lblWater, row, 2); m_edtWater = new NumberEditor; m_edtWater->setDecimalVisible( false ); m_edtWater->setPmVisible( false ); m_edtWater->setMaxLength(4); m_edtWater->setSuffix(" l"); m_edtWater->setRange( 0, 9999 ); m_edtWater->setValue( 0 ); topLayout->addWidget(m_edtWater, row, 3); row++; QHBoxLayout* hbox = new QHBoxLayout; hbox->addWidget( new QLabel(tr("Ref. weight:"), this) ); m_refWeight = new QLabel; m_refWeight->setFocusPolicy(Qt::NoFocus); hbox->addWidget( m_refWeight, 10 ); topLayout->addLayout( hbox, row, 0, 1, 2 ); hbox = new QHBoxLayout; hbox->addWidget( new QLabel(tr("Wing load:"), this) ); m_wingLoad = new QLabel; m_wingLoad->setFocusPolicy(Qt::NoFocus); hbox->addWidget( m_wingLoad, 10 ); topLayout->addLayout( hbox, row, 2, 1, 2 ); row++; topLayout->setRowMinimumHeight( row, 10 ); row++; m_gliderList = new GliderListWidget( this, true ); #ifndef ANDROID m_gliderList->setToolTip(tr("Select a glider to be used")); #endif #ifdef ANDROID QScrollBar* lvsb = m_gliderList->verticalScrollBar(); lvsb->setStyleSheet( Layout::getCbSbStyle() ); #endif #ifdef QSCROLLER QScroller::grabGesture(m_gliderList->viewport(), QScroller::LeftMouseButtonGesture); #endif #ifdef QTSCROLLER QtScroller::grabGesture(m_gliderList->viewport(), QtScroller::LeftMouseButtonGesture); #endif topLayout->addWidget(m_gliderList, row, 0, 1, 4); row++; //--------------------------------------------------------------------- QPushButton* deselect = new QPushButton( tr("Deselect"), this ); #ifndef ANDROID deselect->setToolTip( tr("Clear glider selection") ); #endif topLayout->addWidget( deselect, row, 3 ); //--------------------------------------------------------------------- m_gliderList->fillList(); m_gliderList->clearSelection(); m_gliderList->selectItemFromList(); connect(deselect, SIGNAL(clicked()), this, SLOT(slotGliderDeselected()) ); connect(m_gliderList, SIGNAL(itemSelectionChanged()), this, SLOT(slotGliderChanged())); connect(m_edtLoad, SIGNAL(numberEdited(const QString&)), this, SLOT(slotLoadEdited(const QString&))); connect(m_edtWater, SIGNAL(numberEdited(const QString&)), this, SLOT(slotWaterEdited(const QString&))); QPushButton *help = new QPushButton(this); help->setIcon(QIcon(GeneralConfig::instance()->loadPixmap("help32.png"))); help->setIconSize(QSize(Layout::getButtonSize(12), Layout::getButtonSize(12))); help->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::QSizePolicy::Preferred); QPushButton *cancel = new QPushButton(this); cancel->setIcon(QIcon(GeneralConfig::instance()->loadPixmap("cancel.png"))); cancel->setIconSize(QSize(Layout::getButtonSize(12), Layout::getButtonSize(12))); cancel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::QSizePolicy::Preferred); QPushButton *ok = new QPushButton(this); ok->setIcon(QIcon(GeneralConfig::instance()->loadPixmap("ok.png"))); ok->setIconSize(QSize(Layout::getButtonSize(12), Layout::getButtonSize(12))); ok->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::QSizePolicy::Preferred); QLabel *titlePix = new QLabel(this); titlePix->setAlignment( Qt::AlignCenter ); titlePix->setPixmap( _globalMapConfig->createGlider(315, 1.6) ); connect(help, SIGNAL(pressed()), this, SLOT(slotHelp())); connect(ok, SIGNAL(pressed()), this, SLOT(slotAccept())); connect(cancel, SIGNAL(pressed()), this, SLOT(slotReject())); QVBoxLayout *buttonBox = new QVBoxLayout; buttonBox->setSpacing(0); buttonBox->addWidget(help, 1); buttonBox->addStretch(2); buttonBox->addWidget(cancel, 1); buttonBox->addSpacing(30); buttonBox->addWidget(ok, 1); buttonBox->addStretch(2); buttonBox->addWidget(titlePix); contentLayout->addLayout(buttonBox); }
/** * Starts authentication by opening the browser */ void Authorize::doOAuth() { QUrl url(QString::fromLatin1("https://accounts.google.com/o/oauth2/auth")); QUrlQuery urlQuery; urlQuery.addQueryItem(QString::fromLatin1("scope"), m_scope); urlQuery.addQueryItem(QString::fromLatin1("redirect_uri"), m_redirect_uri); urlQuery.addQueryItem(QString::fromLatin1("response_type"), m_response_type); urlQuery.addQueryItem(QString::fromLatin1("client_id"), m_client_id); urlQuery.addQueryItem(QString::fromLatin1("access_type"), QString::fromLatin1("offline")); url.setQuery(urlQuery); qCDebug(KIPIPLUGINS_LOG) << "OAuth URL: " << url; QDesktopServices::openUrl(url); emit signalBusy(false); m_window = new QDialog(QApplication::activeWindow(),0); m_window->setModal(true); m_window->setWindowTitle(i18n("Google Drive Authorization")); QDialogButtonBox* const buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel); QPushButton* const okButton = buttonBox->button(QDialogButtonBox::Ok); okButton->setDefault(true); m_window->connect(buttonBox, SIGNAL(accepted()), this, SLOT(slotAccept())); m_window->connect(buttonBox, SIGNAL(rejected()), this, SLOT(slotReject())); QLineEdit* const textbox = new QLineEdit(); QPlainTextEdit* const infobox = new QPlainTextEdit(i18n("Please follow the instructions in the browser. " "After logging in and authorizing the application, " "copy the code from the browser, paste it in the " "textbox below, and click OK.")); QVBoxLayout* const layout = new QVBoxLayout; m_window->setLayout(layout); infobox->setReadOnly(true); layout->addWidget(infobox); layout->addWidget(textbox); layout->addWidget(buttonBox); m_window->exec(); if (m_window->result() == QDialog::Accepted && !(textbox->text().isEmpty())) { qCDebug(KIPIPLUGINS_LOG) << "1"; m_code = textbox->text(); } if (textbox->text().isEmpty()) { qCDebug(KIPIPLUGINS_LOG) << "3"; emit signalTextBoxEmpty(); } if (m_code != QString::fromLatin1("0")) { getAccessToken(); } }
void EditorManagerView::slotItemSelected(const QModelIndex &index) { if(_dirty){ qDebug()<<"Is dirty "; if(discardChangesConfirmation()){ slotReject(); } else{ restoreCurrentIndex(_editorWidget->currentIndex()); return; } } QModelIndex sourceIndex = _filterProxyModel->mapToSource(index); _editorWidget->setCurrentIndex(sourceIndex.row()); if(sourceIndex.isValid() == false){ _stackedLayout->setCurrentIndex(NO_DATA_WIDGET); return; } _stackedLayout->setCurrentIndex(EDITOR_WIDGET); if(_newRow){ //Editing a brand new _saveButton->setText(_helper->saveNewButtonText()); _deleteButton->setEnabled(false); _editorWidget->setFocus(); setDirty(true); } else{ //Editing an existing element _saveButton->setText(_helper->saveChangesButtonText()); _deleteButton->setEnabled(true); setDirty(false); } }
SM_CreateFolderDialog::SM_CreateFolderDialog(QWidget *parent) : QDialog(parent), ui(new Ui::CreateFolderDialog) { ui->setupUi(this); ui->nameEdit->setFocus(); connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(slotAccept())); connect(ui->buttonBox, SIGNAL(rejected()), this, SLOT(slotReject())); connect(this, SIGNAL(finished(int)), this, SLOT(slotFinished(int))); }
void PreFlightWidget::keyReleaseEvent( QKeyEvent* event ) { // close the dialog on key press switch(event->key()) { case Qt::Key_Close: case Qt::Key_Escape: slotReject(); break; default: QWidget::keyReleaseEvent( event ); break; } }
/** Ask for authorization and login by opening browser */ void DBTalker::doOAuth() { QUrl url(QString::fromLatin1("https://api.dropbox.com/1/oauth/authorize")); qCDebug(KIPIPLUGINS_LOG) << "in doOAuth()" << m_oauthToken; QUrlQuery q(url); q.addQueryItem(QString::fromLatin1("oauth_token"), m_oauthToken); url.setQuery(q); qCDebug(KIPIPLUGINS_LOG) << "OAuth URL: " << url; QDesktopServices::openUrl(url); emit signalBusy(false); m_dialog = new QDialog(QApplication::activeWindow(), 0); m_dialog->setModal(true); m_dialog->setWindowTitle(i18n("Authorize Dropbox")); QDialogButtonBox* const buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, m_dialog); buttons->button(QDialogButtonBox::Ok)->setDefault(true); m_dialog->connect(buttons, SIGNAL(accepted()), this, SLOT(slotAccept())); m_dialog->connect(buttons, SIGNAL(rejected()), this, SLOT(slotReject())); QPlainTextEdit* const infobox = new QPlainTextEdit(i18n("Please follow the instructions in the browser. " "After logging in and authorizing the application, press OK.")); infobox->setReadOnly(true); QVBoxLayout* const vbx = new QVBoxLayout(m_dialog); vbx->addWidget(infobox); vbx->addWidget(buttons); m_dialog->setLayout(vbx); m_dialog->exec(); if (m_dialog->result() == QDialog::Accepted) { getAccessToken(); } else { return; } }
/* void EditorManagerView::setModel(QAbstractTableModel * model) { _model = model; _navigatorWidget->setModel(_model); _navigatorWidget->setModelColumn(helper->itemLabelColumn()); _editorWidget->setModel(_model); _editorWidget->setCurrentModelIndex(QModelIndex()); } */ void EditorManagerView::slotAddItem() { if(_dirty){ if(discardChangesConfirmation()){ slotReject(); } else{ return; } } int row = _model->rowCount(); if(_model->insertRow(row)){ _newRow = true; _navigatorWidget->setCurrentRow(row); _editorWidget->setFocus(); } else{ qWarning("Failed to insert row. Reason is %s", qPrintable(_model->lastError().text())); //TODO: Show error message } }
SettingsPageTerrainColors::SettingsPageTerrainColors(QWidget *parent) : QWidget(parent), colorsChanged(false), m_autoSip( true ) { setObjectName("SettingsPageTerrainColors"); setWindowFlags( Qt::Tool ); setWindowModality( Qt::WindowModal ); setAttribute(Qt::WA_DeleteOnClose); setWindowTitle( tr("Settings - Terrain Colors") ); if( parent ) { resize( parent->size() ); } // Layout used by scroll area QHBoxLayout *sal = new QHBoxLayout; // new widget used as container for the dialog layout. QWidget* sw = new QWidget; // Scroll area QScrollArea* sa = new QScrollArea; sa->setWidgetResizable( true ); sa->setFrameStyle( QFrame::NoFrame ); sa->setWidget( sw ); #ifdef QSCROLLER QScroller::grabGesture( sa->viewport(), QScroller::LeftMouseButtonGesture ); #endif #ifdef QTSCROLLER QtScroller::grabGesture( sa->viewport(), QtScroller::LeftMouseButtonGesture ); #endif // Add scroll area to its own layout sal->addWidget( sa ); QHBoxLayout *contentLayout = new QHBoxLayout(this); // Pass scroll area layout to the content layout. contentLayout->addLayout( sal ); /** * Altitude levels in meters to be displayed in color combo box. */ const char *altitudes[51] = { "< 0", "0", "10", "25", "50", "75", "100", "150", "200", "250", "300", "350", "400", "450", "500", "600", "700", "800", "900", "1000", "1250", "1500", "1750", "2000", "2250", "2500", "2750", "3000", "3250", "3500", "3750", "4000", "4250", "4500", "4750", "5000", "5250", "5500", "5750", "6000", "6250", "6500", "6750", "7000", "7250", "7500", "7750", "8000", "8250", "8500", "8750" }; // Determine pixmap size to be used for icons in dependency of the used font int size = QFontMetrics(font()).boundingRect("XM").height() - 2; pixmapSize = QSize( size, size ); QPixmap pixmap(pixmapSize); // load stored terrain colors into working list for( int i = 0; i < SIZEOF_TERRAIN_COLORS; i++ ) { QColor color = GeneralConfig::instance()->getTerrainColor(i); terrainColor[i] = color; } // load ground color groundColor = GeneralConfig::instance()->getGroundColor(); // put all widgets in a HBox layout QHBoxLayout *topLayout = new QHBoxLayout(sw); // create elevation color bar as image elevationImage = new ElevationColorImage( &terrainColor[0], this ); topLayout->addWidget( elevationImage ); // all editor widgets will be put into a group box to get a better view QGroupBox *editBox = new QGroupBox( tr("Color Selection"), this ); // put group box in an extra VBox layout to center it vertically QVBoxLayout *editAll = new QVBoxLayout; editAll->addStretch( 10 ); editAll->addWidget( editBox ); editAll->addStretch( 10 ); topLayout->addLayout( editAll ); // put all edit widgets (combo box and buttons) in a separate VBox layout QVBoxLayout *editLayout = new QVBoxLayout; editLayout->setSpacing( editLayout->spacing() * Layout::getIntScaledDensity() ); QLabel *label = new QLabel( tr("Terrain Level") ); editLayout->addWidget( label ); //-------------------------------------------------------------------------- // The users altitude unit (meters/feed) must be considered during // elevation display in the combo box. QString unit; elevationBox = new QComboBox( this ); #ifdef ANDROID QAbstractItemView* listView = elevationBox->view(); QScrollBar* lvsb = listView->verticalScrollBar(); lvsb->setStyleSheet( Layout::getCbSbStyle() ); #endif #ifdef QSCROLLER elevationBox->view()->setVerticalScrollMode( QAbstractItemView::ScrollPerPixel ); QScroller::grabGesture( elevationBox->view()->viewport(), QScroller::LeftMouseButtonGesture ); #endif #ifdef QTSCROLLER elevationBox->view()->setVerticalScrollMode( QAbstractItemView::ScrollPerPixel ); QtScroller::grabGesture( elevationBox->view()->viewport(), QtScroller::LeftMouseButtonGesture ); #endif if( Altitude::getUnit() == Altitude::meters ) { // use unit meter unit = "m"; for( int i = SIZEOF_TERRAIN_COLORS-1; i > 1; i-- ) { pixmap.fill( terrainColor[i] ); elevationBox->addItem( QIcon( pixmap ), QString(altitudes[i]) + unit ); } } else { // use unit feed unit = "ft"; for( int i = SIZEOF_TERRAIN_COLORS-1; i > 1; i-- ) { int altFeed = static_cast<int>(QString(altitudes[i]).toDouble() * 3.28095); pixmap.fill( terrainColor[i] ); elevationBox->addItem( QIcon( pixmap ), QString::number(altFeed) + unit ); } } pixmap.fill( terrainColor[1] ); elevationBox->addItem( QIcon( pixmap ), QString(altitudes[1]) ); pixmap.fill( terrainColor[0] ); elevationBox->addItem( QIcon( pixmap ), QString(altitudes[0]) ); // set index to level 0 elevationBox->setCurrentIndex( SIZEOF_TERRAIN_COLORS-2 ); editLayout->addWidget( elevationBox ); //-------------------------------------------------------------------------- // add push button for elevation color chooser dialog editColorButton = new QPushButton( tr("Terrain Color") ); // on click the color chooser dialog will be opened connect( editColorButton, SIGNAL(clicked()), this, SLOT(slot_editColor()) ); editLayout->addWidget( editColorButton ); //-------------------------------------------------------------------------- // add push button for ground color chooser dialog groundColorButton = new QPushButton( tr("Ground Color") ); pixmap.fill( groundColor ); groundColorButton->setIcon( QIcon(pixmap) ); // on click the color chooser dialog will be opened connect( groundColorButton, SIGNAL(clicked()), this, SLOT(slot_editGroundColor()) ); editLayout->addSpacing( 10 * Layout::getIntScaledDensity() ); editLayout->addWidget( groundColorButton ); editLayout->addSpacing( 20 * Layout::getIntScaledDensity() ); //-------------------------------------------------------------------------- // add button for assigning of default colors defaultColorButton = new QPushButton( tr("Color Defaults") ); // on click all colors are reset to the defaults connect( defaultColorButton, SIGNAL(clicked()), this, SLOT(slot_setColorDefaults()) ); editLayout->addWidget( defaultColorButton ); // add stretch items to posit editor widgets in the center of the VBox layout editLayout->insertStretch(0, 10 ); editLayout->addStretch( 10 ); editBox->setLayout(editLayout); //-------------------------------------------------------------------------- // add spin box for moving elevation zero line QGroupBox *setOffsetBox = new QGroupBox( tr("Elevation Offset"), this ); // put group box in an extra VBox layout to center it vertically QVBoxLayout *offsetLayout = new QVBoxLayout; offsetLayout->addStretch( 10 ); offsetLayout->addWidget( setOffsetBox ); offsetLayout->addStretch( 10 ); QVBoxLayout *spinboxLayout = new QVBoxLayout; elevationOffset = new QSpinBox; elevationOffset->setSingleStep(1); elevationOffset->setRange(-50, 50); connect( elevationOffset, SIGNAL(editingFinished()), MainWindow::mainWindow(), SLOT(slotCloseSip()) ); VarSpinBox* hspin = new VarSpinBox( elevationOffset ); spinboxLayout->addWidget(hspin); setOffsetBox->setLayout(spinboxLayout); topLayout->addLayout( offsetLayout ); topLayout->insertSpacing(1, 60 ); topLayout->addStretch( 10 ); QPushButton *cancel = new QPushButton(this); cancel->setIcon(QIcon(GeneralConfig::instance()->loadPixmap("cancel.png"))); cancel->setIconSize(QSize(Layout::getButtonSize(12), Layout::getButtonSize(12))); cancel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::QSizePolicy::Preferred); QPushButton *ok = new QPushButton(this); ok->setIcon(QIcon(GeneralConfig::instance()->loadPixmap("ok.png"))); ok->setIconSize(QSize(Layout::getButtonSize(12), Layout::getButtonSize(12))); ok->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::QSizePolicy::Preferred); QLabel *titlePix = new QLabel(this); titlePix->setAlignment( Qt::AlignCenter ); titlePix->setPixmap(GeneralConfig::instance()->loadPixmap("setup.png")); connect(ok, SIGNAL(pressed()), this, SLOT(slotAccept())); connect(cancel, SIGNAL(pressed()), this, SLOT(slotReject())); QVBoxLayout *buttonBox = new QVBoxLayout; buttonBox->setSpacing(0); buttonBox->addStretch(2); buttonBox->addWidget(cancel, 1); buttonBox->addSpacing(30); buttonBox->addWidget(ok, 1); buttonBox->addStretch(2); buttonBox->addWidget(titlePix); contentLayout->addLayout(buttonBox); load(); }
AirfieldSelectionList::AirfieldSelectionList( QWidget *parent ) : QWidget(parent) { setObjectName( "AirfieldSelectionList" ); setWindowTitle(tr("Airfield Selection")); setWindowFlags( Qt::Tool ); setWindowModality( Qt::WindowModal ); setAttribute(Qt::WA_DeleteOnClose); if( parent ) { resize( parent->size() ); } QHBoxLayout* mainLayout = new QHBoxLayout( this ); m_airfieldTreeWidget = new QTreeWidget( this ); mainLayout->addWidget( m_airfieldTreeWidget ); m_airfieldTreeWidget->setRootIsDecorated( false ); m_airfieldTreeWidget->setItemsExpandable( false ); m_airfieldTreeWidget->setSortingEnabled( true ); m_airfieldTreeWidget->setSelectionMode( QAbstractItemView::SingleSelection ); m_airfieldTreeWidget->setSelectionBehavior( QAbstractItemView::SelectRows ); m_airfieldTreeWidget->setAlternatingRowColors(true); m_airfieldTreeWidget->setColumnCount( 1 ); m_airfieldTreeWidget->setFocusPolicy( Qt::StrongFocus ); m_airfieldTreeWidget->setUniformRowHeights(true); m_airfieldTreeWidget->setHeaderLabel( tr( "Airfields" ) ); connect( m_airfieldTreeWidget, SIGNAL(itemSelectionChanged()), SLOT(slotItemSelectionChanged()) ); // Set additional space per row RowDelegate* rowDelegate = new RowDelegate( m_airfieldTreeWidget, 10 ); m_airfieldTreeWidget->setItemDelegate( rowDelegate ); QTreeWidgetItem* headerItem = m_airfieldTreeWidget->headerItem(); headerItem->setTextAlignment( 0, Qt::AlignCenter ); m_airfieldTreeWidget->setVerticalScrollMode( QAbstractItemView::ScrollPerPixel ); m_airfieldTreeWidget->setHorizontalScrollMode( QAbstractItemView::ScrollPerPixel ); #ifdef ANDROID QScrollBar* lvsb = m_airfieldTreeWidget->verticalScrollBar(); lvsb->setStyleSheet( Layout::getCbSbStyle() ); #endif #ifdef QSCROLLER QScroller::grabGesture(m_airfieldTreeWidget->viewport(), QScroller::LeftMouseButtonGesture); #endif #ifdef QTSCROLLER QtScroller::grabGesture(m_airfieldTreeWidget->viewport(), QtScroller::LeftMouseButtonGesture); #endif QVBoxLayout* groupLayout = new QVBoxLayout; m_groupBox = new QGroupBox( tr("Search Airfield")); m_groupBox->setLayout( groupLayout ); mainLayout->addWidget( m_groupBox ); m_searchInput = new QLineEdit; groupLayout->addWidget( m_searchInput ); Qt::InputMethodHints imh = (m_searchInput->inputMethodHints() | Qt::ImhNoPredictiveText); m_searchInput->setInputMethodHints(imh); #ifndef ANDROID m_searchInput->setToolTip( tr("Enter a search string, to navigate to a certain list entry.") ); #endif connect( m_searchInput, SIGNAL(returnPressed()), MainWindow::mainWindow(), SLOT(slotCloseSip()) ); connect( m_searchInput, SIGNAL(textEdited(const QString&)), SLOT(slotTextEdited(const QString&)) ); QHBoxLayout* clearLayout = new QHBoxLayout; clearLayout->setSpacing(0); clearLayout->addStretch(5); QPushButton* clearButton = new QPushButton(tr("Clear")); #ifndef ANDROID clearButton->setToolTip( tr("Click Clear to remove the search string.") ); #endif clearLayout->addWidget( clearButton ); groupLayout->addLayout( clearLayout ); groupLayout->addStretch(5); connect( clearButton, SIGNAL(clicked()), SLOT(slotClearSearchEntry())); QPushButton *cancel = new QPushButton(this); cancel->setIcon(QIcon(GeneralConfig::instance()->loadPixmap("cancel.png"))); cancel->setIconSize(QSize(Layout::getButtonSize(12), Layout::getButtonSize(12))); cancel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::QSizePolicy::Preferred); connect( cancel, SIGNAL(clicked()), SLOT(slotReject()) ); m_ok = new QPushButton(this); m_ok->setIcon(QIcon(GeneralConfig::instance()->loadPixmap("ok.png"))); m_ok->setIconSize(QSize(Layout::getButtonSize(12), Layout::getButtonSize(12))); m_ok->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::QSizePolicy::Preferred); m_ok->setEnabled( false ); connect( m_ok, SIGNAL(clicked()), SLOT(slotAccept()) ); QVBoxLayout *buttonBox = new QVBoxLayout; buttonBox->setSpacing(0); buttonBox->addStretch(2); buttonBox->addWidget(cancel, 1); buttonBox->addSpacing(30); buttonBox->addWidget(m_ok, 1); buttonBox->addStretch(2); mainLayout->addLayout(buttonBox); }
PreFlightMiscPage::PreFlightMiscPage(QWidget *parent) : QWidget(parent) { setObjectName("PreFlightMiscPage"); setWindowFlags( Qt::Tool ); setWindowModality( Qt::WindowModal ); setAttribute(Qt::WA_DeleteOnClose); setWindowTitle( tr("PreFlight - Common") ); if( parent ) { resize( parent->size() ); } // Layout used by scroll area QHBoxLayout *sal = new QHBoxLayout; // new widget used as container for the dialog layout. QWidget* sw = new QWidget; // Scroll area QScrollArea* sa = new QScrollArea; sa->setWidgetResizable( true ); sa->setFrameStyle( QFrame::NoFrame ); sa->setWidget( sw ); #ifdef QSCROLLER QScroller::grabGesture( sa->viewport(), QScroller::LeftMouseButtonGesture ); #endif #ifdef QTSCROLLER QtScroller::grabGesture( sa->viewport(), QtScroller::LeftMouseButtonGesture ); #endif // Add scroll area to its own layout sal->addWidget( sa ); QHBoxLayout *contentLayout = new QHBoxLayout(this); // Pass scroll area layout to the content layout. contentLayout->addLayout( sal, 10 ); // Top layout's parent is the scroll widget QGridLayout *topLayout = new QGridLayout(sw); int row = 0; QLabel *lbl = new QLabel(tr("Minimal arrival altitude:")); topLayout->addWidget(lbl, row, 0); // get current set altitude unit. This unit must be considered during // storage. The internal storage is always in meters. m_altUnit = Altitude::getUnit(); // Input accept only feet and meters all other make no sense. Therefore all // other (FL) is treated as feet. m_edtMinimalArrival = new NumberEditor; m_edtMinimalArrival->setDecimalVisible( false ); m_edtMinimalArrival->setPmVisible( false ); m_edtMinimalArrival->setRange( 0, 9999); m_edtMinimalArrival->setMaxLength(4); m_edtMinimalArrival->setSuffix(" " + Altitude::getUnitText()); QRegExpValidator* eValidator = new QRegExpValidator( QRegExp( "([0-9]{1,4})" ), this ); m_edtMinimalArrival->setValidator( eValidator ); int maw = QFontMetrics(font()).width("9999 ft") + 10; m_edtMinimalArrival->setMinimumWidth( maw ); topLayout->addWidget(m_edtMinimalArrival, row, 1); topLayout->setColumnStretch(2, 2); row++; lbl = new QLabel(tr("Arrival altitude display:")); topLayout->addWidget(lbl, row, 0); m_edtArrivalAltitude = new QComboBox; m_edtArrivalAltitude->addItem( tr("Landing Target"), GeneralConfig::landingTarget ); m_edtArrivalAltitude->addItem( tr("Next Target"), GeneralConfig::nextTarget ); topLayout->addWidget(m_edtArrivalAltitude, row, 1); row++; lbl = new QLabel(tr("QNH:")); topLayout->addWidget(lbl, row, 0); m_edtQNH = new NumberEditor; m_edtQNH->setDecimalVisible( false ); m_edtQNH->setPmVisible( false ); m_edtQNH->setRange( 0, 9999); m_edtQNH->setMaxLength(4); m_edtQNH->setSuffix(" hPa"); eValidator = new QRegExpValidator( QRegExp( "([0-9]{1,4})" ), this ); m_edtQNH->setValidator( eValidator ); int mqw = QFontMetrics(font()).width("9999 hPa") + 10; m_edtQNH->setMinimumWidth( mqw ); topLayout->addWidget(m_edtQNH, row, 1); row++; lbl = new QLabel(tr("LD average time") + ":"); topLayout->addWidget(lbl, row, 0); m_edtLDTime = new NumberEditor; m_edtLDTime->setDecimalVisible( false ); m_edtLDTime->setPmVisible( false ); m_edtLDTime->setRange( 5, 600 ); m_edtLDTime->setMaxLength(3); m_edtLDTime->setSuffix(" s"); m_edtLDTime->setTitle( tr("LD average time") ); m_edtLDTime->setTip( "5 ... 600 s" ); eValidator = new QRegExpValidator( QRegExp( "([0-9]{1,3})" ), this ); m_edtLDTime->setValidator( eValidator ); topLayout->addWidget(m_edtLDTime, row, 1); row++; topLayout->setRowMinimumHeight(row, 10); row++; m_chkLogAutoStart = new QCheckBox(tr("Autostart IGC logger")); topLayout->addWidget(m_chkLogAutoStart, row, 0 ); // get current used horizontal speed unit. This unit must be considered // during storage. m_speedUnit = Speed::getHorizontalUnit(); m_logAutoStartSpeed = new DoubleNumberEditor( this ); m_logAutoStartSpeed->setDecimalVisible( true ); m_logAutoStartSpeed->setPmVisible( false ); m_logAutoStartSpeed->setMaxLength(4); m_logAutoStartSpeed->setRange( 1.0, 99.9); m_logAutoStartSpeed->setPrefix( "> " ); m_logAutoStartSpeed->setSuffix( QString(" ") + Speed::getHorizontalUnitText() ); m_logAutoStartSpeed->setDecimals( 1 ); int mlw = QFontMetrics(font()).width("99.9" + Speed::getHorizontalUnitText()) + 10; m_logAutoStartSpeed->setMinimumWidth( mlw ); topLayout->addWidget( m_logAutoStartSpeed, row, 1 ); row++; lbl = new QLabel(tr("B-Record Interval:")); topLayout->addWidget(lbl, row, 0); m_bRecordInterval = new NumberEditor; m_bRecordInterval->setDecimalVisible( false ); m_bRecordInterval->setPmVisible( false ); m_bRecordInterval->setRange( 1, 60); m_bRecordInterval->setTip("1...60 s"); m_bRecordInterval->setMaxLength(2); m_bRecordInterval->setSuffix(" s"); eValidator = new QRegExpValidator( QRegExp( "([0-9]{1,2})" ), this ); m_bRecordInterval->setValidator( eValidator ); int mbrw = QFontMetrics(font()).width("99 s") + 10; m_bRecordInterval->setMinimumWidth( mbrw ); topLayout->addWidget(m_bRecordInterval, row, 1); row++; lbl = new QLabel(tr("K-Record Interval:")); topLayout->addWidget(lbl, row, 0); m_kRecordInterval = new NumberEditor; m_kRecordInterval->setDecimalVisible( false ); m_kRecordInterval->setPmVisible( false ); m_kRecordInterval->setRange( 0, 300); m_kRecordInterval->setTip("0...300 s"); m_kRecordInterval->setMaxLength(3); m_kRecordInterval->setSuffix(" s"); m_kRecordInterval->setSpecialValueText(tr("Off")); eValidator = new QRegExpValidator( QRegExp( "([0-9]{1,2})" ), this ); m_kRecordInterval->setValidator( eValidator ); int mkrw = QFontMetrics(font()).width("999 s") + 10; m_kRecordInterval->setMinimumWidth( mkrw ); topLayout->addWidget(m_kRecordInterval, row, 1); row++; topLayout->setRowMinimumHeight(row, 10); row++; topLayout->setRowStretch(row, 10); QPushButton *help = new QPushButton(this); help->setIcon(QIcon(GeneralConfig::instance()->loadPixmap("help32.png"))); help->setIconSize(QSize(Layout::getButtonSize(12), Layout::getButtonSize(12))); help->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::QSizePolicy::Preferred); QPushButton *cancel = new QPushButton(this); cancel->setIcon(QIcon(GeneralConfig::instance()->loadPixmap("cancel.png"))); cancel->setIconSize(QSize(Layout::getButtonSize(12), Layout::getButtonSize(12))); cancel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::QSizePolicy::Preferred); QPushButton *ok = new QPushButton(this); ok->setIcon(QIcon(GeneralConfig::instance()->loadPixmap("ok.png"))); ok->setIconSize(QSize(Layout::getButtonSize(12), Layout::getButtonSize(12))); ok->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::QSizePolicy::Preferred); QLabel *titlePix = new QLabel(this); titlePix->setAlignment( Qt::AlignCenter ); titlePix->setPixmap( _globalMapConfig->createGlider(315, 1.6) ); connect(help, SIGNAL(pressed()), this, SLOT(slotHelp())); connect(ok, SIGNAL(pressed()), this, SLOT(slotAccept())); connect(cancel, SIGNAL(pressed()), this, SLOT(slotReject())); QVBoxLayout *buttonBox = new QVBoxLayout; buttonBox->setSpacing(0); buttonBox->addWidget(help, 1); buttonBox->addStretch(2); buttonBox->addWidget(cancel, 1); buttonBox->addSpacing(30); buttonBox->addWidget(ok, 1); buttonBox->addStretch(2); buttonBox->addWidget(titlePix); contentLayout->addLayout(buttonBox); load(); }
PreFlightWidget::PreFlightWidget( QWidget* parent ) : QWidget(parent) { setObjectName("PreFlightWidget"); setWindowTitle(tr("Flight Settings")); setWindowFlags( Qt::Tool ); setWindowModality( Qt::WindowModal ); setAttribute(Qt::WA_DeleteOnClose); if( parent ) { resize( parent->size() ); } QHBoxLayout *contentLayout = new QHBoxLayout; setLayout(contentLayout); m_setupTree = new QTreeWidget( this ); m_setupTree->setRootIsDecorated( false ); m_setupTree->setItemsExpandable( false ); m_setupTree->setSortingEnabled( true ); m_setupTree->setSelectionMode( QAbstractItemView::SingleSelection ); m_setupTree->setSelectionBehavior( QAbstractItemView::SelectRows ); m_setupTree->setAlternatingRowColors(true); m_setupTree->setColumnCount( 1 ); m_setupTree->setFocusPolicy( Qt::StrongFocus ); m_setupTree->setUniformRowHeights(true); m_setupTree->setHeaderLabel( tr( FLYING ) ); // Set additional space per row RowDelegate* rowDelegate = new RowDelegate( m_setupTree, 10 ); m_setupTree->setItemDelegate( rowDelegate ); QTreeWidgetItem* headerItem = m_setupTree->headerItem(); headerItem->setTextAlignment( 0, Qt::AlignCenter ); m_setupTree->setVerticalScrollMode( QAbstractItemView::ScrollPerPixel ); m_setupTree->setHorizontalScrollMode( QAbstractItemView::ScrollPerPixel ); #ifdef ANDROID QScrollBar* lvsb = m_setupTree->verticalScrollBar(); lvsb->setStyleSheet( Layout::getCbSbStyle() ); #endif #ifdef QSCROLLER QScroller::grabGesture(m_setupTree->viewport(), QScroller::LeftMouseButtonGesture); #endif #ifdef QTSCROLLER QtScroller::grabGesture(m_setupTree->viewport(), QtScroller::LeftMouseButtonGesture); #endif connect( m_setupTree, SIGNAL(itemClicked( QTreeWidgetItem*, int )), this, SLOT( slotPageClicked( QTreeWidgetItem*, int )) ); contentLayout->addWidget( m_setupTree, 5 ); QTreeWidgetItem* item = new QTreeWidgetItem; item->setText( 0, tr(GLIDER) ); item->setData( 0, Qt::UserRole, GLIDER ); m_setupTree->addTopLevelItem( item ); item = new QTreeWidgetItem; item->setText( 0, tr(TASKS) ); item->setData( 0, Qt::UserRole, TASKS ); m_setupTree->addTopLevelItem( item ); item = new QTreeWidgetItem; item->setText( 0, tr(WAYPOINTS) ); item->setData( 0, Qt::UserRole, WAYPOINTS ); m_setupTree->addTopLevelItem( item ); item = new QTreeWidgetItem; item->setText( 0, tr(CHECKLIST) ); item->setData( 0, Qt::UserRole, CHECKLIST ); m_setupTree->addTopLevelItem( item ); item = new QTreeWidgetItem; item->setText( 0, tr(COMMON) ); item->setData( 0, Qt::UserRole, COMMON ); m_setupTree->addTopLevelItem( item ); item = new QTreeWidgetItem; item->setText( 0, tr(LOGBOOKS) ); item->setData( 0, Qt::UserRole, LOGBOOKS ); m_setupTree->addTopLevelItem( item ); #ifdef FLARM item = new QTreeWidgetItem; item->setText( 0, tr(FLARMIGC) ); item->setData( 0, Qt::UserRole, FLARMIGC ); if( calculator->moving() == false ) { m_setupTree->addTopLevelItem( item ); } #endif #ifdef ANDROID item = new QTreeWidgetItem; item->setText( 0, tr(RETRIEVE) ); item->setData( 0, Qt::UserRole, RETRIEVE ); m_setupTree->addTopLevelItem( item ); #endif #ifdef INTERNET item = new QTreeWidgetItem; item->setText( 0, tr(WEATHER) ); item->setData( 0, Qt::UserRole, WEATHER ); m_setupTree->addTopLevelItem( item ); item = new QTreeWidgetItem; item->setText( 0, tr(LIVETRACK) ); item->setData( 0, Qt::UserRole, LIVETRACK ); m_setupTree->addTopLevelItem( item ); #endif item = new QTreeWidgetItem; item->setText( 0, tr(WIND) ); item->setData( 0, Qt::UserRole, WIND ); m_setupTree->addTopLevelItem( item ); m_setupTree->sortByColumn ( 0, Qt::AscendingOrder ); contentLayout->addSpacing( 25 ); m_menuCb = new QCheckBox( tr("close menu") ); m_menuCb->setChecked( GeneralConfig::instance()->getClosePreFlightMenu() ); contentLayout->addWidget( m_menuCb, 0, Qt::AlignVCenter|Qt::AlignBottom ); QPushButton *help = new QPushButton(this); help->setIcon(QIcon(GeneralConfig::instance()->loadPixmap("help32.png"))); help->setIconSize(QSize(Layout::getButtonSize(12), Layout::getButtonSize(12))); help->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::QSizePolicy::Preferred); QPushButton *cancel = new QPushButton(this); cancel->setIcon(QIcon(GeneralConfig::instance()->loadPixmap("cancel.png", true))); cancel->setIconSize(QSize(Layout::getButtonSize(12), Layout::getButtonSize(12))); cancel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::QSizePolicy::Preferred); QLabel *titlePix = new QLabel(this); titlePix->setAlignment( Qt::AlignCenter ); //titlePix->setPixmap(GeneralConfig::instance()->loadPixmap("preflight.png", true)); titlePix->setPixmap( _globalMapConfig->createGlider(315, 1.6) ); connect(help, SIGNAL(pressed()), this, SLOT(slotHelp())); connect(cancel, SIGNAL(pressed()), this, SLOT(slotReject())); QVBoxLayout *buttonBox = new QVBoxLayout; buttonBox->setSpacing(0); buttonBox->addWidget(help, 1); buttonBox->addStretch(2); buttonBox->addWidget(cancel, 1); buttonBox->addStretch(2); buttonBox->addWidget(titlePix, 0, Qt::AlignCenter); contentLayout->addStretch( 10 ); contentLayout->addLayout(buttonBox); m_headerLabels << ( tr ("Flight Menu") ) << ( tr ("Glider") ) << ( tr ("Tasks/Routes") ) #ifdef ANDROID << ( tr ("Retrieve") ) #endif << ( tr ("Waypoints") ) << ( tr ("Logbooks") ) #ifdef INTERNET << ( tr ("LiveTrack") ) << ( tr ("METAR-TAF") ) #endif << ( tr ("Wind") ) << ( tr ("Common") ) << ( tr ("Checklist") ); #ifdef FLARM if( calculator->moving() == false ) { m_headerLabels << ( tr ("FLARM" ) ); } requestFlarmConfig(); #endif m_setupTree->setMinimumWidth( Layout::maxTextWidth( m_headerLabels, font() ) + 100 ); setVisible( true ); }
PreFlightCheckListPage::PreFlightCheckListPage( QWidget* parent ) : QWidget( parent ), CheckListFileName("cumulus-checklist.txt") { setObjectName("PreFlightCheckListPage"); setWindowFlags( Qt::Tool ); setWindowModality( Qt::WindowModal ); setAttribute(Qt::WA_DeleteOnClose); setWindowTitle( tr("PreFlight - Checklist") ); if( parent ) { resize( parent->size() ); } QVBoxLayout *contentLayout = new QVBoxLayout; setLayout(contentLayout); m_fileDisplay = new QLabel; m_fileDisplay->setWordWrap( true ); m_fileDisplay->hide(); contentLayout->addWidget( m_fileDisplay ); QHBoxLayout *hbox = new QHBoxLayout; hbox->setMargin( 0 ); contentLayout->addLayout( hbox ); m_list = new QTableWidget( 0, 2, this ); m_list->setSelectionBehavior( QAbstractItemView::SelectItems ); m_list->setHorizontalScrollBarPolicy( Qt::ScrollBarAsNeeded ); m_list->setAlternatingRowColors( true ); m_list->setVerticalScrollMode( QAbstractItemView::ScrollPerPixel ); m_list->setHorizontalScrollMode( QAbstractItemView::ScrollPerPixel ); // calculates the needed icon size QFontMetrics qfm( font() ); int iconSize = qfm.height(); // Sets the icon size of a list entry m_list->setIconSize( QSize(iconSize, iconSize) ); hbox->addWidget( m_list ); connect( m_list, SIGNAL(cellDoubleClicked(int, int)), SLOT(slotEditCell(int, int)) ); connect( m_list, SIGNAL(cellClicked(int, int)), SLOT(slotCellClicked(int, int)) ); #ifdef ANDROID QScrollBar* lvsb = m_list->verticalScrollBar(); lvsb->setStyleSheet( Layout::getCbSbStyle() ); #endif #ifdef QSCROLLER QScroller::grabGesture(m_list->viewport(), QScroller::LeftMouseButtonGesture); #endif #ifdef QTSCROLLER QtScroller::grabGesture(m_list->viewport(), QtScroller::LeftMouseButtonGesture); #endif QString style = "QTableView QTableCornerButton::section { background: gray }"; m_list->setStyleSheet( style ); QHeaderView *vHeader = m_list->verticalHeader(); style = "QHeaderView::section { width: 2em }"; vHeader->setStyleSheet( style ); // set new row height from configuration int afMargin = GeneralConfig::instance()->getListDisplayAFMargin(); rowDelegate = new RowDelegate( m_list, afMargin ); m_list->setItemDelegate( rowDelegate ); QHeaderView* hHeader = m_list->horizontalHeader(); hHeader->setStretchLastSection( true ); hHeader->hide(); QTableWidgetItem *item = new QTableWidgetItem( tr(" Check Point ") ); m_list->setHorizontalHeaderItem( 0, item ); #ifndef ANDROID int buttonSize = Layout::getButtonSize(); #else int buttonSize = Layout::getButtonSize(16); #endif iconSize = buttonSize - 5; QPushButton* toggleButton = new QPushButton(this); toggleButton->setIcon(QIcon(GeneralConfig::instance()->loadPixmap("file-32.png"))); toggleButton->setIconSize( QSize(iconSize, iconSize) ); toggleButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::QSizePolicy::Preferred); toggleButton->setMinimumSize(buttonSize, buttonSize); toggleButton->setMaximumSize(buttonSize, buttonSize); QPushButton *addButton = new QPushButton; addButton->setIcon( QIcon( GeneralConfig::instance()->loadPixmap( "add.png" ) ) ); addButton->setIconSize(QSize(iconSize, iconSize)); addButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::QSizePolicy::Preferred); addButton->setMinimumSize(buttonSize, buttonSize); addButton->setMaximumSize(buttonSize, buttonSize); m_editButton = new QPushButton(this); m_editButton->setIcon( QIcon(GeneralConfig::instance()->loadPixmap("edit_new.png")) ); m_editButton->setIconSize( QSize(iconSize, iconSize) ); m_editButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::QSizePolicy::Preferred); m_editButton->setMinimumSize(buttonSize, buttonSize); m_editButton->setMaximumSize(buttonSize, buttonSize); m_deleteButton = new QPushButton; m_deleteButton->setIcon( QIcon( GeneralConfig::instance()->loadPixmap( "delete.png" ) ) ); m_deleteButton->setIconSize( QSize(iconSize, iconSize) ); m_deleteButton->setEnabled(false); m_deleteButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::QSizePolicy::Preferred); m_deleteButton->setMinimumSize(buttonSize, buttonSize); m_deleteButton->setMaximumSize(buttonSize, buttonSize); QPushButton *cancel = new QPushButton(this); cancel->setIcon(QIcon(GeneralConfig::instance()->loadPixmap("cancel.png"))); cancel->setIconSize(QSize(iconSize, iconSize)); cancel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::QSizePolicy::Preferred); cancel->setMinimumSize(buttonSize, buttonSize); cancel->setMaximumSize(buttonSize, buttonSize); m_ok = new QPushButton(this); m_ok->setIcon(QIcon(GeneralConfig::instance()->loadPixmap("ok.png"))); m_ok->setIconSize(QSize(iconSize, iconSize)); m_ok->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::QSizePolicy::Preferred); m_ok->setMinimumSize(buttonSize, buttonSize); m_ok->setMaximumSize(buttonSize, buttonSize); QLabel *titlePix = new QLabel(this); titlePix->setAlignment( Qt::AlignCenter ); titlePix->setPixmap( _globalMapConfig->createGlider(315, 1.6) ); connect( addButton, SIGNAL(pressed()), SLOT(slotAddRow()) ); connect( toggleButton, SIGNAL(pressed()), SLOT(slotToogleFilenameDisplay()) ); connect( m_editButton, SIGNAL(pressed()), SLOT(slotEdit()) ); connect( m_deleteButton, SIGNAL(pressed()), SLOT(slotDeleteRows()) ); connect( m_ok, SIGNAL(pressed()), SLOT(slotAccept()) ); connect( cancel, SIGNAL(pressed()), SLOT(slotReject()) ); QVBoxLayout *buttonBox = new QVBoxLayout; hbox->addLayout(buttonBox); buttonBox->setSpacing(0); buttonBox->addWidget(toggleButton); buttonBox->addSpacing(10 * Layout::getIntScaledDensity()); buttonBox->addWidget(addButton); buttonBox->addSpacing(10 * Layout::getIntScaledDensity()); buttonBox->addWidget(m_editButton); buttonBox->addSpacing(10 * Layout::getIntScaledDensity()); buttonBox->addWidget(m_deleteButton); buttonBox->addSpacing(10 * Layout::getIntScaledDensity()); buttonBox->addWidget(cancel); buttonBox->addSpacing(10 * Layout::getIntScaledDensity()); buttonBox->addWidget(m_ok); buttonBox->addStretch(2); buttonBox->addWidget(titlePix); }
SettingsPageTask::SettingsPageTask( QWidget *parent) : QWidget( parent ), m_selectedSwitchScheme(0), m_distUnit(Distance::getUnit()), m_startLineValue(0), m_startRingValue(0), m_startSectorInnerRadiusValue(0), m_startSectorOuterRadiusValue(0), m_startSectorAngleValue(0), m_finishLineValue(0), m_finishRingValue(0), m_finishSectorInnerRadiusValue(0), m_finishSectorOuterRadiusValue(0), m_finishSectorAngleValue(0), m_obsCircleRadiusValue(0), m_obsSectorInnerRadiusValue(0), m_obsSectorOuterRadiusValue(0), m_obsSectorAngleValue(0) { setObjectName("SettingsPageTask"); setWindowFlags( Qt::Tool ); setWindowModality( Qt::WindowModal ); setAttribute(Qt::WA_DeleteOnClose); setWindowTitle( tr("Settings - Task") ); if( parent ) { resize( parent->size() ); } // Layout used by scroll area QHBoxLayout *sal = new QHBoxLayout; // new widget used as container for the dialog layout. QWidget* sw = new QWidget; // Scroll area QScrollArea* sa = new QScrollArea; sa->setWidgetResizable( true ); sa->setFrameStyle( QFrame::NoFrame ); sa->setWidget( sw ); #ifdef ANDROID QScrollBar* lvsb = sa->verticalScrollBar(); lvsb->setStyleSheet( Layout::getCbSbStyle() ); #endif #ifdef QSCROLLER QScroller::grabGesture( sa->viewport(), QScroller::LeftMouseButtonGesture ); #endif #ifdef QTSCROLLER QtScroller::grabGesture( sa->viewport(), QtScroller::LeftMouseButtonGesture ); #endif // Add scroll area to its own layout sal->addWidget( sa ); QHBoxLayout *contentLayout = new QHBoxLayout(this); // Pass scroll area layout to the content layout. contentLayout->addLayout( sal ); GeneralConfig *conf = GeneralConfig::instance(); int row = 0; QGridLayout *topLayout = new QGridLayout(sw); //contentLayout->addLayout(topLayout); topLayout->setMargin(10); topLayout->setSpacing(20); topLayout->setColumnStretch( 3, 5 ); //--------------------------------------------------------------- QGroupBox *ssBox = new QGroupBox( tr("Switch Scheme"), this ); topLayout->addWidget( ssBox, row, 0 ); ntScheme = new QButtonGroup(this); QRadioButton* nearest = new QRadioButton( tr("Minimum"), this ); QRadioButton* touched = new QRadioButton( tr("Touched"), this ); ntScheme->addButton( nearest, 0 ); ntScheme->addButton( touched, 1 ); m_reportSwitch = new QCheckBox( tr("Report"), this ); QVBoxLayout* vbox = new QVBoxLayout; vbox->addWidget( nearest ); vbox->addWidget( touched ); vbox->addWidget( m_reportSwitch ); vbox->addStretch(1); ssBox->setLayout(vbox); nearest->setEnabled(true); touched->setEnabled(true); touched->setChecked(true); // set active button as selected m_selectedSwitchScheme = (int) conf->getActiveTaskSwitchScheme(); if( ntScheme->button(m_selectedSwitchScheme) ) { ntScheme->button(m_selectedSwitchScheme)->setChecked(true); } connect( ntScheme, SIGNAL(buttonClicked(int)), this, SLOT(slot_buttonPressedNT(int)) ); //-------------------------------------------------------------- // as next shape group is added QGroupBox* shapeGroup = new QGroupBox( tr("Shape"), this ); topLayout->addWidget( shapeGroup, row, 1 ); QGridLayout *gBox = new QGridLayout; shapeGroup->setLayout(gBox); m_drawShape = new QCheckBox( tr("Draw"), this ); gBox->addWidget(m_drawShape, 0, 0 ); m_fillShape = new QCheckBox( tr("Fill"), this ); gBox->addWidget(m_fillShape, 1, 0 ); gBox->setColumnStretch( 2, 5 ); connect( m_fillShape, SIGNAL(stateChanged(int)), SLOT(slot_fillShapeStateChanged(int)) ); m_transShape = new NumberEditor( this ); m_transShape->setDecimalVisible( false ); m_transShape->setPmVisible( false ); m_transShape->setMaxLength(3); m_transShape->setSuffix( " %" ); m_transShape->setRange( 0, 100 ); m_transShape->setTip(tr("Opacity ") + "0...100"); m_transShape->setValue( 0 ); QRegExpValidator* eValidator = new QRegExpValidator( QRegExp( "(0|[1-9][0-9]{0,2})" ), this ); m_transShape->setValidator( eValidator ); // Sets a minimum width for the widget int mw1 = QFontMetrics(font()).width("100 %") + 10; m_transShape->setMinimumWidth( mw1 ); gBox->addWidget(m_transShape, 1, 1 ); m_drawShape->setChecked( conf->getTaskDrawShape() ); m_fillShape->setChecked( conf->getTaskFillShape() ); //-------------------------------------------------------------- // as next auto zoom group is added QGroupBox* zoomGroup = new QGroupBox( tr("Zoom"), this ); topLayout->addWidget( zoomGroup, row, 2 ); QVBoxLayout *zBox = new QVBoxLayout; zoomGroup->setLayout(zBox); m_autoZoom = new QCheckBox( tr("Auto"), this ); zBox->addWidget(m_autoZoom); zBox->addStretch(10); m_autoZoom->setChecked( conf->getTaskPointAutoZoom() ); #ifdef ANDROID topLayout->setRowMinimumHeight( ++row, 30 ); #endif row++; //-------------------------------------------------------------- // as next start group is added QGroupBox* startGroup1 = new QGroupBox( tr("Start"), this ); topLayout->addWidget( startGroup1, row, 0 ); QFormLayout *formLayout = new QFormLayout; startGroup1->setLayout(formLayout); m_startLine = createDNE( this ); m_startLine->setTip(tr("Line Length")); formLayout->addRow(tr("Line:"), m_startLine); m_startRing = createDNE( this ); m_startRing->setTip(tr("Circle Radius")); formLayout->addRow(tr("Circle:"), m_startRing); //-------------------------------------------------------------- // as next inner sector group is added QGroupBox* startGroup2 = new QGroupBox( tr("Sectors"), this ); topLayout->addWidget( startGroup2, row, 1 ); formLayout = new QFormLayout; startGroup2->setLayout(formLayout); m_startSectorInnerRadius = createDNE( this ); m_startSectorInnerRadius->setTip(tr("Inner Radius")); formLayout->addRow(tr("Radius 1:"), m_startSectorInnerRadius); m_startSectorOuterRadius = createDNE( this ); m_startSectorOuterRadius->setTip(tr("Outer Radius")); formLayout->addRow(tr("Radius 2:"), m_startSectorOuterRadius); m_startSectorAngle = createNE( this ); m_startSectorAngle->setTip(tr("Angle 1...360")); formLayout->addRow(tr("Angle:"), m_startSectorAngle); //-------------------------------------------------------------- // as next inner scheme group is added QGroupBox* startGroup3 = new QGroupBox( tr("Scheme"), this ); topLayout->addWidget( startGroup3, row, 2 ); formLayout = new QFormLayout; startGroup3->setLayout(formLayout); QRadioButton* circle = new QRadioButton( tr("Circle"), this ); QRadioButton* sector = new QRadioButton( tr("Sector"), this ); QRadioButton* keyhole = new QRadioButton( tr("Keyhole"), this ); QRadioButton* line = new QRadioButton( tr("Line"), this ); startScheme = new QButtonGroup(this); startScheme->addButton( circle, GeneralConfig::Circle ); startScheme->addButton( sector, GeneralConfig::Sector ); startScheme->addButton( keyhole, GeneralConfig::Keyhole ); startScheme->addButton( line, GeneralConfig::Line ); formLayout->addWidget( circle ); formLayout->addWidget( sector ); formLayout->addWidget( keyhole ); formLayout->addWidget( line ); circle->setEnabled(true); circle->setChecked(false); sector->setEnabled(true); sector->setChecked(false); keyhole->setEnabled(true); keyhole->setChecked(false); line->setEnabled(true); line->setChecked(false); // set active button as selected m_selectedStartScheme = (int) conf->getActiveTaskStartScheme(); if( startScheme->button(m_selectedStartScheme) ) { startScheme->button(m_selectedStartScheme)->setChecked(true); } #ifdef ANDROID topLayout->setRowMinimumHeight( ++row, 30 ); #endif row++; //-------------------------------------------------------------- // as next finish group is added QGroupBox* finishGroup1 = new QGroupBox( tr("Finish"), this ); topLayout->addWidget( finishGroup1, row, 0 ); formLayout = new QFormLayout; finishGroup1->setLayout(formLayout); m_finishLine = createDNE( this ); m_finishLine->setTip(tr("Line Length")); formLayout->addRow(tr("Line:"), m_finishLine); m_finishRing = createDNE( this ); m_finishRing->setTip(tr("Circle Radius")); formLayout->addRow(tr("Circle"), m_finishRing); //-------------------------------------------------------------- // as next inner sector group is added QGroupBox* finishGroup2 = new QGroupBox( tr("Sectors"), this ); topLayout->addWidget( finishGroup2, row, 1 ); formLayout = new QFormLayout; finishGroup2->setLayout(formLayout); m_finishSectorInnerRadius = createDNE( this ); m_finishSectorInnerRadius->setTip(tr("Inner Radius")); formLayout->addRow(tr("Radius 1:"), m_finishSectorInnerRadius); m_finishSectorOuterRadius = createDNE( this ); m_finishSectorOuterRadius->setTip(tr("Outer Radius")); formLayout->addRow(tr("Radius 2:"), m_finishSectorOuterRadius); m_finishSectorAngle = createNE( this ); m_finishSectorAngle->setTip(tr("Angle 1...360")); formLayout->addRow(tr("Angle:"), m_finishSectorAngle); //-------------------------------------------------------------- // as next inner scheme group is added QGroupBox* finishGroup3 = new QGroupBox( tr("Scheme"), this ); topLayout->addWidget( finishGroup3, row, 2 ); formLayout = new QFormLayout; finishGroup3->setLayout(formLayout); circle = new QRadioButton( tr("Circle"), this ); sector = new QRadioButton( tr("Sector"), this ); keyhole = new QRadioButton( tr("Keyhole"), this ); line = new QRadioButton( tr("Line"), this ); finishScheme = new QButtonGroup(this); finishScheme->addButton( circle, GeneralConfig::Circle ); finishScheme->addButton( sector, GeneralConfig::Sector ); finishScheme->addButton( keyhole, GeneralConfig::Keyhole ); finishScheme->addButton( line, GeneralConfig::Line ); formLayout->addWidget( circle ); formLayout->addWidget( sector ); formLayout->addWidget( keyhole ); formLayout->addWidget( line ); circle->setEnabled(true); circle->setChecked(false); sector->setEnabled(true); sector->setChecked(false); keyhole->setEnabled(true); keyhole->setChecked(false); line->setEnabled(true); line->setChecked(false); // set active button as selected m_selectedFinishScheme = (int) conf->getActiveTaskFinishScheme(); if( finishScheme->button(m_selectedFinishScheme) ) { finishScheme->button(m_selectedFinishScheme)->setChecked(true); } #ifdef ANDROID topLayout->setRowMinimumHeight( ++row, 30 ); #endif row++; //-------------------------------------------------------------- // as next observation zone is added QGroupBox* obZoneGroup1 = new QGroupBox( tr("Observation"), this ); topLayout->addWidget( obZoneGroup1, row, 0 ); formLayout = new QFormLayout; obZoneGroup1->setLayout(formLayout); m_obsCircleRadius = createDNE( this ); m_obsCircleRadius->setTip(tr("Circle Radius")); formLayout->addRow(tr("Circle:"), m_obsCircleRadius); //-------------------------------------------------------------- // as next inner sector group is added QGroupBox* obZoneGroup2 = new QGroupBox( tr("Sectors"), this ); topLayout->addWidget( obZoneGroup2, row, 1 ); formLayout = new QFormLayout; obZoneGroup2->setLayout(formLayout); m_obsSectorInnerRadius = createDNE( this ); m_obsSectorInnerRadius->setTip(tr("Inner Radius")); formLayout->addRow(tr("Radius 1:"), m_obsSectorInnerRadius); m_obsSectorOuterRadius = createDNE( this ); m_obsSectorOuterRadius->setTip(tr("Outer Radius")); formLayout->addRow(tr("Radius 2:"), m_obsSectorOuterRadius); m_obsSectorAngle = createNE( this ); m_obsSectorAngle->setTip(tr("Angle 1...360")); formLayout->addRow(tr("Angle:"), m_obsSectorAngle); //-------------------------------------------------------------- // as next inner observer scheme group is added QGroupBox* obZoneGroup3 = new QGroupBox( tr("Scheme"), this ); topLayout->addWidget( obZoneGroup3, row, 2 ); formLayout = new QFormLayout; obZoneGroup3->setLayout(formLayout); circle = new QRadioButton( tr("Circle"), this ); sector = new QRadioButton( tr("Sector"), this ); keyhole = new QRadioButton( tr("Keyhole"), this ); // no line for observer area obsScheme = new QButtonGroup(this); obsScheme->addButton( circle, GeneralConfig::Circle ); obsScheme->addButton( sector, GeneralConfig::Sector ); obsScheme->addButton( keyhole, GeneralConfig::Keyhole ); formLayout->addWidget( circle ); formLayout->addWidget( sector ); formLayout->addWidget( keyhole ); circle->setEnabled(true); circle->setChecked(false); sector->setEnabled(true); sector->setChecked(false); keyhole->setEnabled(true); keyhole->setChecked(false); // set active button as selected m_selectedObsScheme = (int) conf->getActiveTaskObsScheme(); if( obsScheme->button(m_selectedObsScheme) ) { obsScheme->button(m_selectedObsScheme)->setChecked(true); } //-------------------------------------------------------------- // Connect sector check controls. connect( m_startSectorOuterRadius, SIGNAL(numberEdited(const QString&)), this, SLOT(slot_outerSectorStartChanged(const QString&)) ); connect( m_finishSectorOuterRadius, SIGNAL(numberEdited(const QString&)), this, SLOT(slot_outerSectorFinishChanged(const QString&)) ); connect( m_obsSectorOuterRadius, SIGNAL(numberEdited(const QString&)), this, SLOT(slot_outerSectorObsChanged(const QString&)) ); connect( startScheme, SIGNAL(buttonClicked(int)), this, SLOT(slot_buttonPressedSS(int)) ); connect( finishScheme, SIGNAL(buttonClicked(int)), this, SLOT(slot_buttonPressedFS(int)) ); connect( obsScheme, SIGNAL(buttonClicked(int)), this, SLOT(slot_buttonPressedOS(int)) ); QPushButton *cancel = new QPushButton(this); cancel->setIcon(QIcon(GeneralConfig::instance()->loadPixmap("cancel.png"))); cancel->setIconSize(QSize(Layout::getButtonSize(12), Layout::getButtonSize(12))); cancel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::QSizePolicy::Preferred); QPushButton *ok = new QPushButton(this); ok->setIcon(QIcon(GeneralConfig::instance()->loadPixmap("ok.png"))); ok->setIconSize(QSize(Layout::getButtonSize(12), Layout::getButtonSize(12))); ok->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::QSizePolicy::Preferred); QLabel *titlePix = new QLabel(this); titlePix->setAlignment( Qt::AlignCenter ); titlePix->setPixmap(GeneralConfig::instance()->loadPixmap("setup.png")); connect(ok, SIGNAL(pressed()), this, SLOT(slotAccept())); connect(cancel, SIGNAL(pressed()), this, SLOT(slotReject())); QVBoxLayout *buttonBox = new QVBoxLayout; buttonBox->setSpacing(0); buttonBox->addStretch(2); buttonBox->addWidget(cancel, 1); buttonBox->addSpacing(30); buttonBox->addWidget(ok, 1); buttonBox->addStretch(2); buttonBox->addWidget(titlePix); contentLayout->addLayout(buttonBox); load(); }
SettingsPageInformation::SettingsPageInformation( QWidget *parent ) : QWidget(parent) { setObjectName("SettingsPageInformation"); setWindowFlags( Qt::Tool ); setWindowModality( Qt::WindowModal ); setAttribute(Qt::WA_DeleteOnClose); setWindowTitle( tr("Settings - Information") ); if( parent ) { resize( parent->size() ); } // Layout used by scroll area QHBoxLayout *sal = new QHBoxLayout; // new widget used as container for the dialog layout. QWidget* sw = new QWidget; // Scroll area QScrollArea* sa = new QScrollArea; sa->setWidgetResizable( true ); sa->setFrameStyle( QFrame::NoFrame ); sa->setWidget( sw ); #ifdef QSCROLLER QScroller::grabGesture( sa->viewport(), QScroller::LeftMouseButtonGesture ); #endif #ifdef QTSCROLLER QtScroller::grabGesture( sa->viewport(), QtScroller::LeftMouseButtonGesture ); #endif // Add scroll area to its own layout sal->addWidget( sa ); QHBoxLayout *contentLayout = new QHBoxLayout; setLayout(contentLayout); // Pass scroll area layout to the content layout. contentLayout->addLayout( sal, 10 ); // The parent of the layout is the scroll widget QGridLayout *topLayout = new QGridLayout(sw); topLayout->setHorizontalSpacing(20 * Layout::getIntScaledDensity() ); topLayout->setVerticalSpacing(10 * Layout::getIntScaledDensity() ); int row=0; #ifndef ANDROID QHBoxLayout *hBox = new QHBoxLayout(); QPushButton *soundSelection = new QPushButton( tr("Sound Player"), this ); soundSelection->setToolTip(tr("Select a sound player, use %s if played file is enclosed in command line arguments")); hBox->addWidget(soundSelection); connect(soundSelection, SIGNAL( clicked()), this, SLOT(slot_openToolDialog()) ); Qt::InputMethodHints imh; soundTool = new QLineEdit( this ); imh = (soundTool->inputMethodHints() | Qt::ImhNoPredictiveText); soundTool->setInputMethodHints(imh); connect( soundTool, SIGNAL(returnPressed()), MainWindow::mainWindow(), SLOT(slotCloseSip()) ); hBox->addWidget(soundTool); topLayout->addLayout( hBox, row++, 0, 1, 3 ); topLayout->setRowMinimumHeight( row++, 10 ); #endif topLayout->addWidget(new QLabel(tr("Airfield display time:"), this), row, 0); spinAirfield = createNumEd( this ); topLayout->addWidget( spinAirfield, row, 1 ); row++; topLayout->addWidget(new QLabel(tr("Airspace display time:"), this), row, 0); spinAirspace = createNumEd( this ); topLayout->addWidget( spinAirspace, row, 1 ); row++; topLayout->addWidget(new QLabel(tr("Info display time:"), this), row, 0); spinInfo = createNumEd( this ); topLayout->addWidget( spinInfo, row, 1 ); row++; topLayout->addWidget(new QLabel(tr("Waypoint display time:"), this), row, 0); spinWaypoint = createNumEd( this ); topLayout->addWidget( spinWaypoint, row, 1 ); row++; topLayout->addWidget(new QLabel(tr("Warning display time:"), this), row, 0); spinWarning = createNumEd( this ); topLayout->addWidget( spinWarning, row, 1 ); row++; topLayout->addWidget(new QLabel(tr("Warning suppress time:"), this), row, 0); spinSuppress = new NumberEditor; spinSuppress->setDecimalVisible( false ); spinSuppress->setPmVisible( false ); spinSuppress->setMaxLength(3); spinSuppress->setRange(0, 60); spinSuppress->setSpecialValueText(tr("Off")); spinSuppress->setSuffix( " min" ); spinSuppress->setTip("0...60 min"); QRegExpValidator* eValidator = new QRegExpValidator( QRegExp( "([0-9]{1,2})" ), this ); spinSuppress->setValidator( eValidator ); // Sets a minimum width for the widget int mw = QFontMetrics(font()).width(QString("999 min")) + 10; spinSuppress->setMinimumWidth( mw ); topLayout->addWidget( spinSuppress, row, 1 ); buttonReset = new QPushButton (tr("Defaults"), this); topLayout->addWidget( buttonReset, row, 2, Qt::AlignLeft ); row++; checkAlarmSound = new QCheckBox(tr("Alarm Sound"), this); checkAlarmSound->setObjectName("checkAlarmSound"); checkAlarmSound->setChecked(true); topLayout->addWidget( checkAlarmSound, row, 0 ); checkFlarmAlarms = new QCheckBox(tr("Flarm Alarms"), this); checkFlarmAlarms->setObjectName("checkFlarmAlarms"); checkFlarmAlarms->setChecked(true); topLayout->addWidget( checkFlarmAlarms, row, 1, 1, 2 ); row++; calculateNearestSites = new QCheckBox(tr("Nearest Site Calculator"), this); calculateNearestSites->setObjectName("calcNearest"); calculateNearestSites->setChecked(true); topLayout->addWidget( calculateNearestSites, row, 0 ); inverseInfoDisplay = new QCheckBox(tr("Black Display"), this); inverseInfoDisplay->setObjectName("inverseDisplay"); inverseInfoDisplay->setChecked(false); topLayout->addWidget( inverseInfoDisplay, row, 1, 1, 2 ); row++; topLayout->setRowStretch ( row, 10 ); topLayout->setColumnStretch( 2, 10 ); connect( buttonReset, SIGNAL(clicked()), SLOT(slot_setFactoryDefault()) ); QPushButton *cancel = new QPushButton(this); cancel->setIcon(QIcon(GeneralConfig::instance()->loadPixmap("cancel.png"))); cancel->setIconSize(QSize(Layout::getButtonSize(12), Layout::getButtonSize(12))); cancel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::QSizePolicy::Preferred); QPushButton *ok = new QPushButton(this); ok->setIcon(QIcon(GeneralConfig::instance()->loadPixmap("ok.png"))); ok->setIconSize(QSize(Layout::getButtonSize(12), Layout::getButtonSize(12))); ok->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::QSizePolicy::Preferred); QLabel *titlePix = new QLabel(this); titlePix->setAlignment( Qt::AlignCenter ); titlePix->setPixmap(GeneralConfig::instance()->loadPixmap("setup.png")); connect(ok, SIGNAL(pressed()), this, SLOT(slotAccept())); connect(cancel, SIGNAL(pressed()), this, SLOT(slotReject())); QVBoxLayout *buttonBox = new QVBoxLayout; buttonBox->setSpacing(0); buttonBox->addStretch(2); buttonBox->addWidget(cancel, 1); buttonBox->addSpacing(30); buttonBox->addWidget(ok, 1); buttonBox->addStretch(2); buttonBox->addWidget(titlePix); contentLayout->addLayout(buttonBox); load(); }
SettingsPageGPS4A::SettingsPageGPS4A(QWidget *parent) : QWidget(parent) { setObjectName("SettingsPageGPS4A"); setWindowFlags( Qt::Tool ); setWindowModality( Qt::WindowModal ); setAttribute(Qt::WA_DeleteOnClose); setWindowTitle( tr("Settings - GPS") ); if( parent ) { resize( parent->size() ); } QHBoxLayout *contentLayout = new QHBoxLayout; setLayout(contentLayout); QGridLayout* topLayout = new QGridLayout; contentLayout->addLayout(topLayout, 10); int row = 0; topLayout->setRowMinimumHeight( row++, 20); // Defines from which device the altitude data shall be taken. Possible // devices are the GPS or a pressure sonde. GpsAltitude = new QComboBox; GpsAltitude->setEditable(false); GpsAltitude->addItem(tr("GPS")); GpsAltitude->addItem(tr("Pressure")); QFormLayout* fl = new QFormLayout; fl->addRow( tr("Altitude Reference:"), GpsAltitude ); topLayout->addLayout( fl, row++, 0, Qt::AlignLeft ); topLayout->setRowMinimumHeight( row++, 10); saveNmeaData = new QCheckBox (tr("Save NMEA Data to file")); topLayout->addWidget( saveNmeaData, row++, 0, Qt::AlignLeft ); topLayout->setRowStretch( row, 10 ); QPushButton *cancel = new QPushButton(this); cancel->setIcon(QIcon(GeneralConfig::instance()->loadPixmap("cancel.png"))); cancel->setIconSize(QSize(Layout::getButtonSize(12), Layout::getButtonSize(12))); cancel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::QSizePolicy::Preferred); QPushButton *ok = new QPushButton(this); ok->setIcon(QIcon(GeneralConfig::instance()->loadPixmap("ok.png"))); ok->setIconSize(QSize(Layout::getButtonSize(12), Layout::getButtonSize(12))); ok->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::QSizePolicy::Preferred); QLabel *titlePix = new QLabel(this); titlePix->setAlignment( Qt::AlignCenter ); titlePix->setPixmap(GeneralConfig::instance()->loadPixmap("setup.png")); connect(ok, SIGNAL(pressed()), this, SLOT(slotAccept())); connect(cancel, SIGNAL(pressed()), this, SLOT(slotReject())); QVBoxLayout *buttonBox = new QVBoxLayout; buttonBox->setSpacing(0); buttonBox->addStretch(2); buttonBox->addWidget(cancel, 1); buttonBox->addSpacing(30); buttonBox->addWidget(ok, 1); buttonBox->addStretch(2); buttonBox->addWidget(titlePix); contentLayout->addLayout(buttonBox); load(); }
SettingsPageUnits::SettingsPageUnits(QWidget *parent) : QWidget(parent) { setObjectName("SettingsPageUnits"); setWindowFlags( Qt::Tool ); setWindowModality( Qt::WindowModal ); setAttribute(Qt::WA_DeleteOnClose); setWindowTitle( tr("Settings - Units") ); if( parent ) { resize( parent->size() ); } // Layout used by scroll area QHBoxLayout *sal = new QHBoxLayout; // new widget used as container for the dialog layout. QWidget* sw = new QWidget; // Scroll area QScrollArea* sa = new QScrollArea; sa->setWidgetResizable( true ); sa->setFrameStyle( QFrame::NoFrame ); sa->setWidget( sw ); #ifdef ANDROID QScrollBar* lvsb = sa->verticalScrollBar(); lvsb->setStyleSheet( Layout::getCbSbStyle() ); #endif #ifdef QSCROLLER QScroller::grabGesture( sa->viewport(), QScroller::LeftMouseButtonGesture ); #endif #ifdef QTSCROLLER QtScroller::grabGesture( sa->viewport(), QtScroller::LeftMouseButtonGesture ); #endif // Add scroll area to its own layout sal->addWidget( sa ); QHBoxLayout *contentLayout = new QHBoxLayout; setLayout(contentLayout); // Pass scroll area layout to the content layout. contentLayout->addLayout( sal, 10 ); // The parent of the layout is the scroll widget QGridLayout *topLayout = new QGridLayout(sw); int row=0; QLabel *label = new QLabel(tr("Altitude:"), this); topLayout->addWidget(label, row, 0); UnitAlt = new QComboBox(this); UnitAlt->setObjectName("UnitAlt"); UnitAlt->setEditable(false); topLayout->addWidget(UnitAlt,row++,1); UnitAlt->addItem(tr("meters")); UnitAlt->addItem(tr("feet")); altitudes[0] = int(Altitude::meters); altitudes[1] = int(Altitude::feet); label = new QLabel(tr("Speed:"), this); topLayout->addWidget(label, row, 0); UnitSpeed = new QComboBox(this); UnitSpeed->setObjectName("UnitSpeed"); UnitSpeed->setEditable(false); topLayout->addWidget(UnitSpeed,row++,1); UnitSpeed->addItem(tr("meters per second")); UnitSpeed->addItem(tr("kilometers per hour")); UnitSpeed->addItem(tr("knots")); UnitSpeed->addItem(tr("miles per hour")); speeds[0] = Speed::metersPerSecond; speeds[1] = Speed::kilometersPerHour; speeds[2] = Speed::knots; speeds[3] = Speed::milesPerHour; label = new QLabel(tr("Distance:"), this); topLayout->addWidget(label, row, 0); UnitDistance = new QComboBox(this); UnitDistance->setObjectName("UnitDistance"); UnitDistance->setEditable(false); topLayout->addWidget(UnitDistance,row++,1); UnitDistance->addItem(tr("kilometers")); UnitDistance->addItem(tr("statute miles")); UnitDistance->addItem(tr("nautical miles")); distances[0] = Distance::kilometers; distances[1] = Distance::miles; distances[2] = Distance::nautmiles; label = new QLabel(tr("Vario:"), this); topLayout->addWidget(label, row, 0); UnitVario = new QComboBox(this); UnitVario->setObjectName("UnitVario"); UnitVario->setEditable(false); topLayout->addWidget(UnitVario,row++,1); UnitVario->addItem(tr("meters per second")); UnitVario->addItem(tr("feet per minute")); UnitVario->addItem(tr("knots")); varios[0] = Speed::metersPerSecond; varios[1] = Speed::feetPerMinute; varios[2] = Speed::knots; label = new QLabel(tr("Wind:"), this); topLayout->addWidget(label, row, 0); UnitWind = new QComboBox(this); UnitWind->setObjectName("UnitWind"); UnitWind->setEditable(false); topLayout->addWidget(UnitWind,row++,1); UnitWind->addItem(tr("meters per second")); UnitWind->addItem(tr("kilometers per hour")); UnitWind->addItem(tr("knots")); UnitWind->addItem(tr("miles per hour")); winds[0] = Speed::metersPerSecond; winds[1] = Speed::kilometersPerHour; winds[2] = Speed::knots; winds[3] = Speed::milesPerHour; label = new QLabel(tr("Position:"), this); topLayout->addWidget(label, row, 0); UnitPosition = new QComboBox(this); UnitPosition->setObjectName("UnitPosition"); UnitPosition->setEditable(false); topLayout->addWidget(UnitPosition,row++,1); UnitPosition->addItem(QString("ddd") + Qt::Key_degree + "mm'ss\""); UnitPosition->addItem(QString("ddd") + Qt::Key_degree + "mm.mmm'"); UnitPosition->addItem(QString("ddd.ddddd") + Qt::Key_degree); positions[0] = WGSPoint::DMS; positions[1] = WGSPoint::DDM; positions[2] = WGSPoint::DDD; label = new QLabel(tr("Time:"), this); topLayout->addWidget(label, row, 0); UnitTime = new QComboBox(this); UnitTime->setObjectName("UnitTime"); UnitTime->setEditable(false); topLayout->addWidget(UnitTime,row++,1); UnitTime->addItem(tr("UTC")); UnitTime->addItem(tr("Local")); times[0] = Time::utc; times[1] = Time::local; label = new QLabel(tr("Temperature:"), this); topLayout->addWidget(label, row, 0); UnitTemperature = new QComboBox(this); UnitTemperature->setObjectName("UnitTemperature"); UnitTemperature->setEditable(false); topLayout->addWidget(UnitTemperature,row++,1); UnitTemperature->addItem(tr("Celsius")); UnitTemperature->addItem(tr("Fahrenheit")); temperature[0] = GeneralConfig::Celsius; temperature[1] = GeneralConfig::Fahrenheit; label = new QLabel(tr("Air Pressure:"), this); topLayout->addWidget(label, row, 0); UnitAirPressure = new QComboBox(this); UnitAirPressure->setObjectName("UnitAirPressure"); UnitAirPressure->setEditable(false); topLayout->addWidget(UnitAirPressure,row++,1); UnitAirPressure->addItem(tr("hPa")); UnitAirPressure->addItem(tr("inHg")); airPressure[0] = GeneralConfig::hPa; airPressure[1] = GeneralConfig::inHg; topLayout->setRowStretch(row++, 10); topLayout->setColumnStretch(2, 10); QPushButton *help = new QPushButton(this); help->setIcon(QIcon(GeneralConfig::instance()->loadPixmap("help32.png"))); help->setIconSize(QSize(Layout::getButtonSize(12), Layout::getButtonSize(12))); help->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::QSizePolicy::Preferred); QPushButton *cancel = new QPushButton(this); cancel->setIcon(QIcon(GeneralConfig::instance()->loadPixmap("cancel.png"))); cancel->setIconSize(QSize(Layout::getButtonSize(12), Layout::getButtonSize(12))); cancel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::QSizePolicy::Preferred); QPushButton *ok = new QPushButton(this); ok->setIcon(QIcon(GeneralConfig::instance()->loadPixmap("ok.png"))); ok->setIconSize(QSize(Layout::getButtonSize(12), Layout::getButtonSize(12))); ok->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::QSizePolicy::Preferred); QLabel *titlePix = new QLabel(this); titlePix->setAlignment( Qt::AlignCenter ); titlePix->setPixmap(GeneralConfig::instance()->loadPixmap("setup.png")); connect(help, SIGNAL(pressed()), this, SLOT(slotHelp())); connect(ok, SIGNAL(pressed()), this, SLOT(slotAccept())); connect(cancel, SIGNAL(pressed()), this, SLOT(slotReject())); QVBoxLayout *buttonBox = new QVBoxLayout; buttonBox->setSpacing(0); buttonBox->addWidget(help, 1); buttonBox->addStretch(2); buttonBox->addWidget(cancel, 1); buttonBox->addSpacing(30); buttonBox->addWidget(ok, 1); buttonBox->addStretch(2); buttonBox->addWidget(titlePix); contentLayout->addLayout(buttonBox); load(); }