ENH: add ability to create symlinks for command line on mac from gui

This commit is contained in:
Bill Hoffman 2008-04-03 16:18:37 -04:00
parent 61af8d8b32
commit 5d01572348
3 changed files with 23 additions and 2 deletions

View File

@ -31,6 +31,7 @@
#include <QMimeData> #include <QMimeData>
#include <QUrl> #include <QUrl>
#include <QShortcut> #include <QShortcut>
#include <QMacInstallDialog.h>
#include "QCMake.h" #include "QCMake.h"
#include "QCMakeCacheView.h" #include "QCMakeCacheView.h"
@ -96,17 +97,23 @@ CMakeSetupDialog::CMakeSetupDialog()
this->GenerateAction = ToolsMenu->addAction(tr("&Generate")); this->GenerateAction = ToolsMenu->addAction(tr("&Generate"));
QObject::connect(this->GenerateAction, SIGNAL(triggered(bool)), QObject::connect(this->GenerateAction, SIGNAL(triggered(bool)),
this, SLOT(doGenerate())); this, SLOT(doGenerate()));
#if defined(__APPLE__)
this->InstallForCommandLineAction
= ToolsMenu->addAction(tr("&Install For Command Line Use"));
QObject::connect(this->InstallForCommandLineAction, SIGNAL(triggered(bool)),
this, SLOT(doInstallForCommandLine()));
#endif
QMenu* OptionsMenu = this->menuBar()->addMenu(tr("&Options")); QMenu* OptionsMenu = this->menuBar()->addMenu(tr("&Options"));
QAction* supressDevWarningsAction = OptionsMenu->addAction(tr("&Suppress dev Warnings (-Wno-dev)")); QAction* supressDevWarningsAction = OptionsMenu->addAction(tr("&Suppress dev Warnings (-Wno-dev)"));
QObject::connect(supressDevWarningsAction, SIGNAL(triggered(bool)), QObject::connect(supressDevWarningsAction, SIGNAL(triggered(bool)),
this, SLOT(doSuppressDev())); this, SLOT(doSuppressDev()));
supressDevWarningsAction->setCheckable(true); supressDevWarningsAction->setCheckable(true);
QAction* debugAction = OptionsMenu->addAction(tr("&Debug Output")); QAction* debugAction = OptionsMenu->addAction(tr("&Debug Output"));
debugAction->setCheckable(true); debugAction->setCheckable(true);
QObject::connect(debugAction, SIGNAL(toggled(bool)), QObject::connect(debugAction, SIGNAL(toggled(bool)),
this, SLOT(setDebugOutput(bool))); this, SLOT(setDebugOutput(bool)));
QMenu* HelpMenu = this->menuBar()->addMenu(tr("&Help")); QMenu* HelpMenu = this->menuBar()->addMenu(tr("&Help"));
QAction* a = HelpMenu->addAction(tr("About")); QAction* a = HelpMenu->addAction(tr("About"));
QObject::connect(a, SIGNAL(triggered(bool)), QObject::connect(a, SIGNAL(triggered(bool)),
@ -325,6 +332,12 @@ void CMakeSetupDialog::doSuppressDev()
SetSuppressDevWarnings(this->SuppressDevWarnings); SetSuppressDevWarnings(this->SuppressDevWarnings);
} }
void CMakeSetupDialog::doInstallForCommandLine()
{
QMacInstallDialog setupdialog(0);
setupdialog.exec();
}
void CMakeSetupDialog::doGenerate() void CMakeSetupDialog::doGenerate()
{ {
if(this->CurrentState == Generating) if(this->CurrentState == Generating)

View File

@ -45,6 +45,7 @@ protected slots:
void doConfigure(); void doConfigure();
void doGenerate(); void doGenerate();
void doSuppressDev(); void doSuppressDev();
void doInstallForCommandLine();
void doHelp(); void doHelp();
void doAbout(); void doAbout();
void doInterrupt(); void doInterrupt();
@ -94,6 +95,7 @@ protected:
QAction* ConfigureAction; QAction* ConfigureAction;
QAction* GenerateAction; QAction* GenerateAction;
QAction* SuppressDevWarningsAction; QAction* SuppressDevWarningsAction;
QAction* InstallForCommandLineAction;
State CurrentState; State CurrentState;
}; };

View File

@ -46,6 +46,12 @@ void QMacInstallDialog::DoInstall()
newName += filename; newName += filename;
std::cout << "ln -s [" << file << "] ["; std::cout << "ln -s [" << file << "] [";
std::cout << newName << "]\n"; std::cout << newName << "]\n";
// Remove the old files
if(cmSystemTools::FileExists(newName.c_str()))
{
std::cout << "rm [" << newName << "]\n";
cmSystemTools::RemoveFile(newName.c_str());
}
cmSystemTools::CreateSymlink(file.c_str(), cmSystemTools::CreateSymlink(file.c_str(),
newName.c_str()); newName.c_str());
} }