Beispiel #1
0
KComboBoxTest::KComboBoxTest(TQWidget* widget, const char* name )
              :TQWidget(widget, name)
{
  TQVBoxLayout *vbox = new TQVBoxLayout (this, KDialog::marginHint(), KDialog::spacingHint());
  
  // Test for KCombo's KLineEdit destruction
  KComboBox *testCombo = new KComboBox( true, this ); // rw, with KLineEdit
  testCombo->setEditable( false ); // destroys our KLineEdit
  assert( testCombo->delegate() == 0L );
  delete testCombo; // not needed anymore  
  
  // Qt combobox
  TQHBox* hbox = new TQHBox(this);
  hbox->setSpacing (KDialog::spacingHint());
  TQLabel* lbl = new TQLabel("&QCombobox:", hbox);
  lbl->setSizePolicy (TQSizePolicy::Maximum, TQSizePolicy::Preferred);
  
  m_qc = new TQComboBox(hbox, "QtReadOnlyCombo" );
  lbl->setBuddy (m_qc);  
  TQObject::connect (m_qc, TQT_SIGNAL(activated(int)), TQT_SLOT(slotActivated(int)));
  TQObject::connect (m_qc, TQT_SIGNAL(activated(const TQString&)), TQT_SLOT (slotActivated(const TQString&)));
  vbox->addWidget (hbox);
  
  // Read-only combobox
  hbox = new TQHBox(this);
  hbox->setSpacing (KDialog::spacingHint());
  lbl = new TQLabel("&Read-Only Combo:", hbox);
  lbl->setSizePolicy (TQSizePolicy::Maximum, TQSizePolicy::Preferred);

  m_ro = new KComboBox(hbox, "ReadOnlyCombo" );
  lbl->setBuddy (m_ro);
  m_ro->setCompletionMode( TDEGlobalSettings::CompletionAuto );
  TQObject::connect (m_ro, TQT_SIGNAL(activated(int)), TQT_SLOT(slotActivated(int)));
  TQObject::connect (m_ro, TQT_SIGNAL(activated(const TQString&)), TQT_SLOT (slotActivated(const TQString&)));
  vbox->addWidget (hbox);

  // Read-write combobox
  hbox = new TQHBox(this);
  hbox->setSpacing (KDialog::spacingHint());
  lbl = new TQLabel("&Editable Combo:", hbox);
  lbl->setSizePolicy (TQSizePolicy::Maximum, TQSizePolicy::Preferred);

  m_rw = new KComboBox( true, hbox, "ReadWriteCombo" );
  lbl->setBuddy (m_rw);
  m_rw->setDuplicatesEnabled( true );
  m_rw->setInsertionPolicy( TQComboBox::NoInsertion );
  m_rw->setTrapReturnKey( true );
  TQObject::connect (m_rw, TQT_SIGNAL(activated(int)), TQT_SLOT(slotActivated(int)));
  TQObject::connect (m_rw, TQT_SIGNAL(activated(const TQString&)), TQT_SLOT(slotActivated(const TQString&)));
  TQObject::connect (m_rw, TQT_SIGNAL(returnPressed()), TQT_SLOT(slotReturnPressed()));
  TQObject::connect (m_rw, TQT_SIGNAL(returnPressed(const TQString&)), TQT_SLOT(slotReturnPressed(const TQString&)));
  vbox->addWidget (hbox);

  // History combobox...
  hbox = new TQHBox(this);
  hbox->setSpacing (KDialog::spacingHint());
  lbl = new TQLabel("&History Combo:", hbox);
  lbl->setSizePolicy (TQSizePolicy::Maximum, TQSizePolicy::Preferred);

  m_hc = new KHistoryCombo( true, hbox, "HistoryCombo" );
  lbl->setBuddy (m_hc);
  m_hc->setDuplicatesEnabled( true );
  m_hc->setInsertionPolicy( TQComboBox::NoInsertion );
  TQObject::connect (m_hc, TQT_SIGNAL(activated(int)), TQT_SLOT(slotActivated(int)));
  TQObject::connect (m_hc, TQT_SIGNAL(activated(const TQString&)), TQT_SLOT(slotActivated(const TQString&)));
  TQObject::connect (m_hc, TQT_SIGNAL(returnPressed()), TQT_SLOT(slotReturnPressed()));  
  vbox->addWidget (hbox);
  m_hc->setTrapReturnKey(true);

  // Read-write combobox that is a replica of code in konqueror...
  hbox = new TQHBox(this);
  hbox->setSpacing (KDialog::spacingHint());
  lbl = new TQLabel( "&Konq's Combo:", hbox);
  lbl->setSizePolicy (TQSizePolicy::Maximum, TQSizePolicy::Preferred);

  m_konqc = new KComboBox( true, hbox, "KonqyCombo" );
  lbl->setBuddy (m_konqc);
  m_konqc->setMaxCount( 10 );
  TQObject::connect (m_konqc, TQT_SIGNAL(activated(int)), TQT_SLOT(slotActivated(int)));
  TQObject::connect (m_konqc, TQT_SIGNAL(activated(const TQString&)), TQT_SLOT (slotActivated(const TQString&)));
  TQObject::connect (m_konqc, TQT_SIGNAL(returnPressed()), TQT_SLOT(slotReturnPressed()));
  vbox->addWidget (hbox);

  // Create an exit button
  hbox = new TQHBox (this);
  m_btnExit = new TQPushButton( "E&xit", hbox );
  TQObject::connect( m_btnExit, TQT_SIGNAL(clicked()), TQT_SLOT(quitApp()) );

  // Create a disable button...
  m_btnEnable = new TQPushButton( "Disa&ble", hbox );
  TQObject::connect (m_btnEnable, TQT_SIGNAL(clicked()), TQT_SLOT(slotDisable()));

  vbox->addWidget (hbox);

  // Popuplate the select-only list box
  TQStringList list;
  list << "Stone" << "Tree" << "Peables" << "Ocean" << "Sand" << "Chips"
       << "Computer" << "Mankind";
  list.sort();
  
  // Setup the qcombobox
  m_qc->insertStringList (list);
  
  // Setup read-only combo
  m_ro->insertStringList( list );
  m_ro->completionObject()->setItems( list );

  // Setup read-write combo
  m_rw->insertStringList( list );
  m_rw->completionObject()->setItems( list );

  // Setup read-write combo
  m_hc->insertStringList( list );
  m_hc->completionObject()->setItems( list );

  // Setup konq's combobox
  KSimpleConfig historyConfig( "konq_history" );
  historyConfig.setGroup( "Location Bar" );
  TDECompletion * s_pCompletion = new TDECompletion;
  s_pCompletion->setOrder( TDECompletion::Weighted );
  s_pCompletion->setItems( historyConfig.readListEntry( "ComboContents" ) );
  s_pCompletion->setCompletionMode( TDEGlobalSettings::completionMode() );
  m_konqc->setCompletionObject( s_pCompletion );

  TQPixmap pix = SmallIcon("www");
  m_konqc->insertItem( pix, "http://www.kde.org" );
  m_konqc->setCurrentItem( m_konqc->count()-1 );

  m_timer = new TQTimer (this);
  connect (m_timer, TQT_SIGNAL (timeout()), TQT_SLOT (slotTimeout()));
}
QgsAttributeTableDialog::QgsAttributeTableDialog( QgsVectorLayer *theLayer, QWidget *parent, Qt::WindowFlags flags )
    : QDialog( parent, flags )
    , mDock( 0 )
    , mLayer( theLayer )
    , mRubberBand( 0 )
{
  setupUi( this );

  // Fix selection color on loosing focus (Windows)
  setStyleSheet( QgisApp::instance()->styleSheet() );

  setAttribute( Qt::WA_DeleteOnClose );

  QSettings settings;

  // Initialize the window geometry
  restoreGeometry( settings.value( "/Windows/BetterAttributeTable/geometry" ).toByteArray() );

  QgsAttributeEditorContext context;

  myDa = new QgsDistanceArea();

  myDa->setSourceCrs( mLayer->crs() );
  myDa->setEllipsoidalMode( QgisApp::instance()->mapCanvas()->mapSettings().hasCrsTransformEnabled() );
  myDa->setEllipsoid( QgsProject::instance()->readEntry( "Measure", "/Ellipsoid", GEO_NONE ) );

  context.setDistanceArea( *myDa );
  context.setVectorLayerTools( QgisApp::instance()->vectorLayerTools() );

  QgsFeatureRequest r;
  if ( mLayer->geometryType() != QGis::NoGeometry &&
       settings.value( "/qgis/attributeTableBehaviour", QgsAttributeTableFilterModel::ShowAll ).toInt() == QgsAttributeTableFilterModel::ShowVisible )
  {
    QgsMapCanvas *mc = QgisApp::instance()->mapCanvas();
    QgsRectangle extent( mc->mapSettings().mapToLayerCoordinates( theLayer, mc->extent() ) );
    r.setFilterRect( extent );

    QgsGeometry *g = QgsGeometry::fromRect( extent );
    mRubberBand = new QgsRubberBand( mc, true );
    mRubberBand->setToGeometry( g, theLayer );
    delete g;

    mActionShowAllFilter->setText( tr( "Show All Features In Initial Canvas Extent" ) );
  }

  // Initialize dual view
  mMainView->init( mLayer, QgisApp::instance()->mapCanvas(), r, context );

  // Initialize filter gui elements
  mFilterActionMapper = new QSignalMapper( this );
  mFilterColumnsMenu = new QMenu( this );
  mActionFilterColumnsMenu->setMenu( mFilterColumnsMenu );
  mApplyFilterButton->setDefaultAction( mActionApplyFilter );

  // Set filter icon in a couple of places
  QIcon filterIcon = QgsApplication::getThemeIcon( "/mActionFilter.svg" );
  mActionShowAllFilter->setIcon( filterIcon );
  mActionAdvancedFilter->setIcon( filterIcon );
  mActionSelectedFilter->setIcon( filterIcon );
  mActionVisibleFilter->setIcon( filterIcon );
  mActionEditedFilter->setIcon( filterIcon );

  // Connect filter signals
  connect( mActionAdvancedFilter, SIGNAL( triggered() ), SLOT( filterExpressionBuilder() ) );
  connect( mActionShowAllFilter, SIGNAL( triggered() ), SLOT( filterShowAll() ) );
  connect( mActionSelectedFilter, SIGNAL( triggered() ), SLOT( filterSelected() ) );
  connect( mActionVisibleFilter, SIGNAL( triggered() ), SLOT( filterVisible() ) );
  connect( mActionEditedFilter, SIGNAL( triggered() ), SLOT( filterEdited() ) );
  connect( mFilterActionMapper, SIGNAL( mapped( QObject* ) ), SLOT( filterColumnChanged( QObject* ) ) );
  connect( mFilterQuery, SIGNAL( returnPressed() ), SLOT( filterQueryAccepted() ) );
  connect( mActionApplyFilter, SIGNAL( triggered() ), SLOT( filterQueryAccepted() ) );

  // info from layer to table
  connect( mLayer, SIGNAL( editingStarted() ), this, SLOT( editingToggled() ) );
  connect( mLayer, SIGNAL( editingStopped() ), this, SLOT( editingToggled() ) );
  connect( mLayer, SIGNAL( layerDeleted() ), this, SLOT( close() ) );
  connect( mLayer, SIGNAL( selectionChanged() ), this, SLOT( updateTitle() ) );
  connect( mLayer, SIGNAL( attributeAdded( int ) ), this, SLOT( columnBoxInit() ) );
  connect( mLayer, SIGNAL( attributeDeleted( int ) ), this, SLOT( columnBoxInit() ) );

  // connect table info to window
  connect( mMainView, SIGNAL( filterChanged() ), this, SLOT( updateTitle() ) );

  // info from table to application
  connect( this, SIGNAL( saveEdits( QgsMapLayer * ) ), QgisApp::instance(), SLOT( saveEdits( QgsMapLayer * ) ) );

  bool myDockFlag = settings.value( "/qgis/dockAttributeTable", false ).toBool();
  if ( myDockFlag )
  {
    mDock = new QgsAttributeTableDock( tr( "Attribute table - %1 (%n Feature(s))", "feature count", mMainView->featureCount() ).arg( mLayer->name() ), QgisApp::instance() );
    mDock->setAllowedAreas( Qt::BottomDockWidgetArea | Qt::TopDockWidgetArea );
    mDock->setWidget( this );
    connect( this, SIGNAL( destroyed() ), mDock, SLOT( close() ) );
    QgisApp::instance()->addDockWidget( Qt::BottomDockWidgetArea, mDock );
  }

  columnBoxInit();
  updateTitle();

  mRemoveSelectionButton->setIcon( QgsApplication::getThemeIcon( "/mActionUnselectAttributes.png" ) );
  mSelectedToTopButton->setIcon( QgsApplication::getThemeIcon( "/mActionSelectedToTop.png" ) );
  mCopySelectedRowsButton->setIcon( QgsApplication::getThemeIcon( "/mActionCopySelected.png" ) );
  mZoomMapToSelectedRowsButton->setIcon( QgsApplication::getThemeIcon( "/mActionZoomToSelected.svg" ) );
  mPanMapToSelectedRowsButton->setIcon( QgsApplication::getThemeIcon( "/mActionPanToSelected.svg" ) );
  mInvertSelectionButton->setIcon( QgsApplication::getThemeIcon( "/mActionInvertSelection.png" ) );
  mToggleEditingButton->setIcon( QgsApplication::getThemeIcon( "/mActionToggleEditing.svg" ) );
  mSaveEditsButton->setIcon( QgsApplication::getThemeIcon( "/mActionSaveEdits.svg" ) );
  mDeleteSelectedButton->setIcon( QgsApplication::getThemeIcon( "/mActionDeleteSelected.svg" ) );
  mOpenFieldCalculator->setIcon( QgsApplication::getThemeIcon( "/mActionCalculateField.png" ) );
  mAddAttribute->setIcon( QgsApplication::getThemeIcon( "/mActionNewAttribute.png" ) );
  mRemoveAttribute->setIcon( QgsApplication::getThemeIcon( "/mActionDeleteAttribute.png" ) );
  mTableViewButton->setIcon( QgsApplication::getThemeIcon( "/mActionOpenTable.png" ) );
  mAttributeViewButton->setIcon( QgsApplication::getThemeIcon( "/mActionPropertyItem.png" ) );
  mExpressionSelectButton->setIcon( QgsApplication::getThemeIcon( "/mIconExpressionSelect.svg" ) );
  mAddFeature->setIcon( QgsApplication::getThemeIcon( "/mActionNewTableRow.png" ) );

  // toggle editing
  bool canChangeAttributes = mLayer->dataProvider()->capabilities() & QgsVectorDataProvider::ChangeAttributeValues;
  bool canDeleteFeatures = mLayer->dataProvider()->capabilities() & QgsVectorDataProvider::DeleteFeatures;
  bool canAddAttributes = mLayer->dataProvider()->capabilities() & QgsVectorDataProvider::AddAttributes;
  bool canDeleteAttributes = mLayer->dataProvider()->capabilities() & QgsVectorDataProvider::DeleteAttributes;
  bool canAddFeatures = mLayer->dataProvider()->capabilities() & QgsVectorDataProvider::AddFeatures;

  mToggleEditingButton->blockSignals( true );
  mToggleEditingButton->setCheckable( true );
  mToggleEditingButton->setChecked( mLayer->isEditable() );
  mToggleEditingButton->setEnabled(( canChangeAttributes || canDeleteFeatures || canAddAttributes || canDeleteAttributes || canAddFeatures ) && !mLayer->isReadOnly() );
  mToggleEditingButton->blockSignals( false );

  mSaveEditsButton->setEnabled( mToggleEditingButton->isEnabled() && mLayer->isEditable() );
  mAddAttribute->setEnabled(( canChangeAttributes || canAddAttributes ) && mLayer->isEditable() );
  mDeleteSelectedButton->setEnabled( canDeleteFeatures && mLayer->isEditable() );
  mAddFeature->setEnabled( canAddFeatures && mLayer->isEditable() && mLayer->geometryType() == QGis::NoGeometry );
  mAddFeature->setHidden( !canAddFeatures || mLayer->geometryType() != QGis::NoGeometry );

  mMainViewButtonGroup->setId( mTableViewButton, QgsDualView::AttributeTable );
  mMainViewButtonGroup->setId( mAttributeViewButton, QgsDualView::AttributeEditor );

  // Load default attribute table filter
  QgsAttributeTableFilterModel::FilterMode defaultFilterMode = ( QgsAttributeTableFilterModel::FilterMode ) settings.value( "/qgis/attributeTableBehaviour", QgsAttributeTableFilterModel::ShowAll ).toInt();

  switch ( defaultFilterMode )
  {
    case QgsAttributeTableFilterModel::ShowVisible:
      filterVisible();
      break;

    case QgsAttributeTableFilterModel::ShowSelected:
      filterSelected();
      break;

    case QgsAttributeTableFilterModel::ShowAll:
    default:
      filterShowAll();
      break;
  }

  mFieldModel = new QgsFieldModel();
  mFieldModel->setLayer( mLayer );
  mFieldCombo->setModel( mFieldModel );
  connect( mRunFieldCalc, SIGNAL( clicked() ), this, SLOT( updateFieldFromExpression() ) );
  connect( mRunFieldCalcSelected, SIGNAL( clicked() ), this, SLOT( updateFieldFromExpressionSelected() ) );
  // NW TODO Fix in 2.6 - Doesn't work with field model for some reason.
//  connect( mUpdateExpressionText, SIGNAL( returnPressed() ), this, SLOT( updateFieldFromExpression() ) );
  connect( mUpdateExpressionText, SIGNAL( fieldChanged( QString, bool ) ), this, SLOT( updateButtonStatus( QString, bool ) ) );
  mUpdateExpressionText->setLayer( mLayer );
  mUpdateExpressionText->setLeftHandButtonStyle( true );
  editingToggled();
}
Beispiel #3
0
void MainWindow::initSignalsAndSlots()
{
    //双击表格某单元格,根据该行id,从数据库里读取信息
    connect(ui->tableWidget,SIGNAL(cellDoubleClicked(int,int)),this,SLOT(showText(int,int)));
    connect(ui->tableWidget,SIGNAL(cellClicked(int,int)),this,SLOT(updateTheRightSideBar(int,int)));
    connect(ui->menu_action_add_file,SIGNAL(triggered()),this,SLOT(addFile()));

    connect(ui->menu_action_remove_file,SIGNAL(triggered()),this,SLOT(removeDocument()));
    connect(ui->menu_action_add_category,SIGNAL(triggered()),this,SLOT(addCategory()));
    connect(ui->menu_action_remove_category,SIGNAL(triggered()),this,SLOT(removeCategory()));
    connect(ui->menu_action_change_category,SIGNAL(triggered()),this,SLOT(changeCategory()));
    connect(ui->menu_action_manual_input,SIGNAL(triggered()),this,SLOT(manual_input()));
    connect(ui->menu_action_addto_favorite,SIGNAL(triggered()),this,SLOT(add_to_favorite()));
    connect(ui->menu_action_remove_favorite,SIGNAL(triggered()),this,SLOT(remove_outof_favorite()));
    connect(searchSquare,SIGNAL(returnPressed()),this,SLOT(search()));
    connect(ui->menu_action_about,SIGNAL(triggered()),this,SLOT(about()));

    connect(ui->menu_action_open_file,SIGNAL(triggered()),this,SLOT(openFile()));
}

