예제 #1
0
QgsBrowserDockWidget::QgsBrowserDockWidget( const QString& name, QWidget * parent )
    : QgsDockWidget( parent )
    , mModel( nullptr )
    , mProxyModel( nullptr )
    , mPropertiesWidgetEnabled( false )
    , mPropertiesWidgetHeight( 0 )
{
  setupUi( this );

  setWindowTitle( name );

  mBrowserView = new QgsDockBrowserTreeView( this );
  mLayoutBrowser->addWidget( mBrowserView );

  mWidgetFilter->hide();
  mLeFilter->setPlaceholderText( tr( "Type here to filter visible items..." ) );
  // icons from http://www.fatcow.com/free-icons License: CC Attribution 3.0

  QMenu* menu = new QMenu( this );
  menu->setSeparatorsCollapsible( false );
  mBtnFilterOptions->setMenu( menu );
  QAction* action = new QAction( tr( "Case Sensitive" ), menu );
  action->setData( "case" );
  action->setCheckable( true );
  action->setChecked( false );
  connect( action, SIGNAL( toggled( bool ) ), this, SLOT( setCaseSensitive( bool ) ) );
  menu->addAction( action );
  QActionGroup* group = new QActionGroup( menu );
  action = new QAction( tr( "Filter Pattern Syntax" ), group );
  action->setSeparator( true );
  menu->addAction( action );
  action = new QAction( tr( "Normal" ), group );
  action->setData( "normal" );
  action->setCheckable( true );
  action->setChecked( true );
  menu->addAction( action );
  action = new QAction( tr( "Wildcard(s)" ), group );
  action->setData( "wildcard" );
  action->setCheckable( true );
  menu->addAction( action );
  action = new QAction( tr( "Regular Expression" ), group );
  action->setData( "regexp" );
  action->setCheckable( true );
  menu->addAction( action );

  connect( mActionRefresh, SIGNAL( triggered( bool ) ), this, SLOT( refresh() ) );
  connect( mActionAddLayers, SIGNAL( triggered( bool ) ), this, SLOT( addSelectedLayers() ) );
  connect( mActionCollapse, SIGNAL( triggered( bool ) ), mBrowserView, SLOT( collapseAll() ) );
  connect( mActionShowFilter, SIGNAL( triggered( bool ) ), this, SLOT( showFilterWidget( bool ) ) );
  connect( mActionPropertiesWidget, SIGNAL( triggered( bool ) ), this, SLOT( enablePropertiesWidget( bool ) ) );
  connect( mLeFilter, SIGNAL( returnPressed() ), this, SLOT( setFilter() ) );
  connect( mLeFilter, SIGNAL( cleared() ), this, SLOT( setFilter() ) );
  connect( mLeFilter, SIGNAL( textChanged( const QString & ) ), this, SLOT( setFilter() ) );
  connect( group, SIGNAL( triggered( QAction * ) ), this, SLOT( setFilterSyntax( QAction * ) ) );
  connect( mBrowserView, SIGNAL( customContextMenuRequested( const QPoint & ) ), this, SLOT( showContextMenu( const QPoint & ) ) );
  connect( mBrowserView, SIGNAL( doubleClicked( const QModelIndex& ) ), this, SLOT( addLayerAtIndex( const QModelIndex& ) ) );
  connect( mSplitter, SIGNAL( splitterMoved( int, int ) ), this, SLOT( splitterMoved() ) );
}
예제 #2
0
	CNotificationManager::CNotificationManager(QWidget * mainWindow, QObject * parent) : QObject(parent), m_MainWindow(mainWindow) {
		m_MainIcon = new QSystemTrayIcon(QIcon(UI_ICON_QNUT_SMALL), this);

		QMenu * trayMenu = new QMenu("QNUT");
		trayMenu->setSeparatorsCollapsible(true);
		trayMenu->addAction(tr("Open Connection &Manager"), m_MainWindow, SLOT(show()));
		trayMenu->addSeparator();
		m_InsertMarker = trayMenu->addSeparator();
		trayMenu->addAction(tr("&Quit"), qApp, SLOT(quit()));

		m_MainIcon->setContextMenu(trayMenu);
		m_MainIcon->show();

		connect(m_MainIcon, &QSystemTrayIcon::activated,
			this, &CNotificationManager::handleMainIconActivated);

		if (m_MainWindow)
			qApp->setQuitOnLastWindowClosed(false);
	}
