Start: misc improvements

- Hide recent files section if recent files prefs is set to 0
- Better filetype management
- Better tooltip on file thumbnails
- Added notes section (enable in preferences)
This commit is contained in:
Yorik van Havre
2018-08-23 16:00:18 -03:00
parent d139602512
commit dd19005c95
8 changed files with 326 additions and 241 deletions

View File

@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>476</width>
<height>645</height>
<height>743</height>
</rect>
</property>
<property name="windowTitle">
@@ -37,12 +37,74 @@
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>Start page options</string>
<string>Contents</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="13" column="1">
<layout class="QGridLayout" name="gridLayout_2">
<item row="3" column="0">
<widget class="QLabel" name="label_14">
<property name="text">
<string>Show forum</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Show examples folder contents</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_10">
<property name="text">
<string>Show additional folder</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="Gui::PrefCheckBox" name="checkBox_1">
<property name="toolTip">
<string>if you want the examples to show on the first page</string>
</property>
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string/>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>ShowExamples</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Start</cstring>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="Gui::PrefCheckBox" name="checkBox_4">
<property name="toolTip">
<string>If this is checked, the latest posts from the FreeCAD forum will be displayed on the Activity tab</string>
</property>
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string/>
</property>
<property name="prefEntry" stdset="0">
<cstring>ShowForum</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Start</cstring>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="Gui::PrefFileChooser" name="fileChooser_3">
<property name="toolTip">
<string>an optional custom folder to be displayed at the bottom of the first page</string>
@@ -55,13 +117,41 @@
</property>
</widget>
</item>
<item row="13" column="0">
<widget class="QLabel" name="label_10">
<item row="0" column="0">
<widget class="QLabel" name="label_17">
<property name="text">
<string>Show additional folder</string>
<string>Show notepad</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="Gui::PrefCheckBox" name="checkBox">
<property name="toolTip">
<string>Shows a notepad next to the file thumbnails, where you can keep notes across FreeCAD sessions</string>
</property>
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string/>
</property>
<property name="prefEntry" stdset="0">
<cstring>ShowNotes</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Start</cstring>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Fonts and colors</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="6" column="1" alignment="Qt::AlignRight">
<widget class="Gui::PrefColorButton" name="colorButton_3">
<property name="maximumSize">
@@ -88,13 +178,6 @@
</property>
</widget>
</item>
<item row="12" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Show examples folder contents</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="text">
@@ -110,7 +193,7 @@
<bool>false</bool>
</property>
<property name="text">
<string>in same page</string>
<string>in FreeCAD</string>
</property>
<property name="checked">
<bool>true</bool>
@@ -197,13 +280,6 @@
</property>
</widget>
</item>
<item row="15" column="0">
<widget class="QLabel" name="autoModuleLabel">
<property name="text">
<string>Switch workbench after loafing</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="Gui::PrefCheckBox" name="checkBox_5">
<property name="toolTip">
@@ -270,9 +346,6 @@
</property>
</widget>
</item>
<item row="15" column="1">
<widget class="QComboBox" name="AutoloadModuleCombo"/>
</item>
<item row="9" column="1" alignment="Qt::AlignRight">
<widget class="Gui::PrefColorButton" name="colorButton_6">
<property name="maximumSize">
@@ -397,35 +470,6 @@
</property>
</widget>
</item>
<item row="16" column="0">
<widget class="QLabel" name="label_11">
<property name="text">
<string>Close start page after loading</string>
</property>
</widget>
</item>
<item row="12" column="1">
<widget class="Gui::PrefCheckBox" name="checkBox_1">
<property name="toolTip">
<string>if you want the examples to show on the first page</string>
</property>
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string/>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>ShowExamples</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Start</cstring>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
@@ -433,77 +477,6 @@
</property>
</widget>
</item>
<item row="16" column="1">
<widget class="Gui::PrefCheckBox" name="checkBox_2">
<property name="toolTip">
<string>Should the start page be closed after loading?</string>
</property>
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string/>
</property>
<property name="prefEntry" stdset="0">
<cstring>closeStart</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Start</cstring>
</property>
</widget>
</item>
<item row="17" column="0">
<widget class="QLabel" name="label_13">
<property name="text">
<string>Close &amp; switch on file open</string>
</property>
</widget>
</item>
<item row="17" column="1">
<widget class="Gui::PrefCheckBox" name="checkBox_3">
<property name="toolTip">
<string>If FreeCAD is started by opening a file, apply the two settings above</string>
</property>
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string/>
</property>
<property name="prefEntry" stdset="0">
<cstring>DoNotShowOnOpen</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Start</cstring>
</property>
</widget>
</item>
<item row="14" column="0">
<widget class="QLabel" name="label_14">
<property name="text">
<string>Show forum</string>
</property>
</widget>
</item>
<item row="14" column="1">
<widget class="Gui::PrefCheckBox" name="checkBox_4">
<property name="toolTip">
<string>If this is checked, the latest posts from the FreeCAD forum will be displayed on the Activity tab</string>
</property>
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string/>
</property>
<property name="prefEntry" stdset="0">
<cstring>ShowForum</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Start</cstring>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_15">
<property name="text">
@@ -563,6 +536,77 @@
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_4">
<property name="title">
<string>Options</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="1">
<widget class="QComboBox" name="AutoloadModuleCombo"/>
</item>
<item row="1" column="1">
<widget class="Gui::PrefCheckBox" name="checkBox_2">
<property name="toolTip">
<string>Should the start page be closed after loading?</string>
</property>
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string/>
</property>
<property name="prefEntry" stdset="0">
<cstring>closeStart</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Start</cstring>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="autoModuleLabel">
<property name="text">
<string>Switch workbench after loafing</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_11">
<property name="text">
<string>Close start page after loading</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_13">
<property name="text">
<string>Close &amp; switch on file open</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="Gui::PrefCheckBox" name="checkBox_3">
<property name="toolTip">
<string>If FreeCAD is started by opening a file, apply the two settings above</string>
</property>
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string/>
</property>
<property name="prefEntry" stdset="0">
<cstring>DoNotShowOnOpen</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Start</cstring>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">

