annotate mainwindow.cpp @ 53:3c46b2ac45d3

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