ENH: add Drag & Drop (directory, file, or CMakeCache), support for Shortcut too
This commit is contained in:
parent
4823f16ebb
commit
4a792ac1a4
@ -15,10 +15,11 @@ static char THIS_FILE[] = __FILE__;
|
|||||||
|
|
||||||
CMakeCommandLineInfo::CMakeCommandLineInfo()
|
CMakeCommandLineInfo::CMakeCommandLineInfo()
|
||||||
{
|
{
|
||||||
m_WhereSource = _T("");
|
this->m_WhereSource = _T("");
|
||||||
m_WhereBuild = _T("");
|
this->m_WhereBuild = _T("");
|
||||||
m_AdvancedValues = FALSE;
|
this->m_AdvancedValues = FALSE;
|
||||||
m_GeneratorChoiceString = _T("");
|
this->m_GeneratorChoiceString = _T("");
|
||||||
|
this->m_LastUnknownParameter = _T("");
|
||||||
}
|
}
|
||||||
|
|
||||||
CMakeCommandLineInfo::~CMakeCommandLineInfo()
|
CMakeCommandLineInfo::~CMakeCommandLineInfo()
|
||||||
@ -50,7 +51,11 @@ int CMakeCommandLineInfo::GetBoolValue(const CString& v) {
|
|||||||
|
|
||||||
void CMakeCommandLineInfo::ParseParam(LPCTSTR lpszParam, BOOL bFlag, BOOL bLast)
|
void CMakeCommandLineInfo::ParseParam(LPCTSTR lpszParam, BOOL bFlag, BOOL bLast)
|
||||||
{
|
{
|
||||||
if(bFlag)
|
if(!bFlag)
|
||||||
|
{
|
||||||
|
this->m_LastUnknownParameter = lpszParam;
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
CString sParam(lpszParam);
|
CString sParam(lpszParam);
|
||||||
// Single letter valued flag like /B=value or /B:value
|
// Single letter valued flag like /B=value or /B:value
|
||||||
@ -70,21 +75,21 @@ void CMakeCommandLineInfo::ParseParam(LPCTSTR lpszParam, BOOL bFlag, BOOL bLast)
|
|||||||
res = CMakeCommandLineInfo::GetBoolValue(value);
|
res = CMakeCommandLineInfo::GetBoolValue(value);
|
||||||
if (res == 1)
|
if (res == 1)
|
||||||
{
|
{
|
||||||
m_AdvancedValues = TRUE;
|
this->m_AdvancedValues = TRUE;
|
||||||
}
|
}
|
||||||
else if (res == -1)
|
else if (res == -1)
|
||||||
{
|
{
|
||||||
m_AdvancedValues = FALSE;
|
this->m_AdvancedValues = FALSE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'B':
|
case 'B':
|
||||||
m_WhereBuild = value;
|
this->m_WhereBuild = value;
|
||||||
break;
|
break;
|
||||||
case 'G':
|
case 'G':
|
||||||
m_GeneratorChoiceString = value;
|
this->m_GeneratorChoiceString = value;
|
||||||
break;
|
break;
|
||||||
case 'H':
|
case 'H':
|
||||||
m_WhereSource = value;
|
this->m_WhereSource = value;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,6 +45,7 @@ public:
|
|||||||
CString m_WhereBuild;
|
CString m_WhereBuild;
|
||||||
BOOL m_AdvancedValues;
|
BOOL m_AdvancedValues;
|
||||||
CString m_GeneratorChoiceString;
|
CString m_GeneratorChoiceString;
|
||||||
|
CString m_LastUnknownParameter;
|
||||||
|
|
||||||
// Operations
|
// Operations
|
||||||
public:
|
public:
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
|
#include "shellapi.h"
|
||||||
// a fun undef for DOT NET
|
// a fun undef for DOT NET
|
||||||
#undef DEBUG
|
#undef DEBUG
|
||||||
#include "CMakeSetup.h"
|
#include "CMakeSetup.h"
|
||||||
@ -82,15 +83,30 @@ CMakeSetupDialog::CMakeSetupDialog(const CMakeCommandLineInfo& cmdInfo,
|
|||||||
CWnd* pParent /*=NULL*/)
|
CWnd* pParent /*=NULL*/)
|
||||||
: CDialog(CMakeSetupDialog::IDD, pParent)
|
: CDialog(CMakeSetupDialog::IDD, pParent)
|
||||||
{
|
{
|
||||||
cmSystemTools::SetErrorCallback(MFCMessageCallback);
|
cmSystemTools::SetErrorCallback(MFCMessageCallback);
|
||||||
m_RegistryKey = "Software\\Kitware\\CMakeSetup\\Settings\\StartPath";
|
m_RegistryKey = "Software\\Kitware\\CMakeSetup\\Settings\\StartPath";
|
||||||
|
|
||||||
//{{AFX_DATA_INIT(CMakeSetupDialog)
|
//{{AFX_DATA_INIT(CMakeSetupDialog)
|
||||||
m_WhereSource = cmdInfo.m_WhereSource;
|
// Get the parameters from the command line info
|
||||||
m_WhereBuild = cmdInfo.m_WhereBuild;
|
// If an unknown parameter is found, try to interpret it too, since it
|
||||||
m_GeneratorChoiceString = cmdInfo.m_GeneratorChoiceString;
|
// is likely to be a file dropped on the shortcut :)
|
||||||
m_AdvancedValues = cmdInfo.m_AdvancedValues;
|
if (cmdInfo.m_LastUnknownParameter.IsEmpty())
|
||||||
|
{
|
||||||
|
this->m_WhereSource = cmdInfo.m_WhereSource;
|
||||||
|
this->m_WhereBuild = cmdInfo.m_WhereBuild;
|
||||||
|
this->m_GeneratorChoiceString = cmdInfo.m_GeneratorChoiceString;
|
||||||
|
this->m_AdvancedValues = cmdInfo.m_AdvancedValues;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this->m_WhereSource = _T("");
|
||||||
|
this->m_WhereBuild = _T("");
|
||||||
|
this->m_AdvancedValues = FALSE;
|
||||||
|
this->m_GeneratorChoiceString = _T("");
|
||||||
|
this->ChangeDirectoriesFromFile((LPCTSTR)cmdInfo.m_LastUnknownParameter);
|
||||||
|
}
|
||||||
//}}AFX_DATA_INIT
|
//}}AFX_DATA_INIT
|
||||||
|
|
||||||
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
|
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
|
||||||
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
|
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
|
||||||
m_BuildPathChanged = false;
|
m_BuildPathChanged = false;
|
||||||
@ -101,7 +117,7 @@ CMakeSetupDialog::CMakeSetupDialog(const CMakeCommandLineInfo& cmdInfo,
|
|||||||
m_PathToExecutable = cmSystemTools::GetProgramPath(fname).c_str();
|
m_PathToExecutable = cmSystemTools::GetProgramPath(fname).c_str();
|
||||||
// add the cmake.exe to the path
|
// add the cmake.exe to the path
|
||||||
m_PathToExecutable += "/cmake.exe";
|
m_PathToExecutable += "/cmake.exe";
|
||||||
|
|
||||||
m_oldCX = -1;
|
m_oldCX = -1;
|
||||||
m_deltaXRemainder = 0;
|
m_deltaXRemainder = 0;
|
||||||
}
|
}
|
||||||
@ -133,6 +149,7 @@ BEGIN_MESSAGE_MAP(CMakeSetupDialog, CDialog)
|
|||||||
ON_WM_SYSCOMMAND()
|
ON_WM_SYSCOMMAND()
|
||||||
ON_WM_PAINT()
|
ON_WM_PAINT()
|
||||||
ON_WM_QUERYDRAGICON()
|
ON_WM_QUERYDRAGICON()
|
||||||
|
ON_WM_DROPFILES()
|
||||||
ON_BN_CLICKED(IDC_BUTTON2, OnBrowseWhereSource)
|
ON_BN_CLICKED(IDC_BUTTON2, OnBrowseWhereSource)
|
||||||
ON_BN_CLICKED(IDC_BuildProjects, OnConfigure)
|
ON_BN_CLICKED(IDC_BuildProjects, OnConfigure)
|
||||||
ON_BN_CLICKED(IDC_BUTTON3, OnBrowseWhereBuild)
|
ON_BN_CLICKED(IDC_BUTTON3, OnBrowseWhereBuild)
|
||||||
@ -157,6 +174,7 @@ END_MESSAGE_MAP()
|
|||||||
BOOL CMakeSetupDialog::OnInitDialog()
|
BOOL CMakeSetupDialog::OnInitDialog()
|
||||||
{
|
{
|
||||||
CDialog::OnInitDialog();
|
CDialog::OnInitDialog();
|
||||||
|
this->DragAcceptFiles(true);
|
||||||
|
|
||||||
// Add "Create shortcut" menu item to system menu.
|
// Add "Create shortcut" menu item to system menu.
|
||||||
|
|
||||||
@ -914,9 +932,6 @@ void CMakeSetupDialog::OnEditchangeGenerator()
|
|||||||
// Create a shortcut on the desktop with the current Source/Build dir.
|
// Create a shortcut on the desktop with the current Source/Build dir.
|
||||||
int CMakeSetupDialog::CreateShortcut()
|
int CMakeSetupDialog::CreateShortcut()
|
||||||
{
|
{
|
||||||
// m_WhereSource = cmdInfo.m_WhereSource;
|
|
||||||
// m_WhereBuild = cmdInfo.m_WhereBuild;
|
|
||||||
|
|
||||||
// Find the desktop folder and create the link name
|
// Find the desktop folder and create the link name
|
||||||
|
|
||||||
HKEY hKey;
|
HKEY hKey;
|
||||||
@ -1152,3 +1167,64 @@ void CMakeSetupDialog::OnDoubleclickedAdvancedValues()
|
|||||||
{
|
{
|
||||||
this->OnAdvancedValues();
|
this->OnAdvancedValues();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Handle param or single dropped file.
|
||||||
|
// If it's a directory, use it as source and build dirs
|
||||||
|
// otherwise, if it's a CMakeCache, get source dir from cache
|
||||||
|
// otherwise use file's dir to set source and build dirs.
|
||||||
|
|
||||||
|
void CMakeSetupDialog::ChangeDirectoriesFromFile(const char* buffer)
|
||||||
|
{
|
||||||
|
std::string file = buffer;
|
||||||
|
if (cmSystemTools::FileIsDirectory(file.c_str()))
|
||||||
|
{
|
||||||
|
this->m_WhereSource = this->m_WhereBuild = file.c_str();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::string name = cmSystemTools::GetFilenameName(file);
|
||||||
|
std::string path = cmSystemTools::GetFilenamePath(file);
|
||||||
|
this->m_WhereBuild = path.c_str();
|
||||||
|
|
||||||
|
cmCacheManager *cache = cmCacheManager::GetInstance();
|
||||||
|
if (name == "CMakeCache.txt" &&
|
||||||
|
cache->LoadCache(path.c_str()) &&
|
||||||
|
cache->GetCacheEntry("CMAKE_HOME_DIRECTORY"))
|
||||||
|
{
|
||||||
|
this->m_WhereSource =
|
||||||
|
cache->GetCacheEntry("CMAKE_HOME_DIRECTORY")->m_Value.c_str();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this->m_WhereSource = path.c_str();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// The framework calls this member function when the user releases the
|
||||||
|
// left mouse button over a window that has registered itself as the
|
||||||
|
// recipient of dropped files.
|
||||||
|
|
||||||
|
void CMakeSetupDialog::OnDropFiles(HDROP hDropInfo)
|
||||||
|
{
|
||||||
|
UINT nb_files = DragQueryFile(hDropInfo, 0xFFFFFFFF, NULL, 0);
|
||||||
|
if (nb_files > 0)
|
||||||
|
{
|
||||||
|
UINT buffer_size = DragQueryFile(hDropInfo, 0, NULL, 0);
|
||||||
|
char *buffer = new char [buffer_size + 1];
|
||||||
|
DragQueryFile(hDropInfo, 0, buffer, buffer_size + 1);
|
||||||
|
|
||||||
|
this->ChangeDirectoriesFromFile(buffer);
|
||||||
|
delete [] buffer;
|
||||||
|
|
||||||
|
this->m_WhereSourceControl.SetWindowText(this->m_WhereSource);
|
||||||
|
this->m_WhereBuildControl.SetWindowText(this->m_WhereBuild);
|
||||||
|
|
||||||
|
this->UpdateData(FALSE);
|
||||||
|
|
||||||
|
this->OnChangeWhereSource();
|
||||||
|
this->OnChangeWhereBuild();
|
||||||
|
}
|
||||||
|
|
||||||
|
DragFinish(hDropInfo);
|
||||||
|
}
|
||||||
|
@ -87,6 +87,8 @@ protected:
|
|||||||
void FillCacheManagerFromCacheGUI();
|
void FillCacheManagerFromCacheGUI();
|
||||||
// Create a shortcut on the desktop with the current Source/Build dir.
|
// Create a shortcut on the desktop with the current Source/Build dir.
|
||||||
int CreateShortcut();
|
int CreateShortcut();
|
||||||
|
// Handle param or single dropped file.
|
||||||
|
void ChangeDirectoriesFromFile(const char *file);
|
||||||
|
|
||||||
HICON m_hIcon;
|
HICON m_hIcon;
|
||||||
CString m_RegistryKey;
|
CString m_RegistryKey;
|
||||||
@ -107,12 +109,13 @@ protected:
|
|||||||
afx_msg void OnSelendokWhereSource();
|
afx_msg void OnSelendokWhereSource();
|
||||||
afx_msg void OnSize(UINT nType, int cx, int cy);
|
afx_msg void OnSize(UINT nType, int cx, int cy);
|
||||||
afx_msg void OnGetMinMaxInfo( MINMAXINFO FAR* lpMMI );
|
afx_msg void OnGetMinMaxInfo( MINMAXINFO FAR* lpMMI );
|
||||||
afx_msg void OnOk();
|
afx_msg void OnOk();
|
||||||
afx_msg void OnEditchangeGenerator();
|
afx_msg void OnEditchangeGenerator();
|
||||||
afx_msg void OnHelpButton();
|
afx_msg void OnHelpButton();
|
||||||
afx_msg void OnAdvancedValues();
|
afx_msg void OnAdvancedValues();
|
||||||
afx_msg void OnDoubleclickedAdvancedValues();
|
afx_msg void OnDoubleclickedAdvancedValues();
|
||||||
//}}AFX_MSG
|
afx_msg void OnDropFiles(HDROP);
|
||||||
|
//}}AFX_MSG
|
||||||
DECLARE_MESSAGE_MAP()
|
DECLARE_MESSAGE_MAP()
|
||||||
|
|
||||||
int m_oldCX;
|
int m_oldCX;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user