コード例 #1
0
ファイル: mousemark_config.cpp プロジェクト: lmurray/kwin
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
0
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
0
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
0
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
0
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
0
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
0
ファイル: mousemark.cpp プロジェクト: mgottschlag/kwin-tiling
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
0
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
0
ファイル: thumbnailaside.cpp プロジェクト: lmurray/kwin
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
0
ファイル: videorecord.cpp プロジェクト: lmurray/kwin
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
0
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
0
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
0
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
0
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
0
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();

  // read the old config files, convert and add them
  KCal::CalendarLocal calendar( QString::fromLatin1( "UTC" ) );
  if ( KNotesLegacy::convert( &calendar ) ) {
    KCal::Journal::List notes = calendar.journals();
    KCal::Journal::List::ConstIterator it;
    for ( it = notes.constBegin(); it != notes.constEnd(); ++it ) {
      m_manager->addNewNote( *it );
    }

    m_manager->save();
  }

  // set up the alarm reminder - do it after loading the notes because this
  // is used as a check if updateNoteActions has to be called for a new note
  m_alarm = new KNotesAlarm( m_manager, this );

   updateNetworkListener();

  if ( m_notes.size() == 0 && !kapp->isSessionRestored() ) {
      newNote();
  }

  updateNoteActions();
}
コード例 #16
0
ファイル: krunnerapp.cpp プロジェクト: fluxer/kde-workspace
void KRunnerApp::initialize()
{
    setWindowIcon(KIcon(QLatin1String("system-run")));

    setQuitOnLastWindowClosed(false);
    KCrash::setFlags(KCrash::AutoRestart);
    initializeStartupNotification();

    connect(KRunnerSettings::self(), SIGNAL(configChanged()), this, SLOT(reloadConfig()));

    m_runnerManager = new Plasma::RunnerManager;

    new AppAdaptor(this);
    QDBusConnection::sessionBus().registerObject(QLatin1String("/App"), this);

    // Global keys
    m_actionCollection = new KActionCollection(this);
    KAction* a = 0;

    a = m_actionCollection->addAction(QLatin1String("Run Command"));
    a->setText(i18n("Run Command"));
    a->setGlobalShortcut(KShortcut(Qt::ALT+Qt::Key_F2));
    connect(a, SIGNAL(triggered(bool)), SLOT(displayOrHide()));

    a = m_actionCollection->addAction(QLatin1String("Run Command on clipboard contents"));
    a->setText(i18n("Run Command on clipboard contents"));
    a->setGlobalShortcut(KShortcut(Qt::ALT+Qt::SHIFT+Qt::Key_F2));
    connect(a, SIGNAL(triggered(bool)), SLOT(displayWithClipboardContents()));

    a = m_actionCollection->addAction(QLatin1String("Show System Activity"));
    a->setText(i18n("Show System Activity"));
    a->setGlobalShortcut(KShortcut(Qt::CTRL+Qt::Key_Escape));
    connect(a, SIGNAL(triggered(bool)), SLOT(showTaskManager()));

    if (KAuthorized::authorize(QLatin1String("switch_user"))) {
        a = m_actionCollection->addAction(QLatin1String("Switch User"));
        a->setText(i18n("Switch User"));
        a->setGlobalShortcut(KShortcut(Qt::ALT+Qt::CTRL+Qt::Key_Insert));
        connect(a, SIGNAL(triggered(bool)), SLOT(switchUser()));
    }

    //Setup the interface after we have set up the actions
    switch (KRunnerSettings::interface()) {
        default:
        case KRunnerSettings::EnumInterface::CommandOriented:
            m_interface = new Interface(m_runnerManager);
            break;
        case KRunnerSettings::EnumInterface::TaskOriented:
            m_interface = new QsDialog(m_runnerManager);
            break;
    }

#ifdef Q_WS_X11
    //FIXME: if argb visuals enabled Qt will always set WM_CLASS as "qt-subapplication" no matter what
    //the application name is we set the proper XClassHint here, hopefully won't be necessary anymore when
    //qapplication will manage apps with argvisuals in a better way
    XClassHint classHint;
    classHint.res_name = const_cast<char*>("krunner");
    classHint.res_class = const_cast<char*>("krunner");
    XSetClassHint(QX11Info::display(), m_interface->winId(), &classHint);
#endif


    m_actionCollection->readSettings();
    //m_runnerManager->setAllowedRunners(QStringList() << "shell");
    m_runnerManager->reloadConfiguration(); // pre-load the runners

    // Single runner mode actions shortcuts

    foreach (const QString &runnerId, m_runnerManager->singleModeAdvertisedRunnerIds()) {
        a = m_actionCollection->addAction(runnerId);
        a->setText(i18nc("Run krunner restricting the search only to runner %1", "Run Command (runner \"%1\" only)",
                    m_runnerManager->runnerName(runnerId)));
        a->setGlobalShortcut(KShortcut());
        connect(a, SIGNAL(triggered(bool)), SLOT(singleRunnerModeActionTriggered()));
    }
}