annotate mainwindow.cpp @ 36:5986d0758069

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