Resync (forgot to add new files?)
[CMakeLuaTailorHgBridge.git] / CMakeLua / Source / QtDialog / QMacInstallDialog.cxx
blobc3daaf247182afc8aa553c82594cea16d0584ae6
1 #include "QMacInstallDialog.h"
2 #include "cmSystemTools.h"
3 #include <iostream>
4 #include <QFileDialog>
5 #include "ui_MacInstallDialog.h"
7 class QMacInstallDialog::QMacInstallDialogInternals : public Ui::Dialog
9 public:
12 QMacInstallDialog::QMacInstallDialog(QWidget*w)
13 :QDialog(w)
15 this->Internals = new QMacInstallDialogInternals;
16 this->Internals->setupUi(this);
17 QObject::connect(this->Internals->choosePathButton, SIGNAL(pressed()),
18 this, SLOT(ShowBrowser()));
19 QObject::connect(this->Internals->skipInstallButton, SIGNAL(pressed()),
20 this, SLOT(SkipInstall()));
21 QObject::connect(this->Internals->doInstallButton, SIGNAL(pressed()),
22 this, SLOT(DoInstall()));
23 this->Internals->InstallPrefix->setText("/usr/bin/");
27 QMacInstallDialog::~QMacInstallDialog()
29 delete this->Internals;
32 void QMacInstallDialog::DoInstall()
34 QDir installDir(this->Internals->InstallPrefix->text());
35 std::string installTo = installDir.path().toStdString();
36 QDir cmExecDir(QApplication::applicationDirPath());
37 cmExecDir.cd("../bin");
38 QFileInfoList list = cmExecDir.entryInfoList();
39 for (int i = 0; i < list.size(); ++i)
41 QFileInfo fileInfo = list.at(i);
42 std::string filename = fileInfo.fileName().toStdString();
43 std::string file = fileInfo.absoluteFilePath().toStdString();
44 std::string newName = installTo;
45 newName += "/";
46 newName += filename;
47 std::cout << "ln -s [" << file << "] [";
48 std::cout << newName << "]\n";
49 cmSystemTools::CreateSymlink(file.c_str(),
50 newName.c_str());
52 this->done(0);
55 void QMacInstallDialog::SkipInstall()
57 this->done(0);
61 void QMacInstallDialog::ShowBrowser()
63 QString dir = QFileDialog::getExistingDirectory(this,
64 tr("Enter Install Prefix"), this->Internals->InstallPrefix->text());
65 if(!dir.isEmpty())
67 this->Internals->InstallPrefix->setText(dir);