Example #1
0
void ScoreView::createElementPropertyMenu(Element* e, QMenu* popup)
      {
      if (e->type() == Element::BAR_LINE) {
            genPropertyMenu1(e, popup);
            }
      else if (e->type() == Element::ARTICULATION) {
            genPropertyMenu1(e, popup);
            popup->addAction(tr("Articulation Properties..."))->setData("a-props");
            }
      else if (e->type() == Element::BEAM) {
            popup->addAction(getAction("flip"));
            }
      else if (e->type() == Element::STEM) {
            popup->addAction(getAction("flip"));
            }
      else if (e->type() == Element::HOOK) {
            popup->addAction(getAction("flip"));
            }
      else if (e->type() == Element::BEND) {
            genPropertyMenu1(e, popup);
            popup->addAction(tr("Bend Properties..."))->setData("b-props");
            }
      else if (e->type() == Element::TREMOLOBAR) {
            genPropertyMenu1(e, popup);
            popup->addAction(tr("TremoloBar Properties..."))->setData("tr-props");
            }
      else if (e->type() == Element::HBOX) {
            QMenu* textMenu = popup->addMenu(tr("Add"));
            textMenu->addAction(getAction("frame-text"));
            textMenu->addAction(getAction("picture"));
            popup->addAction(tr("Frame Properties..."))->setData("f-props");
            }
      else if (e->type() == Element::VBOX) {
            QMenu* textMenu = popup->addMenu(tr("Add"));
            textMenu->addAction(getAction("frame-text"));
            textMenu->addAction(getAction("title-text"));
            textMenu->addAction(getAction("subtitle-text"));
            textMenu->addAction(getAction("composer-text"));
            textMenu->addAction(getAction("poet-text"));
            textMenu->addAction(getAction("insert-hbox"));
            textMenu->addAction(getAction("picture"));
            popup->addAction(tr("Frame Properties..."))->setData("f-props");
            }
      else if (e->type() == Element::TBOX) {
            popup->addAction(tr("Frame Properties..."))->setData("f-props");
            }
      else if (e->type() == Element::VOLTA_SEGMENT) {
            genPropertyMenu1(e, popup);
            popup->addAction(tr("Volta Properties..."))->setData("v-props");
            }
      else if (e->type() == Element::TIMESIG) {
            genPropertyMenu1(e, popup);
            TimeSig* ts = static_cast<TimeSig*>(e);
            int _track = ts->track();
            // if the time sig. is not generated (= not courtesy) and is in track 0
            // add the specific menu item
            QAction* a;
            if (!ts->generated() && !_track) {
                  a = popup->addAction(ts->showCourtesySig()
                     ? QT_TRANSLATE_NOOP("TimeSig", "Hide Courtesy Time Signature")
                     : QT_TRANSLATE_NOOP("TimeSig", "Show Courtesy Time Signature") );
                  a->setData("ts-courtesy");
                  }
            popup->addSeparator();
            popup->addAction(tr("Time Signature Properties..."))->setData("ts-props");
            }
      else if (e->type() == Element::ACCIDENTAL) {
            Accidental* acc = static_cast<Accidental*>(e);
            genPropertyMenu1(e, popup);
            QAction* a = popup->addAction(QT_TRANSLATE_NOOP("Properties", "small"));
            a->setCheckable(true);
            a->setChecked(acc->small());
            a->setData("smallAcc");
            }
      else if (e->type() == Element::CLEF) {
            genPropertyMenu1(e, popup);
            // if the clef is not generated (= not courtesy) add the specific menu item
            if (!e->generated()) {
                  QAction* a = popup->addAction(static_cast<Clef*>(e)->showCourtesy()
                     ? QT_TRANSLATE_NOOP("Clef", "Hide courtesy clef")
                     : QT_TRANSLATE_NOOP("Clef", "Show courtesy clef") );
                        a->setData("clef-courtesy");
                  }
            }
      else if (e->type() == Element::DYNAMIC) {
            popup->addSeparator();
            if (e->visible())
                  popup->addAction(tr("Set Invisible"))->setData("invisible");
            else
                  popup->addAction(tr("Set Visible"))->setData("invisible");
            popup->addAction(tr("MIDI Properties..."))->setData("d-dynamics");
            popup->addAction(tr("Text Properties..."))->setData("d-props");
            }
      else if (e->type() == Element::TEXTLINE_SEGMENT
                  || e->type() == Element::OTTAVA_SEGMENT
                  || e->type() == Element::VOLTA_SEGMENT
                  || e->type() == Element::PEDAL_SEGMENT) {
            if (e->visible())
                  popup->addAction(tr("Set Invisible"))->setData("invisible");
            else
                  popup->addAction(tr("Set Visible"))->setData("invisible");
            popup->addAction(tr("Line Properties..."))->setData("l-props");
            }
      else if (e->type() == Element::STAFF_TEXT) {
            genPropertyMenuText(e, popup);
            popup->addAction(tr("Staff Text Properties..."))->setData("st-props");
            }
      else if (e->type() == Element::TEXT
               || e->type() == Element::FINGERING
               || e->type() == Element::LYRICS
               || e->type() == Element::FIGURED_BASS) {
            genPropertyMenuText(e, popup);
            }
      else if (e->type() == Element::TEMPO_TEXT) {
            genPropertyMenu1(e, popup);
            popup->addAction(tr("Tempo Properties..."))->setData("tempo-props");
            popup->addAction(tr("Text Properties..."))->setData("text-props");
            }
      else if (e->type() == Element::KEYSIG) {
            genPropertyMenu1(e, popup);
            KeySig* ks = static_cast<KeySig*>(e);
            if (!e->generated()) {
                  QAction* a = popup->addAction(ks->showCourtesy()
                     ? QT_TRANSLATE_NOOP("KeySig", "Hide Courtesy Key Signature")
                     : QT_TRANSLATE_NOOP("KeySig", "Show Courtesy Key Signature") );
                  a->setData("key-courtesy");
                  a = popup->addAction(ks->showNaturals()
                     ? QT_TRANSLATE_NOOP("KeySig", "Hide Naturals")
                     : QT_TRANSLATE_NOOP("KeySig", "Show Naturals") );
                  a->setData("key-naturals");
                  }
            }
      else if (e->type() == Element::STAFF_STATE && static_cast<StaffState*>(e)->staffStateType() == STAFF_STATE_INSTRUMENT) {
            popup->addAction(tr("Change Instrument Properties..."))->setData("ss-props");
            }
      else if (e->type() == Element::SLUR_SEGMENT) {
            genPropertyMenu1(e, popup);
            popup->addAction(tr("Edit Mode"))->setData("edit");
            popup->addAction(tr("Slur Properties..."))->setData("slur-props");
            }
      else if (e->type() == Element::REST) {
            genPropertyMenu1(e, popup);
            }
      else if (e->type() == Element::NOTE) {
            QAction* b = popup->actions()[0];
            QAction* a = popup->insertSeparator(b);
            a->setText(tr("Staff"));
            a = new QAction(tr("Staff Properties..."), 0);
            a->setData("staff-props");
            popup->insertAction(b, a);

            a = popup->insertSeparator(b);
            a->setText(tr("Measure"));
            a = new QAction(tr("Measure Properties..."), 0);
            a->setData("measure-props");
            popup->insertAction(b, a);

            genPropertyMenu1(e, popup);
            popup->addSeparator();

            popup->addAction(tr("Style..."))->setData("style");
            popup->addAction(tr("Chord Articulation..."))->setData("articulation");
            }
      else if (e->type() == Element::LAYOUT_BREAK && static_cast<LayoutBreak*>(e)->layoutBreakType() == LAYOUT_BREAK_SECTION) {
            popup->addAction(tr("Section Break Properties..."))->setData("break-props");
            }
      else if (e->type() == Element::INSTRUMENT_CHANGE) {
            genPropertyMenu1(e, popup);
            popup->addAction(tr("Change Instrument..."))->setData("ch-instr");
            }
      else if (e->type() == Element::FRET_DIAGRAM) {
            if (e->visible())
                  popup->addAction(tr("Set Invisible"))->setData("invisible");
            else
                  popup->addAction(tr("Set Visible"))->setData("invisible");
            popup->addAction(tr("Color..."))->setData("color");
            popup->addAction(tr("Fret Diagram Properties..."))->setData("fret-props");
            }
      else if (e->type() == Element::GLISSANDO) {
            genPropertyMenu1(e, popup);
            popup->addAction(tr("Glissando Properties..."))->setData("gliss-props");
            }
      else if (e->type() == Element::HAIRPIN_SEGMENT) {
            QAction* a = popup->addSeparator();
            a->setText(tr("Dynamics"));
            if (e->visible())
                  a = popup->addAction(tr("Set Invisible"));
            else
                  a = popup->addAction(tr("Set Visible"));
            a->setData("invisible");
            popup->addAction(tr("Hairpin Properties..."))->setData("hp-props");
            }
      else if (e->type() == Element::HARMONY) {
            genPropertyMenu1(e, popup);
            popup->addSeparator();
            popup->addAction(tr("Harmony Properties..."))->setData("ha-props");
            popup->addAction(tr("Text Properties..."))->setData("text-props");
            }
      else if (e->type() == Element::INSTRUMENT_NAME) {
            popup->addAction(tr("Staff Properties..."))->setData("staff-props");
            }
      else
            genPropertyMenu1(e, popup);
      }
