本文整理汇总了C++中KAction::setGlobalShortcut方法的典型用法代码示例。如果您正苦于以下问题:C++ KAction::setGlobalShortcut方法的具体用法?C++ KAction::setGlobalShortcut怎么用?C++ KAction::setGlobalShortcut使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KAction
的用法示例。
在下文中一共展示了KAction::setGlobalShortcut方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: KCModule
MouseMarkEffectConfig::MouseMarkEffectConfig(QWidget* parent, const QVariantList& args) :
KCModule(EffectFactory::componentData(), parent, args)
{
m_ui = new MouseMarkEffectConfigForm(this);
QVBoxLayout* layout = new QVBoxLayout(this);
layout->addWidget(m_ui);
connect(m_ui->editor, SIGNAL(keyChange()), this, SLOT(changed()));
connect(m_ui->spinWidth, SIGNAL(valueChanged(int)), this, SLOT(changed()));
connect(m_ui->comboColors, SIGNAL(currentIndexChanged(int)), this, SLOT(changed()));
// Shortcut config. The shortcut belongs to the component "kwin"!
m_actionCollection = new KActionCollection( this, KComponentData("kwin") );
KAction* a = static_cast< KAction* >( m_actionCollection->addAction( "ClearMouseMarks" ));
a->setText( i18n( "Clear Mouse Marks" ));
a->setProperty("isConfigurationAction", true);
a->setGlobalShortcut( KShortcut( Qt::SHIFT + Qt::META + Qt::Key_F11 ));
a = static_cast< KAction* >( m_actionCollection->addAction( "ClearLastMouseMark" ));
a->setText( i18n( "Clear Last Mouse Mark" ));
a->setProperty("isConfigurationAction", true);
a->setGlobalShortcut( KShortcut( Qt::SHIFT + Qt::META + Qt::Key_F12 ));
m_ui->editor->addCollection(m_actionCollection);
load();
}
示例2: KCModule
LookingGlassEffectConfig::LookingGlassEffectConfig(QWidget* parent, const QVariantList& args) :
KCModule(EffectFactory::componentData(), parent, args)
{
m_ui = new LookingGlassEffectConfigForm(this);
QVBoxLayout* layout = new QVBoxLayout(this);
layout->addWidget(m_ui);
connect(m_ui->editor, SIGNAL(keyChange()), this, SLOT(changed()));
connect(m_ui->radiusSpin, SIGNAL(valueChanged(int)), this, SLOT(changed()));
// Shortcut config. The shortcut belongs to the component "kwin"!
m_actionCollection = new KActionCollection(this, KComponentData("kwin"));
m_actionCollection->setConfigGroup("LookingGlass");
m_actionCollection->setConfigGlobal(true);
KAction* a;
a = static_cast< KAction* >(m_actionCollection->addAction(KStandardAction::ZoomIn));
a->setProperty("isConfigurationAction", true);
a->setGlobalShortcut(KShortcut(Qt::META + Qt::Key_Plus));
a = static_cast< KAction* >(m_actionCollection->addAction(KStandardAction::ZoomOut));
a->setProperty("isConfigurationAction", true);
a->setGlobalShortcut(KShortcut(Qt::META + Qt::Key_Minus));
a = static_cast< KAction* >(m_actionCollection->addAction(KStandardAction::ActualSize));
a->setProperty("isConfigurationAction", true);
a->setGlobalShortcut(KShortcut(Qt::META + Qt::Key_0));
m_ui->editor->addCollection(m_actionCollection);
}
示例3: 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);
}
示例4: KCModule
MouseMarkEffectConfig::MouseMarkEffectConfig(QWidget* parent, const QVariantList& args) :
KCModule(EffectFactory::componentData(), parent, args)
{
m_ui = new MouseMarkEffectConfigForm(this);
m_ui->kcfg_LineWidth->setSuffix(ki18np(" pixel", " pixels"));
QVBoxLayout* layout = new QVBoxLayout(this);
layout->addWidget(m_ui);
addConfig(MouseMarkConfig::self(), m_ui);
// Shortcut config. The shortcut belongs to the component "kwin"!
m_actionCollection = new KActionCollection(this, KComponentData("kwin"));
KAction* a = static_cast< KAction* >(m_actionCollection->addAction("ClearMouseMarks"));
a->setText(i18n("Clear Mouse Marks"));
a->setProperty("isConfigurationAction", true);
a->setGlobalShortcut(KShortcut(Qt::SHIFT + Qt::META + Qt::Key_F11));
a = static_cast< KAction* >(m_actionCollection->addAction("ClearLastMouseMark"));
a->setText(i18n("Clear Last Mouse Mark"));
a->setProperty("isConfigurationAction", true);
a->setGlobalShortcut(KShortcut(Qt::SHIFT + Qt::META + Qt::Key_F12));
m_ui->editor->addCollection(m_actionCollection);
load();
}
示例5: 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__ << ")";
}
示例6: reconfigure
WindowGeometry::WindowGeometry()
{
iAmActivated = true;
iAmActive = false;
myResizeWindow = 0L;
#define myResizeString "Window geometry display, %1 and %2 are the new size," \
" %3 and %4 are pixel increments - avoid reformatting or suffixes like 'px'", \
"Width: %1 (%3)\nHeight: %2 (%4)"
#define myCoordString_0 "Window geometry display, %1 and %2 are the cartesian x and y coordinates" \
" - avoid reformatting or suffixes like 'px'", \
"X: %1\nY: %2"
#define myCoordString_1 "Window geometry display, %1 and %2 are the cartesian x and y coordinates," \
" %3 and %4 are the resp. increments - avoid reformatting or suffixes like 'px'", \
"X: %1 (%3)\nY: %2 (%4)"
reconfigure(ReconfigureAll);
QFont fnt; fnt.setBold(true); fnt.setPointSize(12);
for (int i = 0; i < 3; ++i) {
myMeasure[i] = effects->effectFrame(EffectFrameUnstyled, false);
myMeasure[i]->setFont(fnt);
}
myMeasure[0]->setAlignment(Qt::AlignLeft | Qt::AlignTop);
myMeasure[1]->setAlignment(Qt::AlignCenter);
myMeasure[2]->setAlignment(Qt::AlignRight | Qt::AlignBottom);
KActionCollection* actionCollection = new KActionCollection(this);
KAction* a = static_cast< KAction* >(actionCollection->addAction("WindowGeometry"));
a->setText(i18n("Toggle window geometry display (effect only)"));
a->setGlobalShortcut(KShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_F11));
connect(a, SIGNAL(triggered(bool)), this, SLOT(toggle()));
connect(effects, SIGNAL(windowStartUserMovedResized(KWin::EffectWindow*)), this, SLOT(slotWindowStartUserMovedResized(KWin::EffectWindow*)));
connect(effects, SIGNAL(windowFinishUserMovedResized(KWin::EffectWindow*)), this, SLOT(slotWindowFinishUserMovedResized(KWin::EffectWindow*)));
connect(effects, SIGNAL(windowStepUserMovedResized(KWin::EffectWindow*,QRect)), this, SLOT(slotWindowStepUserMovedResized(KWin::EffectWindow*,QRect)));
}
示例7: KActionCollection
MouseMarkEffect::MouseMarkEffect()
{
KActionCollection* actionCollection = new KActionCollection(this);
KAction* a = static_cast< KAction* >(actionCollection->addAction("ClearMouseMarks"));
a->setText(i18n("Clear All Mouse Marks"));
a->setGlobalShortcut(KShortcut(Qt::SHIFT + Qt::META + Qt::Key_F11));
connect(a, SIGNAL(triggered(bool)), this, SLOT(clear()));
a = static_cast< KAction* >(actionCollection->addAction("ClearLastMouseMark"));
a->setText(i18n("Clear Last Mouse Mark"));
a->setGlobalShortcut(KShortcut(Qt::SHIFT + Qt::META + Qt::Key_F12));
connect(a, SIGNAL(triggered(bool)), this, SLOT(clearLast()));
connect(effects, SIGNAL(mouseChanged(QPoint,QPoint,Qt::MouseButtons,Qt::MouseButtons,Qt::KeyboardModifiers,Qt::KeyboardModifiers)),
this, SLOT(slotMouseChanged(QPoint,QPoint,Qt::MouseButtons,Qt::MouseButtons,Qt::KeyboardModifiers,Qt::KeyboardModifiers)));
reconfigure(ReconfigureAll);
arrow_start = NULL_POINT;
effects->startMousePolling(); // We require it to detect activation as well
}
示例8: 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);
}
示例9: KActionCollection
ThumbnailAsideEffect::ThumbnailAsideEffect()
{
KActionCollection* actionCollection = new KActionCollection( this );
KAction* a = (KAction*)actionCollection->addAction( "ToggleCurrentThumbnail" );
a->setText( i18n("Toggle Thumbnail for Current Window" ));
a->setGlobalShortcut(KShortcut(Qt::CTRL + Qt::META + Qt::Key_T));
connect(a, SIGNAL(triggered(bool)), this, SLOT(toggleCurrentThumbnail()));
reconfigure( ReconfigureAll );
}
示例10: client
VideoRecordEffect::VideoRecordEffect()
: client( NULL )
{
KActionCollection* actionCollection = new KActionCollection( this );
KAction* a = static_cast< KAction* >( actionCollection->addAction( "VideoRecord" ));
a->setText( i18n("Toggle Video Recording" ));
a->setGlobalShortcut( KShortcut( Qt::CTRL + Qt::META + Qt::Key_V ));
connect( a, SIGNAL( triggered( bool )), this, SLOT( toggleRecording()));
area = QRect( 0, 0, displayWidth(), displayHeight());
}
示例11: KCModule
PresentWindowsEffectConfig::PresentWindowsEffectConfig(QWidget* parent, const QVariantList& args)
: KCModule(EffectFactory::componentData(), parent, args)
{
m_ui = new PresentWindowsEffectConfigForm(this);
QVBoxLayout* layout = new QVBoxLayout(this);
layout->addWidget(m_ui);
// Shortcut config. The shortcut belongs to the component "kwin"!
m_actionCollection = new KActionCollection(this, KComponentData("kwin"));
m_actionCollection->setConfigGroup("PresentWindows");
m_actionCollection->setConfigGlobal(true);
KAction* a = (KAction*) m_actionCollection->addAction("ExposeAll");
a->setText(i18n("Toggle Present Windows (All desktops)"));
a->setProperty("isConfigurationAction", true);
a->setGlobalShortcut(KShortcut(Qt::CTRL + Qt::Key_F10));
KAction* b = (KAction*) m_actionCollection->addAction("Expose");
b->setText(i18n("Toggle Present Windows (Current desktop)"));
b->setProperty("isConfigurationAction", true);
b->setGlobalShortcut(KShortcut(Qt::CTRL + Qt::Key_F9));
KAction* c = (KAction*)m_actionCollection->addAction("ExposeClass");
c->setText(i18n("Toggle Present Windows (Window class)"));
c->setProperty("isConfigurationAction", true);
c->setGlobalShortcut(KShortcut(Qt::CTRL + Qt::Key_F7));
m_ui->shortcutEditor->addCollection(m_actionCollection);
connect(m_ui->shortcutEditor, SIGNAL(keyChange()), this, SLOT(changed()));
addConfig(PresentWindowsConfig::self(), m_ui);
load();
}
示例12: actionCollection
void
KMixWindow::initActionsLate()
{
if (m_autouseMultimediaKeys)
{
KAction* globalAction = actionCollection()->addAction("increase_volume");
globalAction->setText(i18n("Increase Volume"));
globalAction->setGlobalShortcut(KShortcut(Qt::Key_VolumeUp));
connect(globalAction, SIGNAL(triggered(bool)),
SLOT(slotIncreaseVolume()));
globalAction = actionCollection()->addAction("decrease_volume");
globalAction->setText(i18n("Decrease Volume"));
globalAction->setGlobalShortcut(KShortcut(Qt::Key_VolumeDown));
connect(globalAction, SIGNAL(triggered(bool)),
SLOT(slotDecreaseVolume()));
globalAction = actionCollection()->addAction("mute");
globalAction->setText(i18n("Mute"));
globalAction->setGlobalShortcut(KShortcut(Qt::Key_VolumeMute));
connect(globalAction, SIGNAL(triggered(bool)), SLOT(slotMute()));
}
}
示例13: 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();
}
示例14: testComponentAssignment
void KGlobalShortcutTest::testComponentAssignment()
{
// We don't use them here
// setupTest();
KComponentData otherComponent("test_component1");
KActionCollection coll((QObject*)NULL);
coll.setComponentData(otherComponent);
KShortcut cutB;
/************************************************************
* Ensure that the actions get a correct component assigned *
************************************************************/
// Action without action collection get the global component
{
KAction action("Text For Action A", NULL);
action.setObjectName("Action C");
QVERIFY(action.d->componentData == KGlobal::mainComponent());
action.setGlobalShortcut(cutB, KAction::ActiveShortcut, KAction::NoAutoloading);
QVERIFY(action.d->componentData == KGlobal::mainComponent());
// cleanup
action.forgetGlobalShortcut();
}
// Action with action collection get the component of the collection
{
KAction *action = coll.addAction("Action C");
QVERIFY(action->d->componentData == otherComponent);
action->setGlobalShortcut(cutB, KAction::ActiveShortcut, KAction::NoAutoloading);
QVERIFY(action->d->componentData == otherComponent);
// cleanup
action->forgetGlobalShortcut();
delete action;
}
}
示例15: KNotesAdaptor
KNotesApp::KNotesApp()
: QWidget(), m_alarm( 0 ), m_listener( 0 ), m_publisher( 0 ), m_find( 0 ), m_findPos( 0 )
{
new KNotesAdaptor( this );
QDBusConnection::sessionBus().registerObject( "/KNotes" , this );
kapp->setQuitOnLastWindowClosed( false );
// create the dock widget...
m_tray = new KStatusNotifierItem(0);
m_tray->setToolTipTitle( i18n( "KNotes: Sticky notes for KDE" ) );
m_tray->setIconByName( "knotes" );
m_tray->setToolTipIconByName( "knotes" );
m_tray->setStatus( KStatusNotifierItem::Active );
m_tray->setCategory( KStatusNotifierItem::ApplicationStatus );
m_tray->setStandardActionsEnabled(false);
connect( m_tray, SIGNAL(activateRequested(bool,QPoint)), this, SLOT(slotActivateRequested(bool,QPoint)) );
connect( m_tray, SIGNAL(secondaryActivateRequested(QPoint)), this, SLOT(slotSecondaryActivateRequested(QPoint)) );
// set the initial style
#ifdef __GNUC__
#warning FIXME
#endif
// KNote::setStyle( KNotesGlobalConfig::style() );
// create the GUI...
KAction *action = new KAction( KIcon( "document-new" ),
i18n( "New Note" ), this );
actionCollection()->addAction( "new_note", action );
action->setGlobalShortcut( KShortcut( Qt::ALT + Qt::SHIFT + Qt::Key_N ));
connect( action, SIGNAL(triggered()), SLOT(newNote()) );
action = new KAction( KIcon( "edit-paste" ),
i18n( "New Note From Clipboard" ), this );
actionCollection()->addAction( "new_note_clipboard", action );
action->setGlobalShortcut( KShortcut( Qt::ALT + Qt::SHIFT + Qt::Key_C ));
connect( action, SIGNAL(triggered()), SLOT(newNoteFromClipboard()) );
action = new KAction( KIcon( "knotes" ), i18n( "Show All Notes" ), this );
actionCollection()->addAction( "show_all_notes", action );
action->setGlobalShortcut( KShortcut( Qt::ALT + Qt::SHIFT + Qt::Key_S ));
connect( action, SIGNAL(triggered()), SLOT(showAllNotes()) );
action = new KAction( KIcon( "window-close" ),
i18n( "Hide All Notes" ), this );
actionCollection()->addAction( "hide_all_notes", action );
action->setGlobalShortcut( KShortcut( Qt::ALT + Qt::SHIFT + Qt::Key_H ));
connect( action, SIGNAL(triggered()), SLOT(hideAllNotes()) );
new KHelpMenu( this, KGlobal::mainComponent().aboutData(), false,
actionCollection() );
m_findAction = KStandardAction::find( this, SLOT(slotOpenFindDialog()),
actionCollection() );
KStandardAction::preferences( this, SLOT(slotPreferences()),
actionCollection() );
KStandardAction::keyBindings( this, SLOT(slotConfigureAccels()),
actionCollection() );
//FIXME: no shortcut removing!?
KStandardAction::quit( this, SLOT(slotQuit()),
actionCollection() )->setShortcut( 0 );
setXMLFile( componentData().componentName() + "appui.rc" );
m_guiBuilder = new KXMLGUIBuilder( this );
m_guiFactory = new KXMLGUIFactory( m_guiBuilder, this );
m_guiFactory->addClient( this );
m_contextMenu = static_cast<KMenu *>( m_guiFactory->container(
"knotes_context",
this ) );
m_noteMenu = static_cast<KMenu *>( m_guiFactory->container(
"notes_menu", this ) );
m_tray->setContextMenu( m_contextMenu );
// get the most recent XML UI file
QString xmlFileName = componentData().componentName() + "ui.rc";
QString filter = componentData().componentName() + '/' + xmlFileName;
const QStringList fileList =
componentData().dirs()->findAllResources( "data", filter ) +
componentData().dirs()->findAllResources( "data", xmlFileName );
QString doc;
KXMLGUIClient::findMostRecentXMLFile( fileList, doc );
m_noteGUI.setContent( doc );
KConfigGroup config( KGlobal::config(), "Global Keybindings" );
// clean up old config files
KNotesLegacy::cleanUp();
// create the resource manager
m_manager = new KNotesResourceManager();
connect( m_manager, SIGNAL(sigRegisteredNote(KCal::Journal*)),
this, SLOT(createNote(KCal::Journal*)) );
connect( m_manager, SIGNAL(sigDeregisteredNote(KCal::Journal*)),
this, SLOT(killNote(KCal::Journal*)) );
// read the notes
m_manager->load();
//.........这里部分代码省略.........