annotate mainwindow.cpp @ 69:6d5a5571caec

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