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 /Source/QtDialog/QMacInstallDialog.cxx | |
parent | a3c2d3280234fb5883f3e2ee0a3b980fe77f9b90 (diff) | |
download | CMake-4a9517a688d0bff682b538a272794000de56641d.zip CMake-4a9517a688d0bff682b538a272794000de56641d.tar.gz CMake-4a9517a688d0bff682b538a272794000de56641d.tar.bz2 |
ENH: add mac install symlink option to dialog
Diffstat (limited to 'Source/QtDialog/QMacInstallDialog.cxx')
-rw-r--r-- | Source/QtDialog/QMacInstallDialog.cxx | 69 |
1 files changed, 69 insertions, 0 deletions
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); + } +} |