mirror of https://github.com/buggins/dlangide.git
recent workspaces list: close #71
This commit is contained in:
parent
fff1d3e87c
commit
c6836aa6c4
|
@ -797,6 +797,10 @@ class IDEFrame : AppFrame, ProgramExecutionStatusListener, BreakpointListChangeL
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
case IDEActions.FileOpenWorkspace:
|
case IDEActions.FileOpenWorkspace:
|
||||||
|
if (!a.stringParam.empty) {
|
||||||
|
openFileOrWorkspace(a.stringParam);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
UIString caption;
|
UIString caption;
|
||||||
caption = "Open Workspace or Project"d;
|
caption = "Open Workspace or Project"d;
|
||||||
FileDialog dlg = createFileDialog(caption);
|
FileDialog dlg = createFileDialog(caption);
|
||||||
|
@ -1112,6 +1116,7 @@ class IDEFrame : AppFrame, ProgramExecutionStatusListener, BreakpointListChangeL
|
||||||
askForUnsavedEdits(delegate() {
|
askForUnsavedEdits(delegate() {
|
||||||
setWorkspace(ws);
|
setWorkspace(ws);
|
||||||
hideHomeScreen();
|
hideHomeScreen();
|
||||||
|
_settings.updateRecentWorkspace(filename);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
window.showMessageBox(UIString("Cannot open workspace"d), UIString("Error occured while opening workspace"d));
|
window.showMessageBox(UIString("Cannot open workspace"d), UIString("Error occured while opening workspace"d));
|
||||||
|
|
|
@ -7,6 +7,8 @@ import dlangui.widgets.controls;
|
||||||
import dlangide.ui.frame;
|
import dlangide.ui.frame;
|
||||||
import dlangide.ui.commands;
|
import dlangide.ui.commands;
|
||||||
|
|
||||||
|
import std.path;
|
||||||
|
|
||||||
class HomeScreen : ScrollWidget {
|
class HomeScreen : ScrollWidget {
|
||||||
protected IDEFrame _frame;
|
protected IDEFrame _frame;
|
||||||
protected HorizontalLayout _content;
|
protected HorizontalLayout _content;
|
||||||
|
@ -38,7 +40,17 @@ class HomeScreen : ScrollWidget {
|
||||||
_column1.addChild(_startItems);
|
_column1.addChild(_startItems);
|
||||||
_column1.addChild(new VSpacer());
|
_column1.addChild(new VSpacer());
|
||||||
_column1.addChild((new TextWidget(null, "Recent:"d)).fontSize(20).textColor(linkColor));
|
_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(_recentItems);
|
||||||
_column1.addChild(new VSpacer());
|
_column1.addChild(new VSpacer());
|
||||||
_column2.addChild((new TextWidget(null, "Useful Links:"d)).fontSize(20).textColor(linkColor));
|
_column2.addChild((new TextWidget(null, "Useful Links:"d)).fontSize(20).textColor(linkColor));
|
||||||
|
|
|
@ -175,5 +175,31 @@ class IDESettings : SettingsFile {
|
||||||
return null;
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue