-
T_RECENTFILES
-
- UL_RECENTFILES
-
-
- SECTION_EXAMPLES
-
- SECTION_CUSTOM
-
-
diff --git a/src/Mod/Start/StartPage/StartPage.js b/src/Mod/Start/StartPage/StartPage.js
index 578d78b436..1742a5253c 100644
--- a/src/Mod/Start/StartPage/StartPage.js
+++ b/src/Mod/Start/StartPage/StartPage.js
@@ -46,6 +46,12 @@ function load() {
tobj.addScriptTag(); // Execute (add) the script tag
ddiv.innerHTML = "Downloading addons list...";
}
+ if (localStorage["notepad"]) {
+ document.getElementById("notepad").value = localStorage["notepad"]; // Load notepad from local storage
+ }
+ document.getElementById("notepad").addEventListener( "input", function () {
+ localStorage.setItem("notepad", document.getElementById("notepad").value); // Save notepad on type
+ }, false);
}
}
diff --git a/src/Mod/Start/StartPage/StartPage.py b/src/Mod/Start/StartPage/StartPage.py
index 5d18e661a6..05789ea963 100644
--- a/src/Mod/Start/StartPage/StartPage.py
+++ b/src/Mod/Start/StartPage/StartPage.py
@@ -47,23 +47,20 @@ def gethexcolor(color):
-def isplainfile(filename):
+def isOpenableByFreeCAD(filename):
- "check if this is any type we don't want to show"
+ "check if FreeCAD can handle this file type"
if os.path.isdir(filename):
return False
- basename = os.path.basename(filename)
- if basename.startswith("."):
- return False
- if basename[-1].isdigit():
- if basename[-7:-1].lower() == "fcstd": # freecad backup file
- return False
- if basename.endswith("~"):
- return False
- if basename.lower().endswith(".bak"):
- return False
- return True
+ extensions = [key.lower() for key in FreeCAD.getImportType().keys()]
+ ext = os.path.splitext(filename)[1].lower()
+ if ext:
+ if ext[0] == ".":
+ ext = ext[1:]
+ if ext in extensions:
+ return True
+ return False
@@ -72,10 +69,12 @@ def getInfo(filename):
"returns available file information"
global iconbank,tempfolder
+
+ tformat = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Start").GetString("TimeFormat","%m/%d/%Y %H:%M:%S")
def getLocalTime(timestamp):
"returns a local time from a timestamp"
- return time.strftime("%m/%d/%Y %H:%M:%S",time.localtime(timestamp))
+ return time.strftime(tformat,time.localtime(timestamp))
def getSize(size):
"returns a human-readable size"
@@ -90,17 +89,18 @@ def getInfo(filename):
if os.path.exists(filename):
if os.path.isdir(filename):
- return None,None,None
+ return None
# get normal file info
s = os.stat(filename)
size = getSize(s.st_size)
- #ctime = getLocalTime(s.st_ctime)
- #mtime = getLocalTime(s.st_mtime)
- author = TranslationTexts.T_UNKNOWN
- #company = TranslationTexts.T_UNKNOWN
- #lic = TranslationTexts.T_UNKNOWN
+ ctime = getLocalTime(s.st_ctime)
+ mtime = getLocalTime(s.st_mtime)
+ author = ""
+ company = TranslationTexts.T_UNKNOWN
+ lic = TranslationTexts.T_UNKNOWN
image = None
+ descr = ""
# get additional info from fcstd files
if filename.lower().endswith(".fcstd"):
@@ -113,12 +113,15 @@ def getInfo(filename):
r = re.findall("Property name=\"CreatedBy.*?String value=\"(.*?)\"\/>",doc)
if r:
author = r[0]
- #r = re.findall("Property name=\"Company.*?String value=\"(.*?)\"\/>",doc)
- #if r:
- # company = r
- #r = re.findall("Property name=\"License.*?String value=\"(.*?)\"\/>",doc)
- #if r:
- # lic =r
+ r = re.findall("Property name=\"Company.*?String value=\"(.*?)\"\/>",doc)
+ if r:
+ company = r[0]
+ r = re.findall("Property name=\"License.*?String value=\"(.*?)\"\/>",doc)
+ if r:
+ lic = r[0]
+ r = re.findall("Property name=\"Comment.*?String value=\"(.*?)\"\/>",doc)
+ if r:
+ descr = r[0]
if "thumbnails/Thumbnail.png" in files:
if filename in iconbank:
image = iconbank[filename]
@@ -144,9 +147,42 @@ def getInfo(filename):
px.save(image)
iconbank[t] = image
- return image,size,author
+ return [image,size,author,ctime,mtime,descr,company,lic]
- return None,None,None
+ return None
+
+
+
+def buildCard(filename,method,arg=None):
+
+ "builds a html
element representing a file. method is a script + a keyword, for ex. url.py?key="
+
+ result = ""
+ if os.path.exists(filename) and isOpenableByFreeCAD(filename):
+ basename = os.path.basename(filename)
+ if not arg:
+ arg = basename
+ finfo = getInfo(filename)
+ if finfo:
+ image = finfo[0]
+ size = finfo[1]
+ author = finfo[2]
+ infostring = TranslationTexts.T_CREATIONDATE+": "+finfo[3]+"\n"
+ infostring += TranslationTexts.T_LASTMODIFIED+": "+finfo[4]
+ if finfo[5]:
+ infostring += "\n\n" + finfo[5]
+ if size:
+ result += ''
+ result += ''
+ result += '
'
+ result += ''
+ result += '
'+basename+'
'
+ result += '
'+size+'
'
+ result += '
'+author+'
'
+ result += '
'
+ result += ''
+ result += ''
+ return result
@@ -156,7 +192,6 @@ def handle():
global iconbank,tempfolder
-
# reuse stuff from previous runs to reduce temp dir clutter
import Start
@@ -167,7 +202,6 @@ def handle():
else:
tempfolder = tempfile.mkdtemp(prefix="FreeCADStartThumbnails")
-
# build the html page skeleton
resources_dir = os.path.join(FreeCAD.getResourceDir(), "Mod", "Start", "StartPage")
@@ -188,7 +222,6 @@ def handle():
HTML = HTML.replace("JS",JS)
HTML = HTML.replace("CSS",CSS)
-
# get the stylesheet if we are using one
if FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Start").GetBool("UseStyleSheet",False):
@@ -198,21 +231,18 @@ def handle():
ALTCSS = f.read().decode("utf8")
HTML = HTML.replace("","")
-
# get FreeCAD version
v = FreeCAD.Version()
VERSIONSTRING = TranslationTexts.T_VERSION + " " + v[0] + "." + v[1] + " " + TranslationTexts.T_BUILD + " " + v[2]
HTML = HTML.replace("VERSIONSTRING",VERSIONSTRING)
-
# translate texts
HTML = HTML.replace("T_TITLE",TranslationTexts.T_TITLE)
HTML = HTML.replace("T_DOCUMENTS",TranslationTexts.T_DOCUMENTS)
HTML = HTML.replace("T_HELP",TranslationTexts.T_HELP)
HTML = HTML.replace("T_ACTIVITY",TranslationTexts.T_ACTIVITY)
- HTML = HTML.replace("T_RECENTFILES",TranslationTexts.T_RECENTFILES)
HTML = HTML.replace("T_TIP",TranslationTexts.T_TIP)
HTML = HTML.replace("T_ADJUSTRECENT",TranslationTexts.T_ADJUSTRECENT)
HTML = HTML.replace("T_GENERALDOCUMENTATION",TranslationTexts.T_GENERALDOCUMENTATION)
@@ -241,7 +271,7 @@ def handle():
HTML = HTML.replace("T_FORUM",TranslationTexts.T_FORUM)
HTML = HTML.replace("T_DESCR_FORUM",TranslationTexts.T_DESCR_FORUM)
HTML = HTML.replace("T_EXTERNALLINKS",TranslationTexts.T_EXTERNALLINKS)
-
+ HTML = HTML.replace("T_NOTES",TranslationTexts.T_NOTES)
# build a "create new" icon with the FreeCAD background color gradient
@@ -260,44 +290,29 @@ def handle():
i.save(createimg)
iconbank["createimg"] = createimg
+ # build SECTION_RECENTFILES
- # build UL_RECENTFILES
-
+ SECTION_RECENTFILES = ""
rf = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/RecentFiles")
rfcount = rf.GetInt("RecentFiles",0)
if rfcount:
- UL_RECENTFILES = "
'
if sys.version_info.major < 3:
- UL_RECENTFILES = UL_RECENTFILES.decode("utf8")
- HTML = HTML.replace("UL_RECENTFILES",UL_RECENTFILES)
-
+ SECTION_RECENTFILES = SECTION_RECENTFILES.decode("utf8")
+ HTML = HTML.replace("SECTION_RECENTFILES",SECTION_RECENTFILES)
# build SECTION_EXAMPLES
@@ -307,25 +322,12 @@ def handle():
SECTION_EXAMPLES += "
"
for basename in os.listdir(FreeCAD.getResourceDir()+"examples"):
filename = FreeCAD.getResourceDir()+"examples"+os.sep+basename
- if filename.endswith(".FCStd") or filename.endswith(".fcstd") or filename.endswith(".stp"):
- image,size,author = getInfo(filename)
- if size:
- SECTION_EXAMPLES += '- '
- SECTION_EXAMPLES += ''
- SECTION_EXAMPLES += '
'
- SECTION_EXAMPLES += ''
- SECTION_EXAMPLES += ''
- SECTION_EXAMPLES += '
'+basename+'
'
- SECTION_EXAMPLES += '
'+size+'
'
- SECTION_EXAMPLES += '
'+author+'
'
- SECTION_EXAMPLES += '
'
- SECTION_EXAMPLES += ' '
+ SECTION_EXAMPLES += buildCard(filename,method="LoadExample.py?filename=")
SECTION_EXAMPLES += "
"
if sys.version_info.major < 3:
SECTION_EXAMPLES = SECTION_EXAMPLES.decode("utf8")
HTML = HTML.replace("SECTION_EXAMPLES",SECTION_EXAMPLES)
-
# build SECTION_CUSTOM
SECTION_CUSTOM = ""
@@ -337,25 +339,12 @@ def handle():
SECTION_CUSTOM += "
"
for basename in os.listdir(cfolder):
filename = os.path.join(cfolder,basename)
- if isplainfile(filename):
- image,size,author = getInfo(filename)
- if size:
- SECTION_CUSTOM += '- '
- SECTION_CUSTOM += ''
- SECTION_CUSTOM += '
'
- SECTION_CUSTOM += ''
- SECTION_CUSTOM += ''
- SECTION_CUSTOM += '
'+basename+'
'
- SECTION_CUSTOM += '
'+size+'
'
- SECTION_CUSTOM += '
'+author+'
'
- SECTION_CUSTOM += '
'
- SECTION_CUSTOM += ' '
+ SECTION_CUSTOM += buildCard(filename,method="LoadCustom.py?filename=")
SECTION_CUSTOM += "
"
if sys.version_info.major < 3:
SECTION_CUSTOM = SECTION_CUSTOM.decode("utf8")
HTML = HTML.replace("SECTION_CUSTOM",SECTION_CUSTOM)
-
# build UL_WORKBENCHES
wblist = []
@@ -401,6 +390,7 @@ def handle():
HTML = HTML.replace("UL_WORKBENCHES",UL_WORKBENCHES)
# Detect additional addons that are not a workbench
+
try:
import dxfLibrary
except:
@@ -421,7 +411,6 @@ def handle():
wblist.append("cadexchanger")
HTML = HTML.replace("var wblist = [];","var wblist = " + str(wblist) + ";")
-
# set and replace colors and font settings
p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Start")
@@ -451,26 +440,28 @@ def handle():
HTML = HTML.replace("FONTFAMILY",FONTFAMILY)
HTML = HTML.replace("FONTSIZE",str(FONTSIZE)+"px")
-
# enable web access if permitted
if FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Start").GetBool("AllowDownload",False):
HTML = HTML.replace("var allowDownloads = 0;","var allowDownloads = 1;")
-
# enable or disable forum
if FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Start").GetBool("ShowForum",False):
HTML = HTML.replace("var showForum = 0;","var showForum = 1;")
HTML = HTML.replace("display: none; /* forum display */","display: block; /* forum display */")
+ # enable or disable notepad
+
+ if FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Start").GetBool("ShowNotes",False):
+ HTML = HTML.replace("display: none; /* notes display */","display: block; /* notes display */")
+ HTML = HTML.replace("width: 100%; /* thumbs display */","width: 70%; /* thumbs display */")
# store variables for further use
Start.iconbank = iconbank
Start.tempfolder = tempfolder
-
# encode if necessary
if sys.version_info.major < 3:
diff --git a/src/Mod/Start/StartPage/TranslationTexts.py b/src/Mod/Start/StartPage/TranslationTexts.py
index f1c9d274b7..d22cd151e0 100644
--- a/src/Mod/Start/StartPage/TranslationTexts.py
+++ b/src/Mod/Start/StartPage/TranslationTexts.py
@@ -77,3 +77,6 @@ T_UNKNOWN = translate("StartPage", "Unknown")
T_FORUM = translate("StartPage", "Forum")
T_DESCR_FORUM = translate("StartPage", "The latest posts on the
FreeCAD forum:")
T_EXTERNALLINKS = translate("StartPage", "To open any of the links above in your desktop browser, Right-click -> Open in external browser")
+T_CREATIONDATE = translate("StartPage", "Creation date")
+T_LASTMODIFIED = translate("StartPage", "Last modification")
+T_NOTES = translate("StartPage", "Notes")
diff --git a/src/Mod/Web/Gui/BrowserView.cpp b/src/Mod/Web/Gui/BrowserView.cpp
index c2e735de68..262670141c 100644
--- a/src/Mod/Web/Gui/BrowserView.cpp
+++ b/src/Mod/Web/Gui/BrowserView.cpp
@@ -232,6 +232,11 @@ BrowserView::BrowserView(QWidget* parent)
// set our custom cookie manager
FcCookieJar* cookiejar = new FcCookieJar(this);
view->page()->networkAccessManager()->setCookieJar(cookiejar);
+
+ // enable local storage so we can store stuff across sessions (startpage)
+ QWebSettings* settings = view->settings();
+ settings->setAttribute(QWebSettings::LocalStorageEnabled, true);
+ settings->setLocalStoragePath(QString::fromUtf8((App::Application::getUserAppDataDir()+"webdata").c_str()));
// setting background to white
QPalette palette = view->palette();