本文整理汇总了C++中QAction::setEnabled方法的典型用法代码示例。如果您正苦于以下问题:C++ QAction::setEnabled方法的具体用法?C++ QAction::setEnabled怎么用?C++ QAction::setEnabled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QAction
的用法示例。
在下文中一共展示了QAction::setEnabled方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initMenu
void MainWindow::initMenu()
{
//file
_fileMenu = menuBar()->addMenu(QWidget::tr("文件(&F)"));
QAction* actionNewFile = new QAction(QIcon(":/images/new.png"), QWidget::tr("新建(&New)"), this);
actionNewFile->setShortcut(QWidget::tr("Ctrl+N"));
actionNewFile->setToolTip(QWidget::tr("新建场景文件"));
connect(actionNewFile, SIGNAL(triggered()), this, SLOT(slotNewFile()));
_fileMenu->addAction(actionNewFile);
QAction* actionOpenFile = new QAction(QIcon(":/images/open.png"), QWidget::tr("打开(&Open)"), this);
actionOpenFile->setShortcut(QWidget::tr("Ctrl+O"));
actionOpenFile->setToolTip(QWidget::tr("打开一个场景文件"));
connect(actionOpenFile, SIGNAL(triggered()), this, SLOT(slotOpenFile()));
_fileMenu->addAction(actionOpenFile);
QAction* actionSaveFile = new QAction(QIcon(":/images/save.png"), QWidget::tr("保存(&Save)"), this);
actionSaveFile->setShortcut(QWidget::tr("Ctrl+S"));
actionSaveFile->setToolTip(QWidget::tr("保存场景文件"));
actionSaveFile->setEnabled(false);
connect(actionSaveFile, SIGNAL(triggered()), this, SLOT(slotSaveFile()));
_fileMenu->addAction(actionSaveFile);
QAction* actionSaveAsFile = new QAction(QIcon(":/images/save.png"), QWidget::tr("另存(SaveAs)"), this);
actionSaveAsFile->setToolTip(QWidget::tr("另存场景文件"));
actionSaveAsFile->setEnabled(false);
connect(actionSaveAsFile, SIGNAL(triggered()), this, SLOT(slotSaveAsFile()));
_fileMenu->addAction(actionSaveAsFile);
QAction* actionExit = new QAction(QIcon(":/images/close.png"), QWidget::tr("退出(&X)"), this);
actionExit->setToolTip(QWidget::tr("退出场景编辑器"));
connect(actionExit, SIGNAL(triggered()), this, SLOT(slotExit()));
_fileMenu->addAction(actionExit);
//edit
_editMenu = menuBar()->addMenu(QWidget::tr("编辑(&E)"));
QAction* actionUndo = new QAction(QIcon(":/images/undo.png"), QWidget::tr("撤销"), this);
actionUndo->setShortcut(QWidget::tr("Ctrl+Z"));
actionUndo->setToolTip(QWidget::tr("撤销Ctrl+Z"));
actionUndo->setEnabled(false);
connect(actionUndo, SIGNAL(triggered()), this, SLOT(slotUndo()));
_editMenu->addAction(actionUndo);
QAction* actionRedo = new QAction(QIcon(":/images/redo.png"), QWidget::tr("重做"), this);
actionRedo->setShortcut(QWidget::tr("Ctrl+Y"));
actionRedo->setToolTip(QWidget::tr("重做Ctrl+Y"));
actionRedo->setEnabled(false);
connect(actionRedo, SIGNAL(triggered()), this, SLOT(slotRedo()));
_editMenu->addAction(actionRedo);
QAction* actionCopy = new QAction(QIcon(":/images/copy.png"), QWidget::tr("复制"), this);
actionCopy->setShortcut(QWidget::tr("Ctrl+C"));
actionCopy->setToolTip(QWidget::tr("复制Ctrl+C"));
actionCopy->setEnabled(false);
connect(actionCopy, SIGNAL(triggered()), this, SLOT(slotCopy()));
_editMenu->addAction(actionCopy);
QAction* actionRotateFast = new QAction(QIcon(":/images/rotate.png"), QWidget::tr("快速旋转"), this);
actionRotateFast->setShortcut(QKeySequence(Qt::Key_F3));
actionRotateFast->setToolTip(QWidget::tr("快速旋转F3"));
actionRotateFast->setEnabled(false);
connect(actionRotateFast, SIGNAL(triggered()), this, SLOT(slotRotateFast()));
_editMenu->addAction(actionRotateFast);
QAction* actionAlign = new QAction(QIcon(":/images/align.png"), QWidget::tr("对齐"), this);
actionAlign->setShortcut(QWidget::tr("Ctrl+L"));
actionAlign->setToolTip(QWidget::tr("对齐Ctrl+L"));
actionAlign->setEnabled(false);
connect(actionAlign, SIGNAL(triggered()), this, SLOT(slotAlign()));
_editMenu->addAction(actionAlign);
QAction* actionDelete = new QAction(QIcon(":/images/delete.png"), QWidget::tr("删除"), this);
actionDelete->setShortcut(QKeySequence(QKeySequence::Delete));
actionDelete->setToolTip(QWidget::tr("删除Delete"));
actionDelete->setEnabled(false);
connect(actionDelete, SIGNAL(triggered()), this, SLOT(slotDelete()));
_editMenu->addAction(actionDelete);
//windowsMenu
_windowsMenu = menuBar()->addMenu(QWidget::tr("窗口(&W)"));
QAction* actionObjectsTreeDockWidget = new QAction(QIcon(":/images/default.png"), QWidget::tr("场景树(&ObjTree)"), this);
actionObjectsTreeDockWidget->setShortcut(QKeySequence("h"));
actionObjectsTreeDockWidget->setToolTip(QWidget::tr("打开或隐藏对象树窗口"));
actionObjectsTreeDockWidget->setEnabled(false);
connect(actionObjectsTreeDockWidget, SIGNAL(triggered()), this, SLOT(slotObjectTreeWidgetActive()));
_windowsMenu->addAction(actionObjectsTreeDockWidget);
QAction* actionPropertyDockWidget = new QAction(QIcon(":/images/default.png"), QWidget::tr("属性窗"), this);
actionPropertyDockWidget->setToolTip(QWidget::tr("打开或隐藏属性窗口"));
actionPropertyDockWidget->setEnabled(false);
connect(actionPropertyDockWidget, SIGNAL(triggered()), this, SLOT(slotPropertyDockWidgetActive()));
_windowsMenu->addAction(actionPropertyDockWidget);
QAction* actionBuiltinResourcesDockWidget = new QAction(QIcon(":/images/default.png"), QWidget::tr("内置资源列表"), this);
actionBuiltinResourcesDockWidget->setToolTip(QWidget::tr("打开或隐藏内置资源列表窗口"));
actionBuiltinResourcesDockWidget->setEnabled(false);
connect(actionBuiltinResourcesDockWidget, SIGNAL(triggered()), this, SLOT(slotBuiltinResourcesDockWidgetActive()));
_windowsMenu->addAction(actionBuiltinResourcesDockWidget);
QAction* actionvdsResourcesDockWidget = new QAction(QIcon(":/images/default.png"), QWidget::tr("资源列表"), this);
actionvdsResourcesDockWidget->setToolTip(QWidget::tr("打开或隐藏资源列表窗口"));
actionvdsResourcesDockWidget->setEnabled(false);
connect(actionvdsResourcesDockWidget, SIGNAL(triggered()), this, SLOT(slotvdsResourcesDockWidgetActive()));
_windowsMenu->addAction(actionvdsResourcesDockWidget);
QAction* actionCSharpAssemblyDockWidget = new QAction(QIcon(":/images/default.png"), QWidget::tr("脚本列表"), this);
actionCSharpAssemblyDockWidget->setToolTip(QWidget::tr("打开或隐藏脚本列表窗口"));
actionCSharpAssemblyDockWidget->setEnabled(false);
connect(actionCSharpAssemblyDockWidget, SIGNAL(triggered()), this, SLOT(slotCSharpAssemblyDockWidgetActive()));
_windowsMenu->addAction(actionCSharpAssemblyDockWidget);
//tool
_toolMenu = menuBar()->addMenu(QWidget::tr("工具(&T)"));
QAction* actionAnimationMerge = new QAction(QIcon(":/images/default.png"), QWidget::tr("动画合并(&AnimationMerge)"), this);
actionAnimationMerge->setToolTip(QWidget::tr("完成骨骼动画合并"));
actionAnimationMerge->setEnabled(false);
//.........这里部分代码省略.........
示例2: mwIcon
ApplicationWindow::ApplicationWindow()
: QMainWindow( 0 )
{
clipboard = QApplication::clipboard();
QDateTime dt = QDateTime::currentDateTime();
appPath=qApp->applicationDirPath();
logfilePath=appPath + "\\log_" + qgetenv("USERNAME") + "_" + dt.toString("ddMMyy") + ".txt";
setWindowTitle("Info");
//installPath=QDir(QDir::currentPath() + "\\scripts");
installPath=QDir(appPath + "\\scripts");
if (!installPath.exists())
{
QMessageBox::critical(this, "Info", "Could not open install path " + installPath.absolutePath() + ".");
exit (1);
}
//Tray Icon
iconTray = new QSystemTrayIcon;
QIcon mwIcon(":/info.png");
iconTray->setIcon(mwIcon);
iconTray->setVisible(true);
iconTray->show();
connect(iconTray, SIGNAL(activated ( QSystemTrayIcon::ActivationReason )), this, SLOT(systemTrayActivated(QSystemTrayIcon::ActivationReason)));
//main widget
window = new QWidget(this);
setCentralWidget(window);
resize(540,480);
statusBar()->showMessage( "Welcome" );
QMenu* fileMenu = menuBar()->addMenu(tr("&File"));
QAction* updateAction = new QAction(tr("&Update"), window);
updateAction->setShortcut(Qt::CTRL + Qt::Key_U);
// connect(updateAction, SIGNAL(triggered(bool)), this, SLOT(writeServiceSlot()));
fileMenu->addAction(updateAction);
updateAction->setEnabled(false);
QAction* findAction = new QAction(tr("&Find"), window);
findAction->setShortcut(Qt::CTRL + Qt::Key_F);
// connect(findAction, SIGNAL(triggered(bool)), this, SLOT(findItem()));
fileMenu->addAction(findAction);
findAction->setEnabled(false);
QAction* refreshAction = new QAction(tr("&Refresh"), window);
refreshAction->setShortcut(Qt::CTRL + Qt::Key_R);
connect(refreshAction, SIGNAL(triggered(bool)), this, SLOT(refreshGUI()));
fileMenu->addAction(refreshAction);
fileMenu->addSeparator ();
QAction* exitAction = new QAction(tr("&Exit"), window);
exitAction->setShortcut(Qt::CTRL + Qt::Key_X);
connect(exitAction, SIGNAL(triggered()), this, SLOT(realExit()));
fileMenu->addAction(exitAction);
QMenu* editMenu = menuBar()->addMenu(tr("&Edit"));
QAction* clipAction = new QAction(tr("&Copy to Clipboard"), window);
clipAction->setShortcut(Qt::CTRL + Qt::Key_C);
connect(clipAction, SIGNAL(triggered()), this, SLOT(copyToClipboard()));
editMenu->addAction(clipAction);
QAction* logfileAction = new QAction(tr("&Open Logfile"), window);
logfileAction->setShortcut(Qt::CTRL + Qt::Key_O);
connect(logfileAction, SIGNAL(triggered()), this, SLOT(openLogfile()));
editMenu->addAction(logfileAction);
QMenu* helpMenu = menuBar()->addMenu(tr("&?"));
QAction* aboutAction = new QAction(tr("&about"), window);
connect(aboutAction, SIGNAL(triggered()), this, SLOT(about()));
helpMenu->addAction(aboutAction);
// End of Menu
/*
|----------------|
| Maingrid |
| |----------| |
| |Topgrid | |
| | | |
| |----------| |
| |
| |-------------||
| |Body |-----| ||
| | |Info | ||
| | | | ||
| | |-----| ||
| |-------------||
|----------------|
*/
//.........这里部分代码省略.........
示例3: contextMenu
void ItemPhysEnv::contextMenu(QGraphicsSceneMouseEvent *mouseEvent)
{
m_scene->m_contextMenuIsOpened = true; //bug protector
//Remove selection from non-bgo items
if(!this->isSelected())
{
m_scene->clearSelection();
this->setSelected(true);
}
this->setSelected(true);
QMenu ItemMenu;
/*************Layers*******************/
QMenu *LayerName = ItemMenu.addMenu(tr("Layer: ") + QString("[%1]").arg(m_data.layer).replace("&", "&&&"));
QAction *setLayer;
QList<QAction *> layerItems;
QAction *newLayer = LayerName->addAction(tr("Add to new layer..."));
LayerName->addSeparator();
for(LevelLayer &layer : m_scene->m_data->layers)
{
//Skip system layers
if((layer.name == "Destroyed Blocks") || (layer.name == "Spawned NPCs")) continue;
setLayer = LayerName->addAction(layer.name.replace("&", "&&&") + ((layer.hidden) ? "" + tr("[hidden]") : ""));
setLayer->setData(layer.name);
setLayer->setCheckable(true);
setLayer->setEnabled(true);
setLayer->setChecked(layer.name == m_data.layer);
layerItems.push_back(setLayer);
}
ItemMenu.addSeparator();
/*************Layers*end***************/
QMenu *WaterType = ItemMenu.addMenu(tr("Environment type"));
WaterType->deleteLater();
#define CONTEXT_MENU_ITEM_CHK(name, enable, visible, label, checked_condition)\
name = WaterType->addAction(label);\
name->setCheckable(true);\
name->setEnabled(enable);\
name->setVisible(visible);\
name->setChecked(checked_condition); typeID++;
QAction *envTypes[16];
int typeID = 0;
bool enable_new_types = !m_scene->m_data->meta.smbx64strict
&& (m_scene->m_configs->editor.supported_features.level_phys_ez_new_types == EditorSetup::FeaturesSupport::F_ENABLED);
bool show_new_types = (m_scene->m_configs->editor.supported_features.level_phys_ez_new_types != EditorSetup::FeaturesSupport::F_HIDDEN);
CONTEXT_MENU_ITEM_CHK(envTypes[typeID], true, true, tr("Water"), m_data.env_type == LevelPhysEnv::ENV_WATER);
CONTEXT_MENU_ITEM_CHK(envTypes[typeID], true, true, tr("Quicksand"), m_data.env_type == LevelPhysEnv::ENV_QUICKSAND);
CONTEXT_MENU_ITEM_CHK(envTypes[typeID], enable_new_types, show_new_types, tr("Custom liquid"), m_data.env_type == LevelPhysEnv::ENV_CUSTOM_LIQUID);
CONTEXT_MENU_ITEM_CHK(envTypes[typeID], enable_new_types, show_new_types, tr("Gravity Field"), m_data.env_type == LevelPhysEnv::ENV_GRAVITATIONAL_FIELD);
CONTEXT_MENU_ITEM_CHK(envTypes[typeID], enable_new_types, show_new_types, tr("Touch Event (Once)"), m_data.env_type == LevelPhysEnv::ENV_TOUCH_EVENT_ONCE_PLAYER);
CONTEXT_MENU_ITEM_CHK(envTypes[typeID], enable_new_types, show_new_types, tr("Touch Event (Every frame)"), m_data.env_type == LevelPhysEnv::ENV_TOUCH_EVENT_PLAYER);
CONTEXT_MENU_ITEM_CHK(envTypes[typeID], enable_new_types, show_new_types, tr("NPC/Player Touch Event (Once)"), m_data.env_type == LevelPhysEnv::ENV_TOUCH_EVENT_ONCE_NPC);
CONTEXT_MENU_ITEM_CHK(envTypes[typeID], enable_new_types, show_new_types, tr("NPC/Player Touch Event (Every frame)"), m_data.env_type == LevelPhysEnv::ENV_TOUCH_EVENT_NPC);
CONTEXT_MENU_ITEM_CHK(envTypes[typeID], enable_new_types, show_new_types, tr("Mouse click Event"), m_data.env_type == LevelPhysEnv::ENV_CLICK_EVENT);
CONTEXT_MENU_ITEM_CHK(envTypes[typeID], enable_new_types, show_new_types, tr("Collision script"), m_data.env_type == LevelPhysEnv::ENV_COLLISION_SCRIPT);
CONTEXT_MENU_ITEM_CHK(envTypes[typeID], enable_new_types, show_new_types, tr("Mouse click Script"), m_data.env_type == LevelPhysEnv::ENV_CLICK_SCRIPT);
CONTEXT_MENU_ITEM_CHK(envTypes[typeID], enable_new_types, show_new_types, tr("Collision Event"), m_data.env_type == LevelPhysEnv::ENV_COLLISION_EVENT);
CONTEXT_MENU_ITEM_CHK(envTypes[typeID], enable_new_types, show_new_types, tr("Air chamber"), m_data.env_type == LevelPhysEnv::ENV_AIR);
CONTEXT_MENU_ITEM_CHK(envTypes[typeID], enable_new_types, show_new_types, tr("NPC Touch Event (Once)"), m_data.env_type == LevelPhysEnv::ENV_TOUCH_EVENT_ONCE_NPC1);
CONTEXT_MENU_ITEM_CHK(envTypes[typeID], enable_new_types, show_new_types, tr("NPC Touch Event (Every frame)"), m_data.env_type == LevelPhysEnv::ENV_TOUCH_EVENT_NPC1);
CONTEXT_MENU_ITEM_CHK(envTypes[typeID], enable_new_types, show_new_types, tr("NPC Hurting Field"), m_data.env_type == LevelPhysEnv::ENV_NPC_HURTING_FIELD);
#undef CONTEXT_MENU_ITEM_CHK
ItemMenu.addSeparator();
QMenu *copyPreferences = ItemMenu.addMenu(tr("Copy preferences"));
QAction *copyPosXYWH = copyPreferences->addAction(tr("Position: X, Y, Width, Height"));
QAction *copyPosLTRB = copyPreferences->addAction(tr("Position: Left, Top, Right, Bottom"));
ItemMenu.addSeparator();
QAction *resize = ItemMenu.addAction(tr("Resize"));
resize->deleteLater();
ItemMenu.addSeparator();
QAction *copyWater = ItemMenu.addAction(tr("Copy"));
QAction *cutWater = ItemMenu.addAction(tr("Cut"));
ItemMenu.addSeparator();
QAction *remove = ItemMenu.addAction(tr("Remove"));
/*****************Waiting for answer************************/
QAction *selected = ItemMenu.exec(mouseEvent->screenPos());
/***********************************************************/
if(!selected)
return;
if(selected == cutWater)
m_scene->m_mw->on_actionCut_triggered();
else if(selected == copyWater)
m_scene->m_mw->on_actionCopy_triggered();
else if(selected == copyPosXYWH)
//.........这里部分代码省略.........
示例4: enableLogin
void lemon::enableLogin()
{
QAction *action = actionCollection()->action("login");
action->setEnabled(true);
}
示例5: initGUI
// Setup the GUI
void Mainwindow::initGUI()
{
QAction *action;
// Start a new game
action = KStandardGameAction::gameNew(this, SLOT(menuNewLSkatGame()), actionCollection());
if (global_demo_mode) action->setEnabled(false);
// Clear all time statistics
action = KStandardGameAction::clearStatistics(this, SLOT(menuClearStatistics()), actionCollection());
action->setWhatsThis(i18n("Clears the all time statistics which is kept in all sessions."));
if (global_demo_mode) action->setEnabled(false);
// End a game
action = KStandardGameAction::end(this, SLOT(menuEndGame()), actionCollection());
action->setWhatsThis(i18n("Ends a currently played game. No winner will be declared."));
action->setEnabled(false);
// Quit the program
action = KStandardGameAction::quit(this, SLOT(close()), actionCollection());
action->setWhatsThis(i18n("Quits the program."));
// Determine start player
KSelectAction *startPlayerAct = new KSelectAction(i18n("Starting Player"), this);
actionCollection()->addAction(QLatin1String("startplayer"), startPlayerAct);
connect(startPlayerAct, SIGNAL(triggered(int)), this, SLOT(menuStartplayer()));
startPlayerAct->setToolTip(i18n("Changing starting player..."));
startPlayerAct->setWhatsThis(i18n("Chooses which player begins the next game."));
QStringList list;
list.clear();
list.append(i18n("Player &1"));
list.append(i18n("Player &2"));
startPlayerAct->setItems(list);
if (global_demo_mode) startPlayerAct->setEnabled(false);
// Determine who player player 1
KSelectAction *player1Act = new KSelectAction(i18n("Player &1 Played By"), this);
actionCollection()->addAction(QLatin1String("player1"), player1Act);
connect(player1Act, SIGNAL(triggered(int)), this, SLOT(menuPlayer1By()));
player1Act->setToolTip(i18n("Changing who plays player 1..."));
player1Act->setWhatsThis(i18n("Changing who plays player 1."));
list.clear();
list.append(i18n("&Mouse"));
list.append(i18n("&Computer"));
player1Act->setItems(list);
if (global_demo_mode) player1Act->setEnabled(false);
// Determine who player player 2
KSelectAction *player2Act = new KSelectAction(i18n("Player &2 Played By"), this);
actionCollection()->addAction(QLatin1String("player2"), player2Act);
connect(player2Act, SIGNAL(triggered(int)), this, SLOT(menuPlayer2By()));
player2Act->setToolTip(i18n("Changing who plays player 2..."));
player2Act->setWhatsThis(i18n("Changing who plays player 2."));
player2Act->setItems(list);
if (global_demo_mode) player2Act->setEnabled(false);
// Add all theme files to the menu
QStringList themes(mThemeFiles.keys());
themes.sort();
KSelectAction *themeAct = new KSelectAction(i18n("&Theme"), this);
actionCollection()->addAction(QLatin1String("theme"), themeAct);
themeAct->setItems(themes);
connect(themeAct, SIGNAL(triggered(int)), SLOT(changeTheme(int)));
if (global_debug > 0) kDebug() << "Setting current theme item to" << mThemeIndexNo;
themeAct->setCurrentItem(mThemeIndexNo);
themeAct->setToolTip(i18n("Changing theme..."));
themeAct->setWhatsThis(i18n("Changing theme."));
// Choose card deck
KAction *action1 = actionCollection()->addAction(QLatin1String("select_carddeck"));
action1->setText(i18n("Select &Card Deck..."));
action1->setShortcuts(KShortcut(Qt::Key_F10));
connect(action1, SIGNAL(triggered(bool)), this, SLOT(menuCardDeck()));
action1->setToolTip(i18n("Configure card decks..."));
action1->setWhatsThis(i18n("Choose how the cards should look."));
// Change player names
action = actionCollection()->addAction(QLatin1String("change_names"));
action->setText(i18n("&Change Player Names..."));
connect(action, SIGNAL(triggered(bool)), this, SLOT(menuPlayerNames()));
if (global_demo_mode) action->setEnabled(false);
}
示例6: probePickedCallback
void ManualAlignment::probePickedCallback(void * ud, SoEventCallback * n)
{
Gui::View3DInventorViewer* view = reinterpret_cast<Gui::View3DInventorViewer*>(n->getUserData());
const SoEvent* ev = n->getEvent();
if (ev->getTypeId() == SoMouseButtonEvent::getClassTypeId()) {
// set as handled
n->getAction()->setHandled();
n->setHandled();
const SoMouseButtonEvent * mbe = static_cast<const SoMouseButtonEvent *>(ev);
if (mbe->getButton() == SoMouseButtonEvent::BUTTON1 && mbe->getState() == SoButtonEvent::DOWN) {
// if we are in 'align' mode then handle the click event
ManualAlignment* self = ManualAlignment::instance();
// Get the closest point to the camera of the whole scene.
// This point doesn't need to be part of this view provider.
Gui::WaitCursor wc;
const SoPickedPoint * point = view->getPickedPoint(n);
if (point) {
Gui::ViewProvider* vp = static_cast<Gui::ViewProvider*>(view->getViewProviderByPath(point->getPath()));
if (vp && vp->getTypeId().isDerivedFrom(Gui::ViewProviderDocumentObject::getClassTypeId())) {
Gui::ViewProviderDocumentObject* that = static_cast<Gui::ViewProviderDocumentObject*>(vp);
if (self->applyPickedProbe(that, point)) {
const SbVec3f& vec = point->getPoint();
Gui::getMainWindow()->showMessage(
tr("Point picked at (%1,%2,%3)")
.arg(vec[0]).arg(vec[1]).arg(vec[2]));
}
else {
Gui::getMainWindow()->showMessage(
tr("No point was found on model"));
}
}
}
else {
Gui::getMainWindow()->showMessage(
tr("No point was picked"));
}
}
else if (mbe->getButton() == SoMouseButtonEvent::BUTTON2 && mbe->getState() == SoButtonEvent::UP) {
ManualAlignment* self = ManualAlignment::instance();
if (self->myAlignModel.isEmpty() || self->myFixedGroup.isEmpty())
return;
self->showInstructions();
int nPoints;
if (view == self->myViewer->getViewer(0))
nPoints = self->myAlignModel.activeGroup().countPoints();
else
nPoints = self->myFixedGroup.countPoints();
QMenu menu;
QAction* fi = menu.addAction(QLatin1String("&Align"));
QAction* rem = menu.addAction(QLatin1String("&Remove last point"));
//QAction* cl = menu.addAction("C&lear");
QAction* ca = menu.addAction(QLatin1String("&Cancel"));
fi->setEnabled(self->canAlign());
rem->setEnabled(nPoints > 0);
menu.addSeparator();
QAction* sync = menu.addAction(QLatin1String("&Synchronize views"));
sync->setCheckable(true);
if (self->d->sensorCam1->getAttachedNode())
sync->setChecked(true);
QAction* id = menu.exec(QCursor::pos());
if (id == fi) {
// call align->align();
QTimer::singleShot(300, self, SLOT(onAlign()));
}
else if ((id == rem) && (view == self->myViewer->getViewer(0))) {
QTimer::singleShot(300, self, SLOT(onRemoveLastPointMoveable()));
}
else if ((id == rem) && (view == self->myViewer->getViewer(1))) {
QTimer::singleShot(300, self, SLOT(onRemoveLastPointFixed()));
}
//else if (id == cl) {
// // call align->clear();
// QTimer::singleShot(300, self, SLOT(onClear()));
//}
else if (id == ca) {
// call align->cancel();
QTimer::singleShot(300, self, SLOT(onCancel()));
}
else if (id == sync) {
// setup sensor connection
if (sync->isChecked()) {
SoCamera* cam1 = self->myViewer->getViewer(0)->getSoRenderManager()->getCamera();
SoCamera* cam2 = self->myViewer->getViewer(1)->getSoRenderManager()->getCamera();
if (cam1 && cam2) {
self->d->sensorCam1->attach(cam1);
self->d->rot_cam1 = cam1->orientation.getValue();
self->d->pos_cam1 = cam1->position.getValue();
self->d->sensorCam2->attach(cam2);
self->d->rot_cam2 = cam2->orientation.getValue();
self->d->pos_cam2 = cam2->position.getValue();
}
}
else {
self->d->sensorCam1->detach();
self->d->sensorCam2->detach();
}
}
}
}
//.........这里部分代码省略.........
示例7: addMenu
Menu::Menu() {
MenuWrapper * fileMenu = addMenu("File");
#ifdef Q_OS_MAC
addActionToQMenuAndActionHash(fileMenu, MenuOption::AboutApp, 0, qApp, SLOT(aboutApp()), QAction::AboutRole);
#endif
auto dialogsManager = DependencyManager::get<DialogsManager>();
AccountManager& accountManager = AccountManager::getInstance();
{
addActionToQMenuAndActionHash(fileMenu, MenuOption::Login);
// connect to the appropriate signal of the AccountManager so that we can change the Login/Logout menu item
connect(&accountManager, &AccountManager::profileChanged,
dialogsManager.data(), &DialogsManager::toggleLoginDialog);
connect(&accountManager, &AccountManager::logoutComplete,
dialogsManager.data(), &DialogsManager::toggleLoginDialog);
}
addDisabledActionAndSeparator(fileMenu, "Scripts");
addActionToQMenuAndActionHash(fileMenu, MenuOption::LoadScript, Qt::CTRL | Qt::Key_O,
qApp, SLOT(loadDialog()));
addActionToQMenuAndActionHash(fileMenu, MenuOption::LoadScriptURL,
Qt::CTRL | Qt::SHIFT | Qt::Key_O, qApp, SLOT(loadScriptURLDialog()));
addActionToQMenuAndActionHash(fileMenu, MenuOption::StopAllScripts, 0, qApp, SLOT(stopAllScripts()));
addActionToQMenuAndActionHash(fileMenu, MenuOption::ReloadAllScripts, Qt::CTRL | Qt::Key_R,
qApp, SLOT(reloadAllScripts()));
addActionToQMenuAndActionHash(fileMenu, MenuOption::RunningScripts, Qt::CTRL | Qt::Key_J,
qApp, SLOT(toggleRunningScriptsWidget()));
auto addressManager = DependencyManager::get<AddressManager>();
addDisabledActionAndSeparator(fileMenu, "History");
QAction* backAction = addActionToQMenuAndActionHash(fileMenu,
MenuOption::Back,
0,
addressManager.data(),
SLOT(goBack()));
QAction* forwardAction = addActionToQMenuAndActionHash(fileMenu,
MenuOption::Forward,
0,
addressManager.data(),
SLOT(goForward()));
// connect to the AddressManager signal to enable and disable the back and forward menu items
connect(addressManager.data(), &AddressManager::goBackPossible, backAction, &QAction::setEnabled);
connect(addressManager.data(), &AddressManager::goForwardPossible, forwardAction, &QAction::setEnabled);
// set the two actions to start disabled since the stacks are clear on startup
backAction->setDisabled(true);
forwardAction->setDisabled(true);
addDisabledActionAndSeparator(fileMenu, "Location");
qApp->getBookmarks()->setupMenus(this, fileMenu);
addActionToQMenuAndActionHash(fileMenu,
MenuOption::AddressBar,
Qt::CTRL | Qt::Key_L,
dialogsManager.data(),
SLOT(toggleAddressBar()));
addActionToQMenuAndActionHash(fileMenu, MenuOption::CopyAddress, 0,
addressManager.data(), SLOT(copyAddress()));
addActionToQMenuAndActionHash(fileMenu, MenuOption::CopyPath, 0,
addressManager.data(), SLOT(copyPath()));
addActionToQMenuAndActionHash(fileMenu,
MenuOption::Quit,
Qt::CTRL | Qt::Key_Q,
qApp,
SLOT(quit()),
QAction::QuitRole);
MenuWrapper* editMenu = addMenu("Edit");
QUndoStack* undoStack = qApp->getUndoStack();
QAction* undoAction = undoStack->createUndoAction(editMenu);
undoAction->setShortcut(Qt::CTRL | Qt::Key_Z);
addActionToQMenuAndActionHash(editMenu, undoAction);
QAction* redoAction = undoStack->createRedoAction(editMenu);
redoAction->setShortcut(Qt::CTRL | Qt::SHIFT | Qt::Key_Z);
addActionToQMenuAndActionHash(editMenu, redoAction);
addActionToQMenuAndActionHash(editMenu,
MenuOption::Preferences,
Qt::CTRL | Qt::Key_Comma,
dialogsManager.data(),
SLOT(editPreferences()),
QAction::PreferencesRole);
addActionToQMenuAndActionHash(editMenu, MenuOption::Attachments, 0,
dialogsManager.data(), SLOT(editAttachments()));
addActionToQMenuAndActionHash(editMenu, MenuOption::Animations, 0,
dialogsManager.data(), SLOT(editAnimations()));
MenuWrapper* toolsMenu = addMenu("Tools");
addActionToQMenuAndActionHash(toolsMenu, MenuOption::ScriptEditor, Qt::ALT | Qt::Key_S,
dialogsManager.data(), SLOT(showScriptEditor()));
//.........这里部分代码省略.........
示例8: QToolBar
// ---------------------------------------------------------------------------
void
TextEdit::setupFileActions()
{
QToolBar *tb = new QToolBar(this);
tb->setWindowTitle(tr("File Actions"));
addToolBar(tb);
QMenu *menu = new QMenu(tr("&File"), this);
menuBar()->addMenu(menu);
QAction *a;
a = new QAction(QIcon(rsrcPath + "/filenew.png"), tr("&New"), this);
a->setShortcut(QKeySequence::New);
connect(a, SIGNAL(triggered()), this, SLOT(fileNew()));
tb->addAction(a);
menu->addAction(a);
a = new QAction(QIcon(rsrcPath + "/fileopen.png"), tr("&Open..."), this);
a->setShortcut(QKeySequence::Open);
connect(a, SIGNAL(triggered()), this, SLOT(fileOpen()));
tb->addAction(a);
menu->addAction(a);
menu->addSeparator();
actionSave = a = new QAction(QIcon(rsrcPath + "/filesave.png"), tr("&Save"), this);
a->setShortcut(QKeySequence::Save);
connect(a, SIGNAL(triggered()), this, SLOT(fileSave()));
a->setEnabled(false);
tb->addAction(a);
menu->addAction(a);
a = new QAction(tr("Save &As..."), this);
connect(a, SIGNAL(triggered()), this, SLOT(fileSaveAs()));
menu->addAction(a);
menu->addSeparator();
#ifndef QT_NO_PRINTER
a = new QAction(QIcon(rsrcPath + "/fileprint.png"), tr("&Print..."), this);
a->setShortcut(QKeySequence::Print);
connect(a, SIGNAL(triggered()), this, SLOT(filePrint()));
tb->addAction(a);
menu->addAction(a);
a = new QAction(QIcon(rsrcPath + "/fileprint.png"), tr("Print Preview..."), this);
connect(a, SIGNAL(triggered()), this, SLOT(filePrintPreview()));
menu->addAction(a);
a = new QAction(QIcon(rsrcPath + "/exportpdf.png"), tr("&Export PDF..."), this);
a->setShortcut(Qt::CTRL + Qt::Key_D);
connect(a, SIGNAL(triggered()), this, SLOT(filePrintPdf()));
tb->addAction(a);
menu->addAction(a);
menu->addSeparator();
#endif
a = new QAction(tr("&Quit"), this);
a->setShortcut(Qt::CTRL + Qt::Key_Q);
connect(a, SIGNAL(triggered()), this, SLOT(close()));
menu->addAction(a);
}
示例9: contextMenuEvent
void TabBarWidget::contextMenuEvent(QContextMenuEvent *event)
{
m_clickedTab = tabAt(event->pos());
if (m_previewWidget && m_previewWidget->isVisible())
{
m_previewWidget->hide();
}
if (m_previewTimer > 0)
{
killTimer(m_previewTimer);
m_previewTimer = 0;
}
QMenu menu(this);
menu.addAction(ActionsManager::getAction(QLatin1String("NewTab")));
menu.addAction(ActionsManager::getAction(QLatin1String("NewTabPrivate")));
if (m_clickedTab >= 0)
{
const bool isPinned = getTabProperty(m_clickedTab, QLatin1String("isPinned"), false).toBool();
int amount = 0;
for (int i = 0; i < count(); ++i)
{
if (getTabProperty(i, QLatin1String("isPinned"), false).toBool() || i == m_clickedTab)
{
continue;
}
++amount;
}
menu.addAction(tr("Clone Tab"), this, SLOT(cloneTab()))->setEnabled(getTabProperty(m_clickedTab, QLatin1String("canClone"), false).toBool());
menu.addAction((isPinned ? tr("Unpin Tab") : tr("Pin Tab")), this, SLOT(pinTab()));
menu.addSeparator();
menu.addAction(tr("Detach Tab"), this, SLOT(detachTab()))->setEnabled(count() > 1);
menu.addSeparator();
if (isPinned)
{
QAction *closeAction = menu.addAction(QString());
ActionsManager::setupLocalAction(closeAction, QLatin1String("CloseTab"), true);
closeAction->setEnabled(false);
}
else
{
menu.addAction(ActionsManager::getAction(QLatin1String("CloseTab")));
}
menu.addAction(QIcon(":/icons/tab-close-other.png"), tr("Close Other Tabs"), this, SLOT(closeOther()))->setEnabled(amount > 0);
}
menu.exec(event->globalPos());
m_clickedTab = -1;
if (underMouse())
{
m_previewTimer = startTimer(250);
}
}
示例10: if
void
SourceTreeView::setupMenus()
{
m_playlistMenu.clear();
m_roPlaylistMenu.clear();
m_latchMenu.clear();
m_privacyMenu.clear();
bool readonly = true;
SourcesModel::RowType type = ( SourcesModel::RowType )model()->data( m_contextMenuIndex, SourcesModel::SourceTreeItemTypeRole ).toInt();
if ( type == SourcesModel::StaticPlaylist || type == SourcesModel::AutomaticPlaylist || type == SourcesModel::Station )
{
PlaylistItem* item = itemFromIndex< PlaylistItem >( m_contextMenuIndex );
playlist_ptr playlist = item->playlist();
if ( !playlist.isNull() )
{
readonly = !playlist->author()->isLocal();
}
}
QAction* latchOnAction = ActionCollection::instance()->getAction( "latchOn" );
m_latchMenu.addAction( latchOnAction );
m_privacyMenu.addAction( ActionCollection::instance()->getAction( "togglePrivacy" ) );
if ( type == SourcesModel::Collection )
{
SourceItem* item = itemFromIndex< SourceItem >( m_contextMenuIndex );
source_ptr source = item->source();
if ( !source.isNull() )
{
if ( m_latchManager->isLatched( source ) )
{
QAction *latchOffAction = ActionCollection::instance()->getAction( "latchOff" );
m_latchMenu.addAction( latchOffAction );
connect( latchOffAction, SIGNAL( triggered() ), SLOT( latchOff() ) );
m_latchMenu.addSeparator();
QAction *latchRealtimeAction = ActionCollection::instance()->getAction( "realtimeFollowingAlong" );
latchRealtimeAction->setChecked( source->playlistInterface()->latchMode() == Tomahawk::PlaylistInterface::RealTime );
m_latchMenu.addAction( latchRealtimeAction );
connect( latchRealtimeAction, SIGNAL( toggled( bool ) ), SLOT( latchModeToggled( bool ) ) );
}
}
}
QAction *loadPlaylistAction = ActionCollection::instance()->getAction( "loadPlaylist" );
m_playlistMenu.addAction( loadPlaylistAction );
QAction *renamePlaylistAction = ActionCollection::instance()->getAction( "renamePlaylist" );
m_playlistMenu.addAction( renamePlaylistAction );
m_playlistMenu.addSeparator();
QAction *copyPlaylistAction = m_playlistMenu.addAction( tr( "&Copy Link" ) );
QAction *deletePlaylistAction = m_playlistMenu.addAction( tr( "&Delete %1" ).arg( SourcesModel::rowTypeToString( type ) ) );
QString addToText = QString( "Add to my %1" );
if ( type == SourcesModel::StaticPlaylist )
addToText = addToText.arg( "Playlists" );
if ( type == SourcesModel::AutomaticPlaylist )
addToText = addToText.arg( "Automatic Playlists" );
else if ( type == SourcesModel::Station )
addToText = addToText.arg( "Stations" );
QAction *addToLocalAction = m_roPlaylistMenu.addAction( tr( addToText.toUtf8(), "Adds the given playlist, dynamic playlist, or station to the users's own list" ) );
m_roPlaylistMenu.addAction( copyPlaylistAction );
deletePlaylistAction->setEnabled( !readonly );
renamePlaylistAction->setEnabled( !readonly );
addToLocalAction->setEnabled( readonly );
if ( type == SourcesModel::StaticPlaylist )
copyPlaylistAction->setText( tr( "&Export Playlist" ) );
connect( loadPlaylistAction, SIGNAL( triggered() ), SLOT( loadPlaylist() ) );
connect( renamePlaylistAction, SIGNAL( triggered() ), SLOT( renamePlaylist() ) );
connect( deletePlaylistAction, SIGNAL( triggered() ), SLOT( deletePlaylist() ) );
connect( copyPlaylistAction, SIGNAL( triggered() ), SLOT( copyPlaylistLink() ) );
connect( addToLocalAction, SIGNAL( triggered() ), SLOT( addToLocal() ) );
connect( latchOnAction, SIGNAL( triggered() ), SLOT( latchOnOrCatchUp() ), Qt::QueuedConnection );
}
示例11: QMainWindow
ExternalHelpWindow::ExternalHelpWindow(QWidget *parent)
: QMainWindow(parent)
{
QSettings *settings = Core::ICore::settings();
settings->beginGroup(QLatin1String(Help::Constants::ID_MODE_HELP));
const QVariant geometry = settings->value(QLatin1String("geometry"));
if (geometry.isValid())
restoreGeometry(geometry.toByteArray());
else
resize(640, 480);
settings->endGroup();
QAction *action = new QAction(this);
action->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_I));
connect(action, SIGNAL(triggered()), this, SIGNAL(activateIndex()));
addAction(action);
action = new QAction(this);
action->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_C));
connect(action, SIGNAL(triggered()), this, SIGNAL(activateContents()));
addAction(action);
action = new QAction(this);
action->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_Slash));
connect(action, SIGNAL(triggered()), this, SIGNAL(activateSearch()));
addAction(action);
action = new QAction(this);
action->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_B));
connect(action, SIGNAL(triggered()), this, SIGNAL(activateBookmarks()));
addAction(action);
action = new QAction(this);
action->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_O));
connect(action, SIGNAL(triggered()), this, SIGNAL(activateOpenPages()));
addAction(action);
CentralWidget *centralWidget = CentralWidget::instance();
action = new QAction(this);
action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Plus));
connect(action, SIGNAL(triggered()), centralWidget, SLOT(zoomIn()));
addAction(action);
action = new QAction(this);
action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Minus));
connect(action, SIGNAL(triggered()), centralWidget, SLOT(zoomOut()));
addAction(action);
action = new QAction(this);
action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M));
connect(action, SIGNAL(triggered()), this, SIGNAL(addBookmark()));
addAction(action);
action = new QAction(this);
action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_C));
connect(action, SIGNAL(triggered()), centralWidget, SLOT(copy()));
addAction(action);
action = new QAction(this);
action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_P));
connect(action, SIGNAL(triggered()), centralWidget, SLOT(print()));
addAction(action);
action = new QAction(this);
action->setShortcut(QKeySequence::Back);
action->setEnabled(centralWidget->isBackwardAvailable());
connect(action, SIGNAL(triggered()), centralWidget, SLOT(backward()));
connect(centralWidget, SIGNAL(backwardAvailable(bool)), action,
SLOT(setEnabled(bool)));
action = new QAction(this);
action->setShortcut(QKeySequence::Forward);
action->setEnabled(centralWidget->isForwardAvailable());
connect(action, SIGNAL(triggered()), centralWidget, SLOT(forward()));
connect(centralWidget, SIGNAL(forwardAvailable(bool)), action,
SLOT(setEnabled(bool)));
QAction *reset = new QAction(this);
connect(reset, SIGNAL(triggered()), centralWidget, SLOT(resetZoom()));
addAction(reset);
QAction *ctrlTab = new QAction(this);
connect(ctrlTab, SIGNAL(triggered()), &OpenPagesManager::instance(),
SLOT(gotoPreviousPage()));
addAction(ctrlTab);
QAction *ctrlShiftTab = new QAction(this);
connect(ctrlShiftTab, SIGNAL(triggered()), &OpenPagesManager::instance(),
SLOT(gotoNextPage()));
addAction(ctrlShiftTab);
action = new QAction(QIcon(QLatin1String(Core::Constants::ICON_TOGGLE_SIDEBAR)),
tr("Show Sidebar"), this);
connect(action, SIGNAL(triggered()), this, SIGNAL(showHideSidebar()));
if (Utils::HostOsInfo::isMacHost()) {
reset->setShortcut(QKeySequence(Qt::ALT + Qt::Key_0));
//.........这里部分代码省略.........
示例12: updateExtensionsActionsAndMenus
void AppActions::updateExtensionsActionsAndMenus()
{
ExtensionsRegistry* ExtReg = ExtensionsRegistry::instance();
ExtensionsRegistry::ExtensionsByName_t* Extensions = ExtReg->registeredFeatureExtensions();
ExtensionsRegistry::ExtensionsByName_t::iterator it;
ExtensionsRegistry::ExtensionsByName_t::iterator itb = Extensions->begin();
ExtensionsRegistry::ExtensionsByName_t::iterator ite = Extensions->end();
mp_SpatialExtensionsMenu->clear();
mp_ModelExtensionsMenu->clear();
mp_ResultsExtensionsMenu->clear();
mp_OtherExtensionsMenu->clear();
for (it = itb; it!= ite; ++it)
{
QString MenuText = WaresTranslationsRegistry::instance()
->tryTranslate(QString::fromStdString((*it).second->FileFullPath),
"signature",(*it).second->Signature->MenuText);
// Replace empty menu text by extension ID
MenuText = QString::fromStdString(openfluid::tools::replaceEmptyString(MenuText.toStdString(),(*it).first));
m_ExtensionsActions[(*it).first] = new QAction(MenuText,this);
// associate extension ID with QAction for use when action is triggered and launch the correct extension
m_ExtensionsActions[(*it).first]->setData(QString((*it).first.c_str()));
// set extension in the correct menu, taking into account the extension category
if ((*it).second->Signature->Category == openfluid::builderext::CAT_SPATIAL)
{
mp_SpatialExtensionsMenu->addAction(m_ExtensionsActions[(*it).first]);
}
else if ((*it).second->Signature->Category == openfluid::builderext::CAT_MODEL)
{
mp_ModelExtensionsMenu->addAction(m_ExtensionsActions[(*it).first]);
}
else if ((*it).second->Signature->Category == openfluid::builderext::CAT_RESULTS)
{
mp_ResultsExtensionsMenu->addAction(m_ExtensionsActions[(*it).first]);
}
else
{
mp_OtherExtensionsMenu->addAction(m_ExtensionsActions[(*it).first]);
}
}
// fill empty menus with a "none" action
QAction *NoneAction;
if (mp_SpatialExtensionsMenu->isEmpty())
{
NoneAction = new QAction(tr("(none)"),this);
NoneAction->setEnabled(false);
mp_SpatialExtensionsMenu->addAction(NoneAction);
}
if (mp_ModelExtensionsMenu->isEmpty())
{
NoneAction = new QAction(tr("(none)"),this);
NoneAction->setEnabled(false);
mp_ModelExtensionsMenu->addAction(NoneAction);
}
if (mp_ResultsExtensionsMenu->isEmpty())
{
NoneAction = new QAction(tr("(none)"),this);
NoneAction->setEnabled(false);
mp_ResultsExtensionsMenu->addAction(NoneAction);
}
if (mp_OtherExtensionsMenu->isEmpty())
{
NoneAction = new QAction(tr("(none)"),this);
NoneAction->setEnabled(false);
mp_OtherExtensionsMenu->addAction(NoneAction);
}
}
示例13: getAction
QAction* QtWebKitWebWidget::getAction(WindowAction action)
{
const QWebPage::WebAction webAction = mapAction(action);
if (webAction != QWebPage::NoWebAction)
{
return m_webView->page()->action(webAction);
}
if (action == NoAction)
{
return NULL;
}
if (m_actions.contains(action))
{
return m_actions[action];
}
QAction *actionObject = new QAction(this);
actionObject->setData(action);
connect(actionObject, SIGNAL(triggered()), this, SLOT(triggerAction()));
switch (action)
{
case OpenLinkInNewTabAction:
ActionsManager::setupLocalAction(actionObject, QLatin1String("OpenLinkInNewTab"), true);
break;
case OpenLinkInNewTabBackgroundAction:
ActionsManager::setupLocalAction(actionObject, QLatin1String("OpenLinkInNewTabBackground"), true);
break;
case OpenLinkInNewWindowAction:
ActionsManager::setupLocalAction(actionObject, QLatin1String("OpenLinkInNewWindow"), true);
break;
case OpenLinkInNewWindowBackgroundAction:
ActionsManager::setupLocalAction(actionObject, QLatin1String("OpenLinkInNewWindowBackground"), true);
break;
case OpenFrameInThisTabAction:
ActionsManager::setupLocalAction(actionObject, QLatin1String("OpenFrameInThisTab"), true);
break;
case OpenFrameInNewTabBackgroundAction:
ActionsManager::setupLocalAction(actionObject, QLatin1String("OpenFrameInNewTabBackground"), true);
break;
case CopyFrameLinkToClipboardAction:
ActionsManager::setupLocalAction(actionObject, QLatin1String("CopyFrameLinkToClipboard"), true);
break;
case ViewSourceFrameAction:
ActionsManager::setupLocalAction(actionObject, QLatin1String("ViewSourceFrame"), true);
actionObject->setEnabled(false);
break;
case ReloadFrameAction:
ActionsManager::setupLocalAction(actionObject, QLatin1String("ReloadFrame"), true);
break;
case SaveLinkToDownloadsAction:
ActionsManager::setupLocalAction(actionObject, QLatin1String("SaveLinkToDownloads"));
break;
case RewindBackAction:
ActionsManager::setupLocalAction(actionObject, QLatin1String("RewindBack"), true);
actionObject->setEnabled(getAction(GoBackAction)->isEnabled());
break;
case RewindForwardAction:
ActionsManager::setupLocalAction(actionObject, QLatin1String("RewindForward"), true);
actionObject->setEnabled(getAction(GoForwardAction)->isEnabled());
break;
case ReloadTimeAction:
ActionsManager::setupLocalAction(actionObject, QLatin1String("ReloadTime"), true);
actionObject->setMenu(new QMenu(this));
actionObject->setEnabled(false);
break;
case PrintAction:
ActionsManager::setupLocalAction(actionObject, QLatin1String("Print"), true);
break;
case BookmarkAction:
ActionsManager::setupLocalAction(actionObject, QLatin1String("AddBookmark"), true);
break;
case BookmarkLinkAction:
ActionsManager::setupLocalAction(actionObject, QLatin1String("BookmarkLink"), true);
break;
case CopyAddressAction:
//.........这里部分代码省略.........
示例14: addToPopupMenu
void QgsLegendLayer::addToPopupMenu( QMenu& theMenu )
{
QgsMapLayer *lyr = layer();
QAction *toggleEditingAction = QgisApp::instance()->actionToggleEditing();
QAction *saveLayerEditsAction = QgisApp::instance()->actionSaveActiveLayerEdits();
QAction *allEditsAction = QgisApp::instance()->actionAllEdits();
// zoom to layer extent
theMenu.addAction( QgsApplication::getThemeIcon( "/mActionZoomToLayer.svg" ),
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( QgsApplication::getThemeIcon( "/mActionRemoveLayer.svg" ), tr( "&Remove" ), QgisApp::instance(), SLOT( removeLayer() ) );
// duplicate layer
QAction* duplicateLayersAction = theMenu.addAction( QgsApplication::getThemeIcon( "/mActionDuplicateLayer.svg" ), tr( "&Duplicate" ), QgisApp::instance(), SLOT( duplicateLayers() ) );
// set layer crs
theMenu.addAction( QgsApplication::getThemeIcon( "/mActionSetCRS.png" ), tr( "&Set Layer CRS" ), QgisApp::instance(), SLOT( setLayerCRS() ) );
// assign layer crs to project
theMenu.addAction( QgsApplication::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( QgsApplication::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() );
}
if ( saveLayerEditsAction && vlayer->isModified() )
{
theMenu.addAction( saveLayerEditsAction );
}
}
if ( allEditsAction->isEnabled() )
{
theMenu.addAction( allEditsAction );
}
// disable duplication of memory layers
if ( vlayer->storageType() == "Memory storage" && legend()->selectedLayers().count() == 1 )
{
duplicateLayersAction->setEnabled( false );
}
// save as vector file
theMenu.addAction( tr( "Save As..." ), QgisApp::instance(), SLOT( saveAsFile() ) );
// 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() && vlayer->vectorJoins().isEmpty() )
theMenu.addAction( tr( "&Filter..." ), 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();
}
示例15: contextMenuEvent
/**
* Allow changing tile properties through a context menu.
*/
void TilesetView::contextMenuEvent(QContextMenuEvent *event)
{
const QModelIndex index = indexAt(event->pos());
const TilesetModel *model = tilesetModel();
if (!model)
return;
Tile *tile = model->tileAt(index);
QMenu menu;
QIcon propIcon(QLatin1String(":images/16x16/document-properties.png"));
if (tile) {
if (mEditTerrain) {
// Select this tile to make sure it is clear that only a single
// tile is being used.
selectionModel()->setCurrentIndex(index,
QItemSelectionModel::SelectCurrent |
QItemSelectionModel::Clear);
QAction *addTerrain = menu.addAction(tr("Add Terrain Type"));
connect(addTerrain, &QAction::triggered, this, &TilesetView::addTerrainType);
if (mTerrain) {
QAction *setImage = menu.addAction(tr("Set Terrain Image"));
connect(setImage, &QAction::triggered, this, &TilesetView::selectTerrainImage);
}
} else if (mEditWangSet) {
selectionModel()->setCurrentIndex(index,
QItemSelectionModel::SelectCurrent |
QItemSelectionModel::Clear);
if (mWangSet) {
QAction *setImage = menu.addAction(tr("Set Wang Set Image"));
connect(setImage, &QAction::triggered, this, &TilesetView::selectWangSetImage);
}
if (mWangBehavior != WholeId && mWangColorIndex) {
QAction *setImage = menu.addAction(tr("Set Wang Color Image"));
connect(setImage, &QAction::triggered, this, &TilesetView::selectWangColorImage);
}
} else if (mTilesetDocument) {
QAction *tileProperties = menu.addAction(propIcon,
tr("Tile &Properties..."));
Utils::setThemeIcon(tileProperties, "document-properties");
connect(tileProperties, &QAction::triggered, this, &TilesetView::editTileProperties);
} else {
// Assuming we're used in the MapEditor
// Enable "swap" if there are exactly 2 tiles selected
bool exactlyTwoTilesSelected =
(selectionModel()->selectedIndexes().size() == 2);
QAction *swapTilesAction = menu.addAction(tr("&Swap Tiles"));
swapTilesAction->setEnabled(exactlyTwoTilesSelected);
connect(swapTilesAction, &QAction::triggered, this, &TilesetView::swapTiles);
}
menu.addSeparator();
}
QAction *toggleGrid = menu.addAction(tr("Show &Grid"));
toggleGrid->setCheckable(true);
toggleGrid->setChecked(mDrawGrid);
Preferences *prefs = Preferences::instance();
connect(toggleGrid, &QAction::toggled,
prefs, &Preferences::setShowTilesetGrid);
menu.exec(event->globalPos());
}