# # # add_file "res/forms/dialogs/new_project_setup.ui" # content [a709ba0bd617e27abe4897b64b51d43bf5344073] # # add_file "src/view/dialogs/NewProjectSetup.cpp" # content [4aea59310f5c7e2527f7ddb1866e6b79472f236f] # # add_file "src/view/dialogs/NewProjectSetup.h" # content [3eb92299feb93434a64e52c833168a16872b389b] # # patch "guitone.pro" # from [a6aadb9e25b49eb21cc71c8bd01498957aaa2f33] # to [74a14c0b7e2eafccf668ac80bb2ad1850fa69431] # # patch "src/view/dialogs/DatabaseDialogManager.cpp" # from [bf76575815a0ab6bf17bb5c75fe52a1f4c5db4a5] # to [114836269d5a2ee7c9d086efdda82d69728f79b6] # # patch "src/view/dialogs/DatabaseDialogManager.h" # from [1a090d7cc52c821066410946fbcdd592158eddda] # to [93ebc24723501563f4d2a0c5170af9756df33215] # # patch "src/view/widgets/DatabaseMenuBar.cpp" # from [ce3a7aa362d08e1f816cd9456b8d3fd555a4fadc] # to [c587e7cebc8378a1b7240b1e823ce40a644b4bd3] # # patch "src/view/widgets/DatabaseMenuBar.h" # from [e891dcedbca13fdf865e320f4a6026e1c5eadbb3] # to [c39e62d47e2a899cd0207f90cbf67f34f362bf98] # ============================================================ --- res/forms/dialogs/new_project_setup.ui a709ba0bd617e27abe4897b64b51d43bf5344073 +++ res/forms/dialogs/new_project_setup.ui a709ba0bd617e27abe4897b64b51d43bf5344073 @@ -0,0 +1,144 @@ + + + NewProjectSetupDialog + + + + 0 + 0 + 387 + 143 + + + + + 0 + 0 + + + + Setup a new project + + + + + + + 0 + 0 + + + + Please enter a branch and select a workspace directory + + + + 5 + + + + + + 0 + 0 + + + + Branch + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + This name has to be globally unique. A reversed domain name +with the appended project name, like f.e. "com.example.project", +is a good example. + + + + + + + + 0 + 0 + + + + Workspace + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Choose the root directory of your project +as workspace directory. + + + + + + + Browse + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + NewProjectSetupDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + NewProjectSetupDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + ============================================================ --- src/view/dialogs/NewProjectSetup.cpp 4aea59310f5c7e2527f7ddb1866e6b79472f236f +++ src/view/dialogs/NewProjectSetup.cpp 4aea59310f5c7e2527f7ddb1866e6b79472f236f @@ -0,0 +1,124 @@ +/*************************************************************************** + * Copyright (C) 2010 by Thomas Keller * + * address@hidden * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation, either version 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * + ***************************************************************************/ + +#include "NewProjectSetup.h" +#include "WorkspaceCreator.h" +#include "MonotoneUtil.h" + +#include +#include + +NewProjectSetup::NewProjectSetup(QWidget * parent, const DatabaseFile & database) + : Dialog(parent), db(database) +{ + setupUi(this); + Dialog::init(); + + connect( + selectDirectory, SIGNAL(clicked()), + this, SLOT(doSelectDirectory()) + ); +} + +NewProjectSetup::~NewProjectSetup() {} + +void NewProjectSetup::init() +{ + branch->clear(); + workspacePath->clear(); +} + +void NewProjectSetup::doSelectDirectory() +{ + QString path = QFileDialog::getExistingDirectory( + this, tr("Select a directory for the new project...") + ); + + if (!path.isEmpty()) + { + workspacePath->setText(path); + } +} + +void NewProjectSetup::accept() +{ + QString branchName = branch->text().trimmed(); + QStringList revs = MonotoneUtil::resolveSelector(db, "b:" + branchName); + if (revs.size()) + { + QMessageBox::warning( + this, + tr("Branch already exists"), + tr("The given branch already exists."), + QMessageBox::Ok + ); + return; + } + + QDir workspace(workspacePath->text()); + if (workspace.exists()) + { + QFileInfo fileInfo(workspacePath->text()); + if (fileInfo.exists() && !fileInfo.isDir()) + { + QMessageBox::critical( + this, + tr("Invalid path"), + tr("The selected path exists, but is not a directory."), + QMessageBox::Ok + ); + return; + } + + if (workspace.cd("_MTN")) + { + QMessageBox::critical( + this, + tr("Directory is a workspace"), + tr("The selected directory already contains a monotone workspace."), + QMessageBox::Ok + ); + return; + } + + QMessageBox::StandardButton btn = QMessageBox::question( + this, + tr("Directory exists"), + tr("The selected directory already exists. " + "Do you want to continue?"), + QMessageBox::Yes | QMessageBox::No + ); + + if (btn == QMessageBox::No) return; + } + + if (!WorkspaceCreator::createBookkeepingDirectory(workspace, db, branchName)) + { + QMessageBox::critical( + this, + tr("Could not create bookkeeping directory"), + tr("Could not create bookkeeping directory - please check the log for details."), + QMessageBox::Ok + ); + return; + } + + emit newProjectCreated(workspace.absolutePath()); + done(0); +} + ============================================================ --- src/view/dialogs/NewProjectSetup.h 3eb92299feb93434a64e52c833168a16872b389b +++ src/view/dialogs/NewProjectSetup.h 3eb92299feb93434a64e52c833168a16872b389b @@ -0,0 +1,45 @@ +/*************************************************************************** + * Copyright (C) 2010 by Thomas Keller * + * address@hidden * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation, either version 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * + ***************************************************************************/ + +#ifndef NEW_PROJECT_SETUP_H +#define NEW_PROJECT_SETUP_H + +#include "Dialog.h" +#include "vocab.h" +#include "ui_new_project_setup.h" + +class NewProjectSetup : public Dialog, private Ui::NewProjectSetupDialog +{ + Q_OBJECT +public: + NewProjectSetup(QWidget *, const DatabaseFile &); + ~NewProjectSetup(); + void init(); + +signals: + void newProjectCreated(const QString &); + +private: + DatabaseFile db; + +private slots: + void doSelectDirectory(); + void accept(); +}; + +#endif ============================================================ --- guitone.pro a6aadb9e25b49eb21cc71c8bd01498957aaa2f33 +++ guitone.pro 74a14c0b7e2eafccf668ac80bb2ad1850fa69431 @@ -65,6 +65,7 @@ HEADERS = src/view/widgets/TreeView.h \ src/view/dialogs/AddEditDatabaseVariable.h \ src/view/dialogs/CreateDatabase.h \ src/view/dialogs/Netsync.h \ + src/view/dialogs/NewProjectSetup.h \ src/view/dialogs/Message.h \ src/view/panels/IconHelp.h \ src/view/panels/DatabaseVariables.h \ @@ -153,6 +154,7 @@ SOURCES += src/view/widgets/TreeView.cpp src/view/dialogs/AddEditDatabaseVariable.cpp \ src/view/dialogs/CreateDatabase.cpp \ src/view/dialogs/Netsync.cpp \ + src/view/dialogs/NewProjectSetup.cpp \ src/view/dialogs/Message.cpp \ src/view/panels/IconHelp.cpp \ src/view/panels/DatabaseVariables.cpp \ @@ -222,6 +224,7 @@ FORMS += res/forms/dialogs/select_revi res/forms/dialogs/add_edit_variables.ui \ res/forms/dialogs/create_database.ui \ res/forms/dialogs/netsync.ui \ + res/forms/dialogs/new_project_setup.ui \ res/forms/panels/icon_help.ui \ res/forms/panels/db_variables.ui \ res/forms/panels/nodeinfo.ui @@ -257,6 +260,8 @@ macx { # MacOS X specific configuration # macx { + QMAKE_LFLAGS += -framework Carbon + # copy i18n resources into the final app bundle and # put the current version number into Info.plist QMAKE_POST_LINK = cp -R res/osx/Resources bin/guitone.app/Contents && \ ============================================================ --- src/view/dialogs/DatabaseDialogManager.cpp bf76575815a0ab6bf17bb5c75fe52a1f4c5db4a5 +++ src/view/dialogs/DatabaseDialogManager.cpp 114836269d5a2ee7c9d086efdda82d69728f79b6 @@ -23,7 +23,7 @@ DatabaseDialogManager::DatabaseDialogMan : DialogManager(parent), changesetBrowser(0), checkoutRevision(0), fileDiff(0), fileHistory(0), generateKeypair(0), netsync(0), keyManagement(0), revisionDiff(0), - revisionManifest(0), selectRevision(0) + revisionManifest(0), selectRevision(0), newProjectSetup(0) {} DatabaseDialogManager::~DatabaseDialogManager() @@ -43,6 +43,7 @@ void DatabaseDialogManager::cleanup() if (revisionDiff) { delete revisionDiff; revisionDiff = 0; } if (revisionManifest) { delete revisionManifest; revisionManifest = 0; } if (selectRevision) { delete selectRevision; selectRevision = 0; } + if (newProjectSetup) { delete newProjectSetup; newProjectSetup = 0; } } void DatabaseDialogManager::closeAllDialogs() @@ -57,6 +58,7 @@ void DatabaseDialogManager::closeAllDial if (revisionDiff) revisionDiff->close(); if (revisionManifest) revisionManifest->close(); if (selectRevision) selectRevision->close(); + if (newProjectSetup) newProjectSetup->close(); DialogManager::closeAllDialogs(); } @@ -245,3 +247,20 @@ void DatabaseDialogManager::showSelectRe showDialog(selectRevision); } +void DatabaseDialogManager::showNewProjectSetup() +{ + if (!newProjectSetup) + { + newProjectSetup = new NewProjectSetup(parentWidget(), databaseFile); + + // delegate this further + connect( + newProjectSetup, SIGNAL(newProjectCreated(const QString &)), + this, SIGNAL(newProjectCreated(const QString &)) + ); + } + + newProjectSetup->init(); + showDialog(newProjectSetup); +} + ============================================================ --- src/view/dialogs/DatabaseDialogManager.h 1a090d7cc52c821066410946fbcdd592158eddda +++ src/view/dialogs/DatabaseDialogManager.h 93ebc24723501563f4d2a0c5170af9756df33215 @@ -30,6 +30,7 @@ #include "RevisionDiff.h" #include "RevisionManifest.h" #include "SelectRevision.h" +#include "NewProjectSetup.h" class DatabaseDialogManager : public DialogManager { @@ -44,6 +45,7 @@ signals: //! delegated signals signals: void revisionCheckedOut(const QString &); + void newProjectCreated(const QString &); public slots: void showChangesetBrowser(); @@ -52,6 +54,7 @@ public slots: void showFileHistory(const QString & file, const QString & startRevision); void showGenerateKeypair(); void showNetsync(); + void showNewProjectSetup(); void showKeyManagement(); virtual void showRevisionDiff(const QString & path, const QString & base, const QString & target); void showRevisionManifest(const QString & revision); @@ -68,6 +71,7 @@ protected: RevisionDiff * revisionDiff; RevisionManifest * revisionManifest; SelectRevision * selectRevision; + NewProjectSetup * newProjectSetup; private: void cleanup(); ============================================================ --- src/view/widgets/DatabaseMenuBar.cpp ce3a7aa362d08e1f816cd9456b8d3fd555a4fadc +++ src/view/widgets/DatabaseMenuBar.cpp c587e7cebc8378a1b7240b1e823ce40a644b4bd3 @@ -31,6 +31,7 @@ DatabaseMenuBar::DatabaseMenuBar(QWidget actionKey_management->setShortcut(tr("Ctrl+K")); actionCheckout_revision = new QAction(tr("Checkout revision"), this); actionCheckout_revision->setShortcut(tr("Ctrl+Shift+U")); + actionNew_project_setup = new QAction(tr("Create a new project"), this); menuDatabase = new QMenu(tr("Database"), this); @@ -40,6 +41,7 @@ DatabaseMenuBar::DatabaseMenuBar(QWidget menuDatabase->addAction(actionKey_management); menuDatabase->addSeparator(); menuDatabase->addAction(actionCheckout_revision); + menuDatabase->addAction(actionNew_project_setup); // insert the menu before the Window menu insertMenu(menuWindow->menuAction(), menuDatabase); @@ -64,6 +66,11 @@ DatabaseMenuBar::DatabaseMenuBar(QWidget this, SIGNAL(showCheckoutRevision()) ); + connect( + actionNew_project_setup, SIGNAL(triggered()), + this, SIGNAL(showNewProjectSetup()) + ); + // // the dock widget menu // ============================================================ --- src/view/widgets/DatabaseMenuBar.h e891dcedbca13fdf865e320f4a6026e1c5eadbb3 +++ src/view/widgets/DatabaseMenuBar.h c39e62d47e2a899cd0207f90cbf67f34f362bf98 @@ -35,12 +35,14 @@ signals: void showCheckoutRevision(); void showChangesetBrowser(); void showKeyManagement(); + void showNewProjectSetup(); protected: QAction * actionNetsync; QAction * actionKey_management; QAction * actionChangeset_browser; QAction * actionCheckout_revision; + QAction * actionNew_project_setup; QMenu * menuDatabase; QMenu * menuDockWidgets;