Advertisement
Guest User

jgoday

a guest
May 31st, 2009
326
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.85 KB | None | 0 0
  1. Index: workspace/krunner/interfaces/default/interface.cpp
  2. ===================================================================
  3. --- workspace/krunner/interfaces/default/interface.cpp  (revision 974496)
  4. +++ workspace/krunner/interfaces/default/interface.cpp  (working copy)
  5. @@ -130,6 +130,28 @@
  6.      QAction *focusEdit = new QAction(this);
  7.      focusEdit->setShortcut(Qt::Key_F6);
  8.  
  9. +    QActionGroup *moveActions = new QActionGroup(this);
  10. +
  11. +    QAction *upAction = new QAction(this);
  12. +    upAction->setShortcut(Qt::META | Qt::Key_Up);
  13. +    
  14. +    QAction *downAction = new QAction(this);
  15. +    downAction->setShortcut(Qt::META | Qt::Key_Down);
  16. +
  17. +    QAction *leftAction = new QAction(this);
  18. +    leftAction->setShortcut(Qt::META | Qt::Key_Left);
  19. +    
  20. +    QAction *rightAction = new QAction(this);
  21. +    rightAction->setShortcut(Qt::META | Qt::Key_Right);
  22. +
  23. +    moveActions->addAction(upAction);
  24. +    moveActions->addAction(downAction);
  25. +    moveActions->addAction(leftAction);
  26. +    moveActions->addAction(rightAction);
  27. +    addActions(moveActions->actions());
  28. +
  29. +    connect(moveActions, SIGNAL(triggered(QAction *)), SLOT(slotMove(QAction *)));
  30. +    
  31.      // in therory, the widget should detect the direction from the content
  32.      // but this is not available in Qt4.4/KDE 4.2, so the best default for this widget
  33.      // is LTR: as it's more or less a "command line interface"
  34. @@ -396,6 +418,31 @@
  35.      }
  36.  }
  37.  
  38. +void Interface::slotMove(QAction *action)
  39. +{
  40. +    int movement = 30;
  41. +
  42. +    int x = QWidget::pos().x();
  43. +    int y = QWidget::pos().y();
  44. +
  45. +    switch (action->shortcut()) {
  46. +        case Qt::META | Qt::Key_Up:
  47. +            if (y > 0) y -= movement;
  48. +            break;
  49. +        case Qt::META | Qt::Key_Down:
  50. +            if (y < QApplication::desktop()->screenGeometry().height() - height()) y += movement;
  51. +            break;
  52. +        case Qt::META | Qt::Key_Right:
  53. +            if (x < QApplication::desktop()->screenGeometry().width() - width()) x += movement;
  54. +            break;
  55. +        case Qt::META | Qt::Key_Left:
  56. +            if (x > 0) x -= movement;
  57. +            break;
  58. +    }
  59. +
  60. +    move(x, y);
  61. +}
  62. +
  63.  void Interface::setStaticQueryMode(bool staticQuery)
  64.  {
  65.      if (staticQuery) {
  66. @@ -427,7 +474,7 @@
  67.      }
  68.      e->accept();
  69.  }
  70. -
  71. +    
  72.  void Interface::run(ResultItem *item)
  73.  {
  74.      if (!item || item->group() < Plasma::QueryMatch::PossibleMatch) {
  75. Index: workspace/krunner/interfaces/default/interface.h
  76. ===================================================================
  77. --- workspace/krunner/interfaces/default/interface.h    (revision 974496)
  78. +++ workspace/krunner/interfaces/default/interface.h    (working copy)
  79. @@ -72,6 +72,7 @@
  80.          void resetInterface();
  81.          void showHelp();
  82.          void itemSelected();
  83. +        void slotMove(QAction *);
  84.  
  85.      private:
  86.          void centerOnScreen();
  87.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement