Mercurial > hg > easyhg
comparison mainwindow.cpp @ 363:f89e50d748ed feature_93
Enable Push button whenever the repo is non-empty, even when there is no remote location -- ask for remote location when it is pressed.
Also change "Change Remote..." to "Set Remote..." to be consistent with this new usage
author | Chris Cannam |
---|---|
date | Thu, 17 Mar 2011 17:48:18 +0000 |
parents | 73fb5ef55744 |
children | 1482f5b9f9dc |
comparison
equal
deleted
inserted
replaced
362:73fb5ef55744 | 363:f89e50d748ed |
---|---|
1003 } | 1003 } |
1004 } | 1004 } |
1005 | 1005 |
1006 void MainWindow::hgPush() | 1006 void MainWindow::hgPush() |
1007 { | 1007 { |
1008 if (m_remoteRepoPath.isEmpty()) { | |
1009 changeRemoteRepo(true); | |
1010 if (m_remoteRepoPath.isEmpty()) return; | |
1011 } | |
1012 | |
1008 QString uncommittedNote; | 1013 QString uncommittedNote; |
1009 if (m_hgTabs->canCommit()) { | 1014 if (m_hgTabs->canCommit()) { |
1010 uncommittedNote = tr("<p><b>Note:</b> You have uncommitted changes. If you want to push these changes to the remote repository, you need to commit them first."); | 1015 uncommittedNote = tr("<p><b>Note:</b> You have uncommitted changes. If you want to push these changes to the remote repository, you need to commit them first."); |
1011 } | 1016 } |
1012 | 1017 |
1185 open(local); | 1190 open(local); |
1186 } | 1191 } |
1187 | 1192 |
1188 void MainWindow::changeRemoteRepo() | 1193 void MainWindow::changeRemoteRepo() |
1189 { | 1194 { |
1195 changeRemoteRepo(false); | |
1196 } | |
1197 | |
1198 void MainWindow::changeRemoteRepo(bool initial) | |
1199 { | |
1190 // This will involve rewriting the local .hgrc | 1200 // This will involve rewriting the local .hgrc |
1191 | 1201 |
1192 QDir hgDir(m_workFolderPath + "/.hg"); | 1202 QDir hgDir(m_workFolderPath + "/.hg"); |
1193 if (!hgDir.exists()) { | 1203 if (!hgDir.exists()) { |
1194 //!!! visible error! | 1204 //!!! visible error! |
1200 //!!! visible error! | 1210 //!!! visible error! |
1201 return; | 1211 return; |
1202 } | 1212 } |
1203 | 1213 |
1204 MultiChoiceDialog *d = new MultiChoiceDialog | 1214 MultiChoiceDialog *d = new MultiChoiceDialog |
1205 (tr("Change Remote Location"), | 1215 (tr("Set Remote Location"), |
1206 tr("<qt><big>Change the remote location</big></qt>"), | 1216 tr("<qt><big>Set the remote location</big></qt>"), |
1207 this); | 1217 this); |
1218 | |
1219 QString explanation; | |
1220 if (initial) { | |
1221 explanation = tr("Provide a URL to use for push and pull actions from the current local repository.<br>This will be the default for subsequent pushes and pulls.<br>You can change it using “Set Remote Location” on the File menu."); | |
1222 } else { | |
1223 explanation = tr("Provide a new URL to use for push and pull actions from the current local repository."); | |
1224 } | |
1208 | 1225 |
1209 d->addChoice("remote", | 1226 d->addChoice("remote", |
1210 tr("<qt><center><img src=\":images/browser-64.png\"><br>Remote repository</center></qt>"), | 1227 tr("<qt><center><img src=\":images/browser-64.png\"><br>Remote repository</center></qt>"), |
1211 tr("Provide a new URL to use for push and pull actions from the current local repository."), | 1228 explanation, |
1212 MultiChoiceDialog::UrlArg); | 1229 MultiChoiceDialog::UrlArg); |
1213 | 1230 |
1214 if (d->exec() == QDialog::Accepted) { | 1231 if (d->exec() == QDialog::Accepted) { |
1215 | 1232 |
1216 // New block to ensure QSettings is deleted before | 1233 // New block to ensure QSettings is deleted before |
2433 if (!localRepoDir.exists(m_workFolderPath + "/.hg")) { | 2450 if (!localRepoDir.exists(m_workFolderPath + "/.hg")) { |
2434 m_localRepoActionsEnabled = false; | 2451 m_localRepoActionsEnabled = false; |
2435 localRepoExist = false; | 2452 localRepoExist = false; |
2436 } | 2453 } |
2437 | 2454 |
2438 m_hgIncomingAct -> setEnabled(m_remoteRepoActionsEnabled && m_remoteRepoActionsEnabled); | |
2439 m_hgPullAct -> setEnabled(m_remoteRepoActionsEnabled && m_remoteRepoActionsEnabled); | |
2440 m_hgPushAct -> setEnabled(m_remoteRepoActionsEnabled && m_remoteRepoActionsEnabled); | |
2441 | |
2442 bool haveDiff = false; | 2455 bool haveDiff = false; |
2443 QSettings settings; | 2456 QSettings settings; |
2444 settings.beginGroup("Locations"); | 2457 settings.beginGroup("Locations"); |
2445 if (settings.value("extdiffbinary", "").toString() != "") { | 2458 if (settings.value("extdiffbinary", "").toString() != "") { |
2446 haveDiff = true; | 2459 haveDiff = true; |
2527 } else { | 2540 } else { |
2528 haveMerge = true; | 2541 haveMerge = true; |
2529 m_justMerged = true; | 2542 m_justMerged = true; |
2530 } | 2543 } |
2531 | 2544 |
2545 m_hgIncomingAct->setEnabled(m_remoteRepoActionsEnabled); | |
2546 m_hgPullAct->setEnabled(m_remoteRepoActionsEnabled); | |
2547 // permit push even if no remote yet; we'll ask for one | |
2548 m_hgPushAct->setEnabled(m_localRepoActionsEnabled && !emptyRepo); | |
2549 | |
2532 m_hgMergeAct->setEnabled(m_localRepoActionsEnabled && | 2550 m_hgMergeAct->setEnabled(m_localRepoActionsEnabled && |
2533 (canMerge || m_hgTabs->canResolve())); | 2551 (canMerge || m_hgTabs->canResolve())); |
2534 m_hgUpdateAct->setEnabled(m_localRepoActionsEnabled && | 2552 m_hgUpdateAct->setEnabled(m_localRepoActionsEnabled && |
2535 (canUpdate && !m_hgTabs->haveChangesToCommit())); | 2553 (canUpdate && !m_hgTabs->haveChangesToCommit())); |
2536 | 2554 |
2598 { | 2616 { |
2599 //File actions | 2617 //File actions |
2600 m_openAct = new QAction(QIcon(":/images/fileopen.png"), tr("Open..."), this); | 2618 m_openAct = new QAction(QIcon(":/images/fileopen.png"), tr("Open..."), this); |
2601 m_openAct -> setStatusTip(tr("Open an existing repository or working folder")); | 2619 m_openAct -> setStatusTip(tr("Open an existing repository or working folder")); |
2602 | 2620 |
2603 m_changeRemoteRepoAct = new QAction(tr("Change Remote Location..."), this); | 2621 m_changeRemoteRepoAct = new QAction(tr("Set Remote Location..."), this); |
2604 m_changeRemoteRepoAct->setStatusTip(tr("Change the default remote repository for pull and push actions")); | 2622 m_changeRemoteRepoAct->setStatusTip(tr("Set or change the default remote repository for pull and push actions")); |
2605 | 2623 |
2606 m_settingsAct = new QAction(QIcon(":/images/settings.png"), tr("Settings..."), this); | 2624 m_settingsAct = new QAction(QIcon(":/images/settings.png"), tr("Settings..."), this); |
2607 m_settingsAct -> setStatusTip(tr("View and change application settings")); | 2625 m_settingsAct -> setStatusTip(tr("View and change application settings")); |
2608 | 2626 |
2609 #ifdef Q_OS_WIN32 | 2627 #ifdef Q_OS_WIN32 |