Browse Source

init

tags/v1.0.0
Robin Thoni 9 years ago
commit
abf4bdb093
6 changed files with 444 additions and 0 deletions
  1. 20
    0
      calendar-window.pro
  2. 260
    0
      calendar-window.pro.user
  3. 62
    0
      main.cpp
  4. 33
    0
      mainwidget.cpp
  5. 32
    0
      mainwidget.h
  6. 37
    0
      mainwidget.ui

+ 20
- 0
calendar-window.pro View File

@@ -0,0 +1,20 @@
1
+#-------------------------------------------------
2
+#
3
+# Project created by QtCreator 2015-05-31T20:14:01
4
+#
5
+#-------------------------------------------------
6
+
7
+QT       += core gui
8
+
9
+greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
10
+
11
+TARGET = calendar-window
12
+TEMPLATE = app
13
+
14
+
15
+SOURCES += main.cpp\
16
+        mainwidget.cpp
17
+
18
+HEADERS  += mainwidget.h
19
+
20
+FORMS    += mainwidget.ui

+ 260
- 0
calendar-window.pro.user View File

@@ -0,0 +1,260 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<!DOCTYPE QtCreatorProject>
3
+<!-- Written by QtCreator 3.0.1, 2015-05-31T20:14:23. -->
4
+<qtcreator>
5
+ <data>
6
+  <variable>ProjectExplorer.Project.ActiveTarget</variable>
7
+  <value type="int">0</value>
8
+ </data>
9
+ <data>
10
+  <variable>ProjectExplorer.Project.EditorSettings</variable>
11
+  <valuemap type="QVariantMap">
12
+   <value type="bool" key="EditorConfiguration.AutoIndent">true</value>
13
+   <value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
14
+   <value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
15
+   <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
16
+    <value type="QString" key="language">Cpp</value>
17
+    <valuemap type="QVariantMap" key="value">
18
+     <value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
19
+    </valuemap>
20
+   </valuemap>
21
+   <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
22
+    <value type="QString" key="language">QmlJS</value>
23
+    <valuemap type="QVariantMap" key="value">
24
+     <value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
25
+    </valuemap>
26
+   </valuemap>
27
+   <value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
28
+   <value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
29
+   <value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
30
+   <value type="int" key="EditorConfiguration.IndentSize">4</value>
31
+   <value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
32
+   <value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
33
+   <value type="int" key="EditorConfiguration.PaddingMode">1</value>
34
+   <value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
35
+   <value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
36
+   <value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
37
+   <value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
38
+   <value type="int" key="EditorConfiguration.TabSize">8</value>
39
+   <value type="bool" key="EditorConfiguration.UseGlobal">true</value>
40
+   <value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
41
+   <value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
42
+   <value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
43
+   <value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
44
+   <value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
45
+  </valuemap>
46
+ </data>
47
+ <data>
48
+  <variable>ProjectExplorer.Project.PluginSettings</variable>
49
+  <valuemap type="QVariantMap"/>
50
+ </data>
51
+ <data>
52
+  <variable>ProjectExplorer.Project.Target.0</variable>
53
+  <valuemap type="QVariantMap">
54
+   <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop - Qt4</value>
55
+   <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop - Qt4</value>
56
+   <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{5feb06e2-1c9b-46d1-912f-beb5b4bc2562}</value>
57
+   <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
58
+   <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
59
+   <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
60
+   <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
61
+    <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/robin/projets/bin/calendar-window-Desktop_Qt4-Debug</value>
62
+    <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
63
+     <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
64
+      <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
65
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
66
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
67
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
68
+      <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
69
+      <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value>
70
+      <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
71
+      <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
72
+     </valuemap>
73
+     <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
74
+      <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
75
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
76
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
77
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
78
+      <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
79
+       <value type="QString">-w</value>
80
+       <value type="QString">-r</value>
81
+      </valuelist>
82
+      <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
83
+      <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
84
+      <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
85
+     </valuemap>
86
+     <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
87
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
88
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
89
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
90
+    </valuemap>
91
+    <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
92
+     <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
93
+      <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
94
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
95
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
96
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
97
+      <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
98
+       <value type="QString">-w</value>
99
+       <value type="QString">-r</value>
100
+      </valuelist>
101
+      <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
102
+      <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
103
+      <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
104
+     </valuemap>
105
+     <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
106
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
107
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
108
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
109
+    </valuemap>
110
+    <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
111
+    <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
112
+    <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
113
+    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Debug</value>
114
+    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
115
+    <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
116
+    <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
117
+    <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
118
+   </valuemap>
119
+   <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
120
+    <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/robin/projets/bin/calendar-window-Desktop_Qt4-Release</value>
121
+    <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
122
+     <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
123
+      <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
124
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
125
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
126
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
127
+      <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
128
+      <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value>
129
+      <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
130
+      <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
131
+     </valuemap>
132
+     <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
133
+      <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
134
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
135
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
136
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
137
+      <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
138
+       <value type="QString">-w</value>
139
+       <value type="QString">-r</value>
140
+      </valuelist>
141
+      <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
142
+      <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
143
+      <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
144
+     </valuemap>
145
+     <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
146
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
147
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
148
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
149
+    </valuemap>
150
+    <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
151
+     <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
152
+      <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
153
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
154
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
155
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
156
+      <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
157
+       <value type="QString">-w</value>
158
+       <value type="QString">-r</value>
159
+      </valuelist>
160
+      <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
161
+      <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
162
+      <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
163
+     </valuemap>
164
+     <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
165
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
166
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
167
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
168
+    </valuemap>
169
+    <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
170
+    <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
171
+    <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
172
+    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Release</value>
173
+    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
174
+    <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
175
+    <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
176
+    <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
177
+   </valuemap>
178
+   <value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">2</value>
179
+   <valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
180
+    <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
181
+     <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
182
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
183
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
184
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
185
+    </valuemap>
186
+    <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
187
+    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy locally</value>
188
+    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
189
+    <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
190
+   </valuemap>
191
+   <value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
192
+   <valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/>
193
+   <valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
194
+    <valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
195
+    <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
196
+    <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
197
+    <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
198
+    <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
199
+    <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
200
+    <value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
201
+    <value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
202
+    <value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
203
+    <value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value>
204
+    <value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
205
+    <valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
206
+    <value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value>
207
+    <value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
208
+    <value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value>
209
+    <value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
210
+    <value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
211
+    <valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
212
+     <value type="int">0</value>
213
+     <value type="int">1</value>
214
+     <value type="int">2</value>
215
+     <value type="int">3</value>
216
+     <value type="int">4</value>
217
+     <value type="int">5</value>
218
+     <value type="int">6</value>
219
+     <value type="int">7</value>
220
+     <value type="int">8</value>
221
+     <value type="int">9</value>
222
+     <value type="int">10</value>
223
+     <value type="int">11</value>
224
+     <value type="int">12</value>
225
+     <value type="int">13</value>
226
+     <value type="int">14</value>
227
+    </valuelist>
228
+    <value type="int" key="PE.EnvironmentAspect.Base">2</value>
229
+    <valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
230
+    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">calendar-window</value>
231
+    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
232
+    <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/home/robin/projets/calendar-window/calendar-window.pro</value>
233
+    <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
234
+    <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">calendar-window.pro</value>
235
+    <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value>
236
+    <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal">false</value>
237
+    <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value>
238
+    <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
239
+    <value type="bool" key="RunConfiguration.UseCppDebugger">true</value>
240
+    <value type="bool" key="RunConfiguration.UseCppDebuggerAuto">false</value>
241
+    <value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
242
+    <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
243
+    <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
244
+   </valuemap>
245
+   <value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
246
+  </valuemap>
247
+ </data>
248
+ <data>
249
+  <variable>ProjectExplorer.Project.TargetCount</variable>
250
+  <value type="int">1</value>
251
+ </data>
252
+ <data>
253
+  <variable>ProjectExplorer.Project.Updater.EnvironmentId</variable>
254
+  <value type="QByteArray">{2507e63c-ae51-4259-8bbb-dbe5f3c672bc}</value>
255
+ </data>
256
+ <data>
257
+  <variable>ProjectExplorer.Project.Updater.FileVersion</variable>
258
+  <value type="int">15</value>
259
+ </data>
260
+</qtcreator>

