本文整理汇总了C++中QAction::setProperty方法的典型用法代码示例。如果您正苦于以下问题:C++ QAction::setProperty方法的具体用法?C++ QAction::setProperty怎么用?C++ QAction::setProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QAction
的用法示例。
在下文中一共展示了QAction::setProperty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: contextMenuEvent
void ExtendedTableWidget::contextMenuEvent(QContextMenuEvent * event)
{
QTableWidgetItem *item = itemAt(event->pos());
QAction *action;
if (item) {
event->accept();
QMenu contextMenu( this );
if (m_editable) {
action = contextMenu.addAction(tr("&Remove"), this, SLOT(remove()));
action->setProperty("row", row(item));
}
if (PhoneNumber::phone_re().exactMatch(item->text())) {
action = contextMenu.addAction(tr("&Dial"), this, SLOT(dialNumber()));
action->setProperty("number", item->text());
} else if(item->text().contains("@")) {
action = contextMenu.addAction(tr("Send an E-mail"),
this, SLOT(sendMail()) );
action->setProperty("email", item->text());
}
if(!contextMenu.isEmpty()) {
contextMenu.exec(event->globalPos());
}
} else {
event->ignore();
}
}
示例2: hookEntryActionsRequested
void Plugin::hookEntryActionsRequested (IHookProxy_ptr proxy, QObject *entry)
{
if (!Entry2ActionHistory_.contains (entry))
{
QAction *action = new QAction (tr ("History..."), entry);
action->setProperty ("ActionIcon", "view-history");
action->setProperty ("Azoth/ChatHistory/IsGood", true);
action->setProperty ("Azoth/ChatHistory/Entry",
QVariant::fromValue<QObject*> (entry));
connect (action,
SIGNAL (triggered ()),
this,
SLOT (handleEntryHistoryRequested ()));
Entry2ActionHistory_ [entry] = action;
}
if (!Entry2ActionEnableHistory_.contains (entry))
{
QAction *action = new QAction (tr ("Logging enabled"), entry);
action->setCheckable (true);
action->setChecked (Core::Instance ()->IsLoggingEnabled (entry));
action->setProperty ("Azoth/ChatHistory/IsGood", true);
action->setProperty ("Azoth/ChatHistory/Entry",
QVariant::fromValue<QObject*> (entry));
connect (action,
SIGNAL (toggled (bool)),
this,
SLOT (handleEntryEnableHistoryRequested (bool)));
Entry2ActionEnableHistory_ [entry] = action;
}
示例3: contextMenuEvent
/*! \brief show the context menu
*/
void XletSwitchBoard::contextMenuEvent(QContextMenuEvent *event)
{
// check if there is a group under the cursor
Group *group = getGroup(m_layout->getPosInGrid(event->pos()));
QMenu contextMenu(this);
QAction *action;
if (group) {
action = contextMenu.addAction(tr("Remove group %1").arg(group->name()),
this, SLOT(removeGroup()));
action->setProperty("group", QVariant::fromValue((void *)group));
action = contextMenu.addAction(tr("Change color of group %1").arg(group->name()),
this, SLOT(changeGroupColor()));
action->setProperty("group", QVariant::fromValue((void *)group));
action = contextMenu.addAction(tr("Rename group %1").arg(group->name()),
this, SLOT(changeGroupName()));
action->setProperty("group", QVariant::fromValue((void *)group));
}
action = contextMenu.addAction(tr("Add Phone number entry"),
this, SLOT(addPhoneNumberEntry()));
action->setProperty("pos", m_layout->getPosInGrid(event->pos()));
action = new QAction(tr("Draw the grid"), this);
action->setCheckable(true);
action->setChecked(m_drawGrid);
connect(action, SIGNAL(toggled(bool)),
this, SLOT(drawTheGrid(bool)));
contextMenu.addAction(action);
contextMenu.exec(event->globalPos());
}
示例4: handleBatteryInfo
void Plugin::handleBatteryInfo (BatteryInfo info)
{
if (!Battery2Action_.contains (info.ID_))
{
QAction *act = new QAction (tr ("Battery status"), this);
act->setProperty ("WatchActionIconChange", true);
act->setProperty ("Liznoo/BatteryID", info.ID_);
act->setProperty ("Action/Class", GetUniqueID () + "/BatteryAction");
act->setProperty ("Action/ID", GetUniqueID () + "/" + info.ID_);
emit gotActions (QList<QAction*> () << act, AEPLCTray);
Battery2Action_ [info.ID_] = act;
connect (act,
SIGNAL (triggered ()),
this,
SLOT (handleHistoryTriggered ()));
}
UpdateAction (info);
CheckNotifications (info);
Battery2LastInfo_ [info.ID_] = info;
}
示例5: handleBatteryInfo
void Plugin::handleBatteryInfo (BatteryInfo info)
{
#if QT_VERSION < 0x050000
const auto& iconName = GetBattIconName (info);
if (!Battery2Action_.contains (info.ID_))
{
QAction *act = new QAction (tr ("Battery status"), this);
act->setProperty ("WatchActionIconChange", true);
act->setProperty ("Liznoo/BatteryID", info.ID_);
act->setProperty ("Action/Class", GetUniqueID () + "/BatteryAction");
act->setProperty ("Action/ID", GetUniqueID () + "/" + info.ID_);
act->setProperty ("ActionIcon", iconName);
emit gotActions ({ act }, ActionsEmbedPlace::LCTray);
Battery2Action_ [info.ID_] = act;
connect (act,
SIGNAL (triggered ()),
this,
SLOT (handleHistoryTriggered ()));
}
else
Battery2Action_ [info.ID_]->setProperty ("ActionIcon", iconName);
#endif
CheckNotifications (info);
Battery2LastInfo_ [info.ID_] = info;
}
示例6: mDebugModeAction
UiManager::UiManager(QAction &debugModeAction
, QAction &editModeAction
, qReal::gui::MainWindowDockInterface &mainWindow
, qReal::SystemEvents &systemEvents
, kitBase::EventsForKitPluginInterface &kitPluginEvents
, kitBase::robotModel::RobotModelManagerInterface &robotModelManager)
: mDebugModeAction(debugModeAction)
, mEditModeAction(editModeAction)
, mMainWindow(mainWindow)
, mTabBar(nullptr)
, mCustomWidgetsBar(new QToolBar(tr("Miscellaneous"), mMainWindow.windowWidget()))
, mRobotConsole(new qReal::ui::ConsoleDock(tr("Robot console"), mMainWindow.windowWidget()))
{
mMainWindow.graphicalModelDock()->setWindowTitle(QObject::tr("Blocks"));
connect(&systemEvents, &qReal::SystemEvents::activeTabChanged, this, &UiManager::onActiveTabChanged);
connect(&systemEvents, &qReal::SystemEvents::ensureDiagramVisible, this, &UiManager::ensureDiagramVisible);
connect(&kitPluginEvents, &kitBase::EventsForKitPluginInterface::interpretationStarted
, this, &UiManager::switchToDebuggerMode);
connect(&kitPluginEvents, &kitBase::EventsForKitPluginInterface::interpretationStarted
, mRobotConsole, &qReal::ui::ConsoleDock::clear);
connect(&kitPluginEvents, &kitBase::EventsForKitPluginInterface::robotModelChanged
, [=]() { QTimer::singleShot(0, this, SLOT(reloadDocksSavingToolbarsAndErrors())); });
connect(&robotModelManager, &kitBase::robotModel::RobotModelManagerInterface::robotModelChanged
, this, &UiManager::onRobotModelChanged);
connect(&debugModeAction, &QAction::triggered, this, &UiManager::switchToDebuggerMode);
connect(&editModeAction, &QAction::triggered, this, &UiManager::switchToEditorMode);
mRobotConsole->hide();
initTab();
mCustomWidgetsBar->setObjectName("robotsMiscellaneousBar");
connect(this, &QObject::destroyed, [this]() { mCustomWidgetsBar->setParent(nullptr); });
mMainWindow.addToolBar(Qt::TopToolBarArea, mCustomWidgetsBar);
mMainWindow.addDockWidget(Qt::BottomDockWidgetArea, mRobotConsole);
mMainWindow.tabifyDockWidget(mRobotConsole, mMainWindow.errorReporterDock());
mMainWindow.windowWidget()->addAction(mRobotConsole->toggleViewAction());
mRobotConsole->toggleViewAction()->setShortcut(Qt::ALT + Qt::Key_2);
mMainWindow.statusBar()->setAutoFillBackground(true);
#ifdef Q_OS_LINUX
// On Windows and Mac this stylesheet is not needed and will cause segfault on program close.
mMainWindow.statusBar()->setStyleSheet("QStatusBar::item { border: 0px solid black; padding: 10px; }");
#endif
editModeAction.setProperty("modeName", tr("edit mode"));
debugModeAction.setProperty("modeName", tr("debug mode"));
produceModeButton(Mode::Editing, debugModeAction, mMainWindow.statusBar());
produceModeButton(Mode::Debugging, editModeAction, mMainWindow.statusBar());
switchToEditorMode();
onActiveTabChanged(qReal::TabInfo());
qReal::SettingsListener::listen("dockableWidgets", this, &UiManager::updateDocksSettings);
}
示例7: dir
Gui::Action * CmdDrawingNewPage::createAction(void)
{
Gui::ActionGroup* pcAction = new Gui::ActionGroup(this, Gui::getMainWindow());
pcAction->setDropDownMenu(true);
applyCommandData(this->className(), pcAction);
QAction* defaultAction = 0;
int defaultId = 0;
std::string path = App::Application::getResourceDir();
path += "Mod/Drawing/Templates/";
QDir dir(QString::fromUtf8(path.c_str()), QString::fromAscii("*.svg"));
for (unsigned int i=0; i<dir.count(); i++ ) {
QRegExp rx(QString::fromAscii("(A|B|C|D|E)(\\d)_(Landscape|Portrait).svg"));
if (rx.indexIn(dir[i]) > -1) {
QString paper = rx.cap(1);
int id = rx.cap(2).toInt();
QString orientation = rx.cap(3);
QFile file(QString::fromAscii(":/icons/actions/drawing-landscape-A0.svg"));
QAction* a = pcAction->addAction(QString());
if (file.open(QFile::ReadOnly)) {
QString s = QString::fromAscii("style=\"font-size:22px\">%1%2</tspan></text>").arg(paper).arg(id);
QByteArray data = file.readAll();
data.replace("style=\"font-size:22px\">A0</tspan></text>", s.toAscii());
a->setIcon(Gui::BitmapFactory().pixmapFromSvg(data, QSize(24,24)));
}
a->setProperty("TemplatePaper", paper);
a->setProperty("TemplateOrientation", orientation);
a->setProperty("TemplateId", id);
a->setProperty("Template", dir.absoluteFilePath(dir[i]));
if (id == 3) {
defaultAction = a;
defaultId = pcAction->actions().size() - 1;
}
}
}
_pcAction = pcAction;
languageChange();
if (defaultAction) {
pcAction->setIcon(defaultAction->icon());
pcAction->setProperty("defaultAction", QVariant(defaultId));
}
else if (!pcAction->actions().isEmpty()) {
pcAction->setIcon(pcAction->actions()[0]->icon());
pcAction->setProperty("defaultAction", QVariant(0));
}
return pcAction;
}
示例8: onCustomMenuHandler
void FilterExpressionToolBar::onCustomMenuHandler(const QPoint& pos)
{
QAction * filterAction = actionAt(pos);
if ( ! filterAction )
return;
QMenu * filterMenu = new QMenu(this);
QAction *actFilter = filterMenu->addAction(tr("Filter Button Preferences..."));
connect(actFilter, SIGNAL(triggered()), this, SLOT(toolBarShowPreferences()));
actFilter->setProperty(dfe_property_label_, filterAction->property(dfe_property_label_));
actFilter->setProperty(dfe_property_expression_, filterAction->property(dfe_property_expression_));
actFilter->setData(filterAction->data());
filterMenu->addSeparator();
QAction * actEdit = filterMenu->addAction(tr("Edit"));
connect(actEdit, SIGNAL(triggered()), this, SLOT(editFilter()));
actEdit->setProperty(dfe_property_label_, filterAction->property(dfe_property_label_));
actEdit->setProperty(dfe_property_expression_, filterAction->property(dfe_property_expression_));
actEdit->setData(filterAction->data());
QAction * actDisable = filterMenu->addAction(tr("Disable"));
connect(actDisable, SIGNAL(triggered()), this, SLOT(disableFilter()));
actDisable->setProperty(dfe_property_label_, filterAction->property(dfe_property_label_));
actDisable->setProperty(dfe_property_expression_, filterAction->property(dfe_property_expression_));
actDisable->setData(filterAction->data());
QAction * actRemove = filterMenu->addAction(tr("Remove"));
connect(actRemove, SIGNAL(triggered()), this, SLOT(removeFilter()));
actRemove->setProperty(dfe_property_label_, filterAction->property(dfe_property_label_));
actRemove->setProperty(dfe_property_expression_, filterAction->property(dfe_property_expression_));
actRemove->setData(filterAction->data());
filterMenu->exec(mapToGlobal(pos));
}
示例9: Fill
void CommandContributionItem::Fill(QToolBar *parent, QAction *before)
{
if (!command || action || parent == nullptr)
{
return;
}
QAction* item = nullptr;
if (before)
{
item = parent->addAction(icon, label);
}
else
{
item = new QAction(icon, label, parent);
parent->insertAction(before, item);
}
item->setData(QVariant::fromValue(Object::Pointer(this)));
item->setProperty("contributionItem", QVariant::fromValue(Object::Pointer(this)));
connect(item, SIGNAL(triggered()), SLOT(HandleWidgetSelection()));
connect(item, SIGNAL(destroyed()), SLOT(HandleActionDestroyed()));
action = item;
this->Update();
this->UpdateIcons();
//bindingService.addBindingManagerListener(bindingManagerListener);
}
示例10: FoldTabClass
void SBWidget::FoldTabClass (const TabClassInfo& tc, QAction *newAct)
{
if (!TabClass2Folder_.contains (tc.TabClass_))
{
QAction *foldAct = new QAction (tc.VisibleName_, this);
foldAct->setToolTip (tc.Description_);
foldAct->setIcon (tc.Icon_);
foldAct->setProperty ("Sidebar/TabClass", tc.TabClass_);
connect (foldAct,
SIGNAL (triggered ()),
this,
SLOT (showFolded ()));
auto tb = new QToolButton;
tb->setIconSize (IconSize_);
tb->setDefaultAction (foldAct);
TabClass2Folder_ [tc.TabClass_] = tb;
Ui_.TabsLay_->insertWidget (0, tb);
Q_FOREACH (QAction *act, TabClass2Action_ [tc.TabClass_])
AddToFolder (tc.TabClass_, act);
}
else
AddToFolder (tc.TabClass_, newAct);
}
示例11: file
foreach(QString filename, files) {
const QFileInfo file(filename);
QAction *a = menu->addAction(QString(index<10?"&%1. %2":"%1. %2").arg(index).arg(file.fileName()));
a->setStatusTip(file.absoluteFilePath());
a->setProperty("filepath",file.absoluteFilePath());
++index;
}
示例12: dir
Gui::Action * CmdRaytracingNewLuxProject::createAction(void)
{
Gui::ActionGroup* pcAction = new Gui::ActionGroup(this, Gui::getMainWindow());
pcAction->setDropDownMenu(true);
applyCommandData(this->className(), pcAction);
QAction* defaultAction = 0;
int defaultId = 0;
std::string path = App::Application::getResourceDir();
path += "Mod/Raytracing/Templates/";
QDir dir(QString::fromUtf8(path.c_str()), QString::fromAscii("*.lxs"));
for (unsigned int i=0; i<dir.count(); i++ ) {
QFileInfo fi(dir[i]);
QAction* a = pcAction->addAction(fi.baseName());
a->setIcon(Gui::BitmapFactory().pixmap("Raytrace_Lux"));
a->setProperty("Template", dir.absoluteFilePath(dir[i]));
}
_pcAction = pcAction;
languageChange();
if (defaultAction) {
pcAction->setIcon(defaultAction->icon());
pcAction->setProperty("defaultAction", QVariant(defaultId));
}
else if (!pcAction->actions().isEmpty()) {
pcAction->setIcon(pcAction->actions()[0]->icon());
pcAction->setProperty("defaultAction", QVariant(0));
}
return pcAction;
}
示例13: RefreshProfiles
void OBSBasic::RefreshProfiles()
{
QList<QAction*> menuActions = ui->profileMenu->actions();
int count = 0;
for (int i = 0; i < menuActions.count(); i++) {
QVariant v = menuActions[i]->property("file_name");
if (v.typeName() != nullptr)
delete menuActions[i];
}
const char *curName = config_get_string(App()->GlobalConfig(),
"Basic", "Profile");
auto addProfile = [&](const char *name, const char *path)
{
std::string file = strrchr(path, '/') + 1;
QAction *action = new QAction(QT_UTF8(name), this);
action->setProperty("file_name", QT_UTF8(path));
connect(action, &QAction::triggered,
this, &OBSBasic::ChangeProfile);
action->setCheckable(true);
action->setChecked(strcmp(name, curName) == 0);
ui->profileMenu->addAction(action);
count++;
return true;
};
EnumProfiles(addProfile);
ui->actionRemoveProfile->setEnabled(count > 1);
}
示例14: saveActions
QStringList TToolbarEditor::saveActions() {
logger()->debug("saveActions");
QStringList list;
for (int row = 0; row < active_actions_table->rowCount(); row++) {
QTableWidgetItem* item = active_actions_table->item(row, COL_NAME);
if (item) {
QString action_name = item->text();
if (action_name.startsWith("separator")) {
action_name = "separator";
}
QString s = action_name;
bool ns = getVis(row, COL_NS);
bool fs = getVis(row, COL_FS);
if (ns) {
if (!fs) {
s += "|1|0";
}
} else if (fs) {
s += "|0|1";
} else {
s += "|0|0";
}
list << s;
if (action_name != "separator") {
// Update icon text
QAction* action = findAction(action_name, *all_actions);
if (action) {
item = active_actions_table->item(row, COL_DESC);
if (item) {
QString action_icon_text = TActionsEditor::actionTextToDescription(
item->text(), action_name).trimmed();
if (!action_icon_text.isEmpty()) {
QString action_text = TActionsEditor::actionTextToDescription(action->text(), action_name);
if (action_text != action_icon_text) {
action->setIconText(action_icon_text);
action->setProperty("modified", true);
logger()->debug("saveActions: updated icon text '"
+ action_name + "' to '" + action_icon_text
+ "'");
} else {
action_icon_text = TActionsEditor::actionTextToDescription(action->iconText(), action_name);
if (action_icon_text != action_text) {
action->setIconText(action_text);
logger()->debug("saveActions: cleared icon text "
+ action_name);
}
}
}
}
}
}
}
}
return list;
}
示例15: QObject
TabManager::TabManager (SeparateTabWidget *tabWidget, MainWindow *window, QObject *parent)
: QObject (parent)
, TabWidget_ (tabWidget)
, Window_ (window)
{
for (int i = 0; i < TabWidget_->WidgetCount (); ++i)
OriginalTabNames_ << TabWidget_->TabText (i);
connect (TabWidget_,
SIGNAL (tabCloseRequested (int)),
this,
SLOT (remove (int)));
connect (TabWidget_,
SIGNAL (currentChanged (int)),
this,
SLOT (handleCurrentChanged (int)));
connect (TabWidget_,
SIGNAL (tabWasMoved (int, int)),
this,
SLOT (handleMoveHappened (int, int)));
XmlSettingsManager::Instance ()->RegisterObject ("UseTabScrollButtons",
this, "handleScrollButtons");
handleScrollButtons ();
QAction *closeAllButCurrent = new QAction (tr ("Close all but this"),
this);
connect (closeAllButCurrent,
SIGNAL (triggered ()),
this,
SLOT (handleCloseAllButCurrent ()));
closeAllButCurrent->setProperty ("ActionIcon", "tab-close-other");
TabWidget_->AddAction2TabBar (closeAllButCurrent);
}