本文整理汇总了C++中QAction::setCheckable方法的典型用法代码示例。如果您正苦于以下问题:C++ QAction::setCheckable方法的具体用法?C++ QAction::setCheckable怎么用?C++ QAction::setCheckable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QAction
的用法示例。
在下文中一共展示了QAction::setCheckable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createElementPropertyMenu
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
//.........这里部分代码省略.........
示例2: QMainWindow
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);
}
示例3: scanFinished
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;
}
}
示例4: createGUIAction
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;
}
示例5: QWidget
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" ) );
//.........这里部分代码省略.........
示例6: QGraphicsView
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);
//.........这里部分代码省略.........
示例7: createMenu
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));
}
}
示例8: aboutToShowMenu
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 );
}
//.........这里部分代码省略.........
示例9: mSettings
//.........这里部分代码省略.........
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);
}
示例10: pixmap
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);
//.........这里部分代码省略.........
示例11: QGLWidget
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);
}
示例12: fillToolBarsPopup
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()));
}
示例13: aboutToShowMenu
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() );
//.........这里部分代码省略.........
示例14: updateWindowMenu
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));
}
}
示例15: settings
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"));
}