comparison mainwindow.cpp @ 69:6d5a5571caec

* Basic working "Open Repository" dialog
author Chris Cannam
date Thu, 18 Nov 2010 15:14:39 +0000
parents 7b1b333acf93
children 121cb1032717
comparison
equal deleted inserted replaced
68:b918e57c7bea 69:6d5a5571caec
29 #include <QToolButton> 29 #include <QToolButton>
30 #include <QSettings> 30 #include <QSettings>
31 31
32 #include "mainwindow.h" 32 #include "mainwindow.h"
33 #include "settingsdialog.h" 33 #include "settingsdialog.h"
34 #include "multichoicedialog.h"
34 #include "startupdialog.h" 35 #include "startupdialog.h"
35 #include "colourset.h" 36 #include "colourset.h"
36 #include "debug.h" 37 #include "debug.h"
37 38
38 39
692 StartupDialog *dlg = new StartupDialog(this); 693 StartupDialog *dlg = new StartupDialog(this);
693 if (dlg->exec()) firstStart = false; 694 if (dlg->exec()) firstStart = false;
694 } 695 }
695 696
696 697
698 void MainWindow::open()
699 {
700 MultiChoiceDialog *d = new MultiChoiceDialog
701 (tr("Open Repository"),
702 tr("What would you like to open?"),
703 this);
704
705 d->addChoice("remote",
706 tr("<qt><center><img src=\":images/browser-64.png\"><br>Remote repository</center></qt>"),
707 tr("Open an existing remote repository, by cloning a Mercurial repository URL into a local folder."),
708 MultiChoiceDialog::UrlArg);
709
710 d->addChoice("local",
711 tr("<qt><center><img src=\":images/hglogo-64.png\"><br>Local repository</center></qt>"),
712 tr("Open an existing local Mercurial repository."),
713 MultiChoiceDialog::DirectoryArg);
714
715 d->addChoice("init",
716 tr("<qt><center><img src=\":images/hdd_unmount-64.png\"><br>File folder</center></qt>"),
717 tr("Open a local folder, by creating a Mercurial repository in it."),
718 MultiChoiceDialog::DirectoryArg);
719
720 d->setCurrentChoice("local");
721
722 if (d->exec() == QDialog::Accepted) {
723
724 QString choice = d->getCurrentChoice();
725 QString arg = d->getArgument().trimmed();
726
727 if (choice == "local") {
728 workFolderPath = arg;
729 } else {
730 //!!!
731 }
732
733 hgExp->clearLists();
734 enableDisableActions();
735 hgStat();
736 }
737
738 delete d;
739 }
740
697 void MainWindow::settings() 741 void MainWindow::settings()
698 { 742 {
743 /*!!!
699 SettingsDialog *settingsDlg = new SettingsDialog(this); 744 SettingsDialog *settingsDlg = new SettingsDialog(this);
700 settingsDlg->setModal(true); 745 settingsDlg->setModal(true);
701 settingsDlg->exec(); 746 settingsDlg->exec();
702 hgExp -> clearLists(); 747 hgExp -> clearLists();
703 enableDisableActions(); 748 enableDisableActions();
704 hgStat(); 749 hgStat();
750 */
705 } 751 }
706 752
707 #define STDOUT_NEEDS_BIG_WINDOW 512 753 #define STDOUT_NEEDS_BIG_WINDOW 512
708 #define SMALL_WND_W 500 754 #define SMALL_WND_W 500
709 #define SMALL_WND_H 300 755 #define SMALL_WND_H 300
949 { 995 {
950 //Successful running. 996 //Successful running.
951 switch(runningAction) 997 switch(runningAction)
952 { 998 {
953 case ACT_STAT: 999 case ACT_STAT:
954 { 1000 MultiChoiceDialog::addRecentArgument("local", workFolderPath);
955 hgExp -> updateWorkFolderFileList(runner -> getStdOut()); 1001 hgExp -> updateWorkFolderFileList(runner -> getStdOut());
956 }
957 break; 1002 break;
958 1003
959 case ACT_INCOMING: 1004 case ACT_INCOMING:
960 case ACT_ANNOTATE: 1005 case ACT_ANNOTATE:
961 case ACT_RESOLVE_LIST: 1006 case ACT_RESOLVE_LIST:
973 QMessageBox::information(this, "Push", runner -> getStdOut()); 1018 QMessageBox::information(this, "Push", runner -> getStdOut());
974 shouldHgStat = true; 1019 shouldHgStat = true;
975 break; 1020 break;
976 1021
977 case ACT_INIT: 1022 case ACT_INIT:
1023 MultiChoiceDialog::addRecentArgument("init", workFolderPath);
1024 MultiChoiceDialog::addRecentArgument("local", workFolderPath);
978 enableDisableActions(); 1025 enableDisableActions();
979 shouldHgStat = true; 1026 shouldHgStat = true;
980 break; 1027 break;
981 1028
982 case ACT_CLONEFROMREMOTE: 1029 case ACT_CLONEFROMREMOTE:
1030 MultiChoiceDialog::addRecentArgument("local", workFolderPath);
1031 MultiChoiceDialog::addRecentArgument("remote", remoteRepoPath);
983 QMessageBox::information(this, "Clone", runner -> getStdOut()); 1032 QMessageBox::information(this, "Clone", runner -> getStdOut());
984 enableDisableActions(); 1033 enableDisableActions();
985 shouldHgStat = true; 1034 shouldHgStat = true;
986 break; 1035 break;
987 1036
1106 connect(hgRetryMergeAct, SIGNAL(triggered()), this, SLOT(hgRetryMerge())); 1155 connect(hgRetryMergeAct, SIGNAL(triggered()), this, SLOT(hgRetryMerge()));
1107 connect(hgTagAct, SIGNAL(triggered()), this, SLOT(hgTag())); 1156 connect(hgTagAct, SIGNAL(triggered()), this, SLOT(hgTag()));
1108 connect(hgIgnoreAct, SIGNAL(triggered()), this, SLOT(hgIgnore())); 1157 connect(hgIgnoreAct, SIGNAL(triggered()), this, SLOT(hgIgnore()));
1109 1158
1110 connect(settingsAct, SIGNAL(triggered()), this, SLOT(settings())); 1159 connect(settingsAct, SIGNAL(triggered()), this, SLOT(settings()));
1160 connect(openAct, SIGNAL(triggered()), this, SLOT(open()));
1111 1161
1112 connect(hgInitAct, SIGNAL(triggered()), this, SLOT(hgInit())); 1162 connect(hgInitAct, SIGNAL(triggered()), this, SLOT(hgInit()));
1113 connect(hgCloneFromRemoteAct, SIGNAL(triggered()), this, SLOT(hgCloneFromRemote())); 1163 connect(hgCloneFromRemoteAct, SIGNAL(triggered()), this, SLOT(hgCloneFromRemote()));
1114 connect(hgIncomingAct, SIGNAL(triggered()), this, SLOT(hgIncoming())); 1164 connect(hgIncomingAct, SIGNAL(triggered()), this, SLOT(hgIncoming()));
1115 connect(hgPullAct, SIGNAL(triggered()), this, SLOT(hgPull())); 1165 connect(hgPullAct, SIGNAL(triggered()), this, SLOT(hgPull()));
1308 hgInitAct->setStatusTip(tr("Create an empty local repository in selected folder")); 1358 hgInitAct->setStatusTip(tr("Create an empty local repository in selected folder"));
1309 1359
1310 hgCloneFromRemoteAct = new QAction(tr("Clone from remote"), this); 1360 hgCloneFromRemoteAct = new QAction(tr("Clone from remote"), this);
1311 hgCloneFromRemoteAct->setStatusTip(tr("Clone from remote repository into local repository in selected folder")); 1361 hgCloneFromRemoteAct->setStatusTip(tr("Clone from remote repository into local repository in selected folder"));
1312 1362
1363 openAct = new QAction(QIcon(":/images/fileopen.png"), tr("Open..."), this);
1364 openAct -> setStatusTip(tr("Open repository"));
1365 openAct -> setIconVisibleInMenu(true);
1366
1313 settingsAct = new QAction(QIcon(":/images/settings.png"), tr("Settings..."), this); 1367 settingsAct = new QAction(QIcon(":/images/settings.png"), tr("Settings..."), this);
1314 settingsAct -> setStatusTip(tr("View and change application settings")); 1368 settingsAct -> setStatusTip(tr("View and change application settings"));
1315 settingsAct -> setIconVisibleInMenu(true); 1369 settingsAct -> setIconVisibleInMenu(true);
1316 1370
1317 exitAct = new QAction(QIcon(":/images/exit.png"), tr("Exit"), this); 1371 exitAct = new QAction(QIcon(":/images/exit.png"), tr("Exit"), this);
1397 { 1451 {
1398 fileMenu = menuBar()->addMenu(tr("File")); 1452 fileMenu = menuBar()->addMenu(tr("File"));
1399 fileMenu -> addAction(hgInitAct); 1453 fileMenu -> addAction(hgInitAct);
1400 fileMenu -> addAction(hgCloneFromRemoteAct); 1454 fileMenu -> addAction(hgCloneFromRemoteAct);
1401 fileMenu -> addSeparator(); 1455 fileMenu -> addSeparator();
1456 fileMenu -> addAction(openAct);
1402 fileMenu -> addAction(settingsAct); 1457 fileMenu -> addAction(settingsAct);
1403 fileMenu -> addSeparator(); 1458 fileMenu -> addSeparator();
1404 fileMenu -> addAction(exitAct); 1459 fileMenu -> addAction(exitAct);
1405 1460
1406 advancedMenu = menuBar()->addMenu(tr("Advanced")); 1461 advancedMenu = menuBar()->addMenu(tr("Advanced"));
1425 1480
1426 void MainWindow::createToolBars() 1481 void MainWindow::createToolBars()
1427 { 1482 {
1428 fileToolBar = addToolBar(tr("File")); 1483 fileToolBar = addToolBar(tr("File"));
1429 fileToolBar -> setIconSize(QSize(MY_ICON_SIZE, MY_ICON_SIZE)); 1484 fileToolBar -> setIconSize(QSize(MY_ICON_SIZE, MY_ICON_SIZE));
1430 fileToolBar -> addAction(settingsAct); 1485 fileToolBar -> addAction(openAct);
1431 fileToolBar -> addAction(hgStatAct); 1486 fileToolBar -> addAction(hgStatAct);
1432 fileToolBar -> addSeparator(); 1487 fileToolBar -> addSeparator();
1433 // fileToolBar -> addAction(hgChgSetDiffAct); 1488 // fileToolBar -> addAction(hgChgSetDiffAct);
1434 fileToolBar -> setMovable(false); 1489 fileToolBar -> setMovable(false);
1435 1490
1465 void MainWindow::createStatusBar() 1520 void MainWindow::createStatusBar()
1466 { 1521 {
1467 statusBar()->showMessage(tr("Ready")); 1522 statusBar()->showMessage(tr("Ready"));
1468 } 1523 }
1469 1524
1525
1526 //!!! review these:
1527
1470 void MainWindow::readSettings() 1528 void MainWindow::readSettings()
1471 { 1529 {
1472 QDir workFolder; 1530 QDir workFolder;
1473 1531
1474 QSettings settings; 1532 QSettings settings;