comparison mainwindow.cpp @ 182:bf366e0b9050

* Fix "Serve by HTTP"; stub out "Change Remote Location"
author Chris Cannam
date Fri, 17 Dec 2010 10:01:02 +0000
parents a51980a00dac
children 01580704de3e
comparison
equal deleted inserted replaced
181:731aef59d5f4 182:bf366e0b9050
777 params << "push" << "--new-branch" << remoteRepoPath; 777 params << "push" << "--new-branch" << remoteRepoPath;
778 runner->requestAction(HgAction(ACT_PUSH, workFolderPath, params)); 778 runner->requestAction(HgAction(ACT_PUSH, workFolderPath, params));
779 } 779 }
780 } 780 }
781 781
782 QString MainWindow::listAllUpIpV4Addresses() 782 QStringList MainWindow::listAllUpIpV4Addresses()
783 { 783 {
784 QString ret; 784 QStringList ret;
785 QList<QNetworkInterface> ifaces = QNetworkInterface::allInterfaces(); 785 QList<QNetworkInterface> ifaces = QNetworkInterface::allInterfaces();
786 786
787 for (int i = 0; i < ifaces.count(); i++) 787 for (int i = 0; i < ifaces.count(); i++) {
788 {
789 QNetworkInterface iface = ifaces.at(i); 788 QNetworkInterface iface = ifaces.at(i);
790 789 if (iface.flags().testFlag(QNetworkInterface::IsUp)
791 if (iface.flags().testFlag(QNetworkInterface::IsUp) && !iface.flags().testFlag(QNetworkInterface::IsLoopBack)) 790 && !iface.flags().testFlag(QNetworkInterface::IsLoopBack)) {
792 { 791 for (int j=0; j<iface.addressEntries().count(); j++) {
793 for (int j=0; j<iface.addressEntries().count(); j++)
794 {
795 QHostAddress tmp = iface.addressEntries().at(j).ip(); 792 QHostAddress tmp = iface.addressEntries().at(j).ip();
796 if (QAbstractSocket::IPv4Protocol == tmp.protocol()) 793 if (QAbstractSocket::IPv4Protocol == tmp.protocol()) {
797 { 794 ret.push_back(tmp.toString());
798 if (!ret.isEmpty())
799 {
800 ret += " ";
801 }
802 ret += tmp.toString();
803 } 795 }
804 } 796 }
805 } 797 }
806 } 798 }
807 return ret; 799 return ret;
825 void MainWindow::hgServe() 817 void MainWindow::hgServe()
826 { 818 {
827 QStringList params; 819 QStringList params;
828 QString msg; 820 QString msg;
829 821
830 QString addrs = listAllUpIpV4Addresses(); 822 QStringList addrs = listAllUpIpV4Addresses();
831 QTextStream(&msg) << "Server running on address(es) (" << addrs << "), port 8000"; 823
824 if (addrs.empty()) {
825 QMessageBox::critical
826 (this, tr("Serve"), tr("Failed to identify an active IPv4 address"));
827 return;
828 }
829
830 //!!! should find available port as well
831
832 QTextStream ts(&msg);
833 ts << QString("<qt><p>%1</p>")
834 .arg(tr("Running temporary server at %n address(es):", "", addrs.size()));
835 foreach (QString addr, addrs) {
836 ts << QString("<pre>&nbsp;&nbsp;http://%1:8000</pre>").arg(xmlEncode(addr));
837 }
838 ts << tr("<p>Press Close to stop the server and return.</p>");
839 ts.flush();
840
832 params << "serve"; 841 params << "serve";
833 842
834 runner->requestAction(HgAction(ACT_SERVE, workFolderPath, params)); 843 runner->requestAction(HgAction(ACT_SERVE, workFolderPath, params));
835 844
836 QMessageBox::information(this, "Serve", msg, QMessageBox::Close); 845 QMessageBox::information(this, tr("Serve"), msg, QMessageBox::Close);
837 //!!! runner -> killCurrentCommand(); 846
847 runner->killCurrentActions();
838 } 848 }
839 849
840 void MainWindow::startupDialog() 850 void MainWindow::startupDialog()
841 { 851 {
842 StartupDialog *dlg = new StartupDialog(this); 852 StartupDialog *dlg = new StartupDialog(this);
899 done = true; 909 done = true;
900 } 910 }
901 911
902 delete d; 912 delete d;
903 } 913 }
914 }
915
916 void MainWindow::changeRemoteRepo()
917 {
918 //!!! so we want a "multi-choice" thingy but with remote only? and then we rewrite the local hgrc??
904 } 919 }
905 920
906 void MainWindow::open(QString local) 921 void MainWindow::open(QString local)
907 { 922 {
908 if (openLocal(local)) { 923 if (openLocal(local)) {
1664 connect(hgMergeAct, SIGNAL(triggered()), this, SLOT(hgMerge())); 1679 connect(hgMergeAct, SIGNAL(triggered()), this, SLOT(hgMerge()));
1665 connect(hgIgnoreAct, SIGNAL(triggered()), this, SLOT(hgIgnore())); 1680 connect(hgIgnoreAct, SIGNAL(triggered()), this, SLOT(hgIgnore()));
1666 1681
1667 connect(settingsAct, SIGNAL(triggered()), this, SLOT(settings())); 1682 connect(settingsAct, SIGNAL(triggered()), this, SLOT(settings()));
1668 connect(openAct, SIGNAL(triggered()), this, SLOT(open())); 1683 connect(openAct, SIGNAL(triggered()), this, SLOT(open()));
1684 connect(changeRemoteRepoAct, SIGNAL(triggered()), this, SLOT(changeRemoteRepo()));
1669 1685
1670 connect(hgIncomingAct, SIGNAL(triggered()), this, SLOT(hgIncoming())); 1686 connect(hgIncomingAct, SIGNAL(triggered()), this, SLOT(hgIncoming()));
1671 connect(hgPullAct, SIGNAL(triggered()), this, SLOT(hgPull())); 1687 connect(hgPullAct, SIGNAL(triggered()), this, SLOT(hgPull()));
1672 connect(hgPushAct, SIGNAL(triggered()), this, SLOT(hgPush())); 1688 connect(hgPushAct, SIGNAL(triggered()), this, SLOT(hgPush()));
1673 1689
1862 { 1878 {
1863 //File actions 1879 //File actions
1864 openAct = new QAction(QIcon(":/images/fileopen.png"), tr("Open..."), this); 1880 openAct = new QAction(QIcon(":/images/fileopen.png"), tr("Open..."), this);
1865 openAct -> setStatusTip(tr("Open a repository")); 1881 openAct -> setStatusTip(tr("Open a repository"));
1866 1882
1883 changeRemoteRepoAct = new QAction(tr("Change Remote Location..."), this);
1884 changeRemoteRepoAct->setStatusTip(tr("Change the default remote repository for pull and push actions"));
1885
1867 settingsAct = new QAction(QIcon(":/images/settings.png"), tr("Settings..."), this); 1886 settingsAct = new QAction(QIcon(":/images/settings.png"), tr("Settings..."), this);
1868 settingsAct -> setStatusTip(tr("View and change application settings")); 1887 settingsAct -> setStatusTip(tr("View and change application settings"));
1869 1888
1870 exitAct = new QAction(QIcon(":/images/exit.png"), tr("Quit"), this); 1889 exitAct = new QAction(QIcon(":/images/exit.png"), tr("Quit"), this);
1871 exitAct->setShortcuts(QKeySequence::Quit); 1890 exitAct->setShortcuts(QKeySequence::Quit);
1911 //Advanced actions 1930 //Advanced actions
1912 //!!! needs to be modified for number 1931 //!!! needs to be modified for number
1913 hgAnnotateAct = new QAction(tr("Annotate"), this); 1932 hgAnnotateAct = new QAction(tr("Annotate"), this);
1914 hgAnnotateAct -> setStatusTip(tr("Show line-by-line version information for selected file")); 1933 hgAnnotateAct -> setStatusTip(tr("Show line-by-line version information for selected file"));
1915 1934
1916 hgIgnoreAct = new QAction(tr("Edit .hgignore"), this); 1935 hgIgnoreAct = new QAction(tr("Edit .hgignore File"), this);
1917 hgIgnoreAct -> setStatusTip(tr("Edit the .hgignore file, containing the names of files that should be ignored by Mercurial")); 1936 hgIgnoreAct -> setStatusTip(tr("Edit the .hgignore file, containing the names of files that should be ignored by Mercurial"));
1918 1937
1919 hgServeAct = new QAction(tr("Serve (via http)"), this); 1938 hgServeAct = new QAction(tr("Serve via HTTP"), this);
1920 hgServeAct -> setStatusTip(tr("Serve local repository via http for workgroup access")); 1939 hgServeAct -> setStatusTip(tr("Serve local repository via http for workgroup access"));
1921 1940
1922 //Help actions 1941 //Help actions
1923 aboutAct = new QAction(tr("About"), this); 1942 aboutAct = new QAction(tr("About"), this);
1924 1943
1930 void MainWindow::createMenus() 1949 void MainWindow::createMenus()
1931 { 1950 {
1932 fileMenu = menuBar()->addMenu(tr("File")); 1951 fileMenu = menuBar()->addMenu(tr("File"));
1933 1952
1934 fileMenu -> addAction(openAct); 1953 fileMenu -> addAction(openAct);
1954 fileMenu -> addAction(changeRemoteRepoAct);
1935 fileMenu -> addAction(settingsAct); 1955 fileMenu -> addAction(settingsAct);
1936 fileMenu -> addSeparator(); 1956 fileMenu -> addSeparator();
1937 fileMenu -> addAction(exitAct); 1957 fileMenu -> addAction(exitAct);
1938 1958
1939 advancedMenu = menuBar()->addMenu(tr("Advanced")); 1959 advancedMenu = menuBar()->addMenu(tr("Advanced"));