Ejemplo n.º 1
1
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);
}
Ejemplo n.º 2
0
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();
}
Ejemplo n.º 3
0
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);
}
Ejemplo n.º 4
0
GliderEditorNumPad::GliderEditorNumPad(QWidget *parent, Glider *glider ) :
  QWidget(parent),
  m_gliderCreated(false)
{
  setWindowFlags(Qt::Tool);
  setWindowModality( Qt::WindowModal );
  setAttribute(Qt::WA_DeleteOnClose);

  // Resize the window to the same size as the main window has. That will
  // completely hide the parent window.
  resize( MainWindow::mainWindow()->size() );

  // save current horizontal/vertical speed unit. This unit must be considered
  // during storage.
  m_currHSpeedUnit = Speed::getHorizontalUnit();
  m_currVSpeedUnit = Speed::getVerticalUnit();

  if (glider == 0)
    {
      setWindowTitle(tr("New Glider"));
      m_isNew = true;
    }
  else
    {
      setWindowTitle(tr("Edit Glider"));
      m_isNew = false;
    }

  m_glider = glider;

  QHBoxLayout* topLayout = new QHBoxLayout(this);
  QGridLayout* itemsLayout = new QGridLayout;
  itemsLayout->setHorizontalSpacing(10);
  itemsLayout->setVerticalSpacing(10);
  int row = 0;

  if( m_isNew )
    {
      itemsLayout->addWidget(new QLabel(tr("Glider Pool:"), this), row, 0);
      m_openGliderList = new QPushButton( tr("Open") );
      itemsLayout->addWidget(m_openGliderList, row, 1, 1, 3);

      connect( m_openGliderList, SIGNAL(clicked()),
	       SLOT(slot_openGliderSelectionList()) );
      row++;
    }

  Qt::InputMethodHints imh = Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText;

  itemsLayout->addWidget(new QLabel(tr("Glider Type:"), this), row, 0);
  m_edtGType = new QLineEdit(this);
  imh |= m_edtGType->inputMethodHints();
  m_edtGType->setInputMethodHints(imh);

  connect( m_edtGType, SIGNAL(returnPressed()),
           MainWindow::mainWindow(), SLOT(slotCloseSip()) );

  itemsLayout->addWidget(m_edtGType, row, 1, 1, 3);
  row++;

  itemsLayout->addWidget(new QLabel(tr("Registration:"), this), row, 0);
  m_edtGReg = new QLineEdit(this);
  m_edtGReg->setInputMethodHints(imh);

  connect( m_edtGReg, SIGNAL(returnPressed()),
           MainWindow::mainWindow(), SLOT(slotCloseSip()) );

  itemsLayout->addWidget(m_edtGReg, row, 1);

  itemsLayout->addWidget(new QLabel(tr("Seats:"), this), row, 2);
  m_seats = new QPushButton( this );
  itemsLayout->addWidget(m_seats, row, 3);

  connect( m_seats, SIGNAL(clicked()), SLOT(slot_changeSeats()) );
  row++;

  itemsLayout->addWidget(new QLabel(tr("Call Sign:"), this), row, 0);
  m_edtGCall = new QLineEdit(this);
  m_edtGCall->setInputMethodHints(imh);

  connect( m_edtGCall, SIGNAL(returnPressed()),
           MainWindow::mainWindow(), SLOT(slotCloseSip()) );

  itemsLayout->addWidget(m_edtGCall, row, 1);

  itemsLayout->addWidget(new QLabel(tr("Wing Area:"), this), row, 2);

  m_dneWingArea = new DoubleNumberEditor(this);
  m_dneWingArea->setDecimalVisible( true );
  m_dneWingArea->setPmVisible( false );
  m_dneWingArea->setMaxLength(7);
  m_dneWingArea->setDecimals( 2 );
  QChar tsChar(Qt::Key_twosuperior);
  m_dneWingArea->setSuffix( QString(" m") + tsChar );
  itemsLayout->addWidget(m_dneWingArea, row, 3);
  row++;

  itemsLayout->setRowMinimumHeight(row++, 10);

  QGridLayout* spinboxLayout = new QGridLayout;
  spinboxLayout->setHorizontalSpacing(10);
  spinboxLayout->setVerticalSpacing(10);
  int srow = 0;

  spinboxLayout->addWidget(new QLabel("v1:", this), srow, 0);

  m_dneV1 = new DoubleNumberEditor(this);
  m_dneV1->setDecimalVisible( true );
  m_dneV1->setPmVisible( false );
  m_dneV1->setMaxLength(5);
  m_dneV1->setRange(0.0, 250.0);
  m_dneV1->setDecimals( 1 );
  m_dneV1->setSuffix( " " + Speed::getHorizontalUnitText() );
  spinboxLayout->addWidget(m_dneV1, srow, 1);

  spinboxLayout->addWidget(new QLabel("w1:", this), srow, 2);

  m_dneW1 = new DoubleNumberEditor(this);
  m_dneW1->setDecimalVisible( true );
  m_dneW1->setPmVisible( true );
  m_dneW1->setMaxLength(7);
  m_dneW1->setDecimals( 2 );
  m_dneW1->setSuffix( " " + Speed::getVerticalUnitText() );

  QRegExpValidator *eValidator = new QRegExpValidator( QRegExp( "-[0-9]+\\.?[0-9]*" ), this );
  m_dneW1->setValidator(eValidator);

  spinboxLayout->addWidget(m_dneW1, srow, 3);

  spinboxLayout->addWidget(new QLabel(tr("Ref. weight:"), this), srow, 4);

  m_grossWeight = new NumberEditor( this );
  m_grossWeight->setDecimalVisible( false );
  m_grossWeight->setPmVisible( false );
  m_grossWeight->setMaxLength(4);
  m_grossWeight->setSuffix(" kg");
  m_grossWeight->setRange( 0, 9999 );
  spinboxLayout->addWidget(m_grossWeight, srow, 5);
  srow++;

  spinboxLayout->addWidget(new QLabel("v2", this), srow, 0);

  m_dneV2 = new DoubleNumberEditor(this);
  m_dneV2->setDecimalVisible( true );
  m_dneV2->setPmVisible( false );
  m_dneV2->setMaxLength(5);
  m_dneV2->setRange(0.0, 250.0);
  m_dneV2->setDecimals( 1 );
  m_dneV2->setSuffix( " " + Speed::getHorizontalUnitText() );
  spinboxLayout->addWidget(m_dneV2, srow, 1);

  spinboxLayout->addWidget(new QLabel("w2:", this), srow, 2);

  m_dneW2 = new DoubleNumberEditor(this);
  m_dneW2->setDecimalVisible( true );
  m_dneW2->setPmVisible( true );
  m_dneW2->setMaxLength(7);
  m_dneW2->setDecimals( 2 );
  m_dneW2->setSuffix( " " + Speed::getVerticalUnitText() );

  eValidator = new QRegExpValidator( QRegExp( "-[0-9]+\\.?[0-9]*" ), this );
  m_dneW2->setValidator(eValidator);

  spinboxLayout->addWidget(m_dneW2, srow, 3);

  spinboxLayout->addWidget(new QLabel(tr("Load corr.:"), this), srow, 4);

  m_addedLoad = new NumberEditor( this );
  m_addedLoad->setDecimalVisible( false );
  m_addedLoad->setPmVisible( true );
  m_addedLoad->setMaxLength(4);
  m_addedLoad->setSuffix(" kg");
  m_addedLoad->setRange( -999, 999 );
  spinboxLayout->addWidget(m_addedLoad, srow, 5);
  srow++;

  spinboxLayout->addWidget(new QLabel("v3:", this), srow, 0);

  m_dneV3 = new DoubleNumberEditor(this);
  m_dneV3->setDecimalVisible( true );
  m_dneV3->setPmVisible( false );
  m_dneV3->setMaxLength(5);
  m_dneV3->setRange(0.0, 250.0);
  m_dneV3->setDecimals( 1 );
  m_dneV3->setSuffix( " " + Speed::getHorizontalUnitText() );
  spinboxLayout->addWidget(m_dneV3, srow, 1);

  spinboxLayout->addWidget(new QLabel("w3:", this), srow, 2);

  m_dneW3 = new DoubleNumberEditor(this);
  m_dneW3->setDecimalVisible( true );
  m_dneW3->setPmVisible( true );
  m_dneW3->setMaxLength(7);
  m_dneW3->setDecimals( 2 );
  m_dneW3->setSuffix( " " + Speed::getVerticalUnitText() );

  eValidator = new QRegExpValidator( QRegExp( "-[0-9]+\\.?[0-9]*" ), this );
  m_dneW3->setValidator(eValidator);

  spinboxLayout->addWidget(m_dneW3, srow, 3);

  spinboxLayout->addWidget(new QLabel(tr("Max. water:"), this), srow, 4);

  m_addedWater = new NumberEditor( this );
  m_addedWater->setDecimalVisible( false );
  m_addedWater->setPmVisible( false );
  m_addedWater->setMaxLength(4);
  m_addedWater->setSuffix(" l");
  m_addedWater->setRange( 0, 9999 );
  spinboxLayout->addWidget(m_addedWater, srow++, 5);
  spinboxLayout->setColumnStretch(6, 10);
  spinboxLayout->setRowMinimumHeight(srow++, 20);

  m_buttonShow = new QPushButton(tr("Show Polar"));

  QHBoxLayout* buttonRow = new QHBoxLayout;
  buttonRow->setSpacing(0);
  buttonRow->addStretch( 10 );
  buttonRow->addWidget( m_buttonShow );

  spinboxLayout->addLayout(buttonRow, srow++, 0, 1, 6);
  spinboxLayout->setRowStretch( srow++, 10 );

  itemsLayout->addLayout(spinboxLayout, row++, 0, 1, 4);
  itemsLayout->setColumnStretch( 1, 10 );
  itemsLayout->setColumnStretch( 4, 20 );

  connect(m_buttonShow, SIGNAL(pressed()), this, SLOT(slotButtonShow()));

  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);

  connect(ok, SIGNAL(pressed()), this, SLOT(accept()));
  connect(cancel, SIGNAL(pressed()), this, SLOT(reject()));

  QVBoxLayout *buttonBox = new QVBoxLayout;
  buttonBox->setSpacing(0);
  buttonBox->addStretch(2);
  buttonBox->addWidget(cancel, 1);
  buttonBox->addSpacing(30);
  buttonBox->addWidget(ok, 1);
  buttonBox->addStretch(2);

  topLayout->addLayout(itemsLayout);
  topLayout->addLayout(buttonBox);

  if( m_isNew )
    {
      readLK8000PolarData();
    }
  else
    {
      load();
    }

  show();
}
Ejemplo n.º 5
0
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();
}
Ejemplo n.º 6
0
PreFlightWeatherPage::PreFlightWeatherPage( QWidget *parent ) :
  QWidget(parent),
  m_downloadManger(0),
  m_updateIsRunning(false),
  NoMetar(tr("No METAR available")),
  NoTaf(tr("No TAF available"))
{
  setObjectName("PreFlightWeatherPage");
  setWindowTitle(tr("METAR and TAF"));
  setWindowFlags( Qt::Tool );
  setWindowModality( Qt::WindowModal );
  setAttribute(Qt::WA_DeleteOnClose);

  if( MainWindow::mainWindow() )
    {
      // Resize the window to the same size as the main window has. That will
      // completely hide the parent window.
      resize( MainWindow::mainWindow()->size() );

#ifdef ANDROID
      // On Galaxy S3 there are size problems observed
      setMinimumSize( MainWindow::mainWindow()->size() );
      setMaximumSize( MainWindow::mainWindow()->size() );
#endif
    }

  QVBoxLayout *mainLayout  = new QVBoxLayout( this );
  m_listWidget             = new QWidget( this );
  m_displayWidget          = new QWidget( this );
  m_editorWidget           = new QWidget( this );

  mainLayout->addWidget( m_listWidget );
  mainLayout->addWidget( m_displayWidget );
  mainLayout->addWidget( m_editorWidget );

  m_displayWidget->hide();
  m_editorWidget->hide();

  //----------------------------------------------------------------------------
  // List widget
  //----------------------------------------------------------------------------
  QVBoxLayout *listLayout = new QVBoxLayout( m_listWidget );

  m_list = new QTreeWidget;
  m_list->setRootIsDecorated( false );
  m_list->setItemsExpandable( false );
  m_list->setSortingEnabled( true );
  m_list->setSelectionMode( QAbstractItemView::SingleSelection );
  m_list->setSelectionBehavior( QAbstractItemView::SelectRows );
  m_list->setAlternatingRowColors(true);
  m_list->setColumnCount( 1 );
  m_list->setFocusPolicy( Qt::StrongFocus );
  m_list->setUniformRowHeights(true);
  m_list->setHeaderLabel( tr( "METAR and TAF" ) );

  m_list->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  m_list->setVerticalScrollMode( QAbstractItemView::ScrollPerPixel );

#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

  listLayout->addWidget( m_list );

  QHBoxLayout* hbbox1 = new QHBoxLayout;
  listLayout->addLayout( hbbox1 );

  QPushButton* cmd = new QPushButton(tr("Add"), this);
  hbbox1->addWidget(cmd);
  connect (cmd, SIGNAL(clicked()), SLOT(slotShowAirportEditor()));

  hbbox1->addSpacing( 10 );

  m_listUpdateButton = new QPushButton(tr("Update"), this);
  hbbox1->addWidget(m_listUpdateButton);
  connect (m_listUpdateButton, SIGNAL(clicked()), SLOT(slotRequestWeatherData()));

  hbbox1->addSpacing( 10 );

  cmd = new QPushButton(tr("Details"), this);
  hbbox1->addWidget(cmd);
  connect (cmd, SIGNAL(clicked()), SLOT(slotDetails()));

  QHBoxLayout* hbbox2 = new QHBoxLayout;
  listLayout->addLayout( hbbox2 );

  cmd = new QPushButton(tr("Delete"), this);
  hbbox2->addWidget(cmd);
  connect (cmd, SIGNAL(clicked()), SLOT(slotDeleteAirport()));

  hbbox2->addSpacing( 10 );

  cmd = new QPushButton(tr("Close"), this);
  hbbox2->addWidget(cmd);
  connect (cmd, SIGNAL(clicked()), SLOT(slotClose()));

  //----------------------------------------------------------------------------
  // Display widget for report details
  //----------------------------------------------------------------------------
  QVBoxLayout *displayLayout = new QVBoxLayout( m_displayWidget );
  m_display = new QTextEdit;
  m_display->setReadOnly( true );

#ifdef ANDROID
  lvsb = m_display->verticalScrollBar();
  lvsb->setStyleSheet( Layout::getCbSbStyle() );
#endif

#ifdef QSCROLLER
  QScroller::grabGesture(m_display->viewport(), QScroller::LeftMouseButtonGesture);
#endif

#ifdef QTSCROLLER
  QtScroller::grabGesture(m_display->viewport(), QtScroller::LeftMouseButtonGesture);
#endif

  displayLayout->addWidget( m_display );

  QHBoxLayout* hbbox = new QHBoxLayout;
  displayLayout->addLayout( hbbox );

  m_detailsUpdateButton = new QPushButton(tr("Update"));
  hbbox->addWidget(m_detailsUpdateButton);
  connect (m_detailsUpdateButton, SIGNAL(clicked()), SLOT(slotRequestWeatherData()));

  hbbox->addSpacing( 10 );

  cmd = new QPushButton(tr("Close"));
  hbbox->addWidget(cmd);
  connect (cmd, SIGNAL(clicked()), SLOT(slotShowListWidget()));

  //----------------------------------------------------------------------------
  // Editor widget for station adding.
  //----------------------------------------------------------------------------
  QVBoxLayout *editorLayout = new QVBoxLayout( m_editorWidget );

  editorLayout->addWidget( new QLabel(tr("Airport ICAO Code")), 0, Qt::AlignLeft );

  QHBoxLayout *inputLayout = new QHBoxLayout;
  editorLayout->addLayout( inputLayout );

  QRegExpValidator* eValidator = new QRegExpValidator( QRegExp( "[a-zA-Z0-9]{4}|^$" ), this );

  Qt::InputMethodHints imh;
  m_airportEditor = new QLineEdit;
  m_airportEditor->setInputMethodHints(Qt::ImhUppercaseOnly | Qt::ImhDigitsOnly | Qt::ImhNoPredictiveText);
  m_airportEditor->setValidator( eValidator );

  connect( m_airportEditor, SIGNAL(returnPressed()),
           MainWindow::mainWindow(), SLOT(slotCloseSip()) );

  inputLayout->addWidget( m_airportEditor, 5 );
  inputLayout->addSpacing( 10 );

  cmd = new QPushButton(tr("Cancel"), this);
  inputLayout->addWidget(cmd);
  connect (cmd, SIGNAL(clicked()), SLOT(slotShowListWidget()));

  inputLayout->addSpacing( 10 );

  cmd = new QPushButton(tr("Ok"), this);
  inputLayout->addWidget(cmd);
  connect (cmd, SIGNAL(clicked()), SLOT(slotAddAirport()));

  editorLayout->addStretch( 10 );

  //----------------------------------------------------------------------------
  loadAirportData( true );
  show();
}