本文整理汇总了C++中KAction::setObjectName方法的典型用法代码示例。如果您正苦于以下问题:C++ KAction::setObjectName方法的具体用法?C++ KAction::setObjectName怎么用?C++ KAction::setObjectName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KAction
的用法示例。
在下文中一共展示了KAction::setObjectName方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
void DesktopCorona::init()
{
setPreferredToolBoxPlugin(Plasma::Containment::DesktopContainment, "org.kde.desktoptoolbox");
setPreferredToolBoxPlugin(Plasma::Containment::CustomContainment, "org.kde.desktoptoolbox");
setPreferredToolBoxPlugin(Plasma::Containment::PanelContainment, "org.kde.paneltoolbox");
setPreferredToolBoxPlugin(Plasma::Containment::CustomPanelContainment, "org.kde.paneltoolbox");
kDebug() << "!!{} STARTUP TIME" << QTime().msecsTo(QTime::currentTime()) << "DesktopCorona init start" << "(line:" << __LINE__ << ")";
Kephal::Screens *screens = Kephal::Screens::self();
connect(screens, SIGNAL(screenAdded(Kephal::Screen*)), SLOT(screenAdded(Kephal::Screen*)));
connect(KWindowSystem::self(), SIGNAL(workAreaChanged()), this, SIGNAL(availableScreenRegionChanged()));
Plasma::ContainmentActionsPluginsConfig desktopPlugins;
desktopPlugins.addPlugin(Qt::NoModifier, Qt::Vertical, "switchdesktop");
desktopPlugins.addPlugin(Qt::NoModifier, Qt::MidButton, "paste");
desktopPlugins.addPlugin(Qt::NoModifier, Qt::RightButton, "contextmenu");
Plasma::ContainmentActionsPluginsConfig panelPlugins;
panelPlugins.addPlugin(Qt::NoModifier, Qt::RightButton, "contextmenu");
setContainmentActionsDefaults(Plasma::Containment::DesktopContainment, desktopPlugins);
setContainmentActionsDefaults(Plasma::Containment::CustomContainment, desktopPlugins);
setContainmentActionsDefaults(Plasma::Containment::PanelContainment, panelPlugins);
setContainmentActionsDefaults(Plasma::Containment::CustomPanelContainment, panelPlugins);
checkAddPanelAction();
//why do these actions belong to plasmaapp?
//because it makes the keyboard shortcuts work.
KAction *action = new KAction(PlasmaApp::self());
action->setText(i18n("Next Activity"));
action->setObjectName( QLatin1String("Next Activity" )); // NO I18N
action->setGlobalShortcut(KShortcut(Qt::META + Qt::Key_Tab));
connect(action, SIGNAL(triggered()), this, SLOT(activateNextActivity()));
action = new KAction(PlasmaApp::self());
action->setText(i18n("Previous Activity"));
action->setObjectName( QLatin1String("Previous Activity" )); // NO I18N
action->setGlobalShortcut(KShortcut(Qt::META + Qt::SHIFT + Qt::Key_Tab));
connect(action, SIGNAL(triggered()), this, SLOT(activatePreviousActivity()));
connect(this, SIGNAL(immutabilityChanged(Plasma::ImmutabilityType)),
this, SLOT(updateImmutability(Plasma::ImmutabilityType)));
connect(KSycoca::self(), SIGNAL(databaseChanged(QStringList)), this, SLOT(checkAddPanelAction(QStringList)));
connect(m_activityController, SIGNAL(currentActivityChanged(QString)), this, SLOT(currentActivityChanged(QString)));
connect(m_activityController, SIGNAL(activityAdded(QString)), this, SLOT(activityAdded(QString)));
connect(m_activityController, SIGNAL(activityRemoved(QString)), this, SLOT(activityRemoved(QString)));
mapAnimation(Plasma::Animator::AppearAnimation, Plasma::Animator::ZoomAnimation);
mapAnimation(Plasma::Animator::DisappearAnimation, Plasma::Animator::ZoomAnimation);
kDebug() << "!!{} STARTUP TIME" << QTime().msecsTo(QTime::currentTime()) << "DesktopCorona init end" << "(line:" << __LINE__ << ")";
}
示例2: testOverrideMainComponentData
void KGlobalShortcutTest::testOverrideMainComponentData()
{
setupTest("testOverrideMainComponentData");
KComponentData otherComponent("test_component1");
KActionCollection coll((QObject*)NULL);
coll.setComponentData(otherComponent);
KShortcut cutB;
// Action without action collection
KAction *action = new KAction("Text For Action A", this);
QVERIFY(action->d->componentData == KGlobal::mainComponent());
action->setObjectName("Action A");
action->setGlobalShortcut(cutB, KAction::ActiveShortcut, KAction::NoAutoloading);
QVERIFY(action->d->componentData == KGlobal::mainComponent());
// Action with action collection
action->forgetGlobalShortcut();
delete action;
action = coll.addAction("Action A");
QVERIFY(action->d->componentData == otherComponent);
action->setGlobalShortcut(cutB, KAction::ActiveShortcut, KAction::NoAutoloading);
QVERIFY(action->d->componentData == otherComponent);
// cleanup
action->forgetGlobalShortcut();
delete coll.takeAction(action);
}
示例3: cut
KAction *create(StandardAction id, const QObject *recvr, const char *slot, QObject *parent)
{
KAction *pAction = 0;
const Info* pInfo = infoPtr(id);
if (pInfo) {
pAction = new KAction(parent);
pAction->setObjectName(pInfo->psName);
KShortcut cut(pInfo->shortcut);
if (!cut.isEmpty())
pAction->setShortcut(cut);
pAction->setText(i18n(pInfo->psText));
pAction->setToolTip(i18n(pInfo->psToolTip));
pAction->setWhatsThis(i18n(pInfo->psWhatsThis));
if (pInfo->psIconName)
pAction->setIcon(KIcon(QLatin1String(pInfo->psIconName)));
}
if (recvr && slot)
QObject::connect(pAction, SIGNAL(triggered(bool)), recvr, slot);
if (pAction) {
KActionCollection *collection = qobject_cast<KActionCollection *>(parent);
if (collection)
collection->addAction(pAction->objectName(), pAction);
}
return pAction;
}
示例4: addGlobalShortcut
void MainWindow::addGlobalShortcut(QKeySequence shortcut,
QObject *object,
const char *slot,
QString name) {
KAction *action = new KAction(name, this);
action->setObjectName(name);
action->setGlobalShortcut(KShortcut(shortcut), KAction::ActiveShortcut, KAction::Autoloading);
QObject::connect(action, SIGNAL(triggered()), object, slot);
}
示例5: createGUIClients
void Part::createGUIClients()//KexiMainWindow *win)
{
// d->mainWin = win;
if (!d->guiClient) {
//create part's gui client
d->guiClient = new GUIClient(this, false, "part");
//default actions for part's gui client:
KAction *act = new KAction(
KIcon(info()->createItemIcon()),
instanceCaption() + "...",
KexiMainWindowIface::global()->actionCollection()
);
act->setObjectName(KexiPart::nameForCreateAction(*info()));
QString defaultToolTip(i18n("Create new object of type \"%1\"", instanceCaption().toLower()));
act->setToolTip(internalPropertyValue("instanceToolTip", defaultToolTip).toString());
QString defaultWhatsThis(i18n("Creates new object of type \"%1\"", instanceCaption().toLower()));
act->setWhatsThis(internalPropertyValue("instanceWhatsThis", defaultWhatsThis).toString());
connect(act, SIGNAL(triggered()), this, SLOT(slotCreate()));
KexiMainWindowIface::global()->actionCollection()->addAction(act->objectName(), act);
#ifdef __GNUC__
#warning TODO KexiMainWindowIface::global()->guiFactory()->addClient(d->guiClient); //this client is added permanently
#else
#pragma WARNING( TODO KexiMainWindowIface::global()->guiFactory()->addClient(d->guiClient); )
#endif
//default actions for part instance's gui client:
//NONE
//let init specific actions for part instances
for (int mode = 1; mode <= 0x01000; mode <<= 1) {
if (d->supportedViewModes & (Kexi::ViewMode)mode) {
GUIClient *instanceGuiClient = new GUIClient(
this, true, Kexi::nameForViewMode((Kexi::ViewMode)mode).toLatin1());
d->instanceGuiClients.insert((Kexi::ViewMode)mode, instanceGuiClient);
}
}
// also add an instance common for all modes (mode==0)
GUIClient *instanceGuiClient = new GUIClient(this, true, "allViews");
d->instanceGuiClients.insert(Kexi::AllViewModes, instanceGuiClient);
//todo
initPartActions();
// initActions();
}
}
示例6: testNotification
void KGlobalShortcutTest::testNotification()
{
setupTest("testNotification");
// Action without action collection
KAction *action = new KAction("Text For Action A", this);
QVERIFY(action->d->componentData == KGlobal::mainComponent());
action->setObjectName("Action A");
KShortcut cutB;
action->setGlobalShortcut(cutB, KAction::ActiveShortcut, KAction::NoAutoloading);
QVERIFY(action->d->componentData == KGlobal::mainComponent());
// kglobalacceld collects registrations and shows the together. Give it
// time to kick in.
sleep(2);
action->forgetGlobalShortcut();
}
示例7: init
//.........这里部分代码省略.........
// This is used by KHTML, see khtml_popupmenu.rc (copy, selectAll, searchProvider etc.)
// and by DolphinPart (rename, trash, delete)
addGroup( "editactions" );
if (m_itemFlags & KParts::BrowserExtension::ShowTextSelectionItems) {
// OK, we have to stop here.
// Anything else that is provided by the part
addGroup( "partactions" );
return;
}
if ( !isCurrentTrash && !isIntoTrash && (m_itemFlags & KParts::BrowserExtension::ShowBookmark))
{
QString caption;
if (currentDir)
{
const bool httpPage = m_sViewURL.protocol().startsWith("http", Qt::CaseInsensitive);
if (httpPage)
caption = i18n("&Bookmark This Page");
else
caption = i18n("&Bookmark This Location");
}
else if (isDirectory)
caption = i18n("&Bookmark This Folder");
else if (bIsLink)
caption = i18n("&Bookmark This Link");
else
caption = i18n("&Bookmark This File");
act = new KAction(m_parentWidget);
m_ownActions.append(act);
act->setObjectName( QLatin1String("bookmark_add" )); // for unittest
act->setIcon( KIcon("bookmark-new") );
act->setText( caption );
QObject::connect(act, SIGNAL(triggered()), q, SLOT(slotPopupAddToBookmark()));
if (lstItems.count() > 1)
act->setEnabled(false);
if (KAuthorized::authorizeKAction("bookmarks"))
q->addAction( act );
if (bIsLink)
addGroup( "linkactions" ); // see khtml
}
// "Open With" actions
m_menuActions.setItemListProperties(m_popupItemProperties);
if ( sReading ) {
m_menuActions.addOpenWithActionsTo(q, "DesktopEntryName != 'kfmclient' and DesktopEntryName != 'kfmclient_dir' and DesktopEntryName != 'kfmclient_html'");
QList<QAction *> previewActions = m_actionGroups.value("preview");
if (!previewActions.isEmpty()) {
if (previewActions.count() == 1) {
q->addAction(previewActions.first());
} else {
QMenu* subMenu = new QMenu(i18n("Preview In"), q);
subMenu->menuAction()->setObjectName( QLatin1String("preview_submenu" )); // for the unittest
q->addMenu(subMenu);
subMenu->addActions(previewActions);
}
}
}
// Second block, builtin + user
示例8: fillMenu
void TokenWithLayout::fillMenu( QMenu * menu )
{
DEBUG_BLOCK
KAction *boldAction = new KAction( KIcon( "format-text-bold"), i18n( "Bold" ), menu );
boldAction->setObjectName( ActionBoldName );
boldAction->setCheckable( true );
boldAction->setChecked( m_bold );
KAction *italicAction = new KAction( KIcon( "format-text-italic"), i18n( "Italic" ), menu );
italicAction->setObjectName( ActionItalicName );
italicAction->setCheckable( true );
italicAction->setChecked( m_italic );
KAction *alignLeftAction = new KAction( KIcon( "format-justify-left"), i18n( "Left" ), menu );
KAction *alignCenterAction = new KAction( KIcon( "format-justify-center"), i18n( "Center" ), menu );
KAction *alignRightAction = new KAction( KIcon( "format-justify-right"), i18n( "Right" ), menu );
alignLeftAction->setObjectName( ActionAlignLeftName );
alignLeftAction->setCheckable( true );
alignCenterAction->setObjectName( ActionAlignCenterName );
alignCenterAction->setCheckable( true );
alignRightAction->setObjectName( ActionAlignRightName );
alignRightAction->setCheckable( true );
if ( m_alignment & Qt::AlignLeft )
alignLeftAction->setChecked( true );
else if ( m_alignment & Qt::AlignHCenter )
alignCenterAction->setChecked( true );
else if ( m_alignment & Qt::AlignRight )
alignRightAction->setChecked( true );
QActionGroup *alignmentGroup = new QActionGroup( menu );
alignmentGroup->addAction( alignLeftAction );
alignmentGroup->addAction( alignCenterAction );
alignmentGroup->addAction( alignRightAction );
menu->addAction( boldAction );
menu->addAction( italicAction );
menu->addSeparator()->setText( i18n( "Alignment" ) );
menu->addAction( alignLeftAction );
menu->addAction( alignCenterAction );
menu->addAction( alignRightAction );
menu->addSeparator()->setText( i18n( "Width" ) );
menu->adjustSize();
int orgHeight = menu->height();
KHBox * sliderBox = new KHBox( menu );
sliderBox->setFixedWidth( menu->width() - 4 );
sliderBox->move( sliderBox->pos().x() + 2, orgHeight );
QSlider * slider = new QSlider( Qt::Horizontal, sliderBox );
slider->setMaximum( 100 );
slider->setMinimum( 0 );
// this should really not be done here as it makes upward assumptions
// it was however done in setWidth with similar upward assumptions as well
// solution: the popup stuff -iff- should be done in the dialog or the editWidget
if ( parentWidget() )
{
if ( TokenDropTarget *editWidget = qobject_cast<TokenDropTarget*>( parentWidget() ) )
{
qreal spareWidth = 100.0;
int row = editWidget->row( this );
if ( row > -1 )
{
QList<Token*> tokens = editWidget->drags( row );
foreach (Token *t, tokens)
{
if (t == this)
continue;
if ( TokenWithLayout *twl = qobject_cast<TokenWithLayout*>( t ) )
spareWidth -= twl->width() * 100.0;
}
}
int max = qMax( spareWidth, 0.0 );
debug() << "slider max value: " << max;
if ( max >= m_width * 100.0 )
slider->setMaximum( qMax( spareWidth, 0.0 ) );
else
slider->setMaximum( m_width * 100.0 );
}