annotate mainwindow.cpp @ 157:e411bb42d934

* Default merge comments
author Chris Cannam
date Thu, 02 Dec 2010 21:52:24 +0000
parents 4999dbf3a266
children 910c2c5d1873
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@98 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>
Chris@90 31 #include <QInputDialog>
Chris@125 32 #include <QRegExp>
jtkorhonen@0 33
Chris@53 34 #include "mainwindow.h"
Chris@69 35 #include "multichoicedialog.h"
Chris@64 36 #include "startupdialog.h"
Chris@53 37 #include "colourset.h"
Chris@62 38 #include "debug.h"
Chris@74 39 #include "logparser.h"
Chris@103 40 #include "confirmcommentdialog.h"
Chris@125 41 #include "incomingdialog.h"
Chris@53 42
jtkorhonen@0 43
jtkorhonen@0 44 MainWindow::MainWindow()
jtkorhonen@0 45 {
jtkorhonen@0 46 QString wndTitle;
jtkorhonen@0 47
Chris@90 48 fsWatcher = 0;
Chris@133 49 commitsSincePush = 0;
Chris@90 50
jtkorhonen@0 51 createActions();
jtkorhonen@0 52 createMenus();
jtkorhonen@0 53 createToolBars();
jtkorhonen@0 54 createStatusBar();
jtkorhonen@0 55
jtkorhonen@0 56 runner = new HgRunner(this);
Chris@109 57 connect(runner, SIGNAL(commandCompleted(HgAction, QString)),
Chris@109 58 this, SLOT(commandCompleted(HgAction, QString)));
Chris@109 59 connect(runner, SIGNAL(commandFailed(HgAction, QString)),
Chris@109 60 this, SLOT(commandFailed(HgAction, QString)));
jtkorhonen@0 61 statusBar()->addPermanentWidget(runner);
jtkorhonen@0 62
Chris@61 63 setWindowTitle(tr("EasyMercurial"));
jtkorhonen@0 64
jtkorhonen@0 65 remoteRepoPath = "";
jtkorhonen@0 66 workFolderPath = "";
jtkorhonen@0 67
jtkorhonen@0 68 readSettings();
jtkorhonen@0 69
jtkorhonen@33 70 justMerged = false;
Chris@98 71 hgTabs = new HgTabWidget((QWidget *) this, remoteRepoPath, workFolderPath);
Chris@141 72 connectTabsSignals();
Chris@98 73 setCentralWidget(hgTabs);
jtkorhonen@0 74
Chris@98 75 connect(hgTabs, SIGNAL(selectionChanged()),
Chris@95 76 this, SLOT(enableDisableActions()));
Chris@95 77
jtkorhonen@0 78 setUnifiedTitleAndToolBarOnMac(true);
jtkorhonen@0 79 connectActions();
Chris@120 80 clearState();
jtkorhonen@0 81 enableDisableActions();
jtkorhonen@0 82
Chris@64 83 if (firstStart) {
Chris@64 84 startupDialog();
jtkorhonen@0 85 }
jtkorhonen@0 86
Chris@112 87 findDiffBinaryName();
Chris@112 88
Chris@64 89 ColourSet *cs = ColourSet::instance();
Chris@64 90 cs->clearDefaultNames();
Chris@64 91 cs->addDefaultName("");
Chris@153 92 cs->addDefaultName("default");
Chris@64 93 cs->addDefaultName(getUserInfo());
Chris@62 94
Chris@72 95 if (workFolderPath == "") {
Chris@72 96 open();
Chris@72 97 }
Chris@72 98
Chris@109 99 hgQueryPaths();
jtkorhonen@0 100 }
jtkorhonen@0 101
jtkorhonen@0 102
jtkorhonen@0 103 void MainWindow::closeEvent(QCloseEvent *)
jtkorhonen@0 104 {
jtkorhonen@0 105 writeSettings();
Chris@90 106 delete fsWatcher;
jtkorhonen@0 107 }
jtkorhonen@0 108
jtkorhonen@0 109
Chris@64 110 QString MainWindow::getUserInfo() const
Chris@64 111 {
Chris@64 112 QSettings settings;
Chris@64 113 settings.beginGroup("User Information");
Chris@64 114 QString name = settings.value("name", getUserRealName()).toString();
Chris@64 115 QString email = settings.value("email", "").toString();
Chris@64 116
Chris@64 117 QString identifier;
Chris@64 118
Chris@64 119 if (email != "") {
Chris@64 120 identifier = QString("%1 <%2>").arg(name).arg(email);
Chris@64 121 } else {
Chris@64 122 identifier = name;
Chris@64 123 }
Chris@64 124
Chris@64 125 return identifier;
Chris@64 126 }
Chris@64 127
jtkorhonen@0 128 void MainWindow::about()
jtkorhonen@0 129 {
Chris@97 130 QMessageBox::about(this, tr("About EasyMercurial"),
Chris@97 131 tr("<qt><h2>About EasyMercurial</h2>"
Chris@97 132 "<p>EasyMercurial is a simple user interface for the "
Chris@97 133 "Mercurial version control system.</p>"
Chris@98 134 "<p>EasyMercurial is based on hgExplorer by "
Chris@97 135 "Jari Korhonen, with thanks.<br>EasyMercurial development carried out by "
Chris@97 136 "Chris Cannam for soundsoftware.ac.uk at the Centre for Digital Music, Queen Mary, University of London."
Chris@97 137 "<ul><li>Copyright &copy; 2010 Jari Korhonen</li>"
Chris@97 138 "<li>Copyright &copy; 2010 Chris Cannam</li>"
Chris@97 139 "<li>Copyright &copy; 2010 Queen Mary, University of London</li>"
Chris@97 140 "</ul>"
Chris@97 141 "<p> This program is free software; you can redistribute it and/or "
Chris@97 142 "modify it under the terms of the GNU General Public License as "
Chris@97 143 "published by the Free Software Foundation; either version 2 of the "
Chris@97 144 "License, or (at your option) any later version. See the file "
Chris@97 145 "COPYING included with this distribution for more information."));
jtkorhonen@0 146 }
jtkorhonen@0 147
Chris@94 148 void MainWindow::clearSelections()
Chris@94 149 {
Chris@98 150 hgTabs->clearSelections();
Chris@94 151 }
jtkorhonen@0 152
Chris@120 153 void MainWindow::hgRefresh()
Chris@120 154 {
Chris@120 155 clearState();
Chris@120 156 hgQueryPaths();
Chris@120 157 }
Chris@120 158
jtkorhonen@0 159 void MainWindow::hgStat()
jtkorhonen@0 160 {
Chris@109 161 QStringList params;
Chris@109 162 params << "stat" << "-ardum";
Chris@153 163
Chris@153 164 // annoyingly, hg stat actually modifies the working directory --
Chris@153 165 // it creates files called hg-checklink and hg-checkexec to test
Chris@153 166 // properties of the filesystem
Chris@153 167 if (fsWatcher) fsWatcher->blockSignals(true);
Chris@153 168
Chris@109 169 runner->requestAction(HgAction(ACT_STAT, workFolderPath, params));
jtkorhonen@0 170 }
jtkorhonen@0 171
Chris@109 172 void MainWindow::hgQueryPaths()
Chris@74 173 {
Chris@109 174 QStringList params;
Chris@109 175 params << "paths";
Chris@109 176 runner->requestAction(HgAction(ACT_QUERY_PATHS, workFolderPath, params));
Chris@74 177 }
Chris@74 178
Chris@109 179 void MainWindow::hgQueryBranch()
Chris@106 180 {
Chris@109 181 QStringList params;
Chris@109 182 params << "branch";
Chris@109 183 runner->requestAction(HgAction(ACT_QUERY_BRANCH, workFolderPath, params));
Chris@106 184 }
Chris@106 185
Chris@109 186 void MainWindow::hgQueryHeads()
jtkorhonen@0 187 {
Chris@109 188 QStringList params;
Chris@137 189 // On empty repos, "hg heads" will fail -- we don't care about
Chris@137 190 // that. Use --closed option so as to include closed branches;
Chris@137 191 // otherwise we'll be stuck if the user updates into one, and our
Chris@137 192 // incremental log will end up with spurious stuff in it because
Chris@137 193 // we won't be pruning at the ends of closed branches
Chris@137 194 params << "heads" << "--closed";
Chris@109 195 runner->requestAction(HgAction(ACT_QUERY_HEADS, workFolderPath, params));
jtkorhonen@0 196 }
jtkorhonen@0 197
jtkorhonen@0 198 void MainWindow::hgLog()
jtkorhonen@0 199 {
Chris@109 200 QStringList params;
Chris@109 201 params << "log";
Chris@109 202 params << "--template";
Chris@125 203 params << Changeset::getLogTemplate();
Chris@109 204
Chris@109 205 runner->requestAction(HgAction(ACT_LOG, workFolderPath, params));
Chris@109 206 }
Chris@109 207
Chris@150 208 void MainWindow::hgLogIncremental(QStringList prune)
Chris@120 209 {
Chris@120 210 QStringList params;
Chris@120 211 params << "log";
Chris@120 212
Chris@150 213 foreach (QString p, prune) {
Chris@153 214 params << "--prune" << Changeset::hashOf(p);
Chris@120 215 }
Chris@120 216
Chris@120 217 params << "--template";
Chris@125 218 params << Changeset::getLogTemplate();
Chris@120 219
Chris@120 220 runner->requestAction(HgAction(ACT_LOG_INCREMENTAL, workFolderPath, params));
Chris@120 221 }
Chris@109 222
Chris@109 223 void MainWindow::hgQueryParents()
Chris@109 224 {
Chris@109 225 QStringList params;
Chris@109 226 params << "parents";
Chris@109 227 runner->requestAction(HgAction(ACT_QUERY_PARENTS, workFolderPath, params));
Chris@109 228 }
Chris@109 229
Chris@109 230 void MainWindow::hgAnnotate()
Chris@109 231 {
Chris@109 232 QStringList params;
Chris@109 233 QString currentFile;//!!! = hgTabs -> getCurrentFileListLine();
Chris@109 234
Chris@109 235 if (!currentFile.isEmpty())
jtkorhonen@0 236 {
Chris@109 237 params << "annotate" << "--" << currentFile.mid(2); //Jump over status marker characters (e.g "M ")
jtkorhonen@0 238
Chris@109 239 runner->requestAction(HgAction(ACT_ANNOTATE, workFolderPath, params));
jtkorhonen@0 240 }
jtkorhonen@0 241 }
jtkorhonen@0 242
Chris@109 243 void MainWindow::hgResolveMark()
Chris@109 244 {
Chris@109 245 QStringList params;
Chris@109 246 QString currentFile;//!!! = hgTabs -> getCurrentFileListLine();
jtkorhonen@0 247
Chris@109 248 if (!currentFile.isEmpty())
jtkorhonen@0 249 {
Chris@109 250 params << "resolve" << "--mark" << "--" << currentFile.mid(2); //Jump over status marker characters (e.g "M ")
jtkorhonen@0 251
Chris@109 252 runner->requestAction(HgAction(ACT_RESOLVE_MARK, workFolderPath, params));
jtkorhonen@0 253 }
jtkorhonen@0 254 }
jtkorhonen@0 255
Chris@109 256 void MainWindow::hgResolveList()
Chris@109 257 {
Chris@109 258 QStringList params;
jtkorhonen@0 259
Chris@109 260 params << "resolve" << "--list";
Chris@109 261 runner->requestAction(HgAction(ACT_RESOLVE_LIST, workFolderPath, params));
Chris@109 262 }
Chris@109 263
Chris@109 264 void MainWindow::hgAdd()
jtkorhonen@0 265 {
Chris@109 266 QStringList params;
jtkorhonen@0 267
Chris@109 268 // hgExplorer permitted adding "all" files -- I'm not sure
Chris@109 269 // that one is a good idea, let's require the user to select
jtkorhonen@0 270
Chris@109 271 QStringList files = hgTabs->getSelectedAddableFiles();
Chris@109 272
Chris@109 273 if (!files.empty()) {
Chris@109 274 params << "add" << "--" << files;
Chris@109 275 runner->requestAction(HgAction(ACT_ADD, workFolderPath, params));
jtkorhonen@0 276 }
jtkorhonen@0 277 }
jtkorhonen@0 278
jtkorhonen@0 279
Chris@98 280 void MainWindow::hgRemove()
Chris@98 281 {
Chris@109 282 QStringList params;
Chris@98 283
Chris@109 284 QStringList files = hgTabs->getSelectedRemovableFiles();
Chris@98 285
Chris@109 286 //!!! todo: confirmation dialog (with file list in it) (or do we
Chris@109 287 // need that? all it does is move the files to the removed
Chris@109 288 // list... doesn't it?)
Chris@98 289
Chris@109 290 if (!files.empty()) {
Chris@109 291 params << "remove" << "--after" << "--force" << "--" << files;
Chris@109 292 runner->requestAction(HgAction(ACT_REMOVE, workFolderPath, params));
Chris@109 293 }
Chris@98 294
Chris@91 295 /*!!!
Chris@98 296 QString currentFile;//!!! = hgTabs -> getCurrentFileListLine();
Chris@98 297
Chris@98 298 if (!currentFile.isEmpty())
jtkorhonen@5 299 {
Chris@98 300 if (QMessageBox::Ok == QMessageBox::warning(this, "Remove file", "Really remove file " + currentFile.mid(2) + "?",
Chris@98 301 QMessageBox::Ok | QMessageBox::Cancel, QMessageBox::Cancel))
Chris@98 302 {
Chris@98 303 params << "remove" << "--after" << "--force" << "--" << currentFile.mid(2); //Jump over status marker characters (e.g "M ")
jtkorhonen@17 304
Chris@98 305 runner -> startHgCommand(workFolderPath, params);
Chris@98 306 runningAction = ACT_REMOVE;
jtkorhonen@17 307 }
jtkorhonen@5 308 }
Chris@98 309 */
jtkorhonen@0 310 }
jtkorhonen@0 311
jtkorhonen@0 312 void MainWindow::hgCommit()
jtkorhonen@0 313 {
Chris@109 314 QStringList params;
Chris@109 315 QString comment;
Chris@94 316
Chris@157 317 if (justMerged) {
Chris@157 318 comment = mergeCommitComment;
Chris@157 319 }
Chris@157 320
Chris@109 321 QStringList files = hgTabs->getSelectedCommittableFiles();
Chris@127 322 QStringList reportFiles = files;
Chris@127 323 if (reportFiles.empty()) reportFiles = hgTabs->getAllCommittableFiles();
Chris@103 324
Chris@155 325 QString cf(tr("Commit files"));
Chris@155 326
Chris@109 327 if (ConfirmCommentDialog::confirmAndGetLongComment
Chris@109 328 (this,
Chris@155 329 cf,
Chris@155 330 tr("<h3>%1</h3><p>%2").arg(cf)
Chris@155 331 .arg(tr("You are about to commit the following files:")),
Chris@155 332 tr("<h3>%1</h3><p>%2").arg(cf)
Chris@155 333 .arg(tr("You are about to commit %n file(s):", "", reportFiles.size())),
Chris@127 334 reportFiles,
Chris@109 335 comment)) {
Chris@103 336
Chris@157 337 if (!justMerged && !files.empty()) {
Chris@157 338 // User wants to commit selected file(s) (and this is not
Chris@157 339 // merge commit, which would fail if we selected files)
Chris@157 340 params << "commit" << "--message" << comment
Chris@157 341 << "--user" << getUserInfo() << "--" << files;
Chris@109 342 } else {
Chris@109 343 // Commit all changes
Chris@157 344 params << "commit" << "--message" << comment
Chris@157 345 << "--user" << getUserInfo();
jtkorhonen@0 346 }
Chris@109 347
Chris@109 348 runner->requestAction(HgAction(ACT_COMMIT, workFolderPath, params));
jtkorhonen@0 349 }
Chris@157 350
Chris@157 351 justMerged = false;
jtkorhonen@0 352 }
jtkorhonen@0 353
jtkorhonen@34 354 QString MainWindow::filterTag(QString tag)
jtkorhonen@34 355 {
jtkorhonen@34 356 for(int i = 0; i < tag.size(); i++)
jtkorhonen@34 357 {
jtkorhonen@34 358 if (tag[i].isLower() || tag[i].isUpper() || tag[i].isDigit() || (tag[i] == QChar('.')))
jtkorhonen@34 359 {
jtkorhonen@34 360 //ok
jtkorhonen@34 361 }
jtkorhonen@34 362 else
jtkorhonen@34 363 {
jtkorhonen@34 364 tag[i] = QChar('_');
jtkorhonen@34 365 }
jtkorhonen@34 366 }
jtkorhonen@34 367 return tag;
jtkorhonen@34 368 }
jtkorhonen@34 369
jtkorhonen@34 370
jtkorhonen@34 371 void MainWindow::hgTag()
jtkorhonen@34 372 {
Chris@109 373 QStringList params;
Chris@109 374 QString tag;
jtkorhonen@34 375
Chris@109 376 if (ConfirmCommentDialog::confirmAndGetShortComment
Chris@109 377 (this,
Chris@109 378 tr("Tag"),
Chris@109 379 tr("Enter tag:"),
Chris@109 380 tag)) {
Chris@109 381 if (!tag.isEmpty()) //!!! do something better if it is empty
Chris@109 382 {
Chris@109 383 params << "tag" << "--user" << getUserInfo() << filterTag(tag);
Chris@109 384
Chris@109 385 runner->requestAction(HgAction(ACT_TAG, workFolderPath, params));
jtkorhonen@34 386 }
jtkorhonen@34 387 }
jtkorhonen@34 388 }
jtkorhonen@34 389
jtkorhonen@34 390
jtkorhonen@34 391 void MainWindow::hgIgnore()
jtkorhonen@34 392 {
Chris@109 393 QString hgIgnorePath;
Chris@109 394 QStringList params;
Chris@109 395 QString editorName;
Chris@109 396
Chris@109 397 hgIgnorePath = workFolderPath;
Chris@109 398 hgIgnorePath += ".hgignore";
Chris@109 399
Chris@109 400 params << hgIgnorePath;
Chris@112 401
Chris@112 402 //!!!
Chris@112 403 #ifdef Q_OS_LINUX
Chris@112 404
Chris@109 405 editorName = "gedit";
Chris@112 406
Chris@112 407 #else
Chris@112 408
Chris@109 409 editorName = """C:\\Program Files\\Windows NT\\Accessories\\wordpad.exe""";
Chris@112 410
Chris@112 411 #endif
jtkorhonen@34 412
Chris@109 413 HgAction action(ACT_HG_IGNORE, workFolderPath, params);
Chris@109 414 action.executable = editorName;
jtkorhonen@34 415
Chris@109 416 runner->requestAction(action);
jtkorhonen@34 417 }
jtkorhonen@34 418
Chris@112 419 void MainWindow::findDiffBinaryName()
Chris@112 420 {
Chris@112 421 QSettings settings;
Chris@112 422 QString diff = settings.value("extdiffbinary", "").toString();
Chris@112 423 if (diff == "") {
Chris@112 424 QStringList bases;
Chris@112 425 bases << "opendiff" << "kompare" << "kdiff3" << "meld";
Chris@112 426 bool found = false;
Chris@112 427 foreach (QString base, bases) {
Chris@112 428 diff = findExecutable(base);
Chris@112 429 if (diff != base) {
Chris@112 430 found = true;
Chris@112 431 break;
Chris@112 432 }
Chris@112 433 }
Chris@112 434 if (found) {
Chris@112 435 settings.setValue("extdiffbinary", diff);
Chris@112 436 } else {
Chris@112 437 diff = "";
Chris@112 438 }
Chris@112 439 }
Chris@112 440 diffBinaryName = diff;
Chris@112 441 }
jtkorhonen@34 442
jtkorhonen@0 443 void MainWindow::hgFileDiff()
jtkorhonen@0 444 {
jtkorhonen@0 445 QStringList params;
Chris@91 446 /*!!!
Chris@98 447 QString currentFile = hgTabs -> getCurrentFileListLine();
jtkorhonen@0 448
jtkorhonen@0 449 if (!currentFile.isEmpty())
jtkorhonen@0 450 {
jtkorhonen@0 451 //Diff parent file against working folder file
mg@41 452 params << "kdiff3" << "--" << currentFile.mid(2);
Chris@62 453 runner -> startHgCommand(workFolderPath, params);
jtkorhonen@0 454 runningAction = ACT_FILEDIFF;
jtkorhonen@0 455 }
Chris@91 456 */
jtkorhonen@0 457 }
jtkorhonen@0 458
jtkorhonen@0 459
jtkorhonen@0 460 void MainWindow::hgFolderDiff()
jtkorhonen@0 461 {
Chris@112 462 if (diffBinaryName == "") return;
Chris@112 463
Chris@109 464 QStringList params;
jtkorhonen@0 465
Chris@112 466 // Diff parent against working folder (folder diff)
Chris@112 467
Chris@148 468 params << "--config" << "extensions.extdiff=" << "extdiff";
Chris@148 469 params << "--program" << diffBinaryName;
Chris@109 470
Chris@153 471 params << hgTabs->getSelectedCommittableFiles(); // may be none: whole dir
Chris@153 472
Chris@109 473 runner->requestAction(HgAction(ACT_FOLDERDIFF, workFolderPath, params));
jtkorhonen@0 474 }
jtkorhonen@0 475
jtkorhonen@0 476
Chris@148 477 void MainWindow::hgDiffToCurrent(QString id)
jtkorhonen@0 478 {
Chris@148 479 QStringList params;
jtkorhonen@0 480
Chris@148 481 // Diff given revision against working folder
jtkorhonen@0 482
Chris@148 483 params << "--config" << "extensions.extdiff=" << "extdiff";
Chris@148 484 params << "--program" << diffBinaryName;
Chris@153 485 params << "--rev" << Changeset::hashOf(id);
Chris@148 486
Chris@148 487 runner->requestAction(HgAction(ACT_FOLDERDIFF, workFolderPath, params));
jtkorhonen@0 488 }
jtkorhonen@0 489
jtkorhonen@0 490
Chris@148 491 void MainWindow::hgDiffToParent(QString child, QString parent)
Chris@148 492 {
Chris@148 493 QStringList params;
Chris@148 494
Chris@148 495 // Diff given revision against working folder
Chris@148 496
Chris@148 497 params << "--config" << "extensions.extdiff=" << "extdiff";
Chris@148 498 params << "--program" << diffBinaryName;
Chris@153 499 params << "--rev" << Changeset::hashOf(parent)
Chris@153 500 << "--rev" << Changeset::hashOf(child);
Chris@148 501
Chris@148 502 runner->requestAction(HgAction(ACT_CHGSETDIFF, workFolderPath, params));
Chris@148 503 }
Chris@148 504
jtkorhonen@0 505
jtkorhonen@0 506 void MainWindow::hgUpdate()
jtkorhonen@0 507 {
Chris@109 508 QStringList params;
jtkorhonen@0 509
Chris@109 510 params << "update";
Chris@109 511
Chris@109 512 runner->requestAction(HgAction(ACT_UPDATE, workFolderPath, params));
jtkorhonen@0 513 }
jtkorhonen@0 514
jtkorhonen@0 515
Chris@148 516 void MainWindow::hgUpdateToRev(QString id)
jtkorhonen@0 517 {
Chris@148 518 QStringList params;
jtkorhonen@0 519
Chris@153 520 params << "update" << "--rev" << Changeset::hashOf(id) << "--check";
jtkorhonen@0 521
Chris@148 522 runner->requestAction(HgAction(ACT_UPDATE, workFolderPath, params));
jtkorhonen@0 523 }
jtkorhonen@0 524
jtkorhonen@0 525
jtkorhonen@0 526 void MainWindow::hgRevert()
jtkorhonen@0 527 {
Chris@109 528 QStringList params;
Chris@109 529 QString comment;
Chris@98 530
Chris@109 531 QStringList files = hgTabs->getSelectedRevertableFiles();
Chris@109 532 if (files.empty()) files = hgTabs->getAllRevertableFiles();
Chris@155 533
Chris@155 534 QString rf(tr("Revert files"));
Chris@109 535
Chris@109 536 if (ConfirmCommentDialog::confirmDangerousFilesAction
Chris@109 537 (this,
Chris@155 538 rf,
Chris@155 539 tr("<h3>%1</h3><p>%2").arg(rf)
Chris@155 540 .arg(tr("You are about to <b>revert</b> the following files to their previous committed state.<br><br>This will <b>throw away any changes</b> that you have made to these files but have not committed:")),
Chris@155 541 tr("<h3>%1</h3><p>%2").arg(rf)
Chris@155 542 .arg(tr("You are about to <b>revert</b> %n file(s).<br><br>This will <b>throw away any changes</b> that you have made to these files but have not committed.", "", files.size())),
Chris@109 543 files)) {
Chris@109 544
Chris@98 545 if (files.empty()) {
Chris@98 546 params << "revert" << "--no-backup";
Chris@98 547 } else {
Chris@98 548 params << "revert" << "--no-backup" << "--" << files;
Chris@98 549 }
Chris@109 550
Chris@109 551 runner->requestAction(HgAction(ACT_REVERT, workFolderPath, params));
jtkorhonen@0 552 }
jtkorhonen@0 553 }
jtkorhonen@0 554
jtkorhonen@33 555 void MainWindow::hgRetryMerge()
jtkorhonen@33 556 {
Chris@109 557 QStringList params;
jtkorhonen@33 558
Chris@109 559 params << "resolve" << "--all";
Chris@109 560 runner->requestAction(HgAction(ACT_RETRY_MERGE, workFolderPath, params));
jtkorhonen@33 561 }
jtkorhonen@33 562
jtkorhonen@33 563
jtkorhonen@0 564 void MainWindow::hgMerge()
jtkorhonen@0 565 {
Chris@109 566 QStringList params;
jtkorhonen@0 567
Chris@109 568 params << "merge";
Chris@109 569
Chris@109 570 runner->requestAction(HgAction(ACT_MERGE, workFolderPath, params));
Chris@157 571
Chris@157 572 mergeCommitComment = tr("Merge");
jtkorhonen@0 573 }
jtkorhonen@0 574
jtkorhonen@0 575
Chris@148 576 void MainWindow::hgMergeFrom(QString id)
Chris@148 577 {
Chris@148 578 QStringList params;
Chris@148 579
Chris@148 580 params << "merge";
Chris@153 581 params << "--rev" << Changeset::hashOf(id);
Chris@148 582
Chris@148 583 runner->requestAction(HgAction(ACT_MERGE, workFolderPath, params));
Chris@157 584
Chris@157 585 mergeCommitComment = "";
Chris@157 586
Chris@157 587 foreach (Changeset *cs, currentHeads) {
Chris@157 588 if (cs->id() == id && !cs->isOnBranch(currentBranch)) {
Chris@157 589 if (cs->branch() == "" || cs->branch() == "default") {
Chris@157 590 mergeCommitComment = tr("Merge from the default branch");
Chris@157 591 } else {
Chris@157 592 mergeCommitComment = tr("Merge from branch \"%1\"").arg(cs->branch());
Chris@157 593 }
Chris@157 594 }
Chris@157 595 }
Chris@157 596
Chris@157 597 if (mergeCommitComment == "") {
Chris@157 598 mergeCommitComment = tr("Merge from %1").arg(id);
Chris@157 599 }
Chris@148 600 }
Chris@148 601
Chris@148 602
jtkorhonen@0 603 void MainWindow::hgCloneFromRemote()
jtkorhonen@0 604 {
Chris@109 605 QStringList params;
jtkorhonen@0 606
Chris@109 607 if (!QDir(workFolderPath).exists()) {
Chris@109 608 if (!QDir().mkpath(workFolderPath)) {
Chris@109 609 DEBUG << "hgCloneFromRemote: Failed to create target path "
Chris@109 610 << workFolderPath << endl;
Chris@109 611 //!!! report error
Chris@109 612 return;
Chris@104 613 }
Chris@109 614 }
Chris@104 615
Chris@109 616 params << "clone" << remoteRepoPath << workFolderPath;
Chris@109 617
Chris@109 618 hgTabs->setWorkFolderAndRepoNames(workFolderPath, remoteRepoPath);
Chris@113 619 hgTabs->updateWorkFolderFileList("");
jtkorhonen@0 620
Chris@109 621 runner->requestAction(HgAction(ACT_CLONEFROMREMOTE, workFolderPath, params));
jtkorhonen@0 622 }
jtkorhonen@0 623
jtkorhonen@0 624 void MainWindow::hgInit()
jtkorhonen@0 625 {
Chris@109 626 QStringList params;
jtkorhonen@0 627
Chris@109 628 params << "init";
Chris@109 629 params << workFolderPath;
jtkorhonen@0 630
Chris@109 631 runner->requestAction(HgAction(ACT_INIT, workFolderPath, params));
jtkorhonen@0 632 }
jtkorhonen@0 633
jtkorhonen@0 634 void MainWindow::hgIncoming()
jtkorhonen@0 635 {
Chris@109 636 QStringList params;
jtkorhonen@0 637
Chris@109 638 params << "incoming" << "--newest-first" << remoteRepoPath;
Chris@125 639 params << "--template" << Changeset::getLogTemplate();
jtkorhonen@0 640
Chris@109 641 runner->requestAction(HgAction(ACT_INCOMING, workFolderPath, params));
jtkorhonen@0 642 }
jtkorhonen@0 643
jtkorhonen@0 644 void MainWindow::hgPull()
jtkorhonen@0 645 {
Chris@126 646 if (QMessageBox::question
Chris@126 647 (this, tr("Confirm pull"),
Chris@126 648 format3(tr("Confirm pull from remote repository"),
Chris@126 649 tr("You are about to pull from the following remote repository:"),
Chris@126 650 remoteRepoPath),
Chris@126 651 QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Ok) {
jtkorhonen@0 652
Chris@126 653 QStringList params;
Chris@126 654 params << "pull" << remoteRepoPath;
Chris@126 655 runner->requestAction(HgAction(ACT_PULL, workFolderPath, params));
Chris@126 656 }
jtkorhonen@0 657 }
jtkorhonen@0 658
jtkorhonen@0 659 void MainWindow::hgPush()
jtkorhonen@0 660 {
Chris@126 661 if (QMessageBox::question
Chris@126 662 (this, tr("Confirm push"),
Chris@126 663 format3(tr("Confirm push to remote repository"),
Chris@126 664 tr("You are about to push to the following remote repository:"),
Chris@126 665 remoteRepoPath),
Chris@126 666 QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Ok) {
jtkorhonen@0 667
Chris@126 668 QStringList params;
Chris@154 669 params << "push" << "--new-branch" << remoteRepoPath;
Chris@126 670 runner->requestAction(HgAction(ACT_PUSH, workFolderPath, params));
Chris@126 671 }
jtkorhonen@0 672 }
jtkorhonen@0 673
jtkorhonen@28 674 QString MainWindow::listAllUpIpV4Addresses()
jtkorhonen@26 675 {
jtkorhonen@28 676 QString ret;
jtkorhonen@26 677 QList<QNetworkInterface> ifaces = QNetworkInterface::allInterfaces();
jtkorhonen@26 678
jtkorhonen@26 679 for (int i = 0; i < ifaces.count(); i++)
jtkorhonen@26 680 {
jtkorhonen@26 681 QNetworkInterface iface = ifaces.at(i);
jtkorhonen@26 682
jtkorhonen@26 683 if (iface.flags().testFlag(QNetworkInterface::IsUp) && !iface.flags().testFlag(QNetworkInterface::IsLoopBack))
jtkorhonen@26 684 {
jtkorhonen@26 685 for (int j=0; j<iface.addressEntries().count(); j++)
jtkorhonen@26 686 {
jtkorhonen@28 687 QHostAddress tmp = iface.addressEntries().at(j).ip();
jtkorhonen@28 688 if (QAbstractSocket::IPv4Protocol == tmp.protocol())
jtkorhonen@24 689 {
jtkorhonen@28 690 if (!ret.isEmpty())
jtkorhonen@28 691 {
jtkorhonen@28 692 ret += " ";
jtkorhonen@28 693 }
jtkorhonen@28 694 ret += tmp.toString();
jtkorhonen@24 695 }
jtkorhonen@24 696 }
jtkorhonen@22 697 }
jtkorhonen@17 698 }
jtkorhonen@28 699 return ret;
jtkorhonen@28 700 }
jtkorhonen@17 701
Chris@120 702 void MainWindow::clearState()
Chris@120 703 {
Chris@120 704 foreach (Changeset *cs, currentParents) delete cs;
Chris@120 705 currentParents.clear();
Chris@120 706 foreach (Changeset *cs, currentHeads) delete cs;
Chris@120 707 currentHeads.clear();
Chris@120 708 currentBranch = "";
Chris@120 709 needNewLog = true;
Chris@120 710 }
jtkorhonen@17 711
jtkorhonen@11 712 void MainWindow::hgServe()
jtkorhonen@11 713 {
Chris@109 714 QStringList params;
Chris@109 715 QString msg;
jtkorhonen@11 716
Chris@109 717 QString addrs = listAllUpIpV4Addresses();
Chris@109 718 QTextStream(&msg) << "Server running on address(es) (" << addrs << "), port 8000";
Chris@109 719 params << "serve";
jtkorhonen@11 720
Chris@109 721 runner->requestAction(HgAction(ACT_SERVE, workFolderPath, params));
Chris@109 722
Chris@109 723 QMessageBox::information(this, "Serve", msg, QMessageBox::Close);
Chris@109 724 //!!! runner -> killCurrentCommand();
jtkorhonen@11 725 }
jtkorhonen@11 726
Chris@64 727 void MainWindow::startupDialog()
Chris@64 728 {
Chris@64 729 StartupDialog *dlg = new StartupDialog(this);
Chris@65 730 if (dlg->exec()) firstStart = false;
Chris@64 731 }
jtkorhonen@11 732
Chris@69 733 void MainWindow::open()
Chris@69 734 {
Chris@86 735 bool done = false;
Chris@69 736
Chris@86 737 while (!done) {
Chris@69 738
Chris@86 739 MultiChoiceDialog *d = new MultiChoiceDialog
Chris@86 740 (tr("Open Repository"),
Chris@86 741 tr("<qt><big>What would you like to open?</big></qt>"),
Chris@86 742 this);
Chris@69 743
Chris@86 744 d->addChoice("remote",
Chris@86 745 tr("<qt><center><img src=\":images/browser-64.png\"><br>Remote repository</center></qt>"),
Chris@86 746 tr("Open a remote Mercurial repository, by cloning from its URL into a local folder."),
Chris@86 747 MultiChoiceDialog::UrlToDirectoryArg);
Chris@69 748
Chris@86 749 d->addChoice("local",
Chris@86 750 tr("<qt><center><img src=\":images/hglogo-64.png\"><br>Local repository</center></qt>"),
Chris@86 751 tr("Open an existing local Mercurial repository."),
Chris@86 752 MultiChoiceDialog::DirectoryArg);
Chris@69 753
Chris@86 754 d->addChoice("init",
Chris@86 755 tr("<qt><center><img src=\":images/hdd_unmount-64.png\"><br>File folder</center></qt>"),
Chris@86 756 tr("Open a local folder, by creating a Mercurial repository in it."),
Chris@86 757 MultiChoiceDialog::DirectoryArg);
Chris@79 758
Chris@86 759 d->setCurrentChoice("local");
Chris@86 760
Chris@86 761 if (d->exec() == QDialog::Accepted) {
Chris@86 762
Chris@86 763 QString choice = d->getCurrentChoice();
Chris@86 764 QString arg = d->getArgument().trimmed();
Chris@86 765
Chris@86 766 bool result = false;
Chris@86 767
Chris@86 768 if (choice == "local") {
Chris@86 769 result = openLocal(arg);
Chris@86 770 } else if (choice == "remote") {
Chris@86 771 result = openRemote(arg, d->getAdditionalArgument().trimmed());
Chris@86 772 } else if (choice == "init") {
Chris@86 773 result = openInit(arg);
Chris@86 774 }
Chris@86 775
Chris@86 776 if (result) {
Chris@86 777 enableDisableActions();
Chris@120 778 clearState();
Chris@109 779 hgQueryPaths();
Chris@91 780 done = true;
Chris@91 781 }
Chris@86 782
Chris@86 783 } else {
Chris@86 784
Chris@86 785 // cancelled
Chris@86 786 done = true;
Chris@69 787 }
Chris@79 788
Chris@86 789 delete d;
Chris@69 790 }
Chris@69 791 }
Chris@69 792
Chris@145 793 void MainWindow::open(QString local)
Chris@145 794 {
Chris@145 795 if (openLocal(local)) {
Chris@145 796 enableDisableActions();
Chris@145 797 clearState();
Chris@145 798 hgQueryPaths();
Chris@145 799 }
Chris@145 800 }
Chris@145 801
Chris@79 802 bool MainWindow::complainAboutFilePath(QString arg)
Chris@79 803 {
Chris@79 804 QMessageBox::critical
Chris@79 805 (this, tr("File chosen"),
Chris@84 806 tr("<qt><b>Folder required</b><br><br>You asked to open \"%1\".<br>This is a file; to open a repository, you need to choose a folder.</qt>").arg(xmlEncode(arg)));
Chris@79 807 return false;
Chris@79 808 }
Chris@79 809
Chris@79 810 bool MainWindow::complainAboutUnknownFolder(QString arg)
Chris@79 811 {
Chris@79 812 QMessageBox::critical
Chris@79 813 (this, tr("Folder does not exist"),
Chris@84 814 tr("<qt><b>Folder does not exist</b><br><br>You asked to open \"%1\".<br>This folder does not exist, and it cannot be created because its parent does not exist either.</qt>").arg(xmlEncode(arg)));
Chris@84 815 return false;
Chris@84 816 }
Chris@84 817
Chris@84 818 bool MainWindow::complainAboutInitInRepo(QString arg)
Chris@84 819 {
Chris@84 820 QMessageBox::critical
Chris@84 821 (this, tr("Path is in existing repository"),
Chris@84 822 tr("<qt><b>Path is in an existing repository</b><br><br>You asked to initialise a repository at \"%1\".<br>This path is already inside an existing repository.</qt>").arg(xmlEncode(arg)));
Chris@84 823 return false;
Chris@84 824 }
Chris@84 825
Chris@84 826 bool MainWindow::complainAboutInitFile(QString arg)
Chris@84 827 {
Chris@84 828 QMessageBox::critical
Chris@84 829 (this, tr("Path is a file"),
Chris@84 830 tr("<qt><b>Path is a file</b><br><br>You asked to initialise a repository at \"%1\".<br>This is an existing file; it is only possible to initialise in folders.</qt>").arg(xmlEncode(arg)));
Chris@84 831 return false;
Chris@84 832 }
Chris@84 833
Chris@84 834 bool MainWindow::complainAboutCloneToExisting(QString arg)
Chris@84 835 {
Chris@84 836 QMessageBox::critical
Chris@84 837 (this, tr("Path is in existing repository"),
Chris@84 838 tr("<qt><b>Local path is in an existing repository</b><br><br>You asked to open a remote repository by cloning it to the local path \"%1\".<br>This path is already inside an existing repository.<br>Please provide a new folder name for the local repository.</qt>").arg(xmlEncode(arg)));
Chris@84 839 return false;
Chris@84 840 }
Chris@84 841
Chris@84 842 bool MainWindow::complainAboutCloneToFile(QString arg)
Chris@84 843 {
Chris@84 844 QMessageBox::critical
Chris@84 845 (this, tr("Path is a file"),
Chris@84 846 tr("<qt><b>Local path is a file</b><br><br>You asked to open a remote repository by cloning it to the local path \"%1\".<br>This path is an existing file.<br>Please provide a new folder name for the local repository.</qt>").arg(xmlEncode(arg)));
Chris@84 847 return false;
Chris@84 848 }
Chris@84 849
Chris@84 850 bool MainWindow::complainAboutCloneToExistingFolder(QString arg)
Chris@84 851 {
Chris@84 852 QMessageBox::critical
Chris@84 853 (this, tr("Folder exists"),
Chris@84 854 tr("<qt><b>Local folder already exists</b><br><br>You asked to open a remote repository by cloning it to the local path \"%1\".<br>This is the path of an existing folder.<br>Please provide a new folder name for the local repository.</qt>").arg(xmlEncode(arg)));
Chris@79 855 return false;
Chris@79 856 }
Chris@79 857
Chris@79 858 bool MainWindow::askToOpenParentRepo(QString arg, QString parent)
Chris@79 859 {
Chris@79 860 return (QMessageBox::question
Chris@84 861 (this, tr("Path is inside a repository"),
Chris@86 862 tr("<qt><b>Open the repository that contains this path?</b><br><br>You asked to open \"%1\".<br>This is not the root folder of a repository.<br>But it is inside a repository, whose root is at \"%2\". <br><br>Would you like to open that repository instead?</qt>")
Chris@79 863 .arg(xmlEncode(arg)).arg(xmlEncode(parent)),
Chris@79 864 QMessageBox::Ok | QMessageBox::Cancel,
Chris@79 865 QMessageBox::Ok)
Chris@79 866 == QMessageBox::Ok);
Chris@79 867 }
Chris@79 868
Chris@79 869 bool MainWindow::askToInitExisting(QString arg)
Chris@79 870 {
Chris@79 871 return (QMessageBox::question
Chris@84 872 (this, tr("Folder has no repository"),
Chris@84 873 tr("<qt><b>Initialise a repository here?</b><br><br>You asked to open \"%1\".<br>This folder does not contain a Mercurial repository.<br><br>Would you like to initialise a repository here?</qt>")
Chris@79 874 .arg(xmlEncode(arg)),
Chris@79 875 QMessageBox::Ok | QMessageBox::Cancel,
Chris@79 876 QMessageBox::Ok)
Chris@79 877 == QMessageBox::Ok);
Chris@79 878 }
Chris@79 879
Chris@79 880 bool MainWindow::askToInitNew(QString arg)
Chris@79 881 {
Chris@79 882 return (QMessageBox::question
Chris@84 883 (this, tr("Folder does not exist"),
Chris@84 884 tr("<qt><b>Initialise a new repository?</b><br><br>You asked to open \"%1\".<br>This folder does not yet exist.<br><br>Would you like to create the folder and initialise a new empty repository in it?</qt>")
Chris@84 885 .arg(xmlEncode(arg)),
Chris@84 886 QMessageBox::Ok | QMessageBox::Cancel,
Chris@84 887 QMessageBox::Ok)
Chris@84 888 == QMessageBox::Ok);
Chris@84 889 }
Chris@84 890
Chris@84 891 bool MainWindow::askToOpenInsteadOfInit(QString arg)
Chris@84 892 {
Chris@84 893 return (QMessageBox::question
Chris@84 894 (this, tr("Repository exists"),
Chris@84 895 tr("<qt><b>Open existing repository?</b><br><br>You asked to initialise a new repository at \"%1\".<br>This folder already contains a repository. Would you like to open it?</qt>")
Chris@79 896 .arg(xmlEncode(arg)),
Chris@79 897 QMessageBox::Ok | QMessageBox::Cancel,
Chris@79 898 QMessageBox::Ok)
Chris@79 899 == QMessageBox::Ok);
Chris@79 900 }
Chris@79 901
Chris@79 902 bool MainWindow::openLocal(QString local)
Chris@79 903 {
Chris@79 904 DEBUG << "open " << local << endl;
Chris@79 905
Chris@79 906 FolderStatus status = getFolderStatus(local);
Chris@79 907 QString containing = getContainingRepoFolder(local);
Chris@79 908
Chris@79 909 switch (status) {
Chris@79 910
Chris@79 911 case FolderHasRepo:
Chris@79 912 // fine
Chris@79 913 break;
Chris@79 914
Chris@79 915 case FolderExists:
Chris@79 916 if (containing != "") {
Chris@79 917 if (!askToOpenParentRepo(local, containing)) return false;
Chris@84 918 local = containing;
Chris@79 919 } else {
Chris@86 920 //!!! No -- this is likely to happen far more by accident
Chris@86 921 // than because the user actually wanted to init something.
Chris@86 922 // Don't ask, just politely reject.
Chris@79 923 if (!askToInitExisting(local)) return false;
Chris@79 924 return openInit(local);
Chris@79 925 }
Chris@79 926 break;
Chris@79 927
Chris@79 928 case FolderParentExists:
Chris@79 929 if (containing != "") {
Chris@79 930 if (!askToOpenParentRepo(local, containing)) return false;
Chris@84 931 local = containing;
Chris@79 932 } else {
Chris@79 933 if (!askToInitNew(local)) return false;
Chris@79 934 return openInit(local);
Chris@79 935 }
Chris@79 936 break;
Chris@79 937
Chris@79 938 case FolderUnknown:
Chris@84 939 if (containing != "") {
Chris@84 940 if (!askToOpenParentRepo(local, containing)) return false;
Chris@84 941 local = containing;
Chris@84 942 } else {
Chris@84 943 return complainAboutUnknownFolder(local);
Chris@84 944 }
Chris@84 945 break;
Chris@79 946
Chris@79 947 case FolderIsFile:
Chris@79 948 return complainAboutFilePath(local);
Chris@79 949 }
Chris@79 950
Chris@79 951 workFolderPath = local;
Chris@79 952 remoteRepoPath = "";
Chris@79 953 return true;
Chris@79 954 }
Chris@79 955
Chris@79 956 bool MainWindow::openRemote(QString remote, QString local)
Chris@79 957 {
Chris@79 958 DEBUG << "clone " << remote << " to " << local << endl;
Chris@84 959
Chris@84 960 FolderStatus status = getFolderStatus(local);
Chris@84 961 QString containing = getContainingRepoFolder(local);
Chris@84 962
Chris@84 963 DEBUG << "status = " << status << ", containing = " << containing << endl;
Chris@84 964
Chris@84 965 if (status == FolderHasRepo || containing != "") {
Chris@84 966 return complainAboutCloneToExisting(local);
Chris@84 967 }
Chris@84 968
Chris@84 969 if (status == FolderIsFile) {
Chris@84 970 return complainAboutCloneToFile(local);
Chris@84 971 }
Chris@84 972
Chris@84 973 if (status == FolderUnknown) {
Chris@84 974 return complainAboutUnknownFolder(local);
Chris@84 975 }
Chris@84 976
Chris@84 977 if (status == FolderExists) {
Chris@84 978 //!!! we can do better than this surely?
Chris@84 979 return complainAboutCloneToExistingFolder(local);
Chris@84 980 }
Chris@84 981
Chris@84 982 workFolderPath = local;
Chris@84 983 remoteRepoPath = remote;
Chris@84 984 hgCloneFromRemote();
Chris@84 985
Chris@79 986 return true;
Chris@79 987 }
Chris@79 988
Chris@84 989 bool MainWindow::openInit(QString local)
Chris@79 990 {
Chris@84 991 DEBUG << "openInit " << local << endl;
Chris@84 992
Chris@84 993 FolderStatus status = getFolderStatus(local);
Chris@84 994 QString containing = getContainingRepoFolder(local);
Chris@84 995
Chris@84 996 DEBUG << "status = " << status << ", containing = " << containing << endl;
Chris@84 997
Chris@84 998 if (status == FolderHasRepo) {
Chris@84 999 if (!askToOpenInsteadOfInit(local)) return false;
Chris@84 1000 }
Chris@84 1001
Chris@84 1002 if (containing != "") {
Chris@84 1003 return complainAboutInitInRepo(local);
Chris@84 1004 }
Chris@84 1005
Chris@84 1006 if (status == FolderIsFile) {
Chris@84 1007 return complainAboutInitFile(local);
Chris@84 1008 }
Chris@84 1009
Chris@84 1010 if (status == FolderUnknown) {
Chris@84 1011 return complainAboutUnknownFolder(local);
Chris@84 1012 }
Chris@84 1013
Chris@84 1014 workFolderPath = local;
Chris@84 1015 remoteRepoPath = "";
Chris@84 1016 hgInit();
Chris@79 1017 return true;
Chris@79 1018 }
Chris@79 1019
jtkorhonen@0 1020 void MainWindow::settings()
jtkorhonen@0 1021 {
Chris@69 1022 /*!!!
jtkorhonen@0 1023 SettingsDialog *settingsDlg = new SettingsDialog(this);
jtkorhonen@0 1024 settingsDlg->setModal(true);
jtkorhonen@0 1025 settingsDlg->exec();
Chris@98 1026 hgTabs -> clearLists();
jtkorhonen@0 1027 enableDisableActions();
jtkorhonen@0 1028 hgStat();
Chris@69 1029 */
jtkorhonen@0 1030 }
jtkorhonen@0 1031
jtkorhonen@2 1032 #define STDOUT_NEEDS_BIG_WINDOW 512
jtkorhonen@2 1033 #define SMALL_WND_W 500
jtkorhonen@2 1034 #define SMALL_WND_H 300
jtkorhonen@2 1035
jtkorhonen@2 1036 #define BIG_WND_W 1024
jtkorhonen@2 1037 #define BIG_WND_H 768
jtkorhonen@2 1038
jtkorhonen@2 1039
jtkorhonen@2 1040 void MainWindow::presentLongStdoutToUser(QString stdo)
jtkorhonen@0 1041 {
jtkorhonen@2 1042 if (!stdo.isEmpty())
jtkorhonen@2 1043 {
jtkorhonen@2 1044 QDialog dlg;
jtkorhonen@0 1045
jtkorhonen@2 1046 if (stdo.length() > STDOUT_NEEDS_BIG_WINDOW)
jtkorhonen@2 1047 {
jtkorhonen@2 1048 dlg.setMinimumWidth(BIG_WND_W);
jtkorhonen@2 1049 dlg.setMinimumHeight(BIG_WND_H);
jtkorhonen@2 1050 }
jtkorhonen@2 1051 else
jtkorhonen@2 1052 {
jtkorhonen@2 1053 dlg.setMinimumWidth(SMALL_WND_W);
jtkorhonen@2 1054 dlg.setMinimumHeight(SMALL_WND_H);
jtkorhonen@2 1055 }
jtkorhonen@0 1056
jtkorhonen@2 1057 QVBoxLayout *box = new QVBoxLayout;
jtkorhonen@2 1058 QListWidget *list = new QListWidget;
jtkorhonen@2 1059 list-> addItems(stdo.split("\n"));
jtkorhonen@2 1060 QPushButton *btn = new QPushButton(tr("Ok"));
jtkorhonen@2 1061 connect(btn, SIGNAL(clicked()), &dlg, SLOT(accept()));
jtkorhonen@0 1062
jtkorhonen@2 1063 box -> addWidget(list);
jtkorhonen@2 1064 box -> addWidget(btn);
jtkorhonen@2 1065 dlg.setLayout(box);
jtkorhonen@2 1066
jtkorhonen@2 1067 dlg.exec();
jtkorhonen@2 1068 }
jtkorhonen@2 1069 else
jtkorhonen@2 1070 {
Chris@98 1071 QMessageBox::information(this, tr("EasyMercurial"), tr("Mercurial command did not return any output."));
jtkorhonen@2 1072 }
jtkorhonen@0 1073 }
jtkorhonen@0 1074
Chris@90 1075 void MainWindow::updateFileSystemWatcher()
Chris@90 1076 {
Chris@90 1077 delete fsWatcher;
Chris@90 1078 fsWatcher = new QFileSystemWatcher();
Chris@90 1079 std::deque<QString> pending;
Chris@90 1080 pending.push_back(workFolderPath);
Chris@90 1081 while (!pending.empty()) {
Chris@90 1082 QString path = pending.front();
Chris@90 1083 pending.pop_front();
Chris@90 1084 fsWatcher->addPath(path);
Chris@90 1085 DEBUG << "Added to file system watcher: " << path << endl;
Chris@90 1086 QDir d(path);
Chris@90 1087 if (d.exists()) {
Chris@115 1088 d.setFilter(QDir::Dirs | QDir::NoDotAndDotDot | QDir::Readable);
Chris@90 1089 foreach (QString entry, d.entryList()) {
Chris@90 1090 if (entry == ".hg") continue;
Chris@90 1091 QString entryPath = d.absoluteFilePath(entry);
Chris@90 1092 pending.push_back(entryPath);
Chris@90 1093 }
Chris@90 1094 }
Chris@90 1095 }
Chris@90 1096 connect(fsWatcher, SIGNAL(directoryChanged(QString)),
Chris@90 1097 this, SLOT(fsDirectoryChanged(QString)));
Chris@90 1098 connect(fsWatcher, SIGNAL(fileChanged(QString)),
Chris@90 1099 this, SLOT(fsFileChanged(QString)));
Chris@90 1100 }
Chris@90 1101
Chris@122 1102 void MainWindow::fsDirectoryChanged(QString d)
Chris@90 1103 {
Chris@122 1104 DEBUG << "MainWindow::fsDirectoryChanged " << d << endl;
Chris@90 1105 hgStat();
Chris@90 1106 }
Chris@90 1107
Chris@122 1108 void MainWindow::fsFileChanged(QString f)
Chris@90 1109 {
Chris@122 1110 DEBUG << "MainWindow::fsFileChanged " << f << endl;
Chris@90 1111 hgStat();
Chris@90 1112 }
Chris@90 1113
Chris@125 1114 QString MainWindow::format3(QString head, QString intro, QString code)
Chris@125 1115 {
Chris@125 1116 if (intro == "") {
Chris@125 1117 return QString("<qt><h3>%1</h3><code>%2</code>")
Chris@125 1118 .arg(head).arg(xmlEncode(code).replace("\n", "<br>"));
Chris@126 1119 } else if (code == "") {
Chris@126 1120 return QString("<qt><h3>%1</h3><p>%2</p>")
Chris@126 1121 .arg(head).arg(intro);
Chris@125 1122 } else {
Chris@125 1123 return QString("<qt><h3>%1</h3><p>%2</p><code>%3</code>")
Chris@125 1124 .arg(head).arg(intro).arg(xmlEncode(code).replace("\n", "<br>"));
Chris@125 1125 }
Chris@125 1126 }
Chris@125 1127
Chris@120 1128 void MainWindow::showIncoming(QString output)
Chris@120 1129 {
Chris@120 1130 runner->hide();
Chris@125 1131 IncomingDialog *d = new IncomingDialog(this, output);
Chris@125 1132 d->exec();
Chris@125 1133 delete d;
Chris@125 1134 }
Chris@125 1135
Chris@125 1136 int MainWindow::extractChangeCount(QString text)
Chris@125 1137 {
Chris@125 1138 QRegExp re("added (\\d+) ch\\w+ with (\\d+) ch\\w+ to (\\d+) f\\w+");
Chris@125 1139 if (re.indexIn(text) >= 0) {
Chris@125 1140 return re.cap(1).toInt();
Chris@125 1141 } else if (text.contains("no changes")) {
Chris@125 1142 return 0;
Chris@125 1143 } else {
Chris@125 1144 return -1; // unknown
Chris@125 1145 }
Chris@120 1146 }
Chris@120 1147
Chris@120 1148 void MainWindow::showPushResult(QString output)
Chris@120 1149 {
Chris@125 1150 QString report;
Chris@125 1151 int n = extractChangeCount(output);
Chris@125 1152 if (n > 0) {
Chris@125 1153 report = tr("Pushed %n changeset(s)", "", n);
Chris@125 1154 } else if (n == 0) {
Chris@125 1155 report = tr("No changes to push");
Chris@125 1156 } else {
Chris@125 1157 report = tr("Push complete");
Chris@125 1158 }
Chris@125 1159 report = format3(report, tr("The push command output was:"), output);
Chris@120 1160 runner->hide();
Chris@125 1161 QMessageBox::information(this, "Push complete", report);
Chris@120 1162 }
Chris@120 1163
Chris@120 1164 void MainWindow::showPullResult(QString output)
Chris@120 1165 {
Chris@125 1166 QString report;
Chris@125 1167 int n = extractChangeCount(output);
Chris@125 1168 if (n > 0) {
Chris@125 1169 report = tr("Pulled %n changeset(s)", "", n);
Chris@125 1170 } else if (n == 0) {
Chris@125 1171 report = tr("No changes to pull");
Chris@125 1172 } else {
Chris@125 1173 report = tr("Pull complete");
Chris@125 1174 }
Chris@125 1175 report = format3(report, tr("The pull command output was:"), output);
Chris@120 1176 runner->hide();
Chris@125 1177
Chris@125 1178 //!!! and something about updating
Chris@125 1179
Chris@125 1180 QMessageBox::information(this, "Pull complete", report);
Chris@120 1181 }
Chris@120 1182
Chris@143 1183 void MainWindow::commandFailed(HgAction action, QString output)
Chris@62 1184 {
Chris@62 1185 DEBUG << "MainWindow::commandFailed" << endl;
Chris@74 1186
Chris@113 1187 // Some commands we just have to ignore bad return values from:
Chris@113 1188
Chris@113 1189 switch(action.action) {
Chris@113 1190 case ACT_NONE:
Chris@113 1191 // uh huh
Chris@113 1192 return;
Chris@113 1193 case ACT_INCOMING:
Chris@113 1194 // returns non-zero code if the check was successful but there
Chris@113 1195 // are no changes pending
Chris@143 1196 if (output.trimmed() == "") showIncoming("");
Chris@113 1197 return;
Chris@113 1198 case ACT_FOLDERDIFF:
Chris@113 1199 case ACT_FILEDIFF:
Chris@113 1200 case ACT_CHGSETDIFF:
Chris@113 1201 // external program, unlikely to be anything useful in stderr
Chris@113 1202 // and some return with failure codes when something as basic
Chris@113 1203 // as the user closing the window via the wm happens
Chris@113 1204 return;
Chris@113 1205
Chris@113 1206 default:
Chris@114 1207 break;
Chris@113 1208 }
Chris@113 1209
Chris@113 1210 QString command = action.executable;
Chris@113 1211 if (command == "") command = "hg";
Chris@113 1212 foreach (QString arg, action.params) {
Chris@113 1213 command += " " + arg;
Chris@113 1214 }
Chris@113 1215
Chris@113 1216 QString message = tr("<qt><h3>Command failed</h3>"
Chris@113 1217 "<p>The following command failed:</p>"
Chris@113 1218 "<code>%1</code>"
Chris@113 1219 "%2</qt>")
Chris@113 1220 .arg(command)
Chris@143 1221 .arg((output.trimmed() != "") ?
Chris@113 1222 tr("<p>Its output said:</p><code>%1</code>")
Chris@143 1223 .arg(xmlEncode(output.left(800))
Chris@113 1224 .replace("\n", "<br>"))
Chris@113 1225 : "");
Chris@113 1226
Chris@113 1227 QMessageBox::warning(this, tr("Command failed"), message);
Chris@150 1228
Chris@150 1229 /* todo:
Chris@150 1230 if ((runningAction == ACT_MERGE) && (exitCode != 0))
Chris@150 1231 {
Chris@150 1232 // If we had a failed merge, offer to retry
Chris@150 1233 if (QMessageBox::Ok == QMessageBox::information(this, tr("Retry merge ?"), tr("Merge attempt failed. retry ?"), QMessageBox::Ok | QMessageBox::Cancel))
Chris@150 1234 {
Chris@150 1235 runningAction = ACT_NONE;
Chris@150 1236 hgRetryMerge();
Chris@150 1237 }
Chris@150 1238 else
Chris@150 1239 {
Chris@150 1240 runningAction = ACT_NONE;
Chris@150 1241 hgStat();
Chris@150 1242 }
Chris@150 1243 }
Chris@150 1244 else
Chris@150 1245 {
Chris@150 1246 */
Chris@62 1247 }
Chris@62 1248
Chris@109 1249 void MainWindow::commandCompleted(HgAction completedAction, QString output)
jtkorhonen@0 1250 {
Chris@109 1251 HGACTIONS action = completedAction.action;
Chris@109 1252
Chris@109 1253 if (action == ACT_NONE) return;
Chris@109 1254
Chris@150 1255 bool shouldHgStat = false;
Chris@150 1256 bool headsChanged = false;
Chris@150 1257 QStringList oldHeadIds;
Chris@150 1258
Chris@150 1259 switch (action) {
Chris@109 1260
Chris@109 1261 case ACT_QUERY_PATHS:
jtkorhonen@0 1262 {
Chris@109 1263 DEBUG << "stdout is " << output << endl;
Chris@109 1264 LogParser lp(output, "=");
Chris@109 1265 LogList ll = lp.parse();
Chris@109 1266 DEBUG << ll.size() << " results" << endl;
Chris@109 1267 if (!ll.empty()) {
Chris@109 1268 remoteRepoPath = lp.parse()[0]["default"].trimmed();
Chris@109 1269 DEBUG << "Set remote path to " << remoteRepoPath << endl;
Chris@109 1270 }
Chris@109 1271 MultiChoiceDialog::addRecentArgument("local", workFolderPath);
Chris@109 1272 MultiChoiceDialog::addRecentArgument("remote", remoteRepoPath);
Chris@109 1273 hgTabs->setWorkFolderAndRepoNames(workFolderPath, remoteRepoPath);
Chris@109 1274 break;
Chris@109 1275 }
jtkorhonen@0 1276
Chris@109 1277 case ACT_QUERY_BRANCH:
Chris@109 1278 currentBranch = output.trimmed();
Chris@109 1279 break;
jtkorhonen@0 1280
Chris@109 1281 case ACT_STAT:
Chris@153 1282 if (fsWatcher) fsWatcher->blockSignals(false);
Chris@113 1283 hgTabs->updateWorkFolderFileList(output);
Chris@109 1284 updateFileSystemWatcher();
Chris@109 1285 break;
Chris@109 1286
Chris@109 1287 case ACT_INCOMING:
Chris@120 1288 showIncoming(output);
Chris@120 1289 break;
Chris@120 1290
Chris@109 1291 case ACT_ANNOTATE:
Chris@109 1292 case ACT_RESOLVE_LIST:
Chris@109 1293 case ACT_RESOLVE_MARK:
Chris@109 1294 presentLongStdoutToUser(output);
Chris@109 1295 shouldHgStat = true;
Chris@109 1296 break;
Chris@109 1297
Chris@109 1298 case ACT_PULL:
Chris@120 1299 showPullResult(output);
Chris@109 1300 shouldHgStat = true;
Chris@109 1301 break;
Chris@109 1302
Chris@109 1303 case ACT_PUSH:
Chris@120 1304 showPushResult(output);
Chris@109 1305 break;
Chris@109 1306
Chris@109 1307 case ACT_INIT:
Chris@109 1308 MultiChoiceDialog::addRecentArgument("init", workFolderPath);
Chris@109 1309 MultiChoiceDialog::addRecentArgument("local", workFolderPath);
Chris@109 1310 enableDisableActions();
Chris@109 1311 shouldHgStat = true;
Chris@109 1312 break;
Chris@109 1313
Chris@109 1314 case ACT_CLONEFROMREMOTE:
Chris@109 1315 MultiChoiceDialog::addRecentArgument("local", workFolderPath);
Chris@109 1316 MultiChoiceDialog::addRecentArgument("remote", remoteRepoPath);
Chris@109 1317 MultiChoiceDialog::addRecentArgument("remote", workFolderPath, true);
Chris@109 1318 QMessageBox::information(this, "Clone", output);
Chris@109 1319 enableDisableActions();
Chris@109 1320 shouldHgStat = true;
Chris@109 1321 break;
Chris@109 1322
Chris@109 1323 case ACT_LOG:
Chris@120 1324 hgTabs->setNewLog(output);
Chris@120 1325 needNewLog = false;
Chris@120 1326 break;
Chris@120 1327
Chris@120 1328 case ACT_LOG_INCREMENTAL:
Chris@120 1329 hgTabs->addIncrementalLog(output);
Chris@109 1330 break;
Chris@109 1331
Chris@109 1332 case ACT_QUERY_PARENTS:
Chris@152 1333 {
Chris@109 1334 foreach (Changeset *cs, currentParents) delete cs;
Chris@109 1335 currentParents = Changeset::parseChangesets(output);
Chris@152 1336 QStringList parentIds = Changeset::getIds(currentParents);
Chris@153 1337 hgTabs->setCurrent(parentIds, currentBranch);
Chris@152 1338 }
Chris@109 1339 break;
Chris@109 1340
Chris@109 1341 case ACT_QUERY_HEADS:
Chris@150 1342 {
Chris@150 1343 oldHeadIds = Changeset::getIds(currentHeads);
Chris@150 1344 Changesets newHeads = Changeset::parseChangesets(output);
Chris@150 1345 QStringList newHeadIds = Changeset::getIds(newHeads);
Chris@150 1346 if (oldHeadIds != newHeadIds) {
Chris@150 1347 DEBUG << "Heads changed, will prompt an incremental log if appropriate" << endl;
Chris@150 1348 headsChanged = true;
Chris@150 1349 foreach (Changeset *cs, currentHeads) delete cs;
Chris@150 1350 currentHeads = newHeads;
Chris@150 1351 }
Chris@150 1352 }
Chris@109 1353 break;
Chris@130 1354
Chris@130 1355 case ACT_COMMIT:
Chris@130 1356 hgTabs->clearSelections();
Chris@130 1357 shouldHgStat = true;
Chris@130 1358 break;
Chris@109 1359
Chris@109 1360 case ACT_REMOVE:
Chris@109 1361 case ACT_ADD:
Chris@116 1362 case ACT_REVERT:
Chris@116 1363 hgTabs->clearSelections();
Chris@116 1364 shouldHgStat = true;
Chris@116 1365 break;
Chris@116 1366
Chris@109 1367 case ACT_FILEDIFF:
Chris@109 1368 case ACT_FOLDERDIFF:
Chris@109 1369 case ACT_CHGSETDIFF:
Chris@109 1370 case ACT_SERVE:
Chris@109 1371 case ACT_TAG:
Chris@109 1372 case ACT_HG_IGNORE:
Chris@109 1373 shouldHgStat = true;
Chris@109 1374 break;
Chris@109 1375
Chris@109 1376 case ACT_UPDATE:
Chris@109 1377 QMessageBox::information(this, tr("Update"), output);
Chris@109 1378 shouldHgStat = true;
Chris@109 1379 break;
Chris@109 1380
Chris@109 1381 case ACT_MERGE:
Chris@109 1382 QMessageBox::information(this, tr("Merge"), output);
Chris@109 1383 shouldHgStat = true;
Chris@109 1384 justMerged = true;
Chris@109 1385 break;
Chris@109 1386
Chris@109 1387 case ACT_RETRY_MERGE:
Chris@150 1388 QMessageBox::information(this, tr("Merge retry"),
Chris@150 1389 tr("Merge retry successful."));
Chris@109 1390 shouldHgStat = true;
Chris@109 1391 justMerged = true;
Chris@109 1392 break;
Chris@109 1393
Chris@109 1394 default:
Chris@109 1395 break;
Chris@109 1396 }
Chris@108 1397
Chris@121 1398 // Sequence when no full log required:
Chris@150 1399 // paths -> branch -> stat -> heads ->
Chris@150 1400 // incremental-log (only if heads changed) -> parents
Chris@150 1401 //
Chris@121 1402 // Sequence when full log required:
Chris@121 1403 // paths -> branch -> stat -> heads -> parents -> log
Chris@150 1404 //
Chris@150 1405 // Note we want to call enableDisableActions only once, at the end
Chris@150 1406 // of whichever sequence is in use.
Chris@150 1407
Chris@156 1408 bool noMore = false;
Chris@156 1409
Chris@150 1410 switch (action) {
Chris@150 1411
Chris@150 1412 case ACT_QUERY_PATHS:
Chris@109 1413 hgQueryBranch();
Chris@150 1414 break;
Chris@150 1415
Chris@150 1416 case ACT_QUERY_BRANCH:
Chris@109 1417 hgStat();
Chris@150 1418 break;
Chris@150 1419
Chris@150 1420 case ACT_STAT:
Chris@150 1421 hgQueryHeads();
Chris@150 1422 break;
Chris@150 1423
Chris@150 1424 case ACT_QUERY_HEADS:
Chris@150 1425 if (headsChanged && !needNewLog) {
Chris@150 1426 hgLogIncremental(oldHeadIds);
Chris@121 1427 } else {
Chris@150 1428 hgQueryParents();
Chris@121 1429 }
Chris@150 1430 break;
Chris@150 1431
Chris@150 1432 case ACT_LOG_INCREMENTAL:
Chris@109 1433 hgQueryParents();
Chris@150 1434 break;
Chris@150 1435
Chris@150 1436 case ACT_QUERY_PARENTS:
Chris@120 1437 if (needNewLog) {
Chris@120 1438 hgLog();
Chris@150 1439 } else {
Chris@150 1440 // we're done
Chris@156 1441 noMore = true;
Chris@120 1442 }
Chris@150 1443 break;
Chris@150 1444
Chris@150 1445 case ACT_LOG:
Chris@150 1446 // we're done
Chris@156 1447 noMore = true;
Chris@150 1448
Chris@150 1449 default:
Chris@109 1450 if (shouldHgStat) {
Chris@109 1451 hgQueryPaths();
Chris@150 1452 } else {
Chris@156 1453 noMore = true;
jtkorhonen@0 1454 }
Chris@150 1455 break;
Chris@150 1456 }
Chris@156 1457
Chris@156 1458 if (noMore) {
Chris@156 1459 enableDisableActions();
Chris@156 1460 hgTabs->updateHistory();
Chris@156 1461 }
jtkorhonen@0 1462 }
jtkorhonen@0 1463
jtkorhonen@0 1464 void MainWindow::connectActions()
jtkorhonen@0 1465 {
jtkorhonen@0 1466 connect(exitAct, SIGNAL(triggered()), this, SLOT(close()));
jtkorhonen@0 1467 connect(aboutAct, SIGNAL(triggered()), this, SLOT(about()));
jtkorhonen@0 1468 connect(aboutQtAct, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
jtkorhonen@0 1469
Chris@120 1470 connect(hgRefreshAct, SIGNAL(triggered()), this, SLOT(hgRefresh()));
jtkorhonen@0 1471 connect(hgRemoveAct, SIGNAL(triggered()), this, SLOT(hgRemove()));
jtkorhonen@0 1472 connect(hgAddAct, SIGNAL(triggered()), this, SLOT(hgAdd()));
jtkorhonen@0 1473 connect(hgCommitAct, SIGNAL(triggered()), this, SLOT(hgCommit()));
jtkorhonen@0 1474 connect(hgFileDiffAct, SIGNAL(triggered()), this, SLOT(hgFileDiff()));
jtkorhonen@0 1475 connect(hgFolderDiffAct, SIGNAL(triggered()), this, SLOT(hgFolderDiff()));
Chris@149 1476 // connect(hgChgSetDiffAct, SIGNAL(triggered()), this, SLOT(hgChgSetDiff()));
jtkorhonen@0 1477 connect(hgUpdateAct, SIGNAL(triggered()), this, SLOT(hgUpdate()));
jtkorhonen@0 1478 connect(hgRevertAct, SIGNAL(triggered()), this, SLOT(hgRevert()));
jtkorhonen@0 1479 connect(hgMergeAct, SIGNAL(triggered()), this, SLOT(hgMerge()));
jtkorhonen@33 1480 connect(hgRetryMergeAct, SIGNAL(triggered()), this, SLOT(hgRetryMerge()));
jtkorhonen@34 1481 connect(hgTagAct, SIGNAL(triggered()), this, SLOT(hgTag()));
jtkorhonen@34 1482 connect(hgIgnoreAct, SIGNAL(triggered()), this, SLOT(hgIgnore()));
jtkorhonen@0 1483
jtkorhonen@0 1484 connect(settingsAct, SIGNAL(triggered()), this, SLOT(settings()));
Chris@69 1485 connect(openAct, SIGNAL(triggered()), this, SLOT(open()));
jtkorhonen@0 1486
jtkorhonen@0 1487 connect(hgInitAct, SIGNAL(triggered()), this, SLOT(hgInit()));
jtkorhonen@0 1488 connect(hgCloneFromRemoteAct, SIGNAL(triggered()), this, SLOT(hgCloneFromRemote()));
jtkorhonen@0 1489 connect(hgIncomingAct, SIGNAL(triggered()), this, SLOT(hgIncoming()));
jtkorhonen@0 1490 connect(hgPullAct, SIGNAL(triggered()), this, SLOT(hgPull()));
jtkorhonen@0 1491 connect(hgPushAct, SIGNAL(triggered()), this, SLOT(hgPush()));
jtkorhonen@0 1492
Chris@109 1493 // connect(hgTabs, SIGNAL(currentChanged(int)), this, SLOT(tabChanged(int)));
jtkorhonen@0 1494
Chris@148 1495 // connect(hgUpdateToRevAct, SIGNAL(triggered()), this, SLOT(hgUpdateToRev()));
jtkorhonen@0 1496 connect(hgAnnotateAct, SIGNAL(triggered()), this, SLOT(hgAnnotate()));
jtkorhonen@0 1497 connect(hgResolveListAct, SIGNAL(triggered()), this, SLOT(hgResolveList()));
jtkorhonen@0 1498 connect(hgResolveMarkAct, SIGNAL(triggered()), this, SLOT(hgResolveMark()));
jtkorhonen@11 1499 connect(hgServeAct, SIGNAL(triggered()), this, SLOT(hgServe()));
Chris@94 1500 connect(clearSelectionsAct, SIGNAL(triggered()), this, SLOT(clearSelections()));
jtkorhonen@0 1501 }
Chris@141 1502
Chris@141 1503 void MainWindow::connectTabsSignals()
Chris@141 1504 {
Chris@141 1505 connect(hgTabs, SIGNAL(commit()),
Chris@141 1506 this, SLOT(hgCommit()));
Chris@141 1507
Chris@141 1508 connect(hgTabs, SIGNAL(revert()),
Chris@141 1509 this, SLOT(hgRevert()));
Chris@141 1510
Chris@141 1511 connect(hgTabs, SIGNAL(diffWorkingFolder()),
Chris@141 1512 this, SLOT(hgFolderDiff()));
Chris@148 1513
Chris@141 1514 connect(hgTabs, SIGNAL(updateTo(QString)),
Chris@148 1515 this, SLOT(hgUpdateToRev(QString)));
Chris@141 1516
Chris@141 1517 connect(hgTabs, SIGNAL(diffToCurrent(QString)),
Chris@148 1518 this, SLOT(hgDiffToCurrent(QString)));
Chris@141 1519
Chris@148 1520 connect(hgTabs, SIGNAL(diffToParent(QString, QString)),
Chris@148 1521 this, SLOT(hgDiffToParent(QString, QString)));
Chris@141 1522
Chris@141 1523 connect(hgTabs, SIGNAL(mergeFrom(QString)),
Chris@148 1524 this, SLOT(hgMergeFrom(QString)));
Chris@148 1525 /*
Chris@141 1526 connect(hgTabs, SIGNAL(tag(QString)),
Chris@148 1527 this, SLOT(hgTag(QString)));
Chris@141 1528 */
Chris@141 1529 }
Chris@141 1530
Chris@109 1531 /*!!!
jtkorhonen@0 1532 void MainWindow::tabChanged(int currTab)
jtkorhonen@0 1533 {
jtkorhonen@0 1534 tabPage = currTab;
jtkorhonen@32 1535
jtkorhonen@0 1536 }
Chris@109 1537 */
jtkorhonen@0 1538 void MainWindow::enableDisableActions()
jtkorhonen@0 1539 {
Chris@90 1540 DEBUG << "MainWindow::enableDisableActions" << endl;
Chris@90 1541
Chris@115 1542 //!!! should also do things like set the status texts for the
Chris@115 1543 //!!! actions appropriately by context
Chris@115 1544
jtkorhonen@0 1545 QDir localRepoDir;
jtkorhonen@0 1546 QDir workFolderDir;
Chris@145 1547 bool workFolderExist = true;
Chris@145 1548 bool localRepoExist = true;
jtkorhonen@0 1549
jtkorhonen@0 1550 remoteRepoActionsEnabled = true;
Chris@90 1551 if (remoteRepoPath.isEmpty()) {
jtkorhonen@0 1552 remoteRepoActionsEnabled = false;
jtkorhonen@0 1553 }
jtkorhonen@0 1554
jtkorhonen@0 1555 localRepoActionsEnabled = true;
Chris@90 1556 if (workFolderPath.isEmpty()) {
jtkorhonen@0 1557 localRepoActionsEnabled = false;
jtkorhonen@0 1558 workFolderExist = false;
jtkorhonen@0 1559 }
jtkorhonen@0 1560
Chris@90 1561 if (!workFolderDir.exists(workFolderPath)) {
jtkorhonen@0 1562 localRepoActionsEnabled = false;
jtkorhonen@0 1563 workFolderExist = false;
Chris@90 1564 } else {
jtkorhonen@0 1565 workFolderExist = true;
jtkorhonen@0 1566 }
jtkorhonen@0 1567
Chris@112 1568 if (!localRepoDir.exists(workFolderPath + "/.hg")) {
jtkorhonen@0 1569 localRepoActionsEnabled = false;
jtkorhonen@0 1570 localRepoExist = false;
jtkorhonen@0 1571 }
jtkorhonen@0 1572
jtkorhonen@0 1573 hgCloneFromRemoteAct -> setEnabled(remoteRepoActionsEnabled);
jtkorhonen@0 1574 hgIncomingAct -> setEnabled(remoteRepoActionsEnabled && remoteRepoActionsEnabled);
jtkorhonen@0 1575 hgPullAct -> setEnabled(remoteRepoActionsEnabled && remoteRepoActionsEnabled);
jtkorhonen@0 1576 hgPushAct -> setEnabled(remoteRepoActionsEnabled && remoteRepoActionsEnabled);
Chris@73 1577 /*
jtkorhonen@0 1578 if (tabPage != WORKTAB)
jtkorhonen@0 1579 {
jtkorhonen@0 1580 localRepoActionsEnabled = false;
jtkorhonen@0 1581 }
Chris@73 1582 */
Chris@112 1583 bool haveDiff = (diffBinaryName != "");
Chris@112 1584
jtkorhonen@0 1585 hgInitAct -> setEnabled((localRepoExist == false) && (workFolderExist==true));
Chris@120 1586 hgRefreshAct -> setEnabled(localRepoActionsEnabled);
Chris@112 1587 hgFileDiffAct -> setEnabled(localRepoActionsEnabled && haveDiff);
Chris@112 1588 hgFolderDiffAct -> setEnabled(localRepoActionsEnabled && haveDiff);
jtkorhonen@0 1589 hgRevertAct -> setEnabled(localRepoActionsEnabled);
jtkorhonen@0 1590 hgAddAct -> setEnabled(localRepoActionsEnabled);
jtkorhonen@0 1591 hgRemoveAct -> setEnabled(localRepoActionsEnabled);
jtkorhonen@0 1592 hgUpdateAct -> setEnabled(localRepoActionsEnabled);
jtkorhonen@0 1593 hgCommitAct -> setEnabled(localRepoActionsEnabled);
jtkorhonen@0 1594 hgMergeAct -> setEnabled(localRepoActionsEnabled);
jtkorhonen@33 1595 hgRetryMergeAct -> setEnabled(localRepoActionsEnabled);
jtkorhonen@2 1596 hgResolveListAct -> setEnabled(localRepoActionsEnabled);
jtkorhonen@2 1597 hgResolveMarkAct -> setEnabled(localRepoActionsEnabled);
jtkorhonen@2 1598 hgAnnotateAct -> setEnabled(localRepoActionsEnabled);
jtkorhonen@11 1599 hgServeAct -> setEnabled(localRepoActionsEnabled);
jtkorhonen@34 1600 hgTagAct -> setEnabled(localRepoActionsEnabled);
jtkorhonen@34 1601 hgIgnoreAct -> setEnabled(localRepoActionsEnabled);
jtkorhonen@0 1602
Chris@98 1603 //!!!hgTabs -> enableDisableOtherTabs(tabPage);
jtkorhonen@0 1604
Chris@90 1605 DEBUG << "localRepoActionsEnabled = " << localRepoActionsEnabled << endl;
Chris@98 1606 DEBUG << "canCommit = " << hgTabs->canCommit() << endl;
Chris@90 1607
Chris@90 1608 //!!! new stuff:
Chris@98 1609 hgAddAct->setEnabled(localRepoActionsEnabled && hgTabs->canAdd());
Chris@98 1610 hgRemoveAct->setEnabled(localRepoActionsEnabled && hgTabs->canRemove());
Chris@98 1611 hgCommitAct->setEnabled(localRepoActionsEnabled && hgTabs->canCommit());
Chris@98 1612 hgRevertAct->setEnabled(localRepoActionsEnabled && hgTabs->canCommit());
Chris@98 1613 hgFolderDiffAct->setEnabled(localRepoActionsEnabled && hgTabs->canDoDiff());
Chris@90 1614
Chris@108 1615 // A default merge makes sense if:
Chris@108 1616 // * there is only one parent (if there are two, we have an uncommitted merge) and
Chris@108 1617 // * there are exactly two heads that have the same branch as the current branch and
Chris@108 1618 // * our parent is one of those heads
Chris@108 1619 //
Chris@108 1620 // A default update makes sense if:
Chris@108 1621 // * there is only one parent and
Chris@108 1622 // * the parent is not one of the current heads
Chris@156 1623
Chris@108 1624 bool canMerge = false;
Chris@108 1625 bool canUpdate = false;
Chris@156 1626 bool haveMerge = false;
Chris@156 1627 int currentBranchHeads = 0;
Chris@156 1628
Chris@108 1629 if (currentParents.size() == 1) {
Chris@156 1630 bool parentIsHead = false;
Chris@108 1631 Changeset *parent = currentParents[0];
Chris@108 1632 foreach (Changeset *head, currentHeads) {
Chris@108 1633 DEBUG << "head branch " << head->branch() << ", current branch " << currentBranch << endl;
Chris@108 1634 if (head->isOnBranch(currentBranch)) {
Chris@108 1635 ++currentBranchHeads;
Chris@108 1636 if (parent->id() == head->id()) {
Chris@108 1637 parentIsHead = true;
Chris@108 1638 }
Chris@108 1639 }
Chris@108 1640 }
Chris@108 1641 if (currentBranchHeads == 2 && parentIsHead) {
Chris@108 1642 canMerge = true;
Chris@108 1643 }
Chris@108 1644 if (!parentIsHead) {
Chris@108 1645 canUpdate = true;
Chris@108 1646 DEBUG << "parent id = " << parent->id() << endl;
Chris@108 1647 DEBUG << " head ids "<<endl;
Chris@108 1648 foreach (Changeset *h, currentHeads) {
Chris@108 1649 DEBUG << "head id = " << h->id() << endl;
Chris@108 1650 }
Chris@108 1651 }
Chris@156 1652 } else {
Chris@156 1653 haveMerge = true;
Chris@108 1654 }
Chris@156 1655
Chris@108 1656 hgMergeAct->setEnabled(localRepoActionsEnabled && canMerge);
Chris@108 1657 hgUpdateAct->setEnabled(localRepoActionsEnabled && canUpdate);
Chris@115 1658
Chris@115 1659 // Set the state field on the file status widget
Chris@115 1660
Chris@115 1661 QString branchText;
Chris@115 1662 if (currentBranch == "" || currentBranch == "default") {
Chris@115 1663 branchText = tr("the default branch");
Chris@115 1664 } else {
Chris@115 1665 branchText = tr("branch \"%1\"").arg(currentBranch);
Chris@115 1666 }
Chris@156 1667
Chris@156 1668 //!!! Want "merge failed" report
Chris@156 1669
Chris@156 1670 if (canMerge) {
Chris@156 1671 hgTabs->setState(tr("<b>Awaiting merge</b> on %1").arg(branchText));
Chris@156 1672 } else if (haveMerge) {
Chris@157 1673 hgTabs->setState(tr("Have merged but not yet committed on %1").arg(branchText));
Chris@156 1674 } else if (canUpdate) {
Chris@115 1675 hgTabs->setState(tr("On %1. Not at the head of the branch: consider updating").arg(branchText));
Chris@156 1676 } else if (currentBranchHeads > 1) {
Chris@156 1677 hgTabs->setState(tr("At one of %n heads of %1", "", currentBranchHeads).arg(branchText));
Chris@115 1678 } else {
Chris@115 1679 hgTabs->setState(tr("At the head of %1").arg(branchText));
Chris@115 1680 }
jtkorhonen@0 1681 }
jtkorhonen@0 1682
jtkorhonen@0 1683 void MainWindow::createActions()
jtkorhonen@0 1684 {
jtkorhonen@0 1685 //File actions
jtkorhonen@0 1686 hgInitAct = new QAction(tr("Init local repository"), this);
jtkorhonen@0 1687 hgInitAct->setStatusTip(tr("Create an empty local repository in selected folder"));
jtkorhonen@0 1688
jtkorhonen@0 1689 hgCloneFromRemoteAct = new QAction(tr("Clone from remote"), this);
jtkorhonen@0 1690 hgCloneFromRemoteAct->setStatusTip(tr("Clone from remote repository into local repository in selected folder"));
jtkorhonen@0 1691
Chris@69 1692 openAct = new QAction(QIcon(":/images/fileopen.png"), tr("Open..."), this);
Chris@69 1693 openAct -> setStatusTip(tr("Open repository"));
Chris@69 1694 openAct -> setIconVisibleInMenu(true);
Chris@69 1695
jtkorhonen@0 1696 settingsAct = new QAction(QIcon(":/images/settings.png"), tr("Settings..."), this);
jtkorhonen@0 1697 settingsAct -> setStatusTip(tr("View and change application settings"));
jtkorhonen@0 1698 settingsAct -> setIconVisibleInMenu(true);
jtkorhonen@0 1699
jtkorhonen@0 1700 exitAct = new QAction(QIcon(":/images/exit.png"), tr("Exit"), this);
jtkorhonen@0 1701 exitAct->setShortcuts(QKeySequence::Quit);
jtkorhonen@0 1702 exitAct->setStatusTip(tr("Exit application"));
jtkorhonen@0 1703 exitAct -> setIconVisibleInMenu(true);
jtkorhonen@0 1704
jtkorhonen@0 1705 //Repository actions
Chris@120 1706 hgRefreshAct = new QAction(QIcon(":/images/status.png"), tr("Refresh"), this);
Chris@120 1707 hgRefreshAct->setStatusTip(tr("Refresh (info of) status of workfolder files"));
Chris@61 1708
Chris@61 1709 hgIncomingAct = new QAction(QIcon(":/images/incoming.png"), tr("Preview"), this);
jtkorhonen@0 1710 hgIncomingAct -> setStatusTip(tr("View info of changesets incoming to us from remote repository (on pull operation)"));
jtkorhonen@0 1711
Chris@61 1712 hgPullAct = new QAction(QIcon(":/images/pull.png"), tr("Pull"), this);
jtkorhonen@0 1713 hgPullAct -> setStatusTip(tr("Pull changesets from remote repository to local repository"));
jtkorhonen@0 1714
Chris@61 1715 hgPushAct = new QAction(QIcon(":/images/push.png"), tr("Push"), this);
jtkorhonen@0 1716 hgPushAct->setStatusTip(tr("Push local changesets to remote repository"));
jtkorhonen@0 1717
jtkorhonen@0 1718 //Workfolder actions
Chris@61 1719 hgFileDiffAct = new QAction(QIcon(":/images/diff.png"), tr("Diff"), this);
jtkorhonen@0 1720 hgFileDiffAct->setStatusTip(tr("Filediff: View differences between selected working folder file and local repository file"));
jtkorhonen@0 1721
Chris@99 1722 hgFolderDiffAct = new QAction(QIcon(":/images/folderdiff.png"), tr("Diff"), this);
jtkorhonen@0 1723 hgFolderDiffAct->setStatusTip(tr("Folderdiff: View all differences between working folder files and local repository files"));
jtkorhonen@0 1724
jtkorhonen@0 1725 hgChgSetDiffAct = new QAction(QIcon(":/images/chgsetdiff.png"), tr("View changesetdiff"), this);
jtkorhonen@0 1726 hgChgSetDiffAct->setStatusTip(tr("Change set diff: View differences between all files of 2 repository changesets"));
jtkorhonen@0 1727
Chris@61 1728 hgRevertAct = new QAction(QIcon(":/images/undo.png"), tr("Revert"), this);
jtkorhonen@0 1729 hgRevertAct->setStatusTip(tr("Undo selected working folder file changes (return to local repository version)"));
jtkorhonen@0 1730
Chris@61 1731 hgAddAct = new QAction(QIcon(":/images/add.png"), tr("Add"), this);
jtkorhonen@17 1732 hgAddAct -> setStatusTip(tr("Add working folder file(s) (selected or all yet untracked) to local repository (on next commit)"));
jtkorhonen@0 1733
Chris@61 1734 hgRemoveAct = new QAction(QIcon(":/images/remove.png"), tr("Remove"), this);
jtkorhonen@0 1735 hgRemoveAct -> setStatusTip(tr("Remove selected working folder file from local repository (on next commit)"));
jtkorhonen@0 1736
Chris@61 1737 hgUpdateAct = new QAction(QIcon(":/images/update.png"), tr("Update"), this);
jtkorhonen@0 1738 hgUpdateAct->setStatusTip(tr("Update working folder from local repository"));
jtkorhonen@0 1739
Chris@61 1740 hgCommitAct = new QAction(QIcon(":/images/commit.png"), tr("Commit"), this);
jtkorhonen@20 1741 hgCommitAct->setStatusTip(tr("Save selected file(s) or all changed files in working folder (and all subfolders) to local repository"));
jtkorhonen@0 1742
jtkorhonen@0 1743 hgMergeAct = new QAction(QIcon(":/images/merge.png"), tr("Merge"), this);
jtkorhonen@0 1744 hgMergeAct->setStatusTip(tr("Merge two local repository changesets to working folder"));
jtkorhonen@0 1745
jtkorhonen@0 1746 //Advanced actions
Chris@148 1747 /* hgUpdateToRevAct = new QAction(tr("Update to revision"), this);
jtkorhonen@0 1748 hgUpdateToRevAct -> setStatusTip(tr("Update working folder to version selected from history list"));
Chris@148 1749 */
jtkorhonen@0 1750 hgAnnotateAct = new QAction(tr("Annotate"), this);
jtkorhonen@0 1751 hgAnnotateAct -> setStatusTip(tr("Show line-by-line version information for selected file"));
jtkorhonen@0 1752
jtkorhonen@0 1753 hgResolveListAct = new QAction(tr("Resolve (list)"), this);
jtkorhonen@0 1754 hgResolveListAct -> setStatusTip(tr("Resolve (list): Show list of files needing merge"));
jtkorhonen@0 1755
jtkorhonen@0 1756 hgResolveMarkAct = new QAction(tr("Resolve (mark)"), this);
jtkorhonen@0 1757 hgResolveMarkAct -> setStatusTip(tr("Resolve (mark): Mark selected file status as resolved"));
jtkorhonen@0 1758
jtkorhonen@33 1759 hgRetryMergeAct = new QAction(tr("Retry merge"), this);
jtkorhonen@33 1760 hgRetryMergeAct -> setStatusTip(tr("Retry merge after failed merge attempt."));
jtkorhonen@33 1761
jtkorhonen@34 1762 hgTagAct = new QAction(tr("Tag revision"), this);
jtkorhonen@34 1763 hgTagAct -> setStatusTip(tr("Give decsriptive name (tag) to current workfolder parent revision."));
jtkorhonen@34 1764
jtkorhonen@34 1765 hgIgnoreAct = new QAction(tr("Edit .hgignore"), this);
jtkorhonen@34 1766 hgIgnoreAct -> setStatusTip(tr("Edit .hgignore file (file contains names of files that should be ignored by mercurial)"));
jtkorhonen@34 1767
jtkorhonen@11 1768 hgServeAct = new QAction(tr("Serve (via http)"), this);
jtkorhonen@11 1769 hgServeAct -> setStatusTip(tr("Serve local repository via http for workgroup access"));
jtkorhonen@11 1770
jtkorhonen@0 1771 //Help actions
jtkorhonen@0 1772 aboutAct = new QAction(tr("About"), this);
jtkorhonen@0 1773 aboutAct->setStatusTip(tr("Show the application's About box"));
jtkorhonen@0 1774
jtkorhonen@0 1775 aboutQtAct = new QAction(tr("About Qt"), this);
jtkorhonen@0 1776 aboutQtAct->setStatusTip(tr("Show the Qt library's About box"));
Chris@94 1777
Chris@94 1778 // Miscellaneous
Chris@94 1779 clearSelectionsAct = new QAction(tr("Clear selections"), this);
Chris@94 1780 clearSelectionsAct->setShortcut(Qt::Key_Escape);
jtkorhonen@0 1781 }
jtkorhonen@0 1782
jtkorhonen@0 1783 void MainWindow::createMenus()
jtkorhonen@0 1784 {
jtkorhonen@0 1785 fileMenu = menuBar()->addMenu(tr("File"));
Chris@131 1786 /* fileMenu -> addAction(hgInitAct);
jtkorhonen@0 1787 fileMenu -> addAction(hgCloneFromRemoteAct);
Chris@94 1788 fileMenu->addAction(clearSelectionsAct); //!!! can't live here!
jtkorhonen@0 1789 fileMenu -> addSeparator();
Chris@131 1790 */
Chris@69 1791 fileMenu -> addAction(openAct);
jtkorhonen@0 1792 fileMenu -> addAction(settingsAct);
jtkorhonen@0 1793 fileMenu -> addSeparator();
jtkorhonen@0 1794 fileMenu -> addAction(exitAct);
jtkorhonen@0 1795
jtkorhonen@0 1796 advancedMenu = menuBar()->addMenu(tr("Advanced"));
Chris@131 1797 /*
jtkorhonen@0 1798 advancedMenu -> addAction(hgUpdateToRevAct);
jtkorhonen@0 1799 advancedMenu -> addSeparator();
jtkorhonen@0 1800 advancedMenu -> addAction(hgAnnotateAct);
jtkorhonen@0 1801 advancedMenu -> addSeparator();
jtkorhonen@33 1802 advancedMenu -> addAction(hgRetryMergeAct);
jtkorhonen@0 1803 advancedMenu -> addAction(hgResolveListAct);
jtkorhonen@0 1804 advancedMenu -> addAction(hgResolveMarkAct);
jtkorhonen@11 1805 advancedMenu -> addSeparator();
jtkorhonen@34 1806 advancedMenu -> addAction(hgTagAct);
jtkorhonen@34 1807 advancedMenu -> addSeparator();
Chris@131 1808 */
jtkorhonen@34 1809 advancedMenu -> addAction(hgIgnoreAct);
jtkorhonen@34 1810 advancedMenu -> addSeparator();
jtkorhonen@11 1811 advancedMenu -> addAction(hgServeAct);
jtkorhonen@0 1812
jtkorhonen@0 1813 helpMenu = menuBar()->addMenu(tr("Help"));
jtkorhonen@0 1814 helpMenu->addAction(aboutAct);
Chris@128 1815 //!!! helpMenu->addAction(aboutQtAct);
jtkorhonen@0 1816 }
jtkorhonen@0 1817
jtkorhonen@0 1818 void MainWindow::createToolBars()
jtkorhonen@0 1819 {
jtkorhonen@0 1820 fileToolBar = addToolBar(tr("File"));
jtkorhonen@0 1821 fileToolBar -> setIconSize(QSize(MY_ICON_SIZE, MY_ICON_SIZE));
Chris@69 1822 fileToolBar -> addAction(openAct);
Chris@120 1823 fileToolBar -> addAction(hgRefreshAct);
jtkorhonen@0 1824 fileToolBar -> addSeparator();
Chris@61 1825 // fileToolBar -> addAction(hgChgSetDiffAct);
jtkorhonen@0 1826 fileToolBar -> setMovable(false);
jtkorhonen@0 1827
jtkorhonen@0 1828 repoToolBar = addToolBar(tr(REPOMENU_TITLE));
jtkorhonen@0 1829 repoToolBar -> setIconSize(QSize(MY_ICON_SIZE, MY_ICON_SIZE));
jtkorhonen@0 1830 repoToolBar->addAction(hgIncomingAct);
jtkorhonen@0 1831 repoToolBar->addAction(hgPullAct);
jtkorhonen@0 1832 repoToolBar->addAction(hgPushAct);
jtkorhonen@0 1833 repoToolBar -> setMovable(false);
jtkorhonen@0 1834
jtkorhonen@0 1835 workFolderToolBar = addToolBar(tr(WORKFOLDERMENU_TITLE));
jtkorhonen@0 1836 addToolBar(Qt::LeftToolBarArea, workFolderToolBar);
jtkorhonen@0 1837 workFolderToolBar -> setIconSize(QSize(MY_ICON_SIZE, MY_ICON_SIZE));
Chris@61 1838 // workFolderToolBar->addSeparator();
Chris@95 1839 // workFolderToolBar->addAction(hgFileDiffAct);
Chris@95 1840 workFolderToolBar->addAction(hgFolderDiffAct);
jtkorhonen@0 1841 workFolderToolBar->addSeparator();
jtkorhonen@0 1842 workFolderToolBar->addAction(hgRevertAct);
jtkorhonen@0 1843 workFolderToolBar->addAction(hgUpdateAct);
jtkorhonen@0 1844 workFolderToolBar->addAction(hgCommitAct);
jtkorhonen@0 1845 workFolderToolBar->addAction(hgMergeAct);
jtkorhonen@0 1846 workFolderToolBar->addSeparator();
jtkorhonen@0 1847 workFolderToolBar->addAction(hgAddAct);
jtkorhonen@0 1848 workFolderToolBar->addAction(hgRemoveAct);
jtkorhonen@0 1849 workFolderToolBar -> setMovable(false);
Chris@61 1850
Chris@61 1851 foreach (QToolButton *tb, findChildren<QToolButton *>()) {
Chris@61 1852 tb->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
Chris@61 1853 }
jtkorhonen@0 1854 }
jtkorhonen@0 1855
jtkorhonen@0 1856
jtkorhonen@0 1857 void MainWindow::createStatusBar()
jtkorhonen@0 1858 {
jtkorhonen@0 1859 statusBar()->showMessage(tr("Ready"));
jtkorhonen@0 1860 }
jtkorhonen@0 1861
Chris@69 1862
Chris@69 1863 //!!! review these:
Chris@69 1864
jtkorhonen@0 1865 void MainWindow::readSettings()
jtkorhonen@0 1866 {
jtkorhonen@0 1867 QDir workFolder;
jtkorhonen@0 1868
Chris@61 1869 QSettings settings;
jtkorhonen@0 1870
jtkorhonen@30 1871 remoteRepoPath = settings.value("remoterepopath", "").toString();
jtkorhonen@0 1872 workFolderPath = settings.value("workfolderpath", "").toString();
jtkorhonen@0 1873 if (!workFolder.exists(workFolderPath))
jtkorhonen@0 1874 {
jtkorhonen@0 1875 workFolderPath = "";
jtkorhonen@0 1876 }
jtkorhonen@0 1877
jtkorhonen@0 1878 QPoint pos = settings.value("pos", QPoint(200, 200)).toPoint();
jtkorhonen@0 1879 QSize size = settings.value("size", QSize(400, 400)).toSize();
jtkorhonen@0 1880 firstStart = settings.value("firststart", QVariant(true)).toBool();
jtkorhonen@0 1881
Chris@109 1882 //!!! initialFileTypesBits = (unsigned char) settings.value("viewFileTypes", QVariant(DEFAULT_HG_STAT_BITS)).toInt();
jtkorhonen@0 1883 resize(size);
jtkorhonen@0 1884 move(pos);
jtkorhonen@0 1885 }
jtkorhonen@0 1886
jtkorhonen@17 1887
jtkorhonen@0 1888 void MainWindow::writeSettings()
jtkorhonen@0 1889 {
Chris@61 1890 QSettings settings;
jtkorhonen@0 1891 settings.setValue("pos", pos());
jtkorhonen@0 1892 settings.setValue("size", size());
jtkorhonen@0 1893 settings.setValue("remoterepopath", remoteRepoPath);
jtkorhonen@0 1894 settings.setValue("workfolderpath", workFolderPath);
jtkorhonen@0 1895 settings.setValue("firststart", firstStart);
Chris@98 1896 //!!!settings.setValue("viewFileTypes", hgTabs -> getFileTypesBits());
jtkorhonen@0 1897 }
jtkorhonen@0 1898
jtkorhonen@0 1899
jtkorhonen@0 1900
jtkorhonen@0 1901