+ 62
- 0
main.cpp View File

@@ -0,0 +1,62 @@
1
+#include "mainwidget.h"
2
+#include <QApplication>
3
+#include <QDebug>
4
+
5
+int usage()
6
+{
7
+    qDebug() << "Usage: " << QFile(qApp->arguments().at(0)).fileName().toStdString().c_str()
8
+             << " ([--position=X-Y] [--size=WIDTH-HEIGHT] [--onLostFocus=(quit|ignore)]) | (--help|-h)";
9
+    qDebug() << "--size: WIDTH >= 300 && HEIGHT >= 210";
10
+    return 64;
11
+}
12
+
13
+int main(int argc, char *argv[])
14
+{
15
+    QApplication a(argc, argv);
16
+    MainWidget w;
17
+    QStringList args = qApp->arguments();
18
+    QRegExp reg_geo("--(position|size)=([0-9]+)\\-([0-9]+)");
19
+    QRegExp reg_focus("--onLostFocus=(quit|ignore)");
20
+    for (int i = 1; i < args.size(); ++i)
21
+    {
22
+        QString arg = args.at(i);
23
+        if (arg.contains(reg_geo))
24
+        {
25
+            int x = reg_geo.cap(2).toInt();
26
+            if (x < 300)
27
+            {
28
+                qDebug() << "WIDTH < 300:" << x;
29
+                return usage();
30
+            }
31
+            int y = reg_geo.cap(3).toInt();
32
+            if (y < 210)
33
+            {
34
+                qDebug() << "HEIGHT < 210:" << y;
35
+                return usage();
36
+            }
37
+            if (reg_geo.cap(1) == "position")
38
+            {
39
+                qDebug() << "Moving to" << x << y;
40
+                w.move(x, y);
41
+            }
42
+            else
43
+            {
44
+                qDebug() << "Resizing to" << x << y;
45
+                w.resize(x, y);
46
+            }
47
+        }
48
+        else if (arg.contains(reg_focus))
49
+            w.setExitOnLostFocus(reg_focus.cap(1) == "quit");
50
+        else if (arg == "--help" || arg == "-h")
51
+            return usage();
52
+        else
53
+        {
54
+            qWarning() << "Invalid argument:" << arg;
55
+            return usage();
56
+        }
57
+    }
58
+    qDebug() << "Geometry:" << w.geometry();
59
+    w.show();
60
+
61
+    return a.exec();
62
+}

+ 33
- 0
mainwidget.cpp View File

@@ -0,0 +1,33 @@
1
+#include "mainwidget.h"
2
+#include "ui_mainwidget.h"
3
+
4
+MainWidget::MainWidget(QWidget *parent) :
5
+    QWidget(parent),
6
+    ui(new Ui::MainWidget),
7
+    exitOnLostFocus(false)
8
+{
9
+    ui->setupUi(this);
10
+}
11
+
12
+MainWidget::~MainWidget()
13
+{
14
+    delete ui;
15
+}
16
+
17
+void MainWidget::setExitOnLostFocus(bool exit)
18
+{
19
+    exitOnLostFocus = exit;
20
+}
21
+
22
+bool MainWidget::event(QEvent *e)
23
+{
24
+    if (e->type() == QEvent::WindowDeactivate && exitOnLostFocus)
25
+        qApp->exit();
26
+    return QWidget::event(e);
27
+}
28
+
29
+void MainWidget::keyReleaseEvent(QKeyEvent *e)
30
+{
31
+    if (e->key() == Qt::Key_Escape)
32
+        qApp->exit();
33
+}

+ 32
- 0
mainwidget.h View File

@@ -0,0 +1,32 @@
1
+#ifndef MAINWIDGET_H
2
+#define MAINWIDGET_H
3
+
4
+#include <QWidget>
5
+#include <QKeyEvent>
6
+
7
+namespace Ui {
8
+class MainWidget;
9
+}
10
+
11
+class MainWidget : public QWidget
12
+{
13
+    Q_OBJECT
14
+
15
+public:
16
+    explicit MainWidget(QWidget *parent = 0);
17
+    ~MainWidget();
18
+
19
+    void setExitOnLostFocus(bool exit);
20
+
21
+protected:
22
+    bool event(QEvent* e);
23
+
24
+    void keyReleaseEvent(QKeyEvent* e);
25
+
26
+private:
27
+    Ui::MainWidget *ui;
28
+
29
+    bool exitOnLostFocus;
30
+};
31
+
32
+#endif // MAINWIDGET_H

+ 37
- 0
mainwidget.ui View File

@@ -0,0 +1,37 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<ui version="4.0">
3
+ <class>MainWidget</class>
4
+ <widget class="QWidget" name="MainWidget">
5
+  <property name="geometry">
6
+   <rect>
7
+    <x>0</x>
8
+    <y>0</y>
9
+    <width>264</width>
10
+    <height>142</height>
11
+   </rect>
12
+  </property>
13
+  <property name="windowTitle">
14
+   <string>MainWidget</string>
15
+  </property>
16
+  <layout class="QGridLayout" name="gridLayout">
17
+   <property name="leftMargin">
18
+    <number>0</number>
19
+   </property>
20
+   <property name="topMargin">
21
+    <number>0</number>
22
+   </property>
23
+   <property name="rightMargin">
24
+    <number>0</number>
25
+   </property>
26
+   <property name="bottomMargin">
27
+    <number>0</number>
28
+   </property>
29
+   <item row="0" column="0">
30
+    <widget class="QCalendarWidget" name="calendarWidget"/>
31
+   </item>
32
+  </layout>
33
+ </widget>
34
+ <layoutdefault spacing="6" margin="11"/>
35
+ <resources/>
36
+ <connections/>
37
+</ui>

Loading…
Cancel
Save