Browse Source

ENH: add mac install symlink option to dialog

Bill Hoffman 17 years ago
parent
commit
4a9517a688

+ 4 - 0
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)
 

+ 12 - 1
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)

+ 90 - 0
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>

+ 69 - 0
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);
+    }
+}

+ 20 - 0
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