diff options
author | Bill Hoffman <bill.hoffman@kitware.com> | 2008-02-19 19:06:10 (GMT) |
---|---|---|
committer | Bill Hoffman <bill.hoffman@kitware.com> | 2008-02-19 19:06:10 (GMT) |
commit | 4a9517a688d0bff682b538a272794000de56641d (patch) | |
tree | 0014a6f291c96571b8ff2d648404c39d8b19e55c | |
parent | a3c2d3280234fb5883f3e2ee0a3b980fe77f9b90 (diff) | |
download | CMake-4a9517a688d0bff682b538a272794000de56641d.zip CMake-4a9517a688d0bff682b538a272794000de56641d.tar.gz CMake-4a9517a688d0bff682b538a272794000de56641d.tar.bz2 |
ENH: add mac install symlink option to dialog
-rw-r--r-- | Source/QtDialog/CMakeLists.txt | 4 | ||||
-rw-r--r-- | Source/QtDialog/CMakeSetup.cxx | 13 | ||||
-rw-r--r-- | Source/QtDialog/MacInstallDialog.ui | 90 | ||||
-rw-r--r-- | Source/QtDialog/QMacInstallDialog.cxx | 69 | ||||
-rw-r--r-- | Source/QtDialog/QMacInstallDialog.h | 20 |
5 files changed, 195 insertions, 1 deletions
diff --git a/Source/QtDialog/CMakeLists.txt b/Source/QtDialog/CMakeLists.txt index 726f42e..a2cfdbf 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 b43f728..e90ed16 100644 --- a/Source/QtDialog/CMakeSetup.cxx +++ b/Source/QtDialog/CMakeSetup.cxx @@ -20,6 +20,7 @@ #include <QDir> #include <QTranslator> #include <QLocale> +#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 0000000..f43d8a9 --- /dev/null +++ b/Source/QtDialog/MacInstallDialog.ui @@ -0,0 +1,90 @@ +<ui version="4.0" > + <class>Dialog</class> + <widget class="QDialog" name="Dialog" > + <property name="geometry" > + <rect> + <x>0</x> + <y>0</y> + <width>525</width> + <height>134</height> + </rect> + </property> + <property name="windowTitle" > + <string>Install Command Line Tools</string> + </property> + <layout class="QGridLayout" > + <property name="margin" > + <number>9</number> + </property> + <property name="spacing" > + <number>6</number> + </property> + <item row="1" column="0" colspan="3" > + <widget class="QLabel" name="label_2" > + <property name="text" > + <string>This will create symbolic links to the command line tools of cmake into the specified install folder.</string> + </property> + <property name="wordWrap" > + <bool>true</bool> + </property> + </widget> + </item> + <item row="0" column="1" > + <widget class="QLineEdit" name="InstallPrefix" /> + </item> + <item row="0" column="0" > + <widget class="QLabel" name="label" > + <property name="text" > + <string>Install Folder:</string> + </property> + </widget> + </item> + <item row="0" column="2" > + <widget class="QPushButton" name="choosePathButton" > + <property name="text" > + <string>Choose...</string> + </property> + </widget> + </item> + <item row="2" column="0" colspan="3" > + <layout class="QHBoxLayout" > + <property name="margin" > + <number>0</number> + </property> + <property name="spacing" > + <number>6</number> + </property> + <item> + <spacer> + <property name="orientation" > + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" > + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QPushButton" name="skipInstallButton" > + <property name="text" > + <string>Skip Install Command Line </string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="doInstallButton" > + <property name="text" > + <string>Install Command Line Links</string> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/Source/QtDialog/QMacInstallDialog.cxx b/Source/QtDialog/QMacInstallDialog.cxx new file mode 100644 index 0000000..c3daaf2 --- /dev/null +++ b/Source/QtDialog/QMacInstallDialog.cxx @@ -0,0 +1,69 @@ +#include "QMacInstallDialog.h" +#include "cmSystemTools.h" +#include <iostream> +#include <QFileDialog> +#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 0000000..efe67df --- /dev/null +++ b/Source/QtDialog/QMacInstallDialog.h @@ -0,0 +1,20 @@ +#ifndef QMacInstallDialog_h +#define QMacInstallDialog_h +#include <QDialog> + +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 |