Mercurial > hg > easyhg
comparison mainwindow.cpp @ 312:f98c8ece3035
Merge from branch "new-branches-with-status-outside-tabs"
author | Chris Cannam |
---|---|
date | Tue, 01 Mar 2011 14:22:53 +0000 |
parents | b8ed12c2035f 4811eb34e819 |
children | 4b9656471303 |
comparison
equal
deleted
inserted
replaced
310:b8ed12c2035f | 312:f98c8ece3035 |
---|---|
43 #include "confirmcommentdialog.h" | 43 #include "confirmcommentdialog.h" |
44 #include "incomingdialog.h" | 44 #include "incomingdialog.h" |
45 #include "settingsdialog.h" | 45 #include "settingsdialog.h" |
46 #include "moreinformationdialog.h" | 46 #include "moreinformationdialog.h" |
47 #include "version.h" | 47 #include "version.h" |
48 #include "workstatuswidget.h" | |
48 | 49 |
49 | 50 |
50 MainWindow::MainWindow(QString myDirPath) : | 51 MainWindow::MainWindow(QString myDirPath) : |
51 m_myDirPath(myDirPath), | 52 m_myDirPath(myDirPath), |
52 m_fsWatcherGeneralTimer(0), | 53 m_fsWatcherGeneralTimer(0), |
87 m_justMerged = false; | 88 m_justMerged = false; |
88 | 89 |
89 QWidget *central = new QWidget(this); | 90 QWidget *central = new QWidget(this); |
90 setCentralWidget(central); | 91 setCentralWidget(central); |
91 | 92 |
92 m_hgTabs = new HgTabWidget(central, m_remoteRepoPath, m_workFolderPath); | |
93 connectTabsSignals(); | |
94 | |
95 // Instead of setting the tab widget as our central widget | |
96 // directly, put it in a layout, so that we can have some space | |
97 // around it on the Mac where it looks very strange without | |
98 | |
99 QGridLayout *cl = new QGridLayout(central); | 93 QGridLayout *cl = new QGridLayout(central); |
100 cl->addWidget(m_hgTabs, 0, 0); | 94 int row = 0; |
101 | 95 |
102 #ifndef Q_OS_MAC | 96 #ifndef Q_OS_MAC |
103 cl->setMargin(0); | 97 cl->setMargin(0); |
104 #endif | 98 #endif |
99 | |
100 m_workStatus = new WorkStatusWidget(this); | |
101 cl->addWidget(m_workStatus, row++, 0); | |
102 | |
103 m_hgTabs = new HgTabWidget(central, m_workFolderPath); | |
104 connectTabsSignals(); | |
105 | |
106 cl->addWidget(m_hgTabs, row++, 0); | |
105 | 107 |
106 connect(m_hgTabs, SIGNAL(selectionChanged()), | 108 connect(m_hgTabs, SIGNAL(selectionChanged()), |
107 this, SLOT(enableDisableActions())); | 109 this, SLOT(enableDisableActions())); |
108 connect(m_hgTabs, SIGNAL(showAllChanged(bool)), | 110 connect(m_hgTabs, SIGNAL(showAllChanged(bool)), |
109 this, SLOT(showAllChanged(bool))); | 111 this, SLOT(showAllChanged(bool))); |
259 m_remoteRepoPath = path; | 261 m_remoteRepoPath = path; |
260 | 262 |
261 // We have to do this here, because commandCompleted won't be called | 263 // We have to do this here, because commandCompleted won't be called |
262 MultiChoiceDialog::addRecentArgument("local", m_workFolderPath); | 264 MultiChoiceDialog::addRecentArgument("local", m_workFolderPath); |
263 MultiChoiceDialog::addRecentArgument("remote", m_remoteRepoPath); | 265 MultiChoiceDialog::addRecentArgument("remote", m_remoteRepoPath); |
264 m_hgTabs->setWorkFolderAndRepoNames(m_workFolderPath, m_remoteRepoPath); | 266 updateWorkFolderAndRepoNames(); |
265 | 267 |
266 hgQueryBranch(); | 268 hgQueryBranch(); |
267 return; | 269 return; |
268 | 270 |
269 /* The classic method! | 271 /* The classic method! |
425 subsetNote = tr("<p><b>Note:</b> you are committing only the files you have selected, not all of the files that have been changed!"); | 427 subsetNote = tr("<p><b>Note:</b> you are committing only the files you have selected, not all of the files that have been changed!"); |
426 } | 428 } |
427 | 429 |
428 QString cf(tr("Commit files")); | 430 QString cf(tr("Commit files")); |
429 | 431 |
432 QString branchText; | |
433 if (m_currentBranch == "" || m_currentBranch == "default") { | |
434 branchText = tr("the default branch"); | |
435 } else { | |
436 branchText = tr("branch \"%1\"").arg(m_currentBranch); | |
437 } | |
438 | |
430 if (ConfirmCommentDialog::confirmAndGetLongComment | 439 if (ConfirmCommentDialog::confirmAndGetLongComment |
431 (this, | 440 (this, |
432 cf, | 441 cf, |
433 tr("<h3>%1</h3><p>%2%3").arg(cf) | 442 tr("<h3>%1</h3><p>%2%3").arg(cf) |
434 .arg(tr("You are about to commit the following files.")) | 443 .arg(tr("You are about to commit the following files to %1.").arg(branchText)) |
435 .arg(subsetNote), | 444 .arg(subsetNote), |
436 tr("<h3>%1</h3><p>%2%3").arg(cf) | 445 tr("<h3>%1</h3><p>%2%3").arg(cf) |
437 .arg(tr("You are about to commit %n file(s).", "", reportFiles.size())) | 446 .arg(tr("You are about to commit %n file(s) to %1.", "", reportFiles.size()).arg(branchText)) |
438 .arg(subsetNote), | 447 .arg(subsetNote), |
439 reportFiles, | 448 reportFiles, |
440 comment, | 449 comment, |
441 tr("Commit"))) { | 450 tr("Commit"))) { |
442 | 451 |
456 } | 465 } |
457 } | 466 } |
458 | 467 |
459 QString MainWindow::filterTag(QString tag) | 468 QString MainWindow::filterTag(QString tag) |
460 { | 469 { |
461 for(int i = 0; i < tag.size(); i++) | 470 for(int i = 0; i < tag.size(); i++) { |
462 { | 471 if (tag[i].isLower() || tag[i].isUpper() || |
463 if (tag[i].isLower() || tag[i].isUpper() || tag[i].isDigit() || (tag[i] == QChar('.'))) | 472 tag[i].isDigit() || (tag[i] == QChar('.'))) { |
464 { | |
465 //ok | 473 //ok |
466 } | 474 } else { |
467 else | |
468 { | |
469 tag[i] = QChar('_'); | 475 tag[i] = QChar('_'); |
470 } | 476 } |
471 } | 477 } |
472 return tag; | 478 return tag; |
479 } | |
480 | |
481 | |
482 void MainWindow::hgNewBranch() | |
483 { | |
484 QStringList params; | |
485 QString branch; | |
486 | |
487 if (ConfirmCommentDialog::confirmAndGetShortComment | |
488 (this, | |
489 tr("New Branch"), | |
490 tr("Enter new branch name:"), | |
491 branch, | |
492 tr("Start Branch"))) { | |
493 if (!branch.isEmpty()) {//!!! do something better if it is empty | |
494 | |
495 params << "branch" << filterTag(branch); | |
496 m_runner->requestAction(HgAction(ACT_NEW_BRANCH, m_workFolderPath, params)); | |
497 } | |
498 } | |
499 } | |
500 | |
501 | |
502 void MainWindow::hgNoBranch() | |
503 { | |
504 if (m_currentParents.empty()) return; | |
505 | |
506 QString parentBranch = m_currentParents[0]->branch(); | |
507 if (parentBranch == "") parentBranch = "default"; | |
508 | |
509 QStringList params; | |
510 params << "branch" << parentBranch; | |
511 m_runner->requestAction(HgAction(ACT_NEW_BRANCH, m_workFolderPath, params)); | |
473 } | 512 } |
474 | 513 |
475 | 514 |
476 void MainWindow::hgTag(QString id) | 515 void MainWindow::hgTag(QString id) |
477 { | 516 { |
838 } | 877 } |
839 } | 878 } |
840 | 879 |
841 params << "clone" << m_remoteRepoPath << m_workFolderPath; | 880 params << "clone" << m_remoteRepoPath << m_workFolderPath; |
842 | 881 |
843 m_hgTabs->setWorkFolderAndRepoNames(m_workFolderPath, m_remoteRepoPath); | 882 updateWorkFolderAndRepoNames(); |
844 m_hgTabs->updateWorkFolderFileList(""); | 883 m_hgTabs->updateWorkFolderFileList(""); |
845 | 884 |
846 m_runner->requestAction(HgAction(ACT_CLONEFROMREMOTE, m_workFolderPath, params)); | 885 m_runner->requestAction(HgAction(ACT_CLONEFROMREMOTE, m_workFolderPath, params)); |
847 } | 886 } |
848 | 887 |
1809 } else { | 1848 } else { |
1810 m_remoteRepoPath = ""; | 1849 m_remoteRepoPath = ""; |
1811 } | 1850 } |
1812 MultiChoiceDialog::addRecentArgument("local", m_workFolderPath); | 1851 MultiChoiceDialog::addRecentArgument("local", m_workFolderPath); |
1813 MultiChoiceDialog::addRecentArgument("remote", m_remoteRepoPath); | 1852 MultiChoiceDialog::addRecentArgument("remote", m_remoteRepoPath); |
1814 m_hgTabs->setWorkFolderAndRepoNames(m_workFolderPath, m_remoteRepoPath); | 1853 updateWorkFolderAndRepoNames(); |
1815 break; | 1854 break; |
1816 } | 1855 } |
1817 | 1856 |
1818 case ACT_QUERY_BRANCH: | 1857 case ACT_QUERY_BRANCH: |
1819 m_currentBranch = output.trimmed(); | 1858 m_currentBranch = output.trimmed(); |
1934 m_shouldHgStat = true; | 1973 m_shouldHgStat = true; |
1935 break; | 1974 break; |
1936 | 1975 |
1937 case ACT_TAG: | 1976 case ACT_TAG: |
1938 m_needNewLog = true; | 1977 m_needNewLog = true; |
1978 m_shouldHgStat = true; | |
1979 break; | |
1980 | |
1981 case ACT_NEW_BRANCH: | |
1939 m_shouldHgStat = true; | 1982 m_shouldHgStat = true; |
1940 break; | 1983 break; |
1941 | 1984 |
1942 case ACT_UNCOMMITTED_SUMMARY: | 1985 case ACT_UNCOMMITTED_SUMMARY: |
1943 QMessageBox::information(this, tr("Change summary"), | 1986 QMessageBox::information(this, tr("Change summary"), |
2140 connect(m_hgTabs, SIGNAL(diffWorkingFolder()), | 2183 connect(m_hgTabs, SIGNAL(diffWorkingFolder()), |
2141 this, SLOT(hgFolderDiff())); | 2184 this, SLOT(hgFolderDiff())); |
2142 | 2185 |
2143 connect(m_hgTabs, SIGNAL(showSummary()), | 2186 connect(m_hgTabs, SIGNAL(showSummary()), |
2144 this, SLOT(hgShowSummary())); | 2187 this, SLOT(hgShowSummary())); |
2188 | |
2189 connect(m_hgTabs, SIGNAL(newBranch()), | |
2190 this, SLOT(hgNewBranch())); | |
2191 | |
2192 connect(m_hgTabs, SIGNAL(noBranch()), | |
2193 this, SLOT(hgNoBranch())); | |
2145 | 2194 |
2146 connect(m_hgTabs, SIGNAL(updateTo(QString)), | 2195 connect(m_hgTabs, SIGNAL(updateTo(QString)), |
2147 this, SLOT(hgUpdateToRev(QString))); | 2196 this, SLOT(hgUpdateToRev(QString))); |
2148 | 2197 |
2149 connect(m_hgTabs, SIGNAL(diffToCurrent(QString)), | 2198 connect(m_hgTabs, SIGNAL(diffToCurrent(QString)), |
2155 connect(m_hgTabs, SIGNAL(showSummary(Changeset *)), | 2204 connect(m_hgTabs, SIGNAL(showSummary(Changeset *)), |
2156 this, SLOT(hgShowSummaryFor(Changeset *))); | 2205 this, SLOT(hgShowSummaryFor(Changeset *))); |
2157 | 2206 |
2158 connect(m_hgTabs, SIGNAL(mergeFrom(QString)), | 2207 connect(m_hgTabs, SIGNAL(mergeFrom(QString)), |
2159 this, SLOT(hgMergeFrom(QString))); | 2208 this, SLOT(hgMergeFrom(QString))); |
2209 | |
2210 connect(m_hgTabs, SIGNAL(newBranch(QString)), | |
2211 this, SLOT(hgNewBranch())); | |
2160 | 2212 |
2161 connect(m_hgTabs, SIGNAL(tag(QString)), | 2213 connect(m_hgTabs, SIGNAL(tag(QString)), |
2162 this, SLOT(hgTag(QString))); | 2214 this, SLOT(hgTag(QString))); |
2163 } | 2215 } |
2164 | 2216 |
2313 branchText = tr("branch \"%1\"").arg(m_currentBranch); | 2365 branchText = tr("branch \"%1\"").arg(m_currentBranch); |
2314 } | 2366 } |
2315 | 2367 |
2316 if (m_stateUnknown) { | 2368 if (m_stateUnknown) { |
2317 if (m_workFolderPath == "") { | 2369 if (m_workFolderPath == "") { |
2318 m_hgTabs->setState(tr("No repository open")); | 2370 m_workStatus->setState(tr("No repository open")); |
2319 } else { | 2371 } else { |
2320 m_hgTabs->setState(tr("(Examining repository)")); | 2372 m_workStatus->setState(tr("(Examining repository)")); |
2321 } | 2373 } |
2322 } else if (emptyRepo) { | 2374 } else if (emptyRepo) { |
2323 m_hgTabs->setState(tr("Nothing committed to this repository yet")); | 2375 m_workStatus->setState(tr("Nothing committed to this repository yet")); |
2324 } else if (noWorkingCopy) { | 2376 } else if (noWorkingCopy) { |
2325 m_hgTabs->setState(tr("No working copy yet: consider updating")); | 2377 m_workStatus->setState(tr("No working copy yet: consider updating")); |
2326 } else if (canMerge) { | 2378 } else if (canMerge) { |
2327 m_hgTabs->setState(tr("<b>Awaiting merge</b> on %1").arg(branchText)); | 2379 m_workStatus->setState(tr("<b>Awaiting merge</b> on %1").arg(branchText)); |
2328 } else if (!m_hgTabs->getAllUnresolvedFiles().empty()) { | 2380 } else if (!m_hgTabs->getAllUnresolvedFiles().empty()) { |
2329 m_hgTabs->setState(tr("Have unresolved files following merge on %1").arg(branchText)); | 2381 m_workStatus->setState(tr("Have unresolved files following merge on %1").arg(branchText)); |
2330 } else if (haveMerge) { | 2382 } else if (haveMerge) { |
2331 m_hgTabs->setState(tr("Have merged but not yet committed on %1").arg(branchText)); | 2383 m_workStatus->setState(tr("Have merged but not yet committed on %1").arg(branchText)); |
2332 } else if (newBranch) { | 2384 } else if (newBranch) { |
2333 m_hgTabs->setState(tr("On %1. New branch: has not yet been committed").arg(branchText)); | 2385 m_workStatus->setState(tr("On %1. New branch: has not yet been committed").arg(branchText)); |
2334 } else if (canUpdate) { | 2386 } else if (canUpdate) { |
2335 if (m_hgTabs->haveChangesToCommit()) { | 2387 if (m_hgTabs->haveChangesToCommit()) { |
2336 // have uncommitted changes | 2388 // have uncommitted changes |
2337 m_hgTabs->setState(tr("On %1. Not at the head of the branch").arg(branchText)); | 2389 m_workStatus->setState(tr("On %1. Not at the head of the branch").arg(branchText)); |
2338 } else { | 2390 } else { |
2339 // no uncommitted changes | 2391 // no uncommitted changes |
2340 m_hgTabs->setState(tr("On %1. Not at the head of the branch: consider updating").arg(branchText)); | 2392 m_workStatus->setState(tr("On %1. Not at the head of the branch: consider updating").arg(branchText)); |
2341 } | 2393 } |
2342 } else if (m_currentBranchHeads > 1) { | 2394 } else if (m_currentBranchHeads > 1) { |
2343 m_hgTabs->setState(tr("At one of %n heads of %1", "", m_currentBranchHeads).arg(branchText)); | 2395 m_workStatus->setState(tr("At one of %n heads of %1", "", m_currentBranchHeads).arg(branchText)); |
2344 } else { | 2396 } else { |
2345 m_hgTabs->setState(tr("At the head of %1").arg(branchText)); | 2397 m_workStatus->setState(tr("At the head of %1").arg(branchText)); |
2346 } | 2398 } |
2347 } | 2399 } |
2348 | 2400 |
2349 void MainWindow::createActions() | 2401 void MainWindow::createActions() |
2350 { | 2402 { |
2487 Qt::ToolButtonTextUnderIcon : | 2539 Qt::ToolButtonTextUnderIcon : |
2488 Qt::ToolButtonIconOnly); | 2540 Qt::ToolButtonIconOnly); |
2489 } | 2541 } |
2490 } | 2542 } |
2491 | 2543 |
2544 void MainWindow::updateWorkFolderAndRepoNames() | |
2545 { | |
2546 m_hgTabs->setLocalPath(m_workFolderPath); | |
2547 | |
2548 m_workStatus->setLocalPath(m_workFolderPath); | |
2549 m_workStatus->setRemoteURL(m_remoteRepoPath); | |
2550 } | |
2551 | |
2492 void MainWindow::createStatusBar() | 2552 void MainWindow::createStatusBar() |
2493 { | 2553 { |
2494 statusBar()->showMessage(tr("Ready")); | 2554 statusBar()->showMessage(tr("Ready")); |
2495 } | 2555 } |
2496 | |
2497 | |
2498 //!!! review these: | |
2499 | 2556 |
2500 void MainWindow::readSettings() | 2557 void MainWindow::readSettings() |
2501 { | 2558 { |
2502 QDir workFolder; | 2559 QDir workFolder; |
2503 | 2560 |
2512 | 2569 |
2513 QPoint pos = settings.value("pos", QPoint(200, 200)).toPoint(); | 2570 QPoint pos = settings.value("pos", QPoint(200, 200)).toPoint(); |
2514 QSize size = settings.value("size", QSize(400, 400)).toSize(); | 2571 QSize size = settings.value("size", QSize(400, 400)).toSize(); |
2515 m_firstStart = settings.value("firststart", QVariant(true)).toBool(); | 2572 m_firstStart = settings.value("firststart", QVariant(true)).toBool(); |
2516 | 2573 |
2517 //!!! initialFileTypesBits = (unsigned char) settings.value("viewFileTypes", QVariant(DEFAULT_HG_STAT_BITS)).toInt(); | |
2518 resize(size); | 2574 resize(size); |
2519 move(pos); | 2575 move(pos); |
2520 } | 2576 } |
2521 | |
2522 | 2577 |
2523 void MainWindow::writeSettings() | 2578 void MainWindow::writeSettings() |
2524 { | 2579 { |
2525 QSettings settings; | 2580 QSettings settings; |
2526 settings.setValue("pos", pos()); | 2581 settings.setValue("pos", pos()); |
2527 settings.setValue("size", size()); | 2582 settings.setValue("size", size()); |
2528 settings.setValue("remoterepopath", m_remoteRepoPath); | 2583 settings.setValue("remoterepopath", m_remoteRepoPath); |
2529 settings.setValue("workfolderpath", m_workFolderPath); | 2584 settings.setValue("workfolderpath", m_workFolderPath); |
2530 settings.setValue("firststart", m_firstStart); | 2585 settings.setValue("firststart", m_firstStart); |
2531 //!!!settings.setValue("viewFileTypes", m_hgTabs -> getFileTypesBits()); | 2586 } |
2532 } | 2587 |
2533 | 2588 |
2534 | 2589 |
2535 | 2590 |
2536 |