From 4a9517a688d0bff682b538a272794000de56641d Mon Sep 17 00:00:00 2001 From: Bill Hoffman Date: Tue, 19 Feb 2008 14:06:10 -0500 Subject: [PATCH] ENH: add mac install symlink option to dialog --- Source/QtDialog/CMakeLists.txt | 4 ++ Source/QtDialog/CMakeSetup.cxx | 13 +++- Source/QtDialog/MacInstallDialog.ui | 90 +++++++++++++++++++++++++++ Source/QtDialog/QMacInstallDialog.cxx | 69 ++++++++++++++++++++ Source/QtDialog/QMacInstallDialog.h | 20 ++++++ 5 files changed, 195 insertions(+), 1 deletion(-) create mode 100644 Source/QtDialog/MacInstallDialog.ui create mode 100644 Source/QtDialog/QMacInstallDialog.cxx create mode 100644 Source/QtDialog/QMacInstallDialog.h diff --git a/Source/QtDialog/CMakeLists.txt b/Source/QtDialog/CMakeLists.txt index 726f42ebd..a2cfdbf7e 100644 --- a/Source/QtDialog/CMakeLists.txt +++ b/Source/QtDialog/CMakeLists.txt @@ -25,16 +25,20 @@ ELSE(NOT QT4_FOUND) QCMake.h QCMakeCacheView.cxx QCMakeCacheView.h + QMacInstallDialog.cxx + QMacInstallDialog.h ) QT4_WRAP_UI(UI_SRCS CMakeSetupDialog.ui AddCacheEntry.ui + MacInstallDialog.ui ) QT4_WRAP_CPP(MOC_SRCS AddCacheEntry.h CMakeSetupDialog.h QCMake.h QCMakeCacheView.h + QMacInstallDialog.h ) QT4_ADD_RESOURCES(RC_SRCS CMakeSetup.qrc) diff --git a/Source/QtDialog/CMakeSetup.cxx b/Source/QtDialog/CMakeSetup.cxx index b43f728ed..e90ed1654 100644 --- a/Source/QtDialog/CMakeSetup.cxx +++ b/Source/QtDialog/CMakeSetup.cxx @@ -20,6 +20,7 @@ #include #include #include +#include "QMacInstallDialog.h" #include "CMakeSetupDialog.h" #include "cmDocumentation.h" @@ -66,7 +67,17 @@ static const char * cmDocumentationOptions[][3] = int main(int argc, char** argv) { QApplication app(argc, argv); - + + // if arg for install + for(int i =0; i < argc; i++) + { + if(strcmp(argv[i], "--mac-install") == 0) + { + QMacInstallDialog setupdialog(0); + setupdialog.exec(); + return 0; + } + } // tell the cmake library where cmake is QDir cmExecDir(QApplication::applicationDirPath()); #if defined(Q_OS_MAC) diff --git a/Source/QtDialog/MacInstallDialog.ui b/Source/QtDialog/MacInstallDialog.ui new file mode 100644 index 000000000..f43d8a9fd --- /dev/null +++ b/Source/QtDialog/MacInstallDialog.ui @@ -0,0 +1,90 @@ + + Dialog + + + + 0 + 0 + 525 + 134 + + + + Install Command Line Tools + + + + 9 + + + 6 + + + + + This will create symbolic links to the command line tools of cmake into the specified install folder. + + + true + + + + + + + + + + Install Folder: + + + + + + + Choose... + + + + + + + 0 + + + 6 + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Skip Install Command Line + + + + + + + Install Command Line Links + + + + + + + + + + diff --git a/Source/QtDialog/QMacInstallDialog.cxx b/Source/QtDialog/QMacInstallDialog.cxx new file mode 100644 index 000000000..c3daaf247 --- /dev/null +++ b/Source/QtDialog/QMacInstallDialog.cxx @@ -0,0 +1,69 @@ +#include "QMacInstallDialog.h" +#include "cmSystemTools.h" +#include +#include +#include "ui_MacInstallDialog.h" + +class QMacInstallDialog::QMacInstallDialogInternals : public Ui::Dialog +{ +public: +}; + +QMacInstallDialog::QMacInstallDialog(QWidget*w) + :QDialog(w) +{ + this->Internals = new QMacInstallDialogInternals; + this->Internals->setupUi(this); + QObject::connect(this->Internals->choosePathButton, SIGNAL(pressed()), + this, SLOT(ShowBrowser())); + QObject::connect(this->Internals->skipInstallButton, SIGNAL(pressed()), + this, SLOT(SkipInstall())); + QObject::connect(this->Internals->doInstallButton, SIGNAL(pressed()), + this, SLOT(DoInstall())); + this->Internals->InstallPrefix->setText("/usr/bin/"); + +} + +QMacInstallDialog::~QMacInstallDialog() +{ + delete this->Internals; +} + +void QMacInstallDialog::DoInstall() +{ + QDir installDir(this->Internals->InstallPrefix->text()); + std::string installTo = installDir.path().toStdString(); + QDir cmExecDir(QApplication::applicationDirPath()); + cmExecDir.cd("../bin"); + QFileInfoList list = cmExecDir.entryInfoList(); + for (int i = 0; i < list.size(); ++i) + { + QFileInfo fileInfo = list.at(i); + std::string filename = fileInfo.fileName().toStdString(); + std::string file = fileInfo.absoluteFilePath().toStdString(); + std::string newName = installTo; + newName += "/"; + newName += filename; + std::cout << "ln -s [" << file << "] ["; + std::cout << newName << "]\n"; + cmSystemTools::CreateSymlink(file.c_str(), + newName.c_str()); + } + this->done(0); +} + +void QMacInstallDialog::SkipInstall() +{ + this->done(0); +} + + +void QMacInstallDialog::ShowBrowser() +{ + QString dir = QFileDialog::getExistingDirectory(this, + tr("Enter Install Prefix"), this->Internals->InstallPrefix->text()); + if(!dir.isEmpty()) + { + this->Internals->InstallPrefix->setText(dir); + } +} diff --git a/Source/QtDialog/QMacInstallDialog.h b/Source/QtDialog/QMacInstallDialog.h new file mode 100644 index 000000000..efe67dfaf --- /dev/null +++ b/Source/QtDialog/QMacInstallDialog.h @@ -0,0 +1,20 @@ +#ifndef QMacInstallDialog_h +#define QMacInstallDialog_h +#include + +class QMacInstallDialog : public QDialog +{ + Q_OBJECT; +public: + QMacInstallDialog(QWidget*w); + ~QMacInstallDialog(); +private slots: + void ShowBrowser(); + void SkipInstall(); + void DoInstall(); +private: + class QMacInstallDialogInternals; + QMacInstallDialogInternals* Internals; +}; + +#endif