Example #2
0
Phraktalus::Phraktalus(QWidget *parent) :
        QMainWindow(parent),
        lastDir(QString()),
        ui(new Ui::Phraktalus),
        viewport(new GLViewPort(this)),
        ms(new ModelStacker(this)),
        dots(new QSpinBox(this)),
        statusLabel(new QLabel("Welcome to Phraktalus"))
{
    //Sets up the premade ui
    ui->setupUi(this);
    setWindowTitle(windowTitle());
    setStatusBar(new QStatusBar(this));
    statusBar()->addWidget(statusLabel);
    statusBar()->show();
    //Populate the menuBar
    ui->menuBar->addAction(ui->action_About);
    //Populate toolBars
    //File menu
    ui->toolBar->addAction(ui->action_New);
    ui->toolBar->addAction(ui->action_Open);
    ui->toolBar->addSeparator();
    //View Menu
    QSpinBox *gridPrecision = new QSpinBox(this);
    gridPrecision->setMinimum(1);
    gridPrecision->setMaximum(5);
    gridPrecision->setToolTip("Adjusts Grid precision");
    ui->toolBar->addWidget(gridPrecision);

    QAction* showGrids = new QAction(QIcon(":/icons/rule.png"), "Show Grids", this);
    showGrids->setCheckable(true);
    showGrids->setChecked(true);
    showGrids->setMenu(ui->menu_Grids);
    ui->toolBar->addAction(showGrids);

    ui->toolBar->addAction(ui->action_Show_Labels);
    ui->toolBar->addAction(ui->action_Surface);
    ui->toolBar->addAction(ui->action_Lighting);
    ui->toolBar->addAction(ui->action_Reset_Camera);
    ui->toolBar->addSeparator();
    //Process Menu
    dots->setMinimum(1);
    dots->setMaximum(4);
    dots->setToolTip("Adjusts number of visible dots");
    ui->toolBar->addWidget(dots);

    ui->toolBar->addAction(ui->action_Previous);
    connect(ms, SIGNAL(hasPrevious(bool)), ui->action_Previous, SLOT(setEnabled(bool)));
    ui->toolBar->addAction(ui->action_Next);
    connect(ms, SIGNAL(hasNext(bool)), ui->action_Next, SLOT(setEnabled(bool)));
    ui->toolBar->addAction(ui->action_Zoom);
    connect(ms, SIGNAL(isEmpty(bool)), ui->action_Zoom, SLOT(setDisabled(bool)));
    ms->emitSignals();

    ui->toolBar->setVisible(true);
    //Set main viewport
    setCentralWidget(viewport);
    //Connect actions relative to GL
    connect(ui->action_Lighting, SIGNAL(toggled(bool)), viewport, SLOT(setLighting(bool)));
    connect(ui->action_Reset_Camera, SIGNAL(triggered()), viewport, SLOT(resetCamera()));
    connect(ui->action_Horizontal, SIGNAL(toggled(bool)), viewport, SLOT(showHorizontalGrid(bool)));
    connect(ui->action_Vertical, SIGNAL(toggled(bool)), viewport, SLOT(showVerticalGrid(bool)));
    connect(ui->action_Surface, SIGNAL(toggled(bool)), viewport, SLOT(showSurface(bool)));
    connect(gridPrecision, SIGNAL(valueChanged(int)), viewport, SLOT(setGridPrecision(int)));
    connect(ui->action_Show_Labels, SIGNAL(toggled(bool)), viewport, SLOT(showLabels(bool)));
    connect(ms, SIGNAL(topChanged(ElevationModel*)), viewport, SLOT(setModel(ElevationModel*)));
    connect(ms, SIGNAL(topChanged(ElevationModel*)), this, SLOT(onTopChanged(ElevationModel*)));
    //Zoom region
    connect(ui->action_Zoom, SIGNAL(toggled(bool)), viewport, SLOT(zoomModeEnable(bool)));
    connect(viewport, SIGNAL(doZoom(uint,uint,uint)), this, SLOT(zoomHandle(uint, uint, uint)));
    connect(showGrids, SIGNAL(toggled(bool)), ui->action_Vertical, SLOT(setChecked(bool)));
    connect(showGrids, SIGNAL(toggled(bool)), ui->action_Horizontal, SLOT(setChecked(bool)));

    gridPrecision->setValue(GRIDPRECISION);
    dots->setValue(VISIBLEDOTS);
}
void RouterKeygen::scanFinished(int code) {
	cleanLoadingAnimation();
	ui->refreshScan->setEnabled(true);
	ui->calculateButton->setEnabled(true);
	switch (code) {
	case QWifiManager::SCAN_OK: {
		ui->networkslist->clear();
		QVector<QScanResult*> networks = wifiManager->getScanResults();
		ui->networkslist->setRowCount(networks.size());
		trayMenu->clear();
		connect(trayMenu->addAction(tr("Vulnerable networks")),
				SIGNAL(triggered()), this, SLOT(show()));
		bool foundVulnerable = false;
		for (int i = 0; i < networks.size(); ++i) {
			ui->networkslist->setItem(i, 0,
					new QTableWidgetItem(networks.at(i)->ssid));
			ui->networkslist->setItem(i, 1,
					new QTableWidgetItem(networks.at(i)->bssid));
			QString level;
			level.setNum(networks.at(i)->level, 10);
			ui->networkslist->setItem(i, 2, new QTableWidgetItem(level));
			Keygen * supported = matcher.getKeygen(networks.at(i)->ssid,
					networks.at(i)->bssid, networks.at(i)->level, networks.at(i)->capabilities);
			if (supported != NULL) {
				ui->networkslist->setItem(i, 3,
						new QTableWidgetItem(tr("Yes")));
				addNetworkToTray(networks.at(i)->ssid, networks.at(i)->level, supported->isLocked());
				foundVulnerable = true;
				delete supported;
			} else
				ui->networkslist->setItem(i, 3, new QTableWidgetItem(tr("No")));
		}
        if (!foundVulnerable) {
            trayMenu->addAction(tr("\tNone were detected"))->setEnabled(false);
		}
		trayMenu->addSeparator();
		QAction * startUp = trayMenu->addAction(tr("Run on Start up"));
		startUp->setCheckable(true);
		startUp->setChecked(runOnStartUp);
		connect(startUp, SIGNAL(toggled(bool)), this,
				SLOT(startUpRunToggle(bool)));
		QAction * backgroundRun = trayMenu->addAction(
				tr("Run in the background"));
		backgroundRun->setCheckable(true);
		backgroundRun->setChecked(runInBackground);
		connect(backgroundRun, SIGNAL(toggled(bool)), this,
				SLOT(backgroundRunToggle(bool)));
		trayMenu->addSeparator();
		QAction * exitAction = trayMenu->addAction(tr("Exit"));
		connect(exitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
		QStringList headers;
		headers << "SSID" << "BSSID" << tr("Strength") << tr("Supported");
		ui->networkslist->setHorizontalHeaderLabels(headers);
		ui->networkslist->resizeColumnsToContents();
		ui->networkslist->horizontalHeader()->setStretchLastSection(true);
		ui->networkslist->sortByColumn(2); //Order by Strength
		ui->networkslist->sortByColumn(3); // and then by support
		//ui->statusBar->clearMessage();
		break;
	}
	case QWifiManager::ERROR_NO_NM:
		ui->statusBar->showMessage(tr("Network Manager was not detected"));
		break;

	case QWifiManager::ERROR_NO_WIFI:
		ui->statusBar->showMessage(tr("No Wifi device detected"));
		break;

	case QWifiManager::ERROR_NO_WIFI_ENABLED:
		ui->statusBar->showMessage(tr("The wifi card is not enabled"));
		break;
	}

}
QAction* RS_ActionLockRelativeZero::createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/) {
	QAction* action = new QAction(QIcon(":/extui/relzerolock.png"), tr("(Un-)&Lock Relative Zero"),  nullptr);
	action->setCheckable(true);
    return action;
}
QgsRasterHistogramWidget::QgsRasterHistogramWidget( QgsRasterLayer* lyr, QWidget *parent )
    : QWidget( parent )
    , mRasterLayer( lyr )
    , mRendererWidget( 0 )
{
  setupUi( this );

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

  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();
  mHistoDrawLines = settings.value( "/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()->srcDataType( 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( "", 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 );

  }
Example #6
0
FieldWidget::FieldWidget(QWidget *parent) :
    QGraphicsView(parent),
    m_geometryUpdated(true),
    m_rotation(0.0f),
    m_worldStateUpdated(false),
    m_visualizationsUpdated(false),
    m_hasTouchInput(false),
    m_dragType(DragNone),
    m_dragItem(NULL)
{
    m_touchStatusType = QGestureRecognizer::registerRecognizer(new TouchStatusRecognizer);
    grabGesture(m_touchStatusType);
    grabGesture(Qt::PanGesture);
    grabGesture(Qt::PinchGesture);

    geometrySetDefault(&m_geometry);

    // setup context menu
    m_contextMenu = new QMenu(this);
    QAction *actionHorizontal = m_contextMenu->addAction("Horizontal");
    connect(actionHorizontal, SIGNAL(triggered()), SLOT(setHorizontal()));
    QAction *actionVertical = m_contextMenu->addAction("Vertical");
    connect(actionVertical, SIGNAL(triggered()), SLOT(setVertical()));
    QAction *actionFlip = m_contextMenu->addAction("Flip");
    connect(actionFlip, SIGNAL(triggered()), SLOT(flip()));
    m_contextMenu->addSeparator();
    // add actions to allow hiding visualizations of a team
    m_actionShowBlueVis = m_contextMenu->addAction("Show blue visualizations");
    m_actionShowBlueVis->setCheckable(true);
    m_actionShowBlueVis->setChecked(true);
    connect(m_actionShowBlueVis, SIGNAL(triggered()), SLOT(updateVisualizationVisibility()));
    m_actionShowYellowVis = m_contextMenu->addAction("Show yellow visualizations");
    m_actionShowYellowVis->setCheckable(true);
    m_actionShowYellowVis->setChecked(true);
    connect(m_actionShowYellowVis, SIGNAL(triggered()), SLOT(updateVisualizationVisibility()));
    m_actionShowControllerVis = m_contextMenu->addAction("Show controller visualizations");
    m_actionShowControllerVis->setCheckable(true);
    m_actionShowControllerVis->setChecked(true);
    connect(m_actionShowControllerVis, SIGNAL(triggered()), SLOT(updateVisualizationVisibility()));
    updateVisualizationVisibility(); // update the visibility map
    m_contextMenu->addSeparator();
    // other actions
    QAction *actionShowAOI = m_contextMenu->addAction("Enable custom vision area");
    actionShowAOI->setCheckable(true);
    connect(actionShowAOI, SIGNAL(toggled(bool)), SLOT(setAOIVisible(bool)));
    m_actionAntialiasing = m_contextMenu->addAction("Anti-aliasing");
    m_actionAntialiasing->setCheckable(true);
    connect(m_actionAntialiasing, SIGNAL(toggled(bool)), SLOT(setAntialiasing(bool)));
    m_actionGL = m_contextMenu->addAction("OpenGL");
    m_actionGL->setCheckable(true);
    connect(m_actionGL, SIGNAL(toggled(bool)), SLOT(setOpenGL(bool)));
    m_contextMenu->addSeparator();
    QAction *actionScreenshot = m_contextMenu->addAction("Take screenshot");
    connect(actionScreenshot, SIGNAL(triggered()), SLOT(takeScreenshot()));
    QAction *actionSaveSituation = m_contextMenu->addAction("Save Situation");
    connect(actionSaveSituation, SIGNAL(triggered()), SLOT(saveSituation()));

    // create graphics scene
    m_scene = new QGraphicsScene(this);
    setScene(m_scene);

    // ball object
    const float ballRadius = 0.02133f;
    m_ball = new QGraphicsEllipseItem;
    m_ball->setPen(Qt::NoPen);
    m_ball->setBrush(QColor(255, 66, 0));
    m_ball->setZValue(100.0f);
    m_ball->setRect(QRectF(-ballRadius, -ballRadius, ballRadius * 2.0f, ballRadius * 2.0f));
    m_ball->hide();
    m_scene->addItem(m_ball);

    // rectangle for area of interest
    m_aoiItem = new QGraphicsPathItem;
    m_aoiItem->setPen(Qt::NoPen);
    m_aoiItem->setBrush(QColor(0, 0, 0, 128));
    m_aoiItem->setZValue(10000.0f);
    m_aoiItem->hide();
    m_scene->addItem(m_aoiItem);

    m_aoi = QRectF(-1, -1, 2, 2);
    updateAOI();

    m_scene->setBackgroundBrush(Qt::black);
    m_scene->setItemIndexMethod(QGraphicsScene::NoIndex); // should improve the performance

    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    // transforms are centered on the mouse cursor
    setTransformationAnchor(QGraphicsView::NoAnchor);
    setOptimizationFlag(QGraphicsView::DontSavePainterState);
    setCacheMode(QGraphicsView::CacheBackground);

    setHorizontal();

    // view update timer
    QTimer *timer = new QTimer(this);
    connect(timer, SIGNAL(timeout()), SLOT(updateAll()));
    timer->start(30);

    setMouseTracking(true);

    // create label to show field coordinates
    m_lblMousePos = new QLabel(this);
    m_lblMousePos->setAutoFillBackground(true); // solid background
    // draw frame
    m_lblMousePos->setFrameStyle(QFrame::StyledPanel | QFrame::Raised);
    m_lblMousePos->setMargin(2); // some space
    m_lblMousePos->hide(); // ensure that the label is hidden on startup

    // load settings
    QSettings s;
    s.beginGroup("Field");
    m_actionGL->setChecked(s.value("OpenGL").toBool());
    m_actionAntialiasing->setChecked(s.value("AntiAliasing").toBool());
    s.endGroup();
}
Example #7
0
void AdBlockIcon::createMenu(QMenu* menu)
{
    if (!menu) {
        menu = qobject_cast<QMenu*>(sender());
        if (!menu) {
            return;
        }
    }

    menu->clear();

    AdBlockManager* manager = AdBlockManager::instance();
    AdBlockCustomList* customList = manager->customList();

    WebPage* page = m_window->weView()->page();
    const QUrl pageUrl = page->url();

    menu->addAction(tr("Show AdBlock &Settings"), manager, SLOT(showDialog()));
    menu->addSeparator();

    if (!pageUrl.host().isEmpty() && m_enabled && manager->canRunOnScheme(pageUrl.scheme())) {
        const QString host = page->url().host().contains(QLatin1String("www.")) ? pageUrl.host().mid(4) : pageUrl.host();
        const QString hostFilter = QString("@@||%1^$document").arg(host);
        const QString pageFilter = QString("@@|%1|$document").arg(pageUrl.toString());

        QAction* act = menu->addAction(tr("Disable on %1").arg(host));
        act->setCheckable(true);
        act->setChecked(customList->containsFilter(hostFilter));
        act->setData(hostFilter);
        connect(act, SIGNAL(triggered()), this, SLOT(toggleCustomFilter()));

        act = menu->addAction(tr("Disable only on this page"));
        act->setCheckable(true);
        act->setChecked(customList->containsFilter(pageFilter));
        act->setData(pageFilter);
        connect(act, SIGNAL(triggered()), this, SLOT(toggleCustomFilter()));

        menu->addSeparator();
    }

    if (!m_blockedPopups.isEmpty()) {
        menu->addAction(tr("Blocked Popup Windows"))->setEnabled(false);
        for (int i = 0; i < m_blockedPopups.count(); i++) {
            const QPair<AdBlockRule*, QUrl> &pair = m_blockedPopups.at(i);

            QString address = pair.second.toString().right(55);
            QString actionText = tr("%1 with (%2)").arg(address, pair.first->filter()).replace(QLatin1Char('&'), QLatin1String("&&"));

            QAction* action = menu->addAction(actionText, manager, SLOT(showRule()));
            action->setData(QVariant::fromValue((void*)pair.first));
        }
    }

    menu->addSeparator();

    QVector<WebPage::AdBlockedEntry> entries = page->adBlockedEntries();
    if (entries.isEmpty()) {
        menu->addAction(tr("No content blocked"))->setEnabled(false);
    }
    else {
        menu->addAction(tr("Blocked URL (AdBlock Rule) - click to edit rule"))->setEnabled(false);
        foreach (const WebPage::AdBlockedEntry &entry, entries) {
            QString address = entry.url.toString().right(55);
            QString actionText = tr("%1 with (%2)").arg(address, entry.rule->filter()).replace(QLatin1Char('&'), QLatin1String("&&"));

            QAction* action = menu->addAction(actionText, manager, SLOT(showRule()));
            action->setData(QVariant::fromValue((void*)entry.rule));
        }
    }
Example #8
0
void QgsDataDefinedButton::aboutToShowMenu()
{
  mDefineMenu->clear();

  bool hasExp = !getExpression().isEmpty();
  bool hasField = !getField().isEmpty();
  QString ddTitle = tr( "Data defined override" );

  QAction* ddTitleAct = mDefineMenu->addAction( ddTitle );
  QFont titlefont = ddTitleAct->font();
  titlefont.setItalic( true );
  ddTitleAct->setFont( titlefont );
  ddTitleAct->setEnabled( false );

  bool addActiveAction = false;
  if ( useExpression() && hasExp )
  {
    QgsExpression exp( getExpression() );
    // whether expression is parse-able
    addActiveAction = !exp.hasParserError();
  }
  else if ( !useExpression() && hasField )
  {
    // whether field exists
    addActiveAction = mFieldNameList.contains( getField() );
  }

  if ( addActiveAction )
  {
    ddTitleAct->setText( ddTitle + " (" + ( useExpression() ? tr( "expression" ) : tr( "field" ) ) + ")" );
    mDefineMenu->addAction( mActionActive );
    mActionActive->setText( isActive() ? tr( "Deactivate" ) : tr( "Activate" ) );
    mActionActive->setData( QVariant( isActive() ? false : true ) );
  }

  if ( !mFullDescription.isEmpty() )
  {
    mDefineMenu->addAction( mActionDescription );
  }

  mDefineMenu->addSeparator();

  if ( !mDataTypesString.isEmpty() )
  {
    QAction* fieldTitleAct = mDefineMenu->addAction( tr( "Attribute field" ) );
    fieldTitleAct->setFont( titlefont );
    fieldTitleAct->setEnabled( false );

    mDefineMenu->addAction( mActionDataTypes );

    mFieldsMenu->clear();

    if ( mFieldNameList.size() > 0 )
    {

      for ( int j = 0; j < mFieldNameList.count(); ++j )
      {
        QString fldname = mFieldNameList.at( j );
        QAction* act = mFieldsMenu->addAction( fldname + "    (" + mFieldTypeList.at( j ) + ")" );
        act->setData( QVariant( fldname ) );
        if ( getField() == fldname )
        {
          act->setCheckable( true );
          act->setChecked( !useExpression() );
        }
      }
    }
    else
    {
      QAction* act = mFieldsMenu->addAction( tr( "No matching field types found" ) );
      act->setEnabled( false );
    }

    mDefineMenu->addSeparator();
  }

  QAction* exprTitleAct = mDefineMenu->addAction( tr( "Expression" ) );
  exprTitleAct->setFont( titlefont );
  exprTitleAct->setEnabled( false );

  if ( hasExp )
  {
    QString expString = getExpression();
    if ( expString.length() > 35 )
    {
      expString.truncate( 35 );
      expString.append( "..." );
    }

    expString.prepend( tr( "Current: " ) );

    if ( !mActionExpression )
    {
      mActionExpression = new QAction( expString, this );
      mActionExpression->setCheckable( true );
    }
    else
    {
      mActionExpression->setText( expString );
    }
    mDefineMenu->addAction( mActionExpression );
    mActionExpression->setChecked( useExpression() );

    mDefineMenu->addAction( mActionExpDialog );
    mDefineMenu->addAction( mActionCopyExpr );
    mDefineMenu->addAction( mActionPasteExpr );
    mDefineMenu->addAction( mActionClearExpr );
  }
  else
  {
    mDefineMenu->addAction( mActionExpDialog );
    mDefineMenu->addAction( mActionPasteExpr );
  }

}
Example #9
0
MainWindow::MainWindow(TranslationHandler* th, QSettings* settings) :
    mSettings(settings),
    mApplications(new ApplicationList(this)),
    mTranslation(th),
    mLogView(NULL),
    mScratchPad(NULL),
    mProject(NULL),
    mPlatformActions(new QActionGroup(this)),
    mCStandardActions(new QActionGroup(this)),
    mCppStandardActions(new QActionGroup(this)),
    mExiting(false)
{
    mUI.setupUi(this);
    mUI.mResults->Initialize(mSettings, mApplications);

    mThread = new ThreadHandler(this);

    // Filter timer to delay filtering results slightly while typing
    mFilterTimer = new QTimer(this);
    mFilterTimer->setInterval(500);
    mFilterTimer->setSingleShot(true);
    connect(mFilterTimer, SIGNAL(timeout()), this, SLOT(FilterResults()));

    // "Filter" toolbar
    mLineEditFilter = new QLineEdit(mUI.mToolBarFilter);
    mLineEditFilter->setPlaceholderText(tr("Quick Filter:"));
    mUI.mToolBarFilter->addWidget(mLineEditFilter);
    connect(mLineEditFilter, SIGNAL(textChanged(const QString&)), mFilterTimer, SLOT(start()));
    connect(mLineEditFilter, SIGNAL(returnPressed()), this, SLOT(FilterResults()));

    connect(mUI.mActionQuit, SIGNAL(triggered()), this, SLOT(close()));
    connect(mUI.mActionCheckFiles, SIGNAL(triggered()), this, SLOT(CheckFiles()));
    connect(mUI.mActionCheckDirectory, SIGNAL(triggered()), this, SLOT(CheckDirectory()));
    connect(mUI.mActionSettings, SIGNAL(triggered()), this, SLOT(ProgramSettings()));
    connect(mUI.mActionClearResults, SIGNAL(triggered()), this, SLOT(ClearResults()));
    connect(mUI.mActionOpenXML, SIGNAL(triggered()), this, SLOT(OpenResults()));

    connect(mUI.mActionShowStyle, SIGNAL(toggled(bool)), this, SLOT(ShowStyle(bool)));
    connect(mUI.mActionShowErrors, SIGNAL(toggled(bool)), this, SLOT(ShowErrors(bool)));
    connect(mUI.mActionShowWarnings, SIGNAL(toggled(bool)), this, SLOT(ShowWarnings(bool)));
    connect(mUI.mActionShowPortability, SIGNAL(toggled(bool)), this, SLOT(ShowPortability(bool)));
    connect(mUI.mActionShowPerformance, SIGNAL(toggled(bool)), this, SLOT(ShowPerformance(bool)));
    connect(mUI.mActionShowInformation, SIGNAL(toggled(bool)), this, SLOT(ShowInformation(bool)));
    connect(mUI.mActionCheckAll, SIGNAL(triggered()), this, SLOT(CheckAll()));
    connect(mUI.mActionUncheckAll, SIGNAL(triggered()), this, SLOT(UncheckAll()));
    connect(mUI.mActionCollapseAll, SIGNAL(triggered()), mUI.mResults, SLOT(CollapseAllResults()));
    connect(mUI.mActionExpandAll, SIGNAL(triggered()), mUI.mResults, SLOT(ExpandAllResults()));
    connect(mUI.mActionShowHidden, SIGNAL(triggered()), mUI.mResults, SLOT(ShowHiddenResults()));
    connect(mUI.mActionViewLog, SIGNAL(triggered()), this, SLOT(ShowLogView()));
    connect(mUI.mActionViewStats, SIGNAL(triggered()), this, SLOT(ShowStatistics()));

    connect(mUI.mActionRecheck, SIGNAL(triggered()), this, SLOT(ReCheck()));

    connect(mUI.mActionStop, SIGNAL(triggered()), this, SLOT(StopChecking()));
    connect(mUI.mActionSave, SIGNAL(triggered()), this, SLOT(Save()));

    // About menu
    connect(mUI.mActionAbout, SIGNAL(triggered()), this, SLOT(About()));
    connect(mUI.mActionLicense, SIGNAL(triggered()), this, SLOT(ShowLicense()));

    // View > Toolbar menu
    connect(mUI.mActionToolBarMain, SIGNAL(toggled(bool)), this, SLOT(ToggleMainToolBar()));
    connect(mUI.mActionToolBarView, SIGNAL(toggled(bool)), this, SLOT(ToggleViewToolBar()));
    connect(mUI.mActionToolBarFilter, SIGNAL(toggled(bool)), this, SLOT(ToggleFilterToolBar()));

    connect(mUI.mActionAuthors, SIGNAL(triggered()), this, SLOT(ShowAuthors()));
    connect(mThread, SIGNAL(Done()), this, SLOT(CheckDone()));
    connect(mUI.mResults, SIGNAL(GotResults()), this, SLOT(ResultsAdded()));
    connect(mUI.mResults, SIGNAL(ResultsHidden(bool)), mUI.mActionShowHidden, SLOT(setEnabled(bool)));
    connect(mUI.mMenuView, SIGNAL(aboutToShow()), this, SLOT(AboutToShowViewMenu()));

    // File menu
    connect(mUI.mActionNewProjectFile, SIGNAL(triggered()), this, SLOT(NewProjectFile()));
    connect(mUI.mActionOpenProjectFile, SIGNAL(triggered()), this, SLOT(OpenProjectFile()));
    connect(mUI.mActionShowScratchpad, SIGNAL(triggered()), this, SLOT(ShowScratchpad()));
    connect(mUI.mActionCloseProjectFile, SIGNAL(triggered()), this, SLOT(CloseProjectFile()));
    connect(mUI.mActionEditProjectFile, SIGNAL(triggered()), this, SLOT(EditProjectFile()));

    connect(mUI.mActionHelpContents, SIGNAL(triggered()), this, SLOT(OpenHelpContents()));

    LoadSettings();

    mThread->Initialize(mUI.mResults);
    FormatAndSetTitle();

    EnableCheckButtons(true);

    mUI.mActionClearResults->setEnabled(false);
    mUI.mActionSave->setEnabled(false);
    mUI.mActionRecheck->setEnabled(false);
    EnableProjectOpenActions(true);
    EnableProjectActions(false);

    // Must setup MRU menu before CLI param handling as it can load a
    // project file and update MRU menu.
    for (int i = 0; i < MaxRecentProjects; ++i) {
        mRecentProjectActs[i] = new QAction(this);
        mRecentProjectActs[i]->setVisible(false);
        connect(mRecentProjectActs[i], SIGNAL(triggered()),
                this, SLOT(OpenRecentProject()));
    }
    mRecentProjectActs[MaxRecentProjects] = NULL; // The separator
    mUI.mActionProjectMRU->setVisible(false);
    UpdateMRUMenuItems();

    QStringList args = QCoreApplication::arguments();
    //Remove the application itself
    args.removeFirst();
    if (!args.isEmpty()) {
        HandleCLIParams(args);
    }

    for (int i = 0; i < mPlatforms.getCount(); i++) {
        Platform plat = mPlatforms.mPlatforms[i];
        QAction *act = new QAction(this);
        plat.mActMainWindow = act;
        mPlatforms.mPlatforms[i] = plat;
        act->setText(plat.mTitle);
        act->setData(plat.mType);
        act->setCheckable(true);
        act->setActionGroup(mPlatformActions);
        mUI.mMenuCheck->insertAction(mUI.mActionPlatforms, act);
        connect(act, SIGNAL(triggered()), this, SLOT(SelectPlatform()));
    }

    mUI.mActionC89->setActionGroup(mCStandardActions);
    mUI.mActionC99->setActionGroup(mCStandardActions);
    mUI.mActionC11->setActionGroup(mCStandardActions);

    mUI.mActionCpp03->setActionGroup(mCppStandardActions);
    mUI.mActionCpp11->setActionGroup(mCppStandardActions);

    // For Windows platforms default to Win32 checked platform.
    // For other platforms default to unspecified/default which means the
    // platform Cppcheck GUI was compiled on.
#if defined(_WIN32)
    Platform &plat = mPlatforms.get(Settings::Win32A);
#else
    Platform &plat = mPlatforms.get(Settings::Unspecified);
#endif
    plat.mActMainWindow->setChecked(true);
    mSettings->setValue(SETTINGS_CHECKED_PLATFORM, plat.mType);
}
PointViewerMainWindow::PointViewerMainWindow(const QGLFormat& format)
    : m_progressBar(0),
    m_pointView(0),
    m_shaderEditor(0),
    m_helpDialog(0),
    m_logTextView(0),
    m_maxPointCount(200*1000*1000), // 200 million
    m_geometries(0),
    m_ipcServer(0),
    m_hookManager(0)
{
#ifndef _WIN32
    setWindowIcon(QIcon(":resource/icons/hicolor/256x256/apps/displaz.png"));
#else
    // On windows, application icon is set via windows resource file
#endif
    setWindowTitle("Displaz");
    setAcceptDrops(true);

    m_helpDialog = new HelpDialog(this);

    m_geometries = new GeometryCollection(this);
    connect(m_geometries, SIGNAL(layoutChanged()), this, SLOT(updateTitle()));
    connect(m_geometries, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(updateTitle()));
    connect(m_geometries, SIGNAL(rowsInserted(QModelIndex,int,int)),    this, SLOT(updateTitle()));
    connect(m_geometries, SIGNAL(rowsRemoved(QModelIndex,int,int)),     this, SLOT(updateTitle()));

    //--------------------------------------------------
    // Set up file loader in a separate thread
    //
    // Some subtleties regarding qt thread usage are discussed here:
    // http://mayaposch.wordpress.com/2011/11/01/how-to-really-truly-use-qthreads-the-full-explanation
    //
    // Main point: each QObject has a thread affinity which determines which
    // thread its slots will execute on, when called via a connected signal.
    QThread* loaderThread = new QThread();
    m_fileLoader = new FileLoader(m_maxPointCount);
    m_fileLoader->moveToThread(loaderThread);
    connect(loaderThread, SIGNAL(finished()), m_fileLoader, SLOT(deleteLater()));
    connect(loaderThread, SIGNAL(finished()), loaderThread, SLOT(deleteLater()));
    //connect(m_fileLoader, SIGNAL(finished()), this, SIGNAL(fileLoadFinished()));
    connect(m_fileLoader, SIGNAL(geometryLoaded(std::shared_ptr<Geometry>, bool, bool)),
            m_geometries, SLOT(addGeometry(std::shared_ptr<Geometry>, bool, bool)));
    connect(m_fileLoader, SIGNAL(geometryMutatorLoaded(std::shared_ptr<GeometryMutator>)),
            m_geometries, SLOT(mutateGeometry(std::shared_ptr<GeometryMutator>)));
    loaderThread->start();

    //--------------------------------------------------
    // Menus
    menuBar()->setNativeMenuBar(false); // OS X doesn't activate the native menu bar under Qt5

    // File menu
    QMenu* fileMenu = menuBar()->addMenu(tr("&File"));
    QAction* openAct = fileMenu->addAction(tr("&Open"));
    openAct->setToolTip(tr("Open a data set"));
    openAct->setShortcuts(QKeySequence::Open);
    connect(openAct, SIGNAL(triggered()), this, SLOT(openFiles()));
    QAction* addAct = fileMenu->addAction(tr("&Add"));
    addAct->setToolTip(tr("Add a data set"));
    connect(addAct, SIGNAL(triggered()), this, SLOT(addFiles()));
    QAction* reloadAct = fileMenu->addAction(tr("&Reload"));
    reloadAct->setStatusTip(tr("Reload point files from disk"));
    reloadAct->setShortcut(Qt::Key_F5);
    connect(reloadAct, SIGNAL(triggered()), this, SLOT(reloadFiles()));

    fileMenu->addSeparator();
    QAction* screenShotAct = fileMenu->addAction(tr("Scree&nshot"));
    screenShotAct->setStatusTip(tr("Save screen shot of 3D window"));
    screenShotAct->setShortcut(Qt::Key_F9);
    connect(screenShotAct, SIGNAL(triggered()), this, SLOT(screenShot()));

    fileMenu->addSeparator();
    QAction* quitAct = fileMenu->addAction(tr("&Quit"));
    quitAct->setStatusTip(tr("Exit the application"));
    quitAct->setShortcuts(QKeySequence::Quit);
    connect(quitAct, SIGNAL(triggered()), this, SLOT(close()));

    // View menu
    QMenu* viewMenu = menuBar()->addMenu(tr("&View"));
    QAction* trackballMode = viewMenu->addAction(tr("Use &Trackball camera"));
    trackballMode->setCheckable(true);
    trackballMode->setChecked(false);
    // Background sub-menu
    QMenu* backMenu = viewMenu->addMenu(tr("Set &Background"));
    QSignalMapper* mapper = new QSignalMapper(this);
    // Selectable backgrounds (svg_names from SVG standard - see QColor docs)
    const char* backgroundNames[] = {/* "Display Name", "svg_name", */
                                        "Default",      "#3C3232",
                                        "Black",        "black",
                                        "Dark Grey",    "dimgrey",
                                        "Slate Grey",   "#858C93",
                                        "Light Grey",   "lightgrey",
                                        "White",        "white" };
    for(size_t i = 0; i < sizeof(backgroundNames)/sizeof(const char*); i+=2)
    {
        QAction* backgroundAct = backMenu->addAction(tr(backgroundNames[i]));
        QPixmap pixmap(50,50);
        QString colName = backgroundNames[i+1];
        pixmap.fill(QColor(colName));
        QIcon icon(pixmap);
        backgroundAct->setIcon(icon);
        mapper->setMapping(backgroundAct, colName);
        connect(backgroundAct, SIGNAL(triggered()), mapper, SLOT(map()));
    }
    connect(mapper, SIGNAL(mapped(QString)),
            this, SLOT(setBackground(QString)));
    backMenu->addSeparator();
    QAction* backgroundCustom = backMenu->addAction(tr("&Custom"));
    connect(backgroundCustom, SIGNAL(triggered()),
            this, SLOT(chooseBackground()));
    // Check boxes for drawing various scene elements by category
    viewMenu->addSeparator();
    QAction* drawBoundingBoxes = viewMenu->addAction(tr("Draw Bounding bo&xes"));
    drawBoundingBoxes->setCheckable(true);
    drawBoundingBoxes->setChecked(false);
    QAction* drawCursor = viewMenu->addAction(tr("Draw 3D &Cursor"));
    drawCursor->setCheckable(true);
    drawCursor->setChecked(true);
    QAction* drawAxes = viewMenu->addAction(tr("Draw &Axes"));
    drawAxes->setCheckable(true);
    drawAxes->setChecked(true);
    QAction* drawGrid = viewMenu->addAction(tr("Draw &Grid"));
    drawGrid->setCheckable(true);
    drawGrid->setChecked(false);
    QAction* drawAnnotations = viewMenu->addAction(tr("Draw A&nnotations"));
    drawAnnotations->setCheckable(true);
    drawAnnotations->setChecked(true);

    // Shader menu
    QMenu* shaderMenu = menuBar()->addMenu(tr("&Shader"));
    QAction* openShaderAct = shaderMenu->addAction(tr("&Open"));
    openShaderAct->setToolTip(tr("Open a shader file"));
    connect(openShaderAct, SIGNAL(triggered()), this, SLOT(openShaderFile()));
    QAction* editShaderAct = shaderMenu->addAction(tr("&Edit"));
    editShaderAct->setToolTip(tr("Open shader editor window"));
    QAction* saveShaderAct = shaderMenu->addAction(tr("&Save"));
    saveShaderAct->setToolTip(tr("Save current shader file"));
    connect(saveShaderAct, SIGNAL(triggered()), this, SLOT(saveShaderFile()));
    shaderMenu->addSeparator();

    // Help menu
    QMenu* helpMenu = menuBar()->addMenu(tr("&Help"));
    QAction* helpAct = helpMenu->addAction(tr("User &Guide"));
    connect(helpAct, SIGNAL(triggered()), this, SLOT(helpDialog()));
    helpMenu->addSeparator();
    QAction* aboutAct = helpMenu->addAction(tr("&About"));
    connect(aboutAct, SIGNAL(triggered()), this, SLOT(aboutDialog()));


    //--------------------------------------------------
    // Point viewer
    m_pointView = new View3D(m_geometries, format, this);
    setCentralWidget(m_pointView);
    connect(drawBoundingBoxes, SIGNAL(triggered()),
            m_pointView, SLOT(toggleDrawBoundingBoxes()));
    connect(drawCursor, SIGNAL(triggered()),
            m_pointView, SLOT(toggleDrawCursor()));
    connect(drawAxes, SIGNAL(triggered()),
            m_pointView, SLOT(toggleDrawAxes()));
    connect(drawGrid, SIGNAL(triggered()),
            m_pointView, SLOT(toggleDrawGrid()));
    connect(drawAnnotations, SIGNAL(triggered()),
            m_pointView, SLOT(toggleDrawAnnotations()));
    connect(trackballMode, SIGNAL(triggered()),
            m_pointView, SLOT(toggleCameraMode()));
    connect(m_geometries, SIGNAL(rowsInserted(QModelIndex,int,int)),
            this, SLOT(geometryRowsInserted(QModelIndex,int,int)));

    //--------------------------------------------------
    // Docked widgets
    // Shader parameters UI
    QDockWidget* shaderParamsDock = new QDockWidget(tr("Shader Parameters"), this);
    shaderParamsDock->setFeatures(QDockWidget::DockWidgetMovable |
                                  QDockWidget::DockWidgetClosable);
    QWidget* shaderParamsUI = new QWidget(shaderParamsDock);
    shaderParamsDock->setWidget(shaderParamsUI);
    m_pointView->setShaderParamsUIWidget(shaderParamsUI);

    // Shader editor UI
    QDockWidget* shaderEditorDock = new QDockWidget(tr("Shader Editor"), this);
    shaderEditorDock->setFeatures(QDockWidget::DockWidgetMovable |
                                  QDockWidget::DockWidgetClosable |
                                  QDockWidget::DockWidgetFloatable);
    QWidget* shaderEditorUI = new QWidget(shaderEditorDock);
    m_shaderEditor = new ShaderEditor(shaderEditorUI);
    QGridLayout* shaderEditorLayout = new QGridLayout(shaderEditorUI);
    shaderEditorLayout->setContentsMargins(2,2,2,2);
    shaderEditorLayout->addWidget(m_shaderEditor, 0, 0, 1, 1);
    connect(editShaderAct, SIGNAL(triggered()), shaderEditorDock, SLOT(show()));
    shaderEditorDock->setWidget(shaderEditorUI);

    shaderMenu->addAction(m_shaderEditor->compileAction());
    connect(m_shaderEditor->compileAction(), SIGNAL(triggered()),
            this, SLOT(compileShaderFile()));

    // TODO: check if this is needed - test shader update functionality
    //connect(m_shaderEditor, SIGNAL(sendShader(QString)),
    //        &m_pointView->shaderProgram(), SLOT(setShader(QString)));

    // Log viewer UI
    QDockWidget* logDock = new QDockWidget(tr("Log"), this);
    logDock->setFeatures(QDockWidget::DockWidgetMovable |
                         QDockWidget::DockWidgetClosable);
    QWidget* logUI = new QWidget(logDock);
    m_logTextView = new LogViewer(logUI);
    m_logTextView->setReadOnly(true);
    m_logTextView->setTextInteractionFlags(Qt::TextSelectableByKeyboard | Qt::TextSelectableByMouse);
    m_logTextView->connectLogger(&g_logger); // connect to global logger
    m_progressBar = new QProgressBar(logUI);
    m_progressBar->setRange(0,100);
    m_progressBar->setValue(0);
    m_progressBar->hide();
    connect(m_fileLoader, SIGNAL(loadStepStarted(QString)),
            this, SLOT(setProgressBarText(QString)));
    connect(m_fileLoader, SIGNAL(loadProgress(int)),
            m_progressBar, SLOT(setValue(int)));
    connect(m_fileLoader, SIGNAL(resetProgress()),
            m_progressBar, SLOT(hide()));
    QVBoxLayout* logUILayout = new QVBoxLayout(logUI);
    //logUILayout->setContentsMargins(2,2,2,2);
    logUILayout->addWidget(m_logTextView);
    logUILayout->addWidget(m_progressBar);
    //m_logTextView->setLineWrapMode(QPlainTextEdit::NoWrap);
    logDock->setWidget(logUI);

    // Data set list UI
    QDockWidget* dataSetDock = new QDockWidget(tr("Data Sets"), this);
    dataSetDock->setFeatures(QDockWidget::DockWidgetMovable |
                              QDockWidget::DockWidgetClosable |
                              QDockWidget::DockWidgetFloatable);
    DataSetUI* dataSetUI = new DataSetUI(this);
    dataSetDock->setWidget(dataSetUI);
    QAbstractItemView* dataSetOverview = dataSetUI->view();
    dataSetOverview->setModel(m_geometries);
    connect(dataSetOverview, SIGNAL(doubleClicked(const QModelIndex&)),
            m_pointView, SLOT(centerOnGeometry(const QModelIndex&)));
    m_pointView->setSelectionModel(dataSetOverview->selectionModel());

    // Set up docked widgets
    addDockWidget(Qt::RightDockWidgetArea, shaderParamsDock);
    addDockWidget(Qt::LeftDockWidgetArea, shaderEditorDock);
    addDockWidget(Qt::RightDockWidgetArea, logDock);
    addDockWidget(Qt::RightDockWidgetArea, dataSetDock);
    tabifyDockWidget(logDock, dataSetDock);
    logDock->raise();
    shaderEditorDock->setVisible(false);

    // Add dock widget toggles to view menu
    viewMenu->addSeparator();
    viewMenu->addAction(shaderParamsDock->toggleViewAction());
    viewMenu->addAction(logDock->toggleViewAction());
    viewMenu->addAction(dataSetDock->toggleViewAction());

    // Create custom hook events from CLI at runtime
    m_hookManager = new HookManager(this);
}
Example #11
0
Escena::Escena(QWidget *parent)
    : QGLWidget(parent)
    , m_camara(0)
    , m_camara2(0)
    , m_esCamaraLibre(true)
    , m_manipularMuebles(new QAction("Muebles", this))
    , m_manipularLampara(new QAction("Lampara", this))
    , m_camaraLibre(new QAction("Libre", this))
    , m_camaraEsquina1(new QAction("Esquina", this))
    , m_camaraFrontal1(new QAction("Frontal", this))
    , m_camaraLateral1(new QAction("Lateral", this))
    , m_camaraCenital1(new QAction("Cenital", this))
    , m_camaraEsquina2(new QAction("Esquina", this))
    , m_camaraFrontal2(new QAction("Frontal", this))
    , m_camaraLateral2(new QAction("Lateral", this))
    , m_camaraCenital2(new QAction("Cenital", this))
    , m_proyeccion(Camara::Perspectiva)
{
    s_self = this;

    QAction *proyeccionOrtogonal = new QAction("Ortogonal", this);
    proyeccionOrtogonal->setCheckable(true);
    QAction *proyeccionPerspectiva = new QAction("Perspectiva", this);
    proyeccionPerspectiva->setCheckable(true);
    proyeccionPerspectiva->setChecked(true);
    QAction *proyeccionOblicua = new QAction("Oblicua", this);
    proyeccionOblicua->setCheckable(true);

    QActionGroup *proyeccionGroup = new QActionGroup(this);
    proyeccionGroup->addAction(proyeccionOrtogonal);
    proyeccionGroup->addAction(proyeccionPerspectiva);
    proyeccionGroup->addAction(proyeccionOblicua);

    connect(proyeccionOrtogonal, SIGNAL(triggered()), this, SLOT(proyeccionOrtogonal()));
    connect(proyeccionPerspectiva, SIGNAL(triggered()), this, SLOT(proyeccionPerspectiva()));
    connect(proyeccionOblicua, SIGNAL(triggered()), this, SLOT(proyeccionOblicua()));
    connect(m_camaraLibre, SIGNAL(triggered()), this, SLOT(camaraLibre()));
    connect(m_camaraEsquina1, SIGNAL(triggered()), this, SLOT(camaraEsquina1()));
    connect(m_camaraFrontal1, SIGNAL(triggered()), this, SLOT(camaraFrontal1()));
    connect(m_camaraLateral1, SIGNAL(triggered()), this, SLOT(camaraLateral1()));
    connect(m_camaraCenital1, SIGNAL(triggered()), this, SLOT(camaraCenital1()));
    connect(m_camaraEsquina2, SIGNAL(triggered()), this, SLOT(camaraEsquina2()));
    connect(m_camaraFrontal2, SIGNAL(triggered()), this, SLOT(camaraFrontal2()));
    connect(m_camaraLateral2, SIGNAL(triggered()), this, SLOT(camaraLateral2()));
    connect(m_camaraCenital2, SIGNAL(triggered()), this, SLOT(camaraCenital2()));

    setFocusPolicy(Qt::StrongFocus);
    setMouseTracking(true);

    QMenuBar *menuBar = new QMenuBar(parent);

    m_manipularMuebles->setCheckable(true);
    m_manipularMuebles->setChecked(true);
    m_manipularLampara->setCheckable(true);
    
    QActionGroup *actionGroup = new QActionGroup(this);
    actionGroup->addAction(m_manipularMuebles);
    actionGroup->addAction(m_manipularLampara);

    QMenu *controlEscena = new QMenu("Control Escena", this);
    controlEscena->addActions(actionGroup->actions());
    menuBar->addMenu(controlEscena);

    QMenu *habitacion1 = new QMenu("Habitacion 1", this);
    habitacion1->addAction(m_camaraEsquina1);
    habitacion1->addAction(m_camaraFrontal1);
    habitacion1->addAction(m_camaraLateral1);
    habitacion1->addAction(m_camaraCenital1);

    QMenu *habitacion2 = new QMenu("Habitacion 2", this);
    habitacion2->addAction(m_camaraEsquina2);
    habitacion2->addAction(m_camaraFrontal2);
    habitacion2->addAction(m_camaraLateral2);
    habitacion2->addAction(m_camaraCenital2);

    QMenu *posicionCamara = new QMenu("Camara", this);
    posicionCamara->addAction(m_camaraLibre);
    posicionCamara->addMenu(habitacion1);
    posicionCamara->addMenu(habitacion2);
    menuBar->addMenu(posicionCamara);

    QMenu *proyeccion = new QMenu("Proyeccion", this);
    proyeccion->addActions(proyeccionGroup->actions());

    menuBar->addMenu(proyeccion);

    static_cast<QMainWindow*>(parent)->setMenuBar(menuBar);
}
Example #12
0
void KviMainWindow::fillToolBarsPopup(QMenu * p)
{
	p->clear();

	disconnect(p, SIGNAL(triggered(QAction *)), this, SLOT(toolbarsPopupSelected(QAction *))); // just to be sure
	connect(p, SIGNAL(triggered(QAction *)), this, SLOT(toolbarsPopupSelected(QAction *)));

	QAction * pAction = nullptr;
	int cnt = 0;

	KviModuleExtensionDescriptorList * l = g_pModuleExtensionManager->getExtensionList("toolbar");
	if(l)
	{
		for(KviModuleExtensionDescriptor * d = l->first(); d; d = l->next())
		{
			QString label = __tr2qs("Show %1").arg(d->visibleName());
			if(d->icon())
				pAction = p->addAction(*(d->icon()), label);
			else
				pAction = p->addAction(label);
			pAction->setCheckable(true);
			pAction->setChecked(moduleExtensionToolBar(d->id()));
			pAction->setData(d->id());
			cnt++;
		}
	}

	// FIXME: Should this display "Hide %1" when the toolbar is already visible ?
	KviPointerHashTableIterator<QString, KviCustomToolBarDescriptor> it2(*(KviCustomToolBarManager::instance()->descriptors()));
	if(it2.current())
	{
		if(cnt > 0)
			p->addSeparator();

		while(KviCustomToolBarDescriptor * d = it2.current())
		{
			QString label = __tr2qs("Show %1").arg(d->label());
			QString ico = d->iconId();
			if(!ico.isEmpty())
			{
				QPixmap * pix = g_pIconManager->getImage(d->iconId());
				if(pix)
				{
					pAction = p->addAction(*pix, label);
				}
				else
				{
					pAction = p->addAction(label);
				}
			}
			else
			{
				pAction = p->addAction(label);
			}
			pAction->setData(d->internalId());
			pAction->setCheckable(true);
			pAction->setChecked(d->toolBar());
			++it2;
			cnt++;
		}
	}

	if(cnt > 0)
		p->addSeparator();

	p->addAction(
	    *(g_pIconManager->getSmallIcon(KviIconManager::ToolBarEditor)),
	    __tr2qs("Customize..."),
	    this,
	    SLOT(customizeToolBars()));
}
void QgsPropertyOverrideButton::aboutToShowMenu()
{
  mDefineMenu->clear();
  // update fields so that changes made to layer's fields are reflected
  updateFieldLists();

  bool hasExp = !mExpressionString.isEmpty();
  QString ddTitle = tr( "Data defined override" );

  QAction *ddTitleAct = mDefineMenu->addAction( ddTitle );
  QFont titlefont = ddTitleAct->font();
  titlefont.setItalic( true );
  ddTitleAct->setFont( titlefont );
  ddTitleAct->setEnabled( false );

  bool addActiveAction = false;
  if ( mProperty.propertyType() == QgsProperty::ExpressionBasedProperty && hasExp )
  {
    QgsExpression exp( mExpressionString );
    // whether expression is parse-able
    addActiveAction = !exp.hasParserError();
  }
  else if ( mProperty.propertyType() == QgsProperty::FieldBasedProperty )
  {
    // whether field exists
    addActiveAction = mFieldNameList.contains( mFieldName );
  }

  if ( addActiveAction )
  {
    ddTitleAct->setText( ddTitle + " (" + ( mProperty.propertyType() == QgsProperty::ExpressionBasedProperty ? tr( "expression" ) : tr( "field" ) ) + ')' );
    mDefineMenu->addAction( mActionActive );
    mActionActive->setText( mProperty.isActive() ? tr( "Deactivate" ) : tr( "Activate" ) );
    mActionActive->setData( QVariant( !mProperty.isActive() ) );
  }

  if ( !mFullDescription.isEmpty() )
  {
    mDefineMenu->addAction( mActionDescription );
  }

  mDefineMenu->addSeparator();

  // deactivate button if field already exists
  if ( mAuxiliaryStorageEnabled && mVectorLayer )
  {
    mDefineMenu->addAction( mActionCreateAuxiliaryField );

    const QgsAuxiliaryLayer *alayer = mVectorLayer->auxiliaryLayer();

    mActionCreateAuxiliaryField->setEnabled( true );
    mActionCreateAuxiliaryField->setChecked( false );

    int index = mVectorLayer->fields().indexFromName( mFieldName );
    int srcIndex;
    if ( index >= 0 && alayer && mVectorLayer->isAuxiliaryField( index, srcIndex ) )
    {
      mActionCreateAuxiliaryField->setEnabled( false );
      mActionCreateAuxiliaryField->setChecked( true );
    }
  }

  bool fieldActive = false;
  if ( !mDataTypesString.isEmpty() )
  {
    QAction *fieldTitleAct = mDefineMenu->addAction( tr( "Attribute field" ) );
    fieldTitleAct->setFont( titlefont );
    fieldTitleAct->setEnabled( false );

    mDefineMenu->addAction( mActionDataTypes );

    mFieldsMenu->clear();

    if ( !mFieldNameList.isEmpty() )
    {

      for ( int j = 0; j < mFieldNameList.count(); ++j )
      {
        QString fldname = mFieldNameList.at( j );
        QAction *act = mFieldsMenu->addAction( fldname + "    (" + mFieldTypeList.at( j ) + ')' );
        act->setData( QVariant( fldname ) );
        if ( mFieldName == fldname )
        {
          act->setCheckable( true );
          act->setChecked( mProperty.propertyType() == QgsProperty::FieldBasedProperty );
          fieldActive = mProperty.propertyType() == QgsProperty::FieldBasedProperty;
        }
      }
    }
    else
    {
      QAction *act = mFieldsMenu->addAction( tr( "No matching field types found" ) );
      act->setEnabled( false );
    }

    mDefineMenu->addSeparator();
  }

  mFieldsMenu->menuAction()->setCheckable( true );
  mFieldsMenu->menuAction()->setChecked( fieldActive && mProperty.propertyType() == QgsProperty::FieldBasedProperty && !mProperty.transformer() );

  QAction *exprTitleAct = mDefineMenu->addAction( tr( "Expression" ) );
  exprTitleAct->setFont( titlefont );
  exprTitleAct->setEnabled( false );

  mVariablesMenu->clear();
  bool variableActive = false;
  if ( mExpressionContextGenerator )
  {
    QgsExpressionContext context = mExpressionContextGenerator->createExpressionContext();
    QStringList variables = context.variableNames();
    Q_FOREACH ( const QString &variable, variables )
    {
      if ( context.isReadOnly( variable ) ) //only want to show user-set variables
        continue;
      if ( variable.startsWith( '_' ) ) //no hidden variables
        continue;

      QAction *act = mVariablesMenu->addAction( variable );
      act->setData( QVariant( variable ) );

      if ( mProperty.propertyType() == QgsProperty::ExpressionBasedProperty && hasExp && mExpressionString == '@' + variable )
      {
        act->setCheckable( true );
        act->setChecked( true );
        variableActive = true;
      }
    }
  }

  if ( mVariablesMenu->actions().isEmpty() )
  {
    QAction *act = mVariablesMenu->addAction( tr( "No variables set" ) );
    act->setEnabled( false );
  }

  mDefineMenu->addAction( mActionVariables );
  mVariablesMenu->menuAction()->setCheckable( true );
  mVariablesMenu->menuAction()->setChecked( variableActive && !mProperty.transformer() );

  if ( hasExp )
  {
    QString expString = mExpressionString;
    if ( expString.length() > 35 )
    {
      expString.truncate( 35 );
      expString.append( QChar( 0x2026 ) );
    }

    expString.prepend( tr( "Current: " ) );

    if ( !mActionExpression )
    {
      mActionExpression = new QAction( expString, this );
      mActionExpression->setCheckable( true );
    }
    else
    {
      mActionExpression->setText( expString );
    }
    mDefineMenu->addAction( mActionExpression );
    mActionExpression->setChecked( mProperty.propertyType() == QgsProperty::ExpressionBasedProperty && !variableActive && !mProperty.transformer() );

    mDefineMenu->addAction( mActionExpDialog );
    mDefineMenu->addAction( mActionCopyExpr );
    mDefineMenu->addAction( mActionPasteExpr );
    mDefineMenu->addAction( mActionClearExpr );
  }
  else
  {
    mDefineMenu->addAction( mActionExpDialog );
    mDefineMenu->addAction( mActionPasteExpr );
  }

  if ( !mDefinition.name().isEmpty() && mDefinition.supportsAssistant() )
  {
    mDefineMenu->addSeparator();
    mActionAssistant->setCheckable( mProperty.transformer() );
    mActionAssistant->setChecked( mProperty.transformer() );
    mDefineMenu->addAction( mActionAssistant );
  }
}
Example #14
0
void MainWindow::updateWindowMenu()
{
    //Window menu
    ui->menuWindow->clear();

//    while(!action_delete_list.isEmpty())
//    {
//        QAction *tmp = action_delete_list.first();
//        action_delete_list.pop_back();
//        if(tmp!=NULL) {
//            WriteToLog(QtDebugMsg, QString("->>>>Removed trash!<<<<-"));
//            WriteToLog(QtDebugMsg, QString(tmp->text()));
//            delete tmp;
//        }
//    }

    QAction * SubView = ui->menuWindow->addAction(tr("Sub Windows"));
    connect(SubView, SIGNAL(triggered()), this, SLOT(setSubView()));
    SubView->setCheckable(true);
    if(GlobalSettings::MainWindowView==QMdiArea::SubWindowView)
        SubView->setChecked(true);

    //action_delete_list.push_back(SubView);


    QAction * TabView = ui->menuWindow->addAction(tr("Tab Windows"));
    connect(TabView, SIGNAL(triggered()), this, SLOT(setTabView()));
    TabView->setCheckable(true);
    if(GlobalSettings::MainWindowView==QMdiArea::TabbedView)
        TabView->setChecked(true);

    //action_delete_list.push_back(TabView);

    ui->menuWindow->addSeparator();
    //action_delete_list.push_back(ui->menuWindow->addSeparator());

    QList<QMdiSubWindow *> windows = ui->centralWidget->subWindowList();
    QAction * closeC = ui->menuWindow->addAction(tr("Close current"));
        connect(closeC, SIGNAL(triggered()), this, SLOT( on_actionClose_triggered() ) );
        closeC->setEnabled( !windows.isEmpty() );

    //action_delete_list.push_back(closeC);


    ui->menuWindow->addSeparator();
    //action_delete_list.push_back(ui->menuWindow->addSeparator());

    QAction * cascade = ui->menuWindow->addAction(tr("Cascade"));
        connect(cascade, SIGNAL(triggered()), this, SLOT( SWCascade() ) );
        cascade->setEnabled( !windows.isEmpty() );
    //action_delete_list.push_back(cascade);

    QAction * tiledW = ui->menuWindow->addAction(tr("Tiled"));
        connect(tiledW, SIGNAL(triggered()), this, SLOT( SWTile() ) );
        tiledW->setEnabled( !windows.isEmpty() );
    //action_delete_list.push_back(tiledW);

    ui->menuWindow->addSeparator();
    //action_delete_list.push_back(ui->menuWindow->addSeparator());

    QAction * empty = ui->menuWindow->addAction( tr("[No files open]") );
        empty->setDisabled(1);

        empty->setVisible( windows.isEmpty() );
    //action_delete_list.push_back(empty);


    for (int i = 0; i < windows.size(); ++i) {
        QString text;
        text = QString("%1").arg( windows.at(i)->windowTitle() ) ;
        QAction *action  = ui->menuWindow->addAction(text);
        action->setCheckable(true);
        action->setChecked( windows[i] == ui->centralWidget->activeSubWindow() );
        //action_delete_list.push_back(action);

        connect(action, SIGNAL(triggered()), windowMapper, SLOT(map()));
        windowMapper->setMapping(action, windows.at(i));
    }
}
Example #15
0
File: mapzoom.cpp Project: BGmot/Qt
MapZoom::MapZoom()
    : QMainWindow(0)
{
    map = new LightMaps(this);
    setCentralWidget(map);
    map->setFocus();

    QAction *osloAction = new QAction(tr("&Oslo"), this);
    QAction *berlinAction = new QAction(tr("&Berlin"), this);
    QAction *jakartaAction = new QAction(tr("&Jakarta"), this);
    QAction *nightModeAction = new QAction(tr("Night Mode"), this);
    nightModeAction->setCheckable(true);
    nightModeAction->setChecked(false);
    QAction *osmAction = new QAction(tr("About OpenStreetMap"), this);
    connect(osloAction, SIGNAL(triggered()), SLOT(chooseOslo()));
    connect(berlinAction, SIGNAL(triggered()), SLOT(chooseBerlin()));
    connect(jakartaAction, SIGNAL(triggered()), SLOT(chooseJakarta()));
    connect(nightModeAction, SIGNAL(triggered()), map, SLOT(toggleNightMode()));
    connect(osmAction, SIGNAL(triggered()), SLOT(aboutOsm()));

#if defined(Q_OS_SYMBIAN) || defined(Q_OS_WINCE_WM)
    menuBar()->addAction(osloAction);
    menuBar()->addAction(berlinAction);
    menuBar()->addAction(jakartaAction);
    menuBar()->addAction(nightModeAction);
    menuBar()->addAction(osmAction);
#else
    QMenu *menu = menuBar()->addMenu(tr("&Options"));
    menu->addAction(osloAction);
    menu->addAction(berlinAction);
    menu->addAction(jakartaAction);
    menu->addSeparator();
    menu->addAction(nightModeAction);
    menu->addAction(osmAction);
#endif

    QNetworkConfigurationManager manager;
    if (manager.capabilities() & QNetworkConfigurationManager::NetworkSessionRequired) {
        // Get saved network configuration
        QSettings settings(QSettings::UserScope, QLatin1String("Trolltech"));
        settings.beginGroup(QLatin1String("QtNetwork"));
        const QString id =
            settings.value(QLatin1String("DefaultNetworkConfiguration")).toString();
        settings.endGroup();

        // If the saved network configuration is not currently discovered use the system
        // default
        QNetworkConfiguration config = manager.configurationFromIdentifier(id);
        if ((config.state() & QNetworkConfiguration::Discovered) !=
            QNetworkConfiguration::Discovered) {
            config = manager.defaultConfiguration();
        }

        networkSession = new QNetworkSession(config, this);
        connect(networkSession, SIGNAL(opened()), this, SLOT(sessionOpened()));

        networkSession->open();
    } else {
        networkSession = 0;
    }

    setWindowTitle(tr("Light Maps"));
}
Example #16
0
/**
 * @brief FilesWidget::FilesWidget
 * @param parent
 */
FilesWidget::FilesWidget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::FilesWidget)
{
    m_instance = this;
    ui->setupUi(this);
    ui->statusLabel->setText(tr("%n movies", "", 0));
#ifdef Q_OS_MAC
    QFont font = ui->files->font();
    font.setPointSize(font.pointSize()-2);
    ui->files->setFont(font);
#endif

#ifdef Q_OS_WIN32
    ui->verticalLayout->setContentsMargins(0, 0, 0, 1);
#endif

    m_lastMovie = 0;
    m_mouseIsIn = false;
    m_movieProxyModel = new MovieProxyModel(this);
    m_movieProxyModel->setSourceModel(Manager::instance()->movieModel());
    m_movieProxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
    m_movieProxyModel->setDynamicSortFilter(true);
    ui->files->setModel(m_movieProxyModel);
    for (int i=1, n=ui->files->model()->columnCount() ; i<n ; ++i) {
        ui->files->setColumnWidth(i, 24);
        ui->files->setColumnHidden(i, true);
    }
    ui->files->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch);
    ui->files->setIconSize(QSize(12, 12));

    foreach (const MediaStatusColumns &column, Settings::instance()->mediaStatusColumns())
        ui->files->setColumnHidden(MovieModel::mediaStatusToColumn(column), false);

    m_alphaList = new AlphabeticalList(this, ui->files);
    m_baseLabelCss = ui->sortByYear->styleSheet();
    m_activeLabelCss = ui->sortByNew->styleSheet();

    QMenu *mediaStatusColumnsMenu = new QMenu(tr("Media Status Columns"), ui->files);
    for (int i=MediaStatusFirst, n=MediaStatusLast ; i<=n ; ++i) {
        QAction *action = new QAction(MovieModel::mediaStatusToText(static_cast<MediaStatusColumns>(i)), this);
        action->setProperty("mediaStatusColumn", i);
        action->setCheckable(true);
        action->setChecked(Settings::instance()->mediaStatusColumns().contains(static_cast<MediaStatusColumns>(i)));
        connect(action, SIGNAL(triggered()), this, SLOT(onActionMediaStatusColumn()));
        mediaStatusColumnsMenu->addAction(action);
    }

    QMenu *labelsMenu = new QMenu(tr("Label"), ui->files);
    QMapIterator<int, QString> it(Helper::labels());
    while (it.hasNext()) {
        it.next();
        QAction *action = new QAction(it.value(), this);
        action->setIcon(Helper::iconForLabel(it.key()));
        action->setProperty("color", it.key());
        connect(action, SIGNAL(triggered()), this, SLOT(onLabel()));
        labelsMenu->addAction(action);
    }

    QAction *actionMultiScrape = new QAction(tr("Load Information"), this);
    QAction *actionMarkAsWatched = new QAction(tr("Mark as watched"), this);
    QAction *actionMarkAsUnwatched = new QAction(tr("Mark as unwatched"), this);
    QAction *actionLoadStreamDetails = new QAction(tr("Load Stream Details"), this);
    QAction *actionMarkForSync = new QAction(tr("Add to Synchronization Queue"), this);
    QAction *actionUnmarkForSync = new QAction(tr("Remove from Synchronization Queue"), this);
    QAction *actionOpenFolder = new QAction(tr("Open Movie Folder"), this);
    m_contextMenu = new QMenu(ui->files);
    m_contextMenu->addAction(actionMultiScrape);
    m_contextMenu->addSeparator();
    m_contextMenu->addAction(actionMarkAsWatched);
    m_contextMenu->addAction(actionMarkAsUnwatched);
    m_contextMenu->addSeparator();
    m_contextMenu->addAction(actionLoadStreamDetails);
    m_contextMenu->addSeparator();
    m_contextMenu->addAction(actionMarkForSync);
    m_contextMenu->addAction(actionUnmarkForSync);
    m_contextMenu->addSeparator();
    m_contextMenu->addAction(actionOpenFolder);
    m_contextMenu->addSeparator();
    m_contextMenu->addMenu(labelsMenu);
    m_contextMenu->addMenu(mediaStatusColumnsMenu);

    connect(actionMultiScrape, SIGNAL(triggered()), this, SLOT(multiScrape()));
    connect(actionMarkAsWatched, SIGNAL(triggered()), this, SLOT(markAsWatched()));
    connect(actionMarkAsUnwatched, SIGNAL(triggered()), this, SLOT(markAsUnwatched()));
    connect(actionLoadStreamDetails, SIGNAL(triggered()), this, SLOT(loadStreamDetails()));
    connect(actionMarkForSync, SIGNAL(triggered()), this, SLOT(markForSync()));
    connect(actionUnmarkForSync, SIGNAL(triggered()), this, SLOT(unmarkForSync()));
    connect(actionOpenFolder, SIGNAL(triggered()), this, SLOT(openFolder()));

    connect(ui->files, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showContextMenu(QPoint)));
    connect(ui->files->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, SLOT(itemActivated(QModelIndex, QModelIndex)));
    connect(ui->files->model(), SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(setAlphaListData()));
    connect(ui->files, SIGNAL(sigLeftEdge(bool)), this, SLOT(onLeftEdge(bool)));

    connect(m_alphaList, SIGNAL(sigAlphaClicked(QString)), this, SLOT(scrollToAlpha(QString)));

    connect(ui->sortByNew, SIGNAL(clicked()), this, SLOT(onSortByNew()));
    connect(ui->sortByName, SIGNAL(clicked()), this, SLOT(onSortByName()));
    connect(ui->sortByLastAdded, SIGNAL(clicked()), this, SLOT(onSortByAdded()));
    connect(ui->sortBySeen, SIGNAL(clicked()), this, SLOT(onSortBySeen()));
    connect(ui->sortByYear, SIGNAL(clicked()), this, SLOT(onSortByYear()));

    connect(m_movieProxyModel, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(onViewUpdated()));
    connect(m_movieProxyModel, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(onViewUpdated()));
}
void QgsLegendLayer::addToPopupMenu( QMenu& theMenu )
{
  QgsMapLayer *lyr = layer();
  QAction *toggleEditingAction = QgisApp::instance()->actionToggleEditing();

  // zoom to layer extent
  theMenu.addAction( QgisApp::getThemeIcon( "/mActionZoomToLayer.png" ),
                     tr( "&Zoom to layer extent" ), legend(), SLOT( legendLayerZoom() ) );
  if ( lyr->type() == QgsMapLayer::RasterLayer )
  {
    theMenu.addAction( tr( "&Zoom to best scale (100%)" ), legend(), SLOT( legendLayerZoomNative() ) );

    QgsRasterLayer *rasterLayer =  qobject_cast<QgsRasterLayer *>( lyr );
    if ( rasterLayer && rasterLayer->rasterType() != QgsRasterLayer::Palette )
    {
      theMenu.addAction( tr( "&Stretch using current extent" ), legend(), SLOT( legendLayerStretchUsingCurrentExtent() ) );
    }
  }

  // show in overview
  QAction* showInOverviewAction = theMenu.addAction( tr( "&Show in overview" ), this, SLOT( showInOverview() ) );
  showInOverviewAction->setCheckable( true );
  showInOverviewAction->blockSignals( true );
  showInOverviewAction->setChecked( mLyr.isInOverview() );
  showInOverviewAction->blockSignals( false );

  // remove from canvas
  theMenu.addAction( QgisApp::getThemeIcon( "/mActionRemoveLayer.png" ), tr( "&Remove" ), QgisApp::instance(), SLOT( removeLayer() ) );

  // set layer crs
  theMenu.addAction( QgisApp::getThemeIcon( "/mActionSetCRS.png" ), tr( "&Set layer CRS" ), QgisApp::instance(), SLOT( setLayerCRS() ) );

  // assign layer crs to project
  theMenu.addAction( QgisApp::getThemeIcon( "/mActionSetProjectCRS.png" ), tr( "Set &project CRS from layer" ), QgisApp::instance(), SLOT( setProjectCRSFromLayer() ) );

  theMenu.addSeparator();

  if ( lyr->type() == QgsMapLayer::VectorLayer )
  {
    QgsVectorLayer* vlayer = qobject_cast<QgsVectorLayer *>( lyr );

    // attribute table
    theMenu.addAction( QgisApp::getThemeIcon( "/mActionOpenTable.png" ), tr( "&Open attribute table" ),
                       QgisApp::instance(), SLOT( attributeTable() ) );

    // allow editing
    int cap = vlayer->dataProvider()->capabilities();
    if ( cap & QgsVectorDataProvider::EditingCapabilities )
    {
      if ( toggleEditingAction )
      {
        theMenu.addAction( toggleEditingAction );
        toggleEditingAction->setChecked( vlayer->isEditable() );
      }
    }

    // save as vector file
    theMenu.addAction( tr( "Save as..." ), QgisApp::instance(), SLOT( saveAsVectorFile() ) );

    // save selection as vector file
    QAction* saveSelectionAsAction = theMenu.addAction( tr( "Save selection as..." ), QgisApp::instance(), SLOT( saveSelectionAsVectorFile() ) );
    if ( vlayer->selectedFeatureCount() == 0 )
    {
      saveSelectionAsAction->setEnabled( false );
    }

    if ( !vlayer->isEditable() && vlayer->dataProvider()->supportsSubsetString() )
      theMenu.addAction( tr( "&Query..." ), QgisApp::instance(), SLOT( layerSubsetString() ) );

    //show number of features in legend if requested
    QAction* showNFeaturesAction = new QAction( tr( "Show feature count" ), &theMenu );
    showNFeaturesAction->setCheckable( true );
    showNFeaturesAction->setChecked( mShowFeatureCount );
    QObject::connect( showNFeaturesAction, SIGNAL( toggled( bool ) ), this, SLOT( setShowFeatureCount( bool ) ) );
    theMenu.addAction( showNFeaturesAction );
    theMenu.addSeparator();
  }
QgsAdvancedDigitizingDockWidget::QgsAdvancedDigitizingDockWidget( QgsMapCanvas *canvas, QWidget *parent )
  : QgsDockWidget( parent )
  , mMapCanvas( canvas )
  , mCurrentMapToolSupportsCad( false )
  , mCadEnabled( false )
  , mConstructionMode( false )
  , mCommonAngleConstraint( QgsSettings().value( QStringLiteral( "/Cad/CommonAngle" ), 90 ).toInt() )
  , mSnappedToVertex( false )
  , mSessionActive( false )
  , mErrorMessage( nullptr )
{
  setupUi( this );

  mCadPaintItem = new QgsAdvancedDigitizingCanvasItem( canvas, this );

  mAngleConstraint.reset( new CadConstraint( mAngleLineEdit, mLockAngleButton, mRelativeAngleButton, mRepeatingLockAngleButton ) );
  mDistanceConstraint.reset( new CadConstraint( mDistanceLineEdit, mLockDistanceButton, nullptr, mRepeatingLockDistanceButton ) );
  mXConstraint.reset( new CadConstraint( mXLineEdit, mLockXButton, mRelativeXButton, mRepeatingLockXButton ) );
  mYConstraint.reset( new CadConstraint( mYLineEdit, mLockYButton, mRelativeYButton, mRepeatingLockYButton ) );
  mAdditionalConstraint = NoConstraint;

  mMapCanvas->installEventFilter( this );
  mAngleLineEdit->installEventFilter( this );
  mDistanceLineEdit->installEventFilter( this );
  mXLineEdit->installEventFilter( this );
  mYLineEdit->installEventFilter( this );

  // this action is also used in the advanced digitizing tool bar
  mEnableAction = new QAction( this );
  mEnableAction->setText( tr( "Enable advanced digitizing tools" ) );
  mEnableAction->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/cadtools/cad.svg" ) ) );
  mEnableAction->setCheckable( true );
  mEnabledButton->addAction( mEnableAction );
  mEnabledButton->setDefaultAction( mEnableAction );

  // Connect the UI to the event filter to update constraints
  connect( mEnableAction, &QAction::triggered, this, &QgsAdvancedDigitizingDockWidget::activateCad );
  connect( mConstructionModeButton, &QAbstractButton::clicked, this, &QgsAdvancedDigitizingDockWidget::setConstructionMode );
  connect( mParallelButton, &QAbstractButton::clicked, this, &QgsAdvancedDigitizingDockWidget::additionalConstraintClicked );
  connect( mPerpendicularButton, &QAbstractButton::clicked, this, &QgsAdvancedDigitizingDockWidget::additionalConstraintClicked );
  connect( mLockAngleButton, &QAbstractButton::clicked, this, &QgsAdvancedDigitizingDockWidget::lockConstraint );
  connect( mLockDistanceButton, &QAbstractButton::clicked, this, &QgsAdvancedDigitizingDockWidget::lockConstraint );
  connect( mLockXButton, &QAbstractButton::clicked, this, &QgsAdvancedDigitizingDockWidget::lockConstraint );
  connect( mLockYButton, &QAbstractButton::clicked, this, &QgsAdvancedDigitizingDockWidget::lockConstraint );
  connect( mRelativeAngleButton, &QAbstractButton::clicked, this, &QgsAdvancedDigitizingDockWidget::setConstraintRelative );
  connect( mRelativeXButton, &QAbstractButton::clicked, this, &QgsAdvancedDigitizingDockWidget::setConstraintRelative );
  connect( mRelativeYButton, &QAbstractButton::clicked, this, &QgsAdvancedDigitizingDockWidget::setConstraintRelative );
  connect( mRepeatingLockDistanceButton, &QAbstractButton::clicked, this, &QgsAdvancedDigitizingDockWidget::setConstraintRepeatingLock );
  connect( mRepeatingLockAngleButton, &QAbstractButton::clicked, this, &QgsAdvancedDigitizingDockWidget::setConstraintRepeatingLock );
  connect( mRepeatingLockXButton, &QAbstractButton::clicked, this, &QgsAdvancedDigitizingDockWidget::setConstraintRepeatingLock );
  connect( mRepeatingLockYButton, &QAbstractButton::clicked, this, &QgsAdvancedDigitizingDockWidget::setConstraintRepeatingLock );
  connect( mAngleLineEdit, &QLineEdit::returnPressed, this, [ = ]() { lockConstraint(); } );
  connect( mDistanceLineEdit, &QLineEdit::returnPressed, this, [ = ]() { lockConstraint(); } );
  connect( mXLineEdit, &QLineEdit::returnPressed, this, [ = ]() { lockConstraint(); } );
  connect( mYLineEdit, &QLineEdit::returnPressed, this, [ = ]() { lockConstraint(); } );
  connect( mAngleLineEdit, &QLineEdit::textEdited, this, &QgsAdvancedDigitizingDockWidget::constraintTextEdited );
  connect( mDistanceLineEdit, &QLineEdit::textEdited, this, &QgsAdvancedDigitizingDockWidget::constraintTextEdited );
  connect( mXLineEdit, &QLineEdit::textEdited, this, &QgsAdvancedDigitizingDockWidget::constraintTextEdited );
  connect( mYLineEdit, &QLineEdit::textEdited, this, &QgsAdvancedDigitizingDockWidget::constraintTextEdited );
  //also watch for focus out events on these widgets
  QgsFocusWatcher *angleWatcher = new QgsFocusWatcher( mAngleLineEdit );
  connect( angleWatcher, &QgsFocusWatcher::focusOut, this, &QgsAdvancedDigitizingDockWidget::constraintFocusOut );
  QgsFocusWatcher *distanceWatcher = new QgsFocusWatcher( mDistanceLineEdit );
  connect( distanceWatcher, &QgsFocusWatcher::focusOut, this, &QgsAdvancedDigitizingDockWidget::constraintFocusOut );
  QgsFocusWatcher *xWatcher = new QgsFocusWatcher( mXLineEdit );
  connect( xWatcher, &QgsFocusWatcher::focusOut, this, &QgsAdvancedDigitizingDockWidget::constraintFocusOut );
  QgsFocusWatcher *yWatcher = new QgsFocusWatcher( mYLineEdit );
  connect( yWatcher, &QgsFocusWatcher::focusOut, this, &QgsAdvancedDigitizingDockWidget::constraintFocusOut );

  // config menu
  QMenu *menu = new QMenu( this );
  // common angles
  QActionGroup *angleButtonGroup = new QActionGroup( menu ); // actions are exclusive for common angles
  mCommonAngleActions = QMap<QAction *, int>();
  QList< QPair< int, QString > > commonAngles;
  commonAngles << QPair<int, QString>( 0, trUtf8( "Do not snap to common angles" ) );
  commonAngles << QPair<int, QString>( 30, trUtf8( "Snap to 30° angles" ) );
  commonAngles << QPair<int, QString>( 45, trUtf8( "Snap to 45° angles" ) );
  commonAngles << QPair<int, QString>( 90, trUtf8( "Snap to 90° angles" ) );
  for ( QList< QPair< int, QString > >::const_iterator it = commonAngles.constBegin(); it != commonAngles.constEnd(); ++it )
  {
    QAction *action = new QAction( it->second, menu );
    action->setCheckable( true );
    action->setChecked( it->first == mCommonAngleConstraint );
    menu->addAction( action );
    angleButtonGroup->addAction( action );
    mCommonAngleActions.insert( action, it->first );
  }

  mSettingsButton->setMenu( menu );
  connect( mSettingsButton, SIGNAL( triggered( QAction * ) ), this, SLOT( settingsButtonTriggered( QAction * ) ) );

  // set tooltips
  mConstructionModeButton->setToolTip( "<b>" + tr( "Construction mode" ) + "</b><br>(" + tr( "press c to toggle on/off" ) + ")" );
  mDistanceLineEdit->setToolTip( "<b>" + tr( "Distance" ) + "</b><br>(" + tr( "press d for quick access" ) + ")" );
  mLockDistanceButton->setToolTip( "<b>" + tr( "Lock distance" ) + "</b><br>(" + tr( "press Ctrl + d for quick access" ) + ")" );
  mRepeatingLockDistanceButton->setToolTip( "<b>" + tr( "Continuously lock distance" ) + "</b>" );

  mRelativeAngleButton->setToolTip( "<b>" + tr( "Toggles relative angle to previous segment" ) + "</b><br>(" + tr( "press Shift + a for quick access" ) + ")" );
  mAngleLineEdit->setToolTip( "<b>" + tr( "Angle" ) + "</b><br>(" + tr( "press a for quick access" ) + ")" );
  mLockAngleButton->setToolTip( "<b>" + tr( "Lock angle" ) + "</b><br>(" + tr( "press Ctrl + a for quick access" ) + ")" );
  mRepeatingLockAngleButton->setToolTip( "<b>" + tr( "Continuously lock angle" ) + "</b>" );

  mRelativeXButton->setToolTip( "<b>" + tr( "Toggles relative x to previous node" ) + "</b><br>(" + tr( "press Shift + x for quick access" ) + ")" );
  mXLineEdit->setToolTip( "<b>" + tr( "X coordinate" ) + "</b><br>(" + tr( "press x for quick access" ) + ")" );
  mLockXButton->setToolTip( "<b>" + tr( "Lock x coordinate" ) + "</b><br>(" + tr( "press Ctrl + x for quick access" ) + ")" );
  mRepeatingLockXButton->setToolTip( "<b>" + tr( "Continuously lock x coordinate" ) + "</b>" );

  mRelativeYButton->setToolTip( "<b>" + tr( "Toggles relative y to previous node" ) + "</b><br>(" + tr( "press Shift + y for quick access" ) + ")" );
  mYLineEdit->setToolTip( "<b>" + tr( "Y coordinate" ) + "</b><br>(" + tr( "press y for quick access" ) + ")" );
  mLockYButton->setToolTip( "<b>" + tr( "Lock y coordinate" ) + "</b><br>(" + tr( "press Ctrl + y for quick access" ) + ")" );
  mRepeatingLockYButton->setToolTip( "<b>" + tr( "Continuously lock y coordinate" ) + "</b>" );


  updateCapacity( true );
  connect( QgsProject::instance(), &QgsProject::snappingConfigChanged, this, [ = ] { updateCapacity( true ); } );

  disable();
}
Example #19
0
void FriendWidget::contextMenuEvent(QContextMenuEvent * event)
{
    if (!active)
        setBackgroundRole(QPalette::Highlight);

    installEventFilter(this); // Disable leave event.

    QPoint pos = event->globalPos();
    ToxId id = FriendList::findFriend(friendId)->getToxId();
    QString dir = Settings::getInstance().getAutoAcceptDir(id);
    QMenu menu;
    QAction* openChatWindow = nullptr;
    QAction* removeChatWindow = nullptr;

    ContentDialog* contentDialog = ContentDialog::getFriendDialog(friendId);
    bool notAlone = contentDialog != nullptr && contentDialog->chatroomWidgetCount() > 1;

    if (contentDialog == nullptr || notAlone)
        openChatWindow = menu.addAction(tr("Open chat in new window"));

    if (contentDialog != nullptr && contentDialog->hasFriendWidget(friendId, this))
        removeChatWindow = menu.addAction(tr("Remove chat from this window"));

    menu.addSeparator();
    QMenu* inviteMenu = menu.addMenu(tr("Invite to group","Menu to invite a friend to a groupchat"));
    QAction* newGroupAction = inviteMenu->addAction(tr("To new group"));
    inviteMenu->addSeparator();
    QMap<QAction*, Group*> groupActions;

    for (Group* group : GroupList::getAllGroups())
    {
        int maxNameLen = 30;
        QString name = group->getGroupWidget()->getName();
        if ( name.length() > maxNameLen )
        {
            name = name.left(maxNameLen).trimmed() + "..";
        }
        QAction* groupAction = inviteMenu->addAction(tr("Invite to group '%1'").arg(name));
        groupActions[groupAction] =  group;
    }

    int circleId = Settings::getInstance().getFriendCircleID(FriendList::findFriend(friendId)->getToxId());
    CircleWidget *circleWidget = CircleWidget::getFromID(circleId);

    QMenu* circleMenu = nullptr;
    QAction* newCircleAction = nullptr;
    QAction *removeCircleAction = nullptr;
    QMap<QAction*, int> circleActions;

    FriendListWidget *friendList;

    if (circleWidget == nullptr)
        friendList = qobject_cast<FriendListWidget*>(FriendList::findFriend(friendId)->getFriendWidget()->parentWidget());
    else
        friendList = qobject_cast<FriendListWidget*>(circleWidget->parentWidget());

    circleMenu = menu.addMenu(tr("Move to circle...", "Menu to move a friend into a different circle"));

    newCircleAction = circleMenu->addAction(tr("To new circle"));

    if (circleId != -1)
        removeCircleAction = circleMenu->addAction(tr("Remove from circle '%1'").arg(Settings::getInstance().getCircleName(circleId)));

    circleMenu->addSeparator();

    QList<QAction*> circleActionList;

    for (int i = 0; i < Settings::getInstance().getCircleCount(); ++i)
    {
        if (i != circleId)
        {
            circleActionList.push_back(new QAction(tr("Move  to circle \"%1\"").arg(Settings::getInstance().getCircleName(i)), circleMenu));
            circleActions[circleActionList.back()] = i;
        }
    }

    std::sort(circleActionList.begin(), circleActionList.end(), [](const QAction* lhs, const QAction* rhs) -> bool
    {
        QCollator collator;
        collator.setNumericMode(true);
        return collator.compare(lhs->text(), rhs->text()) < 0;
    });

    circleMenu->addActions(circleActionList);

    QAction* setAlias = menu.addAction(tr("Set alias..."));

    menu.addSeparator();
    QAction* autoAccept = menu.addAction(tr("Auto accept files from this friend", "context menu entry"));
    autoAccept->setCheckable(true);
    autoAccept->setChecked(!dir.isEmpty());
    menu.addSeparator();

    QAction* removeFriendAction = nullptr;

    if (contentDialog == nullptr || !contentDialog->hasFriendWidget(friendId, this))
        removeFriendAction = menu.addAction(tr("Remove friend", "Menu to remove the friend from our friendlist"));

    menu.addSeparator();
    QAction* aboutWindow = menu.addAction(tr("Show details"));

    QAction* selectedItem = menu.exec(pos);

    removeEventFilter(this);

    if (!active)
        setBackgroundRole(QPalette::Window);

    if (selectedItem)
    {
        if (selectedItem == setAlias)
        {
            nameLabel->editBegin();
        }
        else if (selectedItem == removeFriendAction)
        {
            emit removeFriend(friendId);
            return;
        }
        else if (selectedItem == openChatWindow)
        {
            emit chatroomWidgetClicked(this, true);
            return;
        }
        else if (selectedItem == removeChatWindow)
        {
            ContentDialog* contentDialog = ContentDialog::getFriendDialog(friendId);
            contentDialog->removeFriend(friendId);
            return;
        }
        else if (selectedItem == autoAccept)
        {
            if (!autoAccept->isChecked())
            {
                qDebug() << "not checked";
                dir = QDir::homePath();
                autoAccept->setChecked(false);
                Settings::getInstance().setAutoAcceptDir(id, "");
            }
            else if (autoAccept->isChecked())
            {
                dir = QFileDialog::getExistingDirectory(0,
                                                        tr("Choose an auto accept directory","popup title"),
                                                        dir,
                                                        QFileDialog::DontUseNativeDialog);
                autoAccept->setChecked(true);
                qDebug() << "setting auto accept dir for" << friendId << "to" << dir;
                Settings::getInstance().setAutoAcceptDir(id, dir);
            }
        }
        else if (selectedItem == aboutWindow)
        {
            AboutUser *aboutUser = new AboutUser(id, Widget::getInstance());
            aboutUser->setFriend(FriendList::findFriend(friendId));
            aboutUser->show();
        }
        else if (selectedItem == newGroupAction)
        {
            int groupId = Core::getInstance()->createGroup();
            Core::getInstance()->groupInviteFriend(friendId, groupId);
        }
        else if (selectedItem == newCircleAction)
        {
            if (circleWidget != nullptr)
                circleWidget->updateStatus();

            if (friendList != nullptr)
                friendList->addCircleWidget(FriendList::findFriend(friendId)->getFriendWidget());
            else
                Settings::getInstance().setFriendCircleID(id, Settings::getInstance().addCircle());
        }
        else if (groupActions.contains(selectedItem))
        {
            Group* group = groupActions[selectedItem];
            Core::getInstance()->groupInviteFriend(friendId, group->getGroupId());
        }
        else if (removeCircleAction != nullptr && selectedItem == removeCircleAction)
        {
            if (friendList != nullptr)
                friendList->moveWidget(FriendList::findFriend(friendId)->getFriendWidget(), FriendList::findFriend(friendId)->getStatus(), true);
            else
                Settings::getInstance().setFriendCircleID(id, -1);

            if (circleWidget)
            {
                circleWidget->updateStatus();
                Widget::getInstance()->searchCircle(circleWidget);
            }
        }
        else if (circleActions.contains(selectedItem))
        {
            CircleWidget* circle = CircleWidget::getFromID(circleActions[selectedItem]);

            if (circle != nullptr)
            {
                circle->addFriendWidget(FriendList::findFriend(friendId)->getFriendWidget(), FriendList::findFriend(friendId)->getStatus());
                circle->setExpanded(true);
                Widget::getInstance()->searchCircle(circle);
                Settings::getInstance().savePersonal();
            }
            else
                Settings::getInstance().setFriendCircleID(id, circleActions[selectedItem]);

            if (circleWidget != nullptr)
            {
                circleWidget->updateStatus();
                Widget::getInstance()->searchCircle(circleWidget);
            }
        }
    }
}
Example #20
0
void MainWindow::createMenus()
{
    Settings::Manager *s = mMain->settings();
    s->beginGroup("IDE/shortcuts");

    new QShortcut( s->shortcut("cmdLineFocus"), this, SLOT(toggleComandLineFocus()) );

    QAction *act;

    // File

    mActions[Quit] = act = new QAction(
        QIcon::fromTheme("application-exit"), tr("&Quit..."), this);
    act->setShortcut(s->shortcut("quit"));
    act->setStatusTip(tr("Quit SuperCollider IDE"));
    QObject::connect( act, SIGNAL(triggered()), this, SLOT(onQuit()) );

    // View
    mActions[ShowDocList] = act = new QAction(tr("&Documents"), this);
    act->setStatusTip(tr("Show/Hide the Documents dock"));
    act->setCheckable(true);
    connect(act, SIGNAL(triggered(bool)), mDocListDock, SLOT(setVisible(bool)));
    connect(mDocListDock, SIGNAL(visibilityChanged(bool)), act, SLOT(setChecked(bool)));

    // Language

    mActions[EvaluateCurrentFile] = act = new QAction(
        QIcon::fromTheme("media-playback-start"), tr("Evaluate &File"), this);
    act->setStatusTip(tr("Evaluate current File"));
    connect(act, SIGNAL(triggered()), this, SLOT(evaluateCurrentFile()));

    mActions[EvaluateSelection] = act = new QAction(
        QIcon::fromTheme("media-playback-start"), tr("&Evaluate Selection"), this);
    act->setShortcut(s->shortcut("evaluateSelection"));
    act->setStatusTip(tr("Evaluate selection or current line"));
    connect(act, SIGNAL(triggered()), this, SLOT(evaluateSelection()));

    mActions[EvaluateRegion] = act = new QAction(
    QIcon::fromTheme("media-playback-start"), tr("&Evaluate Region"), this);
    act->setShortcut(s->shortcut("evaluateRegion"));
    act->setStatusTip(tr("Evaluate current region"));
    connect(act, SIGNAL(triggered()), this, SLOT(evaluateRegion()));

    mMain->scProcess()->action(ScIDE::SCProcess::StopMain)
        ->setShortcut(s->shortcut("stopMain"));

    // Settings

    mActions[ShowSettings] = act = new QAction(tr("&Configure IDE..."), this);
    act->setStatusTip(tr("Show configuration dialog"));
    connect(act, SIGNAL(triggered()), this, SLOT(showSettings()));

    // Help

    mActions[BrowseHelp] = act = new QAction(
    QIcon::fromTheme("system-help"), tr("&Browse Help"), this);
    act->setStatusTip(tr("Open help browser on the Browse page."));
    //connect(act, SIGNAL(triggered()), this, SLOT(browseHelp()));
    mCodeEvalMapper.setMapping(act, "HelpBrowser.openBrowsePage");
    connect(act, SIGNAL(triggered()), &mCodeEvalMapper, SLOT(map()));

    mActions[SearchHelp] = act = new QAction(
    QIcon::fromTheme("system-help"), tr("&Search Help"), this);
    act->setStatusTip(tr("Open help browser on the Search page."));
    //connect(act, SIGNAL(triggered()), this, SLOT(searchHelp()));
    mCodeEvalMapper.setMapping(act, "HelpBrowser.openSearchPage");
    connect(act, SIGNAL(triggered()), &mCodeEvalMapper, SLOT(map()));

    mActions[HelpForSelection] = act = new QAction(
    QIcon::fromTheme("system-help"), tr("&Help for Selection"), this);
    act->setShortcut(s->shortcut("helpForSelection"));
    act->setStatusTip(tr("Find help for selected text"));
    connect(act, SIGNAL(triggered()), this, SLOT(helpForSelection()));

    s->endGroup(); // IDE/shortcuts;

    QMenu *menu;
    QMenu *submenu;

    menu = new QMenu(tr("&File"), this);
    menu->addAction( mEditors->action(MultiEditor::DocNew) );
    menu->addAction( mEditors->action(MultiEditor::DocOpen) );
    menu->addAction( mEditors->action(MultiEditor::DocSave) );
    menu->addAction( mEditors->action(MultiEditor::DocSaveAs) );
    menu->addSeparator();
    menu->addAction( mEditors->action(MultiEditor::DocClose) );
    menu->addSeparator();
    menu->addAction( mActions[Quit] );

    menuBar()->addMenu(menu);

    menu = new QMenu(tr("&Edit"), this);
    menu->addAction( mEditors->action(MultiEditor::Undo) );
    menu->addAction( mEditors->action(MultiEditor::Redo) );
    menu->addSeparator();
    menu->addAction( mEditors->action(MultiEditor::Cut) );
    menu->addAction( mEditors->action(MultiEditor::Copy) );
    menu->addAction( mEditors->action(MultiEditor::Paste) );
    menu->addSeparator();
    menu->addAction( mEditors->action(MultiEditor::Find) );
    menu->addAction( mEditors->action(MultiEditor::Replace) );
    menu->addSeparator();
    menu->addAction( mEditors->action(MultiEditor::IndentMore) );
    menu->addAction( mEditors->action(MultiEditor::IndentLess) );
    menu->addSeparator();
    menu->addAction( mEditors->action(MultiEditor::OpenClassDefinition) );

    menuBar()->addMenu(menu);

    menu = new QMenu(tr("&View"), this);
    submenu = new QMenu(tr("&Docks"), this);
    submenu->addAction( mActions[ShowDocList] );
    menu->addMenu(submenu);
    menu->addSeparator();
    menu->addAction( mEditors->action(MultiEditor::EnlargeFont) );
    menu->addAction( mEditors->action(MultiEditor::ShrinkFont) );
    menu->addSeparator();
    menu->addAction( mEditors->action(MultiEditor::ShowWhitespace) );

    menuBar()->addMenu(menu);

    menu = new QMenu(tr("&Language"), this);
    menu->addAction( mMain->scProcess()->action(SCProcess::StartSCLang) );
    menu->addAction( mMain->scProcess()->action(SCProcess::RecompileClassLibrary) );
    menu->addAction( mMain->scProcess()->action(SCProcess::StopSCLang) );
    menu->addSeparator();
    menu->addAction( mActions[EvaluateCurrentFile] );
    menu->addAction( mActions[EvaluateRegion] );
    menu->addAction( mActions[EvaluateSelection] );
    menu->addSeparator();
    menu->addAction( mMain->scProcess()->action(ScIDE::SCProcess::RunMain) );
    menu->addAction( mMain->scProcess()->action(ScIDE::SCProcess::StopMain) );

    menuBar()->addMenu(menu);

    menu = new QMenu(tr("&Settings"), this);
    menu->addAction( mActions[ShowSettings] );

    menuBar()->addMenu(menu);

    menu = new QMenu(tr("&Help"), this);
    menu->addAction( mActions[BrowseHelp] );
    menu->addAction( mActions[SearchHelp] );
    menu->addAction( mActions[HelpForSelection] );

    menuBar()->addMenu(menu);
}
KrugovyeChasy::KrugovyeChasy(bool app, QWidget *parent)
    : QWidget(parent)
    , mPausa(false)
    , mApp(app)
{
    setObjectName("KrugovyeChasy");
    setMinimumSize(50, 50);

    if (mApp) {
        setWindowFlags(Qt::FramelessWindowHint | Qt::WindowSystemMenuHint);

        QAction *effectsAction = new QAction(tr("Включить э&ффекты"), this);
        effectsAction->setShortcut(QKeySequence(Qt::Key_E));
        effectsAction->setCheckable(true);
        connect(effectsAction, SIGNAL(triggered(bool)), this, SLOT(effects(bool)));

        QAction *pauseAction = new QAction(tr("Прио&становить"), this);
        pauseAction->setShortcut(QKeySequence(Qt::Key_Space));
        pauseAction->setCheckable(true);
        connect(pauseAction, SIGNAL(triggered(bool)), this, SLOT(pause(bool)));

        QAction *sepAction = new QAction(this);
        sepAction->setSeparator(true);

        QAction *vyhodAction = new QAction(tr("В&ыход"), this);
        vyhodAction->setShortcuts(QList<QKeySequence>() << QKeySequence(Qt::Key_Q)
                                  << QKeySequence(Qt::Key_Escape)
                                  << QKeySequence(QKeySequence::Close));
        connect(vyhodAction, SIGNAL(triggered()), this, SLOT(quit()));

        addAction(effectsAction);
        addAction(pauseAction);
        addAction(sepAction);
        addAction(vyhodAction);

        setContextMenuPolicy(Qt::ActionsContextMenu);
        setToolTip(tr("Славяно-Арийские круговые часы"));
        setWindowTitle(tr("Славяно-Арийские круговые часы"));
    }

    KDTime time = KDTime::currentTime();
    mTimer = new KDTimeTimer();
    mTimer->start(4, time.dolya(), time.chast(), time.chas());

    setTime(mTimer->time());

    connect(mTimer, SIGNAL(dolyaChanged(int)), this, SLOT(setDolyu(int)));
    connect(mTimer, SIGNAL(chastChanged(int)), this, SLOT(setChast(int)));
    connect(mTimer, SIGNAL(chasChanged(int)), this, SLOT(setChas(int)));

    readSettings();

    mChasyKartinki << QPixmap(":/kalyadydar/chasy/1paobed.png")
            << QPixmap(":/kalyadydar/chasy/2vecher.png")
            << QPixmap(":/kalyadydar/chasy/3nich.png")
            << QPixmap(":/kalyadydar/chasy/4polich.png")
            << QPixmap(":/kalyadydar/chasy/5zautra.png")
            << QPixmap(":/kalyadydar/chasy/6zaura.png")
            << QPixmap(":/kalyadydar/chasy/7zaurnice.png")
            << QPixmap(":/kalyadydar/chasy/8nastya.png")
            << QPixmap(":/kalyadydar/chasy/9swaor.png")
            << QPixmap(":/kalyadydar/chasy/10utros.png")
            << QPixmap(":/kalyadydar/chasy/11poutros.png")
            << QPixmap(":/kalyadydar/chasy/12obestina.png")
            << QPixmap(":/kalyadydar/chasy/13obed.png")
            << QPixmap(":/kalyadydar/chasy/14podani.png")
            << QPixmap(":/kalyadydar/chasy/15utdayini.png")
            << QPixmap(":/kalyadydar/chasy/16poudani.png")
            ;
}
Example #22
0
void SCgWindow::createToolBar()
{
    mToolBar = new QToolBar(this);

    mToolBar->setIconSize(QSize(32, 32));

    QActionGroup* group = new QActionGroup(mToolBar);

    // Select mode
    QAction *action = new QAction(findIcon("tool-select.png"), tr("Selection mode"), mToolBar);
    action->setCheckable(true);
    action->setChecked(true);
    action->setShortcut(QKeySequence(tr("1", "Selection mode")));
    group->addAction(action);
    mToolBar->addAction(action);
    mMode2Action[SCgScene::Mode_Select] = action;
    connect(action, SIGNAL(triggered()), this, SLOT(onSelectMode()));

    //Pair creation mode
    action = new QAction(findIcon("tool-pair.png"), tr("Pair creation mode"), mToolBar);
    action->setCheckable(true);
    action->setShortcut(QKeySequence(tr("2", "Pair creation mode")));
    group->addAction(action);
    mToolBar->addAction(action);
    mMode2Action[SCgScene::Mode_Pair] = action;
    connect(action, SIGNAL(triggered()), this, SLOT(onPairMode()));

    //Bus creation mode
    action = new QAction(findIcon("tool-bus.png"), tr("Bus creation mode"), mToolBar);
    action->setCheckable(true);
    action->setShortcut(QKeySequence(tr("3", "Bus creation mode")));
    group->addAction(action);
    mToolBar->addAction(action);
    mMode2Action[SCgScene::Mode_Bus] = action;
    connect(action, SIGNAL(triggered()), this, SLOT(onBusMode()));

    //Contour creation mode
    action = new QAction(findIcon("tool-contour.png"), tr("Contour creation mode"), mToolBar);
    action->setCheckable(true);
    action->setShortcut(QKeySequence(tr("4", "Contour creation mode")));
    group->addAction(action);
    mToolBar->addAction(action);
    mMode2Action[SCgScene::Mode_Contour] = action;
    connect(action, SIGNAL(triggered()), this, SLOT(onContourMode()));
    //
    mToolBar->addSeparator();
    //

    // align group button
    QToolButton *alignButton = new QToolButton(mToolBar);
    alignButton->setIcon(findIcon("tool-align.png"));
    alignButton->setPopupMode(QToolButton::InstantPopup);
    mToolBar->addWidget(alignButton);

    //Grid alignment
    action = new QAction(findIcon("tool-align-grid.png"), tr("Grid alignment"), mToolBar);
    action->setCheckable(false);
    action->setShortcut(QKeySequence(tr("5", "Grid alignment")));
    alignButton->addAction(action);
    connect(action, SIGNAL(triggered()), this, SLOT(onGridAlignment()));

    // tuple alignment
    action = new QAction(findIcon("tool-align-tuple.png"), tr("Tuple alignment"), mToolBar);
    action->setCheckable(false);
    action->setShortcut(QKeySequence(tr("6", "Tuple alignment")));
    alignButton->addAction(action);
    connect(action, SIGNAL(triggered()), this, SLOT(onTupleAlignment()));

    //Vertical alignment
    action = new QAction(findIcon("tool-align-vert.png"), tr("Vertical alignment"), mToolBar);
    action->setCheckable(false);
    action->setShortcut(QKeySequence(tr("7", "Vertical alignment")));
    alignButton->addAction(action);
    connect(action, SIGNAL(triggered()), this, SLOT(onVerticalAlignment()));

    //Horizontal alignment
    action = new QAction(findIcon("tool-align-horz.png"), tr("Horizontal alignment"), mToolBar);
    action->setCheckable(false);
    action->setShortcut(QKeySequence(tr("8", "Horizontal alignment")));
    alignButton->addAction(action);
    connect(action, SIGNAL(triggered()), this, SLOT(onHorizontalAlignment()));

    // Energy-based layout
    action = new QAction(findIcon("tool-align-energy.png"), tr("Energy-based layout"), mToolBar);
    action->setCheckable(false);
    action->setShortcut(QKeySequence(tr("9", "Energy-based layout")));
    alignButton->addAction(action);
    connect(action, SIGNAL(triggered()), this, SLOT(onEnergyBasedLayout()));


    // selection group button
    QToolButton *selectButton = new QToolButton(mToolBar);
    selectButton->setIcon(findIcon("tool-select-group.png"));
    selectButton->setPopupMode(QToolButton::InstantPopup);
    mToolBar->addWidget(selectButton);

    // input/output selection
    action = new QAction(findIcon("tool-select-inout.png"), tr("Select input/output"), mToolBar);
    action->setCheckable(false);
    selectButton->addAction(action);
    connect(action, SIGNAL(triggered()), this, SLOT(onSelectInputOutput()));

    // sbgraph selection
    action = new QAction(findIcon("tool-select-subgraph.png"), tr("Select subgraph"), mToolBar);
    action->setCheckable(false);
    selectButton->addAction(action);
    connect(action, SIGNAL(triggered()), this, SLOT(onSelectSubgraph()));

    mToolBar->addSeparator();

    action = new QAction(findIcon("tool-export-image.png"), tr("Export image"), mToolBar);
    action->setCheckable(false);
    action->setShortcut(QKeySequence(tr("0", "Export image")));
    mToolBar->addAction(action);
    connect(action, SIGNAL(triggered()), this, SLOT(onExportImage()));

    action = new QAction(findIcon("tool-print.png"), tr("Print"), mToolBar);
    action->setCheckable(false);
    action->setShortcut(QKeySequence(tr("0", "Print")));
    mToolBar->addAction(action);
    connect(action, SIGNAL(triggered()), this, SLOT(onPrint()));

    //
    mToolBar->addSeparator();
    //Scale combobox
    QComboBox* b = new QComboBox(mToolBar);
    b->setFixedWidth(55);
    b->setEditable(true);
    b->setInsertPolicy(QComboBox::NoInsert);
    b->addItems(SCgWindow::mScales);
    b->setCurrentIndex(mScales.indexOf("100"));
    mZoomFactorLine = b->lineEdit();
    mZoomFactorLine->setInputMask("D90%");
    mToolBar->addWidget(b);
    connect(mZoomFactorLine, SIGNAL(textChanged(const QString&)), mView, SLOT(setScale(const QString&)));
    connect(mView, SIGNAL(scaleChanged(qreal)), this, SLOT(onViewScaleChanged(qreal)));
    //
    //Zoom in
    //action = new QAction(findIcon("tool-zoom-in.png"), tr("Zoom in"), mToolBar);
    action = new QAction("+",mToolBar);
    action->setToolTip(tr("Zoom in"));
    action->setCheckable(false);
    action->setShortcut(QKeySequence(tr("+", "Zoom in")));
    mToolBar->addAction(action);
    connect(action, SIGNAL(triggered()), this, SLOT(onZoomIn()));

    //slider scale
    mZoomSlider = new QSlider();
    mZoomSlider->setFixedWidth(40);
    mZoomSlider->setSizeIncrement(25,180/25);
    mZoomSlider->setFixedHeight(180);
    mZoomSlider->setToolTip(tr("Scale"));
    mZoomSlider->setMinimum(mZoomSliderMinValue);
    mZoomSlider->setValue(100);
    mZoomSlider->setMaximum(mZoomSliderMaxValue);
    mToolBar->addWidget(mZoomSlider);
    connect(mZoomSlider,SIGNAL(valueChanged(int)),this,SLOT(onmZoomSliderMove(int)));


    //Zoom out
  //  action = new QAction(findIcon("tool-zoom-out.png"), tr("Zoom out"), mToolBar);
    action = new QAction("-", mToolBar);
    action->setToolTip(tr("Zoom out"));
    action->setCheckable(false);
    action->setShortcut(QKeySequence(tr("-", "Zoom out")));
    mToolBar->addAction(action);
    connect(action, SIGNAL(triggered()), this, SLOT(onZoomOut()));

    mToolBar->setWindowTitle(tr("SCg Tools"));
    mToolBar->setObjectName("SCgMainToolBar");

    //! @bug toolbar state is not saved
    mToolBar->setMovable(false);
}
Example #23
0
VectorizerPopup::VectorizerPopup(QWidget *parent, Qt::WFlags flags)
#endif
    : Dialog(TApp::instance()->getMainWindow(), true, false, "Vectorizer")
    , m_sceneHandle(TApp::instance()->getCurrentScene()) {
  struct Locals {
    int m_bit;

    Locals() : m_bit() {}

    static void addParameterGroup(std::vector<ParamGroup> &paramGroups,
                                  int group, int startRow,
                                  int separatorRow = -1) {
      assert(group <= paramGroups.size());

      if (group == paramGroups.size())
        paramGroups.push_back(ParamGroup(startRow, separatorRow));
    }

    void addParameter(std::vector<ParamGroup> &paramGroups,
                      const QString &paramName) {
      paramGroups.back().m_params.push_back(Param(paramName, m_bit++));
    }

  } locals;

  // Su MAC i dialog modali non hanno bottoni di chiusura nella titleBar
  setModal(false);
  setWindowTitle(tr("Convert-to-Vector Settings"));

  setLabelWidth(125);

  setTopMargin(0);
  setTopSpacing(0);

  // Build vertical layout
  beginVLayout();

  QSplitter *splitter = new QSplitter(Qt::Vertical, this);
  splitter->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,
                                      QSizePolicy::MinimumExpanding));
  addWidget(splitter);

  QToolBar *leftToolBar = new QToolBar, *rightToolBar = new QToolBar;
  {
    QWidget *toolbarsContainer = new QWidget(this);
    toolbarsContainer->setFixedHeight(22);
    addWidget(toolbarsContainer);

    QHBoxLayout *toolbarsLayout = new QHBoxLayout(toolbarsContainer);
    toolbarsContainer->setLayout(toolbarsLayout);

    toolbarsLayout->setMargin(0);
    toolbarsLayout->setSpacing(0);

    QToolBar *spacingToolBar = new QToolBar(
        toolbarsContainer);  // The spacer object must be a toolbar.
    spacingToolBar->setFixedHeight(
        22);  // It's related to qss choices... I know it's stinky

    toolbarsLayout->addWidget(leftToolBar, 0, Qt::AlignLeft);
    toolbarsLayout->addWidget(spacingToolBar, 1);
    toolbarsLayout->addWidget(rightToolBar, 0, Qt::AlignRight);
  }

  endVLayout();

  // Build parameters area
  QScrollArea *paramsArea = new QScrollArea(splitter);
  paramsArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  paramsArea->setWidgetResizable(true);
  splitter->addWidget(paramsArea);
  splitter->setStretchFactor(0, 1);

  m_paramsWidget = new QFrame(paramsArea);
  paramsArea->setWidget(m_paramsWidget);

  m_paramsLayout = new QGridLayout;
  m_paramsWidget->setLayout(m_paramsLayout);

  int group = 0, row = 0;

  locals.addParameterGroup(::l_centerlineParamGroups, group, row);
  locals.addParameterGroup(::l_outlineParamGroups, group++, row);

  // Vectorization mode
  m_typeMenu = new QComboBox(this);
  m_typeMenu->setFixedSize(245, WidgetHeight);
  QStringList formats;
  formats << tr("Centerline") << tr("Outline");
  m_typeMenu->addItems(formats);
  m_typeMenu->setMinimumHeight(WidgetHeight);
  bool isOutline = m_sceneHandle->getScene()
                       ->getProperties()
                       ->getVectorizerParameters()
                       ->m_isOutline;
  m_typeMenu->setCurrentIndex(isOutline ? 1 : 0);
  connect(m_typeMenu, SIGNAL(currentIndexChanged(int)), this,
          SLOT(onTypeChange(int)));

  m_paramsLayout->addWidget(new QLabel(tr("Mode")), row, 0, Qt::AlignRight);
  m_paramsLayout->addWidget(m_typeMenu, row++, 1);

  locals.addParameter(l_centerlineParamGroups, tr("Mode"));
  locals.addParameter(l_outlineParamGroups, tr("Mode"));

  //-------------------- Parameters area - Centerline ------------------------

  locals.addParameterGroup(l_centerlineParamGroups, group++, row);

  // Threshold
  m_cThresholdLabel = new QLabel(tr("Threshold"));
  m_cThreshold      = new IntField(this);

  m_paramsLayout->addWidget(m_cThresholdLabel, row, 0, Qt::AlignRight);
  m_paramsLayout->addWidget(m_cThreshold, row++, 1);

  locals.addParameter(l_centerlineParamGroups, tr("Threshold"));

  // Accuracy
  m_cAccuracyLabel = new QLabel(tr("Accuracy"));
  m_cAccuracy      = new IntField(this);

  m_paramsLayout->addWidget(m_cAccuracyLabel, row, 0, Qt::AlignRight);
  m_paramsLayout->addWidget(m_cAccuracy, row++, 1);

  locals.addParameter(l_centerlineParamGroups, tr("Accuracy"));

  // Despeckling
  m_cDespecklingLabel = new QLabel(tr("Despeckling"));
  m_cDespeckling      = new IntField(this);

  m_paramsLayout->addWidget(m_cDespecklingLabel, row, 0, Qt::AlignRight);
  m_paramsLayout->addWidget(m_cDespeckling, row++, 1);

  locals.addParameter(l_centerlineParamGroups, tr("Despeckling"));

  // Max Thickness
  m_cMaxThicknessLabel = new QLabel(tr("Max Thickness"));
  m_paramsLayout->addWidget(m_cMaxThicknessLabel, row, 0, Qt::AlignRight);

  m_cMaxThickness = new IntField(this);
  m_cMaxThickness->enableSlider(false);
  m_paramsLayout->addWidget(m_cMaxThickness, row++, 1, Qt::AlignLeft);

  locals.addParameter(l_centerlineParamGroups, tr("Max Thickness"));

  // Thickness Calibration
  m_cThicknessRatioLabel = new QLabel(tr("Thickness Calibration"));
  m_paramsLayout->addWidget(m_cThicknessRatioLabel, row, 0, Qt::AlignRight);

  /*m_cThicknessRatio = new IntField(this);
paramsLayout->addWidget(m_cThicknessRatio, row++, 1);*/

  QHBoxLayout *cThicknessRatioLayout = new QHBoxLayout;

  cThicknessRatioLayout->addSpacing(20);

  m_cThicknessRatioFirstLabel = new QLabel(tr("Start:"));
  cThicknessRatioLayout->addWidget(m_cThicknessRatioFirstLabel);

  m_cThicknessRatioFirst = new MeasuredDoubleLineEdit(this);
  m_cThicknessRatioFirst->setMeasure("percentage");
  cThicknessRatioLayout->addWidget(m_cThicknessRatioFirst);

  m_cThicknessRatioLastLabel = new QLabel(tr("End:"));
  cThicknessRatioLayout->addWidget(m_cThicknessRatioLastLabel);

  m_cThicknessRatioLast = new MeasuredDoubleLineEdit(this);
  m_cThicknessRatioLast->setMeasure("percentage");
  cThicknessRatioLayout->addWidget(m_cThicknessRatioLast);

  cThicknessRatioLayout->addStretch(1);

  m_paramsLayout->addLayout(cThicknessRatioLayout, row++, 1);

  locals.addParameter(l_centerlineParamGroups, tr("Thickness Calibration"));

  // Checkboxes
  {
    static const QString name = tr("Preserve Painted Areas");
    locals.addParameter(l_centerlineParamGroups, name);

    m_cPaintFill = new CheckBox(name, this);
    m_cPaintFill->setFixedHeight(WidgetHeight);
    m_paramsLayout->addWidget(m_cPaintFill, row++, 1);
  }

  {
    static const QString name = tr("Add Border");
    locals.addParameter(l_centerlineParamGroups, name);

    m_cMakeFrame = new CheckBox(name, this);
    m_cMakeFrame->setFixedHeight(WidgetHeight);
    m_paramsLayout->addWidget(m_cMakeFrame, row++, 1);
  }

  locals.addParameterGroup(l_centerlineParamGroups, group++, row + 1, row);

  m_cNaaSourceSeparator = new Separator(tr("Full color non-AA images"));
  m_paramsLayout->addWidget(m_cNaaSourceSeparator, row++, 0, 1, 2);

  {
    static const QString name = tr("Enhanced ink recognition");
    locals.addParameter(l_centerlineParamGroups, name);

    m_cNaaSource = new CheckBox(name, this);
    m_cNaaSource->setFixedHeight(WidgetHeight);
    m_paramsLayout->addWidget(m_cNaaSource, row++, 1);
  }

  //-------------------- Parameters area - Outline ------------------------

  group = 1;
  locals.addParameterGroup(l_outlineParamGroups, group++, row);

  // Accuracy
  m_oAccuracyLabel = new QLabel(tr("Accuracy"));
  m_oAccuracy      = new IntField(this);

  m_paramsLayout->addWidget(m_oAccuracyLabel, row, 0, Qt::AlignRight);
  m_paramsLayout->addWidget(m_oAccuracy, row++, 1);

  locals.addParameter(l_outlineParamGroups, tr("Accuracy"));

  // Despeckling
  m_oDespecklingLabel = new QLabel(tr("Despeckling"));
  m_oDespeckling      = new IntField(this);

  m_paramsLayout->addWidget(m_oDespecklingLabel, row, 0, Qt::AlignRight);
  m_paramsLayout->addWidget(m_oDespeckling, row++, 1);

  locals.addParameter(l_outlineParamGroups, tr("Despeckling"));

  // Paint Fill
  {
    static const QString name = tr("Preserve Painted Areas");
    locals.addParameter(l_outlineParamGroups, name);

    m_oPaintFill = new CheckBox(name, this);
    m_oPaintFill->setFixedHeight(WidgetHeight);
    m_paramsLayout->addWidget(m_oPaintFill, row++, 1);
  }

  locals.addParameterGroup(l_outlineParamGroups, group++, row + 1, row);

  m_oCornersSeparator = new Separator(tr("Corners"));
  m_paramsLayout->addWidget(m_oCornersSeparator, row++, 0, 1, 2);

  // Adherence
  m_oAdherenceLabel = new QLabel(tr("Adherence"));
  m_oAdherence      = new IntField(this);

  m_paramsLayout->addWidget(m_oAdherenceLabel, row, 0, Qt::AlignRight);
  m_paramsLayout->addWidget(m_oAdherence, row++, 1);

  locals.addParameter(l_outlineParamGroups, tr("Adherence"));

  // Angle
  m_oAngleLabel = new QLabel(tr("Angle"));
  m_oAngle      = new IntField(this);

  m_paramsLayout->addWidget(m_oAngleLabel, row, 0, Qt::AlignRight);
  m_paramsLayout->addWidget(m_oAngle, row++, 1);

  locals.addParameter(l_outlineParamGroups, tr("Angle"));

  // Relative
  m_oRelativeLabel = new QLabel(tr("Curve Radius"));
  m_oRelative      = new IntField(this);

  m_paramsLayout->addWidget(m_oRelativeLabel, row, 0, Qt::AlignRight);
  m_paramsLayout->addWidget(m_oRelative, row++, 1);

  locals.addParameter(l_outlineParamGroups, tr("Curve Radius"));

  locals.addParameterGroup(l_outlineParamGroups, group++, row + 1, row);

  m_oFullColorSeparator = new Separator(tr("Raster Levels"));
  m_paramsLayout->addWidget(m_oFullColorSeparator, row++, 0, 1, 2);

  // Max Colors
  m_oMaxColorsLabel = new QLabel(tr("Max Colors"));
  m_oMaxColors      = new IntField(this);

  m_paramsLayout->addWidget(m_oMaxColorsLabel, row, 0, Qt::AlignRight);
  m_paramsLayout->addWidget(m_oMaxColors, row++, 1);

  locals.addParameter(l_outlineParamGroups, tr("Max Colors"));

  // Transparent Color
  m_oTransparentColorLabel = new QLabel(tr("Transparent Color"), this);
  m_oTransparentColor = new ColorField(this, true, TPixel32::Transparent, 48);
  m_paramsLayout->addWidget(m_oTransparentColorLabel, row, 0, Qt::AlignRight);
  m_paramsLayout->addWidget(m_oTransparentColor, row++, 1);

  locals.addParameter(l_outlineParamGroups, tr("Transparent Color"));

  locals.addParameterGroup(l_outlineParamGroups, group++, row + 1, row);

  m_oTlvSeparator = new Separator(tr("TLV Levels"));
  m_paramsLayout->addWidget(m_oTlvSeparator, row++, 0, 1, 2);

  // Tone Threshold
  m_oToneThresholdLabel = new QLabel(tr("Tone Threshold"));
  m_oToneThreshold      = new IntField(this);

  m_paramsLayout->addWidget(m_oToneThresholdLabel, row, 0, Qt::AlignRight);
  m_paramsLayout->addWidget(m_oToneThreshold, row++, 1);

  locals.addParameter(l_outlineParamGroups, tr("Tone Threshold"));

  m_paramsLayout->setRowStretch(row, 1);

  //-------------------- Swatch area ------------------------

  m_swatchArea = new VectorizerSwatchArea(this);
  splitter->addWidget(m_swatchArea);
  m_swatchArea->setEnabled(false);  // Initally not enabled

  connect(this, SIGNAL(valuesChanged()), m_swatchArea,
          SLOT(invalidateContents()));

  //---------------------- Toolbar --------------------------

  QAction *swatchAct = new QAction(createQIconOnOffPNG("preview", true),
                                   tr("Toggle Swatch Preview"), this);
  swatchAct->setCheckable(true);
  leftToolBar->addAction(swatchAct);

  QAction *centerlineAct =
      new QAction(createQIconOnOffPNG("opacitycheck", true),
                  tr("Toggle Centerlines Check"), this);
  centerlineAct->setCheckable(true);
  leftToolBar->addAction(centerlineAct);

  QToolButton *visibilityButton = new QToolButton(this);
  visibilityButton->setIcon(createQIconPNG("options"));
  visibilityButton->setPopupMode(QToolButton::InstantPopup);

  QMenu *visibilityMenu = new QMenu(visibilityButton);
  visibilityButton->setMenu(visibilityMenu);

  rightToolBar->addWidget(visibilityButton);
  rightToolBar->addSeparator();

  QAction *saveAct = new QAction(createQIconOnOffPNG("save", false),
                                 tr("Save Settings"), this);
  rightToolBar->addAction(saveAct);
  QAction *loadAct = new QAction(createQIconOnOffPNG("load", false),
                                 tr("Load Settings"), this);
  rightToolBar->addAction(loadAct);
  rightToolBar->addSeparator();

  QAction *resetAct = new QAction(createQIconOnOffPNG("resetsize", false),
                                  tr("Reset Settings"), this);
  rightToolBar->addAction(resetAct);

  connect(swatchAct, SIGNAL(triggered(bool)), m_swatchArea,
          SLOT(enablePreview(bool)));
  connect(centerlineAct, SIGNAL(triggered(bool)), m_swatchArea,
          SLOT(enableDrawCenterlines(bool)));
  connect(visibilityMenu, SIGNAL(aboutToShow()), this,
          SLOT(populateVisibilityMenu()));
  connect(saveAct, SIGNAL(triggered()), this, SLOT(saveParameters()));
  connect(loadAct, SIGNAL(triggered()), this, SLOT(loadParameters()));
  connect(resetAct, SIGNAL(triggered()), this, SLOT(resetParameters()));

  //------------------- Convert Button ----------------------

  // Convert Button
  m_okBtn = new QPushButton(QString(tr("Convert")), this);
  connect(m_okBtn, SIGNAL(clicked()), this, SLOT(onOk()));

  addButtonBarWidget(m_okBtn);

  // All detailed signals convey to the unique valuesChanged() signal. That
  // makes it easier
  // to disconnect update notifications whenever we loadConfiguration(..).
  connect(this, SIGNAL(valuesChanged()), this, SLOT(updateSceneSettings()));

  // Connect value changes to update the global
  // VectorizerPopUpSettingsContainer.
  // connect(m_typeMenu,SIGNAL(currentIndexChanged(const QString
  // &)),this,SLOT(updateSceneSettings()));
  connect(m_cThreshold, SIGNAL(valueChanged(bool)), this,
          SLOT(onValueEdited(bool)));
  connect(m_cAccuracy, SIGNAL(valueChanged(bool)), this,
          SLOT(onValueEdited(bool)));
  connect(m_cDespeckling, SIGNAL(valueChanged(bool)), this,
          SLOT(onValueEdited(bool)));
  connect(m_cMaxThickness, SIGNAL(valueChanged(bool)), this,
          SLOT(onValueEdited(bool)));
  // connect(m_cThicknessRatio,SIGNAL(valueChanged(bool)),this,SLOT(onValueEdited(bool)));
  connect(m_cThicknessRatioFirst, SIGNAL(valueChanged()), this,
          SLOT(onValueEdited()));
  connect(m_cThicknessRatioLast, SIGNAL(valueChanged()), this,
          SLOT(onValueEdited()));
  connect(m_cMakeFrame, SIGNAL(stateChanged(int)), this, SLOT(onValueEdited()));
  connect(m_cPaintFill, SIGNAL(stateChanged(int)), this, SLOT(onValueEdited()));
  connect(m_cNaaSource, SIGNAL(stateChanged(int)), this, SLOT(onValueEdited()));

  connect(m_oAccuracy, SIGNAL(valueChanged(bool)), this,
          SLOT(onValueEdited(bool)));
  connect(m_oDespeckling, SIGNAL(valueChanged(bool)), this,
          SLOT(onValueEdited(bool)));
  connect(m_oPaintFill, SIGNAL(stateChanged(int)), this, SLOT(onValueEdited()));
  connect(m_oAdherence, SIGNAL(valueChanged(bool)), this,
          SLOT(onValueEdited(bool)));
  connect(m_oAngle, SIGNAL(valueChanged(bool)), this,
          SLOT(onValueEdited(bool)));
  connect(m_oRelative, SIGNAL(valueChanged(bool)), this,
          SLOT(onValueEdited(bool)));
  connect(m_oDespeckling, SIGNAL(valueChanged(bool)), this,
          SLOT(onValueEdited(bool)));
  connect(m_oMaxColors, SIGNAL(valueChanged(bool)), this,
          SLOT(onValueEdited(bool)));
  connect(m_oTransparentColor, SIGNAL(colorChanged(const TPixel32 &, bool)),
          this, SLOT(onValueEdited(const TPixel32 &, bool)));
  connect(m_oToneThreshold, SIGNAL(valueChanged(bool)), this,
          SLOT(onValueEdited(bool)));

  refreshPopup();

  // Non e' corretto: manca la possibilita' di aggiornare la selezione del
  // livello corrente
  //  connect(TApp::instance()->getCurrentLevel(), SIGNAL(xshLevelChanged()),
  //                                         this, SLOT(updateValues()));
}
Example #24
0
MemoryWindow::MemoryWindow(running_machine* machine, QWidget* parent) :
	WindowQt(machine, nullptr)
{
	setWindowTitle("Debug: Memory View");

	if (parent != nullptr)
	{
		QPoint parentPos = parent->pos();
		setGeometry(parentPos.x()+100, parentPos.y()+100, 800, 400);
	}

	//
	// The main frame and its input and log widgets
	//
	QFrame* mainWindowFrame = new QFrame(this);

	// The top frame & groupbox that contains the input widgets
	QFrame* topSubFrame = new QFrame(mainWindowFrame);

	// The input edit
	m_inputEdit = new QLineEdit(topSubFrame);
	connect(m_inputEdit, &QLineEdit::returnPressed, this, &MemoryWindow::expressionSubmitted);

	// The memory space combo box
	m_memoryComboBox = new QComboBox(topSubFrame);
	m_memoryComboBox->setObjectName("memoryregion");
	m_memoryComboBox->setMinimumWidth(300);
	connect(m_memoryComboBox, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &MemoryWindow::memoryRegionChanged);

	// The main memory window
	m_memTable = new DebuggerMemView(DVT_MEMORY, m_machine, this);

	// Layout
	QHBoxLayout* subLayout = new QHBoxLayout(topSubFrame);
	subLayout->addWidget(m_inputEdit);
	subLayout->addWidget(m_memoryComboBox);
	subLayout->setSpacing(3);
	subLayout->setContentsMargins(2,2,2,2);

	QVBoxLayout* vLayout = new QVBoxLayout(mainWindowFrame);
	vLayout->setSpacing(3);
	vLayout->setContentsMargins(2,2,2,2);
	vLayout->addWidget(topSubFrame);
	vLayout->addWidget(m_memTable);

	setCentralWidget(mainWindowFrame);

	//
	// Menu bars
	//

	// Create a data format group
	QActionGroup* dataFormat = new QActionGroup(this);
	dataFormat->setObjectName("dataformat");
	QAction* formatActOne  = new QAction("1-byte chunks", this);
	QAction* formatActTwo  = new QAction("2-byte chunks", this);
	QAction* formatActFour = new QAction("4-byte chunks", this);
	QAction* formatActEight = new QAction("8-byte chunks", this);
	QAction* formatAct32bitFloat = new QAction("32 bit floating point", this);
	QAction* formatAct64bitFloat = new QAction("64 bit floating point", this);
	QAction* formatAct80bitFloat = new QAction("80 bit floating point", this);
	formatActOne->setObjectName("formatActOne");
	formatActTwo->setObjectName("formatActTwo");
	formatActFour->setObjectName("formatActFour");
	formatActEight->setObjectName("formatActEight");
	formatAct32bitFloat->setObjectName("formatAct32bitFloat");
	formatAct64bitFloat->setObjectName("formatAct64bitFloat");
	formatAct80bitFloat->setObjectName("formatAct80bitFloat");
	formatActOne->setCheckable(true);
	formatActTwo->setCheckable(true);
	formatActFour->setCheckable(true);
	formatActEight->setCheckable(true);
	formatAct32bitFloat->setCheckable(true);
	formatAct64bitFloat->setCheckable(true);
	formatAct80bitFloat->setCheckable(true);
	formatActOne->setActionGroup(dataFormat);
	formatActTwo->setActionGroup(dataFormat);
	formatActFour->setActionGroup(dataFormat);
	formatActEight->setActionGroup(dataFormat);
	formatAct32bitFloat->setActionGroup(dataFormat);
	formatAct64bitFloat->setActionGroup(dataFormat);
	formatAct80bitFloat->setActionGroup(dataFormat);
	formatActOne->setShortcut(QKeySequence("Ctrl+1"));
	formatActTwo->setShortcut(QKeySequence("Ctrl+2"));
	formatActFour->setShortcut(QKeySequence("Ctrl+4"));
	formatActEight->setShortcut(QKeySequence("Ctrl+8"));
	formatAct32bitFloat->setShortcut(QKeySequence("Ctrl+9"));
	formatActOne->setChecked(true);
	connect(dataFormat, &QActionGroup::triggered, this, &MemoryWindow::formatChanged);
	// Create a address display group
	QActionGroup* addressGroup = new QActionGroup(this);
	addressGroup->setObjectName("addressgroup");
	QAction* addressActLogical = new QAction("Logical Addresses", this);
	QAction* addressActPhysical = new QAction("Physical Addresses", this);
	addressActLogical->setCheckable(true);
	addressActPhysical->setCheckable(true);
	addressActLogical->setActionGroup(addressGroup);
	addressActPhysical->setActionGroup(addressGroup);
	addressActLogical->setShortcut(QKeySequence("Ctrl+G"));
	addressActPhysical->setShortcut(QKeySequence("Ctrl+Y"));
	addressActLogical->setChecked(true);
	connect(addressGroup, &QActionGroup::triggered, this, &MemoryWindow::addressChanged);

	// Create a reverse view radio
	QAction* reverseAct = new QAction("Reverse View", this);
	reverseAct->setObjectName("reverse");
	reverseAct->setCheckable(true);
	reverseAct->setShortcut(QKeySequence("Ctrl+R"));
	connect(reverseAct, &QAction::toggled, this, &MemoryWindow::reverseChanged);

	// Create increase and decrease bytes-per-line actions
	QAction* increaseBplAct = new QAction("Increase Bytes Per Line", this);
	QAction* decreaseBplAct = new QAction("Decrease Bytes Per Line", this);
	increaseBplAct->setShortcut(QKeySequence("Ctrl+P"));
	decreaseBplAct->setShortcut(QKeySequence("Ctrl+O"));
	connect(increaseBplAct, &QAction::triggered, this, &MemoryWindow::increaseBytesPerLine);
	connect(decreaseBplAct, &QAction::triggered, this, &MemoryWindow::decreaseBytesPerLine);

	// Assemble the options menu
	QMenu* optionsMenu = menuBar()->addMenu("&Options");
	optionsMenu->addActions(dataFormat->actions());
	optionsMenu->addSeparator();
	optionsMenu->addActions(addressGroup->actions());
	optionsMenu->addSeparator();
	optionsMenu->addAction(reverseAct);
	optionsMenu->addSeparator();
	optionsMenu->addAction(increaseBplAct);
	optionsMenu->addAction(decreaseBplAct);


	//
	// Initialize
	//
	populateComboBox();

	// Set to the current CPU's memory view
	setToCurrentCpu();
}
Example #25
0
void MPConfig::rbClicked(QTableWidgetItem* item)
{
    if (item == 0)
        return;
    QString id = item->tableWidget()->item(item->row(), DEVCOL_NO)->text();
    int no = atoi(id.toLatin1().constData()) - 1;
    if (no < 0 || no >= kMaxMidiPorts)
        return;

    int n;
    MidiPort* port = &midiPorts[no];
    MidiDevice* dev = port->device();
    int rwFlags = dev ? dev->rwFlags() : 0;
    int openFlags = dev ? dev->openFlags() : 0;
    QTableWidget* listView = item->tableWidget();
    QPoint ppt = listView->visualItemRect(item).bottomLeft();
    QPoint mousepos = QCursor::pos();

    int col = item->column();
    ppt += QPoint(0, listView->horizontalHeader()->height());

    ppt = listView->mapToGlobal(ppt);

    switch (col)
    {
        case DEVCOL_GUI:
            if (dev == 0)
                //break;
                return;
            // falkTX, we don't want this in the connections manager
            //if (port->hasGui())
            //{
            //	port->instrument()->showGui(!port->guiVisible());
            //	item->setIcon(port->guiVisible() ? QIcon(*dotIcon) : QIcon(*dothIcon));
            //}
            //break;
            return;

        case DEVCOL_CACHE_NRPN:
            if (!dev)
                return;
            dev->setCacheNRPN(!dev->cacheNRPN());
            item->setIcon(dev->cacheNRPN() ? QIcon(*dotIcon) : QIcon(*dothIcon));

            return;

        case DEVCOL_REC:
            if (dev == 0 || !(rwFlags & 2))
                return;
            openFlags ^= 0x2;
            dev->setOpenFlags(openFlags);
            midiSeq->msgSetMidiDevice(port, dev); // reopen device
            item->setIcon(openFlags & 2 ? QIcon(*dotIcon) : QIcon(*dothIcon));

            if (dev->deviceType() == MidiDevice::JACK_MIDI)
            {
                if (dev->openFlags() & 2)
                {
                    item->tableWidget()->item(item->row(), DEVCOL_INROUTES)->setText(tr("in"));
                }
                else
                {
                    item->tableWidget()->item(item->row(), DEVCOL_INROUTES)->setText("");
                }
            }

            return;

        case DEVCOL_PLAY:
            if (dev == 0 || !(rwFlags & 1))
                return;
            openFlags ^= 0x1;
            dev->setOpenFlags(openFlags);
            midiSeq->msgSetMidiDevice(port, dev); // reopen device
            item->setIcon(openFlags & 1 ? QIcon(*dotIcon) : QIcon(*dothIcon));

            if (dev->deviceType() == MidiDevice::JACK_MIDI)
            {
                if (dev->openFlags() & 1)
                {
                    item->tableWidget()->item(item->row(), DEVCOL_OUTROUTES)->setText(tr("out"));
                }
                else
                {
                    item->tableWidget()->item(item->row(), DEVCOL_OUTROUTES)->setText("");
                }
            }

            return;

        case DEVCOL_INROUTES:
        case DEVCOL_OUTROUTES:
        {
            if (!checkAudioDevice())
                return;

            if (audioDevice->deviceType() != AudioDevice::JACK_AUDIO) //Only if Jack is running.
                return;

            if (!dev)
                return;

            // Only Jack midi devices.
            if (dev->deviceType() != MidiDevice::JACK_MIDI)
                return;

            if (!(dev->openFlags() & ((col == DEVCOL_OUTROUTES) ? 1 : 2)))
                return;

            RouteList* rl = (col == DEVCOL_OUTROUTES) ? dev->outRoutes() : dev->inRoutes(); // p3.3.55
            QMenu* pup = 0;
            int gid = 0;
            std::list<QString> sl;
            pup = new QMenu(this);
            //A temporary Route to us for matching later
            QString currentRoute("");
            bool routeSelected = false;

_redisplay:
            pup->clear();
            gid = 0;

            // Jack input ports if device is writable, and jack output ports if device is readable.
            sl = (col == DEVCOL_OUTROUTES) ? audioDevice->inputPorts(true, _showAliases) : audioDevice->outputPorts(true, _showAliases);

            QAction* act;

            act = pup->addAction(tr("Show first aliases"));
            act->setData(gid);
            act->setCheckable(true);
            act->setChecked(_showAliases == 0);
            ++gid;

            act = pup->addAction(tr("Show second aliases"));
            act->setData(gid);
            act->setCheckable(true);
            act->setChecked(_showAliases == 1);
            ++gid;

            pup->addSeparator();
            for (std::list<QString>::iterator ip = sl.begin(); ip != sl.end(); ++ip)
            {
                act = pup->addAction(*ip);
                act->setData(gid);
                act->setCheckable(true);

                Route rt(*ip, (col == DEVCOL_OUTROUTES), -1, Route::JACK_ROUTE);
                for (iRoute ir = rl->begin(); ir != rl->end(); ++ir)
                {
                    if (*ir == rt)
                    {
                        currentRoute = (*ir).name();
                        act->setChecked(true);
                        routeSelected = true;
                        break;
                    }
                }
                ++gid;
            }

            act = pup->exec(ppt);
            if (act)
            {
                n = act->data().toInt();
                if (n == 0) // Show first aliases
                {
                    if (_showAliases == 0)
                        _showAliases = -1;
                    else
                        _showAliases = 0;
                    goto _redisplay; // Go back
                }
                else if (n == 1) // Show second aliases
                {
                    if (_showAliases == 1)
                        _showAliases = -1;
                    else
                        _showAliases = 1;
                    goto _redisplay; // Go back
                }

                QString s(act->text());

                if (col == DEVCOL_OUTROUTES) // Writable
                {
                    Route srcRoute(dev, -1);
                    Route dstRoute(s, true, -1, Route::JACK_ROUTE);
                    if(routeSelected && currentRoute == s)
                    {
                        //it will alread be handled by an unchecked operation
                        routeSelected = false;
                    }

                    iRoute iir = rl->begin();
                    for (; iir != rl->end(); ++iir)
                    {
                        if (*iir == dstRoute)
                            break;
                    }

                    if (iir != rl->end())
                    {
                        // disconnect
                        audio->msgRemoveRoute(srcRoute, dstRoute);
                    }
                    else
                    {
                        // connect
                        audio->msgAddRoute(srcRoute, dstRoute);
                    }
                    if(routeSelected)
                    {
                        iRoute selr = rl->begin();
                        for (; selr != rl->end(); ++selr)
                        {
                            //clean up the routing list as something was selected that was not the current so delete the old route
                            if((*selr).name() == currentRoute)
                            {
                                audio->msgRemoveRoute(srcRoute, (*selr));
                                break;
                            }
                        }
                    }

                }
                else
                {
                    Route srcRoute(s, false, -1, Route::JACK_ROUTE);
                    Route dstRoute(dev, -1);

                    iRoute iir = rl->begin();
                    for (; iir != rl->end(); ++iir)
                    {
                        if (*iir == srcRoute)
                            break;
                    }
                    if (iir != rl->end())
                        // disconnect
                        audio->msgRemoveRoute(srcRoute, dstRoute);
                    else
                        // connect
                        audio->msgAddRoute(srcRoute, dstRoute);
                }

                audio->msgUpdateSoloStates();
                song->update(SC_ROUTE);
            }

            delete pup;
        }
            return;

        case DEVCOL_DEF_IN_CHANS:
        case DEVCOL_DEF_OUT_CHANS:
        {
        }
            //break;
            return;

        case DEVCOL_NAME:
        {
            //printf("MPConfig::rbClicked DEVCOL_NAME\n");

            // Did we click in the text area?
            // NOTE: this needs the +15 pixels to make up for padding in the stylesheet.
            if ((mousepos.x() - (ppt.x() + 15)) > buttondownIcon->width())
            {
                // Start the renaming of the cell...
                QModelIndex current = item->tableWidget()->currentIndex();
                if (item->flags() & Qt::ItemIsEditable)
                    item->tableWidget()->edit(current.sibling(current.row(), DEVCOL_NAME));

                return;
            }
            else
            {// We clicked the 'down' button.
                QMenu* pup = new QMenu(this);

                QAction* act;

                act = pup->addAction(tr("Create") + QT_TRANSLATE_NOOP("@default", " Jack") + tr(" device"));
                act->setData(0);

                typedef std::map<std::string, int > asmap;
                typedef std::map<std::string, int >::iterator imap;

                asmap mapALSA;
                asmap mapJACK;

                int aix = 0x10000000;
                int jix = 0x20000000;
                for (iMidiDevice i = midiDevices.begin(); i != midiDevices.end(); ++i)
                {
                    if ((*i)->deviceType() == MidiDevice::ALSA_MIDI)
                    {
                        mapALSA.insert(std::pair<std::string, int> (std::string((*i)->name().toLatin1().constData()), aix));
                        ++aix;
                    }
                    else if ((*i)->deviceType() == MidiDevice::JACK_MIDI)
                    {
                        mapJACK.insert(std::pair<std::string, int> (std::string((*i)->name().toLatin1().constData()), jix));
                        ++jix;
                    }
                    else
                        printf("MPConfig::rbClicked unknown midi device: %s\n", (*i)->name().toLatin1().constData());
                }

                pup->addSeparator();
                pup->addAction(new MenuTitleItem(QT_TRANSLATE_NOOP("@default", "ALSA:"), pup));

                for (imap i = mapALSA.begin(); i != mapALSA.end(); ++i)
                {
                    int idx = i->second;
                    QString s(i->first.c_str());
                    MidiDevice* md = midiDevices.find(s, MidiDevice::ALSA_MIDI);
                    if (md)
                    {
                        if (md->deviceType() != MidiDevice::ALSA_MIDI)
                            continue;

                        act = pup->addAction(QT_TRANSLATE_NOOP("@default", md->name()));
                        act->setData(idx);
                        act->setCheckable(true);
                        act->setChecked(md == dev);
                    }
                }

                pup->addSeparator();
                pup->addAction(new MenuTitleItem(QT_TRANSLATE_NOOP("@default", "JACK:"), pup));

                for (imap i = mapJACK.begin(); i != mapJACK.end(); ++i)
                {
                    int idx = i->second;
                    QString s(i->first.c_str());
                    MidiDevice* md = midiDevices.find(s, MidiDevice::JACK_MIDI);
                    if (md)
                    {
                        if (md->deviceType() != MidiDevice::JACK_MIDI)
                            continue;

                        act = pup->addAction(QT_TRANSLATE_NOOP("@default", md->name()));
                        act->setData(idx);
                        act->setCheckable(true);
                        act->setChecked(md == dev);
                    }
                }

                act = pup->exec(ppt);
                if (!act)
                {
                    delete pup;
                    return;
                }

                n = act->data().toInt();
                //printf("MPConfig::rbClicked n:%d\n", n);

                MidiDevice* sdev = 0;
                if (n < 0x10000000)
                {
                    delete pup;
                    if (n <= 2)
                    {
                        sdev = MidiJackDevice::createJackMidiDevice();

                        if (sdev)
                        {
                            int of = 3;
                            switch (n)
                            {
                                case 0: of = 0; //3; Set the open flags of the midiDevice this should be off by default
                                    break;
                                case 1: of = 2;
                                    break;
                                case 2: of = 1;
                                    break;
                            }
                            sdev->setOpenFlags(of);
                        }
                    }
                }
                else
                {
                    int typ;
                    if (n < 0x20000000)
                        typ = MidiDevice::ALSA_MIDI;
                    else if (n < 0x30000000)
                        typ = MidiDevice::JACK_MIDI;
                    else
                        typ = MidiDevice::UNKNOWN_MIDI;

                    sdev = midiDevices.find(act->text(), typ);
                    delete pup;

                    // Is it the current device? Reset it to <none>.
                    // falkTX, handle synths properly here
                    if (sdev == dev)
                    {
                        sdev = 0;
                    }
                    else
                    {
                    }
                }

                midiSeq->msgSetMidiDevice(port, sdev);
                los->changeConfig(true); // save configuration file
                song->update();
            }
        }
            //break;
            return;

        case DEVCOL_INSTR:
        {
            if (instrPopup == 0)
                instrPopup = new QMenu(this);
            instrPopup->clear();
            for (iMidiInstrument i = midiInstruments.begin(); i != midiInstruments.end(); ++i)
            {
                instrPopup->addAction((*i)->iname());
            }

            QAction* act = instrPopup->exec(ppt, 0);
            if (!act)
                return;
            QString s = act->text();
            item->tableWidget()->item(item->row(), DEVCOL_INSTR)->setText(s);
            for (iMidiInstrument i = midiInstruments.begin(); i != midiInstruments.end(); ++i)
            {
                if ((*i)->iname() == s)
                {
                    port->setInstrument(*i);
                    break;
                }
            }
            song->update();
        }
            return;
    }
}
void WTrackTableViewHeader::setModel(QAbstractItemModel* model) {
    TrackModel* oldTrackModel = getTrackModel();

    if (dynamic_cast<QAbstractItemModel*>(oldTrackModel) == model) {
        // If the models are the same, do nothing but the redundant call.
        QHeaderView::setModel(model);
        return;
    }

    // Won't happen in practice since the WTrackTableView new's a new
    // WTrackTableViewHeader each time a new TrackModel is loaded.
    // if (oldTrackModel) {
    //     saveHeaderState();
    // }

    // First clear all the context menu actions for the old model.
    clearActions();

    // Now set the header view to show the new model
    QHeaderView::setModel(model);

    // Now build actions for the new TrackModel
    TrackModel* trackModel = dynamic_cast<TrackModel*>(model);

    if (!trackModel) {
        return;
    }

    // Restore saved header state to get sizes, column positioning, etc. back.
    restoreHeaderState();

    // Here we can override values to prevent restoring corrupt values from database
    setMovable(true);

    // Setting true in the next line causes Bug #925619 at least with Qt 4.6.1
    setCascadingSectionResizes(false);

    setMinimumSectionSize(WTTVH_MINIMUM_SECTION_SIZE);

    int columns = model->columnCount();
    for (int i = 0; i < columns; ++i) {
        if (trackModel->isColumnInternal(i)) {
            continue;
        }

        QString title = model->headerData(i, orientation()).toString();
        QAction* action = new QAction(title, &m_menu);
        action->setCheckable(true);

        /* If Mixxx starts the first time or the header states have been cleared
         * due to database schema evolution we gonna hide all columns that may
         * contain a potential large number of NULL values.  Here we uncheck
         * item in the context menu that are hidden by defualt (e.g., key
         * column)
         */
        if (!hasPersistedHeaderState() &&
            trackModel->isColumnHiddenByDefault(i)) {
            action->setChecked(false);
        } else {
            action->setChecked(!isSectionHidden(i));
        }

        // Map this action's signals via our QSignalMapper
        m_signalMapper.setMapping(action, i);
        m_columnActions.insert(i, action);
        connect(action, SIGNAL(triggered()),
                &m_signalMapper, SLOT(map()));
        m_menu.addAction(action);

        // force the section size to be a least WTTVH_MINIMUM_SECTION_SIZE
        if (sectionSize(i) <  WTTVH_MINIMUM_SECTION_SIZE) {
            // This might happen if  WTTVH_MINIMUM_SECTION_SIZ has changed or
            // the header state from database was corrupt
            resizeSection(i,WTTVH_MINIMUM_SECTION_SIZE);
        }
    }

    // Safety check against someone getting stuck with all columns hidden
    // (produces an empty library table). Just re-show them all.
    if (hiddenCount() == columns) {
        for (int i = 0; i < columns; ++i) {
            showSection(i);
        }
    }
}
Example #27
0
void TabBarWidget::contextMenuEvent(QContextMenuEvent *event)
{
	m_clickedTab = tabAt(event->pos());

	hidePreview();

	QMenu menu(this);
	menu.addAction(ActionsManager::getAction(ActionsManager::NewTabAction, this));
	menu.addAction(ActionsManager::getAction(ActionsManager::NewTabPrivateAction, this));

	if (m_clickedTab >= 0)
	{
		const bool isPinned = getTabProperty(m_clickedTab, QLatin1String("isPinned"), false).toBool();
		Action *cloneTabAction = new Action(ActionsManager::CloneTabAction, &menu);
		cloneTabAction->setEnabled(getTabProperty(m_clickedTab, QLatin1String("canClone"), false).toBool());

		Action *pinTabAction = new Action(ActionsManager::PinTabAction, &menu);
		pinTabAction->setOverrideText(isPinned ? QT_TRANSLATE_NOOP("actions", "Unpin Tab") : QT_TRANSLATE_NOOP("actions", "Pin Tab"));

		Action *detachTabAction = new Action(ActionsManager::DetachTabAction, &menu);
		detachTabAction->setEnabled(count() > 1);

		menu.addAction(cloneTabAction);
		menu.addAction(pinTabAction);
		menu.addSeparator();
		menu.addAction(detachTabAction);
		menu.addSeparator();

		if (isPinned)
		{
			Action *closeTabAction = new Action(ActionsManager::CloseTabAction, &menu);
			closeTabAction->setEnabled(false);

			menu.addAction(closeTabAction);
		}
		else
		{
			menu.addAction(ActionsManager::getAction(ActionsManager::CloseTabAction, this));
		}

		const int amount = (count() - getPinnedTabsAmount());
		Action *closeOtherTabsAction = new Action(ActionsManager::CloseOtherTabsAction, &menu);
		closeOtherTabsAction->setEnabled(amount > 0 && !(amount == 1 && !isPinned));

		menu.addAction(closeOtherTabsAction);
		menu.addAction(ActionsManager::getAction(ActionsManager::ClosePrivateTabsAction, this));

		connect(cloneTabAction, SIGNAL(triggered()), this, SLOT(cloneTab()));
		connect(pinTabAction, SIGNAL(triggered()), this, SLOT(pinTab()));
		connect(detachTabAction, SIGNAL(triggered()), this, SLOT(detachTab()));
		connect(closeOtherTabsAction, SIGNAL(triggered()), this, SLOT(closeOtherTabs()));
	}

	menu.addSeparator();

	QMenu *arrangeMenu = menu.addMenu(tr("Arrange"));
	arrangeMenu->addAction(ActionsManager::getAction(ActionsManager::RestoreTabAction, this));
	arrangeMenu->addSeparator();
	arrangeMenu->addAction(ActionsManager::getAction(ActionsManager::RestoreAllAction, this));
	arrangeMenu->addAction(ActionsManager::getAction(ActionsManager::MaximizeAllAction, this));
	arrangeMenu->addAction(ActionsManager::getAction(ActionsManager::MinimizeAllAction, this));
	arrangeMenu->addSeparator();
	arrangeMenu->addAction(ActionsManager::getAction(ActionsManager::CascadeAllAction, this));
	arrangeMenu->addAction(ActionsManager::getAction(ActionsManager::TileAllAction, this));

	QAction *cycleAction = new QAction(tr("Switch tabs using the mouse wheel"), this);
	cycleAction->setCheckable(true);
	cycleAction->setChecked(!SettingsManager::getValue(QLatin1String("TabBar/RequireModifierToSwitchTabOnScroll")).toBool());

	connect(cycleAction, SIGNAL(toggled(bool)), this, SLOT(setCycle(bool)));

	ToolBarWidget *toolBar = qobject_cast<ToolBarWidget*>(parentWidget());

	if (toolBar)
	{
		QList<QAction*> actions;
		actions.append(cycleAction);

		menu.addMenu(ToolBarWidget::createCustomizationMenu(ToolBarsManager::TabBar, actions, &menu));
	}
	else
	{
		QMenu *customizationMenu = menu.addMenu(tr("Customize"));
		customizationMenu->addAction(cycleAction);
		customizationMenu->addSeparator();
		customizationMenu->addAction(ActionsManager::getAction(ActionsManager::LockToolBarsAction, this));
	}

	menu.exec(event->globalPos());

	cycleAction->deleteLater();

	m_clickedTab = -1;

	if (underMouse())
	{
		m_previewTimer = startTimer(250);
	}
}
Example #28
0
int main(int argc, char * argv[])
{
    QList<QWidget*> widgets;
    QApplication app(argc, argv);

    QMainWindow mainWindow;
    mainWindow.setWindowTitle("Test");
    QMenu *fileMenu = mainWindow.menuBar()->addMenu("File");
    QMenu *editMenu = mainWindow.menuBar()->addMenu("Edit");
    QMenu *viewMenu = mainWindow.menuBar()->addMenu("View");
    QMenu *toolsMenu = mainWindow.menuBar()->addMenu("Tools");
    QMenu *optionsMenu = mainWindow.menuBar()->addMenu("Options");
    QMenu *helpMenu = mainWindow.menuBar()->addMenu("Help");

    qApp->processEvents();

    fileMenu->addAction("Open");
    QAction *close = fileMenu->addAction("Close");
    fileMenu->addSeparator();
    fileMenu->addAction("Exit");

    close->setEnabled(false);

    editMenu->addAction("Cut");
    editMenu->addAction("Pase");
    editMenu->addAction("Copy");
    editMenu->addSeparator();
    editMenu->addAction("Find");

    viewMenu->addAction("Hide");
    viewMenu->addAction("Show");
    viewMenu->addAction("Explore");
    QAction *visible = viewMenu->addAction("Visible");
    visible->setCheckable(true);
    visible->setChecked(true);

    toolsMenu->addMenu("Hammer");
    toolsMenu->addMenu("Caliper");
    toolsMenu->addMenu("Helm");

    optionsMenu->addMenu("Settings");
    optionsMenu->addMenu("Standard");
    optionsMenu->addMenu("Extended");

    QMenu *subMenu = helpMenu->addMenu("Help");
    subMenu->addAction("Index");
    subMenu->addSeparator();
    subMenu->addAction("Vodoo Help");
    helpMenu->addAction("Contens");
    helpMenu->addSeparator();
    helpMenu->addAction("About");

    QToolBar toolbar;
    mainWindow.addToolBar(&toolbar);
    toolbar.addAction(QIcon(qApp->style()->standardPixmap(QStyle::SP_FileIcon)), QString("textAction"));

    QTextEdit textEdit;
    mainWindow.setCentralWidget(&textEdit);

    mainWindow.showMaximized();

    app.exec();
}
Example #29
0
/******************************************************************************
* Initializes the menu.
******************************************************************************/
ViewportMenu::ViewportMenu(Viewport* vp) : QMenu(vp->widget()), _viewport(vp)
{
	QAction* action;

	// Build menu.
	action = addAction(tr("Preview Mode"), this, SLOT(onRenderPreviewMode(bool)));
	action->setCheckable(true);
	action->setChecked(_viewport->renderPreviewMode());
	action = addAction(tr("Show Grid"), this, SLOT(onShowGrid(bool)));
	action->setCheckable(true);
	action->setChecked(_viewport->isGridVisible());
#ifdef OVITO_DEBUG
	action = addAction(tr("Stereoscopic Mode (anaglyphs)"), this, SLOT(onStereoscopicMode(bool)));
	action->setCheckable(true);
	action->setChecked(_viewport->stereoscopicMode());
#endif
	addSeparator();

	_viewTypeMenu = addMenu(tr("View Type"));
	connect(_viewTypeMenu, &QMenu::aboutToShow, this, &ViewportMenu::onShowViewTypeMenu);

	QActionGroup* viewTypeGroup = new QActionGroup(this);
	action = viewTypeGroup->addAction(tr("Top"));
	action->setCheckable(true);
	action->setChecked(_viewport->viewType() == Viewport::VIEW_TOP);
	action->setData((int)Viewport::VIEW_TOP);
	action = viewTypeGroup->addAction(tr("Bottom"));
	action->setCheckable(true);
	action->setChecked(_viewport->viewType() == Viewport::VIEW_BOTTOM);
	action->setData((int)Viewport::VIEW_BOTTOM);
	action = viewTypeGroup->addAction(tr("Front"));
	action->setCheckable(true);
	action->setChecked(_viewport->viewType() == Viewport::VIEW_FRONT);
	action->setData((int)Viewport::VIEW_FRONT);
	action = viewTypeGroup->addAction(tr("Back"));
	action->setCheckable(true);
	action->setChecked(_viewport->viewType() == Viewport::VIEW_BACK);
	action->setData((int)Viewport::VIEW_BACK);
	action = viewTypeGroup->addAction(tr("Left"));
	action->setCheckable(true);
	action->setChecked(_viewport->viewType() == Viewport::VIEW_LEFT);
	action->setData((int)Viewport::VIEW_LEFT);
	action = viewTypeGroup->addAction(tr("Right"));
	action->setCheckable(true);
	action->setChecked(_viewport->viewType() == Viewport::VIEW_RIGHT);
	action->setData((int)Viewport::VIEW_RIGHT);
	action = viewTypeGroup->addAction(tr("Ortho"));
	action->setCheckable(true);
	action->setChecked(_viewport->viewType() == Viewport::VIEW_ORTHO);
	action->setData((int)Viewport::VIEW_ORTHO);
	action = viewTypeGroup->addAction(tr("Perspective"));
	action->setCheckable(true);
	action->setChecked(_viewport->viewType() == Viewport::VIEW_PERSPECTIVE);
	action->setData((int)Viewport::VIEW_PERSPECTIVE);
	_viewTypeMenu->addActions(viewTypeGroup->actions());
	connect(viewTypeGroup, &QActionGroup::triggered, this, &ViewportMenu::onViewType);

	addSeparator();
	addAction(tr("Adjust View..."), this, SLOT(onAdjustView()))->setEnabled(_viewport->viewType() != Viewport::VIEW_SCENENODE);

#if QT_VERSION < QT_VERSION_CHECK(5, 4, 0) && defined(Q_OS_MACX)
	connect(static_cast<QGuiApplication*>(QGuiApplication::instance()), &QGuiApplication::focusWindowChanged, this, &ViewportMenu::onWindowFocusChanged);
#endif
}
Example #30
0
void CtrlSortFilter::contextMenuEvent(QContextMenuEvent *i_event)
{
	QMenu menu(this);
	QAction *action;


	action = new QAction( "Sort1 Ascending", this);
	action->setCheckable( true);
	action->setChecked( *m_sortascending1);
	connect( action, SIGNAL( triggered() ), this, SLOT( actSortAscending1() ));
	menu.addAction( action);

	action = new QAction( "Sort1 Descending", this);
	action->setCheckable( true);
	action->setChecked( *m_sortascending1 == false);
	connect( action, SIGNAL( triggered() ), this, SLOT( actSortAscending1() ));
	menu.addAction( action);


	menu.addSeparator();


	action = new QAction( "Sort2 Ascending", this);
	action->setCheckable( true);
	action->setChecked( *m_sortascending2);
	connect( action, SIGNAL( triggered() ), this, SLOT( actSortAscending2() ));
	menu.addAction( action);

	action = new QAction( "Sort2 Descending", this);
	action->setCheckable( true);
	action->setChecked( *m_sortascending2 == false);
	connect( action, SIGNAL( triggered() ), this, SLOT( actSortAscending2() ));
	menu.addAction( action);


	menu.addSeparator();


	action = new QAction( "Filter Include", this);
	action->setCheckable( true);
	action->setChecked( *m_filterinclude);
	connect( action, SIGNAL( triggered() ), this, SLOT( actFilterInclude() ));
	menu.addAction( action);

	action = new QAction( "Filter Exclude", this);
	action->setCheckable( true);
	action->setChecked( *m_filterinclude == false);
	connect( action, SIGNAL( triggered() ), this, SLOT( actFilterInclude() ));
	menu.addAction( action);

	action = new QAction( "Filter Match", this);
	action->setCheckable( true);
	action->setChecked( *m_filtermatch);
	connect( action, SIGNAL( triggered() ), this, SLOT( actFilterMacth() ));
	menu.addAction( action);

	action = new QAction( "Filter Contain", this);
	action->setCheckable( true);
	action->setChecked( *m_filtermatch == false);
	connect( action, SIGNAL( triggered() ), this, SLOT( actFilterMacth() ));
	menu.addAction( action);

	menu.exec( i_event->globalPos());
}