2 #include <kuniqueapplication.h>
4 #include <kcmdlineargs.h>
5 #include <kaboutdata.h>
7 #include <kglobalaccel.h>
8 #include <kactioncollection.h>
12 /* Die optimalen werte für hgap und vgap berechnen sich zu:
14 * gap = size%split + n*split
16 * für n = 0,1,2,... und size die Bildschirmgröße in der jeweiligen Richtung
19 int main(int argc, char **argv)
21 KAboutData * aboutdata = new KAboutData("kwingrid",
26 KAboutData::License_GPL,
27 ki18n("(C) 1999,2000,2002,2004 Stefan Bund"));
28 aboutdata->addAuthor(ki18n("Stefan Bund"),ki18n("Developer"),"stefab@j32.de",
31 KCmdLineOptions winGridOpts;
32 winGridOpts.add("split <width>", ki18n("split"), 0);
33 winGridOpts.add("ignorestruts <screen>", ki18n("ignorestruts"), "");
34 winGridOpts.add("+hgap", ki18n("hgap"), 0);
35 winGridOpts.add("+vgap", ki18n("vgap"), 0);
36 winGridOpts.add("+hsplit", ki18n("hsplit"), 0);
37 winGridOpts.add("+vsplit", ki18n("vsplit"), 0);
39 KCmdLineArgs::init(argc, argv, aboutdata);
40 KCmdLineArgs::addCmdLineOptions(winGridOpts);
41 KUniqueApplication::addCmdLineOptions();
43 if (! KUniqueApplication::start()) {
44 kdError() << "KWinGrid is already running!" << endl;
48 KApplication * app = new KUniqueApplication;
49 KCmdLineArgs * args = KCmdLineArgs::parsedArgs();
51 if (args->count()!=4) {
52 kdError() << "Invalid arguments. Try --help\n";
57 int ignorestruts = -1;
58 if (args->isSet("split"))
59 split = args->getOption("split").toInt();
61 if (args->isSet("ignorestruts"))
62 ignorestruts = args->getOption("ignorestruts").toInt();
64 if (args->count() != 4) {
65 std::cerr << "invalid number of arguments" << std::endl;
68 int hgap = args->arg(0).toInt();
69 int vgap = args->arg(1).toInt();
70 int hsplit = args->arg(2).toInt();
71 int vsplit = args->arg(3).toInt();
75 KWinGrid * winGrid = new KWinGrid(hgap,vgap,hsplit,vsplit,split,ignorestruts);
77 KActionCollection * actions = new KActionCollection(winGrid);
79 KAction * move_TL = new KAction(winGrid);
80 actions->addAction("Move top-left", move_TL);
81 move_TL->setHelpText("Move active window top-left");
82 move_TL->setGlobalShortcut(KShortcut(
83 Qt::ALT+Qt::SHIFT+Qt::Key_I, Qt::META+Qt::SHIFT+Qt::Key_I));
84 QObject::connect(move_TL, SIGNAL(triggered(bool)), winGrid, SLOT(move_TL()));
86 KAction * move_TR = new KAction(winGrid);
87 actions->addAction("Move top-right", move_TR);
88 move_TR->setHelpText("Move active window top-right");
89 move_TR->setGlobalShortcut(KShortcut(
90 Qt::ALT+Qt::SHIFT+Qt::Key_O, Qt::META+Qt::SHIFT+Qt::Key_O));
91 QObject::connect(move_TR, SIGNAL(triggered(bool)), winGrid, SLOT(move_TR()));
93 KAction * move_BL = new KAction(winGrid);
94 actions->addAction("Move bottom-left", move_BL);
95 move_BL->setHelpText("Move active window bottom-left");
96 move_BL->setGlobalShortcut(KShortcut(
97 Qt::ALT+Qt::SHIFT+Qt::Key_K, Qt::META+Qt::SHIFT+Qt::Key_K));
98 QObject::connect(move_BL, SIGNAL(triggered(bool)), winGrid, SLOT(move_BL()));
100 KAction * move_BR = new KAction(winGrid);
101 actions->addAction("Move bottom-right", move_BR);
102 move_BR->setHelpText("Move active window bottom-right");
103 move_BR->setGlobalShortcut(KShortcut(
104 Qt::ALT+Qt::SHIFT+Qt::Key_L, Qt::META+Qt::SHIFT+Qt::Key_L));
105 QObject::connect(move_BR, SIGNAL(triggered(bool)), winGrid, SLOT(move_BR()));
107 KAction * resize_Q = new KAction(winGrid);
108 actions->addAction("Resize quarter", resize_Q);
109 resize_Q->setHelpText("Resize quarter");
110 resize_Q->setGlobalShortcut(KShortcut(
111 Qt::ALT+Qt::CTRL+Qt::SHIFT+Qt::Key_I, Qt::META+Qt::CTRL+Qt::SHIFT+Qt::Key_I));
112 QObject::connect(resize_Q, SIGNAL(triggered(bool)), winGrid, SLOT(resize_Q()));
114 KAction * resize_H = new KAction(winGrid);
115 actions->addAction("Resize horizontal", resize_H);
116 resize_H->setHelpText("Resize horizontal");
117 resize_H->setGlobalShortcut(KShortcut(
118 Qt::ALT+Qt::CTRL+Qt::SHIFT+Qt::Key_O, Qt::META+Qt::CTRL+Qt::SHIFT+Qt::Key_O));
119 QObject::connect(resize_H, SIGNAL(triggered(bool)), winGrid, SLOT(resize_H()));
121 KAction * resize_V = new KAction(winGrid);
122 actions->addAction("Resize vertical", resize_V);
123 resize_V->setHelpText("Resize vertical");
124 resize_V->setGlobalShortcut(KShortcut(
125 Qt::ALT+Qt::CTRL+Qt::SHIFT+Qt::Key_K, Qt::META+Qt::CTRL+Qt::SHIFT+Qt::Key_K));
126 QObject::connect(resize_V, SIGNAL(triggered(bool)), winGrid, SLOT(resize_V()));
128 KAction * resize_F = new KAction(winGrid);
129 actions->addAction("Resize full", resize_F);
130 resize_F->setHelpText("Resize full");
131 resize_F->setGlobalShortcut(KShortcut(
132 Qt::ALT+Qt::CTRL+Qt::SHIFT+Qt::Key_L, Qt::META+Qt::CTRL+Qt::SHIFT+Qt::Key_L));
133 QObject::connect(resize_F, SIGNAL(triggered(bool)), winGrid, SLOT(resize_F()));
135 KAction * move_L = new KAction(winGrid);
136 actions->addAction("Move left", move_L);
137 move_L->setHelpText("Move left");
138 move_L->setGlobalShortcut(KShortcut(
139 Qt::ALT+Qt::SHIFT+Qt::Key_Left, Qt::META+Qt::SHIFT+Qt::Key_Left));
140 QObject::connect(move_L, SIGNAL(triggered(bool)), winGrid, SLOT(move_L()));
142 KAction * move_R = new KAction(winGrid);
143 actions->addAction("Move right", move_R);
144 move_R->setHelpText("Move right");
145 move_R->setGlobalShortcut(KShortcut(
146 Qt::ALT+Qt::SHIFT+Qt::Key_Right, Qt::META+Qt::SHIFT+Qt::Key_Right));
147 QObject::connect(move_R, SIGNAL(triggered(bool)), winGrid, SLOT(move_R()));
149 KAction * move_U = new KAction(winGrid);
150 actions->addAction("Move up", move_U);
151 move_U->setHelpText("Move up");
152 move_U->setGlobalShortcut(KShortcut(
153 Qt::ALT+Qt::SHIFT+Qt::Key_Up, Qt::META+Qt::SHIFT+Qt::Key_Up));
154 QObject::connect(move_U, SIGNAL(triggered(bool)), winGrid, SLOT(move_U()));
156 KAction * move_D = new KAction(winGrid);
157 actions->addAction("Move down", move_D);
158 move_D->setHelpText("Move down");
159 move_D->setGlobalShortcut(KShortcut(
160 Qt::ALT+Qt::SHIFT+Qt::Key_Down, Qt::META+Qt::SHIFT+Qt::Key_Down));
161 QObject::connect(move_D, SIGNAL(triggered(bool)), winGrid, SLOT(move_D()));
163 KAction * resize_IH = new KAction(winGrid);
164 actions->addAction("Increase horizontal size", resize_IH);
165 resize_IH->setHelpText("Increase horizontal size");
166 resize_IH->setGlobalShortcut(KShortcut(
167 Qt::ALT+Qt::CTRL+Qt::SHIFT+Qt::Key_Right,Qt::META+Qt::CTRL+Qt::SHIFT+Qt::Key_Right));
168 QObject::connect(resize_IH, SIGNAL(triggered(bool)), winGrid, SLOT(resize_IH()));
170 KAction * resize_IV = new KAction(winGrid);
171 actions->addAction("Increase vertical size", resize_IV);
172 resize_IV->setHelpText("Increase vertical size");
173 resize_IV->setGlobalShortcut(KShortcut(
174 Qt::ALT+Qt::CTRL+Qt::SHIFT+Qt::Key_Down,Qt::META+Qt::CTRL+Qt::SHIFT+Qt::Key_Down));
175 QObject::connect(resize_IV, SIGNAL(triggered(bool)), winGrid, SLOT(resize_IV()));
177 KAction * resize_DH = new KAction(winGrid);
178 actions->addAction("Decrease horizontal size", resize_DH);
179 resize_DH->setHelpText("Decrease horizontal size");
180 resize_DH->setGlobalShortcut(KShortcut(
181 Qt::ALT+Qt::CTRL+Qt::SHIFT+Qt::Key_Left,Qt::META+Qt::CTRL+Qt::SHIFT+Qt::Key_Left));
182 QObject::connect(resize_DH, SIGNAL(triggered(bool)), winGrid, SLOT(resize_DH()));
184 KAction * resize_DV = new KAction(resize_DV);
185 actions->addAction("Decrease vertical size", resize_DV);
186 resize_DV->setHelpText("Decrease vertical size");
187 resize_DV->setGlobalShortcut(KShortcut(
188 Qt::ALT+Qt::CTRL+Qt::SHIFT+Qt::Key_Up,Qt::META+Qt::CTRL+Qt::SHIFT+Qt::Key_Up));
189 QObject::connect(resize_DV, SIGNAL(triggered(bool)), winGrid, SLOT(resize_DV()));
191 int ret = app->exec();