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