void MainWindow::showText(int a, int b)
{
    QMessageBox::about(this,"Tsignal",ui->tableWidget->item(a,b)->text());
}

void MainWindow::updateTheRightSideBar(int a, int b)
{
    //QMessageBox::about(this,"Tsignal",ui->tableWidget->item(a,0)->text());
    //先根据该行的id去数据库查询构造pdfobject
    //然后再填充右边的textedit
KoCsvImportDialog::KoCsvImportDialog(QWidget* parent)
    : KDialog(parent)
    , d(new Private(this))
{
    d->dialog = new KoCsvImportWidget(this);
    d->rowsAdjusted = false;
    d->columnsAdjusted = false;
    d->startRow = 0;
    d->startCol = 0;
    d->endRow = -1;
    d->endCol = -1;
    d->textQuote = QChar('"');
    d->delimiter = QString(',');
    d->ignoreDuplicates = false;
    d->codec = QTextCodec::codecForName("UTF-8");

    setButtons( KDialog::Ok|KDialog::Cancel );
    setCaption( i18n( "Import Data" ) );

    QStringList encodings;
    encodings << i18nc( "Descriptive encoding name", "Recommended ( %1 )" ,"UTF-8" );
    encodings << i18nc( "Descriptive encoding name", "Locale ( %1 )" ,QString(QTextCodec::codecForLocale()->name() ));
    encodings += KGlobal::charsets()->descriptiveEncodingNames();
    // Add a few non-standard encodings, which might be useful for text files
    const QString description(i18nc("Descriptive encoding name","Other ( %1 )"));
    encodings << description.arg("Apple Roman"); // Apple
    encodings << description.arg("IBM 850") << description.arg("IBM 866"); // MS DOS
    encodings << description.arg("CP 1258"); // Windows
    d->dialog->comboBoxEncoding->insertItems( 0, encodings );

    setDataTypes(Generic|Text|Date|None);
 
    // XXX:	Qt3->Q4
    //d->dialog->m_sheet->setReadOnly( true );

    d->loadSettings();

    //resize(sizeHint());
    resize( 600, 400 ); // Try to show as much as possible of the table view
    setMainWidget(d->dialog);

    d->dialog->m_sheet->setSelectionMode( QAbstractItemView::MultiSelection );

    QButtonGroup* buttonGroup = new QButtonGroup( this );
    buttonGroup->addButton(d->dialog->m_radioComma, 0);
    buttonGroup->addButton(d->dialog->m_radioSemicolon, 1);
    buttonGroup->addButton(d->dialog->m_radioSpace, 2);
    buttonGroup->addButton(d->dialog->m_radioTab, 3);
    buttonGroup->addButton(d->dialog->m_radioOther, 4);

    connect(d->dialog->m_formatComboBox, SIGNAL(activated( const QString& )),
            this, SLOT(formatChanged( const QString& )));
    connect(buttonGroup, SIGNAL(buttonClicked(int)),
            this, SLOT(delimiterClicked(int)));
    connect(d->dialog->m_delimiterEdit, SIGNAL(returnPressed()),
            this, SLOT(returnPressed()));
    connect(d->dialog->m_delimiterEdit, SIGNAL(textChanged ( const QString & )),
            this, SLOT(genericDelimiterChanged( const QString & ) ));
    connect(d->dialog->m_comboQuote, SIGNAL(activated(const QString &)),
            this, SLOT(textquoteSelected(const QString &)));
    connect(d->dialog->m_sheet, SIGNAL(currentCellChanged(int, int, int, int)),
            this, SLOT(currentCellChanged(int, int)));
    connect(d->dialog->m_ignoreDuplicates, SIGNAL(stateChanged(int)),
            this, SLOT(ignoreDuplicatesChanged(int)));
    connect(d->dialog->m_updateButton, SIGNAL(clicked()),
            this, SLOT(updateClicked()));
    connect(d->dialog->comboBoxEncoding, SIGNAL(textChanged ( const QString & )),
            this, SLOT(encodingChanged ( const QString & ) ));
}
QgsAttributeTableDialog::QgsAttributeTableDialog( QgsVectorLayer *theLayer, QWidget *parent, Qt::WindowFlags flags )
    : QDialog( parent, flags )
    , mDock( nullptr )
    , mLayer( theLayer )
    , mRubberBand( nullptr )
    , mCurrentSearchWidgetWrapper( nullptr )
{
  setupUi( this );

  Q_FOREACH ( const QgsField& field, mLayer->fields() )
  {
    mVisibleFields.append( field.name() );
  }

  // Fix selection color on loosing focus (Windows)
  setStyleSheet( QgisApp::instance()->styleSheet() );

  setAttribute( Qt::WA_DeleteOnClose );

  layout()->setMargin( 0 );
  layout()->setContentsMargins( 0, 0, 0, 0 );
  static_cast< QGridLayout* >( layout() )->setVerticalSpacing( 0 );

  QSettings settings;

  int size = settings.value( "/IconSize", 16 ).toInt();
  if ( size > 32 )
  {
    size -= 16;
  }
  else if ( size == 32 )
  {
    size = 24;
  }
  else
  {
    size = 16;
  }
  mToolbar->setIconSize( QSize( size, size ) );

  // Initialize the window geometry
  restoreGeometry( settings.value( "/Windows/BetterAttributeTable/geometry" ).toByteArray() );

  myDa = new QgsDistanceArea();

  myDa->setSourceCrs( mLayer->crs() );
  myDa->setEllipsoidalMode( QgisApp::instance()->mapCanvas()->mapSettings().hasCrsTransformEnabled() );
  myDa->setEllipsoid( QgsProject::instance()->readEntry( "Measure", "/Ellipsoid", GEO_NONE ) );

  mEditorContext.setDistanceArea( *myDa );
  mEditorContext.setVectorLayerTools( QgisApp::instance()->vectorLayerTools() );

  QgsFeatureRequest r;
  if ( mLayer->geometryType() != QGis::NoGeometry &&
       settings.value( "/qgis/attributeTableBehaviour", QgsAttributeTableFilterModel::ShowAll ).toInt() == QgsAttributeTableFilterModel::ShowVisible )
  {
    QgsMapCanvas *mc = QgisApp::instance()->mapCanvas();
    QgsRectangle extent( mc->mapSettings().mapToLayerCoordinates( theLayer, mc->extent() ) );
    r.setFilterRect( extent );

    QgsGeometry *g = QgsGeometry::fromRect( extent );
    mRubberBand = new QgsRubberBand( mc, QGis::Polygon );
    mRubberBand->setToGeometry( g, theLayer );
    delete g;

    mActionShowAllFilter->setText( tr( "Show All Features In Initial Canvas Extent" ) );
  }

  // Initialize dual view
  mMainView->init( mLayer, QgisApp::instance()->mapCanvas(), r, mEditorContext );

  QgsAttributeTableConfig config = mLayer->attributeTableConfig();
  mMainView->setAttributeTableConfig( config );

  // Initialize filter gui elements
  mFilterActionMapper = new QSignalMapper( this );
  mFilterColumnsMenu = new QMenu( this );
  mActionFilterColumnsMenu->setMenu( mFilterColumnsMenu );
  mApplyFilterButton->setDefaultAction( mActionApplyFilter );

  // Set filter icon in a couple of places
  QIcon filterIcon = QgsApplication::getThemeIcon( "/mActionFilter2.svg" );
  mActionShowAllFilter->setIcon( filterIcon );
  mActionAdvancedFilter->setIcon( filterIcon );
  mActionSelectedFilter->setIcon( filterIcon );
  mActionVisibleFilter->setIcon( filterIcon );
  mActionEditedFilter->setIcon( filterIcon );

  // Connect filter signals
  connect( mActionAdvancedFilter, SIGNAL( triggered() ), SLOT( filterExpressionBuilder() ) );
  connect( mActionShowAllFilter, SIGNAL( triggered() ), SLOT( filterShowAll() ) );
  connect( mActionSelectedFilter, SIGNAL( triggered() ), SLOT( filterSelected() ) );
  connect( mActionVisibleFilter, SIGNAL( triggered() ), SLOT( filterVisible() ) );
  connect( mActionEditedFilter, SIGNAL( triggered() ), SLOT( filterEdited() ) );
  connect( mFilterActionMapper, SIGNAL( mapped( QObject* ) ), SLOT( filterColumnChanged( QObject* ) ) );
  connect( mFilterQuery, SIGNAL( returnPressed() ), SLOT( filterQueryAccepted() ) );
  connect( mActionApplyFilter, SIGNAL( triggered() ), SLOT( filterQueryAccepted() ) );
  connect( mActionSetStyles, SIGNAL( triggered() ), SLOT( openConditionalStyles() ) );

  // info from layer to table
  connect( mLayer, SIGNAL( editingStarted() ), this, SLOT( editingToggled() ) );
  connect( mLayer, SIGNAL( editingStopped() ), this, SLOT( editingToggled() ) );
  connect( mLayer, SIGNAL( layerDeleted() ), this, SLOT( close() ) );
  connect( mLayer, SIGNAL( selectionChanged() ), this, SLOT( updateTitle() ) );
  connect( mLayer, SIGNAL( featureAdded( QgsFeatureId ) ), this, SLOT( updateTitle() ) );
  connect( mLayer, SIGNAL( featuresDeleted( QgsFeatureIds ) ), this, SLOT( updateTitle() ) );
  connect( mLayer, SIGNAL( attributeAdded( int ) ), this, SLOT( columnBoxInit() ) );
  connect( mLayer, SIGNAL( attributeDeleted( int ) ), this, SLOT( columnBoxInit() ) );

  // connect table info to window
  connect( mMainView, SIGNAL( filterChanged() ), this, SLOT( updateTitle() ) );
  connect( mMainView, SIGNAL( filterExpressionSet( QString, QgsAttributeForm::FilterType ) ), this, SLOT( formFilterSet( QString, QgsAttributeForm::FilterType ) ) );
  connect( mMainView, SIGNAL( formModeChanged( QgsAttributeForm::Mode ) ), this, SLOT( viewModeChanged( QgsAttributeForm::Mode ) ) );

  // info from table to application
  connect( this, SIGNAL( saveEdits( QgsMapLayer * ) ), QgisApp::instance(), SLOT( saveEdits( QgsMapLayer * ) ) );

  bool myDockFlag = settings.value( "/qgis/dockAttributeTable", false ).toBool();
  if ( myDockFlag )
  {
    mDock = new QgsAttributeTableDock( tr( "%1 (%n Feature(s))", "feature count", mMainView->featureCount() ).arg( mLayer->name() ), QgisApp::instance() );
    mDock->setWidget( this );
    connect( this, SIGNAL( destroyed() ), mDock, SLOT( close() ) );
    QgisApp::instance()->addDockWidget( Qt::BottomDockWidgetArea, mDock );
  }

  columnBoxInit();
  updateTitle();

  mActionRemoveSelection->setIcon( QgsApplication::getThemeIcon( "/mActionDeselectAll.svg" ) );
  mActionSelectAll->setIcon( QgsApplication::getThemeIcon( "/mActionSelectAll.svg" ) );
  mActionSelectedToTop->setIcon( QgsApplication::getThemeIcon( "/mActionSelectedToTop.svg" ) );
  mActionCopySelectedRows->setIcon( QgsApplication::getThemeIcon( "/mActionEditCopy.svg" ) );
  mActionPasteFeatures->setIcon( QgsApplication::getThemeIcon( "/mActionEditPaste.svg" ) );
  mActionZoomMapToSelectedRows->setIcon( QgsApplication::getThemeIcon( "/mActionZoomToSelected.svg" ) );
  mActionPanMapToSelectedRows->setIcon( QgsApplication::getThemeIcon( "/mActionPanToSelected.svg" ) );
  mActionInvertSelection->setIcon( QgsApplication::getThemeIcon( "/mActionInvertSelection.svg" ) );
  mActionToggleEditing->setIcon( QgsApplication::getThemeIcon( "/mActionToggleEditing.svg" ) );
  mActionSaveEdits->setIcon( QgsApplication::getThemeIcon( "/mActionSaveEdits.svg" ) );
  mActionDeleteSelected->setIcon( QgsApplication::getThemeIcon( "/mActionDeleteSelected.svg" ) );
  mActionOpenFieldCalculator->setIcon( QgsApplication::getThemeIcon( "/mActionCalculateField.svg" ) );
  mActionAddAttribute->setIcon( QgsApplication::getThemeIcon( "/mActionNewAttribute.svg" ) );
  mActionRemoveAttribute->setIcon( QgsApplication::getThemeIcon( "/mActionDeleteAttribute.svg" ) );
  mTableViewButton->setIcon( QgsApplication::getThemeIcon( "/mActionOpenTable.svg" ) );
  mAttributeViewButton->setIcon( QgsApplication::getThemeIcon( "/mActionFormView.svg" ) );
  mActionExpressionSelect->setIcon( QgsApplication::getThemeIcon( "/mIconExpressionSelect.svg" ) );
  mActionAddFeature->setIcon( QgsApplication::getThemeIcon( "/mActionNewTableRow.svg" ) );

  // toggle editing
  bool canChangeAttributes = mLayer->dataProvider()->capabilities() & QgsVectorDataProvider::ChangeAttributeValues;
  bool canDeleteFeatures = mLayer->dataProvider()->capabilities() & QgsVectorDataProvider::DeleteFeatures;
  bool canAddAttributes = mLayer->dataProvider()->capabilities() & QgsVectorDataProvider::AddAttributes;
  bool canDeleteAttributes = mLayer->dataProvider()->capabilities() & QgsVectorDataProvider::DeleteAttributes;
  bool canAddFeatures = mLayer->dataProvider()->capabilities() & QgsVectorDataProvider::AddFeatures;

  mActionToggleEditing->blockSignals( true );
  mActionToggleEditing->setCheckable( true );
  mActionToggleEditing->setChecked( mLayer->isEditable() );
  mActionToggleEditing->setEnabled(( canChangeAttributes || canDeleteFeatures || canAddAttributes || canDeleteAttributes || canAddFeatures ) && !mLayer->readOnly() );
  mActionToggleEditing->blockSignals( false );

  mActionSaveEdits->setEnabled( mActionToggleEditing->isEnabled() && mLayer->isEditable() );
  mActionReload->setEnabled( ! mLayer->isEditable() );
  mActionAddAttribute->setEnabled(( canChangeAttributes || canAddAttributes ) && mLayer->isEditable() );
  mActionRemoveAttribute->setEnabled( canDeleteAttributes && mLayer->isEditable() );
  mActionDeleteSelected->setEnabled( canDeleteFeatures && mLayer->isEditable() );
  if ( !canDeleteFeatures )
    mToolbar->removeAction( mActionDeleteSelected );
  mActionAddFeature->setEnabled( canAddFeatures && mLayer->isEditable() );
  if ( !canAddFeatures )
    mToolbar->removeAction( mActionAddFeature );

  if ( canDeleteFeatures || canAddFeatures )
    mToolbar->insertSeparator( mActionExpressionSelect );

  mMainViewButtonGroup->setId( mTableViewButton, QgsDualView::AttributeTable );
  mMainViewButtonGroup->setId( mAttributeViewButton, QgsDualView::AttributeEditor );

  // Load default attribute table filter
  QgsAttributeTableFilterModel::FilterMode defaultFilterMode = ( QgsAttributeTableFilterModel::FilterMode ) settings.value( "/qgis/attributeTableBehaviour", QgsAttributeTableFilterModel::ShowAll ).toInt();

  switch ( defaultFilterMode )
  {
    case QgsAttributeTableFilterModel::ShowVisible:
      filterVisible();
      break;

    case QgsAttributeTableFilterModel::ShowSelected:
      filterSelected();
      break;

    case QgsAttributeTableFilterModel::ShowAll:
    default:
      filterShowAll();
      break;
  }

  mUpdateExpressionText->registerGetExpressionContextCallback( &_getExpressionContext, mLayer );
  mFieldCombo->setFilters( QgsFieldProxyModel::All | QgsFieldProxyModel::HideReadOnly );
  mFieldCombo->setLayer( mLayer );

  connect( mRunFieldCalc, SIGNAL( clicked() ), this, SLOT( updateFieldFromExpression() ) );
  connect( mRunFieldCalcSelected, SIGNAL( clicked() ), this, SLOT( updateFieldFromExpressionSelected() ) );
  // NW TODO Fix in 2.6 - Doesn't work with field model for some reason.
//  connect( mUpdateExpressionText, SIGNAL( returnPressed() ), this, SLOT( updateFieldFromExpression() ) );
  connect( mUpdateExpressionText, SIGNAL( fieldChanged( QString, bool ) ), this, SLOT( updateButtonStatus( QString, bool ) ) );
  mUpdateExpressionText->setLayer( mLayer );
  mUpdateExpressionText->setLeftHandButtonStyle( true );

  int initialView = settings.value( "/qgis/attributeTableView", -1 ).toInt();
  if ( initialView < 0 )
  {
    initialView = settings.value( "/qgis/attributeTableLastView", QgsDualView::AttributeTable ).toInt();
  }
  mMainView->setView( static_cast< QgsDualView::ViewMode >( initialView ) );
  mMainViewButtonGroup->button( initialView )->setChecked( true );

  connect( mActionToggleMultiEdit, SIGNAL( toggled( bool ) ), mMainView, SLOT( setMultiEditEnabled( bool ) ) );
  connect( mActionSearchForm, SIGNAL( toggled( bool ) ), mMainView, SLOT( toggleSearchMode( bool ) ) );
  updateMultiEditButtonState();

  if ( mLayer->editFormConfig()->layout() == QgsEditFormConfig::UiFileLayout )
  {
    //not supported with custom UI
    mActionToggleMultiEdit->setEnabled( false );
    mActionToggleMultiEdit->setToolTip( tr( "Multiedit is not supported when using custom UI forms" ) );
    mActionSearchForm->setEnabled( false );
    mActionSearchForm->setToolTip( tr( "Search is not supported when using custom UI forms" ) );
  }

  editingToggled();
}
/*!
 * 	// Tab "General"
 */
void XYInterpolationCurveDock::setupGeneral() {
	QWidget* generalTab = new QWidget(ui.tabGeneral);
	uiGeneralTab.setupUi(generalTab);

	QGridLayout* gridLayout = dynamic_cast<QGridLayout*>(generalTab->layout());
	if (gridLayout) {
		gridLayout->setContentsMargins(2,2,2,2);
		gridLayout->setHorizontalSpacing(2);
		gridLayout->setVerticalSpacing(2);
	}

	cbXDataColumn = new TreeViewComboBox(generalTab);
	gridLayout->addWidget(cbXDataColumn, 4, 3, 1, 2);
	cbYDataColumn = new TreeViewComboBox(generalTab);
	gridLayout->addWidget(cbYDataColumn, 5, 3, 1, 2);

	uiGeneralTab.cbType->addItem(i18n("linear"));
	uiGeneralTab.cbType->addItem(i18n("polynomial"));
	uiGeneralTab.cbType->addItem(i18n("cubic spline (natural)"));
	uiGeneralTab.cbType->addItem(i18n("cubic spline (periodic)"));
	uiGeneralTab.cbType->addItem(i18n("Akima-spline (natural)"));
	uiGeneralTab.cbType->addItem(i18n("Akima-spline (periodic)"));
#if GSL_MAJOR_VERSION >= 2
	uiGeneralTab.cbType->addItem(i18n("Steffen spline"));
#endif
	uiGeneralTab.cbType->addItem(i18n("cosine"));
	uiGeneralTab.cbType->addItem(i18n("exponential"));
	uiGeneralTab.cbType->addItem(i18n("piecewise cubic Hermite (PCH)"));
	uiGeneralTab.cbType->addItem(i18n("rational functions"));

	uiGeneralTab.cbVariant->addItem(i18n("finite differences"));
	uiGeneralTab.cbVariant->addItem(i18n("Catmull-Rom"));
	uiGeneralTab.cbVariant->addItem(i18n("cardinal"));
	uiGeneralTab.cbVariant->addItem(i18n("Kochanek-Bartels (TCB)"));

	uiGeneralTab.cbEval->addItem(i18n("function"));
	uiGeneralTab.cbEval->addItem(i18n("derivative"));
	uiGeneralTab.cbEval->addItem(i18n("second derivative"));
	uiGeneralTab.cbEval->addItem(i18n("integral"));

	uiGeneralTab.pbRecalculate->setIcon(KIcon("run-build"));

	QHBoxLayout* layout = new QHBoxLayout(ui.tabGeneral);
	layout->setMargin(0);
	layout->addWidget(generalTab);

	//Slots
	connect( uiGeneralTab.leName, SIGNAL(returnPressed()), this, SLOT(nameChanged()) );
	connect( uiGeneralTab.leComment, SIGNAL(returnPressed()), this, SLOT(commentChanged()) );
	connect( uiGeneralTab.chkVisible, SIGNAL(clicked(bool)), this, SLOT(visibilityChanged(bool)) );

	connect( uiGeneralTab.cbType, SIGNAL(currentIndexChanged(int)), this, SLOT(typeChanged(int)) );
	connect( uiGeneralTab.cbVariant, SIGNAL(currentIndexChanged(int)), this, SLOT(variantChanged(int)) );
	connect( uiGeneralTab.sbTension, SIGNAL(valueChanged(double)), this, SLOT(tensionChanged()) );
	connect( uiGeneralTab.sbContinuity, SIGNAL(valueChanged(double)), this, SLOT(continuityChanged()) );
	connect( uiGeneralTab.sbBias, SIGNAL(valueChanged(double)), this, SLOT(biasChanged()) );
	connect( uiGeneralTab.cbEval, SIGNAL(currentIndexChanged(int)), this, SLOT(evaluateChanged()) );
	connect( uiGeneralTab.sbPoints, SIGNAL(valueChanged(int)), this, SLOT(numberOfPointsChanged()) );

	connect( uiGeneralTab.pbRecalculate, SIGNAL(clicked()), this, SLOT(recalculateClicked()) );
}
Beispiel #7
0
ChannelsJoinDialog::ChannelsJoinDialog(const char * name)
    : QDialog(g_pMainWindow)
{
	setObjectName(name);
	setWindowTitle(__tr2qs("Join Channels - KVIrc"));
	setWindowIcon(*(g_pIconManager->getSmallIcon(KviIconManager::Channel)));

	m_pConsole = nullptr;

	QGridLayout * g = new QGridLayout(this);

	m_pTreeWidget = new ChannelsJoinDialogTreeWidget(this);
	m_pTreeWidget->setHeaderLabel(__tr2qs("Channel"));
	m_pTreeWidget->setRootIsDecorated(true);
	m_pTreeWidget->setSelectionMode(QAbstractItemView::SingleSelection);
	g->addWidget(m_pTreeWidget, 0, 0, 1, 2);

	m_pGroupBox = new KviTalGroupBox(Qt::Horizontal, __tr2qs("Channel"), this);
	QString szMsg = __tr2qs("Name");
	szMsg.append(":");

	new QLabel(szMsg, m_pGroupBox);

	m_pChannelEdit = new QLineEdit(m_pGroupBox);
	connect(m_pChannelEdit, SIGNAL(returnPressed()), this, SLOT(editReturnPressed()));
	connect(m_pChannelEdit, SIGNAL(textChanged(const QString &)), this, SLOT(editTextChanged(const QString &)));

	szMsg = __tr2qs("Password");
	szMsg.append(":");

	new QLabel(szMsg, m_pGroupBox);

	m_pPass = new QLineEdit(m_pGroupBox);
	m_pPass->setEchoMode(QLineEdit::Password);

	g->addWidget(m_pGroupBox, 1, 0, 1, 2);

	KviTalHBox * hb = new KviTalHBox(this);
	hb->setSpacing(4);

	g->addWidget(hb, 2, 0, 1, 2);

	m_pJoinButton = new QPushButton(__tr2qs("&Join"), hb);
	// Join on return pressed
	m_pJoinButton->setDefault(true);
	connect(m_pJoinButton, SIGNAL(clicked()), this, SLOT(joinClicked()));

	m_pRegButton = new QPushButton(__tr2qs("&Register"), hb);
	// Join on return pressed
	connect(m_pRegButton, SIGNAL(clicked()), this, SLOT(regClicked()));

	m_pClearButton = new QPushButton(__tr2qs("Clear Recent"), hb);
	connect(m_pClearButton, SIGNAL(clicked()), this, SLOT(clearClicked()));

	m_pShowAtStartupCheck = new QCheckBox(__tr2qs("Show this window after connecting"), this);
	m_pShowAtStartupCheck->setChecked(KVI_OPTION_BOOL(KviOption_boolShowChannelsJoinOnIrc));
	g->addWidget(m_pShowAtStartupCheck, 3, 0);

	QPushButton * cancelButton = new QPushButton(__tr2qs("Close"), this);
	connect(cancelButton, SIGNAL(clicked()), this, SLOT(cancelClicked()));

	g->addWidget(cancelButton, 3, 1, Qt::AlignRight);

	g->setRowStretch(0, 1);
	g->setColumnStretch(0, 1);

	fillListView();

	if(g_rectChannelsJoinGeometry.y() < 5)
		g_rectChannelsJoinGeometry.setY(5);

	resize(g_rectChannelsJoinGeometry.width(), g_rectChannelsJoinGeometry.height());

	QRect rect = g_pApp->desktop()->screenGeometry(g_pMainWindow);
	move(rect.x() + ((rect.width() - g_rectChannelsJoinGeometry.width()) / 2), rect.y() + ((rect.height() - g_rectChannelsJoinGeometry.height()) / 2));

	enableJoin();
}
Beispiel #8
0
QtLoginWindow::QtLoginWindow(UIEventStream* uiEventStream, SettingsProvider* settings, TimerFactory* timerFactory) : QMainWindow(), settings_(settings), timerFactory_(timerFactory) {
    uiEventStream_ = uiEventStream;

    setWindowTitle("Swift");
#ifndef Q_OS_MAC
#ifdef  Q_OS_WIN32
    setWindowIcon(QIcon(":/logo-icon-16-win.png"));
#else
    setWindowIcon(QIcon(":/logo-icon-16.png"));
#endif
#endif
    QtUtilities::setX11Resource(this, "Main");
    setAccessibleName(tr("Swift Login Window"));
    //setAccessibleDescription(tr("This window is used for providing credentials to log into your XMPP service"));

    resize(200, 500);
    setContentsMargins(0,0,0,0);
    QWidget *centralWidget = new QWidget(this);
    setCentralWidget(centralWidget);
    QBoxLayout *topLayout = new QBoxLayout(QBoxLayout::TopToBottom, centralWidget);
    stack_ = new QStackedWidget(centralWidget);
    topLayout->addWidget(stack_);
    topLayout->setMargin(0);
    loginWidgetWrapper_ = new QWidget(this);
    loginWidgetWrapper_->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
    QBoxLayout *layout = new QBoxLayout(QBoxLayout::TopToBottom, loginWidgetWrapper_);
    layout->addStretch(2);

    QLabel* logo = new QLabel(this);
    QIcon swiftWithTextLogo = QIcon(":/logo-shaded-text.png");
    logo->setPixmap(swiftWithTextLogo.pixmap(QSize(192,192)));

    QWidget *logoWidget = new QWidget(this);
    QHBoxLayout *logoLayout = new QHBoxLayout();
    logoLayout->setMargin(0);
    logoLayout->addStretch(0);
    logoLayout->addWidget(logo);
    logoLayout->addStretch(0);
    logoWidget->setLayout(logoLayout);
    layout->addWidget(logoWidget);

    layout->addStretch(2);

    QLabel* jidLabel = new QLabel(this);
    jidLabel->setText("<font size='-1'>" + tr("User address:") + "</font>");
    layout->addWidget(jidLabel);


    username_ = new QComboBox(this);
    username_->setEditable(true);
    username_->setWhatsThis(tr("User address - looks like [email protected]"));
    username_->setToolTip(tr("User address - looks like [email protected]"));
    username_->view()->installEventFilter(this);
    username_->setAccessibleName(tr("User address (of the form [email protected])"));
    username_->setAccessibleDescription(tr("This is the user address that you'll be using to log in with"));
    layout->addWidget(username_);
    QLabel* jidHintLabel = new QLabel(this);
    jidHintLabel->setText("<font size='-1' color='grey' >" + tr("Example: [email protected]") + "</font>");
    jidHintLabel->setAlignment(Qt::AlignRight);
    layout->addWidget(jidHintLabel);


    QLabel* passwordLabel = new QLabel();
    passwordLabel->setText("<font size='-1'>" + tr("Password:"******"</font>");
    passwordLabel->setAccessibleName(tr("User password"));
    passwordLabel->setAccessibleDescription(tr("This is the password you'll use to log in to the XMPP service"));
    layout->addWidget(passwordLabel);


    QWidget* w = new QWidget(this);
    w->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
    layout->addWidget(w);

    QHBoxLayout* credentialsLayout = new QHBoxLayout(w);
    credentialsLayout->setMargin(0);
    credentialsLayout->setSpacing(3);
    password_ = new QLineEdit(this);
    password_->setEchoMode(QLineEdit::Password);
    connect(password_, SIGNAL(returnPressed()), this, SLOT(loginClicked()));
    connect(username_->lineEdit(), SIGNAL(returnPressed()), password_, SLOT(setFocus()));
    connect(username_, SIGNAL(editTextChanged(const QString&)), this, SLOT(handleUsernameTextChanged()));
    credentialsLayout->addWidget(password_);

    certificateButton_ = new QToolButton(this);
    certificateButton_->setCheckable(true);
    certificateButton_->setIcon(QIcon(":/icons/certificate.png"));
    certificateButton_->setToolTip(tr("Click if you have a personal certificate used for login to the service."));
    certificateButton_->setWhatsThis(tr("Click if you have a personal certificate used for login to the service."));
    certificateButton_->setAccessibleName(tr("Login with certificate"));
    certificateButton_->setAccessibleDescription(tr("Click if you have a personal certificate used for login to the service."));

    credentialsLayout->addWidget(certificateButton_);
    connect(certificateButton_, SIGNAL(clicked(bool)), SLOT(handleCertficateChecked(bool)));

    loginButton_ = new QPushButton(this);
    loginButton_->setText(tr("Connect"));
    loginButton_->setAutoDefault(true);
    loginButton_->setDefault(true);
    loginButton_->setAccessibleName(tr("Connect now"));
    layout->addWidget(loginButton_);

    QLabel* connectionOptionsLabel = new QLabel(this);
    connectionOptionsLabel->setText("<a href=\"#\"><font size='-1'>" + QObject::tr("Connection Options") + "</font></a>");
    connectionOptionsLabel->setTextFormat(Qt::RichText);
    connectionOptionsLabel->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
    layout->addWidget(connectionOptionsLabel);
    connect(connectionOptionsLabel, SIGNAL(linkActivated(const QString&)), SLOT(handleOpenConnectionOptions()));

    message_ = new QLabel(this);
    message_->setTextFormat(Qt::RichText);
    message_->setWordWrap(true);
    layout->addWidget(message_);

    layout->addStretch(2);
    remember_ = new QCheckBox(tr("Remember Password?"), this);
    layout->addWidget(remember_);
    loginAutomatically_ = new QCheckBox(tr("Login Automatically?"), this);
    layout->addWidget(loginAutomatically_);

    connect(loginButton_, SIGNAL(clicked()), SLOT(loginClicked()));
    stack_->addWidget(loginWidgetWrapper_);
#ifdef SWIFTEN_PLATFORM_MACOSX
    menuBar_ = new QMenuBar(nullptr);
#else
    menuBar_ = menuBar();
#endif
    QApplication::setQuitOnLastWindowClosed(false);

    swiftMenu_ = new QMenu(tr("&Swift"), this);
#ifdef SWIFTEN_PLATFORM_MACOSX
    generalMenu_ = new QMenu(tr("&General"), this);
#else
    generalMenu_ = swiftMenu_;
#endif

#ifdef SWIFTEN_PLATFORM_MACOSX
    QAction* aboutAction = new QAction(QString("&About %1").arg("Swift"), this);
#else
    QAction* aboutAction = new QAction(QString(tr("&About %1")).arg("Swift"), this);
#endif
    connect(aboutAction, SIGNAL(triggered()), SLOT(handleAbout()));
    swiftMenu_->addAction(aboutAction);

    xmlConsoleAction_ = new QAction(tr("&Show Debug Console"), this);
    connect(xmlConsoleAction_, SIGNAL(triggered()), SLOT(handleShowXMLConsole()));
    generalMenu_->addAction(xmlConsoleAction_);

#ifdef SWIFT_EXPERIMENTAL_FT
    fileTransferOverviewAction_ = new QAction(tr("Show &File Transfer Overview"), this);
    connect(fileTransferOverviewAction_, SIGNAL(triggered()), SLOT(handleShowFileTransferOverview()));
    generalMenu_->addAction(fileTransferOverviewAction_);
#endif

    highlightEditorAction_ = new QAction(tr("&Edit Highlight Rules"), this);
    connect(highlightEditorAction_, SIGNAL(triggered()), SLOT(handleShowHighlightEditor()));
    generalMenu_->addAction(highlightEditorAction_);

    toggleSoundsAction_ = new QAction(tr("&Play Sounds"), this);
    toggleSoundsAction_->setCheckable(true);
    toggleSoundsAction_->setChecked(settings_->getSetting(SettingConstants::PLAY_SOUNDS));
    connect(toggleSoundsAction_, SIGNAL(toggled(bool)), SLOT(handleToggleSounds(bool)));
    generalMenu_->addAction(toggleSoundsAction_);

    toggleNotificationsAction_ = new QAction(tr("Display Pop-up &Notifications"), this);
    toggleNotificationsAction_->setCheckable(true);
    toggleNotificationsAction_->setChecked(settings_->getSetting(SettingConstants::SHOW_NOTIFICATIONS));
    connect(toggleNotificationsAction_, SIGNAL(toggled(bool)), SLOT(handleToggleNotifications(bool)));

#ifndef SWIFTEN_PLATFORM_MACOSX
    swiftMenu_->addSeparator();
#endif

#ifdef SWIFTEN_PLATFORM_MACOSX
    QAction* quitAction = new QAction("&Quit", this);
#else
    QAction* quitAction = new QAction(tr("&Quit"), this);
#endif
    connect(quitAction, SIGNAL(triggered()), SLOT(handleQuit()));
    swiftMenu_->addAction(quitAction);

    setInitialMenus();
    settings_->onSettingChanged.connect(boost::bind(&QtLoginWindow::handleSettingChanged, this, _1));

    bool eagle = settings_->getSetting(SettingConstants::FORGET_PASSWORDS);
    remember_->setEnabled(!eagle);
    loginAutomatically_->setEnabled(!eagle);
    xmlConsoleAction_->setEnabled(!eagle);
    if (eagle) {
        remember_->setChecked(false);
        loginAutomatically_->setChecked(false);
    }

#ifdef SWIFTEN_PLATFORM_MACOSX
    // Temporary workaround for case 501. Could be that this code is still
    // needed when Qt provides a proper fix
    qApp->installEventFilter(this);
#endif


    this->show();
}
int Q3IconView::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = Q3ScrollView::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: selectionChanged(); break;
        case 1: selectionChanged((*reinterpret_cast< Q3IconViewItem*(*)>(_a[1]))); break;
        case 2: currentChanged((*reinterpret_cast< Q3IconViewItem*(*)>(_a[1]))); break;
        case 3: clicked((*reinterpret_cast< Q3IconViewItem*(*)>(_a[1]))); break;
        case 4: clicked((*reinterpret_cast< Q3IconViewItem*(*)>(_a[1])),(*reinterpret_cast< const QPoint(*)>(_a[2]))); break;
        case 5: pressed((*reinterpret_cast< Q3IconViewItem*(*)>(_a[1]))); break;
        case 6: pressed((*reinterpret_cast< Q3IconViewItem*(*)>(_a[1])),(*reinterpret_cast< const QPoint(*)>(_a[2]))); break;
        case 7: doubleClicked((*reinterpret_cast< Q3IconViewItem*(*)>(_a[1]))); break;
        case 8: returnPressed((*reinterpret_cast< Q3IconViewItem*(*)>(_a[1]))); break;
        case 9: rightButtonClicked((*reinterpret_cast< Q3IconViewItem*(*)>(_a[1])),(*reinterpret_cast< const QPoint(*)>(_a[2]))); break;
        case 10: rightButtonPressed((*reinterpret_cast< Q3IconViewItem*(*)>(_a[1])),(*reinterpret_cast< const QPoint(*)>(_a[2]))); break;
        case 11: mouseButtonPressed((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< Q3IconViewItem*(*)>(_a[2])),(*reinterpret_cast< const QPoint(*)>(_a[3]))); break;
        case 12: mouseButtonClicked((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< Q3IconViewItem*(*)>(_a[2])),(*reinterpret_cast< const QPoint(*)>(_a[3]))); break;
        case 13: contextMenuRequested((*reinterpret_cast< Q3IconViewItem*(*)>(_a[1])),(*reinterpret_cast< const QPoint(*)>(_a[2]))); break;
        case 14: dropped((*reinterpret_cast< QDropEvent*(*)>(_a[1])),(*reinterpret_cast< const Q3ValueList<Q3IconDragItem>(*)>(_a[2]))); break;
        case 15: moved(); break;
        case 16: onItem((*reinterpret_cast< Q3IconViewItem*(*)>(_a[1]))); break;
        case 17: onViewport(); break;
        case 18: itemRenamed((*reinterpret_cast< Q3IconViewItem*(*)>(_a[1])),(*reinterpret_cast< const QString(*)>(_a[2]))); break;
        case 19: itemRenamed((*reinterpret_cast< Q3IconViewItem*(*)>(_a[1]))); break;
        case 20: arrangeItemsInGrid((*reinterpret_cast< const QSize(*)>(_a[1])),(*reinterpret_cast< bool(*)>(_a[2]))); break;
        case 21: arrangeItemsInGrid((*reinterpret_cast< const QSize(*)>(_a[1]))); break;
        case 22: arrangeItemsInGrid((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 23: arrangeItemsInGrid(); break;
        case 24: setContentsPos((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break;
        case 25: updateContents(); break;
        case 26: doAutoScroll(); break;
        case 27: adjustItems(); break;
        case 28: slotUpdate(); break;
        case 29: movedContents((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break;
        }
        _id -= 30;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< bool*>(_v) = sorting(); break;
        case 1: *reinterpret_cast< bool*>(_v) = sortDirection(); break;
        case 2: *reinterpret_cast< SelectionMode*>(_v) = selectionMode(); break;
        case 3: *reinterpret_cast< int*>(_v) = gridX(); break;
        case 4: *reinterpret_cast< int*>(_v) = gridY(); break;
        case 5: *reinterpret_cast< int*>(_v) = spacing(); break;
        case 6: *reinterpret_cast< ItemTextPos*>(_v) = itemTextPos(); break;
        case 7: *reinterpret_cast< QBrush*>(_v) = itemTextBackground(); break;
        case 8: *reinterpret_cast< Arrangement*>(_v) = arrangement(); break;
        case 9: *reinterpret_cast< ResizeMode*>(_v) = resizeMode(); break;
        case 10: *reinterpret_cast< int*>(_v) = maxItemWidth(); break;
        case 11: *reinterpret_cast< int*>(_v) = maxItemTextLength(); break;
        case 12: *reinterpret_cast< bool*>(_v) = autoArrange(); break;
        case 13: *reinterpret_cast< bool*>(_v) = itemsMovable(); break;
        case 14: *reinterpret_cast< bool*>(_v) = wordWrapIconText(); break;
        case 15: *reinterpret_cast< bool*>(_v) = showToolTips(); break;
        case 16: *reinterpret_cast< uint*>(_v) = count(); break;
        }
        _id -= 17;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 2: setSelectionMode(*reinterpret_cast< SelectionMode*>(_v)); break;
        case 3: setGridX(*reinterpret_cast< int*>(_v)); break;
        case 4: setGridY(*reinterpret_cast< int*>(_v)); break;
        case 5: setSpacing(*reinterpret_cast< int*>(_v)); break;
        case 6: setItemTextPos(*reinterpret_cast< ItemTextPos*>(_v)); break;
        case 7: setItemTextBackground(*reinterpret_cast< QBrush*>(_v)); break;
        case 8: setArrangement(*reinterpret_cast< Arrangement*>(_v)); break;
        case 9: setResizeMode(*reinterpret_cast< ResizeMode*>(_v)); break;
        case 10: setMaxItemWidth(*reinterpret_cast< int*>(_v)); break;
        case 11: setMaxItemTextLength(*reinterpret_cast< int*>(_v)); break;
        case 12: setAutoArrange(*reinterpret_cast< bool*>(_v)); break;
        case 13: setItemsMovable(*reinterpret_cast< bool*>(_v)); break;
        case 14: setWordWrapIconText(*reinterpret_cast< bool*>(_v)); break;
        case 15: setShowToolTips(*reinterpret_cast< bool*>(_v)); break;
        }
        _id -= 17;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 17;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 17;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 17;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 17;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 17;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 17;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
Beispiel #10
0
PmQuery::PmQuery(bool inputflag, bool printflag, bool noframeflag,
		 bool nosliderflag, bool usesliderflag, bool exclusiveflag)
    : QDialog()
{
    QHBoxLayout *hboxLayout;
    QVBoxLayout *vboxLayout;
    QSpacerItem *spacerItem;
    QSpacerItem *spacerItem1;
    QVBoxLayout *vboxLayout1;
    QHBoxLayout *hboxLayout1;
    QSpacerItem *spacerItem2;

    QString filename;
    if (iconic == HOST_ICON)
	filename = tr(":images/dialog-host.png");
    else if (iconic == ERROR_ICON)
	filename = tr(":images/dialog-error.png");
    else if (iconic == WARNING_ICON)
	filename = tr(":images/dialog-warning.png");
    else if (iconic == ARCHIVE_ICON)
	filename = tr(":images/dialog-archive.png");
    else if (iconic == QUESTION_ICON)
	filename = tr(":images/dialog-question.png");
    else // (iconic == INFO_ICON)
	filename = tr(":images/dialog-information.png");

    QIcon	icon(filename);
    QPixmap	pixmap(filename);
    setWindowIcon(icon);
    setWindowTitle(tr(title));

    QGridLayout *gridLayout = new QGridLayout(this);
    gridLayout->setSpacing(6);
    gridLayout->setMargin(9);
    hboxLayout = new QHBoxLayout();
    hboxLayout->setSpacing(6);
    hboxLayout->setMargin(0);
    vboxLayout = new QVBoxLayout();
    vboxLayout->setSpacing(6);
    vboxLayout->setMargin(0);
    spacerItem = new QSpacerItem(20, 2, QSizePolicy::Minimum,
					QSizePolicy::Expanding);

    vboxLayout->addItem(spacerItem);

    QLabel *imageLabel = new QLabel(this);
    imageLabel->setPixmap(pixmap);

    vboxLayout->addWidget(imageLabel);

    spacerItem1 = new QSpacerItem(20, 20, QSizePolicy::Minimum,
					  QSizePolicy::Expanding);

    vboxLayout->addItem(spacerItem1);
    hboxLayout->addLayout(vboxLayout);
    vboxLayout1 = new QVBoxLayout();
    vboxLayout1->setSpacing(6);
    vboxLayout1->setMargin(0);

    int height;
    int width = DEFAULT_EDIT_WIDTH; 

    QLineEdit* lineEdit = NULL;
    QTextEdit* textEdit = NULL;
    if (inputflag && messagecount <= 1) {
	lineEdit = new QLineEdit(this);
	if (messagecount == 1)
	    lineEdit->setText(tr(messages[0]));
	height = lineEdit->font().pointSize() + 4;
	if (height < 0)
	    height = lineEdit->font().pixelSize() + 4;
	if (height < 0)
	    height = lineEdit->heightForWidth(width) + 4;
	lineEdit->setSizePolicy(QSizePolicy::MinimumExpanding,
				QSizePolicy::Fixed);
	lineEdit->setMinimumSize(QSize(width, height));
	lineEdit->setGeometry(QRect(0, 0, width, height));
	vboxLayout1->addWidget(lineEdit);
    }
    else {
	QFont	fixed("monospace");
	fixed.setStyleHint(QFont::TypeWriter);

	textEdit = new QTextEdit(this);
	textEdit->setFont(fixed);
	textEdit->setLineWrapMode(QTextEdit::FixedColumnWidth);
	textEdit->setLineWrapColumnOrWidth(80);
	textEdit->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	if (nosliderflag)
	    textEdit->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	else if (usesliderflag)
	    textEdit->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
	else
	    textEdit->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
	for (int m = 0; m < messagecount; m++)
	    textEdit->append(tr(messages[m]));
	if (inputflag)
	    textEdit->setReadOnly(FALSE);
	else {
	    textEdit->setLineWidth(1);
	    textEdit->setFrameStyle(noframeflag ? QFrame::NoFrame :
				    QFrame::Box | QFrame::Sunken);
	    textEdit->setReadOnly(TRUE);
	}
	if (usesliderflag)
	    height = DEFAULT_EDIT_HEIGHT;
	else {
	    height = textEdit->font().pointSize() + 4;
	    if (height < 0)
		height = textEdit->font().pixelSize() + 4;
	    if (height < 0)
	        height = textEdit->heightForWidth(width) + 4;
	    height *= messagecount;
	}
	textEdit->setMinimumSize(QSize(width, height));
	textEdit->setSizePolicy(QSizePolicy::MinimumExpanding,
				QSizePolicy::MinimumExpanding);
	textEdit->moveCursor(QTextCursor::Start);
	textEdit->ensureCursorVisible();
	vboxLayout1->addWidget(textEdit);
    }

    hboxLayout1 = new QHBoxLayout();
    hboxLayout1->setSpacing(6);
    hboxLayout1->setMargin(0);
    spacerItem2 = new QSpacerItem(40, 20, QSizePolicy::Expanding,
					  QSizePolicy::Minimum);
    hboxLayout1->addItem(spacerItem2);

    for (int i = 0; i < buttoncount; i++) {
	QueryButton *button = new QueryButton(printflag, this);
	button->setMinimumSize(QSize(72, 32));
	button->setDefault(buttons[i] == defaultbutton);
	button->setQuery(this);
	button->setText(tr(buttons[i]));
	button->setStatus(statusi[i]);
	if (inputflag && buttons[i] == defaultbutton) {
	    if (textEdit) 
		button->setEditor(textEdit);
	    else if (lineEdit) {
		button->setEditor(lineEdit);
		if (buttons[i] == defaultbutton)
		    connect(lineEdit, SIGNAL(returnPressed()),
			    button, SLOT(click()));
	    }
	}
	connect(button, SIGNAL(clicked()), this, SLOT(buttonClicked()));
	hboxLayout1->addWidget(button);
    }

    vboxLayout1->addLayout(hboxLayout1);
    hboxLayout->addLayout(vboxLayout1);
    gridLayout->addLayout(hboxLayout, 0, 0, 1, 1);
    gridLayout->setSizeConstraint(QLayout::SetFixedSize);

    if (inputflag && messagecount <= 1)
	resize(QSize(320, 83));
    else
	resize(QSize(320, 132));

    if (timeout)
	startTimer(timeout * 1000);

    if (exclusiveflag)
	setWindowModality(Qt::WindowModal);
}
Beispiel #11
0
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent), ui(new Ui::MainWindow)
{

    // NOTE: these dataextractors are deleted by
    // routecontainer class instance.
    dataExtractor = new bacra::DataExtractor();
    dataExtractor->initialize();
    dataExtractor2 = new bacra::DataExtractor();
    dataExtractor2->initialize();


    routeContainer = new bacra::RouteContainer(dataExtractor, this);
    stopContainer = new bacra::RouteContainer(dataExtractor2, this);
    stopDelegate = new bacra::StopDelegate(this);
    routeDelegate = new bacra::StopDelegate(this);



    ui->setupUi(this);



    QRegExp rx("\\d{0,6}");
    QValidator *validator = new QRegExpValidator(rx, this);
    ui->stopLineEdit->setValidator(validator);

    ui->routesView->setModel(routeContainer);
    ui->routesView->setItemDelegate(new bacra::StopDelegate());

    ui->stopsView->setModel(stopContainer);
    ui->stopsView->setItemDelegate(new bacra::StopDelegate());

    ui->tab_2->setDisabled(true);

    ui->progressBar->setVisible(false);

    //ui->stopsView->setStyleSheet("QTableView {background: url(:/bacra/images/bacra.png); background-attachment: fixed; background-position: bottom-center;}");
    //ui->departuresView->setStyleSheet("QTableView {background: url(:/bacra/images/bacra.png); background-attachment: fixed; background-position: bottom-center;}");
    //ui->routesView->setStyleSheet("QTableView {background: url(:/bacra/images/bacra.png); background-attachment: fixed; background-position: bottom-center;}");
    ui->addStopButton->setIcon(QIcon(":/bacra/images/add.png"));

    ui->stopsView->setDragEnabled(true);
    ui->stopsView->setAcceptDrops(true);

    connect(stopContainer, SIGNAL(updatedDepartures()), ui->departuresView, SLOT(setFocus()));

    connect(dataExtractor, SIGNAL(infoResponseReady(int)), ui->progressBar, SLOT(setValue(int)));
    connect(dataExtractor2, SIGNAL(infoResponseReady(int)), ui->progressBar, SLOT(setValue(int)));

    connect(ui->tabWidget, SIGNAL(currentChanged(int)), this, SLOT(commercialAnnouncement(int)));

    connect(ui->fromLineEdit, SIGNAL(returnPressed()), ui->toLineEdit, SLOT(setFocus()));
    connect(ui->toLineEdit, SIGNAL(returnPressed()), ui->addRouteButton, SLOT(click()));
    connect(ui->addRouteButton, SIGNAL(clicked()), this, SLOT(addRouteClicked()));
    connect(this, SIGNAL(addRoute(QString, QString)), routeContainer, SLOT(addRouteItem(QString, QString)));

    connect(ui->stopLineEdit, SIGNAL(returnPressed()), ui->addStopButton, SLOT(click()));
    connect(ui->addStopButton, SIGNAL(clicked()), this, SLOT(addStopClicked()));
    connect(this, SIGNAL(addStop(QString)), stopContainer, SLOT(addStopItem(QString)));
    connect(ui->stopsView, SIGNAL(clicked(QModelIndex)), stopContainer, SLOT(indexSelected(QModelIndex)));
    connect(ui->routesView, SIGNAL(clicked(QModelIndex)), routeContainer, SLOT(indexSelected(QModelIndex)));

    connect(ui->updateButton, SIGNAL(clicked()), this, SLOT(updateDepartures()));
    
    connect(stopContainer, SIGNAL(dataChanged(QModelIndex,QModelIndex)), ui->stopsView, SLOT(dataChanged(QModelIndex,QModelIndex)));

    connect(routeContainer, SIGNAL(routeAdded()), this, SLOT(routeAdded()));
    connect(stopContainer, SIGNAL(stopAdded()), this, SLOT(stopAdded()));

    connect(stopContainer, SIGNAL(showDepartures(bacra::Route*)), this, SLOT(showDepartures(bacra::Route*)));

    connect(stopContainer, SIGNAL(invalidStop()), this, SLOT(invalidStop()));
    connect(routeContainer, SIGNAL(invalidRoute()), this, SLOT(invalidRoute()));

     //Loading routes from disk
     //setting ui so loaded stops display themselves
    //correctly
//    ui->stopsView->setColumnWidth(0, 170);
 //   ui->stopsView->setColumnWidth(1, 40);
    ui->stopsView->setColumnWidth(0, 180);
    ui->stopsView->setColumnWidth(1, 30);
    stopContainer->loadRoutes("./savedata.txt");
}
LineEditProxy::LineEditProxy(QLineEdit* line_edit)
  : m_line_edit(line_edit)
{
    connect(m_line_edit, SIGNAL(returnPressed()), SIGNAL(signal_changed()));
}
ColorExpressionProxy::ColorExpressionProxy(QLineEdit* line_edit, QToolButton* picker_button)
  : m_line_edit(line_edit)
  , m_picker_button(picker_button)
{
    connect(m_line_edit, SIGNAL(returnPressed()), SIGNAL(signal_changed()));
}
Beispiel #14
0
KviIrcViewToolWidget::KviIrcViewToolWidget(KviIrcView * pParent)
: QWidget(pParent)
{
	m_pIrcView = pParent;
	setAutoFillBackground(true);
	setContentsMargins(0,0,0,0);

	QHBoxLayout * pLayout = new QHBoxLayout(this);
	pLayout->setMargin(2);
	pLayout->setSpacing(2);

	QPushButton * pButton = new QPushButton(QIcon(*g_pIconManager->getSmallIcon(KviIconManager::Close)), QString(),this);
	pButton->setFixedSize(16,16);
	pButton->setFlat(true);
	connect(pButton,SIGNAL(clicked()),m_pIrcView,SLOT(toggleToolWidget()));
	pLayout->addWidget(pButton);

	m_pStringToFind = new KviThemedLineEdit(this, m_pIrcView->parentKviWindow(), "search_lineedit");
	pLayout->addWidget(m_pStringToFind);
	connect(m_pStringToFind,SIGNAL(returnPressed()),this,SLOT(findNext()));
	connect(m_pStringToFind,SIGNAL(textChanged(QString)),this,SLOT(findNextHelper(QString)));

	pButton = new QPushButton(__tr2qs("&Next"),this);
	pButton->setDefault(true);
	connect(pButton,SIGNAL(clicked()),this,SLOT(findNext()));
	pLayout->addWidget(pButton);

	pButton = new QPushButton(__tr2qs("&Previous"),this);
	connect(pButton,SIGNAL(clicked()),this,SLOT(findPrev()));
	pLayout->addWidget(pButton);

	m_pOptionsButton = new QPushButton(this);
	m_pOptionsButton->setText(__tr2qs("&Options"));
	pLayout->addWidget(m_pOptionsButton);

	m_pOptionsWidget = new QMenu(m_pOptionsButton);
	QGridLayout * pOptionsLayout = new QGridLayout(m_pOptionsWidget);
	pOptionsLayout->setSpacing(2);

	connect(m_pOptionsButton, SIGNAL(clicked()), this, SLOT(toggleOptions()));

	// Filter tab

	QLabel * pLabel = new QLabel(__tr2qs("Message types"), m_pOptionsWidget);
	pOptionsLayout->addWidget(pLabel,0,0,1,2);

	m_pFilterView = new QTreeWidget(m_pOptionsWidget);
	m_pFilterView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	m_pFilterView->setRootIsDecorated(false);
	//FIXME hardcoded size sucks
	m_pFilterView->setMinimumSize(QSize(200,150));
	m_pFilterView->setColumnCount(1);
	m_pFilterView->header()->hide();
	pOptionsLayout->addWidget(m_pFilterView,1,0,4,2);

	m_pFilterItems = (KviIrcMessageCheckListItem **)KviMemory::allocate(KVI_NUM_MSGTYPE_OPTIONS * sizeof(KviIrcMessageCheckListItem *));

	for(int i=0;i<KVI_NUM_MSGTYPE_OPTIONS;i++)
	{
		m_pFilterItems[i] = new KviIrcMessageCheckListItem(m_pFilterView,this,i);
	}

	pButton = new QPushButton(__tr2qs("Set &All"),m_pOptionsWidget);
	connect(pButton,SIGNAL(clicked()),this,SLOT(filterEnableAll()));
	pOptionsLayout->addWidget(pButton,6,0);

	pButton = new QPushButton(__tr2qs("Set &None"),m_pOptionsWidget);
	connect(pButton,SIGNAL(clicked()),this,SLOT(filterEnableNone()));
	pOptionsLayout->addWidget(pButton,6,1);

	pButton = new QPushButton(__tr2qs("&Load From..."),m_pOptionsWidget);
	connect(pButton,SIGNAL(clicked()),this,SLOT(filterLoad()));
	pOptionsLayout->addWidget(pButton,7,0);

	pButton = new QPushButton(__tr2qs("&Save As..."),m_pOptionsWidget);
	connect(pButton,SIGNAL(clicked()),this,SLOT(filterSave()));
	pOptionsLayout->addWidget(pButton,7,1);

	pLabel = new QLabel(__tr2qs("Pattern:"),m_pOptionsWidget);
	pOptionsLayout->addWidget(pLabel,8,0);
	m_pSearchMode = new QComboBox(m_pOptionsWidget);
    m_pSearchMode->insertItem(PlainText, __tr2qs("Plain Text"));
    m_pSearchMode->insertItem(Wildcards, __tr2qs("Wildcards"));
    m_pSearchMode->insertItem(RegExp, __tr2qs("RegExp"));
	pOptionsLayout->addWidget(m_pSearchMode,8,1);

	pLabel = new QLabel(__tr2qs("Match:"),m_pOptionsWidget);
	pOptionsLayout->addWidget(pLabel,9,0);

	m_pCaseSensitive = new QCheckBox(__tr2qs("&Case sensitive"),m_pOptionsWidget);
	pOptionsLayout->addWidget(m_pCaseSensitive,9,1);

// 	m_pFindResult = new QLabel(this);
// 	m_pFindResult->setFrameStyle(QFrame::Sunken | QFrame::StyledPanel);
// 	pOptionsLayout->addWidget(m_pFindResult,0,6);

	// Focussing the 'string to find' widget has been moved to the toggle function so that it happens whenever the widget is shown

	KviShortcut::create(Qt::Key_Escape,m_pIrcView,SLOT(toggleToolWidget()),0,Qt::WidgetWithChildrenShortcut);
	KviShortcut::create(KVI_SHORTCUTS_WIN_SEARCH,m_pIrcView,SLOT(toggleToolWidget()),0,Qt::WidgetWithChildrenShortcut);
}
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();
}
Beispiel #16
0
TodoView::TodoView(CalObject *cal, QWidget *parent, const char *name)
    : KTabListBox(parent, name, 5)
{
  calendar = cal;
  // set up filter for events
  lbox.installEventFilter(this);
  // set up the widget to have 4 columns (one hidden), and
  // only a vertical scrollbar
  clearTableFlags(Tbl_hScrollBar);
  clearTableFlags(Tbl_autoHScrollBar);
  // BL: autoscrollbar in not working...
  setTableFlags(Tbl_hScrollBar);
  setAutoUpdate(TRUE);
  adjustColumns();
  // insert pictures for use to show a checked/not checked todo
  dict().insert("CHECKED", new QPixmap(Icon("checkedbox.xpm")));
  dict().insert("EMPTY", new QPixmap(Icon("emptybox.xpm")));
  dict().insert("CHECKEDMASK", new QPixmap(Icon("checkedbox-mask.xpm")));
  dict().insert("EMPTYMASK", new QPixmap(Icon("emptybox-mask.xpm")));

  // this is the thing that lets you edit the todo text.
  editor = new QLineEdit(this);
  editor->hide();
  connect(editor, SIGNAL(returnPressed()),
	  this, SLOT(updateSummary()));
  connect(editor, SIGNAL(returnPressed()),
	  editor, SLOT(hide()));
  connect(editor, SIGNAL(textChanged(const char *)),
	  this, SLOT(changeSummary(const char *)));
  
  connect(this, SIGNAL(selected(int, int)),
    	  this, SLOT(updateItem(int, int)));
  connect(this, SIGNAL(highlighted(int, int)),
	  this, SLOT(hiliteAction(int, int)));

  priList = new QListBox(this);
  priList->hide();
  priList->insertItem("1");
  priList->insertItem("2");
  priList->insertItem("3");
  priList->insertItem("4");
  priList->insertItem("5");
  priList->setFixedHeight(priList->itemHeight()*5+5);
  priList->setFixedWidth(priList->maxItemWidth()+5);
  connect(priList, SIGNAL(highlighted(int)),
	  priList, SLOT(hide()));
  connect(priList, SIGNAL(highlighted(int)),
	  this, SLOT(changePriority(int)));

  QPixmap pixmap;
  rmbMenu1 = new QPopupMenu;
  pixmap = Icon("checkedbox.xpm");
  rmbMenu1->insertItem(pixmap, i18n("New Todo"), this,
		       SLOT(newTodo()));
  pixmap = Icon("delete.xpm");
  rmbMenu1->insertItem(pixmap, i18n("Purge Completed "), this,
		       SLOT(purgeCompleted()));

  rmbMenu2 = new QPopupMenu;
  pixmap = Icon("checkedbox.xpm");
  rmbMenu2->insertItem(pixmap, i18n("New Todo"), this,
		     SLOT (newTodo()));
  rmbMenu2->insertItem(i18n("Edit Todo"), this,
		     SLOT (editTodo()));
  pixmap = Icon("delete.xpm");
  rmbMenu2->insertItem(pixmap, i18n("Delete Todo"), this,
		     SLOT (deleteTodo()));
  rmbMenu2->insertItem(i18n("Purge Completed "), this,
		       SLOT(purgeCompleted()));


  editingFlag = FALSE;
  connect(this, SIGNAL(headerClicked(int)), this, SLOT(headerAction(int)));
  updateConfig();
  prevRow = updatingRow = -1;
}
Beispiel #17
0
FindEditor::FindEditor(LiteApi::IApplication *app, QObject *parent) :
    QObject(parent),
    m_liteApp(app),
    m_widget(new QWidget)
{
    m_findEdit = new QLineEdit;
    m_replaceEdit = new QLineEdit;

    m_findNext = new QPushButton(tr("Find Next"));
    m_findPrev = new QPushButton(tr("Find Previous"));
    m_replaceLabel = new QLabel(tr("Replace With:"));
    m_replace = new QPushButton(tr("Replace"));
    m_replaceAll = new QPushButton(tr("Replace All"));

    m_matchWordCheckBox = new QCheckBox(tr("Match whole word only"));
    m_matchCaseCheckBox = new QCheckBox(tr("Match case"));
    m_useRegexCheckBox = new QCheckBox(tr("Regular expression"));
    m_wrapAroundCheckBox = new QCheckBox(tr("Wrap around"));

    m_matchWordCheckBox->setChecked(m_liteApp->settings()->value(FIND_MATCHWORD,true).toBool());
    m_matchCaseCheckBox->setChecked(m_liteApp->settings()->value(FIND_MATCHCASE,true).toBool());
    m_useRegexCheckBox->setChecked(m_liteApp->settings()->value(FIND_USEREGEXP,false).toBool());
    m_wrapAroundCheckBox->setChecked(m_liteApp->settings()->value(FIND_WRAPAROUND,true).toBool());

    m_status = new QLabel(tr("Ready"));
    m_status->setFrameStyle(QFrame::Panel | QFrame::Sunken);
    m_status->setAlignment(Qt::AlignRight);
    m_status->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);

    QPushButton *close = new QPushButton();
    close->setIcon(QIcon("icon:images/closetool.png"));
    close->setIconSize(QSize(16,16));
    close->setFlat(true);
    close->setToolTip(tr("Close"));

    connect(close,SIGNAL(clicked()),this,SLOT(hideFind()));

    QGridLayout *layout = new QGridLayout;
    layout->setMargin(0);
    layout->setVerticalSpacing(1);

    QHBoxLayout *optLayout = new QHBoxLayout;
    optLayout->setMargin(0);    

    optLayout->addWidget(m_matchWordCheckBox);
    optLayout->addWidget(m_matchCaseCheckBox);
    optLayout->addWidget(m_useRegexCheckBox);
    optLayout->addWidget(m_wrapAroundCheckBox);
    optLayout->addStretch();
    optLayout->addWidget(m_status);

    layout->addWidget(new QLabel(tr("Find What:")),0,0);
    layout->addWidget(m_findEdit,0,1);
    layout->addWidget(m_findNext,0,2);
    layout->addWidget(m_findPrev,0,3);
    layout->addWidget(close,0,4);

    layout->addWidget(m_replaceLabel,1,0);
    layout->addWidget(m_replaceEdit,1,1);
    layout->addWidget(m_replace,1,2);
    layout->addWidget(m_replaceAll,1,3);

    layout->addWidget(new QLabel(tr("Options:")),3,0);
    layout->addLayout(optLayout,3,1,1,4);

    m_widget->setLayout(layout);

    QWidget::setTabOrder(m_findEdit,m_replaceEdit);

    connect(m_findEdit,SIGNAL(returnPressed()),this,SLOT(findNext()));
    connect(m_findNext,SIGNAL(clicked()),this,SLOT(findNext()));
    connect(m_findPrev,SIGNAL(clicked()),this,SLOT(findPrev()));
    connect(m_replaceEdit,SIGNAL(returnPressed()),this,SLOT(replace()));
    connect(m_replace,SIGNAL(clicked()),this,SLOT(replace()));
    connect(m_replaceAll,SIGNAL(clicked()),this,SLOT(replaceAll()));
    connect(m_matchCaseCheckBox,SIGNAL(toggled(bool)),this,SLOT(findOptionChanged()));
    connect(m_matchWordCheckBox,SIGNAL(toggled(bool)),this,SLOT(findOptionChanged()));
    connect(m_useRegexCheckBox,SIGNAL(toggled(bool)),this,SLOT(findOptionChanged()));
    connect(m_wrapAroundCheckBox,SIGNAL(toggled(bool)),this,SLOT(findOptionChanged()));
    connect(m_findEdit,SIGNAL(textChanged(QString)),this,SLOT(findOptionChanged()));
    connect(m_replaceEdit,SIGNAL(textChanged(QString)),this,SLOT(replaceChanged()));
    connect(m_liteApp->editorManager(),SIGNAL(currentEditorChanged(LiteApi::IEditor*)),this,SLOT(updateCurrentEditor(LiteApi::IEditor*)));
}
ServerChoice::ServerChoice(TeamHolder* team) :
    ui(new Ui::ServerChoice), wasConnected(false), team(team)
{
    ui->setupUi(this);
    ui->announcement->hide();

    ServerChoiceModel *model = new ServerChoiceModel();
    model->setParent(ui->serverList);
    filter = new QSortFilterProxyModel(ui->serverList);
    filter->setSourceModel(model);
    filter->setSortRole(ServerChoiceModel::SortRole);
    ui->serverList->setModel(filter);

    connect(ui->description, SIGNAL(anchorClicked(QUrl)), SLOT(anchorClicked(QUrl)));

    QSettings settings;

    registry_connection = new Analyzer(true);
    connect(registry_connection, SIGNAL(connected()), SLOT(connected()));

    registry_connection->connectTo(
        settings.value("ServerChoice/RegistryServer", "registry.pokemon-online.eu").toString(),
        settings.value("ServerChoice/RegistryPort", 5090).toUInt()
    );
    registry_connection->setParent(this);

    ui->switchPort->setIcon(QApplication::style()->standardIcon(QStyle::SP_BrowserReload));

    connect(registry_connection, SIGNAL(connectionError(int,QString)), SLOT(connectionError(int , QString)));
    connect(registry_connection, SIGNAL(regAnnouncementReceived(QString)), ui->announcement, SLOT(setText(QString)));
    connect(registry_connection, SIGNAL(regAnnouncementReceived(QString)), ui->announcement, SLOT(show()));

    connect(registry_connection, SIGNAL(serverReceived(ServerInfo)), model, SLOT(addServer(ServerInfo)));
    connect(this, SIGNAL(clearList()), model, SLOT(clear()));
    connect(registry_connection, SIGNAL(serverReceived(ServerInfo)), SLOT(serverAdded()));

    //TO-DO: Make  the item 0 un-resizable and unselectable - Latios

    ui->serverList->setColumnWidth(0, settings.value("ServerChoice/PasswordProtectedWidth", 26).toInt());
    ui->serverList->setColumnWidth(1, settings.value("ServerChoice/ServerNameWidth", 152).toInt());
    if (settings.contains("ServerChoice/PlayersInfoWidth")) {
        ui->serverList->setColumnWidth(2, settings.value("ServerChoice/PlayersInfoWidth").toInt());
    }
    ui->serverList->horizontalHeader()->setStretchLastSection(true);

    connect(ui->serverList, SIGNAL(activated(QModelIndex)), SLOT(regServerChosen(QModelIndex)));
    connect(ui->serverList, SIGNAL(currentCellChanged(QModelIndex)), SLOT(showDetails(QModelIndex)));

    ui->nameEdit->setText(team->name());
    ui->advServerEdit->addItem(settings.value("ServerChoice/DefaultServer").toString());

    connect(ui->nameEdit, SIGNAL(returnPressed()), SLOT(advServerChosen()));
    connect(ui->advServerEdit->lineEdit(), SIGNAL(returnPressed()), SLOT(advServerChosen()));

    QCompleter *completer = new QCompleter(ui->advServerEdit);
    completer->setCaseSensitivity(Qt::CaseInsensitive);
    QStringList res = settings.value("ServerChoice/SavedServers").toStringList();

    foreach (QString r, res) {
        if (r.contains("-")) {
            savedServers.push_back(QStringList() << r.section("-", -1).trimmed() << r.section("-", 0, -2).trimmed());
        } else {
            savedServers.push_back(QStringList() << r << "");
        }
    }

    QStringListModel *m = new QStringListModel(res, completer);

    completer->setModel(m);
    ui->advServerEdit->setCompleter(completer);
    ui->advServerEdit->setModel(m);

    connect(ui->teambuilder, SIGNAL(clicked()), SIGNAL(teambuilder()));
    connect(ui->advancedConnection, SIGNAL(clicked()), SLOT(advServerChosen()));

    QTimer *t = new QTimer(this);
    t->singleShot(5000, this, SLOT(timeout()));

#if QT_VERSION >= QT_VERSION_CHECK(4,8,0)
    ui->serverList->sortByColumn(ServerChoiceModel::Players, Qt::SortOrder(filter->headerData(ServerChoiceModel::Players, Qt::Horizontal, Qt::InitialSortOrderRole).toInt()));
#else
    ui->serverList->sortByColumn(ServerChoiceModel::Players, Qt::DescendingOrder);
#endif
}
Beispiel #19
0
MainWidget::MainWidget(QWidget *parent)
  : QMainWindow(parent)
{
  lw_port=0;
  bool ok=false;

  //
  // Process Arguments
  //
  lw_colorize=true;
  lw_mode=SetMode();
  CmdSwitch *cmd=new CmdSwitch(qApp->argc(),qApp->argv(),"lwmon",LWMON_USAGE);
  if(cmd->keys()==0) {
    fprintf(stderr,"%s\n",LWMON_USAGE);
    exit(256);
  }
  for(unsigned i=0;i<cmd->keys()-1;i++) {
    if(cmd->key(i)=="--color") {
      if((cmd->value(i).toLower()=="off")||
	 (cmd->value(i).toLower()=="no")||
	 (cmd->value(i).toLower()=="false")) {
	lw_colorize=false;
	cmd->setProcessed(i,true);
      }
      if((cmd->value(i).toLower()=="on")||
	 (cmd->value(i).toLower()=="yes")||
	 (cmd->value(i).toLower()=="true")) {
	lw_colorize=true;
	cmd->setProcessed(i,true);
      }
      if(!cmd->processed(i)) {
	fprintf(stderr,"lwmon: invalid argument to --color switch\n");
	exit(256);
      }
    }
    if(cmd->key(i)=="--mode") {
      if(cmd->value(i).toLower()=="lwcp") {
	lw_mode=MainWidget::Lwcp;
	cmd->setProcessed(i,true);
      }
      if(cmd->value(i).toLower()=="lwrp") {
	lw_mode=MainWidget::Lwrp;
	cmd->setProcessed(i,true);
      }
      if(cmd->value(i).toLower()=="lwaddr") {
	lw_mode=MainWidget::Lwaddr;
	cmd->setProcessed(i,true);
      }
      if(!cmd->processed(i)) {
	fprintf(stderr,"lwmon: invalid \"--mode\" argument");
	exit(256);
      }
    }
    if(cmd->key(i)=="--port") {
      lw_port=cmd->value(i).toUInt(&ok);
      if(!ok) {
	fprintf(stderr,"lwmon: invalid port argument\n");
	exit(256);
      }
      cmd->setProcessed(i,true);
    }
    if(!cmd->processed(i)) {
      fprintf(stderr,"lwmon: invalid argument \"%s\"\n",
	      (const char *)cmd->key(i).toUtf8());
      exit(256);
    }
  }

  //
  // Set Mode Defaults
  //
  switch(lw_mode) {
  case MainWidget::Lwcp:
    if(lw_port==0) {
      lw_port=LWMON_LWCP_DEFAULT_PORT;
    }
    setWindowTitle(tr("LWCP Monitor"));
    if(CheckSettingsDirectory()) {
      lw_history_path=lw_settings_dir->path()+"/"+LWMON_LWCP_HISTORY_FILE;
    }
    break;

  case MainWidget::Lwrp:
    if(lw_port==0) {
      lw_port=LWMON_LWRP_DEFAULT_PORT;
    }
    setWindowTitle(tr("LWRP Monitor"));
    if(CheckSettingsDirectory()) {
      lw_history_path=lw_settings_dir->path()+"/"+LWMON_LWRP_HISTORY_FILE;
    }
    break;

  case MainWidget::Lwaddr:
    PrintAddr(cmd->key(cmd->keys()-1));
    break;
  }

  //
  // Process Connection Arguments
  //
  lw_hostname=cmd->key(cmd->keys()-1);

  //
  // UI Elements
  //
  lw_text=new QTextEdit(this);
  lw_text->setReadOnly(true);
  lw_text->setFocusPolicy(Qt::NoFocus);

  lw_edit=new LineEdit(this);
  connect(lw_edit,SIGNAL(returnPressed()),this,SLOT(editReturnPressedData()));
  lw_edit->loadHistory(lw_history_path);

  lw_status_frame_widget=new QLabel(this);
  lw_status_frame_widget->setFrameStyle(QFrame::Box|QFrame::Raised);
  lw_status_widget=new StatusWidget(this);
  lw_status_widget->setStatus(StatusWidget::Connecting);

  lw_button=new QPushButton(tr("&Clear"),this);
  lw_button->setFocusPolicy(Qt::NoFocus);
  connect(lw_button,SIGNAL(clicked()),lw_text,SLOT(clear()));

  //
  // Socket
  //
  lw_tcp_socket=new QTcpSocket(this);
  connect(lw_tcp_socket,SIGNAL(connected()),this,SLOT(tcpConnectedData()));
  connect(lw_tcp_socket,SIGNAL(disconnected()),
	  this,SLOT(tcpDisconnectedData()));
  connect(lw_tcp_socket,SIGNAL(readyRead()),this,SLOT(tcpReadyReadData()));
  connect(lw_tcp_socket,SIGNAL(error(QAbstractSocket::SocketError)),
	  this,SLOT(tcpErrorData(QAbstractSocket::SocketError)));
  lw_tcp_socket->connectToHost(lw_hostname,lw_port);

  setMinimumSize(sizeHint());
}
Beispiel #20
0
DatabaseWidget::DatabaseWidget(Database* db, QWidget* parent)
    : QStackedWidget(parent)
    , m_db(db)
    , m_searchUi(new Ui::SearchWidget())
    , m_searchWidget(new QWidget())
    , m_newGroup(Q_NULLPTR)
    , m_newEntry(Q_NULLPTR)
    , m_newParent(Q_NULLPTR)
{
    m_searchUi->setupUi(m_searchWidget);

    m_searchTimer = new QTimer(this);
    m_searchTimer->setSingleShot(true);

    m_mainWidget = new QWidget(this);
    QLayout* layout = new QHBoxLayout(m_mainWidget);
    m_splitter = new QSplitter(m_mainWidget);
    m_splitter->setChildrenCollapsible(false);

    QWidget* rightHandSideWidget = new QWidget(m_splitter);
    m_searchWidget->setParent(rightHandSideWidget);

    m_groupView = new GroupView(db, m_splitter);
    m_groupView->setObjectName("groupView");
    m_groupView->setContextMenuPolicy(Qt::CustomContextMenu);
    connect(m_groupView, SIGNAL(customContextMenuRequested(QPoint)),
            SLOT(emitGroupContextMenuRequested(QPoint)));

    m_entryView = new EntryView(rightHandSideWidget);
    m_entryView->setObjectName("entryView");
    m_entryView->setContextMenuPolicy(Qt::CustomContextMenu);
    m_entryView->setGroup(db->rootGroup());
    connect(m_entryView, SIGNAL(customContextMenuRequested(QPoint)),
            SLOT(emitEntryContextMenuRequested(QPoint)));

    QAction* closeAction = new QAction(m_searchWidget);
    QIcon closeIcon = filePath()->icon("actions", "dialog-close");
    closeAction->setIcon(closeIcon);
    m_searchUi->closeSearchButton->setDefaultAction(closeAction);
    m_searchUi->closeSearchButton->setShortcut(Qt::Key_Escape);
    m_searchWidget->hide();
    m_searchUi->caseSensitiveCheckBox->setVisible(false);

    QVBoxLayout* vLayout = new QVBoxLayout(rightHandSideWidget);
    vLayout->setMargin(0);
    vLayout->addWidget(m_searchWidget);
    vLayout->addWidget(m_entryView);

    rightHandSideWidget->setLayout(vLayout);

    setTabOrder(m_searchUi->searchRootRadioButton, m_entryView);
    setTabOrder(m_entryView, m_groupView);
    setTabOrder(m_groupView, m_searchWidget);

    m_splitter->addWidget(m_groupView);
    m_splitter->addWidget(rightHandSideWidget);

    m_splitter->setStretchFactor(0, 30);
    m_splitter->setStretchFactor(1, 70);

    layout->addWidget(m_splitter);
    m_mainWidget->setLayout(layout);

    m_editEntryWidget = new EditEntryWidget();
    m_editEntryWidget->setObjectName("editEntryWidget");
    m_historyEditEntryWidget = new EditEntryWidget();
    m_editGroupWidget = new EditGroupWidget();
    m_editGroupWidget->setObjectName("editGroupWidget");
    m_changeMasterKeyWidget = new ChangeMasterKeyWidget();
    m_changeMasterKeyWidget->headlineLabel()->setText(tr("Change master key"));
    QFont headlineLabelFont = m_changeMasterKeyWidget->headlineLabel()->font();
    headlineLabelFont.setBold(true);
    headlineLabelFont.setPointSize(headlineLabelFont.pointSize() + 2);
    m_changeMasterKeyWidget->headlineLabel()->setFont(headlineLabelFont);
    m_databaseSettingsWidget = new DatabaseSettingsWidget();
    m_databaseSettingsWidget->setObjectName("databaseSettingsWidget");
    m_databaseOpenWidget = new DatabaseOpenWidget();
    m_databaseOpenWidget->setObjectName("databaseOpenWidget");
    m_keepass1OpenWidget = new KeePass1OpenWidget();
    m_keepass1OpenWidget->setObjectName("keepass1OpenWidget");
    m_unlockDatabaseWidget = new UnlockDatabaseWidget();
    m_unlockDatabaseWidget->setObjectName("unlockDatabaseWidget");
    addWidget(m_mainWidget);
    addWidget(m_editEntryWidget);
    addWidget(m_editGroupWidget);
    addWidget(m_changeMasterKeyWidget);
    addWidget(m_databaseSettingsWidget);
    addWidget(m_historyEditEntryWidget);
    addWidget(m_databaseOpenWidget);
    addWidget(m_keepass1OpenWidget);
    addWidget(m_unlockDatabaseWidget);

    connect(m_splitter, SIGNAL(splitterMoved(int,int)), SIGNAL(splitterSizesChanged()));
    connect(m_entryView->header(), SIGNAL(sectionResized(int,int,int)), SIGNAL(entryColumnSizesChanged()));
    connect(m_groupView, SIGNAL(groupChanged(Group*)), this, SLOT(clearLastGroup(Group*)));
    connect(m_groupView, SIGNAL(groupChanged(Group*)), SIGNAL(groupChanged()));
    connect(m_groupView, SIGNAL(groupChanged(Group*)), m_entryView, SLOT(setGroup(Group*)));
    connect(m_entryView, SIGNAL(entryActivated(Entry*, EntryModel::ModelColumn)),
            SLOT(entryActivationSignalReceived(Entry*, EntryModel::ModelColumn)));
    connect(m_entryView, SIGNAL(entrySelectionChanged()), SIGNAL(entrySelectionChanged()));
    connect(m_editEntryWidget, SIGNAL(editFinished(bool)), SLOT(switchToView(bool)));
    connect(m_editEntryWidget, SIGNAL(historyEntryActivated(Entry*)), SLOT(switchToHistoryView(Entry*)));
    connect(m_historyEditEntryWidget, SIGNAL(editFinished(bool)), SLOT(switchBackToEntryEdit()));
    connect(m_editGroupWidget, SIGNAL(editFinished(bool)), SLOT(switchToView(bool)));
    connect(m_changeMasterKeyWidget, SIGNAL(editFinished(bool)), SLOT(updateMasterKey(bool)));
    connect(m_databaseSettingsWidget, SIGNAL(editFinished(bool)), SLOT(switchToView(bool)));
    connect(m_databaseOpenWidget, SIGNAL(editFinished(bool)), SLOT(openDatabase(bool)));
    connect(m_keepass1OpenWidget, SIGNAL(editFinished(bool)), SLOT(openDatabase(bool)));
    connect(m_unlockDatabaseWidget, SIGNAL(editFinished(bool)), SLOT(unlockDatabase(bool)));
    connect(this, SIGNAL(currentChanged(int)), this, SLOT(emitCurrentModeChanged()));
    connect(m_searchUi->searchEdit, SIGNAL(textChanged(QString)), this, SLOT(startSearchTimer()));
    connect(m_searchUi->caseSensitiveCheckBox, SIGNAL(toggled(bool)), this, SLOT(startSearch()));
    connect(m_searchUi->searchCurrentRadioButton, SIGNAL(toggled(bool)), this, SLOT(startSearch()));
    connect(m_searchUi->searchRootRadioButton, SIGNAL(toggled(bool)), this, SLOT(startSearch()));
    connect(m_searchUi->searchEdit, SIGNAL(returnPressed()), m_entryView, SLOT(setFocus()));
    connect(m_searchTimer, SIGNAL(timeout()), this, SLOT(search()));
    connect(closeAction, SIGNAL(triggered()), this, SLOT(closeSearch()));
    connect( &m_file_watcher, SIGNAL( fileChanged() ), this, SLOT( databaseModifedExternally() ) );

    setCurrentWidget(m_mainWidget);
}
Beispiel #21
0
tagTab::tagTab(int id, QMap<QString,Site*> *sites, QList<Favorite> favorites, mainWindow *parent)
	: searchTab(id, sites, parent), ui(new Ui::tagTab), m_id(id), m_parent(parent), m_favorites(favorites), m_pagemax(-1), m_lastTags(QString()), m_sized(false), m_from_history(false), m_stop(true), m_history_cursor(0), m_history(QList<QMap<QString,QString> >()), m_modifiers(QStringList())
{
	ui->setupUi(this);
	ui->widgetMeant->hide();
	setAttribute(Qt::WA_DeleteOnClose);

	QSettings settings(savePath("settings.ini"), QSettings::IniFormat, this);
	m_ignored = loadIgnored();

	// Search fields
	QStringList favs;
	for (Favorite fav : m_favorites)
		favs.append(fav.getName());
	m_search = new TextEdit(favs, this);
	m_postFiltering = new TextEdit(favs, this);
		m_search->setContextMenuPolicy(Qt::CustomContextMenu);
		m_postFiltering->setContextMenuPolicy(Qt::CustomContextMenu);
		if (settings.value("autocompletion", true).toBool())
		{
			QFile words("words.txt");
			if (words.open(QIODevice::ReadOnly | QIODevice::Text))
			{
				while (!words.atEnd())
					m_completion.append(QString(words.readLine()).trimmed().split(" ", QString::SkipEmptyParts));
				words.close();
			}
			QFile wordsc(savePath("wordsc.txt"));
			if (wordsc.open(QIODevice::ReadOnly | QIODevice::Text))
			{
				while (!wordsc.atEnd())
					m_completion.append(QString(wordsc.readLine()).trimmed().split(" ", QString::SkipEmptyParts));
				wordsc.close();
			}
			for (int i = 0; i < sites->size(); i++)
				if (sites->value(sites->keys().at(i))->contains("Modifiers"))
					m_modifiers.append(sites->value(sites->keys().at(i))->value("Modifiers").trimmed().split(" ", QString::SkipEmptyParts));
			m_completion.append(m_modifiers);
			m_completion.append(favs);
			m_completion.removeDuplicates();
			m_completion.sort();
			QCompleter *completer = new QCompleter(m_completion, this);
				completer->setCaseSensitivity(Qt::CaseInsensitive);
			m_search->setCompleter(completer);
			m_postFiltering->setCompleter(completer);
		}
		connect(m_search, SIGNAL(returnPressed()), this, SLOT(load()));
		connect(m_search, SIGNAL(favoritesChanged()), _mainwindow, SLOT(updateFavorites()));
		connect(m_search, SIGNAL(favoritesChanged()), _mainwindow, SLOT(updateFavoritesDock()));
		connect(m_search, SIGNAL(kflChanged()), _mainwindow, SLOT(updateKeepForLater()));
		connect(m_postFiltering, SIGNAL(returnPressed()), this, SLOT(load()));
		connect(ui->labelMeant, SIGNAL(linkActivated(QString)), this, SLOT(setTags(QString)));
		ui->layoutFields->insertWidget(1, m_search, 1);
		ui->layoutPlus->addWidget(m_postFiltering, 1, 1, 1, 3);

	// Sources
	QString sel = '1'+QString().fill('0',m_sites->count()-1);
	QString sav = settings.value("sites", sel).toString();
	for (int i = 0; i < sel.count(); i++)
	{
		if (sav.count() <= i)
		{ sav[i] = '0'; }
		m_selectedSources.append(sav.at(i) == '1' ? true : false);
	}

	// Others
	ui->checkMergeResults->setChecked(settings.value("mergeresults", false).toBool());
	optionsChanged();
	ui->widgetPlus->hide();
	setWindowIcon(QIcon());
	updateCheckboxes();
	m_search->setFocus();
}
QvisText3DInterface::QvisText3DInterface(QWidget *parent) : 
    QvisAnnotationObjectInterface(parent)
{
    // Set the title of the group box.
    this->setTitle(GetName());

    QGridLayout *cLayout = new QGridLayout(0);
    topLayout->addLayout(cLayout);
    cLayout->setSpacing(10);

    int row = 0;

    // Add controls for entering the text
    textLineEdit = new QLineEdit(this);
    connect(textLineEdit, SIGNAL(returnPressed()),
            this, SLOT(textChanged()));
    cLayout->addWidget(textLineEdit, row, 1, 1, 2);
    cLayout->addWidget(new QLabel(tr("Text"), this), row, 0);
    ++row;

    // Add controls for the position
    positionEdit = new QLineEdit(this);
    connect(positionEdit, SIGNAL(returnPressed()),
            this, SLOT(positionChanged()));
    cLayout->addWidget(positionEdit, row, 1, 1, 2);
    cLayout->addWidget(new QLabel(tr("Position"), this), row, 0);
    ++row;

    // Add controls for the height.
    heightMode = new QButtonGroup(this);
    connect(heightMode, SIGNAL(buttonClicked(int)),
            this, SLOT(heightModeChanged(int)));
    cLayout->addWidget(new QLabel(tr("Height"), this), row, 0);
    QRadioButton *rb = new QRadioButton(tr("Relative"), this);
    heightMode->addButton(rb, 0);
    cLayout->addWidget(rb, row, 1);
    // Add controls for relative height
    relativeHeightSpinBox = new QSpinBox(this);
    relativeHeightSpinBox->setMinimum(1);
    relativeHeightSpinBox->setMaximum(100);
    relativeHeightSpinBox->setSuffix("%");
    relativeHeightSpinBox->setButtonSymbols(QSpinBox::PlusMinus);
    connect(relativeHeightSpinBox, SIGNAL(valueChanged(int)),
            this, SLOT(relativeHeightChanged(int)));
    cLayout->addWidget(relativeHeightSpinBox, row, 2);
    ++row;

    // Add controls for fixed height.
    rb = new QRadioButton(tr("Fixed"), this);
    heightMode->addButton(rb, 1);
    cLayout->addWidget(rb, row, 1);
    fixedHeightEdit = new QLineEdit(this);
    connect(fixedHeightEdit, SIGNAL(returnPressed()),
            this, SLOT(fixedHeightChanged()));
    cLayout->addWidget(fixedHeightEdit, row, 2);
    cLayout->setColumnStretch(2, 10);
    ++row;

    QFrame *splitter1 = new QFrame(this);
    splitter1->setFrameStyle(QFrame::HLine + QFrame::Raised);
    cLayout->addWidget(splitter1, row, 0, 1, 3);
    ++row;

    facesCameraCheckBox = new QCheckBox(tr("Preserve orientation when view changes"), this);
    connect(facesCameraCheckBox, SIGNAL(toggled(bool)),
            this, SLOT(facesCameraToggled(bool)));
    cLayout->addWidget(facesCameraCheckBox, row, 0, 1, 3);
    ++row;

    rotateZ = new QSpinBox(this);
    rotateZ->setMinimum(-360);
    rotateZ->setMaximum(360);
    rotateZ->setButtonSymbols(QSpinBox::PlusMinus);
    rotateZ->setSuffix(" deg");
    connect(rotateZ, SIGNAL(valueChanged(int)),
            this, SLOT(rotateZChanged(int)));
    QLabel *rotateZLabel = new QLabel(tr("Rotate Z"), this);
    rotateX = new QSpinBox(this);
    rotateX->setMinimum(-360);
    rotateX->setMaximum(360);
    rotateX->setButtonSymbols(QSpinBox::PlusMinus);
    rotateX->setSuffix(" deg");
    connect(rotateX, SIGNAL(valueChanged(int)),
            this, SLOT(rotateXChanged(int)));
    QLabel *rotateXLabel = new QLabel(tr("Rotate X"), this);
    rotateY = new QSpinBox(this);
    rotateY->setMinimum(-360);
    rotateY->setMaximum(360);
    rotateY->setButtonSymbols(QSpinBox::PlusMinus);
    rotateY->setSuffix(" deg");
    connect(rotateY, SIGNAL(valueChanged(int)),
            this, SLOT(rotateYChanged(int)));
    QLabel *rotateYLabel = new QLabel(tr("Rotate Y"), this);
    QGridLayout *rLayout = new QGridLayout(0);
    rLayout->setMargin(0);
    cLayout->addLayout(rLayout, row, 0, 1, 3);
    rLayout->addWidget(rotateYLabel, 0, 0);
    rLayout->addWidget(rotateXLabel, 0, 1);
    rLayout->addWidget(rotateZLabel, 0, 2);
    rLayout->addWidget(rotateY, 1, 0);
    rLayout->addWidget(rotateX, 1, 1);
    rLayout->addWidget(rotateZ, 1, 2);
    ++row;

    QFrame *splitter2 = new QFrame(this);
    splitter2->setFrameStyle(QFrame::HLine + QFrame::Raised);
    cLayout->addWidget(splitter2, row, 0, 1, 4);
    ++row;

    // Add controls for the text color.
    textColorButton = new QvisColorButton(this);
    connect(textColorButton, SIGNAL(selectedColor(const QColor &)),
            this, SLOT(textColorChanged(const QColor &)));
    cLayout->addWidget(new QLabel(tr("Text color")), row, 0, Qt::AlignLeft);
    cLayout->addWidget(textColorButton, row, 1);
    textColorOpacity = new QvisOpacitySlider(0, 255, 10, 0, this);
    connect(textColorOpacity, SIGNAL(valueChanged(int)),
            this, SLOT(textOpacityChanged(int)));
    cLayout->addWidget(textColorOpacity, row, 2, 1, 2);
    ++row;

    // Added a use foreground toggle
    useForegroundColorCheckBox = new QCheckBox(tr("Use foreground color"), this);
    connect(useForegroundColorCheckBox, SIGNAL(toggled(bool)),
            this, SLOT(useForegroundColorToggled(bool)));
    cLayout->addWidget(useForegroundColorCheckBox, row, 0, 1, 3);
    ++row;

    // Added a visibility toggle
    visibleCheckBox = new QCheckBox(tr("Visible"), this);
    connect(visibleCheckBox, SIGNAL(toggled(bool)),
            this, SLOT(visibilityToggled(bool)));
    cLayout->addWidget(visibleCheckBox, row, 0);
}
MainWindow::MainWindow(const QUrl& url) : m_dongle(new mobot_t)
{
    progress = 0;

    QFile file;
    file.setFileName(":/jquery.min.js");
    file.open(QIODevice::ReadOnly);
    jQuery = file.readAll();
    jQuery.append("\nvar qt = { 'jQuery': jQuery.noConflict(true) };");
    file.close();
//! [1]

    QNetworkProxyFactory::setUseSystemConfiguration(true);

    m_interface = new JsInterface(this);
//! [2]
    view = new QWebView(this);
    view->settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);
    view->load(url);
    connect(view, SIGNAL(loadFinished(bool)), SLOT(adjustLocation()));
    connect(view, SIGNAL(titleChanged(QString)), SLOT(adjustTitle()));
    connect(view, SIGNAL(loadProgress(int)), SLOT(setProgress(int)));
    connect(view, SIGNAL(loadFinished(bool)), SLOT(finishLoading(bool)));
    connect(view->page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()),
            this, SLOT(populateJavaScriptWindowObject()));

    locationEdit = new QLineEdit(this);
    locationEdit->setSizePolicy(QSizePolicy::Expanding, locationEdit->sizePolicy().verticalPolicy());
    connect(locationEdit, SIGNAL(returnPressed()), SLOT(changeLocation()));

    QToolBar *toolBar = addToolBar(tr("Navigation"));
    toolBar->addAction(view->pageAction(QWebPage::Back));
    toolBar->addAction(view->pageAction(QWebPage::Forward));
    toolBar->addAction(view->pageAction(QWebPage::Reload));
    toolBar->addAction(view->pageAction(QWebPage::Stop));
    toolBar->addWidget(locationEdit);
//! [2]

    QMenu *viewMenu = menuBar()->addMenu(tr("&View"));
    QAction* viewSourceAction = new QAction("Page Source", this);
    connect(viewSourceAction, SIGNAL(triggered()), SLOT(viewSource()));
    viewMenu->addAction(viewSourceAction);

//! [3]
    QMenu *effectMenu = menuBar()->addMenu(tr("&Effect"));
    effectMenu->addAction("Highlight all links", this, SLOT(highlightAllLinks()));

    rotateAction = new QAction(this);
    rotateAction->setIcon(style()->standardIcon(QStyle::SP_FileDialogDetailedView));
    rotateAction->setCheckable(true);
    rotateAction->setText(tr("Turn images upside down"));
    connect(rotateAction, SIGNAL(toggled(bool)), this, SLOT(rotateImages(bool)));
    effectMenu->addAction(rotateAction);

    QMenu *toolsMenu = menuBar()->addMenu(tr("&Tools"));
    toolsMenu->addAction(tr("Remove GIF images"), this, SLOT(removeGifImages()));
    toolsMenu->addAction(tr("Remove all inline frames"), this, SLOT(removeInlineFrames()));
    toolsMenu->addAction(tr("Remove all object elements"), this, SLOT(removeObjectElements()));
    toolsMenu->addAction(tr("Remove all embedded elements"), this, SLOT(removeEmbeddedElements()));

    setCentralWidget(view);
    setUnifiedTitleAndToolBarOnMac(true);

    baroboInit();
    
    qDebug() << "App path : " << qApp->applicationDirPath();
}
qtSearchWindow::qtSearchWindow(std::string index_file, double restart_Probability, int pageRankSteps){
	Restart_Probability = restart_Probability;
	PageRankSteps = pageRankSteps;

	PageParser* parser = new MDparser();
	searchengine.add_parse_from_index_file(index_file, parser);
	wrongFormat = false;

	//title
	setWindowTitle("qtSearch");

	// Overall layout
	overallLayout = new QHBoxLayout();

	// //form to show the seach result
	//Layout
	displayResultLayout = new QVBoxLayout();
	overallLayout->addLayout(displayResultLayout);

	//form
	resultNameList = new QListWidget();
	displayResultLayout->addWidget(resultNameList);


	//display options
	showDetail = new QPushButton("Show Detailed Content!");
	connect(showDetail, SIGNAL(clicked()), this, SLOT(showWebpageContents()));
	displayByFilenameslistButton = new QPushButton("Sort by Filenames");
	connect(displayByFilenameslistButton, SIGNAL(clicked()), this, SLOT(displayByFilename()));
	displayByOutgoingLinksButton = new QPushButton("Sort by Outgoing Links");
	connect(displayByOutgoingLinksButton, SIGNAL(clicked()), this, SLOT(displayByOutgoingLinks()));
	displayByIncomingLinksButton = new QPushButton("Sort by Incoming Links");
	connect(displayByIncomingLinksButton, SIGNAL(clicked()), this, SLOT(displayByIncomingLinks()));
	displayByPageRankButton = new QPushButton("Sort by PageRank");
	connect(displayByPageRankButton, SIGNAL(clicked()), this, SLOT(displayByPageRank()));
	displayResultLayout->addWidget(showDetail);
	displayResultLayout->addWidget(displayByFilenameslistButton);
	displayResultLayout->addWidget(displayByOutgoingLinksButton);
	displayResultLayout->addWidget(displayByIncomingLinksButton);
	displayResultLayout->addWidget(displayByPageRankButton);

	// //Search functionality section
	//Layout
	queryLayout = new QVBoxLayout();
	overallLayout->addLayout(queryLayout);

	//Query Label
	queryLabel = new QLabel("What do you want to search?");
	queryLayout->addWidget(queryLabel);

	//Query words input
	queryInput = new QLineEdit();
	queryLayout->addWidget(queryInput);
	connect(queryInput, SIGNAL(returnPressed()), this, SLOT(query()));

	//search options
	singleOption = new QRadioButton("Let's do single word search!", this);
	andOption = new QRadioButton("Let's do <AND> search!", this);
	orOption = new QRadioButton("Let's do <OR> search!", this);
	singleOption->setChecked(true);
	queryLayout->addWidget(singleOption);
	queryLayout->addWidget(andOption);
	queryLayout->addWidget(orOption);

	//search button
	queryButtton = new QPushButton("Magic Search!");
	connect(queryButtton, SIGNAL(clicked()), this, SLOT(query()));
	quitButton = new QPushButton("Quit Application");
	queryLayout->addWidget(queryButtton);
	queryLayout->addWidget(quitButton);
	connect(quitButton, SIGNAL(clicked()), this, SLOT(quitMain()));

	//this is the section for subwindow

	detailedWindow = new QWidget();
	webpageDetailedDisplayLayout = new QVBoxLayout();
	contentDisplayLayout = new QVBoxLayout();
	webpageDetailedDisplayLayout->addLayout(contentDisplayLayout);
	webpageDetailedNameLabel = new QLabel();

	contentName = new QLabel("Content:");
	content = new QTextEdit();
	content->setReadOnly(true);
	contentDisplayLayout->addWidget(webpageDetailedNameLabel);
	contentDisplayLayout->addWidget(contentName);
	contentDisplayLayout->addWidget(content);
	webpageDetailedIncomingLabel = new QLabel("IncomingLinks of this page:");
	webpageDetailedIncomingList = new QListWidget();
	showdeatilDetail1 = new QPushButton("Show detail of this link!");
	connect(showdeatilDetail1, SIGNAL(clicked()), this, SLOT(showdetail1()));


	webpageDetailedOutgoingLabel= new QLabel("OutgoingLinks of this page:");
	webpageDetailedOutgoingList = new QListWidget();
	showdeatilDetail2 = new QPushButton("Show detail of this link!");
	connect(showdeatilDetail2, SIGNAL(clicked()), this, SLOT(showdetail2()));


	webpageDetailedDisplayLayout->addWidget(webpageDetailedIncomingLabel);
	webpageDetailedDisplayLayout->addWidget(webpageDetailedIncomingList);
	webpageDetailedDisplayLayout->addWidget(showdeatilDetail1);
	webpageDetailedDisplayLayout->addWidget(webpageDetailedOutgoingLabel);
	webpageDetailedDisplayLayout->addWidget(webpageDetailedOutgoingList);
	webpageDetailedDisplayLayout->addWidget(showdeatilDetail2);
	detailedDisplayByFilenamesButtom = new QPushButton("Sort by Filenames");

	detailedDisplayByIncomingLinksButtom = new QPushButton("Sort by Incominglinks");
	detailedDisplayByOutgoingLinkButtom = new QPushButton("Sort by Outgoinginglinks");
	quit = new QPushButton("Close Window");

	webpageDetailedDisplayLayout->addWidget(detailedDisplayByFilenamesButtom);
	webpageDetailedDisplayLayout->addWidget(detailedDisplayByIncomingLinksButtom);
	webpageDetailedDisplayLayout->addWidget(detailedDisplayByOutgoingLinkButtom);
	webpageDetailedDisplayLayout->addWidget(quit);
	connect(quit, SIGNAL(clicked()), this, SLOT(quitSub()));
	connect(detailedDisplayByFilenamesButtom, SIGNAL(clicked()), this, SLOT(detailedDisplayByFileNames()));
	connect(detailedDisplayByIncomingLinksButtom, SIGNAL(clicked()), this, SLOT(detailedDisplayByIncomingLinks()));
	connect(detailedDisplayByOutgoingLinkButtom, SIGNAL(clicked()), this, SLOT(detailedDisplayByOutgoingLinks()));
	

	detailedWindow->setLayout(webpageDetailedDisplayLayout);

	//Set overall layout
	setLayout(overallLayout);	

}
LibraryFilterWidget::LibraryFilterWidget(QWidget* parent)
    : QWidget(parent),
      ui_(new Ui_LibraryFilterWidget),
      model_(nullptr),
      group_by_dialog_(new GroupByDialog),
      filter_delay_(new QTimer(this)),
      filter_applies_to_model_(true),
      delay_behaviour_(DelayedOnLargeLibraries) {
  ui_->setupUi(this);

  // Add the available fields to the tooltip here instead of the ui
  // file to prevent that they get translated by mistake.
  QString available_fields =
      Song::kFtsColumns.join(", ").replace(QRegExp("\\bfts"), "");
  ui_->filter->setToolTip(ui_->filter->toolTip().arg(available_fields));

  connect(ui_->filter, SIGNAL(returnPressed()), SIGNAL(ReturnPressed()));
  connect(filter_delay_, SIGNAL(timeout()), SLOT(FilterDelayTimeout()));

  filter_delay_->setInterval(kFilterDelay);
  filter_delay_->setSingleShot(true);

  // Icons
  ui_->options->setIcon(IconLoader::Load("configure"));

  // Filter by age
  QActionGroup* filter_age_group = new QActionGroup(this);
  filter_age_group->addAction(ui_->filter_age_all);
  filter_age_group->addAction(ui_->filter_age_today);
  filter_age_group->addAction(ui_->filter_age_week);
  filter_age_group->addAction(ui_->filter_age_month);
  filter_age_group->addAction(ui_->filter_age_three_months);
  filter_age_group->addAction(ui_->filter_age_year);

  filter_age_menu_ = new QMenu(tr("Show"), this);
  filter_age_menu_->addActions(filter_age_group->actions());

  filter_age_mapper_ = new QSignalMapper(this);
  filter_age_mapper_->setMapping(ui_->filter_age_all, -1);
  filter_age_mapper_->setMapping(ui_->filter_age_today, 60 * 60 * 24);
  filter_age_mapper_->setMapping(ui_->filter_age_week, 60 * 60 * 24 * 7);
  filter_age_mapper_->setMapping(ui_->filter_age_month, 60 * 60 * 24 * 30);
  filter_age_mapper_->setMapping(ui_->filter_age_three_months,
                                 60 * 60 * 24 * 30 * 3);
  filter_age_mapper_->setMapping(ui_->filter_age_year, 60 * 60 * 24 * 365);

  connect(ui_->filter_age_all, SIGNAL(triggered()), filter_age_mapper_,
          SLOT(map()));
  connect(ui_->filter_age_today, SIGNAL(triggered()), filter_age_mapper_,
          SLOT(map()));
  connect(ui_->filter_age_week, SIGNAL(triggered()), filter_age_mapper_,
          SLOT(map()));
  connect(ui_->filter_age_month, SIGNAL(triggered()), filter_age_mapper_,
          SLOT(map()));
  connect(ui_->filter_age_three_months, SIGNAL(triggered()), filter_age_mapper_,
          SLOT(map()));
  connect(ui_->filter_age_year, SIGNAL(triggered()), filter_age_mapper_,
          SLOT(map()));

  // "Group by ..."
  group_by_group_ = CreateGroupByActions(this);

  group_by_menu_ = new QMenu(tr("Group by"), this);
  group_by_menu_->addActions(group_by_group_->actions());

  connect(group_by_group_, SIGNAL(triggered(QAction*)),
          SLOT(GroupByClicked(QAction*)));

  // Library config menu
  library_menu_ = new QMenu(tr("Display options"), this);
  library_menu_->setIcon(ui_->options->icon());
  library_menu_->addMenu(filter_age_menu_);
  library_menu_->addMenu(group_by_menu_);
  library_menu_->addSeparator();
  ui_->options->setMenu(library_menu_);

  connect(ui_->filter, SIGNAL(textChanged(QString)),
          SLOT(FilterTextChanged(QString)));
}
Beispiel #26
0
QT_BEGIN_NAMESPACE

