annotate mainwindow.cpp @ 65:7b1b333acf93

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