add move-to-screen shortcuts
[kwingrid.git] / main.cc
diff --git a/main.cc b/main.cc
index 2f944a2..51e4353 100644 (file)
--- a/main.cc
+++ b/main.cc
@@ -30,11 +30,13 @@ int main(int argc, char **argv)
 
     KCmdLineOptions winGridOpts;
     winGridOpts.add("split <width>", ki18n("split"), 0);
-    winGridOpts.add("ignorestruts <screen>", ki18n("ignorestruts"), "");
+    winGridOpts.add("ignorestruts <screen>", ki18n("ignorestruts. -1 = all screens"), "");
     winGridOpts.add("reserve-north <n>", ki18n("reserve north"), "");
     winGridOpts.add("reserve-south <n>", ki18n("reserve south"), "");
     winGridOpts.add("reserve-west <n>", ki18n("reserve west"), "");
     winGridOpts.add("reserve-east <n>", ki18n("reserve east"), "");
+    winGridOpts.add("southstrut <n>", ki18n("set south strut size"), "");
+    winGridOpts.add("strutscreen <n>", ki18n("set screen to apply manual strut to. -1 = all screens"), "");
     winGridOpts.add("+hgap", ki18n("hgap"), 0);
     winGridOpts.add("+vgap", ki18n("vgap"), 0);
     winGridOpts.add("+hsplit", ki18n("hsplit"), 0);
@@ -58,7 +60,7 @@ int main(int argc, char **argv)
     }
 
     int split = 0;
-    int ignorestruts = -1;
+    int ignorestruts = -2;
     if (args->isSet("split"))
         split = args->getOption("split").toInt();
 
@@ -70,6 +72,13 @@ int main(int argc, char **argv)
         return 1;
     }
 
+    int southstrut (0);
+    int strutscreen (-2);
+    if (args->isSet("southstrut"))
+        southstrut = args->getOption("southstrut").toInt();
+    if (args->isSet("strutscreen"))
+        strutscreen = args->getOption("strutscreen").toInt();
+
     int rn = 0;
     int rs = 0;
     int re = 0;
@@ -92,125 +101,122 @@ int main(int argc, char **argv)
     args->clear();
 
     KWinGrid * winGrid = new KWinGrid(hgap,vgap,hsplit,vsplit,split,ignorestruts,
-                                      rn, rs, rw, re);
+                                      rn, rs, rw, re, southstrut, strutscreen);
 
     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(winGrid);
