Mercurial > hg > easyhg
comparison mainwindow.cpp @ 251:0689dada1419
Merge
author | Chris Cannam |
---|---|
date | Tue, 11 Jan 2011 20:19:19 +0000 |
parents | 0fe81e1b26ce 123e06d5d9af |
children | 8730dd806cca |
comparison
equal
deleted
inserted
replaced
246:0fe81e1b26ce | 251:0689dada1419 |
---|---|
121 ColourSet *cs = ColourSet::instance(); | 121 ColourSet *cs = ColourSet::instance(); |
122 cs->clearDefaultNames(); | 122 cs->clearDefaultNames(); |
123 cs->addDefaultName(""); | 123 cs->addDefaultName(""); |
124 cs->addDefaultName("default"); | 124 cs->addDefaultName("default"); |
125 cs->addDefaultName(getUserInfo()); | 125 cs->addDefaultName(getUserInfo()); |
126 | |
127 if (workFolderPath == "") { | |
128 open(); | |
129 } | |
130 | 126 |
131 hgTest(); | 127 hgTest(); |
132 } | 128 } |
133 | 129 |
134 | 130 |
493 QString hgIgnorePath; | 489 QString hgIgnorePath; |
494 QStringList params; | 490 QStringList params; |
495 | 491 |
496 hgIgnorePath = workFolderPath; | 492 hgIgnorePath = workFolderPath; |
497 hgIgnorePath += "/.hgignore"; | 493 hgIgnorePath += "/.hgignore"; |
494 | |
495 if (!QDir(workFolderPath).exists()) return; | |
496 QFile f(hgIgnorePath); | |
497 if (!f.exists()) { | |
498 f.open(QFile::WriteOnly); | |
499 QTextStream *ts = new QTextStream(&f); | |
500 *ts << "syntax: glob\n"; | |
501 delete ts; | |
502 f.close(); | |
503 } | |
498 | 504 |
499 params << hgIgnorePath; | 505 params << hgIgnorePath; |
500 | 506 |
501 QString editor = getEditorBinaryName(); | 507 QString editor = getEditorBinaryName(); |
502 | 508 |
971 d->addChoice("init", | 977 d->addChoice("init", |
972 tr("<qt><center><img src=\":images/hdd_unmount-64.png\"><br>File folder</center></qt>"), | 978 tr("<qt><center><img src=\":images/hdd_unmount-64.png\"><br>File folder</center></qt>"), |
973 tr("Open a local folder, by creating a Mercurial repository in it."), | 979 tr("Open a local folder, by creating a Mercurial repository in it."), |
974 MultiChoiceDialog::DirectoryArg); | 980 MultiChoiceDialog::DirectoryArg); |
975 | 981 |
976 d->setCurrentChoice("local"); | 982 QSettings settings; |
983 settings.beginGroup("General"); | |
984 QString lastChoice = settings.value("lastopentype", "local").toString(); | |
985 if (lastChoice != "local" && | |
986 lastChoice != "remote" && | |
987 lastChoice != "init") { | |
988 lastChoice = "local"; | |
989 } | |
990 | |
991 d->setCurrentChoice(lastChoice); | |
977 | 992 |
978 if (d->exec() == QDialog::Accepted) { | 993 if (d->exec() == QDialog::Accepted) { |
979 | 994 |
980 QString choice = d->getCurrentChoice(); | 995 QString choice = d->getCurrentChoice(); |
996 settings.setValue("lastopentype", choice); | |
997 | |
981 QString arg = d->getArgument().trimmed(); | 998 QString arg = d->getArgument().trimmed(); |
982 | 999 |
983 bool result = false; | 1000 bool result = false; |
984 | 1001 |
985 if (choice == "local") { | 1002 if (choice == "local") { |
1065 bool MainWindow::complainAboutFilePath(QString arg) | 1082 bool MainWindow::complainAboutFilePath(QString arg) |
1066 { | 1083 { |
1067 QMessageBox::critical | 1084 QMessageBox::critical |
1068 (this, tr("File chosen"), | 1085 (this, tr("File chosen"), |
1069 tr("<qt><b>Folder required</b><br><br>You asked to open \"%1\".<br>This is a file; to open a repository, you need to choose a folder.</qt>").arg(xmlEncode(arg))); | 1086 tr("<qt><b>Folder required</b><br><br>You asked to open \"%1\".<br>This is a file; to open a repository, you need to choose a folder.</qt>").arg(xmlEncode(arg))); |
1087 return false; | |
1088 } | |
1089 | |
1090 bool MainWindow::askAboutUnknownFolder(QString arg) | |
1091 { | |
1092 bool result = (QMessageBox::question | |
1093 (this, tr("Path does not exist"), | |
1094 tr("<qt><b>Path does not exist: create it?</b><br><br>You asked to open a remote repository by cloning it to \"%1\". This folder does not exist, and neither does its parent.<br><br>Would you like to create the parent folder as well?</qt>").arg(xmlEncode(arg)), | |
1095 QMessageBox::Ok | QMessageBox::Cancel, | |
1096 QMessageBox::Cancel) | |
1097 == QMessageBox::Ok); | |
1098 if (result) { | |
1099 QDir dir(arg); | |
1100 dir.cdUp(); | |
1101 if (!dir.mkpath(dir.absolutePath())) { | |
1102 QMessageBox::critical | |
1103 (this, tr("Failed to create folder"), | |
1104 tr("<qt><b>Failed to create folder</b><br><br>Sorry, the path for the parent folder \"%1\" could not be created.</qt>").arg(dir.absolutePath())); | |
1105 return false; | |
1106 } | |
1107 return true; | |
1108 } | |
1070 return false; | 1109 return false; |
1071 } | 1110 } |
1072 | 1111 |
1073 bool MainWindow::complainAboutUnknownFolder(QString arg) | 1112 bool MainWindow::complainAboutUnknownFolder(QString arg) |
1074 { | 1113 { |
1263 if (status == FolderIsFile) { | 1302 if (status == FolderIsFile) { |
1264 return complainAboutCloneToFile(local); | 1303 return complainAboutCloneToFile(local); |
1265 } | 1304 } |
1266 | 1305 |
1267 if (status == FolderUnknown) { | 1306 if (status == FolderUnknown) { |
1268 return complainAboutUnknownFolder(local); | 1307 if (!askAboutUnknownFolder(local)) { |
1308 return false; | |
1309 } | |
1269 } | 1310 } |
1270 | 1311 |
1271 if (status == FolderExists) { | 1312 if (status == FolderExists) { |
1272 local = complainAboutCloneToExistingFolder(local, remote); | 1313 local = complainAboutCloneToExistingFolder(local, remote); |
1273 if (local == "") return false; | 1314 if (local == "") return false; |
1900 bool noMore = false; | 1941 bool noMore = false; |
1901 | 1942 |
1902 switch (action) { | 1943 switch (action) { |
1903 | 1944 |
1904 case ACT_TEST_HG: | 1945 case ACT_TEST_HG: |
1905 hgTestExtension(); | 1946 { |
1906 break; | 1947 QSettings settings; |
1948 settings.beginGroup("General"); | |
1949 if (settings.value("useextension", true).toBool()) { | |
1950 hgTestExtension(); | |
1951 } else if (workFolderPath == "") { | |
1952 open(); | |
1953 } else { | |
1954 hgQueryPaths(); | |
1955 } | |
1956 break; | |
1957 } | |
1907 | 1958 |
1908 case ACT_TEST_HG_EXT: | 1959 case ACT_TEST_HG_EXT: |
1909 hgQueryPaths(); | 1960 if (workFolderPath == "") { |
1961 open(); | |
1962 } else{ | |
1963 hgQueryPaths(); | |
1964 } | |
1910 break; | 1965 break; |
1911 | 1966 |
1912 case ACT_QUERY_PATHS: | 1967 case ACT_QUERY_PATHS: |
1913 hgQueryBranch(); | 1968 hgQueryBranch(); |
1914 break; | 1969 break; |
2053 if (workFolderPath.isEmpty()) { | 2108 if (workFolderPath.isEmpty()) { |
2054 localRepoActionsEnabled = false; | 2109 localRepoActionsEnabled = false; |
2055 workFolderExist = false; | 2110 workFolderExist = false; |
2056 } | 2111 } |
2057 | 2112 |
2058 if (!workFolderDir.exists(workFolderPath)) { | 2113 if (workFolderPath == "" || !workFolderDir.exists(workFolderPath)) { |
2059 localRepoActionsEnabled = false; | 2114 localRepoActionsEnabled = false; |
2060 workFolderExist = false; | 2115 workFolderExist = false; |
2061 } else { | 2116 } else { |
2062 workFolderExist = true; | 2117 workFolderExist = true; |
2063 } | 2118 } |
2175 } else { | 2230 } else { |
2176 branchText = tr("branch \"%1\"").arg(currentBranch); | 2231 branchText = tr("branch \"%1\"").arg(currentBranch); |
2177 } | 2232 } |
2178 | 2233 |
2179 if (stateUnknown) { | 2234 if (stateUnknown) { |
2180 hgTabs->setState(tr("(Examining repository)")); | 2235 if (workFolderPath == "") { |
2236 hgTabs->setState(tr("No repository open")); | |
2237 } else { | |
2238 hgTabs->setState(tr("(Examining repository)")); | |
2239 } | |
2181 } else if (emptyRepo) { | 2240 } else if (emptyRepo) { |
2182 hgTabs->setState(tr("Nothing committed to this repository yet")); | 2241 hgTabs->setState(tr("Nothing committed to this repository yet")); |
2183 } else if (noWorkingCopy) { | 2242 } else if (noWorkingCopy) { |
2184 hgTabs->setState(tr("No working copy yet: consider updating")); | 2243 hgTabs->setState(tr("No working copy yet: consider updating")); |
2185 } else if (canMerge) { | 2244 } else if (canMerge) { |