KDE4 port
Stefan Bund [Thu, 10 Jun 2010 07:00:57 +0000 (09:00 +0200)]
.gitignore [new file with mode: 0644]
Makefile
kwingrid.cc
kwingrid.h
kwingrid_iface.h [deleted file]
main.cc

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..5b436f3
--- /dev/null
@@ -0,0 +1,4 @@
+*~
+*.moc
+*.o
+kwingrid
index 9eba9a7..ad053ac 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -6,17 +6,15 @@ kwingrid.moc
 OBJECTS=\
 main.o \
 kwingrid.o \
-kwingrid_iface_skel.o \
-kwingrid_iface_stub.o 
 
-LIBS=-lkdecore -lkdeui -lDCOP -lqt-mt -lX11 -lXext
+LIBS=-lkdecore -lkdeui -lQtCore -lQtGui -lX11 -lXext
 LOPTS=-L/usr/X11R6/lib -g
-COPTS=-I. -I /usr/include/kde -I /usr/include/qt3 -I /usr/include/X11 -O2 -Wall -g
+COPTS=-I. -I /usr/include/kde -I /usr/include/qt4 -I /usr/include/X11 -O2 -Wall -g
 
 all: mocs bin
 
 clean:
-       rm -f $(OBJECTS) $(MOCS) *_skel.cpp *_stub.h *_stub.cpp $(TARGET)
+       rm -f $(OBJECTS) $(MOCS) $(TARGET)
 
 bin: $(TARGET)
 
@@ -31,13 +29,5 @@ mocs: $(MOCS)
 %.o: %.cpp
        g++ $(COPTS) -c $< -o $@
 
-%.idl: %.h
-       dcopidl $< > $@
-
-%_skel.cpp %_stub.h %_stub.cpp: %.idl
-       dcopidl2cpp $<
-
 $(TARGET): $(OBJECTS)
        g++ $(LOPTS) -o $@ $(OBJECTS) $(LIBS)
-
-
index ed2823d..a97ec82 100644 (file)
@@ -1,21 +1,23 @@
 #include <iostream>
 
+#include <QtGui/QDesktopWidget>
+#include <QtGui/QX11Info>
+
 #include <kapplication.h>
-#include <dcopclient.h>
-#include <kwin.h>
-#include <Xlib.h>
-#include <Xutil.h>
+#include <kwindowsystem.h>
 #include <netwm_def.h>
 
 #include "kwingrid.h"
 #include "kwingrid.moc"
 
-KWinGrid::KWinGrid(int hgap__, int vgap__, int hsplit__, int vsplit__, int split__)
-    : DCOPObject("grid"), split_(split__), 
-      hgap_(hgap__), vgap_(vgap__), hsplit_(hsplit__), vsplit_(vsplit__)
+KWinGrid::KWinGrid(int hgap__, int vgap__, int hsplit__, int vsplit__, int split__,
+                   int ignorestruts__)
+    : split_(split__), ignorestruts_(ignorestruts__), hgap_(hgap__), vgap_(vgap__), hsplit_(hsplit__),
+      vsplit_(vsplit__)
+
 {
-    module_ = new KWinModule(KApplication::kApplication());
-    connect(module_,SIGNAL(activeWindowChanged(WId)),this,SLOT(activeWindowChanged(WId)));
+    connect(KWindowSystem::self(),SIGNAL(activeWindowChanged(WId)),
+           this,SLOT(activeWindowChanged(WId)));
 }
 
 void KWinGrid::move(int __xslot, int __yslot)
@@ -31,8 +33,8 @@ void KWinGrid::resize(int __xsize, int __ysize)
 void KWinGrid::toDesk(int __desk)
 {
     int w = activeWindow();
-    if (w) 
-       KWin::setOnDesktop(w,__desk);
+    if (w)
+       KWindowSystem::setOnDesktop(w,__desk);
 }
 
 void KWinGrid::quit()
@@ -42,8 +44,8 @@ void KWinGrid::quit()
 
 int KWinGrid::activeWindow()
 {
-    int av = module_->activeWindow();
-    KWin::WindowInfo info = KWin::windowInfo(av,NET::WMWindowType);
+    int av = KWindowSystem::activeWindow();
+    KWindowInfo info = KWindowSystem::windowInfo(av,NET::WMWindowType);
     if (info.windowType(NET::AllTypesMask) == NET::Desktop) return 0;
     return av;
 }
