diff --git a/src/dlangide/ui/frame.d b/src/dlangide/ui/frame.d index b9cf71f..adabb49 100644 --- a/src/dlangide/ui/frame.d +++ b/src/dlangide/ui/frame.d @@ -797,6 +797,10 @@ class IDEFrame : AppFrame, ProgramExecutionStatusListener, BreakpointListChangeL }); return true; case IDEActions.FileOpenWorkspace: + if (!a.stringParam.empty) { + openFileOrWorkspace(a.stringParam); + return true; + } UIString caption; caption = "Open Workspace or Project"d; FileDialog dlg = createFileDialog(caption); @@ -1112,6 +1116,7 @@ class IDEFrame : AppFrame, ProgramExecutionStatusListener, BreakpointListChangeL askForUnsavedEdits(delegate() { setWorkspace(ws); hideHomeScreen(); + _settings.updateRecentWorkspace(filename); }); } else { window.showMessageBox(UIString("Cannot open workspace"d), UIString("Error occured while opening workspace"d)); diff --git a/src/dlangide/ui/homescreen.d b/src/dlangide/ui/homescreen.d index ed09043..ca915e4 100644 --- a/src/dlangide/ui/homescreen.d +++ b/src/dlangide/ui/homescreen.d @@ -7,6 +7,8 @@ import dlangui.widgets.controls; import dlangide.ui.frame; import dlangide.ui.commands; +import std.path; + class HomeScreen : ScrollWidget { protected IDEFrame _frame; protected HorizontalLayout _content; @@ -38,7 +40,17 @@ class HomeScreen : ScrollWidget { _column1.addChild(_startItems); _column1.addChild(new VSpacer()); _column1.addChild((new TextWidget(null, "Recent:"d)).fontSize(20).textColor(linkColor)); - _recentItems.addChild((new TextWidget(null, "No recent items"d))); + string[] recentWorkspaces = _frame.settings.recentWorkspaces; + if (recentWorkspaces.length) { + foreach(fn; recentWorkspaces) { + Action a = ACTION_FILE_OPEN_WORKSPACE.clone(); + a.label = UIString(toUTF32(stripExtension(baseName(fn)))); + a.stringParam = fn; + _column1.addChild(new LinkButton(a)); + } + } else { + _recentItems.addChild((new TextWidget(null, "No recent items"d))); + } _column1.addChild(_recentItems); _column1.addChild(new VSpacer()); _column2.addChild((new TextWidget(null, "Useful Links:"d)).fontSize(20).textColor(linkColor)); diff --git a/src/dlangide/workspace/idesettings.d b/src/dlangide/workspace/idesettings.d index 4dd8d07..6ab9af3 100644 --- a/src/dlangide/workspace/idesettings.d +++ b/src/dlangide/workspace/idesettings.d @@ -175,5 +175,31 @@ class IDESettings : SettingsFile { return null; } + @property string[] recentWorkspaces() { + import std.file; + Setting obj = _setting.objectByPath("history", true); + string[] list = obj.getStringArray("recentWorkspaces"); + string[] res; + foreach(fn; list) { + if (exists(fn) && isFile(fn)) + res ~= fn; + } + return res; + } + + void updateRecentWorkspace(string ws) { + import std.file; + string[] list; + list ~= ws; + string[] existing = recentWorkspaces; + foreach(fn; existing) { + if (exists(fn) && isFile(fn) && !ws.equal(fn)) + list ~= fn; + } + Setting obj = _setting.objectByPath("history", true); + obj["recentWorkspaces"] = list; + save(); + } + }