Mercurial > hg > easyhg
comparison mainwindow.cpp @ 287:3fbafca196e4 status_outside_tabs
Move work-folder state area outside tabs widget
author | Chris Cannam |
---|---|
date | Mon, 21 Feb 2011 11:07:21 +0000 |
parents | a68801b31ceb |
children | d40294e164da |
comparison
equal
deleted
inserted
replaced
286:3b0ff2b96c53 | 287:3fbafca196e4 |
---|---|
42 #include "logparser.h" | 42 #include "logparser.h" |
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 "version.h" | 46 #include "version.h" |
47 #include "workstatuswidget.h" | |
47 | 48 |
48 | 49 |
49 MainWindow::MainWindow(QString myDirPath) : | 50 MainWindow::MainWindow(QString myDirPath) : |
50 m_myDirPath(myDirPath), | 51 m_myDirPath(myDirPath), |
51 m_fsWatcherGeneralTimer(0), | 52 m_fsWatcherGeneralTimer(0), |
86 m_justMerged = false; | 87 m_justMerged = false; |
87 | 88 |
88 QWidget *central = new QWidget(this); | 89 QWidget *central = new QWidget(this); |
89 setCentralWidget(central); | 90 setCentralWidget(central); |
90 | 91 |
91 m_hgTabs = new HgTabWidget(central, m_remoteRepoPath, m_workFolderPath); | |
92 connectTabsSignals(); | |
93 | |
94 // Instead of setting the tab widget as our central widget | |
95 // directly, put it in a layout, so that we can have some space | |
96 // around it on the Mac where it looks very strange without | |
97 | |
98 QGridLayout *cl = new QGridLayout(central); | 92 QGridLayout *cl = new QGridLayout(central); |
99 cl->addWidget(m_hgTabs, 0, 0); | 93 int row = 0; |
100 | 94 |
101 #ifndef Q_OS_MAC | 95 #ifndef Q_OS_MAC |
102 cl->setMargin(0); | 96 cl->setMargin(0); |
103 #endif | 97 #endif |
98 | |
99 m_workStatus = new WorkStatusWidget(this); | |
100 cl->addWidget(m_workStatus, row++, 0); | |
101 | |
102 m_hgTabs = new HgTabWidget(central, m_workFolderPath); | |
103 connectTabsSignals(); | |
104 | |
105 cl->addWidget(m_hgTabs, row++, 0); | |
104 | 106 |
105 connect(m_hgTabs, SIGNAL(selectionChanged()), | 107 connect(m_hgTabs, SIGNAL(selectionChanged()), |
106 this, SLOT(enableDisableActions())); | 108 this, SLOT(enableDisableActions())); |
107 connect(m_hgTabs, SIGNAL(showAllChanged(bool)), | 109 connect(m_hgTabs, SIGNAL(showAllChanged(bool)), |
108 this, SLOT(showAllChanged(bool))); | 110 this, SLOT(showAllChanged(bool))); |
258 m_remoteRepoPath = path; | 260 m_remoteRepoPath = path; |
259 | 261 |
260 // We have to do this here, because commandCompleted won't be called | 262 // We have to do this here, because commandCompleted won't be called |
261 MultiChoiceDialog::addRecentArgument("local", m_workFolderPath); | 263 MultiChoiceDialog::addRecentArgument("local", m_workFolderPath); |
262 MultiChoiceDialog::addRecentArgument("remote", m_remoteRepoPath); | 264 MultiChoiceDialog::addRecentArgument("remote", m_remoteRepoPath); |
263 m_hgTabs->setWorkFolderAndRepoNames(m_workFolderPath, m_remoteRepoPath); | 265 updateWorkFolderAndRepoNames(); |
264 | 266 |
265 hgQueryBranch(); | 267 hgQueryBranch(); |
266 return; | 268 return; |
267 | 269 |
268 /* The classic method! | 270 /* The classic method! |
813 } | 815 } |
814 } | 816 } |
815 | 817 |
816 params << "clone" << m_remoteRepoPath << m_workFolderPath; | 818 params << "clone" << m_remoteRepoPath << m_workFolderPath; |
817 | 819 |
818 m_hgTabs->setWorkFolderAndRepoNames(m_workFolderPath, m_remoteRepoPath); | 820 updateWorkFolderAndRepoNames(); |
819 m_hgTabs->updateWorkFolderFileList(""); | 821 m_hgTabs->updateWorkFolderFileList(""); |
820 | 822 |
821 m_runner->requestAction(HgAction(ACT_CLONEFROMREMOTE, m_workFolderPath, params)); | 823 m_runner->requestAction(HgAction(ACT_CLONEFROMREMOTE, m_workFolderPath, params)); |
822 } | 824 } |
823 | 825 |
1774 } else { | 1776 } else { |
1775 m_remoteRepoPath = ""; | 1777 m_remoteRepoPath = ""; |
1776 } | 1778 } |
1777 MultiChoiceDialog::addRecentArgument("local", m_workFolderPath); | 1779 MultiChoiceDialog::addRecentArgument("local", m_workFolderPath); |
1778 MultiChoiceDialog::addRecentArgument("remote", m_remoteRepoPath); | 1780 MultiChoiceDialog::addRecentArgument("remote", m_remoteRepoPath); |
1779 m_hgTabs->setWorkFolderAndRepoNames(m_workFolderPath, m_remoteRepoPath); | 1781 updateWorkFolderAndRepoNames(); |
1780 break; | 1782 break; |
1781 } | 1783 } |
1782 | 1784 |
1783 case ACT_QUERY_BRANCH: | 1785 case ACT_QUERY_BRANCH: |
1784 m_currentBranch = output.trimmed(); | 1786 m_currentBranch = output.trimmed(); |
2237 branchText = tr("branch \"%1\"").arg(m_currentBranch); | 2239 branchText = tr("branch \"%1\"").arg(m_currentBranch); |
2238 } | 2240 } |
2239 | 2241 |
2240 if (m_stateUnknown) { | 2242 if (m_stateUnknown) { |
2241 if (m_workFolderPath == "") { | 2243 if (m_workFolderPath == "") { |
2242 m_hgTabs->setState(tr("No repository open")); | 2244 m_workStatus->setState(tr("No repository open")); |
2243 } else { | 2245 } else { |
2244 m_hgTabs->setState(tr("(Examining repository)")); | 2246 m_workStatus->setState(tr("(Examining repository)")); |
2245 } | 2247 } |
2246 } else if (emptyRepo) { | 2248 } else if (emptyRepo) { |
2247 m_hgTabs->setState(tr("Nothing committed to this repository yet")); | 2249 m_workStatus->setState(tr("Nothing committed to this repository yet")); |
2248 } else if (noWorkingCopy) { | 2250 } else if (noWorkingCopy) { |
2249 m_hgTabs->setState(tr("No working copy yet: consider updating")); | 2251 m_workStatus->setState(tr("No working copy yet: consider updating")); |
2250 } else if (canMerge) { | 2252 } else if (canMerge) { |
2251 m_hgTabs->setState(tr("<b>Awaiting merge</b> on %1").arg(branchText)); | 2253 m_workStatus->setState(tr("<b>Awaiting merge</b> on %1").arg(branchText)); |
2252 } else if (!m_hgTabs->getAllUnresolvedFiles().empty()) { | 2254 } else if (!m_hgTabs->getAllUnresolvedFiles().empty()) { |
2253 m_hgTabs->setState(tr("Have unresolved files following merge on %1").arg(branchText)); | 2255 m_workStatus->setState(tr("Have unresolved files following merge on %1").arg(branchText)); |
2254 } else if (haveMerge) { | 2256 } else if (haveMerge) { |
2255 m_hgTabs->setState(tr("Have merged but not yet committed on %1").arg(branchText)); | 2257 m_workStatus->setState(tr("Have merged but not yet committed on %1").arg(branchText)); |
2256 } else if (newBranch) { | 2258 } else if (newBranch) { |
2257 m_hgTabs->setState(tr("On %1. New branch: has not yet been committed").arg(branchText)); | 2259 m_workStatus->setState(tr("On %1. New branch: has not yet been committed").arg(branchText)); |
2258 } else if (canUpdate) { | 2260 } else if (canUpdate) { |
2259 if (m_hgTabs->haveChangesToCommit()) { | 2261 if (m_hgTabs->haveChangesToCommit()) { |
2260 // have uncommitted changes | 2262 // have uncommitted changes |
2261 m_hgTabs->setState(tr("On %1. Not at the head of the branch").arg(branchText)); | 2263 m_workStatus->setState(tr("On %1. Not at the head of the branch").arg(branchText)); |
2262 } else { | 2264 } else { |
2263 // no uncommitted changes | 2265 // no uncommitted changes |
2264 m_hgTabs->setState(tr("On %1. Not at the head of the branch: consider updating").arg(branchText)); | 2266 m_workStatus->setState(tr("On %1. Not at the head of the branch: consider updating").arg(branchText)); |
2265 } | 2267 } |
2266 } else if (m_currentBranchHeads > 1) { | 2268 } else if (m_currentBranchHeads > 1) { |
2267 m_hgTabs->setState(tr("At one of %n heads of %1", "", m_currentBranchHeads).arg(branchText)); | 2269 m_workStatus->setState(tr("At one of %n heads of %1", "", m_currentBranchHeads).arg(branchText)); |
2268 } else { | 2270 } else { |
2269 m_hgTabs->setState(tr("At the head of %1").arg(branchText)); | 2271 m_workStatus->setState(tr("At the head of %1").arg(branchText)); |
2270 } | 2272 } |
2271 } | 2273 } |
2272 | 2274 |
2273 void MainWindow::createActions() | 2275 void MainWindow::createActions() |
2274 { | 2276 { |
2411 Qt::ToolButtonTextUnderIcon : | 2413 Qt::ToolButtonTextUnderIcon : |
2412 Qt::ToolButtonIconOnly); | 2414 Qt::ToolButtonIconOnly); |
2413 } | 2415 } |
2414 } | 2416 } |
2415 | 2417 |
2418 void MainWindow::updateWorkFolderAndRepoNames() | |
2419 { | |
2420 m_hgTabs->setLocalPath(m_workFolderPath); | |
2421 | |
2422 m_workStatus->setLocalPath(m_workFolderPath); | |
2423 m_workStatus->setRemoteURL(m_remoteRepoPath); | |
2424 } | |
2425 | |
2416 void MainWindow::createStatusBar() | 2426 void MainWindow::createStatusBar() |
2417 { | 2427 { |
2418 statusBar()->showMessage(tr("Ready")); | 2428 statusBar()->showMessage(tr("Ready")); |
2419 } | 2429 } |
2420 | |
2421 | |
2422 //!!! review these: | |
2423 | 2430 |
2424 void MainWindow::readSettings() | 2431 void MainWindow::readSettings() |
2425 { | 2432 { |
2426 QDir workFolder; | 2433 QDir workFolder; |
2427 | 2434 |
2436 | 2443 |
2437 QPoint pos = settings.value("pos", QPoint(200, 200)).toPoint(); | 2444 QPoint pos = settings.value("pos", QPoint(200, 200)).toPoint(); |
2438 QSize size = settings.value("size", QSize(400, 400)).toSize(); | 2445 QSize size = settings.value("size", QSize(400, 400)).toSize(); |
2439 m_firstStart = settings.value("firststart", QVariant(true)).toBool(); | 2446 m_firstStart = settings.value("firststart", QVariant(true)).toBool(); |
2440 | 2447 |
2441 //!!! initialFileTypesBits = (unsigned char) settings.value("viewFileTypes", QVariant(DEFAULT_HG_STAT_BITS)).toInt(); | |
2442 resize(size); | 2448 resize(size); |
2443 move(pos); | 2449 move(pos); |
2444 } | 2450 } |
2445 | |
2446 | 2451 |
2447 void MainWindow::writeSettings() | 2452 void MainWindow::writeSettings() |
2448 { | 2453 { |
2449 QSettings settings; | 2454 QSettings settings; |
2450 settings.setValue("pos", pos()); | 2455 settings.setValue("pos", pos()); |
2451 settings.setValue("size", size()); | 2456 settings.setValue("size", size()); |
2452 settings.setValue("remoterepopath", m_remoteRepoPath); | 2457 settings.setValue("remoterepopath", m_remoteRepoPath); |
2453 settings.setValue("workfolderpath", m_workFolderPath); | 2458 settings.setValue("workfolderpath", m_workFolderPath); |
2454 settings.setValue("firststart", m_firstStart); | 2459 settings.setValue("firststart", m_firstStart); |
2455 //!!!settings.setValue("viewFileTypes", m_hgTabs -> getFileTypesBits()); | 2460 } |
2456 } | 2461 |
2457 | 2462 |
2458 | 2463 |
2459 | 2464 |
2460 |