annotate mainwindow.cpp @ 63:2340b00561d2

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