Start: New start workbench

This commit is contained in:
Yorik van Havre
2018-08-05 15:47:12 -03:00
committed by Yorik van Havre
parent 80107554f3
commit 6b88ade7be
55 changed files with 2240 additions and 1116 deletions

View File

@@ -8,41 +8,19 @@ if(BUILD_GUI)
)
SET(StartPage_Resources
ArchDesign.py
DefaultWorkbench.py
LoadDrawingExample.py
LoadPartDesignExample.py
LoadRobotExample.py
LoadSchenkel.py
LoadMRU0.py
LoadMRU1.py
LoadMRU2.py
LoadMRU3.py
LoadArchExample.py
LoadFemExample2D.py
LoadFemExample3D.py
LoadFemExample3DNewSolver.py
Mesh.py
PartDesign.py
Ship.py
LoadMRU.py
LoadExample.py
LoadNew.py
LoadCustom.py
StartPage.css
StartPage.js
StartPage.html
EnableDownload.py
images/Background.jpg
images/FreeCAD.png
images/PartDesign.png
images/ArchDesign.png
images/Mesh.png
images/Complete.png
images/PartDesignExample.png
images/ArchExample.png
images/web.png
images/blank.png
images/freecad-doc.png
images/complete.jpg
images/Ship.png
images/ShipExample.png
images/userhub.png
images/poweruserhub.png
images/developerhub.png
images/manual.png
images/freecad.png
)
add_subdirectory(Gui)

View File

@@ -35,6 +35,8 @@
#include <Gui/WorkbenchManager.h>
#include <Gui/Language/Translator.h>
#include "Workbench.h"
#include <Gui/WidgetFactory.h>
#include "DlgStartPreferencesImp.h"
#include <Mod/Start/App/StartConfiguration.h>
@@ -104,6 +106,9 @@ PyMOD_INIT_FUNC(StartGui)
PyObject* mod = StartGui::initModule();
Base::Console().Log("Loading GUI of Start module... done\n");
// register preferences pages
new Gui::PrefPageProducer<StartGui::DlgStartPreferencesImp> ("Start");
// instantiating the commands
CreateStartCommands();
StartGui::Workbench::init();

View File

