jtkorhonen@0
|
1 /****************************************************************************
|
jtkorhonen@0
|
2 **
|
jtkorhonen@0
|
3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
jtkorhonen@0
|
4 ** All rights reserved.
|
jtkorhonen@0
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
|
jtkorhonen@0
|
6 **
|
jtkorhonen@0
|
7 ** This file is part of the examples of the Qt Toolkit.
|
jtkorhonen@0
|
8 **
|
jtkorhonen@0
|
9 ** $QT_BEGIN_LICENSE:LGPL$
|
jtkorhonen@0
|
10 ** Commercial Usage
|
jtkorhonen@0
|
11 ** Licensees holding valid Qt Commercial licenses may use this file in
|
jtkorhonen@0
|
12 ** accordance with the Qt Commercial License Agreement provided with the
|
jtkorhonen@0
|
13 ** Software or, alternatively, in accordance with the terms contained in
|
jtkorhonen@0
|
14 ** a written agreement between you and Nokia.
|
jtkorhonen@0
|
15 **
|
jtkorhonen@0
|
16 ** GNU Lesser General Public License Usage
|
jtkorhonen@0
|
17 ** Alternatively, this file may be used under the terms of the GNU Lesser
|
jtkorhonen@0
|
18 ** General Public License version 2.1 as published by the Free Software
|
jtkorhonen@0
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the
|
jtkorhonen@0
|
20 ** packaging of this file. Please review the following information to
|
jtkorhonen@0
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements
|
jtkorhonen@0
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
jtkorhonen@0
|
23 **
|
jtkorhonen@0
|
24 ** In addition, as a special exception, Nokia gives you certain additional
|
jtkorhonen@0
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception
|
jtkorhonen@0
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
jtkorhonen@0
|
27 **
|
jtkorhonen@0
|
28 ** GNU General Public License Usage
|
jtkorhonen@0
|
29 ** Alternatively, this file may be used under the terms of the GNU
|
jtkorhonen@0
|
30 ** General Public License version 3.0 as published by the Free Software
|
jtkorhonen@0
|
31 ** Foundation and appearing in the file LICENSE.GPL included in the
|
jtkorhonen@0
|
32 ** packaging of this file. Please review the following information to
|
jtkorhonen@0
|
33 ** ensure the GNU General Public License version 3.0 requirements will be
|
jtkorhonen@0
|
34 ** met: http://www.gnu.org/copyleft/gpl.html.
|
jtkorhonen@0
|
35 **
|
jtkorhonen@0
|
36 ** If you have questions regarding the use of this file, please contact
|
jtkorhonen@0
|
37 ** Nokia at qt-info@nokia.com.
|
jtkorhonen@0
|
38 ** $QT_END_LICENSE$
|
jtkorhonen@0
|
39 **
|
jtkorhonen@0
|
40 ** Copyright (C) Jari Korhonen, 2010 (HgExplorer specific parts, under lgpl)
|
jtkorhonen@0
|
41 *************************************************************************************/
|
jtkorhonen@0
|
42
|
jtkorhonen@0
|
43 #include <QtGui>
|
jtkorhonen@0
|
44 #include <QStringList>
|
jtkorhonen@0
|
45 #include <QDir>
|
jtkorhonen@0
|
46
|
jtkorhonen@0
|
47 #include "mainwindow.h"
|
jtkorhonen@0
|
48 #include "settingsdialog.h"
|
jtkorhonen@0
|
49
|
jtkorhonen@0
|
50
|
jtkorhonen@0
|
51 MainWindow::MainWindow()
|
jtkorhonen@0
|
52 {
|
jtkorhonen@0
|
53 QString wndTitle;
|
jtkorhonen@0
|
54
|
jtkorhonen@0
|
55 createActions();
|
jtkorhonen@0
|
56 createMenus();
|
jtkorhonen@0
|
57 createToolBars();
|
jtkorhonen@0
|
58 createStatusBar();
|
jtkorhonen@0
|
59
|
jtkorhonen@0
|
60 timerId = startTimer(200);
|
jtkorhonen@0
|
61 runner = new HgRunner(this);
|
jtkorhonen@0
|
62 runningAction = ACT_NONE;
|
jtkorhonen@0
|
63 statusBar()->addPermanentWidget(runner);
|
jtkorhonen@0
|
64
|
jtkorhonen@0
|
65 wndTitle.sprintf("%s %s", APPNAME, APPVERSION);
|
jtkorhonen@0
|
66 setWindowTitle(wndTitle);
|
jtkorhonen@0
|
67
|
jtkorhonen@0
|
68 remoteRepoPath = "";
|
jtkorhonen@0
|
69 workFolderPath = "";
|
jtkorhonen@0
|
70
|
jtkorhonen@0
|
71 readSettings();
|
jtkorhonen@0
|
72
|
jtkorhonen@0
|
73 tabPage = 0;
|
jtkorhonen@0
|
74 hgExp = new HgExpWidget((QWidget *) this, remoteRepoPath, workFolderPath, initialFileTypesBits);
|
jtkorhonen@0
|
75 setCentralWidget(hgExp);
|
jtkorhonen@0
|
76
|
jtkorhonen@0
|
77 setUnifiedTitleAndToolBarOnMac(true);
|
jtkorhonen@0
|
78 connectActions();
|
jtkorhonen@0
|
79 enableDisableActions();
|
jtkorhonen@0
|
80
|
jtkorhonen@0
|
81 if (firstStart)
|
jtkorhonen@0
|
82 {
|
jtkorhonen@0
|
83 QMessageBox::information(this, tr("First start todo"), tr("Going to \"Settings\" first."));
|
jtkorhonen@0
|
84 settings();
|
jtkorhonen@0
|
85 }
|
jtkorhonen@0
|
86
|
jtkorhonen@0
|
87 hgStat();
|
jtkorhonen@0
|
88 }
|
jtkorhonen@0
|
89
|
jtkorhonen@0
|
90
|
jtkorhonen@0
|
91 void MainWindow::closeEvent(QCloseEvent *)
|
jtkorhonen@0
|
92 {
|
jtkorhonen@0
|
93 writeSettings();
|
jtkorhonen@0
|
94 }
|
jtkorhonen@0
|
95
|
jtkorhonen@0
|
96
|
jtkorhonen@0
|
97 void MainWindow::about()
|
jtkorhonen@0
|
98 {
|
jtkorhonen@0
|
99 QMessageBox::about(this, tr("About HgExplorer"),
|
jtkorhonen@0
|
100 tr("<b>HgExplorer</b> tries to be Mercurial's <b>VSS Explorer:</b> ;-)<br><br>"
|
jtkorhonen@0
|
101 "-Hides command line in normal use<br>"
|
jtkorhonen@0
|
102 "-Makes common operations easier<br><br>"
|
jtkorhonen@0
|
103 "(c) 2010 (lgpl), Jari Korhonen (jtkorhonen@gmail.com)<br><br>"
|
jtkorhonen@0
|
104 "-Needs Mercurial ;-) (thanks Matt Mackall, Bryan O'Sullivan and others !)<br>"
|
jtkorhonen@0
|
105 "-Uses excellent Nuvola icons (c) David Vignoni (Thanks, David !)<br>"
|
jtkorhonen@0
|
106 "-Needs Qt4, mingw (in windows), python, kdiff3 (Thanks to all of you !)<br>"));
|
jtkorhonen@0
|
107 }
|
jtkorhonen@0
|
108
|
jtkorhonen@0
|
109
|
jtkorhonen@0
|
110 void MainWindow::hgStat()
|
jtkorhonen@0
|
111 {
|
jtkorhonen@0
|
112 if (hgStatAct -> isEnabled())
|
jtkorhonen@0
|
113 {
|
jtkorhonen@0
|
114 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
115 {
|
jtkorhonen@0
|
116 QStringList params;
|
jtkorhonen@0
|
117
|
jtkorhonen@0
|
118 QString statFlags = hgExp -> getStatFlags();
|
jtkorhonen@0
|
119 if (statFlags.isEmpty())
|
jtkorhonen@0
|
120 {
|
jtkorhonen@0
|
121 params << "stat";
|
jtkorhonen@0
|
122 }
|
jtkorhonen@0
|
123 else
|
jtkorhonen@0
|
124 {
|
jtkorhonen@0
|
125 params << "stat" << "-" + statFlags;
|
jtkorhonen@0
|
126 }
|
jtkorhonen@0
|
127
|
jtkorhonen@0
|
128
|
jtkorhonen@0
|
129 runner -> startProc(getHgBinaryName(), workFolderPath, params);
|
jtkorhonen@0
|
130 runningAction = ACT_STAT;
|
jtkorhonen@0
|
131 }
|
jtkorhonen@0
|
132 }
|
jtkorhonen@0
|
133 }
|
jtkorhonen@0
|
134
|
jtkorhonen@0
|
135 void MainWindow::hgHeads()
|
jtkorhonen@0
|
136 {
|
jtkorhonen@0
|
137 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
138 {
|
jtkorhonen@0
|
139 QStringList params;
|
jtkorhonen@0
|
140 params << "heads";
|
jtkorhonen@0
|
141
|
jtkorhonen@0
|
142 //on empty repos, "hg heads" will fail, don't care of that.
|
jtkorhonen@0
|
143 runner -> startProc(getHgBinaryName(), workFolderPath, params, false);
|
jtkorhonen@0
|
144 runningAction = ACT_HEADS;
|
jtkorhonen@0
|
145 }
|
jtkorhonen@0
|
146 }
|
jtkorhonen@0
|
147
|
jtkorhonen@0
|
148 void MainWindow::hgLog()
|
jtkorhonen@0
|
149 {
|
jtkorhonen@0
|
150 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
151 {
|
jtkorhonen@0
|
152 QStringList params;
|
jtkorhonen@0
|
153 params << "glog" << "--verbose";
|
jtkorhonen@0
|
154
|
jtkorhonen@0
|
155 runner -> startProc(getHgBinaryName(), workFolderPath, params);
|
jtkorhonen@0
|
156 runningAction = ACT_LOG;
|
jtkorhonen@0
|
157 }
|
jtkorhonen@0
|
158 }
|
jtkorhonen@0
|
159
|
jtkorhonen@0
|
160
|
jtkorhonen@0
|
161 void MainWindow::hgParents()
|
jtkorhonen@0
|
162 {
|
jtkorhonen@0
|
163 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
164 {
|
jtkorhonen@0
|
165 QStringList params;
|
jtkorhonen@0
|
166 params << "parents";
|
jtkorhonen@0
|
167
|
jtkorhonen@0
|
168 runner -> startProc(getHgBinaryName(), workFolderPath, params);
|
jtkorhonen@0
|
169 runningAction = ACT_PARENTS;
|
jtkorhonen@0
|
170 }
|
jtkorhonen@0
|
171 }
|
jtkorhonen@0
|
172
|
jtkorhonen@0
|
173
|
jtkorhonen@0
|
174
|
jtkorhonen@0
|
175 void MainWindow::hgRemove()
|
jtkorhonen@0
|
176 {
|
jtkorhonen@0
|
177 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
178 {
|
jtkorhonen@0
|
179 QStringList params;
|
jtkorhonen@0
|
180 QString currentFile = hgExp -> getCurrentFileListLine();
|
jtkorhonen@0
|
181
|
jtkorhonen@0
|
182 if (!currentFile.isEmpty())
|
jtkorhonen@0
|
183 {
|
jtkorhonen@6
|
184 if (QMessageBox::Ok == QMessageBox::warning(this, "Remove file", "Really remove file " + currentFile.mid(2) + "?",
|
jtkorhonen@6
|
185 QMessageBox::Ok | QMessageBox::Cancel, QMessageBox::Cancel))
|
jtkorhonen@6
|
186 {
|
jtkorhonen@6
|
187 params << "remove" << "--after" << "--force" << currentFile.mid(2); //Jump over status marker characters (e.g "M ")
|
jtkorhonen@0
|
188
|
jtkorhonen@6
|
189 runner -> startProc(getHgBinaryName(), workFolderPath, params);
|
jtkorhonen@6
|
190 runningAction = ACT_REMOVE;
|
jtkorhonen@6
|
191 }
|
jtkorhonen@0
|
192 }
|
jtkorhonen@0
|
193 }
|
jtkorhonen@0
|
194 }
|
jtkorhonen@0
|
195
|
jtkorhonen@0
|
196 void MainWindow::hgAnnotate()
|
jtkorhonen@0
|
197 {
|
jtkorhonen@0
|
198 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
199 {
|
jtkorhonen@0
|
200 QStringList params;
|
jtkorhonen@0
|
201 QString currentFile = hgExp -> getCurrentFileListLine();
|
jtkorhonen@0
|
202
|
jtkorhonen@0
|
203 if (!currentFile.isEmpty())
|
jtkorhonen@0
|
204 {
|
jtkorhonen@0
|
205 params << "annotate" << currentFile.mid(2); //Jump over status marker characters (e.g "M ")
|
jtkorhonen@0
|
206
|
jtkorhonen@0
|
207 runner -> startProc(getHgBinaryName(), workFolderPath, params);
|
jtkorhonen@0
|
208 runningAction = ACT_ANNOTATE;
|
jtkorhonen@0
|
209 }
|
jtkorhonen@0
|
210 }
|
jtkorhonen@0
|
211 }
|
jtkorhonen@0
|
212
|
jtkorhonen@0
|
213
|
jtkorhonen@0
|
214 void MainWindow::hgResolveMark()
|
jtkorhonen@0
|
215 {
|
jtkorhonen@0
|
216 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
217 {
|
jtkorhonen@0
|
218 QStringList params;
|
jtkorhonen@0
|
219 QString currentFile = hgExp -> getCurrentFileListLine();
|
jtkorhonen@0
|
220
|
jtkorhonen@0
|
221 if (!currentFile.isEmpty())
|
jtkorhonen@0
|
222 {
|
jtkorhonen@0
|
223 params << "resolve" << "--mark" << currentFile.mid(2); //Jump over status marker characters (e.g "M ")
|
jtkorhonen@0
|
224
|
jtkorhonen@0
|
225 runner -> startProc(getHgBinaryName(), workFolderPath, params);
|
jtkorhonen@0
|
226 runningAction = ACT_RESOLVE_MARK;
|
jtkorhonen@0
|
227 }
|
jtkorhonen@0
|
228 }
|
jtkorhonen@0
|
229 }
|
jtkorhonen@0
|
230
|
jtkorhonen@0
|
231
|
jtkorhonen@0
|
232
|
jtkorhonen@0
|
233 void MainWindow::hgResolveList()
|
jtkorhonen@0
|
234 {
|
jtkorhonen@0
|
235 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
236 {
|
jtkorhonen@0
|
237 QStringList params;
|
jtkorhonen@0
|
238
|
jtkorhonen@0
|
239 params << "resolve" << "--list";
|
jtkorhonen@0
|
240 runner -> startProc(getHgBinaryName(), workFolderPath, params);
|
jtkorhonen@0
|
241 runningAction = ACT_RESOLVE_LIST;
|
jtkorhonen@0
|
242 }
|
jtkorhonen@0
|
243 }
|
jtkorhonen@0
|
244
|
jtkorhonen@0
|
245
|
jtkorhonen@0
|
246
|
jtkorhonen@0
|
247 void MainWindow::hgAdd()
|
jtkorhonen@0
|
248 {
|
jtkorhonen@0
|
249 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
250 {
|
jtkorhonen@0
|
251 QStringList params;
|
jtkorhonen@0
|
252
|
jtkorhonen@5
|
253 QString currentFile = hgExp -> getCurrentFileListLine();
|
jtkorhonen@5
|
254
|
jtkorhonen@5
|
255 if (isSelectedUntracked(hgExp -> workFolderFileList))
|
jtkorhonen@5
|
256 {
|
jtkorhonen@5
|
257 //User wants to add one file
|
jtkorhonen@5
|
258 params << "add" << currentFile.mid(2);
|
jtkorhonen@5
|
259 }
|
jtkorhonen@5
|
260 else
|
jtkorhonen@5
|
261 {
|
jtkorhonen@5
|
262 //Add all untracked files
|
jtkorhonen@5
|
263 params << "add";
|
jtkorhonen@5
|
264 }
|
jtkorhonen@0
|
265
|
jtkorhonen@0
|
266 runner -> startProc(getHgBinaryName(), workFolderPath, params);
|
jtkorhonen@0
|
267 runningAction = ACT_ADD;
|
jtkorhonen@0
|
268 }
|
jtkorhonen@0
|
269 }
|
jtkorhonen@0
|
270
|
jtkorhonen@0
|
271 int MainWindow::getCommitComment(QString& comment)
|
jtkorhonen@0
|
272 {
|
jtkorhonen@0
|
273 int ret;
|
jtkorhonen@0
|
274
|
jtkorhonen@0
|
275 QDialog dlg(this);
|
jtkorhonen@0
|
276
|
jtkorhonen@0
|
277 QLabel *commentLabel = new QLabel(tr("Comment:"));
|
jtkorhonen@0
|
278 QLineEdit *commentEdit = new QLineEdit;
|
jtkorhonen@0
|
279 commentEdit -> setFixedWidth(400);
|
jtkorhonen@0
|
280 QHBoxLayout *commentLayout = new QHBoxLayout;
|
jtkorhonen@0
|
281 commentLayout -> addWidget(commentLabel);
|
jtkorhonen@0
|
282 commentLayout -> addWidget(commentEdit);
|
jtkorhonen@0
|
283
|
jtkorhonen@0
|
284 QPushButton *btnOk = new QPushButton(tr("Ok"));
|
jtkorhonen@0
|
285 QPushButton *btnCancel = new QPushButton(tr("Cancel"));
|
jtkorhonen@0
|
286 QHBoxLayout *btnLayout = new QHBoxLayout;
|
jtkorhonen@0
|
287 btnLayout -> addWidget(btnOk);
|
jtkorhonen@0
|
288 btnLayout -> addWidget(btnCancel);
|
jtkorhonen@0
|
289
|
jtkorhonen@0
|
290 QVBoxLayout *mainLayout = new QVBoxLayout;
|
jtkorhonen@0
|
291 mainLayout -> addLayout(commentLayout);
|
jtkorhonen@0
|
292 mainLayout -> addLayout(btnLayout);
|
jtkorhonen@0
|
293
|
jtkorhonen@0
|
294 dlg.setLayout(mainLayout);
|
jtkorhonen@0
|
295
|
jtkorhonen@0
|
296 dlg.setWindowTitle(tr("Save (commit)"));
|
jtkorhonen@0
|
297
|
jtkorhonen@0
|
298 connect(btnOk, SIGNAL(clicked()), &dlg, SLOT(accept()));
|
jtkorhonen@0
|
299 connect(btnCancel, SIGNAL(clicked()), &dlg, SLOT(reject()));
|
jtkorhonen@0
|
300
|
jtkorhonen@0
|
301 ret = dlg.exec();
|
jtkorhonen@0
|
302 comment = commentEdit -> text();
|
jtkorhonen@0
|
303 return ret;
|
jtkorhonen@0
|
304 }
|
jtkorhonen@0
|
305
|
jtkorhonen@0
|
306 void MainWindow::hgCommit()
|
jtkorhonen@0
|
307 {
|
jtkorhonen@0
|
308 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
309 {
|
jtkorhonen@0
|
310 QStringList params;
|
jtkorhonen@0
|
311 QString comment;
|
jtkorhonen@0
|
312
|
jtkorhonen@0
|
313 if (QDialog::Accepted == getCommitComment(comment))
|
jtkorhonen@0
|
314 {
|
jtkorhonen@0
|
315 if (!comment.isEmpty())
|
jtkorhonen@0
|
316 {
|
jtkorhonen@11
|
317 QString currentFile = hgExp -> getCurrentFileListLine();
|
jtkorhonen@11
|
318
|
jtkorhonen@11
|
319 if (isSelectedCommitable(hgExp -> workFolderFileList))
|
jtkorhonen@11
|
320 {
|
jtkorhonen@11
|
321 //User wants to commit only one file
|
jtkorhonen@11
|
322 params << "commit" << "--message" << comment << "--user" << userInfo << currentFile.mid(2);
|
jtkorhonen@11
|
323 }
|
jtkorhonen@11
|
324 else
|
jtkorhonen@11
|
325 {
|
jtkorhonen@11
|
326 //Commit all changes
|
jtkorhonen@11
|
327 params << "commit" << "--message" << comment << "--user" << userInfo;
|
jtkorhonen@11
|
328 }
|
jtkorhonen@0
|
329
|
jtkorhonen@0
|
330 runner -> startProc(getHgBinaryName(), workFolderPath, params);
|
jtkorhonen@0
|
331 runningAction = ACT_COMMIT;
|
jtkorhonen@0
|
332 }
|
jtkorhonen@0
|
333 }
|
jtkorhonen@0
|
334 }
|
jtkorhonen@0
|
335 }
|
jtkorhonen@0
|
336
|
jtkorhonen@0
|
337 void MainWindow::hgFileDiff()
|
jtkorhonen@0
|
338 {
|
jtkorhonen@0
|
339 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
340 {
|
jtkorhonen@0
|
341 QStringList params;
|
jtkorhonen@0
|
342
|
jtkorhonen@0
|
343 QString currentFile = hgExp -> getCurrentFileListLine();
|
jtkorhonen@0
|
344
|
jtkorhonen@0
|
345 if (!currentFile.isEmpty())
|
jtkorhonen@0
|
346 {
|
jtkorhonen@0
|
347 //Diff parent file against working folder file
|
jtkorhonen@0
|
348 params << "kdiff3" << currentFile.mid(2);
|
jtkorhonen@0
|
349 runner -> startProc(getHgBinaryName(), workFolderPath, params, false);
|
jtkorhonen@0
|
350 runningAction = ACT_FILEDIFF;
|
jtkorhonen@0
|
351 }
|
jtkorhonen@0
|
352 }
|
jtkorhonen@0
|
353 }
|
jtkorhonen@0
|
354
|
jtkorhonen@0
|
355
|
jtkorhonen@0
|
356 void MainWindow::hgFolderDiff()
|
jtkorhonen@0
|
357 {
|
jtkorhonen@0
|
358 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
359 {
|
jtkorhonen@0
|
360 QStringList params;
|
jtkorhonen@0
|
361
|
jtkorhonen@0
|
362 //Diff parent against working folder (folder diff)
|
jtkorhonen@0
|
363 params << "kdiff3";
|
jtkorhonen@0
|
364 runner -> startProc(getHgBinaryName(), workFolderPath, params, false);
|
jtkorhonen@0
|
365 runningAction = ACT_FOLDERDIFF;
|
jtkorhonen@0
|
366 }
|
jtkorhonen@0
|
367 }
|
jtkorhonen@0
|
368
|
jtkorhonen@0
|
369
|
jtkorhonen@0
|
370 void MainWindow::hgChgSetDiff()
|
jtkorhonen@0
|
371 {
|
jtkorhonen@0
|
372 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
373 {
|
jtkorhonen@0
|
374 QStringList params;
|
jtkorhonen@0
|
375
|
jtkorhonen@0
|
376 //Diff 2 history log versions against each other
|
jtkorhonen@0
|
377 QString revA;
|
jtkorhonen@0
|
378 QString revB;
|
jtkorhonen@0
|
379
|
jtkorhonen@0
|
380 hgExp -> getHistoryDiffRevisions(revA, revB);
|
jtkorhonen@0
|
381
|
jtkorhonen@0
|
382 if ((!revA.isEmpty()) && (!revB.isEmpty()))
|
jtkorhonen@0
|
383 {
|
jtkorhonen@0
|
384 params << "kdiff3" << "--rev" << revA << "--rev" << revB;
|
jtkorhonen@0
|
385 runner -> startProc(getHgBinaryName(), workFolderPath, params, false);
|
jtkorhonen@0
|
386 runningAction = ACT_CHGSETDIFF;
|
jtkorhonen@0
|
387 }
|
jtkorhonen@0
|
388 else
|
jtkorhonen@0
|
389 {
|
jtkorhonen@0
|
390 QMessageBox::information(this, tr("Changeset diff"), tr("Please select two changesets from history list or heads list first."));
|
jtkorhonen@0
|
391 }
|
jtkorhonen@0
|
392 }
|
jtkorhonen@0
|
393 }
|
jtkorhonen@0
|
394
|
jtkorhonen@0
|
395
|
jtkorhonen@0
|
396
|
jtkorhonen@0
|
397 void MainWindow::hgUpdate()
|
jtkorhonen@0
|
398 {
|
jtkorhonen@0
|
399 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
400 {
|
jtkorhonen@0
|
401 QStringList params;
|
jtkorhonen@0
|
402
|
jtkorhonen@0
|
403
|
jtkorhonen@0
|
404 params << "update";
|
jtkorhonen@0
|
405
|
jtkorhonen@0
|
406
|
jtkorhonen@0
|
407 runner -> startProc(getHgBinaryName(), workFolderPath, params);
|
jtkorhonen@0
|
408 runningAction = ACT_UPDATE;
|
jtkorhonen@0
|
409 }
|
jtkorhonen@0
|
410 }
|
jtkorhonen@0
|
411
|
jtkorhonen@0
|
412
|
jtkorhonen@0
|
413 void MainWindow::hgUpdateToRev()
|
jtkorhonen@0
|
414 {
|
jtkorhonen@0
|
415 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
416 {
|
jtkorhonen@0
|
417 QStringList params;
|
jtkorhonen@0
|
418 QString rev;
|
jtkorhonen@0
|
419
|
jtkorhonen@0
|
420 hgExp -> getUpdateToRevRevision(rev);
|
jtkorhonen@0
|
421
|
jtkorhonen@0
|
422 hgExp -> setCurrentIndex(WORKTAB);
|
jtkorhonen@0
|
423 enableDisableActions();
|
jtkorhonen@0
|
424
|
jtkorhonen@0
|
425 params << "update" << "--rev" << rev << "--clean";
|
jtkorhonen@0
|
426
|
jtkorhonen@0
|
427 runner -> startProc(getHgBinaryName(), workFolderPath, params);
|
jtkorhonen@0
|
428
|
jtkorhonen@0
|
429 runningAction = ACT_UPDATE;
|
jtkorhonen@0
|
430 }
|
jtkorhonen@0
|
431 }
|
jtkorhonen@0
|
432
|
jtkorhonen@0
|
433
|
jtkorhonen@0
|
434 void MainWindow::hgRevert()
|
jtkorhonen@0
|
435 {
|
jtkorhonen@0
|
436 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
437 {
|
jtkorhonen@0
|
438 QStringList params;
|
jtkorhonen@0
|
439 QString currentFile = hgExp -> getCurrentFileListLine();
|
jtkorhonen@0
|
440
|
jtkorhonen@5
|
441 params << "revert" << "--no-backup" << currentFile.mid(2);
|
jtkorhonen@0
|
442
|
jtkorhonen@0
|
443 runner -> startProc(getHgBinaryName(), workFolderPath, params);
|
jtkorhonen@0
|
444 runningAction = ACT_REVERT;
|
jtkorhonen@0
|
445 }
|
jtkorhonen@0
|
446 }
|
jtkorhonen@0
|
447
|
jtkorhonen@0
|
448 void MainWindow::hgMerge()
|
jtkorhonen@0
|
449 {
|
jtkorhonen@0
|
450 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
451 {
|
jtkorhonen@0
|
452 QStringList params;
|
jtkorhonen@0
|
453
|
jtkorhonen@0
|
454 params << "merge";
|
jtkorhonen@0
|
455
|
jtkorhonen@0
|
456 runner -> startProc(getHgBinaryName(), workFolderPath, params);
|
jtkorhonen@0
|
457 runningAction = ACT_MERGE;
|
jtkorhonen@0
|
458 }
|
jtkorhonen@0
|
459 }
|
jtkorhonen@0
|
460
|
jtkorhonen@0
|
461
|
jtkorhonen@0
|
462 void MainWindow::hgCloneFromRemote()
|
jtkorhonen@0
|
463 {
|
jtkorhonen@0
|
464 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
465 {
|
jtkorhonen@0
|
466 QStringList params;
|
jtkorhonen@0
|
467
|
jtkorhonen@0
|
468 params << "clone" << remoteRepoPath << workFolderPath;
|
jtkorhonen@0
|
469
|
jtkorhonen@0
|
470 runner -> startProc(getHgBinaryName(), workFolderPath, params);
|
jtkorhonen@0
|
471 runningAction = ACT_CLONEFROMREMOTE;
|
jtkorhonen@0
|
472 }
|
jtkorhonen@0
|
473 }
|
jtkorhonen@0
|
474
|
jtkorhonen@0
|
475
|
jtkorhonen@0
|
476 void MainWindow::hgInit()
|
jtkorhonen@0
|
477 {
|
jtkorhonen@0
|
478 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
479 {
|
jtkorhonen@0
|
480 QStringList params;
|
jtkorhonen@0
|
481
|
jtkorhonen@0
|
482 params << "init";
|
jtkorhonen@0
|
483
|
jtkorhonen@0
|
484 runner -> startProc(getHgBinaryName(), workFolderPath, params);
|
jtkorhonen@0
|
485 runningAction = ACT_INIT;
|
jtkorhonen@0
|
486 }
|
jtkorhonen@0
|
487 }
|
jtkorhonen@0
|
488
|
jtkorhonen@0
|
489
|
jtkorhonen@0
|
490 void MainWindow::hgIncoming()
|
jtkorhonen@0
|
491 {
|
jtkorhonen@0
|
492 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
493 {
|
jtkorhonen@0
|
494 QStringList params;
|
jtkorhonen@0
|
495
|
jtkorhonen@0
|
496 params << "incoming" << "--newest-first" << remoteRepoPath;
|
jtkorhonen@0
|
497
|
jtkorhonen@0
|
498 runner -> startProc(getHgBinaryName(), workFolderPath, params, false);
|
jtkorhonen@0
|
499 runningAction = ACT_INCOMING;
|
jtkorhonen@0
|
500 }
|
jtkorhonen@0
|
501 }
|
jtkorhonen@0
|
502
|
jtkorhonen@0
|
503
|
jtkorhonen@0
|
504 void MainWindow::hgPull()
|
jtkorhonen@0
|
505 {
|
jtkorhonen@0
|
506 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
507 {
|
jtkorhonen@0
|
508 QStringList params;
|
jtkorhonen@0
|
509
|
jtkorhonen@0
|
510 params << "pull" << remoteRepoPath;
|
jtkorhonen@0
|
511
|
jtkorhonen@0
|
512 runner -> startProc(getHgBinaryName(), workFolderPath, params);
|
jtkorhonen@0
|
513 runningAction = ACT_PULL;
|
jtkorhonen@0
|
514 }
|
jtkorhonen@0
|
515 }
|
jtkorhonen@0
|
516
|
jtkorhonen@0
|
517
|
jtkorhonen@0
|
518 void MainWindow::hgPush()
|
jtkorhonen@0
|
519 {
|
jtkorhonen@0
|
520 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
521 {
|
jtkorhonen@0
|
522 QStringList params;
|
jtkorhonen@0
|
523
|
jtkorhonen@0
|
524 params << "push" << remoteRepoPath;
|
jtkorhonen@0
|
525
|
jtkorhonen@0
|
526 runner -> startProc(getHgBinaryName(), workFolderPath, params);
|
jtkorhonen@0
|
527 runningAction = ACT_PUSH;
|
jtkorhonen@0
|
528 }
|
jtkorhonen@0
|
529 }
|
jtkorhonen@0
|
530
|
jtkorhonen@0
|
531
|
jtkorhonen@11
|
532 void MainWindow::hgServe()
|
jtkorhonen@11
|
533 {
|
jtkorhonen@11
|
534 if (runningAction == ACT_NONE)
|
jtkorhonen@11
|
535 {
|
jtkorhonen@11
|
536 QStringList params;
|
jtkorhonen@11
|
537
|
jtkorhonen@11
|
538 params << "serve";
|
jtkorhonen@11
|
539
|
jtkorhonen@11
|
540 runner -> startProc(getHgBinaryName(), workFolderPath, params, false);
|
jtkorhonen@11
|
541 runningAction = ACT_SERVE;
|
jtkorhonen@11
|
542
|
jtkorhonen@11
|
543 QMessageBox::information(this, "Serve", "Server running", QMessageBox::Close);
|
jtkorhonen@11
|
544 runner -> killProc();
|
jtkorhonen@11
|
545 }
|
jtkorhonen@11
|
546 }
|
jtkorhonen@11
|
547
|
jtkorhonen@11
|
548
|
jtkorhonen@11
|
549
|
jtkorhonen@0
|
550 void MainWindow::settings()
|
jtkorhonen@0
|
551 {
|
jtkorhonen@0
|
552 SettingsDialog *settingsDlg = new SettingsDialog(this);
|
jtkorhonen@0
|
553 settingsDlg->setModal(true);
|
jtkorhonen@0
|
554 settingsDlg->exec();
|
jtkorhonen@0
|
555 hgExp -> clearLists();
|
jtkorhonen@0
|
556 enableDisableActions();
|
jtkorhonen@0
|
557 hgStat();
|
jtkorhonen@0
|
558 }
|
jtkorhonen@0
|
559
|
jtkorhonen@2
|
560 #define STDOUT_NEEDS_BIG_WINDOW 512
|
jtkorhonen@2
|
561 #define SMALL_WND_W 500
|
jtkorhonen@2
|
562 #define SMALL_WND_H 300
|
jtkorhonen@2
|
563
|
jtkorhonen@2
|
564 #define BIG_WND_W 1024
|
jtkorhonen@2
|
565 #define BIG_WND_H 768
|
jtkorhonen@2
|
566
|
jtkorhonen@2
|
567
|
jtkorhonen@2
|
568 void MainWindow::presentLongStdoutToUser(QString stdo)
|
jtkorhonen@0
|
569 {
|
jtkorhonen@2
|
570 if (!stdo.isEmpty())
|
jtkorhonen@2
|
571 {
|
jtkorhonen@2
|
572 QDialog dlg;
|
jtkorhonen@0
|
573
|
jtkorhonen@2
|
574 if (stdo.length() > STDOUT_NEEDS_BIG_WINDOW)
|
jtkorhonen@2
|
575 {
|
jtkorhonen@2
|
576 dlg.setMinimumWidth(BIG_WND_W);
|
jtkorhonen@2
|
577 dlg.setMinimumHeight(BIG_WND_H);
|
jtkorhonen@2
|
578 }
|
jtkorhonen@2
|
579 else
|
jtkorhonen@2
|
580 {
|
jtkorhonen@2
|
581 dlg.setMinimumWidth(SMALL_WND_W);
|
jtkorhonen@2
|
582 dlg.setMinimumHeight(SMALL_WND_H);
|
jtkorhonen@2
|
583 }
|
jtkorhonen@0
|
584
|
jtkorhonen@2
|
585 QVBoxLayout *box = new QVBoxLayout;
|
jtkorhonen@2
|
586 QListWidget *list = new QListWidget;
|
jtkorhonen@2
|
587 list-> addItems(stdo.split("\n"));
|
jtkorhonen@2
|
588 QPushButton *btn = new QPushButton(tr("Ok"));
|
jtkorhonen@2
|
589 connect(btn, SIGNAL(clicked()), &dlg, SLOT(accept()));
|
jtkorhonen@0
|
590
|
jtkorhonen@2
|
591 box -> addWidget(list);
|
jtkorhonen@2
|
592 box -> addWidget(btn);
|
jtkorhonen@2
|
593 dlg.setLayout(box);
|
jtkorhonen@2
|
594
|
jtkorhonen@2
|
595 dlg.exec();
|
jtkorhonen@2
|
596 }
|
jtkorhonen@2
|
597 else
|
jtkorhonen@2
|
598 {
|
jtkorhonen@2
|
599 QMessageBox::information(this, tr("HgExplorer"), tr("Mercurial command did not return any output."));
|
jtkorhonen@2
|
600 }
|
jtkorhonen@0
|
601 }
|
jtkorhonen@0
|
602
|
jtkorhonen@0
|
603
|
jtkorhonen@11
|
604 bool MainWindow::isSelectedCommitable(QListWidget *workList)
|
jtkorhonen@11
|
605 {
|
jtkorhonen@11
|
606 QList<QListWidgetItem *> selList = workList -> selectedItems();
|
jtkorhonen@11
|
607 if (selList.count() == 1)
|
jtkorhonen@11
|
608 {
|
jtkorhonen@11
|
609 QString tmp = selList.at(0)->text().mid(0, 1);
|
jtkorhonen@11
|
610 if (tmp == "A")
|
jtkorhonen@11
|
611 {
|
jtkorhonen@11
|
612 //scheduled to be added, ok to commit
|
jtkorhonen@11
|
613 return true;
|
jtkorhonen@11
|
614 }
|
jtkorhonen@11
|
615 else if (tmp == "M")
|
jtkorhonen@11
|
616 {
|
jtkorhonen@11
|
617 //locally modified, ok to commit
|
jtkorhonen@11
|
618 return true;
|
jtkorhonen@11
|
619 }
|
jtkorhonen@11
|
620 }
|
jtkorhonen@11
|
621 return false;
|
jtkorhonen@11
|
622 }
|
jtkorhonen@11
|
623
|
jtkorhonen@6
|
624 bool MainWindow::isSelectedDeletable(QListWidget *workList)
|
jtkorhonen@0
|
625 {
|
jtkorhonen@0
|
626 QList<QListWidgetItem *> selList = workList -> selectedItems();
|
jtkorhonen@0
|
627 if (selList.count() == 1)
|
jtkorhonen@0
|
628 {
|
jtkorhonen@6
|
629 QString tmp = selList.at(0)->text().mid(0, 1);
|
jtkorhonen@6
|
630 if (tmp == "A")
|
jtkorhonen@0
|
631 {
|
jtkorhonen@6
|
632 //scheduled to be added, ok to remove (won't go to repo)
|
jtkorhonen@6
|
633 return true;
|
jtkorhonen@6
|
634 }
|
jtkorhonen@6
|
635 else if (tmp == "C")
|
jtkorhonen@6
|
636 {
|
jtkorhonen@6
|
637 //Tracked but unchanged, ok to remove
|
jtkorhonen@6
|
638 return true;
|
jtkorhonen@6
|
639 }
|
jtkorhonen@6
|
640 else if (tmp == "M")
|
jtkorhonen@6
|
641 {
|
jtkorhonen@6
|
642 //locally modified, ok to remove from repo
|
jtkorhonen@6
|
643 return true;
|
jtkorhonen@6
|
644 }
|
jtkorhonen@6
|
645 else if (tmp == "!")
|
jtkorhonen@6
|
646 {
|
jtkorhonen@6
|
647 //locally deleted, ok to remove from repo
|
jtkorhonen@0
|
648 return true;
|
jtkorhonen@0
|
649 }
|
jtkorhonen@0
|
650 }
|
jtkorhonen@0
|
651 return false;
|
jtkorhonen@0
|
652 }
|
jtkorhonen@0
|
653
|
jtkorhonen@0
|
654
|
jtkorhonen@0
|
655 bool MainWindow::isSelectedUntracked(QListWidget *workList)
|
jtkorhonen@0
|
656 {
|
jtkorhonen@0
|
657 QList<QListWidgetItem *> selList = workList -> selectedItems();
|
jtkorhonen@0
|
658 if (selList.count() == 1)
|
jtkorhonen@0
|
659 {
|
jtkorhonen@0
|
660 if (selList.at(0)->text().mid(0, 1) == "?")
|
jtkorhonen@0
|
661 {
|
jtkorhonen@0
|
662 return true;
|
jtkorhonen@0
|
663 }
|
jtkorhonen@0
|
664 }
|
jtkorhonen@0
|
665 return false;
|
jtkorhonen@0
|
666 }
|
jtkorhonen@0
|
667
|
jtkorhonen@0
|
668
|
jtkorhonen@0
|
669 bool MainWindow::isSelectedModified(QListWidget *workList)
|
jtkorhonen@0
|
670 {
|
jtkorhonen@0
|
671 QList<QListWidgetItem *> selList = workList -> selectedItems();
|
jtkorhonen@0
|
672 if (selList.count() == 1)
|
jtkorhonen@0
|
673 {
|
jtkorhonen@0
|
674 if (selList.at(0)->text().mid(0, 1) == "M")
|
jtkorhonen@0
|
675 {
|
jtkorhonen@0
|
676 return true;
|
jtkorhonen@0
|
677 }
|
jtkorhonen@0
|
678 }
|
jtkorhonen@0
|
679 return false;
|
jtkorhonen@0
|
680 }
|
jtkorhonen@0
|
681
|
jtkorhonen@5
|
682 void MainWindow::countAMRNModifications(QListWidget *workList, int& a, int& m, int& r, int& n)
|
jtkorhonen@0
|
683 {
|
jtkorhonen@0
|
684 int itemCount = workList -> count();
|
jtkorhonen@0
|
685 if (itemCount > 0)
|
jtkorhonen@0
|
686 {
|
jtkorhonen@0
|
687 int A= 0;
|
jtkorhonen@0
|
688 int M=0;
|
jtkorhonen@0
|
689 int R=0;
|
jtkorhonen@5
|
690 int N=0;
|
jtkorhonen@0
|
691 for (int i = 0; i < workList -> count(); i++)
|
jtkorhonen@0
|
692 {
|
jtkorhonen@0
|
693 QListWidgetItem *currItem = workList -> item(i);
|
jtkorhonen@0
|
694
|
jtkorhonen@0
|
695 QString tmp = currItem->text().mid(0, 1);
|
jtkorhonen@0
|
696 if (tmp == "M")
|
jtkorhonen@0
|
697 {
|
jtkorhonen@0
|
698 M++;
|
jtkorhonen@0
|
699 }
|
jtkorhonen@0
|
700 else if (tmp == "R")
|
jtkorhonen@0
|
701 {
|
jtkorhonen@0
|
702 R++;
|
jtkorhonen@0
|
703 }
|
jtkorhonen@0
|
704 else if (tmp == "A")
|
jtkorhonen@0
|
705 {
|
jtkorhonen@0
|
706 A++;
|
jtkorhonen@0
|
707 }
|
jtkorhonen@5
|
708 else if (tmp == "?")
|
jtkorhonen@5
|
709 {
|
jtkorhonen@5
|
710 N++;
|
jtkorhonen@5
|
711 }
|
jtkorhonen@0
|
712 }
|
jtkorhonen@0
|
713
|
jtkorhonen@0
|
714 a = A;
|
jtkorhonen@0
|
715 m = M;
|
jtkorhonen@0
|
716 r = R;
|
jtkorhonen@5
|
717 n = N;
|
jtkorhonen@0
|
718 }
|
jtkorhonen@0
|
719 else
|
jtkorhonen@0
|
720 {
|
jtkorhonen@0
|
721 a = 0;
|
jtkorhonen@0
|
722 m = 0;
|
jtkorhonen@0
|
723 r = 0;
|
jtkorhonen@5
|
724 n = 0;
|
jtkorhonen@0
|
725 }
|
jtkorhonen@0
|
726 }
|
jtkorhonen@0
|
727
|
jtkorhonen@0
|
728
|
jtkorhonen@0
|
729 void MainWindow::timerEvent(QTimerEvent *)
|
jtkorhonen@0
|
730 {
|
jtkorhonen@0
|
731 bool shouldHgStat = false;
|
jtkorhonen@0
|
732
|
jtkorhonen@0
|
733 if (runningAction != ACT_NONE)
|
jtkorhonen@0
|
734 {
|
jtkorhonen@0
|
735 //We are running some hg command...
|
jtkorhonen@0
|
736 if (runner -> isProcRunning() == false)
|
jtkorhonen@0
|
737 {
|
jtkorhonen@0
|
738 //Running has just ended.
|
jtkorhonen@0
|
739 int exitCode = runner -> getExitCode();
|
jtkorhonen@0
|
740
|
jtkorhonen@0
|
741 runner -> hideProgBar();
|
jtkorhonen@0
|
742
|
jtkorhonen@0
|
743 //Clumsy...
|
jtkorhonen@0
|
744 if ((EXITOK(exitCode)) || ((exitCode == 1) && (runningAction == ACT_INCOMING)))
|
jtkorhonen@0
|
745 {
|
jtkorhonen@0
|
746 //Successful running.
|
jtkorhonen@0
|
747 switch(runningAction)
|
jtkorhonen@0
|
748 {
|
jtkorhonen@0
|
749 case ACT_STAT:
|
jtkorhonen@0
|
750 {
|
jtkorhonen@0
|
751 hgExp -> updateWorkFolderFileList(runner -> getStdOut());
|
jtkorhonen@0
|
752 }
|
jtkorhonen@0
|
753 break;
|
jtkorhonen@0
|
754
|
jtkorhonen@0
|
755 case ACT_INCOMING:
|
jtkorhonen@0
|
756 case ACT_ANNOTATE:
|
jtkorhonen@0
|
757 case ACT_RESOLVE_LIST:
|
jtkorhonen@0
|
758 case ACT_RESOLVE_MARK:
|
jtkorhonen@2
|
759 presentLongStdoutToUser(runner -> getStdOut());
|
jtkorhonen@0
|
760 shouldHgStat = true;
|
jtkorhonen@0
|
761 break;
|
jtkorhonen@0
|
762
|
jtkorhonen@0
|
763 case ACT_PULL:
|
jtkorhonen@0
|
764 QMessageBox::information(this, "pull", runner -> getStdOut());
|
jtkorhonen@0
|
765 shouldHgStat = true;
|
jtkorhonen@0
|
766 break;
|
jtkorhonen@0
|
767
|
jtkorhonen@0
|
768 case ACT_PUSH:
|
jtkorhonen@0
|
769 QMessageBox::information(this, "push", runner -> getStdOut());
|
jtkorhonen@0
|
770 shouldHgStat = true;
|
jtkorhonen@0
|
771 break;
|
jtkorhonen@0
|
772
|
jtkorhonen@0
|
773 case ACT_INIT:
|
jtkorhonen@0
|
774 enableDisableActions();
|
jtkorhonen@0
|
775 shouldHgStat = true;
|
jtkorhonen@0
|
776 break;
|
jtkorhonen@0
|
777
|
jtkorhonen@0
|
778 case ACT_CLONEFROMREMOTE:
|
jtkorhonen@0
|
779 QMessageBox::information(this, "clone", runner -> getStdOut());
|
jtkorhonen@0
|
780 enableDisableActions();
|
jtkorhonen@0
|
781 shouldHgStat = true;
|
jtkorhonen@0
|
782 break;
|
jtkorhonen@0
|
783
|
jtkorhonen@0
|
784 case ACT_LOG:
|
jtkorhonen@0
|
785 {
|
jtkorhonen@0
|
786 hgExp -> updateLocalRepoHgLogList(runner -> getStdOut());
|
jtkorhonen@0
|
787 }
|
jtkorhonen@0
|
788 break;
|
jtkorhonen@0
|
789
|
jtkorhonen@0
|
790 case ACT_PARENTS:
|
jtkorhonen@0
|
791 {
|
jtkorhonen@0
|
792 hgExp -> updateLocalRepoParentsList(runner -> getStdOut());
|
jtkorhonen@0
|
793 }
|
jtkorhonen@0
|
794 break;
|
jtkorhonen@0
|
795
|
jtkorhonen@0
|
796 case ACT_HEADS:
|
jtkorhonen@0
|
797 {
|
jtkorhonen@0
|
798 QString stdOut = runner -> getStdOut();
|
jtkorhonen@0
|
799 hgExp -> updateLocalRepoHeadsList(stdOut);
|
jtkorhonen@0
|
800 }
|
jtkorhonen@0
|
801 break;
|
jtkorhonen@0
|
802
|
jtkorhonen@0
|
803 case ACT_REMOVE:
|
jtkorhonen@0
|
804 case ACT_ADD:
|
jtkorhonen@0
|
805 case ACT_COMMIT:
|
jtkorhonen@0
|
806 case ACT_FILEDIFF:
|
jtkorhonen@0
|
807 case ACT_FOLDERDIFF:
|
jtkorhonen@0
|
808 case ACT_CHGSETDIFF:
|
jtkorhonen@0
|
809 case ACT_REVERT:
|
jtkorhonen@11
|
810 case ACT_SERVE:
|
jtkorhonen@0
|
811 shouldHgStat = true;
|
jtkorhonen@0
|
812 break;
|
jtkorhonen@0
|
813
|
jtkorhonen@0
|
814 case ACT_UPDATE:
|
jtkorhonen@0
|
815 QMessageBox::information(this, "update", runner -> getStdOut());
|
jtkorhonen@0
|
816 shouldHgStat = true;
|
jtkorhonen@0
|
817 break;
|
jtkorhonen@0
|
818
|
jtkorhonen@0
|
819 case ACT_MERGE:
|
jtkorhonen@0
|
820 QMessageBox::information(this, "merge", runner -> getStdOut());
|
jtkorhonen@0
|
821 shouldHgStat = true;
|
jtkorhonen@0
|
822 break;
|
jtkorhonen@0
|
823
|
jtkorhonen@0
|
824 default:
|
jtkorhonen@0
|
825 break;
|
jtkorhonen@0
|
826 }
|
jtkorhonen@0
|
827 }
|
jtkorhonen@0
|
828
|
jtkorhonen@0
|
829 //Typical sequence goes stat -> heads -> parents -> log
|
jtkorhonen@0
|
830 if (runningAction == ACT_STAT)
|
jtkorhonen@0
|
831 {
|
jtkorhonen@0
|
832 runningAction = ACT_NONE;
|
jtkorhonen@0
|
833 hgHeads();
|
jtkorhonen@0
|
834 }
|
jtkorhonen@0
|
835 else if (runningAction == ACT_HEADS)
|
jtkorhonen@0
|
836 {
|
jtkorhonen@0
|
837 runningAction = ACT_NONE;
|
jtkorhonen@0
|
838 hgParents();
|
jtkorhonen@0
|
839 }
|
jtkorhonen@0
|
840 else if (runningAction == ACT_PARENTS)
|
jtkorhonen@0
|
841 {
|
jtkorhonen@0
|
842 runningAction = ACT_NONE;
|
jtkorhonen@0
|
843 hgLog();
|
jtkorhonen@0
|
844 }
|
jtkorhonen@0
|
845 else
|
jtkorhonen@0
|
846 {
|
jtkorhonen@0
|
847 runningAction = ACT_NONE;
|
jtkorhonen@0
|
848 if (shouldHgStat)
|
jtkorhonen@0
|
849 {
|
jtkorhonen@0
|
850 hgStat();
|
jtkorhonen@0
|
851 }
|
jtkorhonen@0
|
852 }
|
jtkorhonen@0
|
853 }
|
jtkorhonen@0
|
854 }
|
jtkorhonen@0
|
855 else
|
jtkorhonen@0
|
856 {
|
jtkorhonen@0
|
857 enableDisableActions();
|
jtkorhonen@0
|
858 }
|
jtkorhonen@0
|
859 }
|
jtkorhonen@0
|
860
|
jtkorhonen@0
|
861 void MainWindow::connectActions()
|
jtkorhonen@0
|
862 {
|
jtkorhonen@0
|
863 connect(exitAct, SIGNAL(triggered()), this, SLOT(close()));
|
jtkorhonen@0
|
864 connect(aboutAct, SIGNAL(triggered()), this, SLOT(about()));
|
jtkorhonen@0
|
865 connect(aboutQtAct, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
|
jtkorhonen@0
|
866
|
jtkorhonen@0
|
867 connect(hgStatAct, SIGNAL(triggered()), this, SLOT(hgStat()));
|
jtkorhonen@0
|
868 connect(hgExp, SIGNAL(workFolderViewTypesChanged()), this, SLOT(hgStat()));
|
jtkorhonen@0
|
869 connect(hgRemoveAct, SIGNAL(triggered()), this, SLOT(hgRemove()));
|
jtkorhonen@0
|
870 connect(hgAddAct, SIGNAL(triggered()), this, SLOT(hgAdd()));
|
jtkorhonen@0
|
871 connect(hgCommitAct, SIGNAL(triggered()), this, SLOT(hgCommit()));
|
jtkorhonen@0
|
872 connect(hgFileDiffAct, SIGNAL(triggered()), this, SLOT(hgFileDiff()));
|
jtkorhonen@0
|
873 connect(hgFolderDiffAct, SIGNAL(triggered()), this, SLOT(hgFolderDiff()));
|
jtkorhonen@0
|
874 connect(hgChgSetDiffAct, SIGNAL(triggered()), this, SLOT(hgChgSetDiff()));
|
jtkorhonen@0
|
875 connect(hgUpdateAct, SIGNAL(triggered()), this, SLOT(hgUpdate()));
|
jtkorhonen@0
|
876 connect(hgRevertAct, SIGNAL(triggered()), this, SLOT(hgRevert()));
|
jtkorhonen@0
|
877 connect(hgMergeAct, SIGNAL(triggered()), this, SLOT(hgMerge()));
|
jtkorhonen@0
|
878
|
jtkorhonen@0
|
879 connect(settingsAct, SIGNAL(triggered()), this, SLOT(settings()));
|
jtkorhonen@0
|
880
|
jtkorhonen@0
|
881 connect(hgInitAct, SIGNAL(triggered()), this, SLOT(hgInit()));
|
jtkorhonen@0
|
882 connect(hgCloneFromRemoteAct, SIGNAL(triggered()), this, SLOT(hgCloneFromRemote()));
|
jtkorhonen@0
|
883 connect(hgIncomingAct, SIGNAL(triggered()), this, SLOT(hgIncoming()));
|
jtkorhonen@0
|
884 connect(hgPullAct, SIGNAL(triggered()), this, SLOT(hgPull()));
|
jtkorhonen@0
|
885 connect(hgPushAct, SIGNAL(triggered()), this, SLOT(hgPush()));
|
jtkorhonen@0
|
886
|
jtkorhonen@0
|
887 connect(hgExp, SIGNAL(currentChanged(int)), this, SLOT(tabChanged(int)));
|
jtkorhonen@0
|
888
|
jtkorhonen@0
|
889 connect(hgUpdateToRevAct, SIGNAL(triggered()), this, SLOT(hgUpdateToRev()));
|
jtkorhonen@0
|
890 connect(hgAnnotateAct, SIGNAL(triggered()), this, SLOT(hgAnnotate()));
|
jtkorhonen@0
|
891 connect(hgResolveListAct, SIGNAL(triggered()), this, SLOT(hgResolveList()));
|
jtkorhonen@0
|
892 connect(hgResolveMarkAct, SIGNAL(triggered()), this, SLOT(hgResolveMark()));
|
jtkorhonen@11
|
893 connect(hgServeAct, SIGNAL(triggered()), this, SLOT(hgServe()));
|
jtkorhonen@0
|
894 }
|
jtkorhonen@0
|
895
|
jtkorhonen@0
|
896 void MainWindow::tabChanged(int currTab)
|
jtkorhonen@0
|
897 {
|
jtkorhonen@0
|
898 tabPage = currTab;
|
jtkorhonen@0
|
899 }
|
jtkorhonen@0
|
900
|
jtkorhonen@0
|
901 void MainWindow::enableDisableActions()
|
jtkorhonen@0
|
902 {
|
jtkorhonen@0
|
903 QDir localRepoDir;
|
jtkorhonen@0
|
904 QDir workFolderDir;
|
jtkorhonen@0
|
905 bool workFolderExist;
|
jtkorhonen@0
|
906 bool localRepoExist;
|
jtkorhonen@0
|
907
|
jtkorhonen@0
|
908 remoteRepoActionsEnabled = true;
|
jtkorhonen@0
|
909 if (remoteRepoPath.isEmpty())
|
jtkorhonen@0
|
910 {
|
jtkorhonen@0
|
911 remoteRepoActionsEnabled = false;
|
jtkorhonen@0
|
912 }
|
jtkorhonen@0
|
913
|
jtkorhonen@0
|
914 localRepoActionsEnabled = true;
|
jtkorhonen@0
|
915 if (workFolderPath.isEmpty())
|
jtkorhonen@0
|
916 {
|
jtkorhonen@0
|
917 localRepoActionsEnabled = false;
|
jtkorhonen@0
|
918 workFolderExist = false;
|
jtkorhonen@0
|
919 }
|
jtkorhonen@0
|
920
|
jtkorhonen@0
|
921 if (!workFolderDir.exists(workFolderPath))
|
jtkorhonen@0
|
922 {
|
jtkorhonen@0
|
923 localRepoActionsEnabled = false;
|
jtkorhonen@0
|
924 workFolderExist = false;
|
jtkorhonen@0
|
925 }
|
jtkorhonen@0
|
926 else
|
jtkorhonen@0
|
927 {
|
jtkorhonen@0
|
928 workFolderExist = true;
|
jtkorhonen@0
|
929 }
|
jtkorhonen@0
|
930
|
jtkorhonen@0
|
931 if (!localRepoDir.exists(workFolderPath + getHgDirName()))
|
jtkorhonen@0
|
932 {
|
jtkorhonen@0
|
933 localRepoActionsEnabled = false;
|
jtkorhonen@0
|
934 localRepoExist = false;
|
jtkorhonen@0
|
935 }
|
jtkorhonen@0
|
936
|
jtkorhonen@0
|
937 hgCloneFromRemoteAct -> setEnabled(remoteRepoActionsEnabled);
|
jtkorhonen@0
|
938 hgIncomingAct -> setEnabled(remoteRepoActionsEnabled && remoteRepoActionsEnabled);
|
jtkorhonen@0
|
939 hgPullAct -> setEnabled(remoteRepoActionsEnabled && remoteRepoActionsEnabled);
|
jtkorhonen@0
|
940 hgPushAct -> setEnabled(remoteRepoActionsEnabled && remoteRepoActionsEnabled);
|
jtkorhonen@0
|
941
|
jtkorhonen@0
|
942 if (tabPage != WORKTAB)
|
jtkorhonen@0
|
943 {
|
jtkorhonen@0
|
944 localRepoActionsEnabled = false;
|
jtkorhonen@0
|
945 }
|
jtkorhonen@0
|
946
|
jtkorhonen@0
|
947 hgInitAct -> setEnabled((localRepoExist == false) && (workFolderExist==true));
|
jtkorhonen@0
|
948 hgStatAct -> setEnabled(localRepoActionsEnabled);
|
jtkorhonen@0
|
949 hgFileDiffAct -> setEnabled(localRepoActionsEnabled);
|
jtkorhonen@0
|
950 hgFolderDiffAct -> setEnabled(localRepoActionsEnabled);
|
jtkorhonen@0
|
951 hgRevertAct -> setEnabled(localRepoActionsEnabled);
|
jtkorhonen@0
|
952 hgAddAct -> setEnabled(localRepoActionsEnabled);
|
jtkorhonen@0
|
953 hgRemoveAct -> setEnabled(localRepoActionsEnabled);
|
jtkorhonen@0
|
954 hgUpdateAct -> setEnabled(localRepoActionsEnabled);
|
jtkorhonen@0
|
955 hgCommitAct -> setEnabled(localRepoActionsEnabled);
|
jtkorhonen@0
|
956 hgMergeAct -> setEnabled(localRepoActionsEnabled);
|
jtkorhonen@2
|
957 hgResolveListAct -> setEnabled(localRepoActionsEnabled);
|
jtkorhonen@2
|
958 hgResolveMarkAct -> setEnabled(localRepoActionsEnabled);
|
jtkorhonen@2
|
959 hgAnnotateAct -> setEnabled(localRepoActionsEnabled);
|
jtkorhonen@11
|
960 hgServeAct -> setEnabled(localRepoActionsEnabled);
|
jtkorhonen@0
|
961
|
jtkorhonen@0
|
962 hgExp -> enableDisableOtherTabs();
|
jtkorhonen@0
|
963
|
jtkorhonen@5
|
964 int a, m, r, n;
|
jtkorhonen@5
|
965 countAMRNModifications(hgExp -> workFolderFileList, a, m, r, n);
|
jtkorhonen@0
|
966
|
jtkorhonen@0
|
967 if (tabPage == WORKTAB)
|
jtkorhonen@0
|
968 {
|
jtkorhonen@0
|
969 //Enable / disable actions according to workFolderFileList selections / currentSelection / count
|
jtkorhonen@0
|
970 hgChgSetDiffAct -> setEnabled(false);
|
jtkorhonen@0
|
971 hgUpdateToRevAct -> setEnabled(false);
|
jtkorhonen@0
|
972
|
jtkorhonen@0
|
973 if (localRepoActionsEnabled)
|
jtkorhonen@0
|
974 {
|
jtkorhonen@0
|
975 if ((a == 0) && (m == 0) && (r == 0))
|
jtkorhonen@0
|
976 {
|
jtkorhonen@0
|
977 hgCommitAct -> setEnabled(false);
|
jtkorhonen@0
|
978 hgRevertAct -> setEnabled(false);
|
jtkorhonen@0
|
979 }
|
jtkorhonen@0
|
980
|
jtkorhonen@0
|
981 if (m == 0)
|
jtkorhonen@0
|
982 {
|
jtkorhonen@0
|
983 hgFolderDiffAct -> setEnabled(false);
|
jtkorhonen@0
|
984 }
|
jtkorhonen@0
|
985
|
jtkorhonen@0
|
986 if (!isSelectedModified(hgExp -> workFolderFileList))
|
jtkorhonen@0
|
987 {
|
jtkorhonen@0
|
988 hgFileDiffAct -> setEnabled(false);
|
jtkorhonen@0
|
989 hgRevertAct -> setEnabled(false);
|
jtkorhonen@0
|
990 }
|
jtkorhonen@0
|
991
|
jtkorhonen@5
|
992 //JK 14.5.2010: Fixed confusing add button. Now this is simple: If we have something to add (any non-tracked files), add is enabled.
|
jtkorhonen@5
|
993 if (n == 0)
|
jtkorhonen@0
|
994 {
|
jtkorhonen@0
|
995 hgAddAct -> setEnabled(false);
|
jtkorhonen@0
|
996 }
|
jtkorhonen@0
|
997
|
jtkorhonen@6
|
998 if (!isSelectedDeletable(hgExp -> workFolderFileList))
|
jtkorhonen@0
|
999 {
|
jtkorhonen@0
|
1000 hgRemoveAct -> setEnabled(false);
|
jtkorhonen@0
|
1001 }
|
jtkorhonen@0
|
1002
|
jtkorhonen@2
|
1003 hgResolveListAct -> setEnabled(true);
|
jtkorhonen@2
|
1004
|
jtkorhonen@5
|
1005 if (hgExp -> localRepoHeadsList->count() < 2)
|
jtkorhonen@0
|
1006 {
|
jtkorhonen@0
|
1007 hgMergeAct -> setEnabled(false);
|
jtkorhonen@0
|
1008 }
|
jtkorhonen@0
|
1009
|
jtkorhonen@2
|
1010 QString currentFile = hgExp -> getCurrentFileListLine();
|
jtkorhonen@2
|
1011 if (!currentFile.isEmpty())
|
jtkorhonen@2
|
1012 {
|
jtkorhonen@2
|
1013 hgAnnotateAct -> setEnabled(true);
|
jtkorhonen@2
|
1014 hgResolveMarkAct -> setEnabled(true);
|
jtkorhonen@2
|
1015 }
|
jtkorhonen@2
|
1016 else
|
jtkorhonen@2
|
1017 {
|
jtkorhonen@2
|
1018 hgAnnotateAct -> setEnabled(false);
|
jtkorhonen@2
|
1019 hgResolveMarkAct -> setEnabled(false);
|
jtkorhonen@2
|
1020 }
|
jtkorhonen@0
|
1021 }
|
jtkorhonen@0
|
1022 }
|
jtkorhonen@0
|
1023 else
|
jtkorhonen@0
|
1024 {
|
jtkorhonen@0
|
1025 QList <QListWidgetItem *> headSelList = hgExp -> localRepoHeadsList->selectedItems();
|
jtkorhonen@0
|
1026 QList <QListWidgetItem *> historySelList = hgExp -> localRepoHgLogList->selectedItems();
|
jtkorhonen@0
|
1027
|
jtkorhonen@0
|
1028 if ((historySelList.count() == 2) || (headSelList.count() == 2))
|
jtkorhonen@0
|
1029 {
|
jtkorhonen@0
|
1030 hgChgSetDiffAct -> setEnabled(true);
|
jtkorhonen@0
|
1031 }
|
jtkorhonen@0
|
1032 else
|
jtkorhonen@0
|
1033 {
|
jtkorhonen@0
|
1034 hgChgSetDiffAct -> setEnabled(false);
|
jtkorhonen@0
|
1035 }
|
jtkorhonen@0
|
1036
|
jtkorhonen@0
|
1037 if ((a == 0) && (m == 0) && (r == 0))
|
jtkorhonen@0
|
1038 {
|
jtkorhonen@0
|
1039 if (historySelList.count() == 1)
|
jtkorhonen@0
|
1040 {
|
jtkorhonen@0
|
1041 hgUpdateToRevAct -> setEnabled(true);
|
jtkorhonen@0
|
1042 }
|
jtkorhonen@0
|
1043 else
|
jtkorhonen@0
|
1044 {
|
jtkorhonen@0
|
1045 hgUpdateToRevAct -> setEnabled(false);
|
jtkorhonen@0
|
1046 }
|
jtkorhonen@0
|
1047 }
|
jtkorhonen@0
|
1048 else
|
jtkorhonen@0
|
1049 {
|
jtkorhonen@0
|
1050 hgUpdateToRevAct -> setEnabled(false);
|
jtkorhonen@0
|
1051 }
|
jtkorhonen@0
|
1052 }
|
jtkorhonen@0
|
1053 }
|
jtkorhonen@0
|
1054
|
jtkorhonen@0
|
1055 void MainWindow::createActions()
|
jtkorhonen@0
|
1056 {
|
jtkorhonen@0
|
1057 //File actions
|
jtkorhonen@0
|
1058 hgInitAct = new QAction(tr("Init local repository"), this);
|
jtkorhonen@0
|
1059 hgInitAct->setStatusTip(tr("Create an empty local repository in selected folder"));
|
jtkorhonen@0
|
1060
|
jtkorhonen@0
|
1061 hgCloneFromRemoteAct = new QAction(tr("Clone from remote"), this);
|
jtkorhonen@0
|
1062 hgCloneFromRemoteAct->setStatusTip(tr("Clone from remote repository into local repository in selected folder"));
|
jtkorhonen@0
|
1063
|
jtkorhonen@0
|
1064 settingsAct = new QAction(QIcon(":/images/settings.png"), tr("Settings..."), this);
|
jtkorhonen@0
|
1065 settingsAct -> setStatusTip(tr("View and change application settings"));
|
jtkorhonen@0
|
1066 settingsAct -> setIconVisibleInMenu(true);
|
jtkorhonen@0
|
1067
|
jtkorhonen@0
|
1068 exitAct = new QAction(QIcon(":/images/exit.png"), tr("Exit"), this);
|
jtkorhonen@0
|
1069 exitAct->setShortcuts(QKeySequence::Quit);
|
jtkorhonen@0
|
1070 exitAct->setStatusTip(tr("Exit application"));
|
jtkorhonen@0
|
1071 exitAct -> setIconVisibleInMenu(true);
|
jtkorhonen@0
|
1072
|
jtkorhonen@0
|
1073 //Repository actions
|
jtkorhonen@0
|
1074 hgIncomingAct = new QAction(QIcon(":/images/incoming.png"), tr("View incoming changesets"), this);
|
jtkorhonen@0
|
1075 hgIncomingAct -> setStatusTip(tr("View info of changesets incoming to us from remote repository (on pull operation)"));
|
jtkorhonen@0
|
1076
|
jtkorhonen@0
|
1077 hgPullAct = new QAction(QIcon(":/images/pull.png"), tr("Pull from remote"), this);
|
jtkorhonen@0
|
1078 hgPullAct -> setStatusTip(tr("Pull changesets from remote repository to local repository"));
|
jtkorhonen@0
|
1079
|
jtkorhonen@0
|
1080 hgPushAct = new QAction(QIcon(":/images/push.png"), tr("Push to remote"), this);
|
jtkorhonen@0
|
1081 hgPushAct->setStatusTip(tr("Push local changesets to remote repository"));
|
jtkorhonen@0
|
1082
|
jtkorhonen@0
|
1083 //Workfolder actions
|
jtkorhonen@0
|
1084 hgStatAct = new QAction(QIcon(":/images/status.png"), tr("Refresh status"), this);
|
jtkorhonen@0
|
1085 hgStatAct->setStatusTip(tr("Refresh (info of) status of workfolder files (A=Added, M=Mofified, R=Removed, C=Clean, !=Locally deleted, ?=Not tracked, I=Ignored)"));
|
jtkorhonen@0
|
1086
|
jtkorhonen@0
|
1087 hgFileDiffAct = new QAction(QIcon(":/images/diff.png"), tr("View filediff"), this);
|
jtkorhonen@0
|
1088 hgFileDiffAct->setStatusTip(tr("Filediff: View differences between selected working folder file and local repository file"));
|
jtkorhonen@0
|
1089
|
jtkorhonen@0
|
1090 hgFolderDiffAct = new QAction(QIcon(":/images/folderdiff.png"), tr("View folderdiff"), this);
|
jtkorhonen@0
|
1091 hgFolderDiffAct->setStatusTip(tr("Folderdiff: View all differences between working folder files and local repository files"));
|
jtkorhonen@0
|
1092
|
jtkorhonen@0
|
1093 hgChgSetDiffAct = new QAction(QIcon(":/images/chgsetdiff.png"), tr("View changesetdiff"), this);
|
jtkorhonen@0
|
1094 hgChgSetDiffAct->setStatusTip(tr("Change set diff: View differences between all files of 2 repository changesets"));
|
jtkorhonen@0
|
1095
|
jtkorhonen@0
|
1096 hgRevertAct = new QAction(QIcon(":/images/undo.png"), tr("Undo changes"), this);
|
jtkorhonen@0
|
1097 hgRevertAct->setStatusTip(tr("Undo selected working folder file changes (return to local repository version)"));
|
jtkorhonen@0
|
1098
|
jtkorhonen@0
|
1099 hgAddAct = new QAction(QIcon(":/images/add.png"), tr("Add files"), this);
|
jtkorhonen@5
|
1100 hgAddAct -> setStatusTip(tr("Add working folder files (selected one or all yet untracked) to local repository (on next commit)"));
|
jtkorhonen@0
|
1101
|
jtkorhonen@0
|
1102 hgRemoveAct = new QAction(QIcon(":/images/remove.png"), tr("Remove file"), this);
|
jtkorhonen@0
|
1103 hgRemoveAct -> setStatusTip(tr("Remove selected working folder file from local repository (on next commit)"));
|
jtkorhonen@0
|
1104
|
jtkorhonen@0
|
1105 hgUpdateAct = new QAction(QIcon(":/images/update.png"), tr("Update working folder"), this);
|
jtkorhonen@0
|
1106 hgUpdateAct->setStatusTip(tr("Update working folder from local repository"));
|
jtkorhonen@0
|
1107
|
jtkorhonen@11
|
1108 hgCommitAct = new QAction(QIcon(":/images/commit.png"), tr("Commit / Save change(s)"), this);
|
jtkorhonen@11
|
1109 hgCommitAct->setStatusTip(tr("Save (selected file or all changed files working folder (and all subfolders)) to local repository"));
|
jtkorhonen@0
|
1110
|
jtkorhonen@0
|
1111 hgMergeAct = new QAction(QIcon(":/images/merge.png"), tr("Merge"), this);
|
jtkorhonen@0
|
1112 hgMergeAct->setStatusTip(tr("Merge two local repository changesets to working folder"));
|
jtkorhonen@0
|
1113
|
jtkorhonen@0
|
1114 //Advanced actions
|
jtkorhonen@0
|
1115 hgUpdateToRevAct = new QAction(tr("Update to revision"), this);
|
jtkorhonen@0
|
1116 hgUpdateToRevAct -> setStatusTip(tr("Update working folder to version selected from history list"));
|
jtkorhonen@0
|
1117
|
jtkorhonen@0
|
1118 hgAnnotateAct = new QAction(tr("Annotate"), this);
|
jtkorhonen@0
|
1119 hgAnnotateAct -> setStatusTip(tr("Show line-by-line version information for selected file"));
|
jtkorhonen@0
|
1120
|
jtkorhonen@0
|
1121 hgResolveListAct = new QAction(tr("Resolve (list)"), this);
|
jtkorhonen@0
|
1122 hgResolveListAct -> setStatusTip(tr("Resolve (list): Show list of files needing merge"));
|
jtkorhonen@0
|
1123
|
jtkorhonen@0
|
1124 hgResolveMarkAct = new QAction(tr("Resolve (mark)"), this);
|
jtkorhonen@0
|
1125 hgResolveMarkAct -> setStatusTip(tr("Resolve (mark): Mark selected file status as resolved"));
|
jtkorhonen@0
|
1126
|
jtkorhonen@11
|
1127 hgServeAct = new QAction(tr("Serve (via http)"), this);
|
jtkorhonen@11
|
1128 hgServeAct -> setStatusTip(tr("Serve local repository via http for workgroup access"));
|
jtkorhonen@11
|
1129
|
jtkorhonen@0
|
1130 //Help actions
|
jtkorhonen@0
|
1131 aboutAct = new QAction(tr("About"), this);
|
jtkorhonen@0
|
1132 aboutAct->setStatusTip(tr("Show the application's About box"));
|
jtkorhonen@0
|
1133
|
jtkorhonen@0
|
1134 aboutQtAct = new QAction(tr("About Qt"), this);
|
jtkorhonen@0
|
1135 aboutQtAct->setStatusTip(tr("Show the Qt library's About box"));
|
jtkorhonen@0
|
1136 }
|
jtkorhonen@0
|
1137
|
jtkorhonen@0
|
1138 void MainWindow::createMenus()
|
jtkorhonen@0
|
1139 {
|
jtkorhonen@0
|
1140 fileMenu = menuBar()->addMenu(tr("File"));
|
jtkorhonen@0
|
1141 fileMenu -> addAction(hgInitAct);
|
jtkorhonen@0
|
1142 fileMenu -> addAction(hgCloneFromRemoteAct);
|
jtkorhonen@0
|
1143 fileMenu -> addSeparator();
|
jtkorhonen@0
|
1144 fileMenu -> addAction(settingsAct);
|
jtkorhonen@0
|
1145 fileMenu -> addSeparator();
|
jtkorhonen@0
|
1146 fileMenu -> addAction(exitAct);
|
jtkorhonen@0
|
1147
|
jtkorhonen@0
|
1148 advancedMenu = menuBar()->addMenu(tr("Advanced"));
|
jtkorhonen@0
|
1149 advancedMenu -> addAction(hgUpdateToRevAct);
|
jtkorhonen@0
|
1150 advancedMenu -> addSeparator();
|
jtkorhonen@0
|
1151 advancedMenu -> addAction(hgAnnotateAct);
|
jtkorhonen@0
|
1152 advancedMenu -> addSeparator();
|
jtkorhonen@0
|
1153 advancedMenu -> addAction(hgResolveListAct);
|
jtkorhonen@0
|
1154 advancedMenu -> addAction(hgResolveMarkAct);
|
jtkorhonen@11
|
1155 advancedMenu -> addSeparator();
|
jtkorhonen@11
|
1156 advancedMenu -> addAction(hgServeAct);
|
jtkorhonen@0
|
1157
|
jtkorhonen@0
|
1158 helpMenu = menuBar()->addMenu(tr("Help"));
|
jtkorhonen@0
|
1159 helpMenu->addAction(aboutAct);
|
jtkorhonen@0
|
1160 helpMenu->addAction(aboutQtAct);
|
jtkorhonen@0
|
1161 }
|
jtkorhonen@0
|
1162
|
jtkorhonen@0
|
1163 void MainWindow::createToolBars()
|
jtkorhonen@0
|
1164 {
|
jtkorhonen@0
|
1165 fileToolBar = addToolBar(tr("File"));
|
jtkorhonen@0
|
1166 fileToolBar -> setIconSize(QSize(MY_ICON_SIZE, MY_ICON_SIZE));
|
jtkorhonen@0
|
1167 fileToolBar -> addAction(settingsAct);
|
jtkorhonen@0
|
1168 fileToolBar -> addAction(exitAct);
|
jtkorhonen@0
|
1169 fileToolBar -> addSeparator();
|
jtkorhonen@0
|
1170 fileToolBar -> addAction(hgChgSetDiffAct);
|
jtkorhonen@0
|
1171 fileToolBar -> setMovable(false);
|
jtkorhonen@0
|
1172
|
jtkorhonen@0
|
1173 repoToolBar = addToolBar(tr(REPOMENU_TITLE));
|
jtkorhonen@0
|
1174 repoToolBar -> setIconSize(QSize(MY_ICON_SIZE, MY_ICON_SIZE));
|
jtkorhonen@0
|
1175 repoToolBar->addAction(hgIncomingAct);
|
jtkorhonen@0
|
1176 repoToolBar->addAction(hgPullAct);
|
jtkorhonen@0
|
1177 repoToolBar->addAction(hgPushAct);
|
jtkorhonen@0
|
1178 repoToolBar -> setMovable(false);
|
jtkorhonen@0
|
1179
|
jtkorhonen@0
|
1180 workFolderToolBar = addToolBar(tr(WORKFOLDERMENU_TITLE));
|
jtkorhonen@0
|
1181 addToolBar(Qt::LeftToolBarArea, workFolderToolBar);
|
jtkorhonen@0
|
1182 workFolderToolBar -> setIconSize(QSize(MY_ICON_SIZE, MY_ICON_SIZE));
|
jtkorhonen@0
|
1183 workFolderToolBar->addAction(hgStatAct);
|
jtkorhonen@0
|
1184 workFolderToolBar->addSeparator();
|
jtkorhonen@0
|
1185 workFolderToolBar->addAction(hgFileDiffAct);
|
jtkorhonen@0
|
1186 workFolderToolBar->addAction(hgFolderDiffAct);
|
jtkorhonen@0
|
1187 workFolderToolBar->addSeparator();
|
jtkorhonen@0
|
1188 workFolderToolBar->addAction(hgRevertAct);
|
jtkorhonen@0
|
1189 workFolderToolBar->addAction(hgUpdateAct);
|
jtkorhonen@0
|
1190 workFolderToolBar->addAction(hgCommitAct);
|
jtkorhonen@0
|
1191 workFolderToolBar->addAction(hgMergeAct);
|
jtkorhonen@0
|
1192 workFolderToolBar->addSeparator();
|
jtkorhonen@0
|
1193 workFolderToolBar->addAction(hgAddAct);
|
jtkorhonen@0
|
1194 workFolderToolBar->addAction(hgRemoveAct);
|
jtkorhonen@0
|
1195 workFolderToolBar -> setMovable(false);
|
jtkorhonen@0
|
1196
|
jtkorhonen@0
|
1197 }
|
jtkorhonen@0
|
1198
|
jtkorhonen@0
|
1199
|
jtkorhonen@0
|
1200 void MainWindow::createStatusBar()
|
jtkorhonen@0
|
1201 {
|
jtkorhonen@0
|
1202 statusBar()->showMessage(tr("Ready"));
|
jtkorhonen@0
|
1203 }
|
jtkorhonen@0
|
1204
|
jtkorhonen@0
|
1205 void MainWindow::readSettings()
|
jtkorhonen@0
|
1206 {
|
jtkorhonen@0
|
1207 QDir workFolder;
|
jtkorhonen@0
|
1208
|
jtkorhonen@0
|
1209 QSettings settings("hgexplorer", "hgexplorer");
|
jtkorhonen@0
|
1210
|
jtkorhonen@0
|
1211 remoteRepoPath = settings.value("remoterepopath", "").toString() ;
|
jtkorhonen@0
|
1212 workFolderPath = settings.value("workfolderpath", "").toString();
|
jtkorhonen@0
|
1213 if (!workFolder.exists(workFolderPath))
|
jtkorhonen@0
|
1214 {
|
jtkorhonen@0
|
1215 workFolderPath = "";
|
jtkorhonen@0
|
1216 }
|
jtkorhonen@0
|
1217
|
jtkorhonen@0
|
1218 userInfo = settings.value("userinfo", "").toString();
|
jtkorhonen@0
|
1219
|
jtkorhonen@0
|
1220 QPoint pos = settings.value("pos", QPoint(200, 200)).toPoint();
|
jtkorhonen@0
|
1221 QSize size = settings.value("size", QSize(400, 400)).toSize();
|
jtkorhonen@0
|
1222 firstStart = settings.value("firststart", QVariant(true)).toBool();
|
jtkorhonen@0
|
1223
|
jtkorhonen@0
|
1224 initialFileTypesBits = (unsigned char) settings.value("viewFileTypes", QVariant(DEFAULT_HG_STAT_BITS)).toInt();
|
jtkorhonen@0
|
1225 resize(size);
|
jtkorhonen@0
|
1226 move(pos);
|
jtkorhonen@0
|
1227 }
|
jtkorhonen@0
|
1228
|
jtkorhonen@0
|
1229 void MainWindow::writeSettings()
|
jtkorhonen@0
|
1230 {
|
jtkorhonen@0
|
1231 QSettings settings("hgexplorer", "hgexplorer");
|
jtkorhonen@0
|
1232 settings.setValue("pos", pos());
|
jtkorhonen@0
|
1233 settings.setValue("size", size());
|
jtkorhonen@0
|
1234 settings.setValue("remoterepopath", remoteRepoPath);
|
jtkorhonen@0
|
1235 settings.setValue("workfolderpath", workFolderPath);
|
jtkorhonen@0
|
1236 settings.setValue("userinfo", userInfo);
|
jtkorhonen@0
|
1237 settings.setValue("firststart", firstStart);
|
jtkorhonen@0
|
1238 settings.setValue("viewFileTypes", hgExp -> getFileTypesBits());
|
jtkorhonen@0
|
1239 }
|
jtkorhonen@0
|
1240
|
jtkorhonen@0
|
1241
|
jtkorhonen@0
|
1242
|
jtkorhonen@0
|
1243
|