Chris@57
|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
jtkorhonen@0
|
2
|
Chris@57
|
3 /*
|
Chris@57
|
4 EasyMercurial
|
Chris@57
|
5
|
Chris@57
|
6 Based on HgExplorer by Jari Korhonen
|
Chris@57
|
7 Copyright (c) 2010 Jari Korhonen
|
Chris@57
|
8 Copyright (c) 2010 Chris Cannam
|
Chris@57
|
9 Copyright (c) 2010 Queen Mary, University of London
|
Chris@57
|
10
|
Chris@57
|
11 This program is free software; you can redistribute it and/or
|
Chris@57
|
12 modify it under the terms of the GNU General Public License as
|
Chris@57
|
13 published by the Free Software Foundation; either version 2 of the
|
Chris@57
|
14 License, or (at your option) any later version. See the file
|
Chris@57
|
15 COPYING included with this distribution for more information.
|
Chris@57
|
16 */
|
Chris@50
|
17
|
jtkorhonen@0
|
18 #include <QStringList>
|
jtkorhonen@0
|
19 #include <QDir>
|
jtkorhonen@24
|
20 #include <QNetworkInterface>
|
jtkorhonen@17
|
21 #include <QHostAddress>
|
jtkorhonen@17
|
22 #include <QHostInfo>
|
jtkorhonen@34
|
23 #include <QDesktopServices>
|
Chris@50
|
24 #include <QStatusBar>
|
Chris@50
|
25 #include <QMessageBox>
|
Chris@50
|
26 #include <QMenuBar>
|
Chris@50
|
27 #include <QApplication>
|
Chris@50
|
28 #include <QToolBar>
|
Chris@61
|
29 #include <QToolButton>
|
Chris@50
|
30 #include <QSettings>
|
jtkorhonen@0
|
31
|
Chris@53
|
32 #include "mainwindow.h"
|
Chris@53
|
33 #include "settingsdialog.h"
|
Chris@69
|
34 #include "multichoicedialog.h"
|
Chris@64
|
35 #include "startupdialog.h"
|
Chris@53
|
36 #include "colourset.h"
|
Chris@62
|
37 #include "debug.h"
|
Chris@74
|
38 #include "logparser.h"
|
Chris@53
|
39
|
jtkorhonen@0
|
40
|
jtkorhonen@0
|
41 MainWindow::MainWindow()
|
jtkorhonen@0
|
42 {
|
jtkorhonen@0
|
43 QString wndTitle;
|
jtkorhonen@0
|
44
|
jtkorhonen@0
|
45 createActions();
|
jtkorhonen@0
|
46 createMenus();
|
jtkorhonen@0
|
47 createToolBars();
|
jtkorhonen@0
|
48 createStatusBar();
|
jtkorhonen@0
|
49
|
jtkorhonen@0
|
50 runner = new HgRunner(this);
|
Chris@62
|
51 connect(runner, SIGNAL(commandCompleted()),
|
Chris@62
|
52 this, SLOT(commandCompleted()));
|
Chris@62
|
53 connect(runner, SIGNAL(commandFailed()),
|
Chris@62
|
54 this, SLOT(commandFailed()));
|
jtkorhonen@0
|
55 runningAction = ACT_NONE;
|
jtkorhonen@0
|
56 statusBar()->addPermanentWidget(runner);
|
jtkorhonen@0
|
57
|
Chris@61
|
58 setWindowTitle(tr("EasyMercurial"));
|
jtkorhonen@0
|
59
|
jtkorhonen@0
|
60 remoteRepoPath = "";
|
jtkorhonen@0
|
61 workFolderPath = "";
|
jtkorhonen@0
|
62
|
jtkorhonen@0
|
63 readSettings();
|
jtkorhonen@0
|
64
|
jtkorhonen@0
|
65 tabPage = 0;
|
jtkorhonen@33
|
66 justMerged = false;
|
jtkorhonen@0
|
67 hgExp = new HgExpWidget((QWidget *) this, remoteRepoPath, workFolderPath, initialFileTypesBits);
|
jtkorhonen@0
|
68 setCentralWidget(hgExp);
|
jtkorhonen@0
|
69
|
jtkorhonen@0
|
70 setUnifiedTitleAndToolBarOnMac(true);
|
jtkorhonen@0
|
71 connectActions();
|
jtkorhonen@0
|
72 enableDisableActions();
|
jtkorhonen@0
|
73
|
Chris@64
|
74 if (firstStart) {
|
Chris@64
|
75 startupDialog();
|
jtkorhonen@0
|
76 }
|
jtkorhonen@0
|
77
|
Chris@64
|
78 ColourSet *cs = ColourSet::instance();
|
Chris@64
|
79 cs->clearDefaultNames();
|
Chris@64
|
80 cs->addDefaultName("");
|
Chris@64
|
81 cs->addDefaultName(getUserInfo());
|
Chris@62
|
82
|
Chris@72
|
83 if (workFolderPath == "") {
|
Chris@72
|
84 open();
|
Chris@72
|
85 }
|
Chris@72
|
86
|
Chris@74
|
87 hgPaths();
|
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
|
Chris@64
|
97 QString MainWindow::getUserInfo() const
|
Chris@64
|
98 {
|
Chris@64
|
99 QSettings settings;
|
Chris@64
|
100 settings.beginGroup("User Information");
|
Chris@64
|
101 QString name = settings.value("name", getUserRealName()).toString();
|
Chris@64
|
102 QString email = settings.value("email", "").toString();
|
Chris@64
|
103
|
Chris@64
|
104 QString identifier;
|
Chris@64
|
105
|
Chris@64
|
106 if (email != "") {
|
Chris@64
|
107 identifier = QString("%1 <%2>").arg(name).arg(email);
|
Chris@64
|
108 } else {
|
Chris@64
|
109 identifier = name;
|
Chris@64
|
110 }
|
Chris@64
|
111
|
Chris@64
|
112 return identifier;
|
Chris@64
|
113 }
|
Chris@64
|
114
|
jtkorhonen@0
|
115 void MainWindow::about()
|
jtkorhonen@0
|
116 {
|
jtkorhonen@0
|
117 QMessageBox::about(this, tr("About HgExplorer"),
|
jtkorhonen@0
|
118 tr("<b>HgExplorer</b> tries to be Mercurial's <b>VSS Explorer:</b> ;-)<br><br>"
|
jtkorhonen@0
|
119 "-Hides command line in normal use<br>"
|
jtkorhonen@0
|
120 "-Makes common operations easier<br><br>"
|
jtkorhonen@0
|
121 "(c) 2010 (lgpl), Jari Korhonen (jtkorhonen@gmail.com)<br><br>"
|
jtkorhonen@0
|
122 "-Needs Mercurial ;-) (thanks Matt Mackall, Bryan O'Sullivan and others !)<br>"
|
jtkorhonen@0
|
123 "-Uses excellent Nuvola icons (c) David Vignoni (Thanks, David !)<br>"
|
jtkorhonen@29
|
124 "-Needs Qt4, mingw (in windows), python, kdiff3 (Thanks to all of you !)<br>"
|
jtkorhonen@29
|
125 "-Windows standalone install uses hg / python / kdiff3 from TortoiseHg (BIG Thanks !)<br>"
|
jtkorhonen@29
|
126 "-Windows standalone install uses InstallJammer setup tool (Thanks, great tool !)<br>"));
|
jtkorhonen@0
|
127 }
|
jtkorhonen@0
|
128
|
jtkorhonen@0
|
129
|
jtkorhonen@0
|
130 void MainWindow::hgStat()
|
jtkorhonen@0
|
131 {
|
Chris@73
|
132 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
133 {
|
Chris@73
|
134 QStringList params;
|
Chris@73
|
135
|
Chris@73
|
136 QString statFlags = hgExp -> getStatFlags();
|
Chris@73
|
137 if (statFlags.isEmpty())
|
jtkorhonen@0
|
138 {
|
Chris@73
|
139 params << "stat";
|
jtkorhonen@0
|
140 }
|
Chris@73
|
141 else
|
Chris@73
|
142 {
|
Chris@73
|
143 params << "stat" << "-" + statFlags;
|
Chris@73
|
144 }
|
Chris@73
|
145
|
Chris@73
|
146
|
Chris@73
|
147 runner -> startHgCommand(workFolderPath, params);
|
Chris@73
|
148 runningAction = ACT_STAT;
|
jtkorhonen@0
|
149 }
|
jtkorhonen@0
|
150 }
|
jtkorhonen@0
|
151
|
Chris@74
|
152 void MainWindow::hgPaths()
|
Chris@74
|
153 {
|
Chris@74
|
154 if (runningAction == ACT_NONE)
|
Chris@74
|
155 {
|
Chris@74
|
156 QStringList params;
|
Chris@74
|
157 params << "paths";
|
Chris@74
|
158 runner -> startHgCommand(workFolderPath, params);
|
Chris@74
|
159 runningAction = ACT_PATHS;
|
Chris@74
|
160 }
|
Chris@74
|
161 }
|
Chris@74
|
162
|
jtkorhonen@0
|
163 void MainWindow::hgHeads()
|
jtkorhonen@0
|
164 {
|
jtkorhonen@0
|
165 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
166 {
|
jtkorhonen@0
|
167 QStringList params;
|
jtkorhonen@0
|
168 params << "heads";
|
jtkorhonen@0
|
169
|
jtkorhonen@0
|
170 //on empty repos, "hg heads" will fail, don't care of that.
|
Chris@62
|
171 runner -> startHgCommand(workFolderPath, params);
|
jtkorhonen@0
|
172 runningAction = ACT_HEADS;
|
jtkorhonen@0
|
173 }
|
jtkorhonen@0
|
174 }
|
jtkorhonen@0
|
175
|
jtkorhonen@0
|
176 void MainWindow::hgLog()
|
jtkorhonen@0
|
177 {
|
jtkorhonen@0
|
178 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
179 {
|
jtkorhonen@0
|
180 QStringList params;
|
Chris@43
|
181 params << "log";
|
Chris@43
|
182 params << "--template";
|
Chris@52
|
183 params << "id: {rev}:{node|short}\\nauthor: {author}\\nbranch: {branches}\\ntag: {tag}\\ndatetime: {date|isodate}\\ntimestamp: {date|hgdate}\\nage: {date|age}\\nparents: {parents}\\ncomment: {desc|json}\\n\\n";
|
jtkorhonen@0
|
184
|
Chris@62
|
185 runner -> startHgCommand(workFolderPath, params);
|
jtkorhonen@0
|
186 runningAction = ACT_LOG;
|
jtkorhonen@0
|
187 }
|
jtkorhonen@0
|
188 }
|
jtkorhonen@0
|
189
|
jtkorhonen@0
|
190
|
jtkorhonen@0
|
191 void MainWindow::hgParents()
|
jtkorhonen@0
|
192 {
|
jtkorhonen@0
|
193 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
194 {
|
jtkorhonen@0
|
195 QStringList params;
|
jtkorhonen@0
|
196 params << "parents";
|
jtkorhonen@0
|
197
|
Chris@62
|
198 runner -> startHgCommand(workFolderPath, params);
|
jtkorhonen@0
|
199 runningAction = ACT_PARENTS;
|
jtkorhonen@0
|
200 }
|
jtkorhonen@0
|
201 }
|
jtkorhonen@0
|
202
|
jtkorhonen@0
|
203
|
jtkorhonen@0
|
204
|
jtkorhonen@0
|
205 void MainWindow::hgRemove()
|
jtkorhonen@0
|
206 {
|
jtkorhonen@0
|
207 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
208 {
|
jtkorhonen@0
|
209 QStringList params;
|
jtkorhonen@0
|
210 QString currentFile = hgExp -> getCurrentFileListLine();
|
jtkorhonen@0
|
211
|
jtkorhonen@0
|
212 if (!currentFile.isEmpty())
|
jtkorhonen@0
|
213 {
|
jtkorhonen@6
|
214 if (QMessageBox::Ok == QMessageBox::warning(this, "Remove file", "Really remove file " + currentFile.mid(2) + "?",
|
jtkorhonen@6
|
215 QMessageBox::Ok | QMessageBox::Cancel, QMessageBox::Cancel))
|
jtkorhonen@6
|
216 {
|
mg@41
|
217 params << "remove" << "--after" << "--force" << "--" << currentFile.mid(2); //Jump over status marker characters (e.g "M ")
|
jtkorhonen@0
|
218
|
Chris@62
|
219 runner -> startHgCommand(workFolderPath, params);
|
jtkorhonen@6
|
220 runningAction = ACT_REMOVE;
|
jtkorhonen@6
|
221 }
|
jtkorhonen@0
|
222 }
|
jtkorhonen@0
|
223 }
|
jtkorhonen@0
|
224 }
|
jtkorhonen@0
|
225
|
jtkorhonen@0
|
226 void MainWindow::hgAnnotate()
|
jtkorhonen@0
|
227 {
|
jtkorhonen@0
|
228 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
229 {
|
jtkorhonen@0
|
230 QStringList params;
|
jtkorhonen@0
|
231 QString currentFile = hgExp -> getCurrentFileListLine();
|
jtkorhonen@0
|
232
|
jtkorhonen@0
|
233 if (!currentFile.isEmpty())
|
jtkorhonen@0
|
234 {
|
mg@41
|
235 params << "annotate" << "--" << currentFile.mid(2); //Jump over status marker characters (e.g "M ")
|
jtkorhonen@0
|
236
|
Chris@62
|
237 runner -> startHgCommand(workFolderPath, params);
|
jtkorhonen@0
|
238 runningAction = ACT_ANNOTATE;
|
jtkorhonen@0
|
239 }
|
jtkorhonen@0
|
240 }
|
jtkorhonen@0
|
241 }
|
jtkorhonen@0
|
242
|
jtkorhonen@0
|
243
|
jtkorhonen@0
|
244 void MainWindow::hgResolveMark()
|
jtkorhonen@0
|
245 {
|
jtkorhonen@0
|
246 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
247 {
|
jtkorhonen@0
|
248 QStringList params;
|
jtkorhonen@0
|
249 QString currentFile = hgExp -> getCurrentFileListLine();
|
jtkorhonen@0
|
250
|
jtkorhonen@0
|
251 if (!currentFile.isEmpty())
|
jtkorhonen@0
|
252 {
|
mg@41
|
253 params << "resolve" << "--mark" << "--" << currentFile.mid(2); //Jump over status marker characters (e.g "M ")
|
jtkorhonen@0
|
254
|
Chris@62
|
255 runner -> startHgCommand(workFolderPath, params);
|
jtkorhonen@0
|
256 runningAction = ACT_RESOLVE_MARK;
|
jtkorhonen@0
|
257 }
|
jtkorhonen@0
|
258 }
|
jtkorhonen@0
|
259 }
|
jtkorhonen@0
|
260
|
jtkorhonen@0
|
261
|
jtkorhonen@0
|
262
|
jtkorhonen@0
|
263 void MainWindow::hgResolveList()
|
jtkorhonen@0
|
264 {
|
jtkorhonen@0
|
265 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
266 {
|
jtkorhonen@0
|
267 QStringList params;
|
jtkorhonen@0
|
268
|
jtkorhonen@0
|
269 params << "resolve" << "--list";
|
Chris@62
|
270 runner -> startHgCommand(workFolderPath, params);
|
jtkorhonen@0
|
271 runningAction = ACT_RESOLVE_LIST;
|
jtkorhonen@0
|
272 }
|
jtkorhonen@0
|
273 }
|
jtkorhonen@0
|
274
|
jtkorhonen@0
|
275
|
jtkorhonen@0
|
276
|
jtkorhonen@0
|
277 void MainWindow::hgAdd()
|
jtkorhonen@0
|
278 {
|
jtkorhonen@0
|
279 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
280 {
|
jtkorhonen@0
|
281 QStringList params;
|
jtkorhonen@0
|
282
|
jtkorhonen@5
|
283 QString currentFile = hgExp -> getCurrentFileListLine();
|
jtkorhonen@5
|
284
|
jtkorhonen@17
|
285 if (areAllSelectedUntracked(hgExp -> workFolderFileList))
|
jtkorhonen@5
|
286 {
|
jtkorhonen@17
|
287 //User wants to add selected file(s)
|
jtkorhonen@42
|
288 params << "add" << "--";
|
jtkorhonen@17
|
289
|
jtkorhonen@17
|
290 QList <QListWidgetItem *> selList = hgExp -> workFolderFileList -> selectedItems();
|
jtkorhonen@17
|
291
|
jtkorhonen@17
|
292 for (int i = 0; i < selList.size(); ++i)
|
jtkorhonen@17
|
293 {
|
jtkorhonen@17
|
294 QString tmp = selList.at(i)->text();
|
jtkorhonen@17
|
295 params.append(tmp.mid(2));
|
jtkorhonen@17
|
296 }
|
jtkorhonen@5
|
297 }
|
jtkorhonen@5
|
298 else
|
jtkorhonen@5
|
299 {
|
jtkorhonen@5
|
300 //Add all untracked files
|
jtkorhonen@5
|
301 params << "add";
|
jtkorhonen@5
|
302 }
|
jtkorhonen@0
|
303
|
Chris@62
|
304 runner -> startHgCommand(workFolderPath, params);
|
jtkorhonen@0
|
305 runningAction = ACT_ADD;
|
jtkorhonen@0
|
306 }
|
jtkorhonen@0
|
307 }
|
jtkorhonen@0
|
308
|
jtkorhonen@34
|
309 int MainWindow::getCommentOrTag(QString& commentOrTag, QString question, QString dlgTitle)
|
jtkorhonen@0
|
310 {
|
jtkorhonen@0
|
311 int ret;
|
jtkorhonen@0
|
312
|
jtkorhonen@0
|
313 QDialog dlg(this);
|
jtkorhonen@0
|
314
|
jtkorhonen@34
|
315 QLabel *commentLabel = new QLabel(question);
|
jtkorhonen@34
|
316 QLineEdit *commentOrTagEdit = new QLineEdit;
|
jtkorhonen@34
|
317 commentOrTagEdit -> setFixedWidth(400);
|
jtkorhonen@0
|
318 QHBoxLayout *commentLayout = new QHBoxLayout;
|
jtkorhonen@0
|
319 commentLayout -> addWidget(commentLabel);
|
jtkorhonen@34
|
320 commentLayout -> addWidget(commentOrTagEdit);
|
jtkorhonen@0
|
321
|
jtkorhonen@0
|
322 QPushButton *btnOk = new QPushButton(tr("Ok"));
|
jtkorhonen@0
|
323 QPushButton *btnCancel = new QPushButton(tr("Cancel"));
|
jtkorhonen@0
|
324 QHBoxLayout *btnLayout = new QHBoxLayout;
|
jtkorhonen@0
|
325 btnLayout -> addWidget(btnOk);
|
jtkorhonen@0
|
326 btnLayout -> addWidget(btnCancel);
|
jtkorhonen@0
|
327
|
jtkorhonen@0
|
328 QVBoxLayout *mainLayout = new QVBoxLayout;
|
jtkorhonen@0
|
329 mainLayout -> addLayout(commentLayout);
|
jtkorhonen@0
|
330 mainLayout -> addLayout(btnLayout);
|
jtkorhonen@0
|
331
|
jtkorhonen@0
|
332 dlg.setLayout(mainLayout);
|
jtkorhonen@0
|
333
|
jtkorhonen@34
|
334 dlg.setWindowTitle(dlgTitle);
|
jtkorhonen@0
|
335
|
jtkorhonen@0
|
336 connect(btnOk, SIGNAL(clicked()), &dlg, SLOT(accept()));
|
jtkorhonen@0
|
337 connect(btnCancel, SIGNAL(clicked()), &dlg, SLOT(reject()));
|
jtkorhonen@0
|
338
|
jtkorhonen@0
|
339 ret = dlg.exec();
|
jtkorhonen@34
|
340 commentOrTag = commentOrTagEdit -> text();
|
jtkorhonen@0
|
341 return ret;
|
jtkorhonen@0
|
342 }
|
jtkorhonen@0
|
343
|
jtkorhonen@0
|
344 void MainWindow::hgCommit()
|
jtkorhonen@0
|
345 {
|
jtkorhonen@0
|
346 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
347 {
|
jtkorhonen@0
|
348 QStringList params;
|
jtkorhonen@0
|
349 QString comment;
|
jtkorhonen@0
|
350
|
jtkorhonen@34
|
351 if (QDialog::Accepted == getCommentOrTag(comment, tr("Comment:"), tr("Save (commit)")))
|
jtkorhonen@0
|
352 {
|
jtkorhonen@0
|
353 if (!comment.isEmpty())
|
jtkorhonen@0
|
354 {
|
jtkorhonen@33
|
355 if ((justMerged == false) && (areAllSelectedCommitable(hgExp -> workFolderFileList)))
|
jtkorhonen@11
|
356 {
|
jtkorhonen@33
|
357 //User wants to commit selected file(s) (and this is not merge commit, which would fail if we selected files)
|
Chris@64
|
358 params << "commit" << "--message" << comment << "--user" << getUserInfo() << "--";
|
jtkorhonen@17
|
359
|
jtkorhonen@17
|
360 QList <QListWidgetItem *> selList = hgExp -> workFolderFileList -> selectedItems();
|
jtkorhonen@17
|
361 for (int i = 0; i < selList.size(); ++i)
|
jtkorhonen@17
|
362 {
|
jtkorhonen@17
|
363 QString tmp = selList.at(i)->text();
|
jtkorhonen@17
|
364 params.append(tmp.mid(2));
|
jtkorhonen@17
|
365 }
|
jtkorhonen@11
|
366 }
|
jtkorhonen@11
|
367 else
|
jtkorhonen@11
|
368 {
|
jtkorhonen@11
|
369 //Commit all changes
|
Chris@64
|
370 params << "commit" << "--message" << comment << "--user" << getUserInfo();
|
jtkorhonen@11
|
371 }
|
jtkorhonen@0
|
372
|
Chris@62
|
373 runner -> startHgCommand(workFolderPath, params);
|
jtkorhonen@0
|
374 runningAction = ACT_COMMIT;
|
jtkorhonen@0
|
375 }
|
jtkorhonen@0
|
376 }
|
jtkorhonen@0
|
377 }
|
jtkorhonen@0
|
378 }
|
jtkorhonen@0
|
379
|
jtkorhonen@34
|
380 QString MainWindow::filterTag(QString tag)
|
jtkorhonen@34
|
381 {
|
jtkorhonen@34
|
382 for(int i = 0; i < tag.size(); i++)
|
jtkorhonen@34
|
383 {
|
jtkorhonen@34
|
384 if (tag[i].isLower() || tag[i].isUpper() || tag[i].isDigit() || (tag[i] == QChar('.')))
|
jtkorhonen@34
|
385 {
|
jtkorhonen@34
|
386 //ok
|
jtkorhonen@34
|
387 }
|
jtkorhonen@34
|
388 else
|
jtkorhonen@34
|
389 {
|
jtkorhonen@34
|
390 tag[i] = QChar('_');
|
jtkorhonen@34
|
391 }
|
jtkorhonen@34
|
392 }
|
jtkorhonen@34
|
393 return tag;
|
jtkorhonen@34
|
394 }
|
jtkorhonen@34
|
395
|
jtkorhonen@34
|
396
|
jtkorhonen@34
|
397 void MainWindow::hgTag()
|
jtkorhonen@34
|
398 {
|
jtkorhonen@34
|
399 if (runningAction == ACT_NONE)
|
jtkorhonen@34
|
400 {
|
jtkorhonen@34
|
401 QStringList params;
|
jtkorhonen@34
|
402 QString tag;
|
jtkorhonen@34
|
403
|
jtkorhonen@34
|
404 if (QDialog::Accepted == getCommentOrTag(tag, tr("Tag:"), tr("Tag")))
|
jtkorhonen@34
|
405 {
|
jtkorhonen@34
|
406 if (!tag.isEmpty())
|
jtkorhonen@34
|
407 {
|
Chris@64
|
408 params << "tag" << "--user" << getUserInfo() << filterTag(tag);
|
jtkorhonen@34
|
409
|
Chris@62
|
410 runner -> startHgCommand(workFolderPath, params);
|
jtkorhonen@34
|
411 runningAction = ACT_TAG;
|
jtkorhonen@34
|
412 }
|
jtkorhonen@34
|
413 }
|
jtkorhonen@34
|
414 }
|
jtkorhonen@34
|
415 }
|
jtkorhonen@34
|
416
|
jtkorhonen@34
|
417
|
jtkorhonen@34
|
418 void MainWindow::hgIgnore()
|
jtkorhonen@34
|
419 {
|
jtkorhonen@34
|
420 if (runningAction == ACT_NONE)
|
jtkorhonen@34
|
421 {
|
jtkorhonen@34
|
422 QString hgIgnorePath;
|
jtkorhonen@36
|
423 QStringList params;
|
jtkorhonen@36
|
424 QString editorName;
|
jtkorhonen@34
|
425
|
jtkorhonen@36
|
426 hgIgnorePath = workFolderPath;
|
jtkorhonen@34
|
427 hgIgnorePath += ".hgignore";
|
jtkorhonen@34
|
428
|
jtkorhonen@36
|
429 params << hgIgnorePath;
|
jtkorhonen@36
|
430
|
jtkorhonen@36
|
431 if ((getSystem() == "Linux"))
|
jtkorhonen@36
|
432 {
|
jtkorhonen@36
|
433 editorName = "gedit";
|
jtkorhonen@36
|
434 }
|
jtkorhonen@36
|
435 else
|
jtkorhonen@36
|
436 {
|
jtkorhonen@36
|
437 editorName = """C:\\Program Files\\Windows NT\\Accessories\\wordpad.exe""";
|
jtkorhonen@36
|
438 }
|
jtkorhonen@36
|
439
|
Chris@62
|
440 runner -> startCommand(editorName, workFolderPath, params);
|
jtkorhonen@36
|
441 runningAction = ACT_HG_IGNORE;
|
jtkorhonen@34
|
442 }
|
jtkorhonen@34
|
443 }
|
jtkorhonen@34
|
444
|
jtkorhonen@34
|
445
|
jtkorhonen@34
|
446
|
jtkorhonen@0
|
447 void MainWindow::hgFileDiff()
|
jtkorhonen@0
|
448 {
|
jtkorhonen@0
|
449 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
450 {
|
jtkorhonen@0
|
451 QStringList params;
|
jtkorhonen@0
|
452
|
jtkorhonen@0
|
453 QString currentFile = hgExp -> getCurrentFileListLine();
|
jtkorhonen@0
|
454
|
jtkorhonen@0
|
455 if (!currentFile.isEmpty())
|
jtkorhonen@0
|
456 {
|
jtkorhonen@0
|
457 //Diff parent file against working folder file
|
mg@41
|
458 params << "kdiff3" << "--" << currentFile.mid(2);
|
Chris@62
|
459 runner -> startHgCommand(workFolderPath, params);
|
jtkorhonen@0
|
460 runningAction = ACT_FILEDIFF;
|
jtkorhonen@0
|
461 }
|
jtkorhonen@0
|
462 }
|
jtkorhonen@0
|
463 }
|
jtkorhonen@0
|
464
|
jtkorhonen@0
|
465
|
jtkorhonen@0
|
466 void MainWindow::hgFolderDiff()
|
jtkorhonen@0
|
467 {
|
jtkorhonen@0
|
468 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
469 {
|
jtkorhonen@0
|
470 QStringList params;
|
jtkorhonen@0
|
471
|
jtkorhonen@0
|
472 //Diff parent against working folder (folder diff)
|
jtkorhonen@0
|
473 params << "kdiff3";
|
Chris@62
|
474 runner -> startHgCommand(workFolderPath, params);
|
jtkorhonen@0
|
475 runningAction = ACT_FOLDERDIFF;
|
jtkorhonen@0
|
476 }
|
jtkorhonen@0
|
477 }
|
jtkorhonen@0
|
478
|
jtkorhonen@0
|
479
|
jtkorhonen@0
|
480 void MainWindow::hgChgSetDiff()
|
jtkorhonen@0
|
481 {
|
jtkorhonen@0
|
482 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
483 {
|
jtkorhonen@0
|
484 QStringList params;
|
jtkorhonen@0
|
485
|
jtkorhonen@0
|
486 //Diff 2 history log versions against each other
|
jtkorhonen@0
|
487 QString revA;
|
jtkorhonen@0
|
488 QString revB;
|
jtkorhonen@0
|
489
|
jtkorhonen@0
|
490 hgExp -> getHistoryDiffRevisions(revA, revB);
|
jtkorhonen@0
|
491
|
jtkorhonen@0
|
492 if ((!revA.isEmpty()) && (!revB.isEmpty()))
|
jtkorhonen@0
|
493 {
|
jtkorhonen@0
|
494 params << "kdiff3" << "--rev" << revA << "--rev" << revB;
|
Chris@62
|
495 runner -> startHgCommand(workFolderPath, params);
|
jtkorhonen@0
|
496 runningAction = ACT_CHGSETDIFF;
|
jtkorhonen@0
|
497 }
|
jtkorhonen@0
|
498 else
|
jtkorhonen@0
|
499 {
|
jtkorhonen@0
|
500 QMessageBox::information(this, tr("Changeset diff"), tr("Please select two changesets from history list or heads list first."));
|
jtkorhonen@0
|
501 }
|
jtkorhonen@0
|
502 }
|
jtkorhonen@0
|
503 }
|
jtkorhonen@0
|
504
|
jtkorhonen@0
|
505
|
jtkorhonen@0
|
506
|
jtkorhonen@0
|
507 void MainWindow::hgUpdate()
|
jtkorhonen@0
|
508 {
|
jtkorhonen@0
|
509 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
510 {
|
jtkorhonen@0
|
511 QStringList params;
|
jtkorhonen@0
|
512
|
jtkorhonen@0
|
513
|
jtkorhonen@0
|
514 params << "update";
|
jtkorhonen@0
|
515
|
jtkorhonen@0
|
516
|
Chris@62
|
517 runner -> startHgCommand(workFolderPath, params);
|
jtkorhonen@0
|
518 runningAction = ACT_UPDATE;
|
jtkorhonen@0
|
519 }
|
jtkorhonen@0
|
520 }
|
jtkorhonen@0
|
521
|
jtkorhonen@0
|
522
|
jtkorhonen@0
|
523 void MainWindow::hgUpdateToRev()
|
jtkorhonen@0
|
524 {
|
jtkorhonen@0
|
525 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
526 {
|
jtkorhonen@0
|
527 QStringList params;
|
jtkorhonen@0
|
528 QString rev;
|
jtkorhonen@0
|
529
|
jtkorhonen@0
|
530 hgExp -> getUpdateToRevRevision(rev);
|
jtkorhonen@0
|
531
|
jtkorhonen@0
|
532 hgExp -> setCurrentIndex(WORKTAB);
|
jtkorhonen@0
|
533 enableDisableActions();
|
jtkorhonen@0
|
534
|
jtkorhonen@0
|
535 params << "update" << "--rev" << rev << "--clean";
|
jtkorhonen@0
|
536
|
Chris@62
|
537 runner -> startHgCommand(workFolderPath, params);
|
jtkorhonen@0
|
538
|
jtkorhonen@0
|
539 runningAction = ACT_UPDATE;
|
jtkorhonen@0
|
540 }
|
jtkorhonen@0
|
541 }
|
jtkorhonen@0
|
542
|
jtkorhonen@0
|
543
|
jtkorhonen@0
|
544 void MainWindow::hgRevert()
|
jtkorhonen@0
|
545 {
|
jtkorhonen@0
|
546 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
547 {
|
jtkorhonen@0
|
548 QStringList params;
|
jtkorhonen@0
|
549 QString currentFile = hgExp -> getCurrentFileListLine();
|
jtkorhonen@0
|
550
|
mg@41
|
551 params << "revert" << "--no-backup" << "--" << currentFile.mid(2);
|
jtkorhonen@0
|
552
|
Chris@62
|
553 runner -> startHgCommand(workFolderPath, params);
|
jtkorhonen@0
|
554 runningAction = ACT_REVERT;
|
jtkorhonen@0
|
555 }
|
jtkorhonen@0
|
556 }
|
jtkorhonen@0
|
557
|
jtkorhonen@33
|
558 void MainWindow::hgRetryMerge()
|
jtkorhonen@33
|
559 {
|
jtkorhonen@33
|
560 if (runningAction == ACT_NONE)
|
jtkorhonen@33
|
561 {
|
jtkorhonen@33
|
562 QStringList params;
|
jtkorhonen@33
|
563
|
jtkorhonen@33
|
564 params << "resolve" << "--all";
|
Chris@62
|
565 runner -> startHgCommand(workFolderPath, params);
|
jtkorhonen@33
|
566 runningAction = ACT_RETRY_MERGE;
|
jtkorhonen@33
|
567 }
|
jtkorhonen@33
|
568 }
|
jtkorhonen@33
|
569
|
jtkorhonen@33
|
570
|
jtkorhonen@0
|
571 void MainWindow::hgMerge()
|
jtkorhonen@0
|
572 {
|
jtkorhonen@0
|
573 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
574 {
|
jtkorhonen@0
|
575 QStringList params;
|
jtkorhonen@0
|
576
|
jtkorhonen@0
|
577 params << "merge";
|
jtkorhonen@0
|
578
|
Chris@62
|
579 runner -> startHgCommand(workFolderPath, params);
|
jtkorhonen@0
|
580 runningAction = ACT_MERGE;
|
jtkorhonen@0
|
581 }
|
jtkorhonen@0
|
582 }
|
jtkorhonen@0
|
583
|
jtkorhonen@0
|
584
|
jtkorhonen@0
|
585 void MainWindow::hgCloneFromRemote()
|
jtkorhonen@0
|
586 {
|
jtkorhonen@0
|
587 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
588 {
|
jtkorhonen@0
|
589 QStringList params;
|
jtkorhonen@0
|
590
|
jtkorhonen@0
|
591 params << "clone" << remoteRepoPath << workFolderPath;
|
jtkorhonen@0
|
592
|
Chris@62
|
593 runner -> startHgCommand(workFolderPath, params);
|
jtkorhonen@0
|
594 runningAction = ACT_CLONEFROMREMOTE;
|
jtkorhonen@0
|
595 }
|
jtkorhonen@0
|
596 }
|
jtkorhonen@0
|
597
|
jtkorhonen@0
|
598
|
jtkorhonen@0
|
599 void MainWindow::hgInit()
|
jtkorhonen@0
|
600 {
|
jtkorhonen@0
|
601 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
602 {
|
jtkorhonen@0
|
603 QStringList params;
|
jtkorhonen@0
|
604
|
jtkorhonen@0
|
605 params << "init";
|
jtkorhonen@0
|
606
|
Chris@62
|
607 runner -> startHgCommand(workFolderPath, params);
|
jtkorhonen@0
|
608 runningAction = ACT_INIT;
|
jtkorhonen@0
|
609 }
|
jtkorhonen@0
|
610 }
|
jtkorhonen@0
|
611
|
jtkorhonen@0
|
612
|
jtkorhonen@0
|
613 void MainWindow::hgIncoming()
|
jtkorhonen@0
|
614 {
|
jtkorhonen@0
|
615 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
616 {
|
jtkorhonen@0
|
617 QStringList params;
|
jtkorhonen@0
|
618
|
jtkorhonen@0
|
619 params << "incoming" << "--newest-first" << remoteRepoPath;
|
jtkorhonen@0
|
620
|
Chris@62
|
621 runner -> startHgCommand(workFolderPath, params);
|
jtkorhonen@0
|
622 runningAction = ACT_INCOMING;
|
jtkorhonen@0
|
623 }
|
jtkorhonen@0
|
624 }
|
jtkorhonen@0
|
625
|
jtkorhonen@0
|
626
|
jtkorhonen@0
|
627 void MainWindow::hgPull()
|
jtkorhonen@0
|
628 {
|
jtkorhonen@0
|
629 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
630 {
|
jtkorhonen@0
|
631 QStringList params;
|
jtkorhonen@0
|
632
|
jtkorhonen@0
|
633 params << "pull" << remoteRepoPath;
|
jtkorhonen@0
|
634
|
Chris@62
|
635 runner -> startHgCommand(workFolderPath, params);
|
jtkorhonen@0
|
636 runningAction = ACT_PULL;
|
jtkorhonen@0
|
637 }
|
jtkorhonen@0
|
638 }
|
jtkorhonen@0
|
639
|
jtkorhonen@0
|
640
|
jtkorhonen@0
|
641 void MainWindow::hgPush()
|
jtkorhonen@0
|
642 {
|
jtkorhonen@0
|
643 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
644 {
|
jtkorhonen@0
|
645 QStringList params;
|
jtkorhonen@0
|
646
|
jtkorhonen@0
|
647 params << "push" << remoteRepoPath;
|
jtkorhonen@0
|
648
|
Chris@62
|
649 runner -> startHgCommand(workFolderPath, params);
|
jtkorhonen@0
|
650 runningAction = ACT_PUSH;
|
jtkorhonen@0
|
651 }
|
jtkorhonen@0
|
652 }
|
jtkorhonen@0
|
653
|
jtkorhonen@0
|
654
|
jtkorhonen@28
|
655 QString MainWindow::listAllUpIpV4Addresses()
|
jtkorhonen@26
|
656 {
|
jtkorhonen@28
|
657 QString ret;
|
jtkorhonen@26
|
658 QList<QNetworkInterface> ifaces = QNetworkInterface::allInterfaces();
|
jtkorhonen@26
|
659
|
jtkorhonen@26
|
660 for (int i = 0; i < ifaces.count(); i++)
|
jtkorhonen@26
|
661 {
|
jtkorhonen@26
|
662 QNetworkInterface iface = ifaces.at(i);
|
jtkorhonen@26
|
663
|
jtkorhonen@26
|
664 if (iface.flags().testFlag(QNetworkInterface::IsUp) && !iface.flags().testFlag(QNetworkInterface::IsLoopBack))
|
jtkorhonen@26
|
665 {
|
jtkorhonen@26
|
666 for (int j=0; j<iface.addressEntries().count(); j++)
|
jtkorhonen@26
|
667 {
|
jtkorhonen@28
|
668 QHostAddress tmp = iface.addressEntries().at(j).ip();
|
jtkorhonen@28
|
669 if (QAbstractSocket::IPv4Protocol == tmp.protocol())
|
jtkorhonen@24
|
670 {
|
jtkorhonen@28
|
671 if (!ret.isEmpty())
|
jtkorhonen@28
|
672 {
|
jtkorhonen@28
|
673 ret += " ";
|
jtkorhonen@28
|
674 }
|
jtkorhonen@28
|
675 ret += tmp.toString();
|
jtkorhonen@24
|
676 }
|
jtkorhonen@24
|
677 }
|
jtkorhonen@22
|
678 }
|
jtkorhonen@17
|
679 }
|
jtkorhonen@28
|
680 return ret;
|
jtkorhonen@28
|
681 }
|
jtkorhonen@17
|
682
|
jtkorhonen@17
|
683
|
jtkorhonen@11
|
684 void MainWindow::hgServe()
|
jtkorhonen@11
|
685 {
|
jtkorhonen@11
|
686 if (runningAction == ACT_NONE)
|
jtkorhonen@11
|
687 {
|
jtkorhonen@11
|
688 QStringList params;
|
jtkorhonen@22
|
689 QString msg;
|
jtkorhonen@11
|
690
|
jtkorhonen@28
|
691 QString addrs = listAllUpIpV4Addresses();
|
jtkorhonen@28
|
692 QTextStream(&msg) << "Server running on address(es) (" << addrs << "), port 8000";
|
jtkorhonen@28
|
693 params << "serve";
|
jtkorhonen@11
|
694
|
Chris@62
|
695 runner -> startHgCommand(workFolderPath, params);
|
jtkorhonen@11
|
696 runningAction = ACT_SERVE;
|
jtkorhonen@11
|
697
|
jtkorhonen@17
|
698 QMessageBox::information(this, "Serve", msg, QMessageBox::Close);
|
Chris@62
|
699 runner -> killCurrentCommand();
|
jtkorhonen@11
|
700 }
|
jtkorhonen@11
|
701 }
|
jtkorhonen@11
|
702
|
jtkorhonen@11
|
703
|
Chris@64
|
704 void MainWindow::startupDialog()
|
Chris@64
|
705 {
|
Chris@64
|
706 StartupDialog *dlg = new StartupDialog(this);
|
Chris@65
|
707 if (dlg->exec()) firstStart = false;
|
Chris@64
|
708 }
|
Chris@64
|
709
|
jtkorhonen@11
|
710
|
Chris@69
|
711 void MainWindow::open()
|
Chris@69
|
712 {
|
Chris@69
|
713 MultiChoiceDialog *d = new MultiChoiceDialog
|
Chris@69
|
714 (tr("Open Repository"),
|
Chris@72
|
715 tr("<qt><big>What would you like to open?</big></qt>"),
|
Chris@69
|
716 this);
|
Chris@69
|
717
|
Chris@69
|
718 d->addChoice("remote",
|
Chris@69
|
719 tr("<qt><center><img src=\":images/browser-64.png\"><br>Remote repository</center></qt>"),
|
Chris@72
|
720 tr("Open a remote Mercurial repository, by cloning from its URL into a local folder."),
|
Chris@72
|
721 MultiChoiceDialog::UrlToDirectoryArg);
|
Chris@69
|
722
|
Chris@69
|
723 d->addChoice("local",
|
Chris@69
|
724 tr("<qt><center><img src=\":images/hglogo-64.png\"><br>Local repository</center></qt>"),
|
Chris@69
|
725 tr("Open an existing local Mercurial repository."),
|
Chris@69
|
726 MultiChoiceDialog::DirectoryArg);
|
Chris@69
|
727
|
Chris@69
|
728 d->addChoice("init",
|
Chris@69
|
729 tr("<qt><center><img src=\":images/hdd_unmount-64.png\"><br>File folder</center></qt>"),
|
Chris@69
|
730 tr("Open a local folder, by creating a Mercurial repository in it."),
|
Chris@69
|
731 MultiChoiceDialog::DirectoryArg);
|
Chris@69
|
732
|
Chris@69
|
733 d->setCurrentChoice("local");
|
Chris@69
|
734
|
Chris@69
|
735 if (d->exec() == QDialog::Accepted) {
|
Chris@69
|
736
|
Chris@69
|
737 QString choice = d->getCurrentChoice();
|
Chris@69
|
738 QString arg = d->getArgument().trimmed();
|
Chris@69
|
739
|
Chris@69
|
740 if (choice == "local") {
|
Chris@73
|
741 DEBUG << "open " << arg << endl;
|
Chris@69
|
742 workFolderPath = arg;
|
Chris@73
|
743 remoteRepoPath = "";
|
Chris@72
|
744 } else if (choice == "remote") {
|
Chris@72
|
745 DEBUG << "clone " << arg << " to " << d->getAdditionalArgument().trimmed() << endl;
|
Chris@73
|
746 //!!! check that work folder does not exist, append to it if it does
|
Chris@73
|
747 } else if (choice == "init") {
|
Chris@73
|
748 DEBUG << "init " << arg << endl;
|
Chris@69
|
749 //!!!
|
Chris@69
|
750 }
|
Chris@69
|
751
|
Chris@69
|
752 hgExp->clearLists();
|
Chris@69
|
753 enableDisableActions();
|
Chris@74
|
754 hgPaths();
|
Chris@69
|
755 }
|
Chris@69
|
756
|
Chris@69
|
757 delete d;
|
Chris@69
|
758 }
|
Chris@69
|
759
|
jtkorhonen@0
|
760 void MainWindow::settings()
|
jtkorhonen@0
|
761 {
|
Chris@69
|
762 /*!!!
|
jtkorhonen@0
|
763 SettingsDialog *settingsDlg = new SettingsDialog(this);
|
jtkorhonen@0
|
764 settingsDlg->setModal(true);
|
jtkorhonen@0
|
765 settingsDlg->exec();
|
jtkorhonen@0
|
766 hgExp -> clearLists();
|
jtkorhonen@0
|
767 enableDisableActions();
|
jtkorhonen@0
|
768 hgStat();
|
Chris@69
|
769 */
|
jtkorhonen@0
|
770 }
|
jtkorhonen@0
|
771
|
jtkorhonen@2
|
772 #define STDOUT_NEEDS_BIG_WINDOW 512
|
jtkorhonen@2
|
773 #define SMALL_WND_W 500
|
jtkorhonen@2
|
774 #define SMALL_WND_H 300
|
jtkorhonen@2
|
775
|
jtkorhonen@2
|
776 #define BIG_WND_W 1024
|
jtkorhonen@2
|
777 #define BIG_WND_H 768
|
jtkorhonen@2
|
778
|
jtkorhonen@2
|
779
|
jtkorhonen@2
|
780 void MainWindow::presentLongStdoutToUser(QString stdo)
|
jtkorhonen@0
|
781 {
|
jtkorhonen@2
|
782 if (!stdo.isEmpty())
|
jtkorhonen@2
|
783 {
|
jtkorhonen@2
|
784 QDialog dlg;
|
jtkorhonen@0
|
785
|
jtkorhonen@2
|
786 if (stdo.length() > STDOUT_NEEDS_BIG_WINDOW)
|
jtkorhonen@2
|
787 {
|
jtkorhonen@2
|
788 dlg.setMinimumWidth(BIG_WND_W);
|
jtkorhonen@2
|
789 dlg.setMinimumHeight(BIG_WND_H);
|
jtkorhonen@2
|
790 }
|
jtkorhonen@2
|
791 else
|
jtkorhonen@2
|
792 {
|
jtkorhonen@2
|
793 dlg.setMinimumWidth(SMALL_WND_W);
|
jtkorhonen@2
|
794 dlg.setMinimumHeight(SMALL_WND_H);
|
jtkorhonen@2
|
795 }
|
jtkorhonen@0
|
796
|
jtkorhonen@2
|
797 QVBoxLayout *box = new QVBoxLayout;
|
jtkorhonen@2
|
798 QListWidget *list = new QListWidget;
|
jtkorhonen@2
|
799 list-> addItems(stdo.split("\n"));
|
jtkorhonen@2
|
800 QPushButton *btn = new QPushButton(tr("Ok"));
|
jtkorhonen@2
|
801 connect(btn, SIGNAL(clicked()), &dlg, SLOT(accept()));
|
jtkorhonen@0
|
802
|
jtkorhonen@2
|
803 box -> addWidget(list);
|
jtkorhonen@2
|
804 box -> addWidget(btn);
|
jtkorhonen@2
|
805 dlg.setLayout(box);
|
jtkorhonen@2
|
806
|
jtkorhonen@2
|
807 dlg.exec();
|
jtkorhonen@2
|
808 }
|
jtkorhonen@2
|
809 else
|
jtkorhonen@2
|
810 {
|
jtkorhonen@2
|
811 QMessageBox::information(this, tr("HgExplorer"), tr("Mercurial command did not return any output."));
|
jtkorhonen@2
|
812 }
|
jtkorhonen@0
|
813 }
|
jtkorhonen@0
|
814
|
jtkorhonen@0
|
815
|
jtkorhonen@17
|
816 bool MainWindow::areAllSelectedCommitable(QListWidget *workList)
|
jtkorhonen@11
|
817 {
|
jtkorhonen@11
|
818 QList<QListWidgetItem *> selList = workList -> selectedItems();
|
jtkorhonen@17
|
819 for (int i = 0; i < selList.size(); ++i)
|
jtkorhonen@11
|
820 {
|
jtkorhonen@17
|
821 QString tmp = selList.at(i) -> text().mid(0, 1);
|
jtkorhonen@11
|
822 if (tmp == "A")
|
jtkorhonen@11
|
823 {
|
jtkorhonen@11
|
824 //scheduled to be added, ok to commit
|
jtkorhonen@11
|
825 }
|
jtkorhonen@11
|
826 else if (tmp == "M")
|
jtkorhonen@11
|
827 {
|
jtkorhonen@11
|
828 //locally modified, ok to commit
|
jtkorhonen@17
|
829 }
|
jtkorhonen@17
|
830 else if (tmp == "R")
|
jtkorhonen@17
|
831 {
|
jtkorhonen@17
|
832 //user wants to remove from repo, ok to commit
|
jtkorhonen@17
|
833 }
|
jtkorhonen@17
|
834 else
|
jtkorhonen@17
|
835 {
|
jtkorhonen@17
|
836 return false;
|
jtkorhonen@11
|
837 }
|
jtkorhonen@11
|
838 }
|
jtkorhonen@17
|
839 return true;
|
jtkorhonen@11
|
840 }
|
jtkorhonen@11
|
841
|
jtkorhonen@6
|
842 bool MainWindow::isSelectedDeletable(QListWidget *workList)
|
jtkorhonen@0
|
843 {
|
jtkorhonen@0
|
844 QList<QListWidgetItem *> selList = workList -> selectedItems();
|
jtkorhonen@0
|
845 if (selList.count() == 1)
|
jtkorhonen@0
|
846 {
|
jtkorhonen@6
|
847 QString tmp = selList.at(0)->text().mid(0, 1);
|
jtkorhonen@6
|
848 if (tmp == "A")
|
jtkorhonen@0
|
849 {
|
jtkorhonen@6
|
850 //scheduled to be added, ok to remove (won't go to repo)
|
jtkorhonen@6
|
851 return true;
|
jtkorhonen@6
|
852 }
|
jtkorhonen@6
|
853 else if (tmp == "C")
|
jtkorhonen@6
|
854 {
|
jtkorhonen@6
|
855 //Tracked but unchanged, ok to remove
|
jtkorhonen@6
|
856 return true;
|
jtkorhonen@6
|
857 }
|
jtkorhonen@6
|
858 else if (tmp == "M")
|
jtkorhonen@6
|
859 {
|
jtkorhonen@6
|
860 //locally modified, ok to remove from repo
|
jtkorhonen@6
|
861 return true;
|
jtkorhonen@6
|
862 }
|
jtkorhonen@6
|
863 else if (tmp == "!")
|
jtkorhonen@6
|
864 {
|
jtkorhonen@6
|
865 //locally deleted, ok to remove from repo
|
jtkorhonen@0
|
866 return true;
|
jtkorhonen@0
|
867 }
|
jtkorhonen@0
|
868 }
|
jtkorhonen@0
|
869 return false;
|
jtkorhonen@0
|
870 }
|
jtkorhonen@0
|
871
|
jtkorhonen@0
|
872
|
jtkorhonen@17
|
873 bool MainWindow::areAllSelectedUntracked(QListWidget *workList)
|
jtkorhonen@0
|
874 {
|
jtkorhonen@0
|
875 QList<QListWidgetItem *> selList = workList -> selectedItems();
|
jtkorhonen@17
|
876 for (int i = 0; i < selList.size(); ++i)
|
jtkorhonen@0
|
877 {
|
jtkorhonen@17
|
878 QString tmp = selList.at(i) -> text();
|
jtkorhonen@17
|
879
|
jtkorhonen@17
|
880 if (tmp.mid(0,1) != "?")
|
jtkorhonen@0
|
881 {
|
jtkorhonen@17
|
882 return false;
|
jtkorhonen@0
|
883 }
|
jtkorhonen@0
|
884 }
|
jtkorhonen@17
|
885 return true;
|
jtkorhonen@0
|
886 }
|
jtkorhonen@0
|
887
|
jtkorhonen@0
|
888
|
jtkorhonen@0
|
889 bool MainWindow::isSelectedModified(QListWidget *workList)
|
jtkorhonen@0
|
890 {
|
jtkorhonen@0
|
891 QList<QListWidgetItem *> selList = workList -> selectedItems();
|
jtkorhonen@0
|
892 if (selList.count() == 1)
|
jtkorhonen@0
|
893 {
|
jtkorhonen@0
|
894 if (selList.at(0)->text().mid(0, 1) == "M")
|
jtkorhonen@0
|
895 {
|
jtkorhonen@0
|
896 return true;
|
jtkorhonen@0
|
897 }
|
jtkorhonen@0
|
898 }
|
jtkorhonen@0
|
899 return false;
|
jtkorhonen@0
|
900 }
|
jtkorhonen@0
|
901
|
jtkorhonen@17
|
902 void MainWindow::countModifications(QListWidget *workList, int& added, int& modified, int& removed, int& notTracked,
|
jtkorhonen@17
|
903 int& selected,
|
jtkorhonen@17
|
904 int& selectedAdded, int& selectedModified, int& selectedRemoved, int& selectedNotTracked)
|
jtkorhonen@0
|
905 {
|
jtkorhonen@0
|
906 int itemCount = workList -> count();
|
jtkorhonen@0
|
907 if (itemCount > 0)
|
jtkorhonen@0
|
908 {
|
jtkorhonen@0
|
909 int A= 0;
|
jtkorhonen@0
|
910 int M=0;
|
jtkorhonen@0
|
911 int R=0;
|
jtkorhonen@5
|
912 int N=0;
|
jtkorhonen@17
|
913 int S=0;
|
jtkorhonen@17
|
914 int SA=0;
|
jtkorhonen@17
|
915 int SM=0;
|
jtkorhonen@17
|
916 int SR=0;
|
jtkorhonen@17
|
917 int SN=0;
|
jtkorhonen@17
|
918
|
jtkorhonen@0
|
919 for (int i = 0; i < workList -> count(); i++)
|
jtkorhonen@0
|
920 {
|
jtkorhonen@0
|
921 QListWidgetItem *currItem = workList -> item(i);
|
jtkorhonen@0
|
922
|
jtkorhonen@0
|
923 QString tmp = currItem->text().mid(0, 1);
|
jtkorhonen@0
|
924 if (tmp == "M")
|
jtkorhonen@0
|
925 {
|
jtkorhonen@0
|
926 M++;
|
jtkorhonen@0
|
927 }
|
jtkorhonen@0
|
928 else if (tmp == "R")
|
jtkorhonen@0
|
929 {
|
jtkorhonen@0
|
930 R++;
|
jtkorhonen@0
|
931 }
|
jtkorhonen@0
|
932 else if (tmp == "A")
|
jtkorhonen@0
|
933 {
|
jtkorhonen@0
|
934 A++;
|
jtkorhonen@0
|
935 }
|
jtkorhonen@5
|
936 else if (tmp == "?")
|
jtkorhonen@5
|
937 {
|
jtkorhonen@5
|
938 N++;
|
jtkorhonen@5
|
939 }
|
jtkorhonen@0
|
940 }
|
jtkorhonen@0
|
941
|
jtkorhonen@17
|
942 added = A;
|
jtkorhonen@17
|
943 modified = M;
|
jtkorhonen@17
|
944 removed = R;
|
jtkorhonen@17
|
945 notTracked = N;
|
jtkorhonen@17
|
946
|
jtkorhonen@17
|
947 QList <QListWidgetItem *> selList = workList -> selectedItems();
|
jtkorhonen@17
|
948
|
jtkorhonen@17
|
949 S = selList.size();
|
jtkorhonen@17
|
950 for (int i = 0; i < selList.size(); ++i)
|
jtkorhonen@17
|
951 {
|
jtkorhonen@17
|
952 QString tmp = selList.at(i) -> text();
|
jtkorhonen@17
|
953
|
jtkorhonen@17
|
954 if (tmp.mid(0,1) == "A")
|
jtkorhonen@17
|
955 {
|
jtkorhonen@17
|
956 SA++;
|
jtkorhonen@17
|
957 }
|
jtkorhonen@17
|
958 else if (tmp.mid(0,1) == "M")
|
jtkorhonen@17
|
959 {
|
jtkorhonen@17
|
960 SM++;
|
jtkorhonen@17
|
961 }
|
jtkorhonen@17
|
962 else if (tmp.mid(0,1) == "R")
|
jtkorhonen@17
|
963 {
|
jtkorhonen@17
|
964 SR++;
|
jtkorhonen@17
|
965 }
|
jtkorhonen@17
|
966 else if (tmp.mid(0,1) == "?")
|
jtkorhonen@17
|
967 {
|
jtkorhonen@17
|
968 SN++;
|
jtkorhonen@17
|
969 }
|
jtkorhonen@17
|
970 }
|
jtkorhonen@17
|
971
|
jtkorhonen@17
|
972 selected = S;
|
jtkorhonen@17
|
973 selectedAdded = SA;
|
jtkorhonen@17
|
974 selectedModified = SM;
|
jtkorhonen@17
|
975 selectedRemoved = SR;
|
jtkorhonen@17
|
976 selectedNotTracked = SN;
|
jtkorhonen@0
|
977 }
|
jtkorhonen@0
|
978 else
|
jtkorhonen@0
|
979 {
|
jtkorhonen@17
|
980 added = 0;
|
jtkorhonen@17
|
981 modified = 0;
|
jtkorhonen@17
|
982 removed = 0;
|
jtkorhonen@17
|
983 notTracked = 0;
|
jtkorhonen@17
|
984 selected = 0;
|
jtkorhonen@17
|
985 selectedAdded = 0;
|
jtkorhonen@17
|
986 selectedModified = 0;
|
jtkorhonen@17
|
987 selectedRemoved = 0;
|
jtkorhonen@17
|
988 selectedNotTracked = 0;
|
jtkorhonen@0
|
989 }
|
jtkorhonen@0
|
990 }
|
jtkorhonen@0
|
991
|
jtkorhonen@0
|
992
|
Chris@62
|
993 void MainWindow::commandFailed()
|
Chris@62
|
994 {
|
Chris@62
|
995 DEBUG << "MainWindow::commandFailed" << endl;
|
Chris@74
|
996 runningAction = ACT_NONE;
|
Chris@74
|
997 runner -> hideProgBar();
|
Chris@74
|
998
|
Chris@74
|
999 //!!! N.B hg incoming returns failure even if successful, if there were no changes
|
Chris@62
|
1000 }
|
Chris@62
|
1001
|
Chris@62
|
1002 void MainWindow::commandCompleted()
|
jtkorhonen@0
|
1003 {
|
jtkorhonen@0
|
1004 bool shouldHgStat = false;
|
jtkorhonen@0
|
1005
|
jtkorhonen@0
|
1006 if (runningAction != ACT_NONE)
|
jtkorhonen@0
|
1007 {
|
jtkorhonen@0
|
1008 //We are running some hg command...
|
Chris@62
|
1009 if (runner -> isCommandRunning() == false)
|
jtkorhonen@0
|
1010 {
|
jtkorhonen@0
|
1011 //Running has just ended.
|
jtkorhonen@0
|
1012 int exitCode = runner -> getExitCode();
|
jtkorhonen@0
|
1013
|
jtkorhonen@0
|
1014 runner -> hideProgBar();
|
jtkorhonen@0
|
1015
|
jtkorhonen@0
|
1016 //Clumsy...
|
jtkorhonen@0
|
1017 if ((EXITOK(exitCode)) || ((exitCode == 1) && (runningAction == ACT_INCOMING)))
|
jtkorhonen@0
|
1018 {
|
jtkorhonen@0
|
1019 //Successful running.
|
jtkorhonen@0
|
1020 switch(runningAction)
|
jtkorhonen@0
|
1021 {
|
Chris@74
|
1022 case ACT_PATHS:
|
Chris@74
|
1023 {
|
Chris@76
|
1024 QString sout = runner->getStdOut();
|
Chris@76
|
1025 DEBUG << "stdout is " << sout << endl;
|
Chris@76
|
1026 LogParser lp(sout, "=");
|
Chris@74
|
1027 LogList ll = lp.parse();
|
Chris@74
|
1028 DEBUG << ll.size() << " results" << endl;
|
Chris@74
|
1029 if (!ll.empty()) {
|
Chris@74
|
1030 remoteRepoPath = lp.parse()[0]["default"].trimmed();
|
Chris@74
|
1031 DEBUG << "Set remote path to " << remoteRepoPath << endl;
|
Chris@74
|
1032 }
|
Chris@74
|
1033 MultiChoiceDialog::addRecentArgument("local", workFolderPath);
|
Chris@74
|
1034 MultiChoiceDialog::addRecentArgument("remote", remoteRepoPath);
|
Chris@74
|
1035 enableDisableActions();
|
Chris@74
|
1036 break;
|
Chris@74
|
1037 }
|
Chris@74
|
1038
|
jtkorhonen@0
|
1039 case ACT_STAT:
|
Chris@69
|
1040 hgExp -> updateWorkFolderFileList(runner -> getStdOut());
|
jtkorhonen@0
|
1041 break;
|
jtkorhonen@0
|
1042
|
jtkorhonen@0
|
1043 case ACT_INCOMING:
|
jtkorhonen@0
|
1044 case ACT_ANNOTATE:
|
jtkorhonen@0
|
1045 case ACT_RESOLVE_LIST:
|
jtkorhonen@0
|
1046 case ACT_RESOLVE_MARK:
|
jtkorhonen@2
|
1047 presentLongStdoutToUser(runner -> getStdOut());
|
jtkorhonen@0
|
1048 shouldHgStat = true;
|
jtkorhonen@0
|
1049 break;
|
jtkorhonen@0
|
1050
|
jtkorhonen@0
|
1051 case ACT_PULL:
|
jtkorhonen@37
|
1052 QMessageBox::information(this, "Pull", runner -> getStdOut());
|
jtkorhonen@0
|
1053 shouldHgStat = true;
|
jtkorhonen@0
|
1054 break;
|
jtkorhonen@0
|
1055
|
jtkorhonen@0
|
1056 case ACT_PUSH:
|
jtkorhonen@37
|
1057 QMessageBox::information(this, "Push", runner -> getStdOut());
|
jtkorhonen@0
|
1058 shouldHgStat = true;
|
jtkorhonen@0
|
1059 break;
|
jtkorhonen@0
|
1060
|
jtkorhonen@0
|
1061 case ACT_INIT:
|
Chris@69
|
1062 MultiChoiceDialog::addRecentArgument("init", workFolderPath);
|
Chris@69
|
1063 MultiChoiceDialog::addRecentArgument("local", workFolderPath);
|
jtkorhonen@0
|
1064 enableDisableActions();
|
jtkorhonen@0
|
1065 shouldHgStat = true;
|
jtkorhonen@0
|
1066 break;
|
jtkorhonen@0
|
1067
|
jtkorhonen@0
|
1068 case ACT_CLONEFROMREMOTE:
|
Chris@69
|
1069 MultiChoiceDialog::addRecentArgument("local", workFolderPath);
|
Chris@69
|
1070 MultiChoiceDialog::addRecentArgument("remote", remoteRepoPath);
|
Chris@72
|
1071 MultiChoiceDialog::addRecentArgument("remote", workFolderPath, true);
|
jtkorhonen@37
|
1072 QMessageBox::information(this, "Clone", runner -> getStdOut());
|
jtkorhonen@0
|
1073 enableDisableActions();
|
jtkorhonen@0
|
1074 shouldHgStat = true;
|
jtkorhonen@0
|
1075 break;
|
jtkorhonen@0
|
1076
|
jtkorhonen@0
|
1077 case ACT_LOG:
|
jtkorhonen@0
|
1078 {
|
jtkorhonen@0
|
1079 hgExp -> updateLocalRepoHgLogList(runner -> getStdOut());
|
jtkorhonen@0
|
1080 }
|
jtkorhonen@0
|
1081 break;
|
jtkorhonen@0
|
1082
|
jtkorhonen@0
|
1083 case ACT_PARENTS:
|
jtkorhonen@0
|
1084 {
|
jtkorhonen@0
|
1085 hgExp -> updateLocalRepoParentsList(runner -> getStdOut());
|
jtkorhonen@0
|
1086 }
|
jtkorhonen@0
|
1087 break;
|
jtkorhonen@0
|
1088
|
jtkorhonen@0
|
1089 case ACT_HEADS:
|
jtkorhonen@0
|
1090 {
|
jtkorhonen@0
|
1091 QString stdOut = runner -> getStdOut();
|
jtkorhonen@0
|
1092 hgExp -> updateLocalRepoHeadsList(stdOut);
|
jtkorhonen@0
|
1093 }
|
jtkorhonen@0
|
1094 break;
|
jtkorhonen@0
|
1095
|
jtkorhonen@0
|
1096 case ACT_REMOVE:
|
jtkorhonen@0
|
1097 case ACT_ADD:
|
jtkorhonen@0
|
1098 case ACT_COMMIT:
|
jtkorhonen@0
|
1099 case ACT_FILEDIFF:
|
jtkorhonen@0
|
1100 case ACT_FOLDERDIFF:
|
jtkorhonen@0
|
1101 case ACT_CHGSETDIFF:
|
jtkorhonen@0
|
1102 case ACT_REVERT:
|
jtkorhonen@11
|
1103 case ACT_SERVE:
|
jtkorhonen@34
|
1104 case ACT_TAG:
|
jtkorhonen@36
|
1105 case ACT_HG_IGNORE:
|
jtkorhonen@0
|
1106 shouldHgStat = true;
|
jtkorhonen@0
|
1107 break;
|
jtkorhonen@0
|
1108
|
jtkorhonen@0
|
1109 case ACT_UPDATE:
|
jtkorhonen@37
|
1110 QMessageBox::information(this, tr("Update"), runner -> getStdOut());
|
jtkorhonen@0
|
1111 shouldHgStat = true;
|
jtkorhonen@0
|
1112 break;
|
jtkorhonen@0
|
1113
|
jtkorhonen@0
|
1114 case ACT_MERGE:
|
jtkorhonen@37
|
1115 QMessageBox::information(this, tr("Merge"), runner -> getStdOut());
|
jtkorhonen@0
|
1116 shouldHgStat = true;
|
jtkorhonen@33
|
1117 justMerged = true;
|
jtkorhonen@33
|
1118 break;
|
jtkorhonen@33
|
1119
|
jtkorhonen@33
|
1120 case ACT_RETRY_MERGE:
|
jtkorhonen@38
|
1121 QMessageBox::information(this, tr("Merge retry"), tr("Merge retry successful."));
|
jtkorhonen@33
|
1122 shouldHgStat = true;
|
jtkorhonen@33
|
1123 justMerged = true;
|
jtkorhonen@0
|
1124 break;
|
jtkorhonen@0
|
1125
|
jtkorhonen@0
|
1126 default:
|
jtkorhonen@0
|
1127 break;
|
jtkorhonen@0
|
1128 }
|
jtkorhonen@0
|
1129 }
|
jtkorhonen@0
|
1130
|
jtkorhonen@37
|
1131
|
Chris@74
|
1132 //Typical sequence goes paths -> stat -> heads -> parents -> log
|
Chris@74
|
1133 if (runningAction == ACT_PATHS)
|
Chris@74
|
1134 {
|
Chris@74
|
1135 runningAction = ACT_NONE;
|
Chris@74
|
1136 hgStat();
|
Chris@74
|
1137 }
|
Chris@74
|
1138 else if (runningAction == ACT_STAT)
|
jtkorhonen@0
|
1139 {
|
jtkorhonen@0
|
1140 runningAction = ACT_NONE;
|
jtkorhonen@0
|
1141 hgHeads();
|
jtkorhonen@0
|
1142 }
|
jtkorhonen@0
|
1143 else if (runningAction == ACT_HEADS)
|
jtkorhonen@0
|
1144 {
|
jtkorhonen@0
|
1145 runningAction = ACT_NONE;
|
jtkorhonen@0
|
1146 hgParents();
|
jtkorhonen@0
|
1147 }
|
jtkorhonen@0
|
1148 else if (runningAction == ACT_PARENTS)
|
jtkorhonen@0
|
1149 {
|
jtkorhonen@0
|
1150 runningAction = ACT_NONE;
|
jtkorhonen@0
|
1151 hgLog();
|
jtkorhonen@0
|
1152 }
|
jtkorhonen@37
|
1153 else if ((runningAction == ACT_MERGE) && (exitCode != 0))
|
jtkorhonen@37
|
1154 {
|
jtkorhonen@37
|
1155 //If we had a failed merge, offer to retry
|
jtkorhonen@37
|
1156 if (QMessageBox::Ok == QMessageBox::information(this, tr("Retry merge ?"), tr("Merge attempt failed. retry ?"), QMessageBox::Ok | QMessageBox::Cancel))
|
jtkorhonen@37
|
1157 {
|
jtkorhonen@37
|
1158 runningAction = ACT_NONE;
|
jtkorhonen@37
|
1159 hgRetryMerge();
|
jtkorhonen@37
|
1160 }
|
jtkorhonen@37
|
1161 else
|
jtkorhonen@37
|
1162 {
|
jtkorhonen@37
|
1163 runningAction = ACT_NONE;
|
jtkorhonen@37
|
1164 hgStat();
|
jtkorhonen@37
|
1165 }
|
jtkorhonen@37
|
1166 }
|
jtkorhonen@0
|
1167 else
|
jtkorhonen@0
|
1168 {
|
jtkorhonen@0
|
1169 runningAction = ACT_NONE;
|
jtkorhonen@0
|
1170 if (shouldHgStat)
|
jtkorhonen@0
|
1171 {
|
Chris@74
|
1172 hgPaths();
|
jtkorhonen@0
|
1173 }
|
jtkorhonen@0
|
1174 }
|
jtkorhonen@0
|
1175 }
|
jtkorhonen@0
|
1176 }
|
jtkorhonen@0
|
1177 else
|
jtkorhonen@0
|
1178 {
|
jtkorhonen@0
|
1179 enableDisableActions();
|
jtkorhonen@0
|
1180 }
|
jtkorhonen@0
|
1181 }
|
jtkorhonen@0
|
1182
|
jtkorhonen@0
|
1183 void MainWindow::connectActions()
|
jtkorhonen@0
|
1184 {
|
jtkorhonen@0
|
1185 connect(exitAct, SIGNAL(triggered()), this, SLOT(close()));
|
jtkorhonen@0
|
1186 connect(aboutAct, SIGNAL(triggered()), this, SLOT(about()));
|
jtkorhonen@0
|
1187 connect(aboutQtAct, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
|
jtkorhonen@0
|
1188
|
Chris@74
|
1189 connect(hgStatAct, SIGNAL(triggered()), this, SLOT(hgPaths()));
|
Chris@74
|
1190 connect(hgExp, SIGNAL(workFolderViewTypesChanged()), this, SLOT(hgPaths()));
|
jtkorhonen@0
|
1191 connect(hgRemoveAct, SIGNAL(triggered()), this, SLOT(hgRemove()));
|
jtkorhonen@0
|
1192 connect(hgAddAct, SIGNAL(triggered()), this, SLOT(hgAdd()));
|
jtkorhonen@0
|
1193 connect(hgCommitAct, SIGNAL(triggered()), this, SLOT(hgCommit()));
|
jtkorhonen@0
|
1194 connect(hgFileDiffAct, SIGNAL(triggered()), this, SLOT(hgFileDiff()));
|
jtkorhonen@0
|
1195 connect(hgFolderDiffAct, SIGNAL(triggered()), this, SLOT(hgFolderDiff()));
|
jtkorhonen@0
|
1196 connect(hgChgSetDiffAct, SIGNAL(triggered()), this, SLOT(hgChgSetDiff()));
|
jtkorhonen@0
|
1197 connect(hgUpdateAct, SIGNAL(triggered()), this, SLOT(hgUpdate()));
|
jtkorhonen@0
|
1198 connect(hgRevertAct, SIGNAL(triggered()), this, SLOT(hgRevert()));
|
jtkorhonen@0
|
1199 connect(hgMergeAct, SIGNAL(triggered()), this, SLOT(hgMerge()));
|
jtkorhonen@33
|
1200 connect(hgRetryMergeAct, SIGNAL(triggered()), this, SLOT(hgRetryMerge()));
|
jtkorhonen@34
|
1201 connect(hgTagAct, SIGNAL(triggered()), this, SLOT(hgTag()));
|
jtkorhonen@34
|
1202 connect(hgIgnoreAct, SIGNAL(triggered()), this, SLOT(hgIgnore()));
|
jtkorhonen@0
|
1203
|
jtkorhonen@0
|
1204 connect(settingsAct, SIGNAL(triggered()), this, SLOT(settings()));
|
Chris@69
|
1205 connect(openAct, SIGNAL(triggered()), this, SLOT(open()));
|
jtkorhonen@0
|
1206
|
jtkorhonen@0
|
1207 connect(hgInitAct, SIGNAL(triggered()), this, SLOT(hgInit()));
|
jtkorhonen@0
|
1208 connect(hgCloneFromRemoteAct, SIGNAL(triggered()), this, SLOT(hgCloneFromRemote()));
|
jtkorhonen@0
|
1209 connect(hgIncomingAct, SIGNAL(triggered()), this, SLOT(hgIncoming()));
|
jtkorhonen@0
|
1210 connect(hgPullAct, SIGNAL(triggered()), this, SLOT(hgPull()));
|
jtkorhonen@0
|
1211 connect(hgPushAct, SIGNAL(triggered()), this, SLOT(hgPush()));
|
jtkorhonen@0
|
1212
|
jtkorhonen@0
|
1213 connect(hgExp, SIGNAL(currentChanged(int)), this, SLOT(tabChanged(int)));
|
jtkorhonen@0
|
1214
|
jtkorhonen@0
|
1215 connect(hgUpdateToRevAct, SIGNAL(triggered()), this, SLOT(hgUpdateToRev()));
|
jtkorhonen@0
|
1216 connect(hgAnnotateAct, SIGNAL(triggered()), this, SLOT(hgAnnotate()));
|
jtkorhonen@0
|
1217 connect(hgResolveListAct, SIGNAL(triggered()), this, SLOT(hgResolveList()));
|
jtkorhonen@0
|
1218 connect(hgResolveMarkAct, SIGNAL(triggered()), this, SLOT(hgResolveMark()));
|
jtkorhonen@11
|
1219 connect(hgServeAct, SIGNAL(triggered()), this, SLOT(hgServe()));
|
jtkorhonen@0
|
1220 }
|
jtkorhonen@0
|
1221
|
jtkorhonen@0
|
1222 void MainWindow::tabChanged(int currTab)
|
jtkorhonen@0
|
1223 {
|
jtkorhonen@0
|
1224 tabPage = currTab;
|
jtkorhonen@32
|
1225
|
jtkorhonen@0
|
1226 }
|
jtkorhonen@0
|
1227
|
jtkorhonen@0
|
1228 void MainWindow::enableDisableActions()
|
jtkorhonen@0
|
1229 {
|
jtkorhonen@0
|
1230 QDir localRepoDir;
|
jtkorhonen@0
|
1231 QDir workFolderDir;
|
jtkorhonen@0
|
1232 bool workFolderExist;
|
jtkorhonen@0
|
1233 bool localRepoExist;
|
jtkorhonen@0
|
1234
|
jtkorhonen@0
|
1235 remoteRepoActionsEnabled = true;
|
jtkorhonen@0
|
1236 if (remoteRepoPath.isEmpty())
|
jtkorhonen@0
|
1237 {
|
jtkorhonen@0
|
1238 remoteRepoActionsEnabled = false;
|
jtkorhonen@0
|
1239 }
|
jtkorhonen@0
|
1240
|
jtkorhonen@0
|
1241 localRepoActionsEnabled = true;
|
jtkorhonen@0
|
1242 if (workFolderPath.isEmpty())
|
jtkorhonen@0
|
1243 {
|
jtkorhonen@0
|
1244 localRepoActionsEnabled = false;
|
jtkorhonen@0
|
1245 workFolderExist = false;
|
jtkorhonen@0
|
1246 }
|
jtkorhonen@0
|
1247
|
jtkorhonen@0
|
1248 if (!workFolderDir.exists(workFolderPath))
|
jtkorhonen@0
|
1249 {
|
jtkorhonen@0
|
1250 localRepoActionsEnabled = false;
|
jtkorhonen@0
|
1251 workFolderExist = false;
|
jtkorhonen@0
|
1252 }
|
jtkorhonen@0
|
1253 else
|
jtkorhonen@0
|
1254 {
|
jtkorhonen@0
|
1255 workFolderExist = true;
|
jtkorhonen@0
|
1256 }
|
jtkorhonen@0
|
1257
|
jtkorhonen@0
|
1258 if (!localRepoDir.exists(workFolderPath + getHgDirName()))
|
jtkorhonen@0
|
1259 {
|
jtkorhonen@0
|
1260 localRepoActionsEnabled = false;
|
jtkorhonen@0
|
1261 localRepoExist = false;
|
jtkorhonen@0
|
1262 }
|
jtkorhonen@0
|
1263
|
jtkorhonen@0
|
1264 hgCloneFromRemoteAct -> setEnabled(remoteRepoActionsEnabled);
|
jtkorhonen@0
|
1265 hgIncomingAct -> setEnabled(remoteRepoActionsEnabled && remoteRepoActionsEnabled);
|
jtkorhonen@0
|
1266 hgPullAct -> setEnabled(remoteRepoActionsEnabled && remoteRepoActionsEnabled);
|
jtkorhonen@0
|
1267 hgPushAct -> setEnabled(remoteRepoActionsEnabled && remoteRepoActionsEnabled);
|
Chris@73
|
1268 /*
|
jtkorhonen@0
|
1269 if (tabPage != WORKTAB)
|
jtkorhonen@0
|
1270 {
|
jtkorhonen@0
|
1271 localRepoActionsEnabled = false;
|
jtkorhonen@0
|
1272 }
|
Chris@73
|
1273 */
|
jtkorhonen@0
|
1274 hgInitAct -> setEnabled((localRepoExist == false) && (workFolderExist==true));
|
jtkorhonen@0
|
1275 hgStatAct -> setEnabled(localRepoActionsEnabled);
|
jtkorhonen@0
|
1276 hgFileDiffAct -> setEnabled(localRepoActionsEnabled);
|
jtkorhonen@0
|
1277 hgFolderDiffAct -> setEnabled(localRepoActionsEnabled);
|
jtkorhonen@0
|
1278 hgRevertAct -> setEnabled(localRepoActionsEnabled);
|
jtkorhonen@0
|
1279 hgAddAct -> setEnabled(localRepoActionsEnabled);
|
jtkorhonen@0
|
1280 hgRemoveAct -> setEnabled(localRepoActionsEnabled);
|
jtkorhonen@0
|
1281 hgUpdateAct -> setEnabled(localRepoActionsEnabled);
|
jtkorhonen@0
|
1282 hgCommitAct -> setEnabled(localRepoActionsEnabled);
|
jtkorhonen@0
|
1283 hgMergeAct -> setEnabled(localRepoActionsEnabled);
|
jtkorhonen@33
|
1284 hgRetryMergeAct -> setEnabled(localRepoActionsEnabled);
|
jtkorhonen@2
|
1285 hgResolveListAct -> setEnabled(localRepoActionsEnabled);
|
jtkorhonen@2
|
1286 hgResolveMarkAct -> setEnabled(localRepoActionsEnabled);
|
jtkorhonen@2
|
1287 hgAnnotateAct -> setEnabled(localRepoActionsEnabled);
|
jtkorhonen@11
|
1288 hgServeAct -> setEnabled(localRepoActionsEnabled);
|
jtkorhonen@34
|
1289 hgTagAct -> setEnabled(localRepoActionsEnabled);
|
jtkorhonen@34
|
1290 hgIgnoreAct -> setEnabled(localRepoActionsEnabled);
|
jtkorhonen@0
|
1291
|
jtkorhonen@32
|
1292 hgExp -> enableDisableOtherTabs(tabPage);
|
jtkorhonen@0
|
1293
|
jtkorhonen@17
|
1294 int added, modified, removed, notTracked, selected, selectedAdded, selectedModified, selectedRemoved, selectedNotTracked;
|
jtkorhonen@17
|
1295
|
jtkorhonen@17
|
1296 countModifications(hgExp -> workFolderFileList,
|
jtkorhonen@17
|
1297 added, modified, removed, notTracked,
|
jtkorhonen@17
|
1298 selected,
|
jtkorhonen@17
|
1299 selectedAdded, selectedModified, selectedRemoved, selectedNotTracked);
|
jtkorhonen@0
|
1300
|
jtkorhonen@0
|
1301 if (tabPage == WORKTAB)
|
jtkorhonen@0
|
1302 {
|
jtkorhonen@0
|
1303 //Enable / disable actions according to workFolderFileList selections / currentSelection / count
|
jtkorhonen@0
|
1304 hgChgSetDiffAct -> setEnabled(false);
|
jtkorhonen@0
|
1305 hgUpdateToRevAct -> setEnabled(false);
|
jtkorhonen@0
|
1306
|
jtkorhonen@0
|
1307 if (localRepoActionsEnabled)
|
jtkorhonen@0
|
1308 {
|
jtkorhonen@17
|
1309 if ((added == 0) && (modified == 0) && (removed == 0))
|
jtkorhonen@0
|
1310 {
|
jtkorhonen@0
|
1311 hgCommitAct -> setEnabled(false);
|
jtkorhonen@0
|
1312 hgRevertAct -> setEnabled(false);
|
jtkorhonen@0
|
1313 }
|
jtkorhonen@17
|
1314 else if (selected != 0)
|
jtkorhonen@17
|
1315 {
|
jtkorhonen@17
|
1316 if (selectedNotTracked != 0)
|
jtkorhonen@17
|
1317 {
|
jtkorhonen@17
|
1318 hgCommitAct -> setEnabled(false);
|
jtkorhonen@17
|
1319 }
|
jtkorhonen@17
|
1320 else if ((selectedAdded == 0) && (selectedModified == 0) && (selectedRemoved == 0))
|
jtkorhonen@17
|
1321 {
|
jtkorhonen@17
|
1322 hgCommitAct -> setEnabled(false);
|
jtkorhonen@17
|
1323 }
|
jtkorhonen@17
|
1324 }
|
jtkorhonen@0
|
1325
|
jtkorhonen@17
|
1326 if (modified == 0)
|
jtkorhonen@0
|
1327 {
|
jtkorhonen@0
|
1328 hgFolderDiffAct -> setEnabled(false);
|
jtkorhonen@0
|
1329 }
|
jtkorhonen@0
|
1330
|
jtkorhonen@0
|
1331 if (!isSelectedModified(hgExp -> workFolderFileList))
|
jtkorhonen@0
|
1332 {
|
jtkorhonen@0
|
1333 hgFileDiffAct -> setEnabled(false);
|
jtkorhonen@0
|
1334 hgRevertAct -> setEnabled(false);
|
jtkorhonen@0
|
1335 }
|
jtkorhonen@0
|
1336
|
jtkorhonen@5
|
1337 //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@17
|
1338 if (notTracked == 0)
|
jtkorhonen@0
|
1339 {
|
jtkorhonen@0
|
1340 hgAddAct -> setEnabled(false);
|
jtkorhonen@0
|
1341 }
|
jtkorhonen@0
|
1342
|
jtkorhonen@6
|
1343 if (!isSelectedDeletable(hgExp -> workFolderFileList))
|
jtkorhonen@0
|
1344 {
|
jtkorhonen@0
|
1345 hgRemoveAct -> setEnabled(false);
|
jtkorhonen@0
|
1346 }
|
jtkorhonen@0
|
1347
|
jtkorhonen@2
|
1348 hgResolveListAct -> setEnabled(true);
|
jtkorhonen@2
|
1349
|
jtkorhonen@5
|
1350 if (hgExp -> localRepoHeadsList->count() < 2)
|
jtkorhonen@0
|
1351 {
|
jtkorhonen@0
|
1352 hgMergeAct -> setEnabled(false);
|
jtkorhonen@33
|
1353 hgRetryMergeAct -> setEnabled(false);
|
jtkorhonen@0
|
1354 }
|
jtkorhonen@0
|
1355
|
jtkorhonen@34
|
1356 if (hgExp -> localRepoHeadsList->count() < 1)
|
jtkorhonen@34
|
1357 {
|
jtkorhonen@34
|
1358 hgTagAct -> setEnabled(false);
|
jtkorhonen@34
|
1359 }
|
jtkorhonen@34
|
1360
|
jtkorhonen@2
|
1361 QString currentFile = hgExp -> getCurrentFileListLine();
|
jtkorhonen@2
|
1362 if (!currentFile.isEmpty())
|
jtkorhonen@2
|
1363 {
|
jtkorhonen@2
|
1364 hgAnnotateAct -> setEnabled(true);
|
jtkorhonen@2
|
1365 hgResolveMarkAct -> setEnabled(true);
|
jtkorhonen@2
|
1366 }
|
jtkorhonen@2
|
1367 else
|
jtkorhonen@2
|
1368 {
|
jtkorhonen@2
|
1369 hgAnnotateAct -> setEnabled(false);
|
jtkorhonen@2
|
1370 hgResolveMarkAct -> setEnabled(false);
|
jtkorhonen@2
|
1371 }
|
jtkorhonen@0
|
1372 }
|
jtkorhonen@0
|
1373 }
|
jtkorhonen@0
|
1374 else
|
jtkorhonen@0
|
1375 {
|
jtkorhonen@0
|
1376 QList <QListWidgetItem *> headSelList = hgExp -> localRepoHeadsList->selectedItems();
|
jtkorhonen@0
|
1377 QList <QListWidgetItem *> historySelList = hgExp -> localRepoHgLogList->selectedItems();
|
jtkorhonen@0
|
1378
|
jtkorhonen@0
|
1379 if ((historySelList.count() == 2) || (headSelList.count() == 2))
|
jtkorhonen@0
|
1380 {
|
jtkorhonen@0
|
1381 hgChgSetDiffAct -> setEnabled(true);
|
jtkorhonen@0
|
1382 }
|
jtkorhonen@0
|
1383 else
|
jtkorhonen@0
|
1384 {
|
jtkorhonen@0
|
1385 hgChgSetDiffAct -> setEnabled(false);
|
jtkorhonen@0
|
1386 }
|
jtkorhonen@0
|
1387
|
jtkorhonen@30
|
1388 if (historySelList.count() == 1)
|
jtkorhonen@0
|
1389 {
|
jtkorhonen@30
|
1390 hgUpdateToRevAct -> setEnabled(true);
|
jtkorhonen@0
|
1391 }
|
jtkorhonen@0
|
1392 else
|
jtkorhonen@0
|
1393 {
|
jtkorhonen@0
|
1394 hgUpdateToRevAct -> setEnabled(false);
|
jtkorhonen@0
|
1395 }
|
jtkorhonen@0
|
1396 }
|
jtkorhonen@0
|
1397 }
|
jtkorhonen@0
|
1398
|
jtkorhonen@0
|
1399 void MainWindow::createActions()
|
jtkorhonen@0
|
1400 {
|
jtkorhonen@0
|
1401 //File actions
|
jtkorhonen@0
|
1402 hgInitAct = new QAction(tr("Init local repository"), this);
|
jtkorhonen@0
|
1403 hgInitAct->setStatusTip(tr("Create an empty local repository in selected folder"));
|
jtkorhonen@0
|
1404
|
jtkorhonen@0
|
1405 hgCloneFromRemoteAct = new QAction(tr("Clone from remote"), this);
|
jtkorhonen@0
|
1406 hgCloneFromRemoteAct->setStatusTip(tr("Clone from remote repository into local repository in selected folder"));
|
jtkorhonen@0
|
1407
|
Chris@69
|
1408 openAct = new QAction(QIcon(":/images/fileopen.png"), tr("Open..."), this);
|
Chris@69
|
1409 openAct -> setStatusTip(tr("Open repository"));
|
Chris@69
|
1410 openAct -> setIconVisibleInMenu(true);
|
Chris@69
|
1411
|
jtkorhonen@0
|
1412 settingsAct = new QAction(QIcon(":/images/settings.png"), tr("Settings..."), this);
|
jtkorhonen@0
|
1413 settingsAct -> setStatusTip(tr("View and change application settings"));
|
jtkorhonen@0
|
1414 settingsAct -> setIconVisibleInMenu(true);
|
jtkorhonen@0
|
1415
|
jtkorhonen@0
|
1416 exitAct = new QAction(QIcon(":/images/exit.png"), tr("Exit"), this);
|
jtkorhonen@0
|
1417 exitAct->setShortcuts(QKeySequence::Quit);
|
jtkorhonen@0
|
1418 exitAct->setStatusTip(tr("Exit application"));
|
jtkorhonen@0
|
1419 exitAct -> setIconVisibleInMenu(true);
|
jtkorhonen@0
|
1420
|
jtkorhonen@0
|
1421 //Repository actions
|
Chris@61
|
1422 hgStatAct = new QAction(QIcon(":/images/status.png"), tr("Refresh"), this);
|
Chris@61
|
1423 hgStatAct->setStatusTip(tr("Refresh (info of) status of workfolder files"));
|
Chris@61
|
1424
|
Chris@61
|
1425 hgIncomingAct = new QAction(QIcon(":/images/incoming.png"), tr("Preview"), this);
|
jtkorhonen@0
|
1426 hgIncomingAct -> setStatusTip(tr("View info of changesets incoming to us from remote repository (on pull operation)"));
|
jtkorhonen@0
|
1427
|
Chris@61
|
1428 hgPullAct = new QAction(QIcon(":/images/pull.png"), tr("Pull"), this);
|
jtkorhonen@0
|
1429 hgPullAct -> setStatusTip(tr("Pull changesets from remote repository to local repository"));
|
jtkorhonen@0
|
1430
|
Chris@61
|
1431 hgPushAct = new QAction(QIcon(":/images/push.png"), tr("Push"), this);
|
jtkorhonen@0
|
1432 hgPushAct->setStatusTip(tr("Push local changesets to remote repository"));
|
jtkorhonen@0
|
1433
|
jtkorhonen@0
|
1434 //Workfolder actions
|
Chris@61
|
1435 hgFileDiffAct = new QAction(QIcon(":/images/diff.png"), tr("Diff"), this);
|
jtkorhonen@0
|
1436 hgFileDiffAct->setStatusTip(tr("Filediff: View differences between selected working folder file and local repository file"));
|
jtkorhonen@0
|
1437
|
jtkorhonen@0
|
1438 hgFolderDiffAct = new QAction(QIcon(":/images/folderdiff.png"), tr("View folderdiff"), this);
|
jtkorhonen@0
|
1439 hgFolderDiffAct->setStatusTip(tr("Folderdiff: View all differences between working folder files and local repository files"));
|
jtkorhonen@0
|
1440
|
jtkorhonen@0
|
1441 hgChgSetDiffAct = new QAction(QIcon(":/images/chgsetdiff.png"), tr("View changesetdiff"), this);
|
jtkorhonen@0
|
1442 hgChgSetDiffAct->setStatusTip(tr("Change set diff: View differences between all files of 2 repository changesets"));
|
jtkorhonen@0
|
1443
|
Chris@61
|
1444 hgRevertAct = new QAction(QIcon(":/images/undo.png"), tr("Revert"), this);
|
jtkorhonen@0
|
1445 hgRevertAct->setStatusTip(tr("Undo selected working folder file changes (return to local repository version)"));
|
jtkorhonen@0
|
1446
|
Chris@61
|
1447 hgAddAct = new QAction(QIcon(":/images/add.png"), tr("Add"), this);
|
jtkorhonen@17
|
1448 hgAddAct -> setStatusTip(tr("Add working folder file(s) (selected or all yet untracked) to local repository (on next commit)"));
|
jtkorhonen@0
|
1449
|
Chris@61
|
1450 hgRemoveAct = new QAction(QIcon(":/images/remove.png"), tr("Remove"), this);
|
jtkorhonen@0
|
1451 hgRemoveAct -> setStatusTip(tr("Remove selected working folder file from local repository (on next commit)"));
|
jtkorhonen@0
|
1452
|
Chris@61
|
1453 hgUpdateAct = new QAction(QIcon(":/images/update.png"), tr("Update"), this);
|
jtkorhonen@0
|
1454 hgUpdateAct->setStatusTip(tr("Update working folder from local repository"));
|
jtkorhonen@0
|
1455
|
Chris@61
|
1456 hgCommitAct = new QAction(QIcon(":/images/commit.png"), tr("Commit"), this);
|
jtkorhonen@20
|
1457 hgCommitAct->setStatusTip(tr("Save selected file(s) or all changed files in working folder (and all subfolders) to local repository"));
|
jtkorhonen@0
|
1458
|
jtkorhonen@0
|
1459 hgMergeAct = new QAction(QIcon(":/images/merge.png"), tr("Merge"), this);
|
jtkorhonen@0
|
1460 hgMergeAct->setStatusTip(tr("Merge two local repository changesets to working folder"));
|
jtkorhonen@0
|
1461
|
jtkorhonen@0
|
1462 //Advanced actions
|
jtkorhonen@0
|
1463 hgUpdateToRevAct = new QAction(tr("Update to revision"), this);
|
jtkorhonen@0
|
1464 hgUpdateToRevAct -> setStatusTip(tr("Update working folder to version selected from history list"));
|
jtkorhonen@0
|
1465
|
jtkorhonen@0
|
1466 hgAnnotateAct = new QAction(tr("Annotate"), this);
|
jtkorhonen@0
|
1467 hgAnnotateAct -> setStatusTip(tr("Show line-by-line version information for selected file"));
|
jtkorhonen@0
|
1468
|
jtkorhonen@0
|
1469 hgResolveListAct = new QAction(tr("Resolve (list)"), this);
|
jtkorhonen@0
|
1470 hgResolveListAct -> setStatusTip(tr("Resolve (list): Show list of files needing merge"));
|
jtkorhonen@0
|
1471
|
jtkorhonen@0
|
1472 hgResolveMarkAct = new QAction(tr("Resolve (mark)"), this);
|
jtkorhonen@0
|
1473 hgResolveMarkAct -> setStatusTip(tr("Resolve (mark): Mark selected file status as resolved"));
|
jtkorhonen@0
|
1474
|
jtkorhonen@33
|
1475 hgRetryMergeAct = new QAction(tr("Retry merge"), this);
|
jtkorhonen@33
|
1476 hgRetryMergeAct -> setStatusTip(tr("Retry merge after failed merge attempt."));
|
jtkorhonen@33
|
1477
|
jtkorhonen@34
|
1478 hgTagAct = new QAction(tr("Tag revision"), this);
|
jtkorhonen@34
|
1479 hgTagAct -> setStatusTip(tr("Give decsriptive name (tag) to current workfolder parent revision."));
|
jtkorhonen@34
|
1480
|
jtkorhonen@34
|
1481 hgIgnoreAct = new QAction(tr("Edit .hgignore"), this);
|
jtkorhonen@34
|
1482 hgIgnoreAct -> setStatusTip(tr("Edit .hgignore file (file contains names of files that should be ignored by mercurial)"));
|
jtkorhonen@34
|
1483
|
jtkorhonen@11
|
1484 hgServeAct = new QAction(tr("Serve (via http)"), this);
|
jtkorhonen@11
|
1485 hgServeAct -> setStatusTip(tr("Serve local repository via http for workgroup access"));
|
jtkorhonen@11
|
1486
|
jtkorhonen@0
|
1487 //Help actions
|
jtkorhonen@0
|
1488 aboutAct = new QAction(tr("About"), this);
|
jtkorhonen@0
|
1489 aboutAct->setStatusTip(tr("Show the application's About box"));
|
jtkorhonen@0
|
1490
|
jtkorhonen@0
|
1491 aboutQtAct = new QAction(tr("About Qt"), this);
|
jtkorhonen@0
|
1492 aboutQtAct->setStatusTip(tr("Show the Qt library's About box"));
|
jtkorhonen@0
|
1493 }
|
jtkorhonen@0
|
1494
|
jtkorhonen@0
|
1495 void MainWindow::createMenus()
|
jtkorhonen@0
|
1496 {
|
jtkorhonen@0
|
1497 fileMenu = menuBar()->addMenu(tr("File"));
|
jtkorhonen@0
|
1498 fileMenu -> addAction(hgInitAct);
|
jtkorhonen@0
|
1499 fileMenu -> addAction(hgCloneFromRemoteAct);
|
jtkorhonen@0
|
1500 fileMenu -> addSeparator();
|
Chris@69
|
1501 fileMenu -> addAction(openAct);
|
jtkorhonen@0
|
1502 fileMenu -> addAction(settingsAct);
|
jtkorhonen@0
|
1503 fileMenu -> addSeparator();
|
jtkorhonen@0
|
1504 fileMenu -> addAction(exitAct);
|
jtkorhonen@0
|
1505
|
jtkorhonen@0
|
1506 advancedMenu = menuBar()->addMenu(tr("Advanced"));
|
jtkorhonen@0
|
1507 advancedMenu -> addAction(hgUpdateToRevAct);
|
jtkorhonen@0
|
1508 advancedMenu -> addSeparator();
|
jtkorhonen@0
|
1509 advancedMenu -> addAction(hgAnnotateAct);
|
jtkorhonen@0
|
1510 advancedMenu -> addSeparator();
|
jtkorhonen@33
|
1511 advancedMenu -> addAction(hgRetryMergeAct);
|
jtkorhonen@0
|
1512 advancedMenu -> addAction(hgResolveListAct);
|
jtkorhonen@0
|
1513 advancedMenu -> addAction(hgResolveMarkAct);
|
jtkorhonen@11
|
1514 advancedMenu -> addSeparator();
|
jtkorhonen@34
|
1515 advancedMenu -> addAction(hgTagAct);
|
jtkorhonen@34
|
1516 advancedMenu -> addSeparator();
|
jtkorhonen@34
|
1517 advancedMenu -> addAction(hgIgnoreAct);
|
jtkorhonen@34
|
1518 advancedMenu -> addSeparator();
|
jtkorhonen@11
|
1519 advancedMenu -> addAction(hgServeAct);
|
jtkorhonen@0
|
1520
|
jtkorhonen@0
|
1521 helpMenu = menuBar()->addMenu(tr("Help"));
|
jtkorhonen@0
|
1522 helpMenu->addAction(aboutAct);
|
jtkorhonen@0
|
1523 helpMenu->addAction(aboutQtAct);
|
jtkorhonen@0
|
1524 }
|
jtkorhonen@0
|
1525
|
jtkorhonen@0
|
1526 void MainWindow::createToolBars()
|
jtkorhonen@0
|
1527 {
|
jtkorhonen@0
|
1528 fileToolBar = addToolBar(tr("File"));
|
jtkorhonen@0
|
1529 fileToolBar -> setIconSize(QSize(MY_ICON_SIZE, MY_ICON_SIZE));
|
Chris@69
|
1530 fileToolBar -> addAction(openAct);
|
Chris@43
|
1531 fileToolBar -> addAction(hgStatAct);
|
jtkorhonen@0
|
1532 fileToolBar -> addSeparator();
|
Chris@61
|
1533 // fileToolBar -> addAction(hgChgSetDiffAct);
|
jtkorhonen@0
|
1534 fileToolBar -> setMovable(false);
|
jtkorhonen@0
|
1535
|
jtkorhonen@0
|
1536 repoToolBar = addToolBar(tr(REPOMENU_TITLE));
|
jtkorhonen@0
|
1537 repoToolBar -> setIconSize(QSize(MY_ICON_SIZE, MY_ICON_SIZE));
|
jtkorhonen@0
|
1538 repoToolBar->addAction(hgIncomingAct);
|
jtkorhonen@0
|
1539 repoToolBar->addAction(hgPullAct);
|
jtkorhonen@0
|
1540 repoToolBar->addAction(hgPushAct);
|
jtkorhonen@0
|
1541 repoToolBar -> setMovable(false);
|
jtkorhonen@0
|
1542
|
jtkorhonen@0
|
1543 workFolderToolBar = addToolBar(tr(WORKFOLDERMENU_TITLE));
|
jtkorhonen@0
|
1544 addToolBar(Qt::LeftToolBarArea, workFolderToolBar);
|
jtkorhonen@0
|
1545 workFolderToolBar -> setIconSize(QSize(MY_ICON_SIZE, MY_ICON_SIZE));
|
Chris@61
|
1546 // workFolderToolBar->addSeparator();
|
jtkorhonen@0
|
1547 workFolderToolBar->addAction(hgFileDiffAct);
|
Chris@61
|
1548 // workFolderToolBar->addAction(hgFolderDiffAct);
|
jtkorhonen@0
|
1549 workFolderToolBar->addSeparator();
|
jtkorhonen@0
|
1550 workFolderToolBar->addAction(hgRevertAct);
|
jtkorhonen@0
|
1551 workFolderToolBar->addAction(hgUpdateAct);
|
jtkorhonen@0
|
1552 workFolderToolBar->addAction(hgCommitAct);
|
jtkorhonen@0
|
1553 workFolderToolBar->addAction(hgMergeAct);
|
jtkorhonen@0
|
1554 workFolderToolBar->addSeparator();
|
jtkorhonen@0
|
1555 workFolderToolBar->addAction(hgAddAct);
|
jtkorhonen@0
|
1556 workFolderToolBar->addAction(hgRemoveAct);
|
jtkorhonen@0
|
1557 workFolderToolBar -> setMovable(false);
|
Chris@61
|
1558
|
Chris@61
|
1559 foreach (QToolButton *tb, findChildren<QToolButton *>()) {
|
Chris@61
|
1560 tb->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
|
Chris@61
|
1561 }
|
jtkorhonen@0
|
1562 }
|
jtkorhonen@0
|
1563
|
jtkorhonen@0
|
1564
|
jtkorhonen@0
|
1565 void MainWindow::createStatusBar()
|
jtkorhonen@0
|
1566 {
|
jtkorhonen@0
|
1567 statusBar()->showMessage(tr("Ready"));
|
jtkorhonen@0
|
1568 }
|
jtkorhonen@0
|
1569
|
Chris@69
|
1570
|
Chris@69
|
1571 //!!! review these:
|
Chris@69
|
1572
|
jtkorhonen@0
|
1573 void MainWindow::readSettings()
|
jtkorhonen@0
|
1574 {
|
jtkorhonen@0
|
1575 QDir workFolder;
|
jtkorhonen@0
|
1576
|
Chris@61
|
1577 QSettings settings;
|
jtkorhonen@0
|
1578
|
jtkorhonen@30
|
1579 remoteRepoPath = settings.value("remoterepopath", "").toString();
|
jtkorhonen@0
|
1580 workFolderPath = settings.value("workfolderpath", "").toString();
|
jtkorhonen@0
|
1581 if (!workFolder.exists(workFolderPath))
|
jtkorhonen@0
|
1582 {
|
jtkorhonen@0
|
1583 workFolderPath = "";
|
jtkorhonen@0
|
1584 }
|
jtkorhonen@0
|
1585
|
jtkorhonen@0
|
1586 QPoint pos = settings.value("pos", QPoint(200, 200)).toPoint();
|
jtkorhonen@0
|
1587 QSize size = settings.value("size", QSize(400, 400)).toSize();
|
jtkorhonen@0
|
1588 firstStart = settings.value("firststart", QVariant(true)).toBool();
|
jtkorhonen@0
|
1589
|
jtkorhonen@0
|
1590 initialFileTypesBits = (unsigned char) settings.value("viewFileTypes", QVariant(DEFAULT_HG_STAT_BITS)).toInt();
|
jtkorhonen@0
|
1591 resize(size);
|
jtkorhonen@0
|
1592 move(pos);
|
jtkorhonen@0
|
1593 }
|
jtkorhonen@0
|
1594
|
jtkorhonen@17
|
1595
|
jtkorhonen@0
|
1596 void MainWindow::writeSettings()
|
jtkorhonen@0
|
1597 {
|
Chris@61
|
1598 QSettings settings;
|
jtkorhonen@0
|
1599 settings.setValue("pos", pos());
|
jtkorhonen@0
|
1600 settings.setValue("size", size());
|
jtkorhonen@0
|
1601 settings.setValue("remoterepopath", remoteRepoPath);
|
jtkorhonen@0
|
1602 settings.setValue("workfolderpath", workFolderPath);
|
jtkorhonen@0
|
1603 settings.setValue("firststart", firstStart);
|
jtkorhonen@0
|
1604 settings.setValue("viewFileTypes", hgExp -> getFileTypesBits());
|
jtkorhonen@0
|
1605 }
|
jtkorhonen@0
|
1606
|
jtkorhonen@0
|
1607
|
jtkorhonen@0
|
1608
|
jtkorhonen@0
|
1609
|