@@ -12,14 +12,30 @@ set(StartGui_LIBS
FreeCADGui
)
set(StartGui_MOC_HDRS
DlgStartPreferencesImp.h
)
fc_wrap_cpp(StartGui_MOC_SRCS ${StartGui_MOC_HDRS})
SOURCE_GROUP("Moc" FILES ${StartGui_MOC_SRCS})
set(StartGui_UIC_SRCS
DlgStartPreferences.ui
)
if(BUILD_QT5)
qt5_add_resources(Start_QRC_SRCS Resources/Start.qrc)
qt5_wrap_ui(StartGui_UIC_HDRS ${StartGui_UIC_SRCS})
else()
qt4_add_resources(Start_QRC_SRCS Resources/Start.qrc)
qt4_wrap_ui(StartGui_UIC_HDRS ${StartGui_UIC_SRCS})
endif()
SET(StartGui_SRCS
${Start_QRC_SRCS}
${StartGui_UIC_SRCS}
DlgStartPreferences.ui
DlgStartPreferencesImp.cpp
DlgStartPreferencesImp.h
AppStartGui.cpp
Command.cpp
PreCompiled.cpp

View File

@@ -23,6 +23,8 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <QCoreApplication>
# include <QTextStream>
#endif
#include <Gui/Application.h>
@@ -33,26 +35,74 @@
using namespace std;
DEF_STD_CMD(CmdStartConstraintAxle);
DEF_STD_CMD(CmdStartPage);
CmdStartConstraintAxle::CmdStartConstraintAxle()
:Command("Start_ConstraintAxle")
CmdStartPage::CmdStartPage()
:Command("Start_StartPage")
{
sAppModule = "Start";
sGroup = QT_TR_NOOP("Start");
sMenuText = QT_TR_NOOP("Constraint Axle...");
sToolTipText = QT_TR_NOOP("Set an axle constraint between two objects");
sWhatsThis = "Start_ConstraintAxle";
sMenuText = QT_TR_NOOP("Start Page");
sToolTipText = QT_TR_NOOP("Displays the start page in a browser view");
sWhatsThis = "Start_StartPage";
sStatusTip = sToolTipText;
sPixmap = "actions/document-new";
sPixmap = "StartWorkbench";
}
void CmdStartConstraintAxle::activated(int iMsg)
void CmdStartPage::activated(int iMsg)
{
Q_UNUSED(iMsg);
// load the file with the module
//Command::doCommand(Command::Gui, "import Start, StartGui");
// Ensure that we don't open the Start page multiple times
QString title = QCoreApplication::translate("Workbench", "Start page");
QList<QWidget*> ch = Gui::getMainWindow()->windows();
for (QList<QWidget*>::const_iterator c = ch.begin(); c != ch.end(); ++c) {
if ((*c)->windowTitle() == title)
return;
}
try {
QByteArray utf8Title = title.toUtf8();
QByteArray cmd;
QTextStream str(&cmd);
str << "import WebGui" << endl;
str << "from StartPage import StartPage" << endl;
str << endl;
str << "class WebPage(object):" << endl;
str << " def __init__(self):" << endl;
str << " self.browser=WebGui.openBrowserWindow('" << utf8Title << "')" << endl;
#if defined(FC_OS_WIN32)
str << " self.browser.setHtml(StartPage.handle(), App.getResourceDir() + 'Mod/Start/StartPage/')" << endl;
#else
str << " self.browser.setHtml(StartPage.handle(), 'file://' + App.getResourceDir() + 'Mod/Start/StartPage/')" << endl;
#endif
str << " def onChange(self, par, reason):" << endl;
str << " if reason == 'RecentFiles':" << endl;
#if defined(FC_OS_WIN32)
str << " self.browser.setHtml(StartPage.handle(), App.getResourceDir() + 'Mod/Start/StartPage/')" << endl;
#else
str << " self.browser.setHtml(StartPage.handle(), 'file://' + App.getResourceDir() + 'Mod/Start/StartPage/')" << endl;
#endif
str << endl;
str << "class WebView(object):" << endl;
str << " def __init__(self):" << endl;
str << " self.pargrp = FreeCAD.ParamGet('User parameter:BaseApp/Preferences/RecentFiles')" << endl;
str << " self.webPage = WebPage()" << endl;
str << " self.pargrp.Attach(self.webPage)" << endl;
str << " def __del__(self):" << endl;
str << " self.pargrp.Detach(self.webPage)" << endl;
str << endl;
str << "webView=WebView()" << endl;
//Base::Interpreter().runString(cmd);
// Gui::Command::runCommand(Gui::Command::Gui, cmd);
Command::doCommand(Command::Gui, "import Start, StartGui");
Command::doCommand(Command::Gui, cmd);
}
catch (const Base::Exception& e) {
Base::Console().Error("%s\n", e.what());
}
}
@@ -61,5 +111,5 @@ void CreateStartCommands(void)
{
Gui::CommandManager &rcCmdMgr = Gui::Application::Instance->commandManager();
rcCmdMgr.addCommand(new CmdStartConstraintAxle());
rcCmdMgr.addCommand(new CmdStartPage());
}

View File

@@ -0,0 +1,488 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DlgStartPreferences</class>
<widget class="QWidget" name="DlgStartPreferences">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>476</width>
<height>507</height>
</rect>
</property>
<property name="windowTitle">
<string>Start page options</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Start page template</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="Gui::PrefFileChooser" name="fileChooser_1">
<property name="toolTip">
<string>An optional HTML template that will be used instead of the default start page.</string>
</property>
<property name="prefEntry" stdset="0">
<cstring>Template</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>Start page options</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="1" alignment="Qt::AlignRight">
<widget class="Gui::PrefColorButton" name="colorButton_7">
<property name="enabled">
<bool>false</bool>
</property>
<property name="maximumSize">
<size>
<width>60</width>
<height>60</height>
</size>
</property>
<property name="toolTip">
<string>the down gradient for the background color (currently unsupported)</string>
</property>
<property name="color">
<color>
<red>127</red>
<green>158</green>
<blue>181</blue>
</color>
</property>
<property name="prefEntry" stdset="0">
<cstring>BackgroundColor2</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Start</cstring>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Link color</string>
</property>
</widget>
</item>
<item row="5" column="1" alignment="Qt::AlignRight">
<widget class="Gui::PrefColorButton" name="colorButton_3">
<property name="maximumSize">
<size>
<width>60</width>
<height>60</height>
</size>
</property>
<property name="toolTip">
<string>the background of the main start page area</string>
</property>
<property name="color">
<color>
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</property>
<property name="prefEntry" stdset="0">
<cstring>PageColor</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Start</cstring>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Box background color</string>
</property>
</widget>
</item>
<item row="8" column="1" alignment="Qt::AlignRight">
<widget class="Gui::PrefColorButton" name="colorButton_6">
<property name="maximumSize">
<size>
<width>60</width>
<height>60</height>
</size>
</property>
<property name="toolTip">
<string>the color of the links</string>
</property>
<property name="color">
<color>
<red>0</red>
<green>0</green>
<blue>255</blue>
</color>
</property>
<property name="prefEntry" stdset="0">
<cstring>LinkColor</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Start</cstring>
</property>
</widget>
</item>
<item row="4" column="1" alignment="Qt::AlignRight">
<widget class="Gui::PrefColorButton" name="colorButton_2">
<property name="maximumSize">
<size>
<width>60</width>
<height>60</height>
</size>
</property>
<property name="toolTip">
<string>the color of the version text</string>
</property>
<property name="color">
<color>
<red>255</red>
<green>251</green>
<blue>247</blue>
</color>
</property>
<property name="prefEntry" stdset="0">
<cstring>BackgroundTextColor</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Start</cstring>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Background image</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Background color</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Page text color</string>
</property>
</widget>
</item>
<item row="6" column="1" alignment="Qt::AlignRight">
<widget class="Gui::PrefColorButton" name="colorButton_4">
<property name="maximumSize">
<size>
<width>60</width>
<height>60</height>
</size>
</property>
<property name="toolTip">
<string>the color of the text on he main pages</string>
</property>
<property name="color">
<color>
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</property>
<property name="prefEntry" stdset="0">
<cstring>PageTextColor</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Start</cstring>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="Gui::PrefFileChooser" name="fileChooser_2">
<property name="toolTip">
<string>an optional image to display as background</string>
</property>
<property name="prefEntry" stdset="0">
<cstring>BackgroundImage</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Start</cstring>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Page background color</string>
</property>
</widget>
</item>
<item row="10" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Show examples folder contents</string>
</property>
</widget>
</item>
<item row="11" 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>
</property>
<property name="prefEntry" stdset="0">
<cstring>ShowCustomFolder</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Start</cstring>
</property>
</widget>
</item>
<item row="11" column="0">
<widget class="QLabel" name="label_10">
<property name="text">
<string>Show additional folder</string>
</property>
</widget>
</item>
<item row="7" column="1" alignment="Qt::AlignRight">
<widget class="Gui::PrefColorButton" name="colorButton_5">
<property name="maximumSize">
<size>
<width>60</width>
<height>60</height>
</size>
</property>
<property name="toolTip">
<string>the background color of the boxes inside the pages</string>
</property>
<property name="color">
<color>
<red>221</red>
<green>221</green>
<blue>221</blue>
</color>
</property>
<property name="prefEntry" stdset="0">
<cstring>BoxColor</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Start</cstring>
</property>
</widget>
</item>
<item row="0" column="1" alignment="Qt::AlignRight">
<widget class="Gui::PrefColorButton" name="colorButton_1">
<property name="maximumSize">
<size>
<width>60</width>
<height>60</height>
</size>
</property>
<property name="toolTip">
<string>the background color behind the panels</string>
</property>
<property name="color">
<color>
<red>79</red>
<green>88</green>
<blue>116</blue>
</color>
</property>
<property name="prefEntry" stdset="0">
<cstring>BackgroundColor1</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Start</cstring>
</property>
</widget>
</item>
<item row="9" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="Gui::PrefRadioButton" name="radioButton_2">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>in same page</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>InBrowser</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Start</cstring>
</property>
</widget>
</item>
<item>
<widget class="Gui::PrefRadioButton" name="radioButton_1">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>in external browser</string>
</property>
<property name="prefEntry" stdset="0">
<cstring>InWeb</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Start</cstring>
</property>
</widget>
</item>
</layout>
</item>
<item row="10" 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="4" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Background text color</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_12">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Background color gradient down</string>
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="QLabel" name="label_7">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Open links</string>
</property>
</widget>
</item>
<item row="12" column="0">
<widget class="QLabel" name="autoModuleLabel">
<property name="text">
<string>Auto load module after loafing</string>
</property>
</widget>
</item>
<item row="12" column="1">
<widget class="QComboBox" name="AutoloadModuleCombo"/>
</item>
<item row="13" column="0">
<widget class="QLabel" name="label_11">
<property name="text">
<string>Close start page after loading</string>
</property>
</widget>
</item>
<item row="13" 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>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>Gui::FileChooser</class>
<extends>QWidget</extends>
<header>Gui/FileDialog.h</header>
</customwidget>
<customwidget>
<class>Gui::ColorButton</class>
<extends>QPushButton</extends>
<header>Gui/Widgets.h</header>
</customwidget>
<customwidget>
<class>Gui::PrefFileChooser</class>
<extends>Gui::FileChooser</extends>
<header>Gui/PrefWidgets.h</header>
</customwidget>
<customwidget>
<class>Gui::PrefColorButton</class>
<extends>Gui::ColorButton</extends>
<header>Gui/PrefWidgets.h</header>
</customwidget>
<customwidget>
<class>Gui::PrefRadioButton</class>
<extends>QRadioButton</extends>
<header>Gui/PrefWidgets.h</header>
</customwidget>
<customwidget>
<class>Gui::PrefCheckBox</class>
<extends>QCheckBox</extends>
<header>Gui/PrefWidgets.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@@ -0,0 +1,133 @@
/***************************************************************************
* Copyright (c) 2018 Yorik van Havre <yorik@uncreated.net> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#include "PreCompiled.h"
#include "DlgStartPreferencesImp.h"
#include <Gui/PrefWidgets.h>
#include <Base/Console.h>
#include <Gui/Application.h>
using namespace StartGui;
/**
* Constructs a DlgSettings3DViewImp which is a child of 'parent'
*/
DlgStartPreferencesImp::DlgStartPreferencesImp( QWidget* parent )
: PreferencePage( parent )
{
this->setupUi(this);
// Hide currently unused controls
label_12->hide();
label_7->hide();
radioButton_1->hide();
radioButton_2->hide();
// fills the combo box with all available workbenches
// sorted by their menu text
QStringList work = Gui::Application::Instance->workbenches();
QMap<QString, QString> menuText;
for (QStringList::Iterator it = work.begin(); it != work.end(); ++it) {
QString text = Gui::Application::Instance->workbenchMenuText(*it);
menuText[text] = *it;
}
for (QMap<QString, QString>::Iterator it = menuText.begin(); it != menuText.end(); ++it) {
QPixmap px = Gui::Application::Instance->workbenchIcon(it.value());
if (px.isNull())
AutoloadModuleCombo->addItem(it.key(), QVariant(it.value()));
else
AutoloadModuleCombo->addItem(px, it.key(), QVariant(it.value()));
}
}
/**
* Destroys the object and frees any allocated resources
*/
DlgStartPreferencesImp::~DlgStartPreferencesImp()
{
// no need to delete child widgets, Qt does it all for us
}
void DlgStartPreferencesImp::saveSettings()
{
int index = AutoloadModuleCombo->currentIndex();
QVariant data = AutoloadModuleCombo->itemData(index);
QString startWbName = data.toString();
App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Start")->
SetASCII("AutoloadModule", startWbName.toLatin1());
colorButton_1->onSave();
colorButton_2->onSave();
colorButton_3->onSave();
colorButton_4->onSave();
colorButton_5->onSave();
colorButton_6->onSave();
colorButton_7->onSave();
fileChooser_1->onSave();
fileChooser_2->onSave();
fileChooser_3->onSave();
radioButton_1->onSave();
radioButton_2->onSave();
checkBox_1->onSave();
checkBox_2->onSave();
}
void DlgStartPreferencesImp::loadSettings()
{
std::string start = App::Application::Config()["StartWorkbench"];
start = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Start")->
GetASCII("AutoloadModule", start.c_str());
QString startWbName = QLatin1String(start.c_str());
AutoloadModuleCombo->setCurrentIndex(AutoloadModuleCombo->findData(startWbName));
colorButton_1->onRestore();
colorButton_2->onRestore();
colorButton_3->onRestore();
colorButton_4->onRestore();
colorButton_5->onRestore();
colorButton_6->onRestore();
colorButton_7->onRestore();
fileChooser_1->onRestore();
fileChooser_2->onRestore();
fileChooser_3->onRestore();
radioButton_1->onRestore();
radioButton_2->onRestore();
checkBox_1->onRestore();
checkBox_2->onRestore();
}
/**
* Sets the strings of the subwidgets using the current language.
*/
void DlgStartPreferencesImp::changeEvent(QEvent *e)
{
if (e->type() == QEvent::LanguageChange) {
retranslateUi(this);
}
else {
QWidget::changeEvent(e);
}
}
#include "moc_DlgStartPreferencesImp.cpp"

View File

@@ -0,0 +1,48 @@
/***************************************************************************
* Copyright (c) 2018 Yorik van Havre <yorik@uncreated.net> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#ifndef STARTGUI_DLGSTARTPREFERENCESIMP_H
#define STARTGUI_DLGSTARTPREFERENCESIMP_H
#include "ui_DlgStartPreferences.h"
#include <Gui/PropertyPage.h>
namespace StartGui {
class DlgStartPreferencesImp : public Gui::Dialog::PreferencePage, public Ui_DlgStartPreferences
{
Q_OBJECT
public:
DlgStartPreferencesImp( QWidget* parent = 0 );
~DlgStartPreferencesImp();
protected:
void saveSettings();
void loadSettings();
void changeEvent(QEvent *e);
};
} // namespace StartGui
#endif // STARTGUI_DLGSTARTPREFERENCESIMP_H

View File

@@ -1,6 +1,7 @@
<!DOCTYPE RCC><RCC version="1.0">
<qresource>
<file>icons/StartWorkbench.svg</file>
<file>icons/preferences-start.svg</file>
<file>translations/StartPage_af.qm</file>
<file>translations/StartPage_de.qm</file>
<file>translations/StartPage_fi.qm</file>

View File

@@ -0,0 +1,182 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="64px"
height="64px"
id="svg3037"
sodipodi:version="0.32"
inkscape:version="0.48.5 r10040"
sodipodi:docname="StartWorkbench.svg"
inkscape:output_extension="org.inkscape.output.svg.inkscape"
version="1.1">
<defs
id="defs3039">
<linearGradient
id="linearGradient3794">
<stop
id="stop3796"
offset="0"
style="stop-color:#729fcf;stop-opacity:1" />
<stop
id="stop3798"
offset="1"
style="stop-color:#204a87;stop-opacity:1" />
</linearGradient>
<linearGradient
id="linearGradient3841">
<stop
style="stop-color:#0619c0;stop-opacity:1;"
offset="0"
id="stop3843" />
<stop
style="stop-color:#379cfb;stop-opacity:1;"
offset="1"
id="stop3845" />
</linearGradient>
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient3841"
id="linearGradient3847"
x1="3709.3296"
y1="1286.7291"
x2="3935.5251"
y2="1076.6174"
gradientUnits="userSpaceOnUse" />
<inkscape:perspective
sodipodi:type="inkscape:persp3d"
inkscape:vp_x="0 : 32 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_z="64 : 32 : 1"
inkscape:persp3d-origin="32 : 21.333333 : 1"
id="perspective3045" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient3794"
id="linearGradient2991"
gradientUnits="userSpaceOnUse"
x1="3718.145"
y1="1190.5608"
x2="3940.3335"
y2="1143.1339"
gradientTransform="matrix(0,0.1731146,-0.1731146,0,232.90021,-635.22046)" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient3841-6"
id="linearGradient2991-3"
gradientUnits="userSpaceOnUse"
x1="3709.3296"
y1="1286.7291"
x2="3935.5251"
y2="1076.6174"
gradientTransform="matrix(0,0.1731146,-0.1731146,0,232.90021,-635.22046)" />
<linearGradient
id="linearGradient3841-6">
<stop
style="stop-color:#0619c0;stop-opacity:1;"
offset="0"
id="stop3843-7" />
<stop
style="stop-color:#379cfb;stop-opacity:1;"
offset="1"
id="stop3845-5" />
</linearGradient>
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="3.598799"
inkscape:cx="-13.439241"
inkscape:cy="44.491229"
inkscape:current-layer="layer1"
showgrid="true"
inkscape:document-units="px"
inkscape:grid-bbox="true"
inkscape:window-width="800"
inkscape:window-height="836"
inkscape:window-x="0"
inkscape:window-y="27"
inkscape:window-maximized="0"
inkscape:snap-global="false">
<inkscape:grid
type="xygrid"
id="grid2990"
empspacing="2"
visible="true"
enabled="true"
snapvisiblegridlinesonly="true" />
</sodipodi:namedview>
<metadata
id="metadata3042">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
<dc:creator>
<cc:Agent>
<dc:title>[triplus]</dc:title>
</cc:Agent>
</dc:creator>
<dc:title>StartWorkbench</dc:title>
<dc:date>2016-02-26</dc:date>
<dc:relation>http://www.freecadweb.org/wiki/index.php?title=Artwork</dc:relation>
<dc:publisher>
<cc:Agent>
<dc:title>FreeCAD</dc:title>
</cc:Agent>
</dc:publisher>
<dc:identifier>FreeCAD/src/Mod/Start/Gui/Resources/icons/StartWorkbench.svg</dc:identifier>
<dc:rights>
<cc:Agent>
<dc:title>FreeCAD LGPL2+</dc:title>
</cc:Agent>
</dc:rights>
<cc:license>https://www.gnu.org/copyleft/lesser.html</cc:license>
<dc:contributor>
<cc:Agent>
<dc:title>[agryson] Alexander Gryson</dc:title>
</cc:Agent>
</dc:contributor>
<dc:subject>
<rdf:Bag>
<rdf:li>arrow</rdf:li>
<rdf:li>right</rdf:li>
</rdf:Bag>
</dc:subject>
<dc:description>Arrow pointing towards the right</dc:description>
</cc:Work>
</rdf:RDF>
</metadata>
<g
id="layer1"
inkscape:label="Layer 1"
inkscape:groupmode="layer">
<path
inkscape:connector-curvature="0"
style="fill:url(#linearGradient2991);fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:10;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
d="M 61,31 31,5 l 0,14 -24,0 0,24 24,0 0,14 z"
id="rect3066"
sodipodi:nodetypes="cccccccc" />
<path
inkscape:connector-curvature="0"
style="fill:none;stroke:#729fcf;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:10;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
d="M 58,31 33.012263,9.3801382 33,21 9,21 l 0,20 24,0 0,11.600864 z"
id="rect3066-3"
sodipodi:nodetypes="cccccccc" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 6.0 KiB

View File

@@ -128,7 +128,8 @@ Gui::ToolBarItem* StartGui::Workbench::setupToolBars() const
// web navigation toolbar
Gui::ToolBarItem* navigation = new Gui::ToolBarItem(root);
navigation->setCommand("Navigation");
*navigation << "Web_OpenWebsite"
*navigation << "Web_OpenWebsite"
<< "Start_StartPage"
<< "Separator"
<< "Web_BrowserBack"
<< "Web_BrowserNext"

View File

@@ -42,6 +42,7 @@ class StartWorkbench ( Workbench ):
# load the module
import StartGui
import Start
def GetClassName(self):
return "StartGui::Workbench"

View File

@@ -1,28 +0,0 @@
#***************************************************************************
#* *
#* Copyright (c) 2012 *
#* Yorik van Havre <yorik@uncreated.net> *
#* *
#* This program is free software; you can redistribute it and/or modify *
#* it under the terms of the GNU Lesser General Public License (LGPL) *
#* as published by the Free Software Foundation; either version 2 of *
#* the License, or (at your option) any later version. *
#* for detail see the LICENCE text file. *
#* *
#* This program is distributed in the hope that it will be useful, *
#* but WITHOUT ANY WARRANTY; without even the implied warranty of *
#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
#* GNU Library General Public License for more details. *
#* *
#* You should have received a copy of the GNU Library General Public *
#* License along with this program; if not, write to the Free Software *
#* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
#* USA *
#* *
#***************************************************************************
import FreeCAD, FreeCADGui
workbench = FreeCAD.ConfigGet("DefaultWorkbench")
if not workbench: workbench = "CompleteWorkbench"
FreeCADGui.activateWorkbench(workbench)
App.newDocument()

View File

@@ -1,26 +0,0 @@
#***************************************************************************
#* *
#* Copyright (c) 2012 *
#* Yorik van Havre <yorik@uncreated.net> *
#* *
#* This program is free software; you can redistribute it and/or modify *
#* it under the terms of the GNU Lesser General Public License (LGPL) *
#* as published by the Free Software Foundation; either version 2 of *
#* the License, or (at your option) any later version. *
#* for detail see the LICENCE text file. *
#* *
#* This program is distributed in the hope that it will be useful, *
#* but WITHOUT ANY WARRANTY; without even the implied warranty of *
#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
#* GNU Library General Public License for more details. *
#* *
#* You should have received a copy of the GNU Library General Public *
#* License along with this program; if not, write to the Free Software *
#* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
#* USA *
#* *
#***************************************************************************
import FreeCAD,FreeCADGui
FreeCAD.open(FreeCAD.getResourceDir()+"examples/ArchDetail.FCStd")
FreeCADGui.activeDocument().sendMsgToViews("ViewFit")

View File

@@ -1,7 +1,6 @@
#***************************************************************************
#* *
#* Copyright (c) 2012 *
#* Yorik van Havre <yorik@uncreated.net> *
#* Copyright (c) 2018 Yorik van Havre <yorik@uncreated.net> *
#* *
#* This program is free software; you can redistribute it and/or modify *
#* it under the terms of the GNU Lesser General Public License (LGPL) *
@@ -21,7 +20,16 @@
#* *
#***************************************************************************
import FreeCAD,FreeCADGui,sys
rf=FreeCAD.ParamGet("User parameter:BaseApp/Preferences/RecentFiles")
FreeCAD.loadFile(rf.GetString("MRU3"))
import FreeCAD,FreeCADGui,os,urllib
# filename will be given before this script is run
cfolder = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Start").GetString("ShowCustomFolder","")
if cfolder:
if not os.path.isdir(cfolder):
cfolder = os.path.dirname(cfolder)
f = urllib.unquote(filename).replace("+"," ")
FreeCAD.open(os.path.join(cfolder,f))
FreeCADGui.activeDocument().sendMsgToViews("ViewFit")
from StartPage import StartPage
StartPage.postStart()

View File

@@ -1,28 +0,0 @@
#***************************************************************************
#* *
#* Copyright (c) 2012 *
#* Yorik van Havre <yorik@uncreated.net> *
#* *
#* This program is free software; you can redistribute it and/or modify *
#* it under the terms of the GNU Lesser General Public License (LGPL) *
#* as published by the Free Software Foundation; either version 2 of *
#* the License, or (at your option) any later version. *
#* for detail see the LICENCE text file. *
#* *
#* This program is distributed in the hope that it will be useful, *
#* but WITHOUT ANY WARRANTY; without even the implied warranty of *
#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
#* GNU Library General Public License for more details. *
#* *
#* You should have received a copy of the GNU Library General Public *
#* License along with this program; if not, write to the Free Software *
#* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
#* USA *
#* *
#***************************************************************************
import FreeCAD,FreeCADGui
FreeCADGui.activateWorkbench("DrawingWorkbench")
FreeCAD.open(FreeCAD.getResourceDir()+"examples/DrawingExample.FCStd")
FreeCADGui.activeDocument().sendMsgToViews("ViewFit")
FreeCADGui.activeDocument().sendMsgToViews("ViewAxo")

View File

@@ -21,6 +21,10 @@
#* *
#***************************************************************************
import FreeCAD,FreeCADGui
FreeCAD.open(FreeCAD.getResourceDir()+"examples/FemCalculixCantilever2D.FCStd")
import FreeCAD,FreeCADGui,os
# filename will be given before this script is run
FreeCAD.open(os.path.join(FreeCAD.getResourceDir()+"examples",filename))
FreeCADGui.activeDocument().sendMsgToViews("ViewFit")
from StartPage import StartPage
StartPage.postStart()

View File

@@ -1,26 +0,0 @@
#***************************************************************************
#* *
#* Copyright (c) 2012 *
#* Yorik van Havre <yorik@uncreated.net> *
#* *
#* This program is free software; you can redistribute it and/or modify *
#* it under the terms of the GNU Lesser General Public License (LGPL) *
#* as published by the Free Software Foundation; either version 2 of *
#* the License, or (at your option) any later version. *
#* for detail see the LICENCE text file. *
#* *
#* This program is distributed in the hope that it will be useful, *
#* but WITHOUT ANY WARRANTY; without even the implied warranty of *
#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
#* GNU Library General Public License for more details. *
#* *
#* You should have received a copy of the GNU Library General Public *
#* License along with this program; if not, write to the Free Software *
#* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
#* USA *
#* *
#***************************************************************************
import FreeCAD,FreeCADGui
FreeCAD.open(FreeCAD.getResourceDir()+"examples/FemCalculixCantilever3D.FCStd")
FreeCADGui.activeDocument().sendMsgToViews("ViewFit")

View File

@@ -1,26 +0,0 @@
#***************************************************************************
#* *
#* Copyright (c) 2012 *
#* Yorik van Havre <yorik@uncreated.net> *
#* *
#* This program is free software; you can redistribute it and/or modify *
#* it under the terms of the GNU Lesser General Public License (LGPL) *
#* as published by the Free Software Foundation; either version 2 of *
#* the License, or (at your option) any later version. *
#* for detail see the LICENCE text file. *
#* *
#* This program is distributed in the hope that it will be useful, *
#* but WITHOUT ANY WARRANTY; without even the implied warranty of *
#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
#* GNU Library General Public License for more details. *
#* *
#* You should have received a copy of the GNU Library General Public *
#* License along with this program; if not, write to the Free Software *
#* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
#* USA *
#* *
#***************************************************************************
import FreeCAD,FreeCADGui
FreeCAD.open(FreeCAD.getResourceDir()+"examples/FemCalculixCantilever3D_newSolver.FCStd")
FreeCADGui.activeDocument().sendMsgToViews("ViewFit")

View File

@@ -0,0 +1,63 @@
#***************************************************************************
#* *
#* Copyright (c) 2018 Yorik van Havre <yorik@uncreated.net> *
#* *
#* This program is free software; you can redistribute it and/or modify *
#* it under the terms of the GNU Lesser General Public License (LGPL) *
#* as published by the Free Software Foundation; either version 2 of *
#* the License, or (at your option) any later version. *
#* for detail see the LICENCE text file. *
#* *
#* This program is distributed in the hope that it will be useful, *
#* but WITHOUT ANY WARRANTY; without even the implied warranty of *
#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
#* GNU Library General Public License for more details. *
#* *
#* You should have received a copy of the GNU Library General Public *
#* License along with this program; if not, write to the Free Software *
#* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
#* USA *
#* *
#***************************************************************************
# NOT WORKING - for further implementation
# The forum has a "last posts" feed at
# https://forum.freecadweb.org/feed.php
# Javascript can't fetch it directly, because of cross-domain prohibition
# We can't fetch this from python at StartPAge load, becuase it could take
# several seconds or even fail
# So the idea is to have javascript call this script here, which would
# do it, then find a way to make the result available back to javascript
# a tempfile, for example...
url = "https://forum.freecadweb.org/feed.php"
from xml.etree.ElementTree import parse
xml = parse(urllib.urlopen(url)).getroot()
items = []
channel = xml.find('channel')
for element in channel.findall('item'):
items.append({'title': element.find('title').text,
'description': element.find('description').text,
'link': element.find('link').text})
if len(items) > numitems:
items = items[:numitems]
resp = '<ul>'
for item in items:
descr = re.compile("style=\".*?\"").sub('',item['description'])
descr = re.compile("alt=\".*?\"").sub('',descr)
descr = re.compile("\"").sub('',descr)
d1 = re.findall("<img.*?>",descr)[0]
d2 = re.findall("<span>.*?</span>",descr)[0]
descr = "<h3>" + item['title'] + "</h3>"
descr += d1 + "<br/>"
descr += d2
resp += '<li><a onMouseover="show(\''
resp += descr
resp += '\')" onMouseout="show(\'\')" href="'
resp += item['link']
resp += '">'
resp += item['title']
resp += '</a></li>'
resp += '</ul>'
print(resp)

View File

@@ -1,7 +1,6 @@
#***************************************************************************
#* *
#* Copyright (c) 2012 *
#* Yorik van Havre <yorik@uncreated.net> *
#* Copyright (c) 2018 Yorik van Havre <yorik@uncreated.net> *
#* *
#* This program is free software; you can redistribute it and/or modify *
#* it under the terms of the GNU Lesser General Public License (LGPL) *
@@ -21,7 +20,11 @@
#* *
#***************************************************************************
import FreeCAD,FreeCADGui,sys
import FreeCAD,sys
# MRU will be given before this script is run
rf=FreeCAD.ParamGet("User parameter:BaseApp/Preferences/RecentFiles")
FreeCAD.loadFile(rf.GetString("MRU2"))
FreeCAD.loadFile(rf.GetString("MRU"+str(MRU)))
from StartPage import StartPage
StartPage.postStart()

View File

@@ -1,26 +0,0 @@
#***************************************************************************
#* *
#* Copyright (c) 2012 *
#* Yorik van Havre <yorik@uncreated.net> *
#* *
#* This program is free software; you can redistribute it and/or modify *
#* it under the terms of the GNU Lesser General Public License (LGPL) *
#* as published by the Free Software Foundation; either version 2 of *
#* the License, or (at your option) any later version. *
#* for detail see the LICENCE text file. *
#* *
#* This program is distributed in the hope that it will be useful, *
#* but WITHOUT ANY WARRANTY; without even the implied warranty of *
#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
#* GNU Library General Public License for more details. *
#* *
#* You should have received a copy of the GNU Library General Public *
#* License along with this program; if not, write to the Free Software *
#* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
#* USA *
#* *
#***************************************************************************
import FreeCAD,FreeCADGui,sys
rf=FreeCAD.ParamGet("User parameter:BaseApp/Preferences/RecentFiles")
FreeCAD.loadFile(rf.GetString("MRU0"))

View File

@@ -1,26 +0,0 @@
#***************************************************************************
#* *
#* Copyright (c) 2012 *
#* Yorik van Havre <yorik@uncreated.net> *
#* *
#* This program is free software; you can redistribute it and/or modify *
#* it under the terms of the GNU Lesser General Public License (LGPL) *
#* as published by the Free Software Foundation; either version 2 of *
#* the License, or (at your option) any later version. *
#* for detail see the LICENCE text file. *
#* *
#* This program is distributed in the hope that it will be useful, *
#* but WITHOUT ANY WARRANTY; without even the implied warranty of *
#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
#* GNU Library General Public License for more details. *
#* *
#* You should have received a copy of the GNU Library General Public *
#* License along with this program; if not, write to the Free Software *
#* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
#* USA *
#* *
#***************************************************************************
import FreeCAD,FreeCADGui,sys
rf=FreeCAD.ParamGet("User parameter:BaseApp/Preferences/RecentFiles")
FreeCAD.loadFile(rf.GetString("MRU1"))

View File

@@ -1,26 +1,27 @@
#***************************************************************************
#* *
#* Copyright (c) 2012 *
#* Yorik van Havre <yorik@uncreated.net> *
#* *
#* This program is free software; you can redistribute it and/or modify *
#* it under the terms of the GNU Lesser General Public License (LGPL) *
#* as published by the Free Software Foundation; either version 2 of *
#* the License, or (at your option) any later version. *
#* for detail see the LICENCE text file. *
#* *
#* This program is distributed in the hope that it will be useful, *
#* but WITHOUT ANY WARRANTY; without even the implied warranty of *
#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
#* GNU Library General Public License for more details. *
#* *
#* You should have received a copy of the GNU Library General Public *
#* License along with this program; if not, write to the Free Software *
#* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
#* USA *
#* *
#***************************************************************************
import FreeCADGui
FreeCADGui.activateWorkbench("ArchWorkbench")
App.newDocument()
#***************************************************************************
#* *
#* Copyright (c) 2018 Yorik van Havre <yorik@uncreated.net> *
#* *
#* This program is free software; you can redistribute it and/or modify *
#* it under the terms of the GNU Lesser General Public License (LGPL) *
#* as published by the Free Software Foundation; either version 2 of *
#* the License, or (at your option) any later version. *
#* for detail see the LICENCE text file. *
#* *
#* This program is distributed in the hope that it will be useful, *
#* but WITHOUT ANY WARRANTY; without even the implied warranty of *
#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
#* GNU Library General Public License for more details. *
#* *
#* You should have received a copy of the GNU Library General Public *
#* License along with this program; if not, write to the Free Software *
#* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
#* USA *
#* *
#***************************************************************************
import FreeCAD,FreeCADGui
FreeCAD.newDocument()
from StartPage import StartPage
StartPage.postStart()

View File

@@ -1,27 +0,0 @@
#***************************************************************************
#* *
#* Copyright (c) 2012 *
#* Yorik van Havre <yorik@uncreated.net> *
#* *
#* This program is free software; you can redistribute it and/or modify *
#* it under the terms of the GNU Lesser General Public License (LGPL) *
#* as published by the Free Software Foundation; either version 2 of *
#* the License, or (at your option) any later version. *
#* for detail see the LICENCE text file. *
#* *
#* This program is distributed in the hope that it will be useful, *
#* but WITHOUT ANY WARRANTY; without even the implied warranty of *
#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
#* GNU Library General Public License for more details. *
#* *
#* You should have received a copy of the GNU Library General Public *
#* License along with this program; if not, write to the Free Software *
#* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
#* USA *
#* *
#***************************************************************************
import FreeCAD,FreeCADGui
FreeCAD.open(FreeCAD.getResourceDir()+"examples/PartDesignExample.FCStd")
FreeCADGui.activeDocument().sendMsgToViews("ViewFit")
FreeCADGui.activeDocument().sendMsgToViews("ViewAxo")

View File

@@ -1,27 +0,0 @@
#***************************************************************************
#* *
#* Copyright (c) 2012 *
#* Yorik van Havre <yorik@uncreated.net> *
#* *
#* This program is free software; you can redistribute it and/or modify *
#* it under the terms of the GNU Lesser General Public License (LGPL) *
#* as published by the Free Software Foundation; either version 2 of *
#* the License, or (at your option) any later version. *
#* for detail see the LICENCE text file. *
#* *
#* This program is distributed in the hope that it will be useful, *
#* but WITHOUT ANY WARRANTY; without even the implied warranty of *
#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
#* GNU Library General Public License for more details. *
#* *
#* You should have received a copy of the GNU Library General Public *
#* License along with this program; if not, write to the Free Software *
#* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
#* USA *
#* *
#***************************************************************************
import FreeCAD,FreeCADGui
FreeCAD.open(FreeCAD.getResourceDir()+"examples/RobotExample.FCStd")
FreeCADGui.activeDocument().sendMsgToViews("ViewFit")
FreeCADGui.activeDocument().sendMsgToViews("ViewAxo")

View File

@@ -1,27 +0,0 @@
#***************************************************************************
#* *
#* Copyright (c) 2012 *
#* Yorik van Havre <yorik@uncreated.net> *
#* *
#* This program is free software; you can redistribute it and/or modify *
#* it under the terms of the GNU Lesser General Public License (LGPL) *
#* as published by the Free Software Foundation; either version 2 of *
#* the License, or (at your option) any later version. *
#* for detail see the LICENCE text file. *
#* *
#* This program is distributed in the hope that it will be useful, *
#* but WITHOUT ANY WARRANTY; without even the implied warranty of *
#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
#* GNU Library General Public License for more details. *
#* *
#* You should have received a copy of the GNU Library General Public *
#* License along with this program; if not, write to the Free Software *
#* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
#* USA *
#* *
#***************************************************************************
import FreeCAD,FreeCADGui,Part
Part.open(FreeCAD.getResourceDir()+"examples/Schenkel.stp")
FreeCADGui.activeDocument().sendMsgToViews("ViewFit")
FreeCADGui.activeDocument().sendMsgToViews("ViewAxo")

View File

@@ -1,26 +0,0 @@
#***************************************************************************
#* *
#* Copyright (c) 2012 *
#* Yorik van Havre <yorik@uncreated.net> *
#* *
#* This program is free software; you can redistribute it and/or modify *
#* it under the terms of the GNU Lesser General Public License (LGPL) *
#* as published by the Free Software Foundation; either version 2 of *
#* the License, or (at your option) any later version. *
#* for detail see the LICENCE text file. *
#* *
#* This program is distributed in the hope that it will be useful, *
#* but WITHOUT ANY WARRANTY; without even the implied warranty of *
#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
#* GNU Library General Public License for more details. *
#* *
#* You should have received a copy of the GNU Library General Public *
#* License along with this program; if not, write to the Free Software *
#* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
#* USA *
#* *
#***************************************************************************
import FreeCADGui
FreeCADGui.activateWorkbench("MeshWorkbench")
App.newDocument()

View File

@@ -1,30 +0,0 @@
#***************************************************************************
#* *
#* Copyright (c) 2012 *
#* Yorik van Havre <yorik@uncreated.net> *
#* *
#* This program is free software; you can redistribute it and/or modify *
#* it under the terms of the GNU Lesser General Public License (LGPL) *
#* as published by the Free Software Foundation; either version 2 of *
#* the License, or (at your option) any later version. *
#* for detail see the LICENCE text file. *
#* *
#* This program is distributed in the hope that it will be useful, *
#* but WITHOUT ANY WARRANTY; without even the implied warranty of *
#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
#* GNU Library General Public License for more details. *
#* *
#* You should have received a copy of the GNU Library General Public *
#* License along with this program; if not, write to the Free Software *
#* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
#* USA *
#* *
#***************************************************************************
import FreeCADGui
Gui.activateWorkbench("PartDesignWorkbench")
App.newDocument()
# Make the planes properly visible
#Gui.ActiveDocument.ActiveView.setCameraOrientation(App.ActiveDocument.BaseplaneXY.Placement.Rotation.Q)
#Gui.activeDocument().activeView().viewAxometric()
#Gui.SendMsgToActiveView("ViewFit")

View File

@@ -1,26 +0,0 @@
#***************************************************************************
#* *
#* Copyright (c) 2012 *
#* Yorik van Havre <yorik@uncreated.net> *
#* *
#* This program is free software; you can redistribute it and/or modify *
#* it under the terms of the GNU Lesser General Public License (LGPL) *
#* as published by the Free Software Foundation; either version 2 of *
#* the License, or (at your option) any later version. *
#* for detail see the LICENCE text file. *
#* *
#* This program is distributed in the hope that it will be useful, *
#* but WITHOUT ANY WARRANTY; without even the implied warranty of *
#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
#* GNU Library General Public License for more details. *
#* *
#* You should have received a copy of the GNU Library General Public *
#* License along with this program; if not, write to the Free Software *
#* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
#* USA *
#* *
#***************************************************************************
import FreeCADGui
FreeCADGui.activateWorkbench("ShipWorkbench")
App.newDocument()

View File

@@ -1,125 +1,150 @@
body {
background: #basecolor;
color: #textcolor;
background: BACKGROUND;
color: BGTCOLOR;
font-family: Arial, Helvetica, Sans;
font-size: 11px;
font-size: 13px;
}
a {
color: #linkcolor;
font-weight: bold;
a, a:link, a:visited {
text-decoration: none;
padding: 2px;
color: LINKCOLOR;
font-weight: bold;
}
a:hover {
color: white;
background: #linkcolor;
border-radius: 5px;
text-decoration: underline;
}
p {
text-align: justify;
}
.left {
text-align: left;
}
h1 {
font-size: 3em;
letter-spacing: 2px;
padding: 20px 0 0 80px;
align: bottom;
color: #ffffff;
width: 100%;
text-align: center;
}
h2 {
font-size: 1.2em;
}
ul {
list-style-type: none;
padding: 0;
}
#column {
margin: 0 350px 0 10px;
}
#column img {
max-width: 14px;
}
.block {
background: #windowcolor !important;
border-radius: 5px;
padding: 8px;
margin-bottom: 10px;
color: #windowtextcolor;
width: auto;
clear: left;
}
.half-block {
background: #windowcolor !important;
border-radius: 5px;
padding: 8px;
margin-bottom: 10px;
color: #windowtextcolor;
}
.options {
text-align: center;
fint-size: 0.9em;
clear: both;
}
.from {
font-size: 0.7em;
font-weight: normal;
.hidden {
display: none;
}
#versionbox {
.version {
font-size: 0.8em;
float: right;
text-align: right;
font-size: 0.33em;
font-weight: normal;
padding-right: 20px;
letter-spacing: 0;
color: #ffffff;
padding-right: 40px;
}
#description {
background: #windowcolor;
border-radius: 5px;
padding: 8px;
color: #windowtextcolor;
float: right;
width: 316px;
right: 10px;
height: 640px;
position: relative;
.container {
margin: 2%
}
#description img {
max-width: 300px;
ul.tabs {
margin: 9px 0;
}
ul.tabs li {
list-style: none;
display: inline;
}
ul.tabs li a {
color: TEXTCOLOR;
background-color: BOXCOLOR;
padding: 8px 14px 8px 14px;
text-decoration: none;
font-size: 1em;
font-weight: bold;
text-transform: uppercase;
border:1px solid SHADOW;
border-radius: 1px;
box-shadow: #445 0 -5px 5px;
outline: 0;
}
ul.tabs li a:hover {
background-color: TEXTCOLOR;
color: BASECOLOR;
}
ul.tabs li a.active {
background-color: BASECOLOR;
border-bottom: 1px solid BASECOLOR;
}
.panel {
background: BASECOLOR;
color: TEXTCOLOR;
padding: 15px;
clear: both;
margin-bottom: 10px;
border-radius: 3px;
overflow: auto;
box-shadow: SHADOW 0 2px 5px;
}
ul.icons {
clear: both;
}
#description p span {
text-align: left;
.icon {
list-style: none;
display: inline;
float: left;
padding: 5px 0px 15px 10px;
width: 138px;
height: 200px;
background: BOXCOLOR;
border-radius: 3px;
margin: 10px;
box-shadow: SHADOW 0 0px 6px;
}
.disabled {
opacity: 0.5;
.icon h4 {
margin: 3px 0;
max-width: 90%;
word-wrap: break-word;
}
pre {
width: 300px !important;
white-space: pre-wrap;
.icon img {
width: 128px;
height: 128px;
}
.stick {
position: fixed !important;
top: 0px;
right: 18px !important;
.icon p {
margin: 0;
}
.docbox {
float: left;
padding: 10px;
max-width: 360px;
background: BOXCOLOR;
border-radius: 3px;
margin: 10px;
box-shadow: SHADOW 0 0px 6px;
}
.docbox h2 {
text-align: center;
}
.docbox img {
max-width: 24px;
max-height: 24px;
}
.allwidth {
max-width: 98%;
}
h3 a {
height: 32px;
vertical-align: middle;
padding-bottom: 18px;
padding-left: 5px;
}
#commits ul {
margin: 30px 0;
padding: 10px;
}
#commits ul li, .forum ul li {
margin-bottom: 10px;
}
.footnote {
text-align: center;
display: block;
clear: both;
padding-top: 10px;
}
ul.workbenches, ul.addonslist {
overflow: hidden;
padding: 10px;
}
ul.workbenches li, ul.addonslist li {
list-style: none;
float: left;
display: inline;
width: 50%;
}
.forum ul {
padding: 10px;
}

View File

@@ -1,103 +1,124 @@
<html>
<head>
<title>FreeCAD - Start page</title>
<script language="javascript">startpage_js</script>
<style type="text/css">startpage_css</style>
</head>
<body onload="load()" onresize="resize()">
<h1><img src="images/FreeCAD.png">&nbsp;text01<div id=versionbox>&nbsp</div></h1>
<div id="description">
&nbsp;
</div>
<div id="column">
<div id="files" class="block">
<h2>text03</h2>
recentfiles
</div>
<div id="newproject" class="half-block" style="float: left; display: inline-block; height: 145px;">
<h2>text02</h2>
<ul>
<li><img src="images/blank.png">&nbsp;
<a onMouseover="show('<h3>text49</h3> \
<p>text50</p>')"
onMouseout="show('')"
href=text51>text49</a>
</li>
<li><img src="images/PartDesign.png">&nbsp;
<a onMouseover="show('<h3>text19</h3> \
<p>text20</p><p><small>text21 \
:</small></p><img src=images/PartDesignExample.png>')"
onMouseout="show('')"
href="PartDesign.py">text22</a>
</li>
<li><img src="images/ArchDesign.png">&nbsp;
<a onMouseover="show('<h3>text23</h3> \
<p>text24</p><p><small>text21 \
:</small></p><img src=images/ArchExample.png>')"
onMouseout="show('')"
href="ArchDesign.py">text25</a>
</li>
<li><img src="images/Ship.png">&nbsp;
<a onMouseover="show('<h3>text53</h3> \
<p>text54</p><p><small>text21 \
:</small></p><img src=images/ShipExample.png>')"
onMouseout="show('')"
href="Ship.py">text52</a>
</li>
<li><img src="images/Mesh.png">&nbsp;
<a onMouseover="show('<h3>text26</h3> \
<p>text27</p><p>text28</p>')"
onMouseout="show('')"
href="Mesh.py">text29</a>
</li>
</ul>
</div>
<div id="ontheweb" class="half-block" style="float: right; display: inline-block; height: 145px;">
<h2>text06</h2>
<ul>
<li><img src="images/web.png">&nbsp;
<a onMouseover="show('<p>text07</p>')"
onMouseout="show('')"
href="exthttp://www.freecadweb.org/">text08</a></li>
<li><img src="images/web.png">&nbsp;
<a onMouseover="show('<p>text45</p>')" onMouseout="show('')"
href=exttext38>text37</a></li>
<li><img src="images/web.png">&nbsp;
<a onMouseover="show('<p>text46</p>')"
onMouseout="show('')"
href=exttext56>text39</a></li>
<li><img src="images/web.png">&nbsp;
<a onMouseover="show('<p>text47</p>')"
onMouseout="show('')"
href=exttext57>text40</a></li>
<li><img src="images/web.png">&nbsp;
<a onMouseover="show('<p>text48</p>')"
onMouseout="show('')"
href="exthttp://freecad-tutorial.blogspot.com/">text43</a></li>
<li><img src="images/web.png">&nbsp;
<a href="exthttp://github.com/FreeCAD/FreeCAD/releases"
onMouseOver="show('<p>text62</p>')"
onMouseOut="show('')">text61</a></li>
</ul>
</div>
<div id="examples" class="half-block" style="float: left; display: inline-block;">
<h2>text09</h2>
<ul>
<li><img src="images/FreeCAD.png" style="width: 16px">&nbsp;<a href="LoadSchenkel.py">text10</a></li>
<li><img src="images/FreeCAD.png" style="width: 16px">&nbsp;<a href="LoadPartDesignExample.py">text11</a></li>
<li><img src="images/FreeCAD.png" style="width: 16px">&nbsp;<a href="LoadDrawingExample.py">text12</a></li>
<li><img src="images/FreeCAD.png" style="width: 16px">&nbsp;<a href="LoadRobotExample.py">text13</a></li>
<li><img src="images/FreeCAD.png" style="width: 16px">&nbsp;<a href="LoadArchExample.py">text55</a></li>
<li><img src="images/FreeCAD.png" style="width: 16px">&nbsp;<a href="LoadFemExample2D.py">text64</a></li>
<li><img src="images/FreeCAD.png" style="width: 16px">&nbsp;<a href="LoadFemExample3D.py">text60</a></li>
<li><img src="images/FreeCAD.png" style="width: 16px">&nbsp;<a href="LoadFemExample3DNewSolver.py">text69</a></li>
</ul>
</div>
<div id="commits" class="half-block" style="float: right; display: inline-block;">
<h2>text05</h2>
<div id="news">news feed</div>
</div>
customblocks
</div>
</body>
<head>
<title>T_TITLE</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<script language="javascript">JS</script>
<style type="text/css">CSS</style>
</head>
<body onload="load()">
<div class="container">
<div class="title">
<div class="version">VERSIONSTRING</div>
</div>
<ul id="tabs" class="tabs">
<li><a id="htab1" class="active" onClick="toggle('tab1')" href="#">T_DOCUMENTS</a></li>
<li><a id="htab2" onClick="toggle('tab2')" href="#">T_HELP</a></li>
<li><a id="htab3" onClick="toggle('tab3')" href="#">T_ACTIVITY</a></li>
</ul>
<div id="tab1" class="panel">
<h2>T_RECENTFILES</h2>
UL_RECENTFILES
<div class="footnote">
<b>T_TIP</b>: T_ADJUSTRECENT<br/>
</div>
SECTION_EXAMPLES
SECTION_CUSTOM
<div class="footnote">
T_CUSTOM
</div>
</div>
<div id="tab2" class="panel hidden">
<div class="docbox">
<h2>T_GENERALDOCUMENTATION</h2>
<h3>
<img src="images/userhub.png" />
<a href="https://www.freecadweb.org/wiki/User_hub">T_USERHUB</a>
</h3>
<p>T_DESCR_USERHUB</p>
<h3>
<img src="images/poweruserhub.png" />
<a href="https://www.freecadweb.org/wiki/Power_users_hub">T_POWERHUB</a>
</h3>
<p>T_DESCR_POWERHUB</p>
<h3>
<img src="images/developerhub.png" />
<a href="https://www.freecadweb.org/wiki/Developer_hub">T_DEVHUB</a>
</h3>
<p>T_DESCR_DEVHUB</p>
<h3>
<img src="images/manual.png" />
<a href="https://www.freecadweb.org/wiki/Manual:Introduction">T_MANUAL</a>
</h3>
<p>T_DESCR_MANUAL</p>
</div>
<div class="docbox">
<h2>T_WBHELP</h2>
<p>T_DESCR_WBHELP</p>
UL_WORKBENCHES
</div>
<div class="docbox">
<h2>T_COMMUNITYHELP</h2>
T_DESCR_COMMUNITYHELP
</div>
<div class="docbox">
<h2>T_ADDONS</h2>
<p>T_DESCR_ADDONS</p>
<div id="addons">T_OFFLINEPLACEHOLDER</div>
</div>
<div class="footnote">
<p><b>TIP</b>: T_OFFLINEHELP</p>
</div>
</div>
<div id="tab3" class="panel tab3 hidden">
<div class="docbox allwidth">
<h2>T_RECENTCOMMITS</h2>
<p>T_DESCR_RECENTCOMMITS</p>
<div id="commits">T_OFFLINEPLACEHOLDER</div>
<div class="footnote">
<a href="http://github.com/FreeCAD/FreeCAD/commits/master">T_SEEONGITHUB</a>
</div>
</div>
</div>
</div>
</body>
</html>

View File

@@ -1,9 +1,68 @@
var linkDescriptions = [];
var allowDownloads = 0;
function toggle(tab) {
// switch to the given tab ID ("tab1", "tab2", etc...)
var tabs = document.getElementById("tabs").childElementCount;
document.getElementById(tab).classList.remove("hidden");
document.getElementById("h"+tab).classList.add("active");
for (var i = 1; i <= tabs; i++) {
if ("tab"+i != tab) {
document.getElementById("tab"+i).classList.add("hidden");
document.getElementById("htab"+i).classList.remove("active");
}
}
}
function load() {
if (allowDownloads == 1) {
// load latest commits
ddiv = document.getElementById("commits");
ddiv.innerHTML = "Connecting...";
var tobj=new JSONscriptRequest('https://api.github.com/repos/FreeCAD/FreeCAD/commits?callback=printCommits');
tobj.buildScriptTag(); // Build the script tag
tobj.addScriptTag(); // Execute (add) the script tag
ddiv.innerHTML = "Downloading latest news...";
// load addons list
ddiv = document.getElementById("addons");
ddiv.innerHTML = "Connecting...";
var tobj=new JSONscriptRequest('https://api.github.com/repos/FreeCAD/FreeCAD-addons/contents?callback=printAddons');
tobj.buildScriptTag(); // Build the script tag
tobj.addScriptTag(); // Execute (add) the script tag
ddiv.innerHTML = "Downloading addons list...";
}
}
function printCommits(data) {
ddiv = document.getElementById('commits');
ddiv.innerHTML = "Received";
var html = ['<ul>'];
for (var i = 0; i < 25; i++) {
html.push('<li><a href="', data.data[i].html_url, '">', data.data[i].commit.message, '</a> ', data.data[i].commit.committer.date.split("T")[0], ' - ', data.data[i].commit.author.name, '</li>');
}
html.push('</ul>');
ddiv.innerHTML = html.join('');
}
function printAddons(data) {
ddiv = document.getElementById('addons');
ddiv.innerHTML = "Received";
var html = ['<ul class="addonslist">'];
var blacklist = ['addons_installer.FCMacro','FreeCAD-Addon-Details.md','README.md'];
for (var i = 0; i < data.data.length; i++) {
if ( (data.data[i].name[0] != ".") && (blacklist.indexOf(data.data[i].name) < 0) ) {
html.push('<li><a href="', data.data[i].html_url, '">', data.data[i].name, '</a></li>');
}
}
html.push('</ul>');
ddiv.innerHTML = html.join('');
}
// below are JSON helper functions
function JSONscriptRequest(fullUrl) {
// REST request path
this.fullUrl = fullUrl;
this.fullUrl = fullUrl;
// Get the DOM location to put the script tag
this.headLoc = document.getElementsByTagName("head").item(0);
// Generate a unique script tag id
@@ -25,154 +84,10 @@ JSONscriptRequest.prototype.buildScriptTag = function () {
JSONscriptRequest.prototype.removeScriptTag = function () {
// Destroy the script tag
this.headLoc.removeChild(this.scriptObj);
this.headLoc.removeChild(this.scriptObj);
}
JSONscriptRequest.prototype.addScriptTag = function () {
// Create the script tag
this.headLoc.appendChild(this.scriptObj);
}
function show(theText) {
ddiv = document.getElementById("description");
if (theText == "") theText = "&nbsp;";
ddiv.innerHTML = theText;
}
function checkVersion(data) {
vdiv = document.getElementById("versionbox");
console.log('test');
var cmajor = vmajor;
var cminor = vminor;
var cbuild = vbuild;
var amajor = data[0]['major'];
var aminor = data[0]['minor'];
var abuild = data[0]['build'];
if (cmajor >= amajor && cminor >= aminor && cbuild >= abuild) {
vdiv.innerHTML=" text58: vmajor.vminor.vbuild";
} else {
vdiv.innerHTML="<a href=exthttp://github.com/FreeCAD/FreeCAD/releases/latest>text59:"+amajor+"."+aminor+"."+abuild+"</a>";
}
}
function load() {
ddiv = document.getElementById("news");
if (allowDownloads == 0) {
ddiv.innerHTML = '<a href="EnableDownload.py" onClick="enableDownloads()">text70</a> text71';
return;
}
// load latest news
ddiv.innerHTML = "Connecting...";
var tobj=new JSONscriptRequest('https://api.github.com/repos/FreeCAD/FreeCAD/commits?callback=showTweets');
tobj.buildScriptTag(); // Build the script tag
tobj.addScriptTag(); // Execute (add) the script tag
ddiv.innerHTML = "Downloading latest news...";
// load version
var script = document.createElement('script');
script.src = 'http://www.freecadweb.org/version.php?callback=checkVersion';
document.body.appendChild(script);
}
function stripTags(text) {
// from http://www.pagecolumn.com/tool/all_about_html_tags.htm /<\s*\/?\s*span\s*.*?>/g
stripped = text.replace("<table", "<div");
stripped = stripped.replace("</table", "</div");
stripped = stripped.replace("<tr", "<tr");
stripped = stripped.replace("</tr", "</tr");
stripped = stripped.replace("<td", "<td");
stripped = stripped.replace("</td", "</td");
stripped = stripped.replace("555px", "auto");
stripped = stripped.replace("border:1px", "border:0px");
stripped = stripped.replace("color:#000000;","");
return stripped;
}
function showTweets(data) {
ddiv = document.getElementById('news');
if (allowDownloads == 0) {
ddiv.innerHTML = '<a href="EnableDownload.py" onClick="enableDownloads()">text70</a> text71';
return;
}
ddiv.innerHTML = "Received";
var html = ['<ul>'];
for (var i = 0; i < 4; i++) {
html.push('<li><img src="images/web.png">&nbsp;<a href="ext', data.data[i].commit.url, '" onMouseOver="showDescr(', i+1, ')" onMouseOut="showDescr()">', data.data[i].commit.message, '</a></li>');
if ("message" in data.data[i].commit) {
linkDescriptions.push(stripTags(data.data[i].commit.message)+'<br/>'+data.data[i].commit.author.name+'<br/>'+data.data[i].commit.author.date);
} else {
linkDescriptions.push("");
}
}
html.push('</ul>');
html.push('<a href="exthttp://github.com/FreeCAD/FreeCAD/commits/master">text63<a/>');
ddiv.innerHTML = html.join('');
resize();
resize(); // intentional javascript hack
}
function enableDownloads() {
allowDownloads = 1;
// load latest news
ddiv = document.getElementById("news");
ddiv.innerHTML = "Connecting...";
var tobj=new JSONscriptRequest('https://api.github.com/repos/FreeCAD/FreeCAD/commits?callback=showTweets');
tobj.buildScriptTag(); // Build the script tag
tobj.addScriptTag(); // Execute (add) the script tag
ddiv.innerHTML = "Downloading latest news...";
}
function showDescr(d) {
if (d) {
show(linkDescriptions[d-1]);
} else {
show("");
}
}
function scroller() {
desc = document.getElementById("description");
base = document.getElementById("column").offsetTop;
scro = window.scrollY;
if (scro > base) {
desc.className = "stick";
} else {
desc.className = "";
}
}
function resize() {
var halfblocks = document.getElementsByClassName('half-block');
var commits = document.getElementById("commits");
var examples = document.getElementById("examples");
var files = document.getElementById("files");
var newproj = document.getElementById('newproject');
var ontheweb = document.getElementById('ontheweb');
var description = document.getElementById("description");
var w = files.offsetWidth;
var filesHeight = files.offsetHeight;
var h1 = newproj.getElementsByTagName('ul')[0].offsetHeight;
var h2 = ontheweb.getElementsByTagName('ul')[0].offsetHeight;
var h3 = examples.getElementsByTagName('ul')[0].offsetHeight;
var h4 = commits.getElementsByTagName('ul')[0].offsetHeight;
var rowTwoHeight = h1 > h2 ? h1 : h2;
var rowThreeHeight = h3 > h4 ? h3 : h4;
rowTwoHeight = rowTwoHeight + 40;
rowThreeHeight = rowThreeHeight + 80;
var totalHeight = rowTwoHeight + rowThreeHeight + filesHeight + 36;
w = w - 45;
for (var i = 0; i < halfblocks.length; i++) {
halfblocks[i].style.width = w/2 + 'px';
}
newproj.style.height = rowTwoHeight + 'px';
ontheweb.style.height = rowTwoHeight + 'px';
examples.style.height = rowThreeHeight + 'px';
commits.style.height = rowThreeHeight + 'px';
description.style.height = totalHeight + 'px';
}
document.onmousemove=scroller;

View File

@@ -1,7 +1,6 @@
#***************************************************************************
#* *
#* Copyright (c) 2012 *
#* Yorik van Havre <yorik@uncreated.net> *
#* Copyright (c) 2018 Yorik van Havre <yorik@uncreated.net> *
#* *
#* This program is free software; you can redistribute it and/or modify *
#* it under the terms of the GNU Lesser General Public License (LGPL) *
@@ -21,62 +20,64 @@
#* *
#***************************************************************************
# This is the start page template
import os,FreeCAD,FreeCADGui,tempfile,time,zipfile,urllib,re
from PySide import QtGui
from xml.etree.ElementTree import parse
# This is the start page template. It builds a HTML global variable that contains
# the html code of the start page. It is built only once per FreeCAD session for now...
from .TranslationTexts import (text01, text02, text03, text04, text05, text06,
text07, text08, text09, text10, text11, text12,
text13, text14, text15, text16, text17, text18,
text19, text20, text21, text22, text23, text24,
text25, text26, text27, text28, text29, text30,
text31, text32, text33, text34, text35, text36,
text37, text38, text39, text40, text41, text42,
text43, text44, text45, text46, text47, text48,
text49, text50, text51, text52, text53, text54,
text55, text56, text57, text58, text59, text60,
text61, text62, text63, text64, text65, text66,
text67, text68, text69, text70, text71)
try:
import io as cStringIO
except:
import cStringIO
import sys,os,FreeCAD,FreeCADGui,tempfile,time,zipfile,urllib,re,TranslationTexts
from PySide import QtCore,QtGui
FreeCADGui.addLanguagePath(":/translations")
FreeCADGui.updateLocale()
# get FreeCAD version
v = FreeCAD.Version()
vmajor, vminor = v[0], v[1]
vbuild = v[2].split(" ")[0]
iconprovider = QtGui.QFileIconProvider()
iconbank = {} # to store already created icons
# here is the html page skeleton
resources_dir = os.path.join(FreeCAD.getResourceDir(), "Mod", "Start", "StartPage")
html_filename = os.path.join(resources_dir, "StartPage.html")
js_filename = os.path.join(resources_dir, "StartPage.js")
css_filename = os.path.join(resources_dir, "StartPage.css")
with open(html_filename, 'r') as f:
startpage_html = f.read()
with open(js_filename, 'r') as f:
startpage_js = f.read()
def gethexcolor(color):
"returns a color hex value #000000"
r = str(hex(int(((color>>24)&0xFF))))[2:].zfill(2)
g = str(hex(int(((color>>16)&0xFF))))[2:].zfill(2)
b = str(hex(int(((color>>8)&0xFF))))[2:].zfill(2)
return "#"+r+g+b
def isplainfile(filename):
"check if this is any type we don't want to show"
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":
return False
if basename.endswith("~"):
return False
if basename.lower().endswith(".bak"):
return False
return True
with open(css_filename, 'r') as f:
startpage_css = f.read()
def getInfo(filename):
"returns available file information"
global iconbank
def getLocalTime(timestamp):
"returns a local time from a timestamp"
"returns a local time from a timestamp"
return time.strftime("%m/%d/%Y %H:%M:%S",time.localtime(timestamp))
def getSize(size):
"returns a human-readable size"
"returns a human-readable size"
if size > 1024*1024:
hsize = str(size/(1024*1024)) + "Mb"
elif size > 1024:
@@ -84,234 +85,353 @@ def getInfo(filename):
else:
hsize = str(size) + "b"
return hsize
html = '<h3>'+os.path.basename(filename)+'</h3>'
if os.path.exists(filename):
# get normal file info
s = os.stat(filename)
html += "<p>" + text33 + " " + getSize(s.st_size) + "<br/>"
html += text34 + " " + getLocalTime(s.st_ctime) + "<br/>"
html += text35 + " " + getLocalTime(s.st_mtime) + "<br/>"
html += "<span>" + text36 + " " + filename + "</span></p>"
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
image = None
# get additional info from fcstd files
if os.path.splitext(filename)[1].upper() in [".FCSTD"]:
if filename.lower().endswith(".fcstd"):
zfile=zipfile.ZipFile(filename)
files=zfile.namelist()
# check for meta-file if it's really a FreeCAD document
if files[0] == "Document.xml":
html += "<p><b>" + text65 + "</b></p>"
image="thumbnails/Thumbnail.png"
doc = str(zfile.read(files[0]))
doc = doc.replace("\n"," ")
author = re.findall("Property name=\"CreatedBy.*?String value=\"(.*?)\"\/>",doc)
if author:
html += "<p>" + text66 + ": " + author[0] + "</p>"
company = re.findall("Property name=\"Company.*?String value=\"(.*?)\"\/>",doc)
if company:
html += "<p>" + text67 + ": " + company[0] + "</p>"
lic = re.findall("Property name=\"License.*?String value=\"(.*?)\"\/>",doc)
if lic:
html += "<p>" + text68 + ": " + lic[0] + "</p>"
if image in files:
image=zfile.read(image)
thumbfile = tempfile.mkstemp(suffix='.png')[1]
thumb = open(thumbfile,"wb")
thumb.write(image)
thumb.close()
html += '<img src=file://'
html += thumbfile + '><br/>'
else:
print ("not a freecad file: "+os.path.splitext(filename)[1].upper())
else:
html += "<p>" + text41 + "</p>"
return html
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
if "thumbnails/Thumbnail.png" in files:
if filename in iconbank:
image = iconbank[filename]
else:
imagedata=zfile.read("thumbnails/Thumbnail.png")
image = tempfile.mkstemp(suffix='.png')[1]
thumb = open(image,"wb")
thumb.write(imagedata)
thumb.close()
iconbank[filename] = image
def getRecentFiles():
"returns a list of 3 latest recent files"
rf = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/RecentFiles")
ct = rf.GetInt("RecentFiles")
html = '<ul>'
for i in range(4):
if i < ct:
mr = rf.GetString("MRU%d" % (i))
if os.path.exists(mr):
fn = os.path.basename(mr)
html += '<li>'
if mr[-5:].upper() == "FCSTD":
html += '<img src="images/freecad-doc.png" style="width: 16px">&nbsp;'
else:
html += '<img src="images/blank.png" style="width: 16px">&nbsp;'
html += '<a '
html += 'onMouseover="show(\''+getInfo(mr).replace("'","&rsquo;")+'\')" '
html += 'onMouseout="show(\'\')" '
html += 'href="LoadMRU'+str(i)+'.py">'
html += fn
html += '</a></li>'
# retrieve default mime icon if needed
if not image:
i = QtCore.QFileInfo(filename)
t = iconprovider.type(i)
if t in iconbank:
image = iconbank[t]
else:
fn = os.path.basename(mr)
html += '<li>'
if mr[-5:].upper() == "FCSTD":
html += '<img src="images/freecad-doc.png" style="width: 16px">&nbsp;'
else:
html += '<img src="images/blank.png" style="width: 16px">&nbsp;'
html += '<span class="disabled">'
html += fn
html += '</span></li>'
html += '</ul>'
return html
icon = iconprovider.icon(i)
px = icon.pixmap(128,128)
image = tempfile.mkstemp(suffix='.png')[1]
px.save(image)
iconbank[t] = image
def getFeed(url,numitems=3):
"returns a html list with links from the given RSS feed url"
xml = parse(urllib.urlopen(url)).getroot()
items = []
channel = xml.find('channel')
for element in channel.findall('item'):
items.append({'title': element.find('title').text,
'description': element.find('description').text,
'link': element.find('link').text})
if len(items) > numitems:
items = items[:numitems]
resp = '<ul>'
for item in items:
descr = re.compile("style=\".*?\"").sub('',item['description'])
descr = re.compile("alt=\".*?\"").sub('',descr)
descr = re.compile("\"").sub('',descr)
d1 = re.findall("<img.*?>",descr)[0]
d2 = re.findall("<span>.*?</span>",descr)[0]
descr = "<h3>" + item['title'] + "</h3>"
descr += d1 + "<br/>"
descr += d2
resp += '<li><a onMouseover="show(\''
resp += descr
resp += '\')" onMouseout="show(\'\')" href="'
resp += item['link']
resp += '">'
resp += item['title']
resp += '</a></li>'
resp += '</ul>'
print(resp)
return resp
return image,size,author
def getCustomBlocks():
"fetches custom html files in FreeCAD user dir"
output = ""
return output
return None,None,None
def setColors(html):
"gets theme colors from the system, and sets appropriate styles"
defaults = {"#basecolor":"#191B26",
"#linkcolor":"#0092E8",
"#textcolor":"#FFFFFF",
"#windowcolor":"#FFFFFF",
"#windowtextcolor":"#000000"}
try:
palette = QtGui.QApplication.palette()
except:
pass
else:
#defaults["#basecolor"] = palette.base().color().name()
defaults["#basecolor"] = "#171A2B url(images/Background.jpg)"
#defaults["#linkcolor"] = palette.link().color().name() # UGLY!!
defaults["#textcolor"] = palette.text().color().name()
defaults["#windowcolor"] = palette.window().color().name()
defaults["#windowtextcolor"] = palette.windowText().color().name()
for k,v in defaults.items():
html = html.replace(k,str(v))
return html
def insert_page_resources(html):
html = html.replace("startpage_js", startpage_js)
html = html.replace("startpage_css", startpage_css)
return html
def replace_html_text(html):
html = html.replace("text01", text01)
html = html.replace("text02", text02)
html = html.replace("text03", text03)
html = html.replace("text05", text05)
html = html.replace("text06", text06)
html = html.replace("text07", text07)
html = html.replace("text08", text08)
html = html.replace("text09", text09)
html = html.replace("text10", text10)
html = html.replace("text11", text11)
html = html.replace("text12", text12)
html = html.replace("text13", text13)
html = html.replace("text17", text17)
html = html.replace("text18", text18)
html = html.replace("text19", text19)
html = html.replace("text20", text20)
html = html.replace("text21", text21)
html = html.replace("text22", text22)
html = html.replace("text23", text23)
html = html.replace("text24", text24)
html = html.replace("text25", text25)
html = html.replace("text26", text26)
html = html.replace("text27", text27)
html = html.replace("text28", text28)
html = html.replace("text29", text29)
html = html.replace("text37", text37)
html = html.replace("text38", text38)
html = html.replace("text39", text39)
html = html.replace("text40", text40)
html = html.replace("text43", text43)
html = html.replace("text45", text45)
html = html.replace("text46", text46)
html = html.replace("text47", text47)
html = html.replace("text48", text48)
html = html.replace("text49", text49)
html = html.replace("text50", text50)
html = html.replace("text51", text51)
html = html.replace("text52", text52)
html = html.replace("text53", text53)
html = html.replace("text54", text54)
html = html.replace("text55", text55)
html = html.replace("text56", text56)
html = html.replace("text57", text57)
html = html.replace("text60", text60)
html = html.replace("text61", text61)
html = html.replace("text62", text62)
html = html.replace("text64", text64)
html = html.replace("text69", text69)
return html
def replace_js_text(html):
html = html.replace("vmajor", vmajor)
html = html.replace("vminor", vminor)
html = html.replace("vbuild", vbuild)
html = html.replace("text58", text58)
html = html.replace("text59", text59)
html = html.replace("text63", text63)
html = html.replace("text70", text70)
html = html.replace("text71", text71)
return html
def handle():
"returns the complete html startpage"
# add strings into files
html = insert_page_resources(startpage_html)
html = replace_js_text(html)
# add recent files
recentfiles = getRecentFiles()
html = html.replace("recentfiles",recentfiles)
# add custom blocks
html = html.replace("customblocks",getCustomBlocks())
# 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;")
html = replace_html_text(html)
# fetches system colors
html = setColors(html)
return html
"builds the HTML code of the start page"
global iconbank
# build the html page skeleton
resources_dir = os.path.join(FreeCAD.getResourceDir(), "Mod", "Start", "StartPage")
p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Start")
template = p.GetString("Template","")
if template:
html_filename = template
else:
html_filename = os.path.join(resources_dir, "StartPage.html")
js_filename = os.path.join(resources_dir, "StartPage.js")
css_filename = os.path.join(resources_dir, "StartPage.css")
with open(html_filename, 'r') as f:
HTML = f.read()
with open(js_filename, 'r') as f:
JS = f.read()
with open(css_filename, 'r') as f:
CSS = f.read()
HTML = HTML.replace("JS",JS)
HTML = HTML.replace("CSS",CSS)
# 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)
HTML = HTML.replace("T_USERHUB",TranslationTexts.T_USERHUB)
HTML = HTML.replace("T_DESCR_USERHUB",TranslationTexts.T_DESCR_USERHUB)
HTML = HTML.replace("T_POWERHUB",TranslationTexts.T_POWERHUB)
HTML = HTML.replace("T_DESCR_POWERHUB",TranslationTexts.T_DESCR_POWERHUB)
HTML = HTML.replace("T_DEVHUB",TranslationTexts.T_DEVHUB)
HTML = HTML.replace("T_DESCR_DEVHUB",TranslationTexts.T_DESCR_DEVHUB)
HTML = HTML.replace("T_MANUAL",TranslationTexts.T_MANUAL)
HTML = HTML.replace("T_DESCR_MANUAL",TranslationTexts.T_DESCR_MANUAL)
HTML = HTML.replace("T_WBHELP",TranslationTexts.T_WBHELP)
HTML = HTML.replace("T_DESCR_WBHELP",TranslationTexts.T_DESCR_WBHELP)
HTML = HTML.replace("T_COMMUNITYHELP",TranslationTexts.T_COMMUNITYHELP)
HTML = HTML.replace("T_DESCR_COMMUNITYHELP",TranslationTexts.T_DESCR_COMMUNITYHELP)
HTML = HTML.replace("T_ADDONS",TranslationTexts.T_ADDONS)
HTML = HTML.replace("T_DESCR_ADDONS",TranslationTexts.T_DESCR_ADDONS)
HTML = HTML.replace("T_OFFLINEHELP",TranslationTexts.T_OFFLINEHELP)
HTML = HTML.replace("T_OFFLINEPLACEHOLDER",TranslationTexts.T_OFFLINEPLACEHOLDER)
HTML = HTML.replace("T_RECENTCOMMITS",TranslationTexts.T_RECENTCOMMITS)
HTML = HTML.replace("T_DESCR_RECENTCOMMITS",TranslationTexts.T_DESCR_RECENTCOMMITS)
HTML = HTML.replace("T_SEEONGITHUB",TranslationTexts.T_SEEONGITHUB)
HTML = HTML.replace("T_CUSTOM",TranslationTexts.T_CUSTOM)
# build a "create new" icon with the FreeCAD background color gradient
if not "createimg" in iconbank:
p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/View")
c1 = gethexcolor(p.GetUnsigned("BackgroundColor2"))
c2 = gethexcolor(p.GetUnsigned("BackgroundColor3"))
gradient = QtGui.QLinearGradient(0, 0, 0, 128)
gradient.setColorAt(0.0, QtGui.QColor(c1))
gradient.setColorAt(1.0, QtGui.QColor(c2))
i = QtGui.QImage(128,128,QtGui.QImage.Format_RGB16)
pa = QtGui.QPainter(i)
pa.fillRect(i.rect(),gradient)
pa.end()
createimg = tempfile.mkstemp(suffix='.png')[1]
i.save(createimg)
iconbank["createimg"] = createimg
# build UL_RECENTFILES
rf = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/RecentFiles")
rfcount = rf.GetInt("RecentFiles",0)
if rfcount:
UL_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>'
if sys.version_info.major < 3:
UL_RECENTFILES = UL_RECENTFILES.decode("utf8")
HTML = HTML.replace("UL_RECENTFILES",UL_RECENTFILES)
# build SECTION_EXAMPLES
SECTION_EXAMPLES = ""
if FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Start").GetBool("ShowExamples",True):
SECTION_EXAMPLES = "<h2>"+TranslationTexts.T_EXAMPLES+"</h2>"
SECTION_EXAMPLES += "<ul>"
for basename in os.listdir(FreeCAD.getResourceDir()+"examples"):
filename = FreeCAD.getResourceDir()+"examples"+os.sep+basename
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 += "</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 = ""
cfolder = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Start").GetString("ShowCustomFolder","")
if cfolder:
if not os.path.isdir(cfolder):
cfolder = os.path.dirname(cfolder)
SECTION_CUSTOM = "<h2>"+os.path.basename(os.path.normpath(cfolder))+"</h2>"
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 += "</ul>"
if sys.version_info.major < 3:
SECTION_CUSTOM = SECTION_CUSTOM.decode("utf8")
HTML = HTML.replace("SECTION_CUSTOM",SECTION_CUSTOM)
# build UL_WORKBENCHES
UL_WORKBENCHES = '<ul class="workbenches">'
FreeCAD.getResourceDir()
for wb in FreeCADGui.listWorkbenches().keys():
if wb.endswith("Workbench"):
wn = wb[:-9]
if wb in iconbank:
img = iconbank[wb]
else:
img = os.path.join(FreeCAD.getResourceDir(),"data","Mod",wn,"Resources","icons",wn+"Workbench.svg")
if not os.path.exists(img):
w = FreeCADGui.listWorkbenches()[wb]
if hasattr(w,"Icon"):
xpm = w.Icon
if "XPM" in xpm:
r = [s[:-1].strip('"') for s in re.findall("(?s)\{(.*?)\};",xpm)[0].split("\n")[1:]]
p = QtGui.QPixmap(r)
p = p.scaled(24,24)
img = tempfile.mkstemp(suffix='.png')[1]
p.save(img)
else:
img = xpm
else:
img="images/freecad.png"
iconbank[wb] = img
UL_WORKBENCHES += '<li><h3>'
UL_WORKBENCHES += '<img src="'+iconbank[wb]+'">'
UL_WORKBENCHES += '<a href="https://www.freecadweb.org/wiki/'+wn+'_Workbench">'+wn+'</a>'
UL_WORKBENCHES += '</h3></li>'
UL_WORKBENCHES += '</ul>'
HTML = HTML.replace("UL_WORKBENCHES",UL_WORKBENCHES)
# set and replace colors
p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Start")
if p.GetString("BackgroundImage",""):
BACKGROUND = gethexcolor(p.GetUnsigned("BackgroundColor1",1331197183))+" url("+p.GetString("BackgroundImage","")+")"
else:
BACKGROUND = gethexcolor(p.GetUnsigned("BackgroundColor1",1331197183))
# linear gradient not supported by QT "linear-gradient("+gethexcolor(p.GetUnsigned("BackgroundColor1",1331197183))+","+gethexcolor(p.GetUnsigned("BackgroundColor2",2141107711))+")"
LINKCOLOR = gethexcolor(p.GetUnsigned("LinkColor",65535))
BASECOLOR = gethexcolor(p.GetUnsigned("PageColor",4294967295))
BOXCOLOR = gethexcolor(p.GetUnsigned("BoxColor",3722305023))
TEXTCOLOR = gethexcolor(p.GetUnsigned("PageTextColor",255))
BGTCOLOR = gethexcolor(p.GetUnsigned("BackgroundTextColor",4294703103))
SHADOW = "#888888"
if QtGui.QColor(BASECOLOR).valueF() < 0.5: # dark page
SHADOW = "#000000"
HTML = HTML.replace("BASECOLOR",BASECOLOR)
HTML = HTML.replace("BOXCOLOR",BOXCOLOR)
HTML = HTML.replace("LINKCOLOR",LINKCOLOR)
HTML = HTML.replace("TEXTCOLOR",TEXTCOLOR)
HTML = HTML.replace("BGTCOLOR",BGTCOLOR)
HTML = HTML.replace("BACKGROUND",BACKGROUND)
HTML = HTML.replace("SHADOW",SHADOW)
# 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;")
# encode if necessary
if sys.version_info.major < 3:
if isinstance(HTML,unicode):
HTML = HTML.encode("utf8")
return HTML
def exportTestFile():
"Allow to check if everything is Ok"
f = open(os.path.expanduser("~")+os.sep+"freecad-startpage.html","wb")
f.write(handle())
f.close()
def postStart():
"executes needed operations after loading a file"
param = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Start")
# switch workbench
wb = param.GetString("AutoloadModule","")
if wb:
FreeCADGui.activateWorkbench(wb)
# close start tab
cl = param.GetBool("closeStart",False)
if cl:
title = QtGui.QApplication.translate("Workbench","Start page")
mw = FreeCADGui.getMainWindow()
if mw:
mdi = mw.findChild(QtGui.QMdiArea)
if mdi:
for mdichild in mdi.children():
for subw in mdichild.findChildren(QtGui.QMdiSubWindow):
if subw.windowTitle() == title:
subw.close()

File diff suppressed because one or more lines are too long

Binary file not shown.

Before

Width:  |  Height:  |  Size: 789 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 99 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 753 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 65 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 838 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 396 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 666 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -0,0 +1,462 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Form</class>
<widget class="QWidget" name="Form">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>500</width>
<height>507</height>
</rect>
</property>
<property name="windowTitle">
<string>Start page options</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Start page template</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="Gui::PrefFileChooser" name="fileChooser_1">
<property name="toolTip">
<string>An optional HTML template that will be used instead of the default start page.</string>
</property>
<property name="prefEntry" stdset="0">
<cstring>Template</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>Start page options</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="1" alignment="Qt::AlignRight">
<widget class="Gui::PrefColorButton" name="colorButton_7">
<property name="enabled">
<bool>false</bool>
</property>
<property name="maximumSize">
<size>
<width>60</width>
<height>60</height>
</size>
</property>
<property name="toolTip">
<string>the down gradient for the background color (currently unsupported)</string>
</property>
<property name="color">
<color>
<red>127</red>
<green>158</green>
<blue>181</blue>
</color>
</property>
<property name="prefEntry" stdset="0">
<cstring>BackgroundColor2</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Start</cstring>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Link color</string>
</property>
</widget>
</item>
<item row="5" column="1" alignment="Qt::AlignRight">
<widget class="Gui::PrefColorButton" name="colorButton_3">
<property name="maximumSize">
<size>
<width>60</width>
<height>60</height>
</size>
</property>
<property name="toolTip">
<string>the background of the main start page area</string>
</property>
<property name="color">
<color>
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</property>
<property name="prefEntry" stdset="0">
<cstring>PageColor</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Start</cstring>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Box background color</string>
</property>
</widget>
</item>
<item row="8" column="1" alignment="Qt::AlignRight">
<widget class="Gui::PrefColorButton" name="colorButton_6">
<property name="maximumSize">
<size>
<width>60</width>
<height>60</height>
</size>
</property>
<property name="toolTip">
<string>the color of the links</string>
</property>
<property name="color">
<color>
<red>0</red>
<green>0</green>
<blue>255</blue>
</color>
</property>
<property name="prefEntry" stdset="0">
<cstring>LinkColor</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Start</cstring>
</property>
</widget>
</item>
<item row="4" column="1" alignment="Qt::AlignRight">
<widget class="Gui::PrefColorButton" name="colorButton_2">
<property name="maximumSize">
<size>
<width>60</width>
<height>60</height>
</size>
</property>
<property name="toolTip">
<string>the color of the version text</string>
</property>
<property name="color">
<color>
<red>255</red>
<green>251</green>
<blue>247</blue>
</color>
</property>
<property name="prefEntry" stdset="0">
<cstring>BackgroundTextColor</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Start</cstring>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Background image</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Background color</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Page text color</string>
</property>
</widget>
</item>
<item row="6" column="1" alignment="Qt::AlignRight">
<widget class="Gui::PrefColorButton" name="colorButton_4">
<property name="maximumSize">
<size>
<width>60</width>
<height>60</height>
</size>
</property>
<property name="toolTip">
<string>the color of the text on he main pages</string>
</property>
<property name="color">
<color>
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</property>
<property name="prefEntry" stdset="0">
<cstring>PageTextColor</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Start</cstring>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="Gui::PrefFileChooser" name="fileChooser_2">
<property name="toolTip">
<string>an optional image to display as background</string>
</property>
<property name="prefEntry" stdset="0">
<cstring>BackgroundImage</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Start</cstring>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Page background color</string>
</property>
</widget>
</item>
<item row="10" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Show examples folder contents</string>
</property>
</widget>
</item>
<item row="11" 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>
</property>
<property name="prefEntry" stdset="0">
<cstring>ShowCustomFolder</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Start</cstring>
</property>
</widget>
</item>
<item row="11" column="0">
<widget class="QLabel" name="label_10">
<property name="text">
<string>Show additional folder</string>
</property>
</widget>
</item>
<item row="7" column="1" alignment="Qt::AlignRight">
<widget class="Gui::PrefColorButton" name="colorButton_5">
<property name="maximumSize">
<size>
<width>60</width>
<height>60</height>
</size>
</property>
<property name="toolTip">
<string>the background color of the boxes inside the pages</string>
</property>
<property name="color">
<color>
<red>221</red>
<green>221</green>
<blue>221</blue>
</color>
</property>
<property name="prefEntry" stdset="0">
<cstring>BoxColor</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Start</cstring>
</property>
</widget>
</item>
<item row="0" column="1" alignment="Qt::AlignRight">
<widget class="Gui::PrefColorButton" name="colorButton_1">
<property name="maximumSize">
<size>
<width>60</width>
<height>60</height>
</size>
</property>
<property name="toolTip">
<string>the background color behind the panels</string>
</property>
<property name="color">
<color>
<red>79</red>
<green>88</green>
<blue>116</blue>
</color>
</property>
<property name="prefEntry" stdset="0">
<cstring>BackgroundColor1</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Start</cstring>
</property>
</widget>
</item>
<item row="9" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="Gui::PrefRadioButton" name="radioButton_2">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>in same page</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>InBrowser</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Start</cstring>
</property>
</widget>
</item>
<item>
<widget class="Gui::PrefRadioButton" name="radioButton_1">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>in external browser</string>
</property>
<property name="prefEntry" stdset="0">
<cstring>InWeb</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Start</cstring>
</property>
</widget>
</item>
</layout>
</item>
<item row="10" 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="4" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Background text color</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_gradientDown">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Background color gradient down</string>
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="QLabel" name="label_links">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Open links</string>
</property>
</widget>
</item>
<item row="12" column="0">
<widget class="QLabel" name="autoModuleLabel">
<property name="text">
<string>Switch workbench after loading a file</string>
</property>
</widget>
</item>
<item row="12" column="1">
<widget class="QComboBox" name="AutoloadModuleCombo"/>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>Gui::FileChooser</class>
<extends>QWidget</extends>
<header>Gui/FileDialog.h</header>
</customwidget>
<customwidget>
<class>Gui::ColorButton</class>
<extends>QPushButton</extends>
<header>Gui/Widgets.h</header>
</customwidget>
<customwidget>
<class>Gui::PrefFileChooser</class>
<extends>Gui::FileChooser</extends>
<header>Gui/PrefWidgets.h</header>
</customwidget>
<customwidget>
<class>Gui::PrefColorButton</class>
<extends>Gui::ColorButton</extends>
<header>Gui/PrefWidgets.h</header>
</customwidget>
<customwidget>
<class>Gui::PrefRadioButton</class>
<extends>QRadioButton</extends>
<header>Gui/PrefWidgets.h</header>
</customwidget>
<customwidget>
<class>Gui::PrefCheckBox</class>
<extends>QCheckBox</extends>
<header>Gui/PrefWidgets.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>