View File

@@ -91,6 +91,7 @@ void DlgStartPreferencesImp::saveSettings()
fileChooser_3->onSave();
radioButton_1->onSave();
radioButton_2->onSave();
checkBox->onSave();
checkBox_1->onSave();
checkBox_2->onSave();
checkBox_3->onSave();
@@ -119,6 +120,7 @@ void DlgStartPreferencesImp::loadSettings()
fileChooser_3->onRestore();
radioButton_1->onRestore();
radioButton_2->onRestore();
checkBox->onRestore();
checkBox_1->onRestore();
checkBox_2->onRestore();
checkBox_3->onRestore();

View File

@@ -9,9 +9,6 @@ a, a:link, a:visited {
color: LINKCOLOR;
font-weight: bold;
}
a:hover {
text-decoration: underline;
}
h1 {
width: 100%;
text-align: center;
@@ -50,7 +47,7 @@ ul.tabs li a {
font-size: 1em;
font-weight: bold;
text-transform: uppercase;
border:1px solid SHADOW;
border:1px solid BOXCOLOR;
border-radius: 1px;
box-shadow: #445 0 -5px 5px;
outline: 0;
@@ -101,6 +98,16 @@ ul.icons {
.icon p {
margin: 0;
}
.caption {
clear: both;
}
a .caption, a .caption:link, a .caption:visited {
color: TEXTCOLOR;
text-decoration-color: TEXTCOLOR;
}
.docbox a:hover {
text-decoration: underline;
}
.docbox {
float: left;
padding: 10px;
@@ -153,8 +160,25 @@ ul.workbenches li, ul.addonslist li {
width: 50%;
}
.forum {
display: none; /* forum display */
display: none; /* forum display */ /* don't change this line */
}
.forum pre {
white-space: pre-wrap;
}
.thumbnails {
float: left;
width: 100%; /* thumbs display */ /* don't change this line */
}
.notes {
display: none; /* notes display */ /* don't change this line */
float: right;
width: 30%;
}
#notepad {
width: 100%;
height: 100%;
color: TEXTCOLOR;
background: BOXCOLOR;
border: none;
padding: 5px;
}

View File

@@ -17,21 +17,31 @@
<li><a id="htab3" onClick="toggle('tab3')" href="#">T_ACTIVITY</a></li>
</ul>
<div id="tab1" class="panel">
<div class="thumbnails">
<h2>T_RECENTFILES</h2>
UL_RECENTFILES
<div class="footnote">
<b>T_TIP</b>: T_ADJUSTRECENT<br/>
SECTION_RECENTFILES
<div class="footnote">
<b>T_TIP</b>: T_ADJUSTRECENT<br/>
</div>
SECTION_EXAMPLES
SECTION_CUSTOM
<div class="footnote">
T_CUSTOM
</div>
</div>
SECTION_EXAMPLES
SECTION_CUSTOM
<div class="footnote">
T_CUSTOM
<div class="notes">
<h2>T_NOTES</h2>
<textarea id="notepad"></textarea>
</div>
</div>

View File

@@ -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);
}
}

View File

