annotate mainwindow.cpp @ 86:89f793fbedda

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