예제 #3
0
void RightClickLabel::mousePressEvent(QMouseEvent* event)
{
	if(event->button() == Qt::RightButton)
	{
		QMenu menu;
		QAction* action;
		QLineEdit* lineEdit = new QLineEdit(&menu);
		QWidgetAction* wa = new QWidgetAction(&menu);
		int speed = (m_nSpeed) ? (m_nSpeed/1024) : 200;

		lineEdit->setText(QString::number(m_nSpeed/1024));
		//lineEdit->setInputMask("00000");
		wa->setDefaultWidget(lineEdit);
		connect(lineEdit, SIGNAL(returnPressed()), this, SLOT(customSpeedEntered()));
		connect(lineEdit, SIGNAL(returnPressed()), &menu, SLOT(close()));
		
		menu.setSeparatorsCollapsible(false);
		action = menu.addSeparator();
		action->setText(m_bUpload ? tr("Upload") : tr("Download"));
		menu.addAction(wa);
		menu.addSeparator();
		
		action = menu.addAction(QString::fromUtf8("∞ kB/s"));
		action->setData(0);
		connect(action, SIGNAL(triggered()), this, SLOT(setLimit()));
		menu.addSeparator();
		
		int step = speed/4;
		speed *= 2;
		
		for(int i=0;i<8 && speed;i++)
		{
			action = menu.addAction(formatSize(speed*1024, true));
			action->setData(speed);
			connect(action, SIGNAL(triggered()), this, SLOT(setLimit()));
			
			speed -= step;
		}
		
		menu.exec(QCursor::pos());
	}
}
QgsRasterHistogramWidget::QgsRasterHistogramWidget( QgsRasterLayer* lyr, QWidget *parent )
    : QWidget( parent ),
    mRasterLayer( lyr ), mRendererWidget( 0 )
{
  setupUi( this );

  mSaveAsImageButton->setIcon( QgsApplication::getThemeIcon( "/mActionFileSave.png" ) );

  mRendererWidget = 0;
  mRendererName = "singlebandgray";

  mHistoMin = 0;
  mHistoMax = 0;

  mHistoPicker = NULL;
  mHistoZoomer = NULL;
  mHistoMarkerMin = NULL;
  mHistoMarkerMax = NULL;

  QSettings settings;
  mHistoShowMarkers = settings.value( "/Raster/histogram/showMarkers", false ).toBool();
  // mHistoLoadApplyAll = settings.value( "/Raster/histogram/loadApplyAll", false ).toBool();
  mHistoZoomToMinMax = settings.value( "/Raster/histogram/zoomToMinMax", false ).toBool();
  mHistoUpdateStyleToMinMax = settings.value( "/Raster/histogram/updateStyleToMinMax", true ).toBool();
  // mHistoShowBands = (HistoShowBands) settings.value( "/Raster/histogram/showBands", (int) ShowAll ).toInt();
  mHistoShowBands = ShowAll;

  if ( true )
  {
    //band selector
    int myBandCountInt = mRasterLayer->bandCount();
    for ( int myIteratorInt = 1;
          myIteratorInt <= myBandCountInt;
          ++myIteratorInt )
    {
      cboHistoBand->addItem( mRasterLayer->bandName( myIteratorInt ) );
    }

    // histo min/max selectors
    leHistoMin->setValidator( new QDoubleValidator( this ) );
    leHistoMax->setValidator( new QDoubleValidator( this ) );
    // this might generate many refresh events! test..
    // connect( leHistoMin, SIGNAL( textChanged( const QString & ) ), this, SLOT( updateHistoMarkers() ) );
    // connect( leHistoMax, SIGNAL( textChanged( const QString & ) ), this, SLOT( updateHistoMarkers() ) );
    // connect( leHistoMin, SIGNAL( textChanged( const QString & ) ), this, SLOT( applyHistoMin() ) );
    // connect( leHistoMax, SIGNAL( textChanged( const QString & ) ), this, SLOT( applyHistoMax() ) );
    connect( leHistoMin, SIGNAL( editingFinished() ), this, SLOT( applyHistoMin() ) );
    connect( leHistoMax, SIGNAL( editingFinished() ), this, SLOT( applyHistoMax() ) );

    // histo actions
    QMenu* menu = new QMenu( this );
    menu->setSeparatorsCollapsible( false );
    btnHistoActions->setMenu( menu );
    QActionGroup* group;
    QAction* action;

    // min/max options
    group = new QActionGroup( this );
    group->setExclusive( false );
    connect( group, SIGNAL( triggered( QAction* ) ), this, SLOT( histoActionTriggered( QAction* ) ) );
    action = new QAction( tr( "Min/Max options" ), group );
    action->setSeparator( true );
    menu->addAction( action );
    action = new QAction( tr( "Always show min/max markers" ), group );
    action->setData( QVariant( "Show markers" ) );
    action->setCheckable( true );
    action->setChecked( mHistoShowMarkers );
    menu->addAction( action );
    action = new QAction( tr( "Zoom to min/max" ), group );
    action->setData( QVariant( "Zoom min_max" ) );
    action->setCheckable( true );
    action->setChecked( mHistoZoomToMinMax );
    menu->addAction( action );
    action = new QAction( tr( "Update style to min/max" ), group );
    action->setData( QVariant( "Update min_max" ) );
    action->setCheckable( true );
    action->setChecked( mHistoUpdateStyleToMinMax );
    menu->addAction( action );

    // visibility options
    group = new QActionGroup( this );
    group->setExclusive( false );
    connect( group, SIGNAL( triggered( QAction* ) ), this, SLOT( histoActionTriggered( QAction* ) ) );
    action = new QAction( tr( "Visibility" ), group );
    action->setSeparator( true );
    menu->addAction( action );
    group = new QActionGroup( this );
    group->setExclusive( true ); // these options are exclusive
    connect( group, SIGNAL( triggered( QAction* ) ), this, SLOT( histoActionTriggered( QAction* ) ) );
    action = new QAction( tr( "Show all bands" ), group );
    action->setData( QVariant( "Show all" ) );
    action->setCheckable( true );
    action->setChecked( mHistoShowBands == ShowAll );
    menu->addAction( action );
    action = new QAction( tr( "Show RGB/Gray band(s)" ), group );
    action->setData( QVariant( "Show RGB" ) );
    action->setCheckable( true );
    action->setChecked( mHistoShowBands == ShowRGB );
    menu->addAction( action );
    action = new QAction( tr( "Show selected band" ), group );
    action->setData( QVariant( "Show selected" ) );
    action->setCheckable( true );
    action->setChecked( mHistoShowBands == ShowSelected );
    menu->addAction( action );

    // actions
    action = new QAction( tr( "Actions" ), group );
    action->setSeparator( true );
    menu->addAction( action );

    // load actions
    group = new QActionGroup( this );
    group->setExclusive( false );
    connect( group, SIGNAL( triggered( QAction* ) ), this, SLOT( histoActionTriggered( QAction* ) ) );
    action = new QAction( tr( "Reset" ), group );
    action->setData( QVariant( "Load reset" ) );
    menu->addAction( action );

    // these actions have been disabled for api cleanup, restore them eventually
#if 0
    // Load min/max needs 3 params (method, extent, accuracy), cannot put it in single item
    action = new QAction( tr( "Load min/max" ), group );
    action->setSeparator( true );
    menu->addAction( action );
    action = new QAction( tr( "Estimate (faster)" ), group );
    action->setData( QVariant( "Load estimate" ) );
    menu->addAction( action );
    action = new QAction( tr( "Actual (slower)" ), group );
    action->setData( QVariant( "Load actual" ) );
    menu->addAction( action );
    action = new QAction( tr( "Current extent" ), group );
    action->setData( QVariant( "Load extent" ) );
    menu->addAction( action );
    action = new QAction( tr( "Use stddev (1.0)" ), group );
    action->setData( QVariant( "Load 1 stddev" ) );
    menu->addAction( action );
    action = new QAction( tr( "Use stddev (custom)" ), group );
    action->setData( QVariant( "Load stddev" ) );
    menu->addAction( action );
    action = new QAction( tr( "Load for each band" ), group );
    action->setData( QVariant( "Load apply all" ) );
    action->setCheckable( true );
    action->setChecked( mHistoLoadApplyAll );
    menu->addAction( action );
#endif

    //others
    action = new QAction( tr( "Recompute Histogram" ), group );
    action->setData( QVariant( "Compute histogram" ) );
    menu->addAction( action );

  }
예제 #5
0
void QMenuProto::setSeparatorsCollapsible(bool collapse)
{
  QMenu *item = qscriptvalue_cast<QMenu*>(thisObject());
  if (item)
    item->setSeparatorsCollapsible(collapse);
}
예제 #6
0
// Neue Widget-Klasse vom eigentlichen Widget ableiten
MyWindow::MyWindow( QMainWindow *parent,
                    Qt::WindowFlags flags) :
                    QMainWindow(parent, flags)  {
    editor = new QTextEdit;
    editor->setWhatsThis(
                "Dieser Text kann mit (Shift)+(F1) angezeigt werden."
                "Auch eine <b>HTML-Formatierung</b> ist möglich. ");


    // Das komplette Menü zum Hauptprogramm
    QMenu *fileMenu = new QMenu(tr("&Datei"), this);
    menuBar()->addMenu(fileMenu);
    act1 = fileMenu->addAction(
                QIcon(QString("%1%2").arg(QCoreApplication::applicationDirPath()).arg("/images/page_white.png")), tr("&Neu"),
       this, SLOT(newFile()),
       QKeySequence(tr("Ctrl+N", "Datei|Neu")) );
    act1->setStatusTip(
       tr("Löscht den aktuellen Inhalt der Datei"));
    act2 = fileMenu->addAction(
                QIcon(QString("%1%2").arg(QCoreApplication::applicationDirPath()).arg("/images/folder_page_white.png")),
       tr("&Öffnen..."), this, SLOT(openFile() ),
       QKeySequence(tr("Ctrl+O", "Datei|Öffnen")));
    act2->setStatusTip(
       tr("Öffnet eine Datei in den Texteditor"));
    fileMenu->addSeparator();
    act3 = fileMenu->addAction(
                QIcon(QString("%1%2").arg(QCoreApplication::applicationDirPath()).arg("/images/cancel.png"))   ,
                tr("Be&enden"),
       qApp, SLOT(quit()),
       QKeySequence(tr("Ctrl+E", "Datei|Beenden")) );
    act3->setStatusTip(tr("Programm beenden"));
    QMenu *workMenu = new QMenu(
       tr("&Bearbeiten"), this);
    menuBar()->addMenu(workMenu);
    act4 = workMenu->addAction(
       tr("&Suchen"), this, SLOT(search()),
       QKeySequence(tr("Ctrl+S", "Bearbeiten|Suchen")));
    act4->setStatusTip(
       tr("Nach einer Stringfolge suchen") );
    // Menü mit Linie von der Leiste Abnehmbar
    fileMenu->setSeparatorsCollapsible(true);

    // Mehrere Aktionen erzeugen
    QAction* underLineAct = new QAction(
       tr("&Unterstreichen"), this );
    underLineAct->setCheckable(true);
    underLineAct->setShortcut(tr("Ctrl+U"));
    underLineAct->setStatusTip(
       tr("Text unterstreichen") );
    underLineAct->setIcon(
                QIcon(QString("%1%2").arg(QCoreApplication::applicationDirPath()).arg("/images/text_underline.png")));
    connect( underLineAct, SIGNAL(triggered(bool)),
             editor, SLOT(setFontUnderline(bool)) );

    QAction *leftAlignAct = new QAction(
       tr("&Links ausgerichtet"), this);
    leftAlignAct->setCheckable(true);
    leftAlignAct->setShortcut(tr("Ctrl+L"));
    leftAlignAct->setStatusTip(
       tr("Text links ausrichten"));
    leftAlignAct->setIcon(
                 QIcon(QString("%1%2").arg(QCoreApplication::applicationDirPath()).arg("/images/text_align_left.png")));
    connect( leftAlignAct, SIGNAL(triggered()),
             this, SLOT(leftAlignment() ) );

    QAction *rightAlignAct = new QAction(
       tr("&Rechts ausgerichtet"), this);
    rightAlignAct->setCheckable(true);
    rightAlignAct->setShortcut(tr("Ctrl+R"));
    rightAlignAct->setStatusTip(
       tr("Text rechts ausrichten") );
    rightAlignAct->setIcon(
                 QIcon(QString("%1%2").arg(QCoreApplication::applicationDirPath()).arg("/images/text_align_right.png")));
    connect( rightAlignAct, SIGNAL(triggered()),
             this, SLOT(rightAlignment() ) );

    QAction *justifyAct = new QAction(
       tr("&Bündig ausrichten"), this);
    justifyAct->setCheckable(true);
    justifyAct->setShortcut(tr("Ctrl+J"));
    justifyAct->setStatusTip(
       tr("Text bündig ausrichten"));
    justifyAct->setIcon(
                QIcon(QString("%1%2").arg(QCoreApplication::applicationDirPath()).arg("/images/text_align_justify.png")));
    connect( justifyAct, SIGNAL(triggered()),
             this, SLOT(justifyAlignment() ) );

    QAction *centerAct = new QAction(
       tr("&Zentriert ausrichten"), this);
    centerAct->setCheckable(true);
    centerAct->setShortcut(tr("Ctrl+E"));
    centerAct->setStatusTip(
       tr("Text zentriert ausrichten") );
    centerAct->setIcon(
                  QIcon(QString("%1%2").arg(QCoreApplication::applicationDirPath()).arg("/images/text_align_center.png")));
    connect( centerAct, SIGNAL(triggered()),
             this, SLOT(centerAlignment() ) );

    // Einige Aktionen zu einer Gruppe zusammenfassen
    QActionGroup* alignmentGroup = new QActionGroup(
       this );
    alignmentGroup->addAction(leftAlignAct);
    alignmentGroup->addAction(rightAlignAct);
    alignmentGroup->addAction(justifyAct);
    alignmentGroup->addAction(centerAct);
    leftAlignAct->setChecked(true);

    // Nochmals zwei weitere Aktionen
    QAction *InZoom = new QAction(
       tr("&Zoom in ..."), this );
    InZoom->setStatusTip(tr("Zoom in the text"));
    connect( InZoom, SIGNAL(triggered()),
             editor, SLOT(zoomIn() ) );
    QAction *OutZoom = new QAction(
       tr("&Zoom out ..."), this );
    OutZoom->setStatusTip(tr("Zoom out the text"));
    connect( OutZoom, SIGNAL(triggered() ),
             editor, SLOT(zoomOut() ) );

    // Ein Sub-Menü "Format" bei "Bearbeiten" einfügen
    QMenu *formatMenu = workMenu->addMenu(
       tr("&Format") );
    formatMenu->addAction(underLineAct);
    formatMenu->addSeparator();
    formatMenu->addAction(leftAlignAct);
    formatMenu->addAction(rightAlignAct);
    formatMenu->addAction(justifyAct);
    formatMenu->addAction(centerAct);
    formatMenu->addSeparator();
    formatMenu->addAction(InZoom);
    formatMenu->addAction(OutZoom);
    workMenu->setTearOffEnabled(true);
    workMenu->setWindowTitle("Bearbeiten");

    // Zur Demonstration eine Aktion mit QVariant
    Start = new QAction(tr("&Programmstart ..."), this);
    Start->setStatusTip(tr("Zeit des Programmstarts"));
    Start->setData(QVariant(QTime::currentTime()));
    QFont font; font.setBold(true);
    Start->setFont(font);
    Start->setShortcut(tr("Ctrl+T"));
    Start->setShortcutContext(Qt::ApplicationShortcut);
    connect( Start, SIGNAL( triggered() ),
             this, SLOT( printStart() ) );
    workMenu->addAction(Start);


    // Eine neue Statusleiste erzeugen und zum
    // Hauptfenster hinzufügen
    (void*) statusBar ();
    // Permanente Meldung in der Statusleiste
    // Zeichen, Wörter, Zeilen
    sLabel = new QLabel;
    sLabel->setFrameStyle(
       QFrame::Panel | QFrame::Sunken );
    sLabel->setLineWidth(2);
    statusBar()->addPermanentWidget(sLabel);
    connect( editor, SIGNAL( textChanged() ),
             this, SLOT( updateStatusBar() ) );
    updateStatusBar();
    // Laufend aktuelle Uhrzeit in der Statusleiste
    time = new QLCDNumber;
    time->setFrameStyle(QFrame::Panel | QFrame::Sunken);
    time->setLineWidth(2);
    time->setSegmentStyle(QLCDNumber::Flat);
    statusBar()->addPermanentWidget(time);
    QTimer *timer = new QTimer(this);
    connect( timer, SIGNAL(timeout()),
             this, SLOT(updateTime()) );
    // Jede Sekunde updateTime() aufrufen
    timer->start(1000);
    updateTime();

    // Werkzeugleiste erzeugen
    toolFile = addToolBar(tr("Datei"));
    // Icons mit Text darunter anzeigen
    toolFile->setToolButtonStyle (
       Qt::ToolButtonTextUnderIcon );
    // Werkzeugleiste nur nach links
    // oder oben Verschiebbar
    toolFile->setAllowedAreas(
       Qt::LeftToolBarArea | Qt::TopToolBarArea );
    // Aktionen zur Werkzeugleiste hinzufügen
    toolFile->addAction(act1);
    toolFile->addAction(act2);
    toolFile->addAction(act3);
    // Noch eine Werkzeugleiste
    toolWork = addToolBar(tr("Bearbeiten"));
    // Werkzeugleiste unten anzeigen
    addToolBar(Qt::TopToolBarArea, toolWork );
    // Position nicht mehr veränderbar
    toolWork->setMovable(false);
    // Aktionen zur Werkzeugleiste hinzufügen
    toolWork->addAction(underLineAct);
    toolWork->addSeparator ();
    toolWork->addAction(leftAlignAct);
    toolWork->addAction(rightAlignAct);
    toolWork->addAction(justifyAct);
    toolWork->addAction(centerAct);
    toolWork->addSeparator ();
    // Eine Schrift-Combobox zur Werkzeugleiste
    QFontComboBox *cFont = new QFontComboBox;
    toolWork->addWidget(cFont);
    connect(
      cFont, SIGNAL( currentFontChanged(const QFont& )),
      editor, SLOT(setCurrentFont ( const QFont&) ) );

    // Ein neues Dock-Widget-erzeugen
    QDockWidget *dock = new QDockWidget(
       tr("WYSIWYG-Editor"), this );
    // nur in den rechten und linken Bereich erlauben
    dock->setAllowedAreas(
       Qt::LeftDockWidgetArea|Qt::RightDockWidgetArea);
    // Widget für das Dock-Widget erzeugen
    dock_editor = new QTextEdit;
    // Editor als Widget im Dock-Fenster verwenden
    dock->setWidget(dock_editor);
    // auf der rechten Seite zum Hauptfenster hinzufügen
    addDockWidget(Qt::RightDockWidgetArea, dock);
    connect( editor, SIGNAL(textChanged() ),
             this, SLOT( showHTML() ) );

    // Einstellungen des Programms speichern
    // Im Beispiel wird nur (ggf.) die zuletzt
    // geöffnete Datei und die Größe des Fensters
    settings = new QSettings(
       tr("J.Wolf"), tr("JWTexteditor") );
    settings->beginGroup("HauptFenster");
    QString fileName =
       settings->value("lastFile").toString();
    QSize size =
       settings->value("size", sizeHint()).toSize();
    if (!fileName.isEmpty()) {
       QFile file(fileName);
       if (file.open(QFile::ReadOnly | QFile::Text)) {
          editor->setPlainText(file.readAll());
          statusBar()->showMessage(
             tr("Zuletzt geöffnete Datei "
                "erfolgreich geladen"));
          // Wieder setzen
          settings->setValue("lastFile", fileName );
       }
       else // falls die Datei nicht mehr existiert
          settings->setValue("lastFile", "");
    }
    else // Keine Datei gesetzt
       settings->setValue("lastFile", "");
    settings->endGroup();

    if( size.isNull() )
       resize(640, 480);
    else
       resize(size);
    setCentralWidget(editor);
    setWindowTitle("QMainWindow - Demo");
}
예제 #7
0
QgsRasterHistogramWidget::QgsRasterHistogramWidget( QgsRasterLayer* lyr, QWidget *parent )
    : QgsMapLayerConfigWidget( lyr, nullptr, parent )
    , mRasterLayer( lyr )
    , mRendererWidget( nullptr )
{
  setupUi( this );

  mSaveAsImageButton->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionFileSave.svg" ) ) );

  mRendererWidget = nullptr;
  mRendererName = QStringLiteral( "singlebandgray" );

  mHistoMin = 0;
  mHistoMax = 0;

  mHistoPicker = nullptr;
  mHistoZoomer = nullptr;
  mHistoMarkerMin = nullptr;
  mHistoMarkerMax = nullptr;

  QSettings settings;
  mHistoShowMarkers = settings.value( QStringLiteral( "/Raster/histogram/showMarkers" ), false ).toBool();
  // mHistoLoadApplyAll = settings.value( "/Raster/histogram/loadApplyAll", false ).toBool();
  mHistoZoomToMinMax = settings.value( QStringLiteral( "/Raster/histogram/zoomToMinMax" ), false ).toBool();
  mHistoUpdateStyleToMinMax = settings.value( QStringLiteral( "/Raster/histogram/updateStyleToMinMax" ), true ).toBool();
  mHistoDrawLines = settings.value( QStringLiteral( "/Raster/histogram/drawLines" ), true ).toBool();
  // mHistoShowBands = (HistoShowBands) settings.value( "/Raster/histogram/showBands", (int) ShowAll ).toInt();
  mHistoShowBands = ShowAll;

  bool isInt = true;
  if ( true )
  {
    //band selector
    int myBandCountInt = mRasterLayer->bandCount();
    for ( int myIteratorInt = 1;
          myIteratorInt <= myBandCountInt;
          ++myIteratorInt )
    {
      cboHistoBand->addItem( mRasterLayer->bandName( myIteratorInt ) );
      Qgis::DataType mySrcDataType = mRasterLayer->dataProvider()->sourceDataType( myIteratorInt );
      if ( !( mySrcDataType == Qgis::Byte ||
              mySrcDataType == Qgis::Int16 || mySrcDataType == Qgis::Int32 ||
              mySrcDataType == Qgis::UInt16 || mySrcDataType == Qgis::UInt32 ) )
        isInt = false;
    }

    // histo min/max selectors
    leHistoMin->setValidator( new QDoubleValidator( this ) );
    leHistoMax->setValidator( new QDoubleValidator( this ) );
    // this might generate many refresh events! test..
    // connect( leHistoMin, SIGNAL( textChanged( const QString & ) ), this, SLOT( updateHistoMarkers() ) );
    // connect( leHistoMax, SIGNAL( textChanged( const QString & ) ), this, SLOT( updateHistoMarkers() ) );
    // connect( leHistoMin, SIGNAL( textChanged( const QString & ) ), this, SLOT( applyHistoMin() ) );
    // connect( leHistoMax, SIGNAL( textChanged( const QString & ) ), this, SLOT( applyHistoMax() ) );
    connect( leHistoMin, SIGNAL( editingFinished() ), this, SLOT( applyHistoMin() ) );
    connect( leHistoMax, SIGNAL( editingFinished() ), this, SLOT( applyHistoMax() ) );

    // histo actions
    // TODO move/add options to qgis options dialog
    QMenu* menu = new QMenu( this );
    menu->setSeparatorsCollapsible( false );
    btnHistoActions->setMenu( menu );
    QActionGroup* group;
    QAction* action;

    // min/max options
    group = new QActionGroup( this );
    group->setExclusive( false );
    connect( group, SIGNAL( triggered( QAction* ) ), this, SLOT( histoActionTriggered( QAction* ) ) );
    action = new QAction( tr( "Min/Max options" ), group );
    action->setSeparator( true );
    menu->addAction( action );
    action = new QAction( tr( "Always show min/max markers" ), group );
    action->setData( QVariant( "Show markers" ) );
    action->setCheckable( true );
    action->setChecked( mHistoShowMarkers );
    menu->addAction( action );
    action = new QAction( tr( "Zoom to min/max" ), group );
    action->setData( QVariant( "Zoom min_max" ) );
    action->setCheckable( true );
    action->setChecked( mHistoZoomToMinMax );
    menu->addAction( action );
    action = new QAction( tr( "Update style to min/max" ), group );
    action->setData( QVariant( "Update min_max" ) );
    action->setCheckable( true );
    action->setChecked( mHistoUpdateStyleToMinMax );
    menu->addAction( action );

    // visibility options
    group = new QActionGroup( this );
    group->setExclusive( false );
    connect( group, SIGNAL( triggered( QAction* ) ), this, SLOT( histoActionTriggered( QAction* ) ) );
    action = new QAction( tr( "Visibility" ), group );
    action->setSeparator( true );
    menu->addAction( action );
    group = new QActionGroup( this );
    group->setExclusive( true ); // these options are exclusive
    connect( group, SIGNAL( triggered( QAction* ) ), this, SLOT( histoActionTriggered( QAction* ) ) );
    action = new QAction( tr( "Show all bands" ), group );
    action->setData( QVariant( "Show all" ) );
    action->setCheckable( true );
    action->setChecked( mHistoShowBands == ShowAll );
    menu->addAction( action );
    action = new QAction( tr( "Show RGB/Gray band(s)" ), group );
    action->setData( QVariant( "Show RGB" ) );
    action->setCheckable( true );
    action->setChecked( mHistoShowBands == ShowRGB );
    menu->addAction( action );
    action = new QAction( tr( "Show selected band" ), group );
    action->setData( QVariant( "Show selected" ) );
    action->setCheckable( true );
    action->setChecked( mHistoShowBands == ShowSelected );
    menu->addAction( action );

    // display options
    group = new QActionGroup( this );
    group->setExclusive( false );
    connect( group, SIGNAL( triggered( QAction* ) ), this, SLOT( histoActionTriggered( QAction* ) ) );
    action = new QAction( tr( "Display" ), group );
    action->setSeparator( true );
    menu->addAction( action );
    // should we plot as histogram instead of line plot? (int data only)
    action = new QAction( QLatin1String( "" ), group );
    action->setData( QVariant( "Draw lines" ) );
    if ( isInt )
    {
      action->setText( tr( "Draw as lines" ) );
      action->setCheckable( true );
      action->setChecked( mHistoDrawLines );
    }
    else
    {
      action->setText( tr( "Draw as lines (only int layers)" ) );
      action->setEnabled( false );
    }
    menu->addAction( action );

    // actions
    action = new QAction( tr( "Actions" ), group );
    action->setSeparator( true );
    menu->addAction( action );

    // load actions
    group = new QActionGroup( this );
    group->setExclusive( false );
    connect( group, SIGNAL( triggered( QAction* ) ), this, SLOT( histoActionTriggered( QAction* ) ) );
    action = new QAction( tr( "Reset" ), group );
    action->setData( QVariant( "Load reset" ) );
    menu->addAction( action );

    // these actions have been disabled for api cleanup, restore them eventually
    // TODO restore these in qgis 2.4
#if 0
    // Load min/max needs 3 params (method, extent, accuracy), cannot put it in single item
    action = new QAction( tr( "Load min/max" ), group );
    action->setSeparator( true );
    menu->addAction( action );
    action = new QAction( tr( "Estimate (faster)" ), group );
    action->setData( QVariant( "Load estimate" ) );
    menu->addAction( action );
    action = new QAction( tr( "Actual (slower)" ), group );
    action->setData( QVariant( "Load actual" ) );
    menu->addAction( action );
    action = new QAction( tr( "Current extent" ), group );
    action->setData( QVariant( "Load extent" ) );
    menu->addAction( action );
    action = new QAction( tr( "Use stddev (1.0)" ), group );
    action->setData( QVariant( "Load 1 stddev" ) );
    menu->addAction( action );
    action = new QAction( tr( "Use stddev (custom)" ), group );
    action->setData( QVariant( "Load stddev" ) );
    menu->addAction( action );
    action = new QAction( tr( "Load for each band" ), group );
    action->setData( QVariant( "Load apply all" ) );
    action->setCheckable( true );
    action->setChecked( mHistoLoadApplyAll );
    menu->addAction( action );
#endif

    //others
    action = new QAction( tr( "Recompute Histogram" ), group );
    action->setData( QVariant( "Compute histogram" ) );
    menu->addAction( action );

  }
예제 #8
0
XmlConsole::XmlConsole(Client* client, QWidget *parent) :
	QWidget(parent),
	m_ui(new Ui::XmlConsole),
	m_client(client),	m_filter(0x1f)
{
	m_ui->setupUi(this);

    m_client->addXmlStreamHandler(this);

	QPalette pal = palette();
	pal.setColor(QPalette::Base, Qt::black);
	pal.setColor(QPalette::Text, Qt::white);
	m_ui->xmlBrowser->viewport()->setPalette(pal);
	QTextDocument *doc = m_ui->xmlBrowser->document();
	doc->setDocumentLayout(new QPlainTextDocumentLayout(doc));
	doc->clear();

	QTextFrameFormat format = doc->rootFrame()->frameFormat();
	format.setBackground(QColor(Qt::black));
	format.setMargin(0);
	doc->rootFrame()->setFrameFormat(format);
	QMenu *menu = new QMenu(m_ui->filterButton);
	menu->setSeparatorsCollapsible(false);
	menu->addSeparator()->setText(tr("Filter"));
	QActionGroup *group = new QActionGroup(menu);
	QAction *disabled = group->addAction(menu->addAction(tr("Disabled")));
	disabled->setCheckable(true);
	disabled->setData(Disabled);
	QAction *jid = group->addAction(menu->addAction(tr("By JID")));
	jid->setCheckable(true);
	jid->setData(ByJid);
	QAction *xmlns = group->addAction(menu->addAction(tr("By namespace uri")));
	xmlns->setCheckable(true);
	xmlns->setData(ByXmlns);
	QAction *attrb = group->addAction(menu->addAction(tr("By all attributes")));
	attrb->setCheckable(true);
	attrb->setData(ByAllAttributes);
	disabled->setChecked(true);
	connect(group, SIGNAL(triggered(QAction*)), this, SLOT(onActionGroupTriggered(QAction*)));
	menu->addSeparator()->setText(tr("Visible stanzas"));
	group = new QActionGroup(menu);
	group->setExclusive(false);
	QAction *iq = group->addAction(menu->addAction(tr("Information query")));
	iq->setCheckable(true);
	iq->setData(XmlNode::Iq);
	iq->setChecked(true);
	QAction *message = group->addAction(menu->addAction(tr("Message")));
	message->setCheckable(true);
	message->setData(XmlNode::Message);
	message->setChecked(true);
	QAction *presence = group->addAction(menu->addAction(tr("Presence")));
	presence->setCheckable(true);
	presence->setData(XmlNode::Presence);
	presence->setChecked(true);
	QAction *custom = group->addAction(menu->addAction(tr("Custom")));
	custom->setCheckable(true);
	custom->setData(XmlNode::Custom);
	custom->setChecked(true);
	connect(group, SIGNAL(triggered(QAction*)), this, SLOT(onActionGroupTriggered(QAction*)));
	m_ui->filterButton->setMenu(menu);
	m_stackBracketsColor = QColor(0x666666);
	m_stackIncoming.bodyColor = QColor(0xbb66bb);
	m_stackIncoming.tagColor = QColor(0x006666);
	m_stackIncoming.attributeColor = QColor(0x009933);
	m_stackIncoming.paramColor = QColor(0xcc0000);
	m_stackOutgoing.bodyColor = QColor(0x999999);
	m_stackOutgoing.tagColor = QColor(0x22aa22);
	m_stackOutgoing.attributeColor = QColor(0xffff33);
	m_stackOutgoing.paramColor = QColor(0xdd8811);

	QAction *action = new QAction(tr("Close"),this);
	action->setSoftKeyRole(QAction::NegativeSoftKey);
	connect(action, SIGNAL(triggered()), SLOT(close()));
	addAction(action);
}
예제 #9
0
QgsBrowserDockWidget::QgsBrowserDockWidget( const QString &name, QWidget *parent )
  : QgsDockWidget( parent )
  , mModel( nullptr )
  , mProxyModel( nullptr )
  , mPropertiesWidgetEnabled( false )
  , mPropertiesWidgetHeight( 0 )
{
  setupUi( this );

  mContents->layout()->setContentsMargins( 0, 0, 0, 0 );
  mContents->layout()->setMargin( 0 );
  static_cast< QVBoxLayout * >( mContents->layout() )->setSpacing( 0 );

  setWindowTitle( name );

  mBrowserView = new QgsDockBrowserTreeView( this );
  mLayoutBrowser->addWidget( mBrowserView );

  mWidgetFilter->hide();
  mLeFilter->setPlaceholderText( tr( "Type here to filter visible items..." ) );
  // icons from http://www.fatcow.com/free-icons License: CC Attribution 3.0

  QMenu *menu = new QMenu( this );
  menu->setSeparatorsCollapsible( false );
  mBtnFilterOptions->setMenu( menu );
  QAction *action = new QAction( tr( "Case Sensitive" ), menu );
  action->setData( "case" );
  action->setCheckable( true );
  action->setChecked( false );
  connect( action, &QAction::toggled, this, &QgsBrowserDockWidget::setCaseSensitive );
  menu->addAction( action );
  QActionGroup *group = new QActionGroup( menu );
  action = new QAction( tr( "Filter Pattern Syntax" ), group );
  action->setSeparator( true );
  menu->addAction( action );
  action = new QAction( tr( "Normal" ), group );
  action->setData( "normal" );
  action->setCheckable( true );
  action->setChecked( true );
  menu->addAction( action );
  action = new QAction( tr( "Wildcard(s)" ), group );
  action->setData( "wildcard" );
  action->setCheckable( true );
  menu->addAction( action );
  action = new QAction( tr( "Regular Expression" ), group );
  action->setData( "regexp" );
  action->setCheckable( true );
  menu->addAction( action );

  connect( mActionRefresh, &QAction::triggered, this, &QgsBrowserDockWidget::refresh );
  connect( mActionAddLayers, &QAction::triggered, this, &QgsBrowserDockWidget::addSelectedLayers );
  connect( mActionCollapse, &QAction::triggered, mBrowserView, &QgsDockBrowserTreeView::collapseAll );
  connect( mActionShowFilter, &QAction::triggered, this, &QgsBrowserDockWidget::showFilterWidget );
  connect( mActionPropertiesWidget, &QAction::triggered, this, &QgsBrowserDockWidget::enablePropertiesWidget );
  connect( mLeFilter, &QgsFilterLineEdit::returnPressed, this, &QgsBrowserDockWidget::setFilter );
  connect( mLeFilter, &QgsFilterLineEdit::cleared, this, &QgsBrowserDockWidget::setFilter );
  connect( mLeFilter, &QgsFilterLineEdit::textChanged, this, &QgsBrowserDockWidget::setFilter );
  connect( group, &QActionGroup::triggered, this, &QgsBrowserDockWidget::setFilterSyntax );
  connect( mBrowserView, &QgsDockBrowserTreeView::customContextMenuRequested, this, &QgsBrowserDockWidget::showContextMenu );
  connect( mBrowserView, &QgsDockBrowserTreeView::doubleClicked, this, &QgsBrowserDockWidget::addLayerAtIndex );
  connect( mSplitter, &QSplitter::splitterMoved, this, &QgsBrowserDockWidget::splitterMoved );
}