本文整理汇总了C++中QAction::setDisabled方法的典型用法代码示例。如果您正苦于以下问题:C++ QAction::setDisabled方法的具体用法?C++ QAction::setDisabled怎么用?C++ QAction::setDisabled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QAction
的用法示例。
在下文中一共展示了QAction::setDisabled方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createContextMenu
void HistoryManager::createContextMenu(const QPoint &pos)
{
QMenu menu;
QAction* actNewTab = menu.addAction(IconProvider::newTabIcon(), tr("Open in new tab"));
QAction* actNewWindow = menu.addAction(IconProvider::newWindowIcon(), tr("Open in new window"));
QAction* actNewPrivateWindow = menu.addAction(IconProvider::privateBrowsingIcon(), tr("Open in new private window"));
menu.addSeparator();
QAction* actCopyUrl = menu.addAction(tr("Copy url"), this, SLOT(copyUrl()));
QAction* actCopyTitle = menu.addAction(tr("Copy title"), this, SLOT(copyTitle()));
menu.addSeparator();
QAction* actDelete = menu.addAction(QIcon::fromTheme(QSL("edit-delete")), tr("Delete"));
connect(actNewTab, SIGNAL(triggered()), this, SLOT(openUrlInNewTab()));
connect(actNewWindow, SIGNAL(triggered()), this, SLOT(openUrlInNewWindow()));
connect(actNewPrivateWindow, SIGNAL(triggered()), this, SLOT(openUrlInNewPrivateWindow()));
connect(actDelete, SIGNAL(triggered()), ui->historyTree, SLOT(removeSelectedItems()));
if (ui->historyTree->selectedUrl().isEmpty()) {
actNewTab->setDisabled(true);
actNewWindow->setDisabled(true);
actNewPrivateWindow->setDisabled(true);
actCopyTitle->setDisabled(true);
actCopyUrl->setDisabled(true);
}
menu.exec(pos);
}
示例2: disableConfig
void lemon::disableConfig()
{
QAction *actPref = actionCollection()->action(KStandardAction::stdName(KStandardAction::Preferences));
actPref->setDisabled(true);
QAction *actQuit = actionCollection()->action(KStandardAction::stdName(KStandardAction::Quit));
//FIXME: esto no es muy bueno en produccion..
if (!Settings::allowAnyUserToQuit()) actQuit->setDisabled(true);
}
示例3: setModule
void ProtocolPreferencesMenu::setModule(const char *module_name)
{
QAction *action;
int proto_id = -1;
if (module_name) {
proto_id = proto_get_id_by_filter_name(module_name);
}
clear();
module_name_.clear();
module_ = NULL;
protocol_ = find_protocol_by_id(proto_id);
const QString long_name = proto_get_protocol_long_name(protocol_);
const QString short_name = proto_get_protocol_short_name(protocol_);
if (!module_name || proto_id < 0 || !protocol_) {
action = addAction(tr("No protocol preferences available"));
action->setDisabled(true);
return;
}
QAction *disable_action = new QAction(tr("Disable %1" UTF8_HORIZONTAL_ELLIPSIS).arg(short_name), this);
connect(disable_action, SIGNAL(triggered(bool)), this, SLOT(disableProtocolTriggered()));
module_ = prefs_find_module(module_name);
if (!module_ || !prefs_is_registered_protocol(module_name)) {
action = addAction(tr("%1 has no preferences").arg(long_name));
action->setDisabled(true);
addSeparator();
addAction(disable_action);
return;
}
module_name_ = module_name;
action = addAction(tr("Open %1 preferences" UTF8_HORIZONTAL_ELLIPSIS).arg(long_name));
action->setData(QString(module_name));
connect(action, SIGNAL(triggered(bool)), this, SLOT(modulePreferencesTriggered()));
addSeparator();
prefs_pref_foreach(module_, add_prefs_menu_item, this);
if (!actions().last()->isSeparator()) {
addSeparator();
}
addAction(disable_action);
}
示例4: customContextMenuRequested
void ImHistoryBrowser::customContextMenuRequested(QPoint /*pos*/)
{
std::list<uint32_t> msgIds;
getSelectedItems(msgIds);
QListWidgetItem *currentItem = ui.listWidget->currentItem();
QMenu contextMnu(this);
QAction *selectAll = new QAction(tr("Mark all"), &contextMnu);
QAction *copyMessage = new QAction(tr("Copy"), &contextMnu);
QAction *removeMessages = new QAction(tr("Delete"), &contextMnu);
QAction *clearHistory = new QAction(tr("Clear history"), &contextMnu);
QAction *sendItem = NULL;
if (textEdit) {
sendItem = new QAction(tr("Send"), &contextMnu);
if (currentItem) {
connect(sendItem, SIGNAL(triggered()), this, SLOT(sendMessage()));
} else {
sendItem->setDisabled(true);
}
}
if (msgIds.size()) {
connect(selectAll, SIGNAL(triggered()), ui.listWidget, SLOT(selectAll()));
connect(copyMessage, SIGNAL(triggered()), this, SLOT(copyMessage()));
connect(removeMessages, SIGNAL(triggered()), this, SLOT(removeMessages()));
connect(clearHistory, SIGNAL(triggered()), this, SLOT(clearHistory()));
} else {
selectAll->setDisabled(true);
copyMessage->setDisabled(true);
removeMessages->setDisabled(true);
clearHistory->setDisabled(true);
}
contextMnu.addAction(selectAll);
contextMnu.addSeparator();
contextMnu.addAction(copyMessage);
contextMnu.addAction(removeMessages);
contextMnu.addAction(clearHistory);
if (sendItem) {
contextMnu.addSeparator();
contextMnu.addAction(sendItem);
}
contextMnu.exec(QCursor::pos());
}
示例5: contextMenuEvent
void MimeTextEdit::contextMenuEvent(QContextMenuEvent *e)
{
emit calculateContextMenuActions();
QMenu *contextMenu = createStandardContextMenu(e->pos());
/* Add actions for pasting links */
contextMenu->addAction( tr("Paste as plain text"), this, SLOT(pastePlainText()));
QAction *spoilerAction = contextMenu->addAction(tr("Spoiler"), this, SLOT(spoiler()));
spoilerAction->setToolTip(tr("Select text to hide, then push this button"));
contextMenu->addSeparator();
QAction *pasteLinkAction = contextMenu->addAction(QIcon(":/images/pasterslink.png"), tr("Paste RetroShare Link"), this, SLOT(pasteLink()));
contextMenu->addAction(QIcon(":/images/pasterslink.png"), tr("Paste my certificate link"), this, SLOT(pasteOwnCertificateLink()));
if (RSLinkClipboard::empty()) {
pasteLinkAction->setDisabled(true);
}
QList<QAction*>::iterator it;
for (it = mContextMenuActions.begin(); it != mContextMenuActions.end(); ++it) {
contextMenu->addAction(*it);
}
contextMenu->exec(QCursor::pos());
delete(contextMenu);
}
示例6: updateTabHeaderMenu
void MainTabs::updateTabHeaderMenu()
{
tabHeaderContextMenu->clear();
QMenu * newTabMenu = guiHelper->getNewTabMenu();
if (newTabMenu != nullptr) {
tabHeaderContextMenu->addMenu(newTabMenu);
}
QList<TabAbstract *> list = guiHelper->getDeletedTabs();
if (list.size() > 0) {
if (newTabMenu != nullptr) {
tabHeaderContextMenu->addSeparator();
}
QAction * action = new(std::nothrow) QAction(tr("Deleted Tabs"), tabHeaderContextMenu);
if (action == nullptr) {
qFatal("Cannot allocate memory for action for \"deleted tab\" X{");
return;
}
action->setDisabled(true);
tabHeaderContextMenu->addAction(action);
for (int i = 0; i < list.size(); i++) {
action = new(std::nothrow) QAction(list.at(i)->getName(), tabHeaderContextMenu);
if (action == nullptr) {
qFatal("Cannot allocate memory for action for deletedTabContextMenu X{");
return;
}
tabHeaderContextMenu->addAction(action);
}
}
}
示例7: groupListCustomPopupMenu
void WikiDialog::groupListCustomPopupMenu(QPoint /*point*/)
{
int subscribeFlags = ui.groupTreeWidget->subscribeFlags(QString::fromStdString(mGroupId));
QMenu contextMnu(this);
std::cerr << "WikiDialog::groupListCustomPopupMenu()";
std::cerr << std::endl;
std::cerr << " mGroupId: " << mGroupId;
std::cerr << std::endl;
std::cerr << " subscribeFlags: " << subscribeFlags;
std::cerr << std::endl;
std::cerr << " IS_GROUP_SUBSCRIBED(): " << IS_GROUP_SUBSCRIBED(subscribeFlags);
std::cerr << std::endl;
std::cerr << " IS_GROUP_ADMIN(): " << IS_GROUP_ADMIN(subscribeFlags);
std::cerr << std::endl;
std::cerr << std::endl;
QAction *action = contextMnu.addAction(QIcon(IMAGE_SUBSCRIBE), tr("Subscribe to Group"), this, SLOT(subscribeToGroup()));
action->setDisabled (mGroupId.empty() || IS_GROUP_SUBSCRIBED(subscribeFlags));
action = contextMnu.addAction(QIcon(IMAGE_UNSUBSCRIBE), tr("Unsubscribe to Group"), this, SLOT(unsubscribeToGroup()));
action->setEnabled (!mGroupId.empty() && IS_GROUP_SUBSCRIBED(subscribeFlags));
contextMnu.addSeparator();
action = contextMnu.addAction(QIcon(IMAGE_INFO), tr("Show Wiki Group"), this, SLOT(showGroupDetails()));
action->setEnabled (!mGroupId.empty ());
action = contextMnu.addAction(QIcon(IMAGE_EDIT), tr("Edit Wiki Group"), this, SLOT(editGroupDetails()));
action->setEnabled (!mGroupId.empty() && IS_GROUP_ADMIN(subscribeFlags));
/************** NOT ENABLED YET *****************/
//if (!Settings->getForumOpenAllInNewTab()) {
// action = contextMnu.addAction(QIcon(""), tr("Open in new tab"), this, SLOT(openInNewTab()));
// if (mForumId.empty() || forumThreadWidget(mForumId)) {
// action->setEnabled(false);
// }
//}
//QAction *shareKeyAct = new QAction(QIcon(":/images/gpgp_key_generate.png"), tr("Share Forum"), &contextMnu);
//connect( shareKeyAct, SIGNAL( triggered() ), this, SLOT( shareKey() ) );
//shareKeyAct->setEnabled(!mForumId.empty() && IS_GROUP_ADMIN(subscribeFlags));
//contextMnu.addAction( shareKeyAct);
//QAction *restoreKeysAct = new QAction(QIcon(":/images/settings16.png"), tr("Restore Publish Rights for Forum" ), &contextMnu);
//connect( restoreKeysAct , SIGNAL( triggered() ), this, SLOT( restoreForumKeys() ) );
//restoreKeysAct->setEnabled(!mForumId.empty() && !IS_GROUP_ADMIN(subscribeFlags));
//contextMnu.addAction( restoreKeysAct);
//action = contextMnu.addAction(QIcon(IMAGE_COPYLINK), tr("Copy RetroShare Link"), this, SLOT(copyForumLink()));
//action->setEnabled(!mForumId.empty());
//contextMnu.addSeparator();
contextMnu.exec(QCursor::pos());
}
示例8: updateToolsMenu
void MainWindow::updateToolsMenu()
{
if (ui->actionLaunchInstance->menu())
{
ui->actionLaunchInstance->menu()->deleteLater();
}
QMenu *launchMenu = new QMenu(this);
QAction *normalLaunch = launchMenu->addAction(tr("Launch"));
connect(normalLaunch, &QAction::triggered, [this](){doLaunch();});
launchMenu->addSeparator()->setText(tr("Profilers"));
for (auto profiler : MMC->profilers().values())
{
QAction *profilerAction = launchMenu->addAction(profiler->name());
QString error;
if (!profiler->check(&error))
{
profilerAction->setDisabled(true);
profilerAction->setToolTip(tr("Profiler not setup correctly. Go into settings, \"External Tools\"."));
}
else
{
connect(profilerAction, &QAction::triggered, [this, profiler](){doLaunch(true, profiler.get());});
}
}
launchMenu->addSeparator()->setText(tr("Tools"));
for (auto tool : MMC->tools().values())
{
QAction *toolAction = launchMenu->addAction(tool->name());
QString error;
if (!tool->check(&error))
{
toolAction->setDisabled(true);
toolAction->setToolTip(tr("Tool not setup correctly. Go into settings, \"External Tools\"."));
}
else
{
connect(toolAction, &QAction::triggered, [this, tool]()
{
tool->createDetachedTool(m_selectedInstance, this)->run();
});
}
}
ui->actionLaunchInstance->setMenu(launchMenu);
}
示例9: showWorkspaceMenu
void MuseScore::showWorkspaceMenu()
{
if (workspaces == 0) {
workspaces = new QActionGroup(this);
workspaces->setExclusive(true);
connect(workspaces, SIGNAL(triggered(QAction*)), SLOT(changeWorkspace(QAction*)));
}
else {
for (QAction* a : workspaces->actions())
workspaces->removeAction(a);
}
menuWorkspaces->clear();
const QList<Workspace*> pl = Workspace::workspaces();
for (Workspace* p : pl) {
QAction* a = workspaces->addAction(qApp->translate("Ms::Workspace", p->name().toUtf8()));
a->setCheckable(true);
a->setData(p->path());
a->setChecked(p->name() == preferences.getString(PREF_APP_WORKSPACE));
menuWorkspaces->addAction(a);
}
menuWorkspaces->addSeparator();
QAction* a = new QAction(tr("New..."), this);
connect(a, SIGNAL(triggered()), SLOT(createNewWorkspace()));
menuWorkspaces->addAction(a);
a = new QAction(tr("Edit"), this);
a->setDisabled(Workspace::currentWorkspace->readOnly());
connect(a, SIGNAL(triggered()), SLOT(editWorkspace()));
menuWorkspaces->addAction(a);
a = new QAction(tr("Delete"), this);
a->setDisabled(Workspace::currentWorkspace->readOnly());
connect(a, SIGNAL(triggered()), SLOT(deleteWorkspace()));
menuWorkspaces->addAction(a);
a = new QAction(tr("Undo Changes"), this);
a->setDisabled(Workspace::currentWorkspace->readOnly());
connect(a, SIGNAL(triggered()), SLOT(undoWorkspace()));
menuWorkspaces->addAction(a);
}
示例10: init_menu
void MainWindow::init_menu()
{
static QMenu *file = NULL, *help = NULL, *import = NULL,
*token = NULL, *languageMenu = NULL, *extra = NULL;
static QActionGroup * langGroup = NULL;
QAction *a;
QList<myLang> languages;
if (file) delete file;
if (help) delete help;
if (import) delete import;
if (token) delete token;
if (extra) delete extra;
if (languageMenu) delete languageMenu;
if (historyMenu) delete historyMenu;
if (langGroup) delete langGroup;
wdMenuList.clear();
scardList.clear();
acList.clear();
langGroup = new QActionGroup(this);
historyMenu = new tipMenu(tr("Recent DataBases") + " ...", this);
connect(historyMenu, SIGNAL(triggered(QAction*)),
this, SLOT(open_database(QAction*)));
languages <<
myLang("System", tr("System"), QLocale::system()) <<
myLang("Croatian", tr("Croatian"), QLocale("hr")) <<
myLang("English", tr("English"), QLocale("en")) <<
myLang("French", tr("French"), QLocale("fr")) <<
myLang("German", tr("German"), QLocale("de")) <<
myLang("Russian", tr("Russian"), QLocale("ru")) <<
myLang("Slovak", tr("Slovak"), QLocale("sk")) <<
myLang("Spanish", tr("Spanish"), QLocale("es")) <<
myLang("Turkish", tr("Turkish"), QLocale("tr"));
languageMenu = new tipMenu(tr("Language"), this);
connect(languageMenu, SIGNAL(triggered(QAction*)),
qApp, SLOT(switchLanguage(QAction*)));
foreach(myLang l, languages) {
QAction *a = new QAction(l.english, langGroup);
a->setToolTip(l.native);
a->setData(QVariant(l.locale));
a->setDisabled(!XCA_application::languageAvailable(l.locale));
a->setCheckable(true);
langGroup->addAction(a);
languageMenu->addAction(a);
if (l.locale == XCA_application::language())
a->setChecked(true);
}
示例11: onCustomContextMenuRequested
void AMCurrentAmplifierCompositeView::onCustomContextMenuRequested(QPoint position)
{
if (isValid()) {
QMenu menu(this);
QAction *basic = menu.addAction("Basic view");
basic->setDisabled(viewMode_ == Basic);
QAction *advanced = menu.addAction("Advanced view");
advanced->setDisabled(viewMode_ == Advanced);
QAction *selected = menu.exec(mapToGlobal(position));
if (selected) {
if (selected->text() == "Basic view")
setViewMode(Basic);
else if (selected->text() == "Advanced view")
setViewMode(Advanced);
}
}
}
示例12: contextMenuEvent
void PrefQuantitySpinBox::contextMenuEvent(QContextMenuEvent *event)
{
Q_D(PrefQuantitySpinBox);
QMenu *editMenu = lineEdit()->createStandardContextMenu();
editMenu->setTitle(tr("Edit"));
QMenu* menu = new QMenu(QString::fromLatin1("PrefQuantitySpinBox"));
menu->addMenu(editMenu);
menu->addSeparator();
// datastructure to remember actions for values
std::vector<QString> values;
std::vector<QAction *> actions;
// add the history menu part...
QStringList history = getHistory();
for (QStringList::const_iterator it = history.begin();it!= history.end();++it) {
actions.push_back(menu->addAction(*it));
values.push_back(*it);
}
// add the save value portion of the menu
menu->addSeparator();
QAction *saveValueAction = menu->addAction(tr("Save value"));
QAction *clearListAction = menu->addAction(tr("Clear list"));
clearListAction->setDisabled(history.empty());
// call the menu and wait until its back
QAction *userAction = menu->exec(event->globalPos());
// look what the user has choosen
if (userAction == saveValueAction) {
pushToHistory(this->text());
}
else if (userAction == clearListAction) {
d->handle->Clear();
}
else {
int i=0;
for (std::vector<QAction *>::const_iterator it = actions.begin();it!=actions.end();++it,i++) {
if (*it == userAction) {
lineEdit()->setText(values[i]);
break;
}
}
}
delete menu;
}
示例13: on_lstContacts_customContextMenuRequested
/**
* Creates a context menu when user right-clicks on a contact.
* @brief MainWindow::on_lstContacts_customContextMenuRequested
* @param pos Cooridinates of right-click
*/
void MainWindow::on_lstContacts_customContextMenuRequested(const QPoint &pos)
{
if(ui->lstContacts->selectedItems().count() < 1) return;
contactsMenu = new QMenu("Context menu", this);
QAction* add = new QAction(STR_ADD_TO_CONVO, this);
if(ui->tabgrpConversations->currentIndex() == 0) add->setDisabled(true);
contactsMenu->addAction(add);
contactsMenu->addAction(new QAction(STR_REMOVE, this));
contactsMenu->addAction(new QAction(STR_BLOCK_UNBLK, this));
connect(contactsMenu, SIGNAL(triggered(QAction*)), this, SLOT(contactsMenuClicked(QAction*)));
contactsMenu->exec(ui->lstContacts->mapToGlobal(pos));
contactsMenu->deleteLater();
}
示例14: customPopUpMenu
void GxsCommentTreeWidget::customPopUpMenu(const QPoint& /*point*/)
{
QMenu contextMnu( this );
QAction* action = contextMnu.addAction(QIcon(IMAGE_MESSAGE), tr("Reply to Comment"), this, SLOT(replyToComment()));
action->setDisabled(mCurrentMsgId.isNull());
action = contextMnu.addAction(QIcon(IMAGE_MESSAGE), tr("Submit Comment"), this, SLOT(makeComment()));
action->setDisabled(mThreadId.first.isNull());
contextMnu.addSeparator();
action = contextMnu.addAction(QIcon(IMAGE_VOTEUP), tr("Vote Up"), this, SLOT(voteUp()));
action->setDisabled(mVoterId.isNull());
action = contextMnu.addAction(QIcon(IMAGE_VOTEDOWN), tr("Vote Down"), this, SLOT(voteDown()));
action->setDisabled(mVoterId.isNull());
if (!mCurrentMsgId.isNull())
{
// not implemented yet
/*
contextMnu.addSeparator();
QMenu *rep_menu = contextMnu.addMenu(tr("Reputation"));
action = rep_menu->addAction(QIcon(IMAGE_MESSAGE), tr("Show Reputation"), this, SLOT(showReputation()));
contextMnu.addSeparator();
action = rep_menu->addAction(QIcon(IMAGE_MESSAGE), tr("Interesting User"), this, SLOT(markInteresting()));
contextMnu.addSeparator();
action = rep_menu->addAction(QIcon(IMAGE_MESSAGE), tr("Mark Spammy"), this, SLOT(markSpammer()));
action = rep_menu->addAction(QIcon(IMAGE_MESSAGE), tr("Ban User"), this, SLOT(banUser()));
*/
}
contextMnu.exec(QCursor::pos());
}
示例15: displayContextMenuSharedDirs
void SettingsWidget::displayContextMenuSharedDirs(const QPoint& point)
{
QPoint globalPosition = this->ui->tblShareDirs->mapToGlobal(point);
globalPosition.setY(globalPosition.y() + this->ui->tblShareDirs->horizontalHeader()->height());
QMenu menu;
QAction* actionDelete = menu.addAction(QIcon(":/icons/ressources/delete.png"), tr("Remove the shared directory"), this, SLOT(removeShared()));
QAction* actionUp = menu.addAction(QIcon(":/icons/ressources/arrow_up.png"), tr("Move up"), this, SLOT(moveUpShared()));
QAction* actionDown = menu.addAction(QIcon(":/icons/ressources/arrow_down.png"), tr("Move down"), this, SLOT(moveDownShared()));
if (this->coreConnection->isLocal() && this->sharedDirsModel.rowCount() > 0)
menu.addAction(QIcon(":/icons/ressources/explore_folder.png"), tr("Open location"), this, SLOT(openLocation()));
if (this->sharedDirsModel.rowCount() == 0)
actionDelete->setDisabled(true);
if (this->ui->tblShareDirs->currentIndex().row() == 0 || this->sharedDirsModel.rowCount() == 0)
actionUp->setDisabled(true);
if (this->ui->tblShareDirs->currentIndex().row() >= this->sharedDirsModel.rowCount() - 1 || this->sharedDirsModel.rowCount() == 0)
actionDown->setDisabled(true);
menu.exec(globalPosition);
}