@@ -62,16 +64,16 @@ void KWinGrid::activeWindowChanged(WId id)
 
     int deltaDays = timestamp_.date().daysTo(tm.date());
     int deltaMSecs = timestamp_.time().msecsTo(tm.time());
-    
+
     if (deltaDays>2 || deltaDays<0) {
        activeWindow_ = 0;
        return;
     }
-    
+
     deltaMSecs += deltaDays * 1000*(60*60*24);
 
     if (deltaMSecs <= 300 && deltaMSecs > 0)
-       KWin::forceActiveWindow(activeWindow_);
+       KWindowSystem::forceActiveWindow(activeWindow_);
     else
        activeWindow_ = 0;
 }
@@ -96,15 +98,18 @@ void KWinGrid::moveRelative(int __xdiff, int __ydiff)
        xSlot += __xdiff;
        ySlot += __ydiff;
        if (xSlot<0) {
-           if (numScreens_ > 1 and screen_ > 0) {
-               initGeometry(screen_-1);
-               xSlot = hsplit_-1;
-               ySlot = (outer_.top()-region_.top()+vsize_/2)/vsize_ + __ydiff;
-           } else 
+           QPoint p (outer_.topLeft());
+           if (numScreens_ > 1 && p.x() > hsize_) {
+               p.rx() -= hsize_;
+               initGeometry( QApplication::desktop()->screenNumber(p) );
+           } else
                xSlot = 0;
        } else if (xSlot >= hsplit_) {
-           if (numScreens_ > 1 and screen_ < numScreens_-1) {
-               initGeometry(screen_+1);
+           QPoint p (outer_.topLeft());
+           QRect wa = KWindowSystem::workArea();
+           if (numScreens_ > 1 && p.x() + 2* hsize_ < wa.right()) {
+               p.rx() += 2*hsize_;
+               initGeometry( QApplication::desktop()->screenNumber(p) );
                xSlot = 0;
                ySlot = (outer_.top()-region_.top()+vsize_/2)/vsize_ + __ydiff;
            } else
@@ -146,7 +151,7 @@ QRect KWinGrid::doMoveResize(int __xslot, int __yslot,
                             int __xsize, int __ysize)
 {
     QRect newGeometry(outer_);
-    
+
     if (__xsize == -1) {
        __xsize = (outer_.width()+hsize_/2)/hsize_;
        if (__xsize<1) __xsize = 1;
@@ -157,7 +162,7 @@ QRect KWinGrid::doMoveResize(int __xslot, int __yslot,
        if (__ysize<1) __ysize = 1;
        if (__ysize>vsplit_) __ysize = vsplit_;
     }
-    
+
     newGeometry.setWidth(__xsize*hsize_-hgap_);
     newGeometry.setHeight(__ysize*vsize_-vgap_);
 
@@ -200,7 +205,7 @@ void KWinGrid::initGeometry(int __forceScreen)
     if (activeWindow_ == 0)
        activeWindow_ = activeWindow();
     if (activeWindow_) {
-       KWin::WindowInfo info(KWin::windowInfo(activeWindow_));
+       KWindowInfo info(KWindowSystem::windowInfo(activeWindow_,NET::WMGeometry|NET::WMFrameExtents));
        inner_ = info.geometry();
        outer_ = info.frameGeometry();
        orig_ = outer_;
@@ -223,8 +228,10 @@ void KWinGrid::initGeometry(int __forceScreen)
            region_ = QApplication::desktop()->screenGeometry(screen_);
            numScreens_ = QApplication::desktop()->numScreens();
        }
-       QRect wa = module_->workArea();
-       region_ = region_ & wa;
+       if (screen_ != ignorestruts_) {
+           QRect wa = KWindowSystem::workArea();
+           region_ = region_ & wa;
+       }
 
        hsize_ = (region_.width()-hgap_)/hsplit_;
        vsize_ = (region_.height()-vgap_)/vsplit_;
@@ -235,6 +242,12 @@ void KWinGrid::initGeometry(int __forceScreen)
        topLeft+=QPoint(hdelta/2,vdelta/2);
        region_.moveTopLeft(topLeft);
        region_.setSize(QSize(hsize_*hsplit_,vsize_*vsplit_));
+
+       long supplied;
+       if (XGetWMNormalHints(QX11Info::display(), activeWindow_, &hints_, &supplied))
+           hints_.flags &= supplied;
+       else
+           hints_.flags = 0;
     }
 }
 
@@ -248,29 +261,25 @@ void KWinGrid::updateGeometry(QRect& __new)
     inner_ = newInner;
     outer_ = __new;
 
-    XSizeHints hints;
-    long supplied;
-    if (XGetWMNormalHints(KApplication::kApplication()->getDisplay(), 
-                         activeWindow_, &hints, &supplied)) {
-       hints.flags &= supplied;
-       if (hints.flags & PResizeInc && hints.width_inc != 0 && hints.height_inc != 0) {
-           QSize base(0,0);
-           if (hints.flags & PBaseSize) {
-               base.setWidth(hints.base_width);
-               base.setHeight(hints.base_height);
-           } else if (hints.flags & PMinSize) {
-               base.setWidth(hints.min_width);
-               base.setHeight(hints.min_height);
-           }
-           QSize newSize(((inner_.width()-base.width())/hints.width_inc)*hints.width_inc + base.width(),
-                         ((inner_.height()-base.height())/hints.height_inc)*hints.height_inc + base.height());
-           QSize delta(inner_.size() - newSize);
-           QPoint offset(delta.width()/2,delta.height()/2);
-           inner_.setSize(newSize);
-           outer_.setSize(outer_.size() - delta);
-           inner_.moveTopLeft(inner_.topLeft() + offset);
-           outer_.moveTopLeft(outer_.topLeft() + offset);
+    if (hints_.flags & PResizeInc && hints_.width_inc != 0 && hints_.height_inc != 0) {
+       QSize base(0,0);
+       if (hints_.flags & PBaseSize) {
+           base.setWidth(hints_.base_width);
+           base.setHeight(hints_.base_height);
+       } else if (hints_.flags & PMinSize) {
+           base.setWidth(hints_.min_width);
+           base.setHeight(hints_.min_height);
        }
+       QSize newSize(((inner_.width()-base.width())/hints_.width_inc)*hints_.width_inc
+                     + base.width(),
+                     ((inner_.height()-base.height())/hints_.height_inc)*hints_.height_inc
+                     + base.height());
+       QSize delta(inner_.size() - newSize);
+       QPoint offset(delta.width()/2,delta.height()/2);
+       inner_.setSize(newSize);
+       outer_.setSize(outer_.size() - delta);
+       inner_.moveTopLeft(inner_.topLeft() + offset);
+       outer_.moveTopLeft(outer_.topLeft() + offset);
     }
 }
 
@@ -282,8 +291,7 @@ void KWinGrid::applyGeometry()
        // XMoveResizeWindow sometimes still moves the window a little
        // bit. Seems to have something todo with window gravity
        // ... we just leave the position allone in that case.
-       XResizeWindow(KApplication::kApplication()->getDisplay(),activeWindow_,
-                     inner_.width(),inner_.height());
+       XResizeWindow(QX11Info::display(),activeWindow_, inner_.width(),inner_.height());
     else {
        // I don't really know, whats all this stuff concerning window
        // gravity. I only know, this works for my openoffice windows,
@@ -292,11 +300,9 @@ void KWinGrid::applyGeometry()
        // NorthWestGravity on my desktop so did not check other
        // window gravities.
        QPoint pos = outer_.topLeft();
-       XWindowAttributes winAttributes;
-       if (XGetWindowAttributes(KApplication::kApplication()->getDisplay(),activeWindow_, 
-                                &winAttributes) && winAttributes.win_gravity == StaticGravity)
+       if (hints_.flags & PWinGravity && hints_.win_gravity == StaticGravity)
            pos = inner_.topLeft();
-       XMoveResizeWindow(KApplication::kApplication()->getDisplay(),activeWindow_,
+       XMoveResizeWindow(QX11Info::display(),activeWindow_,
                          pos.x(),pos.y(), inner_.width(),inner_.height());
     }
 }
@@ -323,7 +329,6 @@ void KWinGrid::move_BR()
     move(hsplit_/2,vsplit_/2);
 }
 
-    
 void KWinGrid::resize_Q()
 {
     resize(vsplit_/2,hsplit_/2);
@@ -344,7 +349,6 @@ void KWinGrid::resize_F()
     resize(vsplit_,hsplit_);
 }
 
-
 void KWinGrid::move_L()
 {
     moveRelative(-1,0);
@@ -365,7 +369,6 @@ void KWinGrid::move_D()
     moveRelative(0,1);
 }
 
-    
 void KWinGrid::resize_IH()
 {
     resizeRelative(1,0);
index 78d0733..66047e4 100644 (file)
@@ -3,22 +3,23 @@
 #ifndef __kwingrid_h
 #define __kwingrid_h 1
 
-#include <qobject.h>
-#include <qdatetime.h>
-#include <kwinmodule.h>
-#include <kwingrid_iface.h>
+#include <Xlib.h>
+#include <Xutil.h>
 
-class KWinGrid 
-    : public QObject, public virtual KWinGrid_Iface
+#include <QtCore/QObject>
+#include <QtCore/QDateTime>
+#include <QtCore/QRect>
+
+class KWinGrid : public QObject
 {
     Q_OBJECT
 
 public:
-    KWinGrid(int hgap__, int vgap__, int hsplit__, int vsplit__, int split__=0);
-    
+    KWinGrid(int hgap__, int vgap__, int hsplit__, int vsplit__, int split__=0, int ignorestruts__=-1);
+
     virtual void move(int __xslot, int __yslot);
     virtual void resize(int __xsize, int __ysize);
-    virtual void moveResize(int __xslot, int __yslot, 
+    virtual void moveResize(int __xslot, int __yslot,
                            int __xsize, int __ysize);
     virtual void moveRelative(int __xdiff, int __ydiff);
     virtual void resizeRelative(int __xdiff, int __ydiff);
@@ -33,7 +34,7 @@ public slots:
     void move_TR();
     void move_BL();
     void move_BR();
-    
+
     void resize_Q();
     void resize_H();
     void resize_V();
@@ -43,7 +44,7 @@ public slots:
     void move_R();
     void move_U();
     void move_D();
-    
+
     void resize_IH();
     void resize_DH();
     void resize_IV();
@@ -56,21 +57,20 @@ private:
     void initGeometry(int __forceScreens=-1);
     void updateGeometry(QRect& __new);
     void applyGeometry();
-    QRect doMoveResize(int __xslot, int __yslot, 
+    QRect doMoveResize(int __xslot, int __yslot,
                       int __xsize, int __ysize);
 
     void updateTimestamp(void);
-    
-    KWinModule* module_;
-    DCOPClient* client_;
 
     int split_;
+    int ignorestruts_;
 
     int activeWindow_;
     QRect inner_;
     QRect outer_;
     QRect orig_;
     QRect region_;
+    XSizeHints hints_;
     int screen_;
     int numScreens_;
 
diff --git a/kwingrid_iface.h b/kwingrid_iface.h
deleted file mode 100644 (file)
index a038732..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-#ifndef __kwingrid_iface_h
-#define __kwingrid_iface_h
-
-#include <qstring.h>
-#include <dcopobject.h>
-
-class KWinGrid_Iface : virtual public DCOPObject
-{
-    K_DCOP
-public:
-    virtual ~KWinGrid_Iface() {}
-
-k_dcop:
-    virtual void move(int __xslot, int __yslot) = 0;
-    virtual void resize(int __xsize, int __ysize) = 0;
-    virtual void moveResize(int __xslot, int __yslot, 
-                           int __xsize, int __ysize) = 0;
-    virtual void moveRelative(int __xdiff, int __ydiff) = 0;
-    virtual void resizeRelative(int __xdiff, int __ydiff) = 0;
-    virtual void toDesk(int __desk) = 0;
-
-    virtual void quit() = 0;
-    
-    virtual int activeWindow() = 0;
-};
-
-#endif
diff --git a/main.cc b/main.cc
index e68af52..850c4e2 100644 (file)
--- a/main.cc
+++ b/main.cc
@@ -1,24 +1,14 @@
-#include <stdlib.h>
+#include <iostream>
 #include <kuniqueapplication.h>
 #include <klocale.h>
 #include <kcmdlineargs.h>
 #include <kaboutdata.h>
 #include <kdebug.h>
 #include <kglobalaccel.h>
-#include <qnamespace.h>
+#include <kactioncollection.h>
 
 #include "kwingrid.h"
 
-static KCmdLineOptions winGridOpts[] =
-{
-    { "split <width>", I18N_NOOP("split"), 0 },
-    { "+hgap", I18N_NOOP("hgap"), 0 },
-    { "+vgap", I18N_NOOP("vgap"), 0 },
-    { "+hsplit", I18N_NOOP("hsplit"), 0 },
-    { "+vsplit", I18N_NOOP("vsplit"), 0 },
-    { 0,0,0 }
-};
-
 /* Die optimalen werte für hgap und vgap berechnen sich zu:
  *
  * gap = size%split + n*split
@@ -28,14 +18,24 @@ static KCmdLineOptions winGridOpts[] =
 
 int main(int argc, char **argv)
 {
-    KAboutData * aboutdata = new KAboutData("kwingrid","KWinGrid","0.5",
-                                           I18N_NOOP("Window Grid"),
+    KAboutData * aboutdata = new KAboutData("kwingrid",
+                                           "KWinGrid",
+                                           ki18n("Window Grid"),
+                                           "0.1",
+                                           KLocalizedString(),
                                            KAboutData::License_GPL,
-                                           "(C) 1999,2000,2002,2004 Stefan Bund",
-                                           "", "http://www.j32.de/");
-    aboutdata->addAuthor("Stefan Bund",I18N_NOOP("Developer"),"stefab@j32.de",
+                                           ki18n("(C) 1999,2000,2002,2004 Stefan Bund"));
+    aboutdata->addAuthor(ki18n("Stefan Bund"),ki18n("Developer"),"stefab@j32.de",
                         "http://www.j32.de");
   
+    KCmdLineOptions winGridOpts;
+    winGridOpts.add("split <width>", ki18n("split"), 0);
+    winGridOpts.add("ignorestruts <screen>", ki18n("ignorestruts"), "");
+    winGridOpts.add("+hgap", ki18n("hgap"), 0);
+    winGridOpts.add("+vgap", ki18n("vgap"), 0);
+    winGridOpts.add("+hsplit", ki18n("hsplit"), 0);
+    winGridOpts.add("+vsplit", ki18n("vsplit"), 0);
+
     KCmdLineArgs::init(argc, argv, aboutdata);
     KCmdLineArgs::addCmdLineOptions(winGridOpts);
     KUniqueApplication::addCmdLineOptions();
@@ -54,95 +54,139 @@ int main(int argc, char **argv)
     }
 
     int split = 0;
+    int ignorestruts = -1;
     if (args->isSet("split"))
-       split=args->getOption("split").toInt();
+       split = args->getOption("split").toInt();
+    
+    if (args->isSet("ignorestruts"))
+       ignorestruts = args->getOption("ignorestruts").toInt();
     
-    int hgap = atoi(args->arg(0));
-    int vgap = atoi(args->arg(1));
-    int hsplit = atoi(args->arg(2));
-    int vsplit = atoi(args->arg(3));
+    if (args->count() != 4) {
+       std::cerr << "invalid number of arguments" << std::endl;
+       return 1;
+    }
+    int hgap = args->arg(0).toInt();
+    int vgap = args->arg(1).toInt();
+    int hsplit = args->arg(2).toInt();
+    int vsplit = args->arg(3).toInt();
 
     args->clear();
 
-    KWinGrid * winGrid = new KWinGrid(hgap,vgap,hsplit,vsplit,split);
-
-    KGlobalAccel * accel = new KGlobalAccel(app);
-
-    accel->insert("move_TL",
-                 I18N_NOOP("Move top-left"),
-                 I18N_NOOP("Move active window top-left"),
-                 Qt::ALT+Qt::SHIFT+Qt::Key_I, KKey::QtWIN+Qt::SHIFT+Qt::Key_I,
-                 winGrid, SLOT ( move_TL() ));
-    accel->insert("move_TR",
-                 I18N_NOOP("Move top-right"),
-                 I18N_NOOP("Move active window top-right"),
-                 Qt::ALT+Qt::SHIFT+Qt::Key_O, KKey::QtWIN+Qt::SHIFT+Qt::Key_O,
-                 winGrid, SLOT ( move_TR() ));
-    accel->insert("move_BL",
-                 I18N_NOOP("Move bottom-left"),
-                 I18N_NOOP("Move active window bottom-left"),
-                 Qt::ALT+Qt::SHIFT+Qt::Key_K, KKey::QtWIN+Qt::SHIFT+Qt::Key_K,
-                 winGrid, SLOT ( move_BL() ));
-    accel->insert("move_BR",
-                 I18N_NOOP("Move bottom-right"),
-                 I18N_NOOP("Move active window bottom-right"),
-                 Qt::ALT+Qt::SHIFT+Qt::Key_L, KKey::QtWIN+Qt::SHIFT+Qt::Key_L,
-                 winGrid, SLOT ( move_BR() ));
-
-    accel->insert("resize_Q",
-                 I18N_NOOP("Resize quarter"), I18N_NOOP("Resize quarter"),
-                 Qt::ALT+Qt::CTRL+Qt::SHIFT+Qt::Key_I, KKey::QtWIN+Qt::CTRL+Qt::SHIFT+Qt::Key_I,
-                 winGrid, SLOT ( resize_Q() ));
-    accel->insert("resize_H",
-                 I18N_NOOP("Resize horizontal"), I18N_NOOP("Resize horizontal"),
-                 Qt::ALT+Qt::CTRL+Qt::SHIFT+Qt::Key_O, KKey::QtWIN+Qt::CTRL+Qt::SHIFT+Qt::Key_O,
-                 winGrid, SLOT ( resize_H() ));
-    accel->insert("resize_V",
-                 I18N_NOOP("Resize vertical"), I18N_NOOP("Resize vertical"),
-                 Qt::ALT+Qt::CTRL+Qt::SHIFT+Qt::Key_K, KKey::QtWIN+Qt::CTRL+Qt::SHIFT+Qt::Key_K,
-                 winGrid, SLOT ( resize_V() ));
-    accel->insert("resize_F",
-                 I18N_NOOP("Resize full"), I18N_NOOP("Resize full"),
-                 Qt::ALT+Qt::CTRL+Qt::SHIFT+Qt::Key_L, KKey::QtWIN+Qt::CTRL+Qt::SHIFT+Qt::Key_L,
-                 winGrid, SLOT ( resize_F() ));
-
-    accel->insert("move_L",
-                 I18N_NOOP("Move left"), I18N_NOOP("Move left"),
-                 Qt::ALT+Qt::SHIFT+Qt::Key_Left, KKey::QtWIN+Qt::SHIFT+Qt::Key_Left,
-                 winGrid, SLOT ( move_L() ));
-    accel->insert("move_R",
-                 I18N_NOOP("Move right"), I18N_NOOP("Move right"),
-                 Qt::ALT+Qt::SHIFT+Qt::Key_Right, KKey::QtWIN+Qt::SHIFT+Qt::Key_Right,
-                 winGrid, SLOT ( move_R() ));
-    accel->insert("move_U",
-                 I18N_NOOP("Move up"), I18N_NOOP("Move up"),
-                 Qt::ALT+Qt::SHIFT+Qt::Key_Up, KKey::QtWIN+Qt::SHIFT+Qt::Key_Up,
-                 winGrid, SLOT ( move_U() ));
-    accel->insert("move_D",
-                 I18N_NOOP("Move down"), I18N_NOOP("Move down"),
-                 Qt::ALT+Qt::SHIFT+Qt::Key_Down, KKey::QtWIN+Qt::SHIFT+Qt::Key_Down,
-                 winGrid, SLOT ( move_D() ));
-
-    accel->insert("resize_IH",
-                 I18N_NOOP("Increase horizontal size"), I18N_NOOP("Increase horizontal size"),
-                 Qt::ALT+Qt::CTRL+Qt::SHIFT+Qt::Key_Right,KKey::QtWIN+Qt::CTRL+Qt::SHIFT+Qt::Key_Right,
-                 winGrid, SLOT ( resize_IH() ));
-    accel->insert("resize_IV",
-                 I18N_NOOP("Increase vertical size"), I18N_NOOP("Increase vertical size"),
-                 Qt::ALT+Qt::CTRL+Qt::SHIFT+Qt::Key_Down,KKey::QtWIN+Qt::CTRL+Qt::SHIFT+Qt::Key_Down,
-                 winGrid, SLOT ( resize_IV() ));
-    accel->insert("resize_DH",
-                 I18N_NOOP("Decrease horizontal size"), I18N_NOOP("Decrease horizontal size"),
-                 Qt::ALT+Qt::CTRL+Qt::SHIFT+Qt::Key_Left,KKey::QtWIN+Qt::CTRL+Qt::SHIFT+Qt::Key_Left,
-                 winGrid, SLOT ( resize_DH() ));
-    accel->insert("resize_DV",
-                 I18N_NOOP("Decrease vertical size"), I18N_NOOP("Decrease vertical size"),
-                 Qt::ALT+Qt::CTRL+Qt::SHIFT+Qt::Key_Up,KKey::QtWIN+Qt::CTRL+Qt::SHIFT+Qt::Key_Up,
-                 winGrid, SLOT ( resize_DV() ));
-    
-    
-    accel->updateConnections();
+    KWinGrid * winGrid = new KWinGrid(hgap,vgap,hsplit,vsplit,split,ignorestruts);
 
+    KActionCollection * actions = new KActionCollection(winGrid);
+    
+    KAction * move_TL = new KAction(winGrid);
+    actions->addAction("Move top-left", move_TL);
+    move_TL->setHelpText("Move active window top-left");
+    move_TL->setGlobalShortcut(KShortcut(
+        Qt::ALT+Qt::SHIFT+Qt::Key_I, Qt::META+Qt::SHIFT+Qt::Key_I));
+    QObject::connect(move_TL, SIGNAL(triggered(bool)), winGrid, SLOT(move_TL()));
+
+    KAction * move_TR = new KAction(winGrid);
+    actions->addAction("Move top-right", move_TR);
+    move_TR->setHelpText("Move active window top-right");
+    move_TR->setGlobalShortcut(KShortcut(
+        Qt::ALT+Qt::SHIFT+Qt::Key_O, Qt::META+Qt::SHIFT+Qt::Key_O));
+    QObject::connect(move_TR, SIGNAL(triggered(bool)), winGrid, SLOT(move_TR()));
+
+    KAction * move_BL = new KAction(winGrid);
+    actions->addAction("Move bottom-left", move_BL);
+    move_BL->setHelpText("Move active window bottom-left");
+    move_BL->setGlobalShortcut(KShortcut(
+        Qt::ALT+Qt::SHIFT+Qt::Key_K, Qt::META+Qt::SHIFT+Qt::Key_K));
+    QObject::connect(move_BL, SIGNAL(triggered(bool)), winGrid, SLOT(move_BL()));
+
+    KAction * move_BR = new KAction(winGrid);
+    actions->addAction("Move bottom-right", move_BR);
+    move_BR->setHelpText("Move active window bottom-right");
+    move_BR->setGlobalShortcut(KShortcut(
+        Qt::ALT+Qt::SHIFT+Qt::Key_L, Qt::META+Qt::SHIFT+Qt::Key_L));
+    QObject::connect(move_BR, SIGNAL(triggered(bool)), winGrid, SLOT(move_BR()));
+
+    KAction * resize_Q = new KAction(winGrid);
+    actions->addAction("Resize quarter", resize_Q);
+    resize_Q->setHelpText("Resize quarter");
+    resize_Q->setGlobalShortcut(KShortcut(
+        Qt::ALT+Qt::CTRL+Qt::SHIFT+Qt::Key_I, Qt::META+Qt::CTRL+Qt::SHIFT+Qt::Key_I));
+    QObject::connect(resize_Q, SIGNAL(triggered(bool)), winGrid, SLOT(resize_Q()));
+
+    KAction * resize_H = new KAction(winGrid);
+    actions->addAction("Resize horizontal", resize_H);
+    resize_H->setHelpText("Resize horizontal");
+    resize_H->setGlobalShortcut(KShortcut(
+        Qt::ALT+Qt::CTRL+Qt::SHIFT+Qt::Key_O, Qt::META+Qt::CTRL+Qt::SHIFT+Qt::Key_O));
+    QObject::connect(resize_H, SIGNAL(triggered(bool)), winGrid, SLOT(resize_H()));
+
+    KAction * resize_V = new KAction(winGrid);
+    actions->addAction("Resize vertical", resize_V);
+    resize_V->setHelpText("Resize vertical");
+    resize_V->setGlobalShortcut(KShortcut(
+        Qt::ALT+Qt::CTRL+Qt::SHIFT+Qt::Key_K, Qt::META+Qt::CTRL+Qt::SHIFT+Qt::Key_K));
+    QObject::connect(resize_V, SIGNAL(triggered(bool)), winGrid, SLOT(resize_V()));
+
+    KAction * resize_F = new KAction(winGrid);
+    actions->addAction("Resize full", resize_F);
+    resize_F->setHelpText("Resize full");
+    resize_F->setGlobalShortcut(KShortcut(
+        Qt::ALT+Qt::CTRL+Qt::SHIFT+Qt::Key_L, Qt::META+Qt::CTRL+Qt::SHIFT+Qt::Key_L));
+    QObject::connect(resize_F, SIGNAL(triggered(bool)), winGrid, SLOT(resize_F()));
+
+    KAction * move_L = new KAction(winGrid);
+    actions->addAction("Move left", move_L);
+    move_L->setHelpText("Move left");
+    move_L->setGlobalShortcut(KShortcut(
+        Qt::ALT+Qt::SHIFT+Qt::Key_Left, Qt::META+Qt::SHIFT+Qt::Key_Left));
+    QObject::connect(move_L, SIGNAL(triggered(bool)), winGrid, SLOT(move_L()));
+
+    KAction * move_R = new KAction(winGrid);
+    actions->addAction("Move right", move_R);
+    move_R->setHelpText("Move right");
+    move_R->setGlobalShortcut(KShortcut(
+        Qt::ALT+Qt::SHIFT+Qt::Key_Right, Qt::META+Qt::SHIFT+Qt::Key_Right));
+    QObject::connect(move_R, SIGNAL(triggered(bool)), winGrid, SLOT(move_R()));
+
+    KAction * move_U = new KAction(winGrid);
+    actions->addAction("Move up", move_U);
+    move_U->setHelpText("Move up");
+    move_U->setGlobalShortcut(KShortcut(
+        Qt::ALT+Qt::SHIFT+Qt::Key_Up, Qt::META+Qt::SHIFT+Qt::Key_Up));
+    QObject::connect(move_U, SIGNAL(triggered(bool)), winGrid, SLOT(move_U()));
+
+    KAction * move_D = new KAction(winGrid);
+    actions->addAction("Move down", move_D);
+    move_D->setHelpText("Move down");
+    move_D->setGlobalShortcut(KShortcut(
+        Qt::ALT+Qt::SHIFT+Qt::Key_Down, Qt::META+Qt::SHIFT+Qt::Key_Down));
+    QObject::connect(move_D, SIGNAL(triggered(bool)), winGrid, SLOT(move_D()));
+
+    KAction * resize_IH = new KAction(winGrid);
+    actions->addAction("Increase horizontal size", resize_IH);
+    resize_IH->setHelpText("Increase horizontal size");
+    resize_IH->setGlobalShortcut(KShortcut(
+        Qt::ALT+Qt::CTRL+Qt::SHIFT+Qt::Key_Right,Qt::META+Qt::CTRL+Qt::SHIFT+Qt::Key_Right));
+    QObject::connect(resize_IH, SIGNAL(triggered(bool)), winGrid, SLOT(resize_IH()));
+
+    KAction * resize_IV = new KAction(winGrid);
+    actions->addAction("Increase vertical size", resize_IV);
+    resize_IV->setHelpText("Increase vertical size");
+    resize_IV->setGlobalShortcut(KShortcut(
+        Qt::ALT+Qt::CTRL+Qt::SHIFT+Qt::Key_Down,Qt::META+Qt::CTRL+Qt::SHIFT+Qt::Key_Down));
+    QObject::connect(resize_IV, SIGNAL(triggered(bool)), winGrid, SLOT(resize_IV()));
+
+    KAction * resize_DH = new KAction(winGrid);
+    actions->addAction("Decrease horizontal size", resize_DH);
+    resize_DH->setHelpText("Decrease horizontal size");
+    resize_DH->setGlobalShortcut(KShortcut(
+        Qt::ALT+Qt::CTRL+Qt::SHIFT+Qt::Key_Left,Qt::META+Qt::CTRL+Qt::SHIFT+Qt::Key_Left));
+    QObject::connect(resize_DH, SIGNAL(triggered(bool)), winGrid, SLOT(resize_DH()));
+
+    KAction * resize_DV = new KAction(resize_DV);
+    actions->addAction("Decrease vertical size", resize_DV);
+    resize_DV->setHelpText("Decrease vertical size");
+    resize_DV->setGlobalShortcut(KShortcut(
+        Qt::ALT+Qt::CTRL+Qt::SHIFT+Qt::Key_Up,Qt::META+Qt::CTRL+Qt::SHIFT+Qt::Key_Up));
+    QObject::connect(resize_DV, SIGNAL(triggered(bool)), winGrid, SLOT(resize_DV()));
 
     int ret = app->exec();