Added preference setting to set default Author & License - fixes #1883
* added fields in Prefereces->Default->Document * new documents take the values of those fields
This commit is contained in:
parent
17a85e4352
commit
645d176a13
|
@ -595,13 +595,17 @@ Document::Document(void)
|
|||
Console().Log("+App::Document: %p\n",this);
|
||||
#endif
|
||||
std::string CreationDateString = Base::TimeInfo::currentDateTimeString();
|
||||
std::string Author = App::GetApplication().GetParameterGroupByPath
|
||||
("User parameter:BaseApp/Preferences/Document")->GetASCII("prefAuthor","");
|
||||
std::string AuthorComp = App::GetApplication().GetParameterGroupByPath
|
||||
("User parameter:BaseApp/Preferences/Document")->GetASCII("prefCompany","");
|
||||
ADD_PROPERTY_TYPE(Label,("Unnamed"),0,Prop_None,"The name of the document");
|
||||
ADD_PROPERTY_TYPE(FileName,(""),0,Prop_ReadOnly,"The path to the file where the document is saved to");
|
||||
ADD_PROPERTY_TYPE(CreatedBy,(""),0,Prop_None,"The creator of the document");
|
||||
ADD_PROPERTY_TYPE(CreatedBy,(Author.c_str()),0,Prop_None,"The creator of the document");
|
||||
ADD_PROPERTY_TYPE(CreationDate,(CreationDateString.c_str()),0,Prop_ReadOnly,"Date of creation");
|
||||
ADD_PROPERTY_TYPE(LastModifiedBy,(""),0,Prop_None,0);
|
||||
ADD_PROPERTY_TYPE(LastModifiedDate,("Unknown"),0,Prop_ReadOnly,"Date of last modification");
|
||||
ADD_PROPERTY_TYPE(Company,(""),0,Prop_None,"Additional tag to save the the name of the company");
|
||||
ADD_PROPERTY_TYPE(Company,(AuthorComp.c_str()),0,Prop_None,"Additional tag to save the the name of the company");
|
||||
ADD_PROPERTY_TYPE(Comment,(""),0,Prop_None,"Additional tag to save a comment");
|
||||
ADD_PROPERTY_TYPE(Meta,(),0,Prop_None,"Map with additional meta information");
|
||||
ADD_PROPERTY_TYPE(Material,(),0,Prop_None,"Map with material properties");
|
||||
|
@ -611,8 +615,44 @@ Document::Document(void)
|
|||
ADD_PROPERTY_TYPE(Uid,(id),0,Prop_ReadOnly,"UUID of the document");
|
||||
|
||||
// license stuff
|
||||
ADD_PROPERTY_TYPE(License,("CC-BY 3.0"),0,Prop_None,"License string of the Item");
|
||||
ADD_PROPERTY_TYPE(LicenseURL,("http://creativecommons.org/licenses/by/3.0/"),0,Prop_None,"URL to the license text/contract");
|
||||
int licenseId = App::GetApplication().GetParameterGroupByPath
|
||||
("User parameter:BaseApp/Preferences/Document")->GetInt("prefLicenseType",0);
|
||||
std::string license;
|
||||
switch (licenseId) {
|
||||
case 0:
|
||||
license = "All rights reserved";
|
||||
break;
|
||||
case 1:
|
||||
license = "CreativeCommons Attribution";
|
||||
break;
|
||||
case 2:
|
||||
license = "CreativeCommons Attribution-ShareAlike";
|
||||
break;
|
||||
case 3:
|
||||
license = "CreativeCommons Attribution-NoDerivatives";
|
||||
break;
|
||||
case 4:
|
||||
license = "CreativeCommons Attribution-NonCommercial";
|
||||
break;
|
||||
case 5:
|
||||
license = "CreativeCommons Attribution-NonCommercial-ShareAlike";
|
||||
break;
|
||||
case 6:
|
||||
license = "CreativeCommons Attribution-NonCommercial-NoDerivatives";
|
||||
break;
|
||||
case 7:
|
||||
license = "Public Domain";
|
||||
break;
|
||||
case 8:
|
||||
license = "FreeArt";
|
||||
break;
|
||||
default:
|
||||
license = "Other";
|
||||
}
|
||||
std::string licenseUrl = App::GetApplication().GetParameterGroupByPath
|
||||
("User parameter:BaseApp/Preferences/Document")->GetASCII("prefLicenseUrl","http://en.wikipedia.org/wiki/All_rights_reserved");
|
||||
ADD_PROPERTY_TYPE(License,(license.c_str()),0,Prop_None,"License string of the Item");
|
||||
ADD_PROPERTY_TYPE(LicenseURL,(licenseUrl.c_str()),0,Prop_None,"URL to the license text/contract");
|
||||
|
||||
// this creates and sets 'TransientDir' in onChanged()
|
||||
ADD_PROPERTY_TYPE(TransientDir,(""),0,PropertyType(Prop_Transient|Prop_ReadOnly),
|
||||
|
@ -951,6 +991,14 @@ bool Document::save (void)
|
|||
if (*(FileName.getValue()) != '\0') {
|
||||
std::string LastModifiedDateString = Base::TimeInfo::currentDateTimeString();
|
||||
LastModifiedDate.setValue(LastModifiedDateString.c_str());
|
||||
// set author if needed
|
||||
bool saveAuthor = App::GetApplication().GetParameterGroupByPath
|
||||
("User parameter:BaseApp/Preferences/Document")->GetBool("prefSetAuthorOnSave",false);
|
||||
if (saveAuthor) {
|
||||
std::string Author = App::GetApplication().GetParameterGroupByPath
|
||||
("User parameter:BaseApp/Preferences/Document")->GetASCII("prefAuthor","");
|
||||
LastModifiedBy.setValue(Author.c_str());
|
||||
}
|
||||
// make a tmp. file where to save the project data first and then rename to
|
||||
// the actual file name. This may be useful if overwriting an existing file
|
||||
// fails so that the data of the work up to now isn't lost.
|
||||
|
|
|
@ -6,14 +6,27 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>470</width>
|
||||
<height>423</height>
|
||||
<width>500</width>
|
||||
<height>593</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Document</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="4" column="0">
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>429</width>
|
||||
<height>37</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QGroupBox" name="GroupBox5">
|
||||
<property name="title">
|
||||
|
@ -92,10 +105,10 @@
|
|||
<property name="text">
|
||||
<string>Create new document at start up</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>CreateNewDoc</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
|
@ -134,10 +147,10 @@
|
|||
<property name="text">
|
||||
<string>Using Undo/Redo on documents</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>UsingUndo</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
|
@ -293,30 +306,207 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
<widget class="QGroupBox" name="groupBox_3">
|
||||
<property name="title">
|
||||
<string>Authoring and License</string>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>429</width>
|
||||
<height>37</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Author name</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Gui::PrefLineEdit" name="prefAuthor">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>The name to use on document creation.</p><p>Keep blank for anonymous.</p><p>You can also use the form:</p><p>John Doe &lt;john@doe.com&gt;</p></body></html></string>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>prefAuthor</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Document</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Gui::PrefCheckBox" name="prefSetAuthorOnSave">
|
||||
<property name="toolTip">
|
||||
<string>If this is checked, the "Last modified by" field will be set when saving the file</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Set on save</string>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>prefSetAuthorOnSave</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Document</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Company</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Gui::PrefLineEdit" name="prefCompany">
|
||||
<property name="toolTip">
|
||||
<string>The defautl company to use for new files</string>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>prefCompany</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Document</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Default license</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Gui::PrefComboBox" name="prefLicenseType">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>The default license for new documents</string>
|
||||
</property>
|
||||
<property name="editable">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>prefLicenseType</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Document</cstring>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>All rights reserved</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>CreativeCommons Attribution</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>CreativeCommons Attribution-ShareAlike</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>CreativeCommons Attribution-NoDerivatives</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>CreativeCommons Attribution-NonCommercial</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>CreativeCommons Attribution-NonCommercial-ShareAlike</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>CreativeCommons Attribution-NonCommercial-NoDerivatives</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Public Domain</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>FreeArt</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Other</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>License URL</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Gui::PrefLineEdit" name="prefLicenseUrl">
|
||||
<property name="toolTip">
|
||||
<string>An URL where the user can find more details about the license</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>http://en.wikipedia.org/wiki/All_rights_reserved</string>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>prefLicenseUrl</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Document</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>Gui::PrefSpinBox</class>
|
||||
<extends>QSpinBox</extends>
|
||||
<header>Gui/PrefWidgets.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>Gui::PrefCheckBox</class>
|
||||
<extends>QCheckBox</extends>
|
||||
<header>Gui/PrefWidgets.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>Gui::PrefSpinBox</class>
|
||||
<extends>QSpinBox</extends>
|
||||
<class>Gui::PrefComboBox</class>
|
||||
<extends>QComboBox</extends>
|
||||
<header>Gui/PrefWidgets.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>Gui::PrefLineEdit</class>
|
||||
<extends>QLineEdit</extends>
|
||||
<header>Gui/PrefWidgets.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
|
|
|
@ -43,6 +43,7 @@ DlgSettingsDocumentImp::DlgSettingsDocumentImp( QWidget* parent )
|
|||
prefCountBackupFiles->setMaximum(INT_MAX);
|
||||
prefCompression->setMinimum(Z_NO_COMPRESSION);
|
||||
prefCompression->setMaximum(Z_BEST_COMPRESSION);
|
||||
connect( prefLicenseType, SIGNAL(currentIndexChanged(int)), this, SLOT(on_prefLicenseType_changed(int)) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -67,6 +68,11 @@ void DlgSettingsDocumentImp::saveSettings()
|
|||
prefSaveBackupFiles->onSave();
|
||||
prefCountBackupFiles->onSave();
|
||||
prefDuplicateLabel->onSave();
|
||||
prefLicenseType->onSave();
|
||||
prefLicenseUrl->onSave();
|
||||
prefAuthor->onSave();
|
||||
prefSetAuthorOnSave->onSave();
|
||||
prefCompany->onSave();
|
||||
}
|
||||
|
||||
void DlgSettingsDocumentImp::loadSettings()
|
||||
|
@ -82,6 +88,11 @@ void DlgSettingsDocumentImp::loadSettings()
|
|||
prefSaveBackupFiles->onRestore();
|
||||
prefCountBackupFiles->onRestore();
|
||||
prefDuplicateLabel->onRestore();
|
||||
prefLicenseType->onRestore();
|
||||
prefLicenseUrl->onRestore();
|
||||
prefAuthor->onRestore();
|
||||
prefSetAuthorOnSave->onRestore();
|
||||
prefCompany->onRestore();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -97,4 +108,42 @@ void DlgSettingsDocumentImp::changeEvent(QEvent *e)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the correct URL depending on the license type
|
||||
*/
|
||||
void DlgSettingsDocumentImp::on_prefLicenseType_changed(int index)
|
||||
{
|
||||
switch (index) {
|
||||
case 0:
|
||||
prefLicenseUrl->setText(QString::fromAscii("http://en.wikipedia.org/wiki/All_rights_reserved"));
|
||||
break;
|
||||
case 1:
|
||||
prefLicenseUrl->setText(QString::fromAscii("http://creativecommons.org/licenses/by/4.0/"));
|
||||
break;
|
||||
case 2:
|
||||
prefLicenseUrl->setText(QString::fromAscii("http://creativecommons.org/licenses/by-sa/4.0/"));
|
||||
break;
|
||||
case 3:
|
||||
prefLicenseUrl->setText(QString::fromAscii("http://creativecommons.org/licenses/by-nd/4.0/"));
|
||||
break;
|
||||
case 4:
|
||||
prefLicenseUrl->setText(QString::fromAscii("http://creativecommons.org/licenses/by-nc/4.0/"));
|
||||
break;
|
||||
case 5:
|
||||
prefLicenseUrl->setText(QString::fromAscii("http://creativecommons.org/licenses/by-nc-sa/4.0/"));
|
||||
break;
|
||||
case 6:
|
||||
prefLicenseUrl->setText(QString::fromAscii("http://creativecommons.org/licenses/by-nc-nd/4.0/"));
|
||||
break;
|
||||
case 7:
|
||||
prefLicenseUrl->setText(QString::fromAscii("http://en.wikipedia.org/wiki/Public_domain"));
|
||||
break;
|
||||
case 8:
|
||||
prefLicenseUrl->setText(QString::fromAscii("http://artlibre.org/licence/lal"));
|
||||
break;
|
||||
default:
|
||||
prefLicenseUrl->setText(QString::fromAscii(""));
|
||||
}
|
||||
}
|
||||
|
||||
#include "moc_DlgSettingsDocumentImp.cpp"
|
||||
|
|
|
@ -45,6 +45,9 @@ public:
|
|||
|
||||
void saveSettings();
|
||||
void loadSettings();
|
||||
|
||||
protected Q_SLOTS:
|
||||
void on_prefLicenseType_changed(int index);
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *e);
|
||||
|
|
Loading…
Reference in New Issue
Block a user