-    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()));
+#define ACTION(pos, key, slot)                                          \
+    KAction * slot = new KAction(winGrid);                              \
+    actions->addAction("Move " pos, slot);                              \
+    slot->setHelpText("Move active window" pos);                        \
+    slot->setGlobalShortcut(KShortcut(                                  \
+        Qt::ALT+Qt::SHIFT+Qt::Key_ ## key, Qt::META+Qt::SHIFT+Qt::Key_ ## key)); \
+    QObject::connect(slot, SIGNAL(triggered(bool)), winGrid, SLOT(slot()))
+
+    ACTION("top-left", I, move_TL);
+    ACTION("top-right", O, move_TR);
+    ACTION("bottom-left", K, move_BL);
+    ACTION("bottom-right", L, move_BR);
+
+    ACTION("top-left (3x2 grid)", T, move32_00);
+    ACTION("top-middle (3x2 grid)", Y, move32_10);
+    ACTION("top-right (3x2 grid)", U, move32_20);
+    ACTION("bottom-left (3x2 grid)", G, move32_01);
+    ACTION("bottom-middle (3x2 grid)", H, move32_11);
+    ACTION("bottom-right (3x2 grid)", J, move32_21);
+
+    ACTION(" 0,0 (4x3 grid)", Q, move43_00);
+    ACTION(" 1,0 (4x3 grid)", W, move43_10);
+    ACTION(" 2,0 (4x3 grid)", E, move43_20);
+    ACTION(" 3,0 (4x3 grid)", R, move43_30);
+    ACTION(" 0,1 (4x3 grid)", A, move43_01);
+    ACTION(" 1,1 (4x3 grid)", S, move43_11);
+    ACTION(" 2,1 (4x3 grid)", D, move43_21);
+    ACTION(" 3,1 (4x3 grid)", F, move43_31);
+    ACTION(" 0,2 (4x3 grid)", Z, move43_02);
+    ACTION(" 1,2 (4x3 grid)", X, move43_12);
+    ACTION(" 2,2 (4x3 grid)", C, move43_22);
+    ACTION(" 3,2 (4x3 grid)", V, move43_32);
+
+#undef ACTION
+
+#define ACTION(pos, key, slot)                                          \
+    KAction * slot = new KAction(winGrid);                              \
+    actions->addAction("Move to Screen " pos, slot);                              \
+    slot->setHelpText("Move to Screen " pos);                        \
+    slot->setGlobalShortcut(KShortcut(                                  \
+        Qt::ALT+Qt::SHIFT+Qt::Key_ ## key, Qt::META+Qt::SHIFT+Qt::Key_ ## key)); \
+    QObject::connect(slot, SIGNAL(triggered(bool)), winGrid, SLOT(slot()))
+
+    ACTION("0", B, move_Screen0);
+    ACTION("1", M, move_Screen1);
+#undef ACTION
+
+#define ACTION(size, key, slot)                                         \
+    KAction * slot = new KAction(winGrid);                              \
+    actions->addAction("Resize " size, slot);                           \
+    slot->setHelpText("Resize " size);                                  \
+    slot->setGlobalShortcut(KShortcut(                                  \
+        Qt::ALT+Qt::CTRL+Qt::SHIFT+Qt::Key_ ## key, Qt::META+Qt::CTRL+Qt::SHIFT+Qt::Key_ ## key)); \
+    QObject::connect(slot, SIGNAL(triggered(bool)), winGrid, SLOT(slot()));
+
+    ACTION("quarter", I, resize_Q);
+
+    ACTION("horizontal", O, resize_H);
+    ACTION("vertical", K, resize_V);
+    ACTION("full", L, resize_F);
+
+    ACTION("top-left (3x2 grid)", T, resize32_00);
+    ACTION("top-middle (3x2 grid)", Y, resize32_10);
+    ACTION("top-right (3x2 grid)", U, resize32_20);
+    ACTION("bottom-left (3x2 grid)", G, resize32_01);
+    ACTION("bottom-middle (3x2 grid)", H, resize32_11);
+    ACTION("bottom-right (3x2 grid)", J, resize32_21);
+
+    ACTION(" 0,0 (4x3 grid)", Q, resize43_00);
+    ACTION(" 1,0 (4x3 grid)", W, resize43_10);
+    ACTION(" 2,0 (4x3 grid)", E, resize43_20);
+    ACTION(" 3,0 (4x3 grid)", R, resize43_30);
+    ACTION(" 0,1 (4x3 grid)", A, resize43_01);
+    ACTION(" 1,1 (4x3 grid)", S, resize43_11);
+    ACTION(" 2,1 (4x3 grid)", D, resize43_21);
+    ACTION(" 3,1 (4x3 grid)", F, resize43_31);
+    ACTION(" 0,2 (4x3 grid)", Z, resize43_02);
+    ACTION(" 1,2 (4x3 grid)", X, resize43_12);
+    ACTION(" 2,2 (4x3 grid)", C, resize43_22);
+    ACTION(" 3,2 (4x3 grid)", V, resize43_32);
+#undef ACTION
+
+#define ACTION(dir, key, slot)                                          \
+    KAction * slot = new KAction(winGrid);                              \
+    actions->addAction("Move " dir, slot);                              \
+    slot->setHelpText("Move " dir);                                     \
+    slot->setGlobalShortcut(KShortcut(                                  \
+        Qt::ALT+Qt::SHIFT+Qt::Key_ ## key, Qt::META+Qt::SHIFT+Qt::Key_ ## key)); \
+    QObject::connect(slot, SIGNAL(triggered(bool)), winGrid, SLOT(slot()));
+
+    ACTION("left", Left, move_L);
+    ACTION("right", Right, move_R);
+    ACTION("up", Up, move_U);
+    ACTION("down", Down, move_D);
+#undef ACTION
+
+#define ACTION(resize, key, slot)                                       \
+    KAction * slot = new KAction(winGrid);                              \
+    actions->addAction(resize " size", slot);                           \
+    slot->setHelpText(resize " size");                                  \
+    slot->setGlobalShortcut(KShortcut(                                  \
+        Qt::ALT+Qt::CTRL+Qt::SHIFT+Qt::Key_ ## key,Qt::META+Qt::CTRL+Qt::SHIFT+Qt::Key_ ## key)); \
+    QObject::connect(slot, SIGNAL(triggered(bool)), winGrid, SLOT(slot()));
+
+    ACTION("Increase horizontal", Right, resize_IH);
+    ACTION("Increase vertical", Down, resize_IV);
+    ACTION("Decrease horizontal", Left, resize_DH);
+    ACTION("Decrease vertical", Up, resize_DV);
+#undef ACTION
 
     int ret = app->exec();
 
     delete app;
     return ret;
 }
-