annotate mainwindow.cpp @ 156:4999dbf3a266

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