FindWidget::FindWidget(QWidget *parent)
    : QWidget(parent)
    , appPalette(qApp->palette())
{
    TRACE_OBJ
    installEventFilter(this);
    QHBoxLayout *hboxLayout = new QHBoxLayout(this);
    QString resourcePath = QLatin1String(":/qt-project.org/assistant/images/");

#ifndef Q_OS_MAC
    hboxLayout->setMargin(0);
    hboxLayout->setSpacing(6);
    resourcePath.append(QLatin1String("win"));
#else
    resourcePath.append(QLatin1String("mac"));
#endif

    toolClose = setupToolButton(QLatin1String(""),
        resourcePath + QLatin1String("/closetab.png"));
    hboxLayout->addWidget(toolClose);
    connect(toolClose, SIGNAL(clicked()), SLOT(hide()));

    editFind = new QLineEdit(this);
    hboxLayout->addWidget(editFind);
    editFind->setMinimumSize(QSize(150, 0));
    connect(editFind, SIGNAL(textChanged(QString)), this,
        SLOT(textChanged(QString)));
    connect(editFind, SIGNAL(returnPressed()), this, SIGNAL(findNext()));
    connect(editFind, SIGNAL(textChanged(QString)), this, SLOT(updateButtons()));

    toolPrevious = setupToolButton(tr("Previous"),
        resourcePath + QLatin1String("/previous.png"));
    connect(toolPrevious, SIGNAL(clicked()), this, SIGNAL(findPrevious()));

    hboxLayout->addWidget(toolPrevious);

    toolNext = setupToolButton(tr("Next"),
        resourcePath + QLatin1String("/next.png"));
    hboxLayout->addWidget(toolNext);
    connect(toolNext, SIGNAL(clicked()), this, SIGNAL(findNext()));

    checkCase = new QCheckBox(tr("Case Sensitive"), this);
    hboxLayout->addWidget(checkCase);

    labelWrapped = new QLabel(this);
    labelWrapped->setScaledContents(true);
    labelWrapped->setTextFormat(Qt::RichText);
    labelWrapped->setMinimumSize(QSize(0, 20));
    labelWrapped->setMaximumSize(QSize(105, 20));
    labelWrapped->setAlignment(Qt::AlignLeading | Qt::AlignLeft | Qt::AlignVCenter);
    labelWrapped->setText(tr("<img src=\":/qt-project.org/assistant/images/wrap.png\""
        ">&nbsp;Search wrapped"));
    hboxLayout->addWidget(labelWrapped);

    QSpacerItem *spacerItem = new QSpacerItem(20, 20, QSizePolicy::Expanding,
        QSizePolicy::Minimum);
    hboxLayout->addItem(spacerItem);
    setMinimumWidth(minimumSizeHint().width());
    labelWrapped->hide();

    updateButtons();
}
Beispiel #27
0
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent), ui(new Ui::MainWindow) {
  ui->setupUi(this);

  QFile styleFile(":/style.css");
  styleFile.open(QFile::ReadOnly);
  QString styleSheet = QLatin1String(styleFile.readAll());
  qApp->setStyleSheet(styleSheet);

  QPixmap window_icon;
  QFile iconFile(":/icon.png");
  iconFile.open(QFile::ReadOnly);
  QByteArray icon_data = iconFile.readAll();
  window_icon.loadFromData(icon_data);
  qApp->setWindowIcon(QIcon(window_icon));

  awesome = new QtAwesome(qApp);
  settings = new Settings(this);
  window_watcher = new WindowWatcher(this);
  anitomy = new AnitomyWrapper();
  event_timer = new QTimer(this);
  watch_timer = new QTimer(this);
  uptime_timer = new QElapsedTimer;
  progress_bar = new QProgressBar(ui->statusBar);
  over = new Overlay(this);
  torrent_refresh_time = 0;
  user_refresh_time =
      settings->getValue(Settings::UserRefreshTime, D_USER_REFRESH_TIME)
          .toInt();
  download_rule = 0;
  download_count = 0;
  hasUser = false;

  uptime_timer->start();
  watch_timer->setSingleShot(true);

  awesome->initFontAwesome();

  bool check_for_updates =
      settings->getValue(Settings::CheckUpdates, D_CHECK_FOR_UPDATES).toBool();

  if (check_for_updates) {
    connect(FvUpdater::sharedUpdater(), &FvUpdater::restartRequested,
            [&]() {  // NOLINT
              QString app = QApplication::applicationFilePath();
              QStringList arguments = QApplication::arguments();
              QString wd = QDir::currentPath();
              QProcess::startDetached(app, arguments, wd);
              elegantClose(true);
            });

    FvUpdater::sharedUpdater()->CheckForUpdatesSilent();
  }

  QFont font = ui->listTabs->tabBar()->font();
  font.setCapitalization(QFont::Capitalize);
  ui->listTabs->tabBar()->setFont(font);

  int currentYear = QDate::currentDate().year();
  int lowerYear = currentYear - 10;

  while (currentYear > lowerYear) {
    ui->comboYear->addItem(QString::number(currentYear));
    currentYear--;
  }

  QWidget *container = new QWidget(ui->scrollArea);
  layout = new FlowLayout(container);
  ui->scrollArea->setWidget(container);
  container->setLayout(layout);

  QWidget *container2 = new QWidget(ui->scrollArea_2);
  layout2 = new FlowLayout(container2);
  layout2->disableSort();
  ui->scrollArea_2->setWidget(container2);
  container2->setLayout(layout2);

  QVariantMap black;
  black.insert("color", QColor(0, 0, 0));
  black.insert("color-active", QColor(0, 0, 0));
  black.insert("color-disabled", QColor(0, 0, 0));
  black.insert("color-selected", QColor(0, 0, 0));

  ui->airingButton->setIcon(awesome->icon(fa::clocko, black));
  ui->torrentsButton->setIcon(awesome->icon(fa::rss, black));
  ui->animeButton->setIcon(awesome->icon(fa::bars, black));
  ui->seasonsButton->setIcon(awesome->icon(fa::th, black));
  ui->statisticsButton->setIcon(awesome->icon(fa::piechart, black));

  ui->tabWidget->tabBar()->hide();
  ui->tabWidget->setCurrentIndex(UserTabs::tAnime);
  ui->listTabs->setCurrentIndex(0);

  ui->statusBar->addWidget(progress_bar);
  ui->statusBar->layout()->setContentsMargins(1, 0, 0, 0);
  progress_bar->setRange(0, 100);
  progress_bar->setValue(5);
  progress_bar->setFormat("Authorizing");

  QSettings s;
  restoreGeometry(s.value("mainWindowGeometry").toByteArray());
  restoreState(s.value("mainWindowState").toByteArray());

  connect(&user_future_watcher, SIGNAL(finished()), SLOT(userLoaded()));
  connect(&user_list_future_watcher, SIGNAL(finished()),
          SLOT(userListLoaded()));

  connect(ui->animeButton, SIGNAL(clicked()), SLOT(showAnimeTab()));
  connect(ui->airingButton, SIGNAL(clicked()), SLOT(showAiringTab()));
  connect(ui->torrentsButton, SIGNAL(clicked()), SLOT(showTorrentsTab()));
  connect(ui->seasonsButton, SIGNAL(clicked()), SLOT(showBrowseTab()));
  connect(ui->actionSettings, SIGNAL(triggered()), SLOT(showSettings()));
  connect(ui->statisticsButton, SIGNAL(clicked()), SLOT(showStatisticsTab()));

  connect(ui->actionExit, &QAction::triggered, [&, this]() {  // NOLINT
    this->elegantClose();
  });

  connect(ui->actionAbout, &QAction::triggered, [&, this]() {  // NOLINT
    About *about = new About(this);
    about->show();
  });

  connect(ui->actionHelp, &QAction::triggered, [&, this]() {  // NOLINT
    QDesktopServices::openUrl(QUrl("http://app.shinjiru.me/support.php"));
  });

  connect(ui->actionRL, &QAction::triggered, [&, this]() {  // NOLINT
    loadUser();
  });

  connect(ui->actionAS, &QAction::triggered, [&]() {  // NOLINT
    SearchPanel *sp = new SearchPanel(this);
    sp->show();
  });

  connect(ui->actionARR, &QAction::triggered, [&, this]() {  // NOLINT
    SettingsDialog *s = new SettingsDialog(this);
    s->showSmartTitles();

    connect(s, &QDialog::accepted, [&, this]() {  // NOLINT
      Settings set;

      toggleAnimeRecognition(
          set.getValue(Settings::AnimeRecognitionEnabled, D_ANIME_RECOGNITION)
              .toBool());

      torrents_enabled =
          set.getValue(Settings::TorrentsEnabled, D_TORRENTS_ENABLED).toBool();

      reloadSmartTitles();
      reloadRules();
    });
  });

  connect(qApp, SIGNAL(aboutToQuit()), SLOT(elegantClose()));

  connect(ui->actionVAL, SIGNAL(triggered()), SLOT(viewAnimeList()));
  connect(ui->actionVD, SIGNAL(triggered()), SLOT(viewDashboard()));
  connect(ui->actionVP, SIGNAL(triggered()), SLOT(viewProfile()));
  connect(ui->actionEAR, SIGNAL(triggered(bool)),
          SLOT(toggleAnimeRecognition(bool)));
  connect(ui->actionExport, SIGNAL(triggered()), SLOT(exportListJSON()));
  connect(ui->actionUpdate, SIGNAL(triggered()), FvUpdater::sharedUpdater(),
          SLOT(CheckForUpdatesNotSilent()));

  connect(window_watcher, SIGNAL(title_found(QString)), SLOT(watch(QString)));
  connect(watch_timer, SIGNAL(timeout()), SLOT(updateEpisode()));
  connect(event_timer, SIGNAL(timeout()), SLOT(eventTick()));

  connect(ui->torrentTable, SIGNAL(customContextMenuRequested(QPoint)),
          SLOT(torrentContextMenu(QPoint)));
  connect(ui->torrentFilter, SIGNAL(textChanged(QString)),
          SLOT(filterTorrents(QString)));
  connect(ui->chkHideUnknown, SIGNAL(toggled(bool)),
          SLOT(filterTorrents(bool)));
  connect(ui->refreshButton, SIGNAL(clicked()), SLOT(refreshTorrentListing()));

  connect(ui->actionEAR, SIGNAL(toggled(bool)), SLOT(applyEAR()));

  connect(ui->tabWidget, &QTabWidget::currentChanged, [&, this](  // NOLINT
                                                          int tab) {
    if (tab != 0) {
      this->over->removeDrawing("blank_table");
      this->over->removeDrawing("no anime");
      ui->listTabs->show();
      ui->listFilterLineEdit->show();
    } else {
      this->filterList(3);

      if (hasUser && (User::sharedUser()->getAnimeList().count() == 0)) {
        this->addNoAnimePrompt();
      }
    }
  });

  ui->actionEAR->setChecked(
      settings->getValue(Settings::AnimeRecognitionEnabled, D_ANIME_RECOGNITION)
          .toBool());

  this->toggleAnimeRecognition(ui->actionEAR->isChecked());

  QString genrelist =
      "Action, Adult, Adventure, Cars, Comedy, Dementia, Demons, Doujinshi, "
      "Drama, Ecchi, Fantasy, Game, Gender Bender, Harem, Hentai, Historical, "
      "Horror, Josei, Kids, Magic, Martial Arts, Mature, Mecha, Military, "
      "Motion Comic, Music, Mystery, Mythological , Parody, Police, "
      "Psychological, Romance, Samurai, School, Sci-Fi, Seinen, Shoujo, Shoujo "
      "Ai, Shounen, Shounen Ai, Slice of Life, Space, Sports, Super Power, "
      "Supernatural, Thriller, Tragedy, Vampire, Yaoi, Yuri";
  QStringList genres = genrelist.split(", ");

  for (QString genre : genres) {
    QCheckBox *chk = new QCheckBox();

    chk->setText(genre);
    chk->setTristate(true);

    ui->genreList->addWidget(chk);
  }

  connect(ui->listFilterLineEdit, SIGNAL(textChanged(QString)),
          SLOT(filterList(QString)));
  connect(ui->listFilterLineEdit, SIGNAL(returnPressed()), SLOT(showSearch()));
  connect(ui->listTabs, SIGNAL(currentChanged(int)), SLOT(filterList(int)));

  connect(ui->browseButton, SIGNAL(clicked()), SLOT(loadBrowserData()));

  this->show();
  createActions();
  initTray();
  trayIcon->show();

  int result = API::sharedAPI()->verifyAPI();

  if (result == AniListAPI::OK) {
    connect(API::sharedAPI()->sharedAniListAPI(), &AniListAPI::access_granted,
            [&, this]() {  // NOLINT
              progress_bar->setValue(10);
              progress_bar->setFormat("Access granted");
              loadUser();

              event_timer->start(1000);
            });

    connect(API::sharedAPI()->sharedAniListAPI(), &AniListAPI::access_denied,
            [&, this](QString error) {  // NOLINT
              qCritical() << error;

              if (isVisible()) {
                QMessageBox::critical(this, "Shinjiru", tr("Error: ") + error);
              }
            });
  } else if (result == AniListAPI::NO_CONNECTION) {
    qDebug() << "Starting Shinjiru in offline mode";
    hasUser = User::sharedUser()->loadLocal();
  }

  reloadRules();
}
SniffWindow::SniffWindow(QWidget* parent) :
    QMainWindow(parent),
    ui(new Ui::SniffWindow),
    model(),
    statsTable(new PacketStats(this)),
    toNotStop(true),
    isNotExiting(true),
    manageThread(&SniffWindow::managePacketsList, this),
    filterTree(nullptr)
{
    SniffWindow::window = this;
    ui->setupUi(this);
    connect(ui->actionAbout_Qt, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
    ui->table_packets->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
    ui->table_packets->horizontalHeader()->setStretchLastSection(true);
    ui->table_packets->verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);

    m_sortFilterProxy = new QSortFilterProxyModel(this);
    m_sortFilterProxy->setSourceModel(&model);
    ui->table_packets->setModel(m_sortFilterProxy);

    connect(ui->table_packets->selectionModel(), SIGNAL(currentRowChanged(QModelIndex, QModelIndex)),
            this, SLOT(model_currentRowChanged(QModelIndex, QModelIndex)));
    connect(ui->action_preferences, SIGNAL(triggered()), this, SLOT(open_preference_window()));

    ui->tree_packet->setHeaderLabels(QStringList({QStringLiteral("Key"), QStringLiteral("Value")}));
    ui->tree_packet->setColumnCount(2);
    loadStatsFunctions(HungrySniffer_Core::core->stats, *ui->menuStats);
#ifdef PYTHON_CMD
    QWidget* verticalLayoutWidget = new QWidget(ui->splitter);
    QVBoxLayout* panel_python = new QVBoxLayout(verticalLayoutWidget);
    panel_python->setContentsMargins(0, 0, 0, 0);
    lb_cmd = new QPlainTextEdit(verticalLayoutWidget);
    lb_cmd->setReadOnly(true);
    panel_python->addWidget(lb_cmd);
    QHBoxLayout* horizontalLayout = new QHBoxLayout();
    horizontalLayout->setContentsMargins(0, 0, 0, 0);
    QLabel* img_python = new QLabel(verticalLayoutWidget);
    QSizePolicy sizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    sizePolicy.setHeightForWidth(img_python->sizePolicy().hasHeightForWidth());
    img_python->setSizePolicy(sizePolicy);
    img_python->setMaximumSize(QSize(32, 32));
    img_python->setPixmap(QPixmap(QStringLiteral(":/icons/python.png")));
#ifndef QT_NO_TOOLTIP
    img_python->setToolTip(PythonThread::getVersionString());
#endif
    horizontalLayout->addWidget(img_python);
    tb_command = new History_Line_Edit(verticalLayoutWidget);
    connect(tb_command, SIGNAL(returnPressed()), this, SLOT(tb_command_returnPressed()));
    horizontalLayout->addWidget(tb_command);
    panel_python->addLayout(horizontalLayout);
    ui->splitter->addWidget(verticalLayoutWidget);

    this->py_checkCommand.reset();
    connect(this, SIGNAL(sig_appendToCmd(QString)), this, SLOT(lb_cmd_appendString(QString)));
    connect(this, SIGNAL(sig_clearCmd()), this, SLOT(lb_cmd_clear()));
#ifndef QT_NO_DEBUG
    python_thread.setObjectName(QStringLiteral("Python Interpreter"));
#endif
    python_thread.start();
#else
    ui->action_Python->setVisible(false);
#endif
    setAcceptDrops(true);

    if(HungrySniffer_Core::core->preferences.empty())
        ui->action_preferences->setVisible(false);

    { // settings block
        QSettings& settings = *Preferences::settings;
        QVariant var;
        settings.beginGroup(QStringLiteral("General"));
        settings.beginGroup(QStringLiteral("UI"));
        bool flag = settings.value(QStringLiteral("splitter_sizes"), false).toBool();
        default_open_location = settings.value(QStringLiteral("default_dir")).toString();
        max_recent_files = settings.value(QStringLiteral("max_recent_files"), 10).toInt();
        model.showColors = settings.value(QStringLiteral("colored_packets"), true).toBool();
        settings.endGroup();
        settings.endGroup();

        settings.beginGroup(QStringLiteral("SniffWindow"));
        if(flag)
        {
            var = settings.value(QStringLiteral("splitter_sizes"));
            if(!var.isNull())
            {
                QList<int> sizes;
                QVariantList list = var.value<QVariantList>();
                for(const auto& i : list)
                    sizes << i.toInt();
                ui->splitter->setSizes(sizes);
            }
        }
        var = settings.value(QStringLiteral("recent_files"));
        if(!var.isNull())
        {
            this->recentFiles_paths = var.toStringList();
        }
        settings.endGroup();
    }

    { // recent files
        recentFiles_actions.resize(max_recent_files, nullptr);
        for(int i = 0; i < max_recent_files; i++)
        {
            QAction* temp = recentFiles_actions[i] = new QAction(ui->menu_recent_files);
            temp->setData(i);
            connect(temp, SIGNAL(triggered(bool)), this, SLOT(recentFile_triggered()));
            ui->menu_recent_files->addAction(temp);
        }
        updateRecentsMenu();
    }
}
Beispiel #29
0
SpiceDialog::SpiceDialog(QucsApp* App_, SpiceFile *c, Schematic *d)
    : QDialog(d, 0, TRUE, Qt::WDestructiveClose)
{
    App = App_; // pointer to main application

    resize(400, 250);
    setCaption(tr("Edit SPICE Component Properties"));
    Comp = c;
    Doc  = d;

    all = new Q3VBoxLayout(this); // to provide neccessary size
    QWidget *myParent = this;

    Expr.setPattern("[^\"=]+");  // valid expression for property 'edit' etc
    Validator = new QRegExpValidator(Expr, this);
    Expr.setPattern("[\\w_]+");  // valid expression for property 'NameEdit' etc
    ValRestrict = new QRegExpValidator(Expr, this);


    // ...........................................................
    Q3GridLayout *topGrid = new Q3GridLayout(0, 4,3,3,3);
    all->addLayout(topGrid);

    topGrid->addWidget(new QLabel(tr("Name:"), myParent), 0,0);
    CompNameEdit = new QLineEdit(myParent);
    CompNameEdit->setValidator(ValRestrict);
    topGrid->addWidget(CompNameEdit, 0,1);
    connect(CompNameEdit, SIGNAL(returnPressed()), SLOT(slotButtOK()));

    topGrid->addWidget(new QLabel(tr("File:"), myParent), 1,0);
    FileEdit = new QLineEdit(myParent);
    FileEdit->setValidator(ValRestrict);
    topGrid->addWidget(FileEdit, 1,1);
    connect(FileEdit, SIGNAL(returnPressed()), SLOT(slotButtOK()));

    ButtBrowse = new QPushButton(tr("Browse"), myParent);
    topGrid->addWidget(ButtBrowse, 1,2);
    connect(ButtBrowse, SIGNAL(clicked()), SLOT(slotButtBrowse()));

    ButtEdit = new QPushButton(tr("Edit"), myParent);
    topGrid->addWidget(ButtEdit, 2,2);
    connect(ButtEdit, SIGNAL(clicked()), SLOT(slotButtEdit()));

    FileCheck = new QCheckBox(tr("show file name in schematic"), myParent);
    topGrid->addWidget(FileCheck, 2,1);

    SimCheck = new QCheckBox(tr("include SPICE simulations"), myParent);
    topGrid->addWidget(SimCheck, 3,1);

    Q3HBox *h1 = new Q3HBox(myParent);
    h1->setSpacing(5);
    PrepCombo = new QComboBox(h1);
    PrepCombo->insertItem("none");
    PrepCombo->insertItem("ps2sp");
    PrepCombo->insertItem("spicepp");
    PrepCombo->insertItem("spiceprm");
    QLabel * PrepLabel = new QLabel(tr("preprocessor"), h1);
    PrepLabel->setMargin(5);
    topGrid->addWidget(h1, 4,1);
    connect(PrepCombo, SIGNAL(activated(int)), SLOT(slotPrepChanged(int)));

    // ...........................................................
    Q3GridLayout *midGrid = new Q3GridLayout(0, 2,3,5,5);
    all->addLayout(midGrid);

    midGrid->addWidget(new QLabel(tr("SPICE net nodes:"), myParent), 0,0);
    NodesList = new Q3ListBox(myParent);
    midGrid->addWidget(NodesList, 1,0);
    connect(NodesList, SIGNAL(doubleClicked(Q3ListBoxItem*)),
            SLOT(slotAddPort(Q3ListBoxItem*)));

    Q3VBox *v0 = new Q3VBox(myParent);
    v0->setSpacing(5);
    midGrid->addWidget(v0, 1,1);
    ButtAdd = new QPushButton(tr("Add >>"), v0);
    connect(ButtAdd, SIGNAL(clicked()), SLOT(slotButtAdd()));
    ButtRemove = new QPushButton(tr("<< Remove"), v0);
    connect(ButtRemove, SIGNAL(clicked()), SLOT(slotButtRemove()));
    v0->setStretchFactor(new QWidget(v0), 5); // stretchable placeholder

    midGrid->addWidget(new QLabel(tr("Component ports:"), myParent), 0,2);
    PortsList = new Q3ListBox(myParent);
    midGrid->addWidget(PortsList, 1,2);
    connect(PortsList, SIGNAL(doubleClicked(Q3ListBoxItem*)),
            SLOT(slotRemovePort(Q3ListBoxItem*)));


    // ...........................................................
    Q3HBox *h0 = new Q3HBox(this);
    h0->setSpacing(5);
    all->addWidget(h0);
    connect(new QPushButton(tr("OK"),h0), SIGNAL(clicked()),
            SLOT(slotButtOK()));
    connect(new QPushButton(tr("Apply"),h0), SIGNAL(clicked()),
            SLOT(slotButtApply()));
    connect(new QPushButton(tr("Cancel"),h0), SIGNAL(clicked()),
            SLOT(slotButtCancel()));

    // ------------------------------------------------------------
    CompNameEdit->setText(Comp->Name);
    changed = false;

    // insert all properties into the ListBox
    Property *pp = Comp->Props.first();
    FileEdit->setText(pp->Value);
    FileCheck->setChecked(pp->display);
    SimCheck->setChecked(Comp->Props.at(2)->Value == "yes");
    for(int i=0; i<PrepCombo->count(); i++)
    {
        if(PrepCombo->text(i) == Comp->Props.at(3)->Value)
        {
            PrepCombo->setCurrentItem(i);
            currentPrep = i;
            break;
        }
    }

    loadSpiceNetList(pp->Value);  // load netlist nodes
}
Beispiel #30
0
MriWatcherGUI::MriWatcherGUI(QWidget *parent)
{
  setupUi(this);
  installEventFilter(this);
  setAcceptDrops(true);

  connect(g_loadimg, SIGNAL( clicked() ), this, SLOT( LoadImg() ) );
  connect(g_loadoverlay, SIGNAL( clicked() ), this, SLOT( LoadOverlay() ) );
  connect(g_loadimg2, SIGNAL( clicked() ), this, SLOT( LoadImg2() ) );
  connect(g_reset_view, SIGNAL( clicked() ), this, SLOT( ResetView() ) );
  connect(g_screenshot, SIGNAL( clicked() ), this, SLOT( ScreenShot() ) );
  connect(g_combine, SIGNAL( clicked() ), this, SLOT( Combine() ) );
  connect(g_help, SIGNAL( clicked() ), this, SLOT( Help() ) );
  connect(g_xview, SIGNAL( toggled(bool) ), this, SLOT( ChangeView() ) );
  connect(g_yview, SIGNAL( toggled(bool) ), this, SLOT( ChangeView() ) );
  connect(g_zview, SIGNAL( toggled(bool) ), this, SLOT( ChangeView() ) );
  connect(g_slice_slider, SIGNAL( sliderMoved(int) ), this, SLOT( ChangeSlice(int) ) );
//    connect(g_slice_slider, SIGNAL( valueChanged(int) ), this, SLOT( ChangeSlice(int) ));
  connect(g_overlay_alpha_slider, SIGNAL( valueChanged(int) ), this, SLOT( ChangeOverlayAlpha(int) ) );
  connect(g_draw_name, SIGNAL( stateChanged(int) ), this, SLOT( DrawImageName(int) ) );
  connect(g_draw_info, SIGNAL( stateChanged(int) ), this, SLOT( DrawImageInfo(int) ) );
  connect(g_draw_position, SIGNAL( stateChanged(int) ), this, SLOT( DrawImagePosition(int) ) );
  connect(g_draw_intensity, SIGNAL( stateChanged(int) ), this, SLOT( DrawImageIntensity(int) ) );
  connect(g_overlayzero, SIGNAL( stateChanged(int) ), this, SLOT( ChangeOverlayZero() ) );
  connect(g_intensity_min_slider, SIGNAL( valueChanged(int) ), this, SLOT( ChangeIntensityMin(int) ) );
  connect(g_intensity_max_slider, SIGNAL( valueChanged(int) ), this, SLOT( ChangeIntensityMax(int) ) );
  connect(g_blending_mode, SIGNAL( stateChanged(int) ), this, SLOT( SetBlendingMode() ) );
  connect(g_alpha, SIGNAL( valueChanged(int) ), this, SLOT( ChangeImageAlpha(int) ) );
  connect(g_viewall, SIGNAL( toggled(bool) ), this, SLOT( ViewOptions() ) );
  connect(g_viewcolumn, SIGNAL( toggled(bool) ), this, SLOT( ViewOptions() ) );
  // connect(g_nbcolumn, SIGNAL( returnPressed() ), this, SLOT( ViewOptions() ) );
  connect(g_nbcolumn, SIGNAL( valueChanged(int) ), this, SLOT( ChangeColumn() ));
  connect(g_overlaymin, SIGNAL( returnPressed() ), this, SLOT( ChangeOverlayMinMax() ) );
  connect(g_overlaymax, SIGNAL( returnPressed() ), this, SLOT( ChangeOverlayMinMax() ) );

  m_direction = 0;
  m_numberofimages = 0;
  m_maxsize[0] = 0;
  m_maxsize[1] = 0;
  m_maxsize[2] = 0;
  m_imagemin = 999999;
  m_imagemax = 0;
  m_keyalt = false;
  m_keyctrl = false;   // multiselection
  m_overlaymin = 0;
  m_overlaymax = 0;
  m_imagemanager.ChangeAlpha(100);

  g_slice_slider->setEnabled(false);
  g_overlay_alpha_slider->setEnabled(false);

  g_intensity_min_slider->setMinimum(0);
  g_intensity_max_slider->setMinimum(0);
  g_intensity_min_slider->setMaximum(static_cast<int>(MAX_PERCENTAGE) );
  g_intensity_max_slider->setMaximum(static_cast<int>(MAX_PERCENTAGE) );
  g_intensity_min_slider->setValue(0);
  g_intensity_max_slider->setValue(static_cast<int>(MAX_PERCENTAGE) );

  m_frame = new MriWatcherFrame(g_scrollArea);

  connect(m_frame, SIGNAL( UnSelectAll() ), this, SLOT( UnSelectAll() ) );
  connect(m_frame, SIGNAL( GetFiles(const QString &) ), this, SLOT( LoadFile(const QString &) ) );
  //   m_imageframelayout = new ImageFrameLayout();
  //   QBoxLayout* gm = new QVBoxLayout(m_frame);
  m_imageframelayout = new ImageFrameLayout();
//    g_scrollArea->setLayout(m_imageframelayout);
  g_scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
  g_scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  // g_scrollArea->verticalScrollBar()->setRange();
  g_scrollArea->setWidget(m_frame);
  m_frame->setLayout(m_imageframelayout);

  g_name_version->setText(QString("MriWatcher") + "  " + MriWatcher_VERSION);
  g_tips->setText(
    "\nQuick Tips:\n- Left mouse drag: Move image\n- Right mouse drag: Zoom in/out\n- Middle mouse: Pick one voxel\n- Control + mouse: Pick images\n- Shift + mouse: Global operatation\n- Left or right key: Switch order\n- Delete key: Remove image");
/*
     imageLabel = new QLabel;
     imageLabel->setBackgroundRole(QPalette::Base);
     imageLabel->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
     imageLabel->setScaledContents(true);

     g_scrollArea->setBackgroundRole(QPalette::Dark);
     g_scrollArea->setWidget(imageLabel);
     */
}