@@ -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 <li> 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 += '<li class="icon">'
result += '<a href="'+method+arg+'" title="'+infostring+'">'
result += '<img src="'+image+'">'
result += '<div class="caption">'
result += '<h4>'+basename+'</h4>'
result += '<p>'+size+'</p>'
result += '<p>'+author+'</p>'
result += '</div>'
result += '</a>'
result += '</li>'
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("<!--QSS-->","<style type=\"text/css\">"+ALTCSS+"</style>")
# 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 = "<ul>"
SECTION_RECENTFILES = "<h2>"+TranslationTexts.T_RECENTFILES+"</h2>"
SECTION_RECENTFILES += "<ul>"
for i in range(rfcount):
filename = rf.GetString("MRU%d" % (i))
if os.path.exists(filename):
basename = os.path.basename(filename)
image,size,author = getInfo(filename)
if size:
UL_RECENTFILES += '<li class="icon">'
UL_RECENTFILES += '<a href="LoadMRU.py?MRU='+str(i)+'" title="'+basename+'">'
UL_RECENTFILES += '<img src="'+image+'">'
UL_RECENTFILES += '</a>'
UL_RECENTFILES += '<div class="caption">'
UL_RECENTFILES += '<h4>'+basename+'</h4>'
UL_RECENTFILES += '<p>'+size+'</p>'
UL_RECENTFILES += '<p>'+author+'</p>'
UL_RECENTFILES += '</div>'
UL_RECENTFILES += '</li>'
UL_RECENTFILES += '<li class="icon">'
UL_RECENTFILES += '<a href="LoadNew.py" title="'+TranslationTexts.T_CREATENEW+'">'
UL_RECENTFILES += '<img src="'+iconbank["createimg"]+'">'
UL_RECENTFILES += '</a>'
UL_RECENTFILES += '<div class="caption">'
UL_RECENTFILES += '<h4>'+TranslationTexts.T_CREATENEW+'</h4>'
UL_RECENTFILES += '</div>'
UL_RECENTFILES += '</li>'
UL_RECENTFILES += '</ul>'
SECTION_RECENTFILES += buildCard(filename,method="LoadMRU.py?MRU=",arg=str(i))
SECTION_RECENTFILES += '<li class="icon">'
SECTION_RECENTFILES += '<a href="LoadNew.py" title="'+TranslationTexts.T_CREATENEW+'">'
SECTION_RECENTFILES += '<img src="'+iconbank["createimg"]+'">'
SECTION_RECENTFILES += '<div class="caption">'
SECTION_RECENTFILES += '<h4>'+TranslationTexts.T_CREATENEW+'</h4>'
SECTION_RECENTFILES += '</div>'
SECTION_RECENTFILES += '</li>'
SECTION_RECENTFILES += '</a>'
SECTION_RECENTFILES += '</ul>'
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 += "<ul>"
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 += '<li class="icon">'
SECTION_EXAMPLES += '<a href="LoadExample.py?filename='+basename+'" title="'+basename+'">'
SECTION_EXAMPLES += '<img src="'+image+'">'
SECTION_EXAMPLES += '</a>'
SECTION_EXAMPLES += '<div class="caption">'
SECTION_EXAMPLES += '<h4>'+basename+'</h4>'
SECTION_EXAMPLES += '<p>'+size+'</p>'
SECTION_EXAMPLES += '<p>'+author+'</p>'
SECTION_EXAMPLES += '</div>'
SECTION_EXAMPLES += '</li>'
SECTION_EXAMPLES += buildCard(filename,method="LoadExample.py?filename=")
SECTION_EXAMPLES += "</ul>"
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 += "<ul>"
for basename in os.listdir(cfolder):
filename = os.path.join(cfolder,basename)
if isplainfile(filename):
image,size,author = getInfo(filename)
if size:
SECTION_CUSTOM += '<li class="icon">'
SECTION_CUSTOM += '<a href="LoadCustom.py?filename='+urllib.quote(basename)+'" title="'+basename+'">'
SECTION_CUSTOM += '<img src="'+image+'">'
SECTION_CUSTOM += '</a>'
SECTION_CUSTOM += '<div class="caption">'
SECTION_CUSTOM += '<h4>'+basename+'</h4>'
SECTION_CUSTOM += '<p>'+size+'</p>'
SECTION_CUSTOM += '<p>'+author+'</p>'
SECTION_CUSTOM += '</div>'
SECTION_CUSTOM += '</li>'
SECTION_CUSTOM += buildCard(filename,method="LoadCustom.py?filename=")
SECTION_CUSTOM += "</ul>"
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:

View File

@@ -77,3 +77,6 @@ T_UNKNOWN = translate("StartPage", "Unknown")
T_FORUM = translate("StartPage", "Forum")
T_DESCR_FORUM = translate("StartPage", "The latest posts on the <a href=\"https://forum.freecadweb.org\">FreeCAD forum</a>:")
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")

View File

@@ -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();