mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-27 03:58:01 +02:00
Improved cwd handling in comptime, generator file/folder edit
This commit is contained in:
parent
49716559e4
commit
087a129007
6 changed files with 130 additions and 32 deletions
|
@ -548,6 +548,8 @@ namespace IDE.ui
|
|||
|
||||
if (mUIData != null)
|
||||
{
|
||||
Project project = gApp.mWorkspace.FindProject(mProjectName);
|
||||
|
||||
if (mOutputPanel != null)
|
||||
{
|
||||
mOutputPanel.RemoveSelf();
|
||||
|
@ -587,6 +589,23 @@ namespace IDE.ui
|
|||
AddWidget(editWidget);
|
||||
mUIEntries.Add(uiEntry);
|
||||
mTabWidgets.Add(editWidget);
|
||||
case "addFilePath", "addFolderPath":
|
||||
if (mSubmitting)
|
||||
break;
|
||||
UIEntry uiEntry = new UIEntry();
|
||||
uiEntry.mName = partItr.GetNext().Value.UnQuoteString(.. new .());
|
||||
uiEntry.mLabel = partItr.GetNext().Value.UnQuoteString(.. new .());
|
||||
var defaultValue = partItr.GetNext().Value.UnQuoteString(.. scope .());
|
||||
PathEditWidget editWidget = new PathEditWidget((kind == "addFilePath") ? .File : .Folder);
|
||||
if (project != null)
|
||||
editWidget.mDefaultFolderPath = new .(project.mProjectDir);
|
||||
uiEntry.mWidget = editWidget;
|
||||
editWidget.SetText(defaultValue);
|
||||
editWidget.mEditWidgetContent.SelectAll();
|
||||
editWidget.mOnSubmit.Add(new => EditSubmitHandler);
|
||||
AddWidget(editWidget);
|
||||
mUIEntries.Add(uiEntry);
|
||||
mTabWidgets.Add(editWidget);
|
||||
case "addCombo":
|
||||
if (mSubmitting)
|
||||
break;
|
||||
|
|
|
@ -57,6 +57,7 @@ namespace IDE.ui
|
|||
public String mRelPath ~ delete _;
|
||||
PathKind mPathKind;
|
||||
DarkButton mBrowseButton;
|
||||
public String mDefaultFolderPath ~ delete _;
|
||||
|
||||
public this(PathKind pathKind = .Unknown)
|
||||
{
|
||||
|
@ -73,6 +74,9 @@ namespace IDE.ui
|
|||
{
|
||||
String path = scope .();
|
||||
GetText(path);
|
||||
|
||||
if (path.IsWhiteSpace)
|
||||
path.Set(mDefaultFolderPath);
|
||||
#if !CLI
|
||||
FolderBrowserDialog folderDialog = scope .();
|
||||
folderDialog.SelectedPath = path;
|
||||
|
@ -83,6 +87,30 @@ namespace IDE.ui
|
|||
}
|
||||
#endif
|
||||
}
|
||||
else if (mPathKind == .File)
|
||||
{
|
||||
String path = scope .();
|
||||
GetText(path);
|
||||
|
||||
|
||||
String dirPath = scope .();
|
||||
Path.GetDirectoryPath(path, dirPath).IgnoreError();
|
||||
if ((dirPath.IsWhiteSpace) && (mDefaultFolderPath != null))
|
||||
dirPath.Set(mDefaultFolderPath);
|
||||
|
||||
#if !CLI
|
||||
OpenFileDialog fileDialog = scope .();
|
||||
fileDialog.FileName = path;
|
||||
if (!dirPath.IsWhiteSpace)
|
||||
fileDialog.InitialDirectory = dirPath;
|
||||
mWidgetWindow.PreModalChild();
|
||||
if (fileDialog.ShowDialog(gApp.GetActiveWindow()).GetValueOrDefault() == .OK)
|
||||
{
|
||||
if (!fileDialog.FileNames.IsEmpty)
|
||||
SetText(scope String()..Append(fileDialog.FileNames[0]));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
});
|
||||
mEditWidgetContent.mTextInsets.mRight += GS!(20);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue