annotate mainwindow.cpp @ 84:8a4e26dc3182

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