Improved handling of document's license

Merged, abandoned or rejected pull requests are moved here to clear the main Pull Requests forum.
User avatar
f3nix
Posts: 319
Joined: Sat May 30, 2015 11:58 am

Improved handling of document's license

Postby f3nix » Sun Sep 06, 2015 4:56 pm

Hi,
this is a small improvement of document's license handling.
* One can edit the "Other" license URL.
* The document does not get the "All rights reserved" licence by default.

The following changes since commit de442b18539a4af57ca9e5a7f797bb0311c9c3ce:

Improved handling of document's license. (2015-09-06 18:45:24 +0200)

are available in the git repository at:

git://github.com/f3nix/FreeCAD

for you to fetch changes up to de442b18539a4af57ca9e5a7f797bb0311c9c3ce:

Improved handling of document's license. (2015-09-06 18:45:24 +0200)

----------------------------------------------------------------

Cheers,
Mateusz
User avatar
yorik
Site Admin
Posts: 11618
Joined: Tue Feb 17, 2009 9:16 pm
Location: São Paulo, Brazil
Contact:

Re: Improved handling of document's license

Postby yorik » Mon Sep 07, 2015 6:40 pm

There is something in your commit, I don't know what, that makes it very difficult to know what has changed becuase all the file content is marked as changed:
https://github.com/f3nix/FreeCAD/commit ... 0311c9c3ce

Besides, the "All rights reserved" license by default is on purpose: If the user doesn't do anything to specify a "cooler" license, he remains in possession of all his rights. Forcing anything else on the user without him explicitely choosing it would be wrong.
User avatar
DeepSOIC
Posts: 7231
Joined: Fri Aug 29, 2014 12:45 am
Location: Saint-Petersburg, Russia

Re: Improved handling of document's license

Postby DeepSOIC » Mon Sep 07, 2015 7:07 pm

shoogen taught me that adding ?w=1 to address bar in github will hide whitespace differences, which helps a lot in this case:
https://github.com/f3nix/FreeCAD/commit ... c9c3ce?w=1
I wonder what has actually happened... maybe line endings were changed?
User avatar
f3nix
Posts: 319
Joined: Sat May 30, 2015 11:58 am

Re: Improved handling of document's license

Postby f3nix » Mon Sep 07, 2015 7:16 pm

Hi,
sorry about that. The file was encoded in ISO 8859-2 and my IDE complained about it. So I clicked update to UTF-8. I have not noticed that the diff looks so strange. Too little coffee I guess. ;)

Cheers,
Mateusz
User avatar
f3nix
Posts: 319
Joined: Sat May 30, 2015 11:58 am

Re: Improved handling of document's license

Postby f3nix » Mon Sep 07, 2015 7:27 pm

Hi,
I miswrote the description of the second change. If You choose "Other license" as default and do not enter the URL the default URL won't be "All rights reserved".

Cheers,
Mateusz

Here is the diff:

Code: Select all

diff --git a/src/App/Document.cpp b/src/App/Document.cpp
index a146f99..2711d12 100644
--- a/src/App/Document.cpp
+++ b/src/App/Document.cpp
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (c) J<FC>rgen Riegel          (juergen.riegel@web.de) 2002     *
+ *   Copyright (c) Jürgen Riegel          (juergen.riegel@web.de) 2002     *
  *                                                                         *
  *   This file is part of the FreeCAD CAx development system.              *
  *                                                                         *
@@ -668,7 +668,7 @@ Document::Document(void)
             license = "Other";
     }
     std::string licenseUrl = App::GetApplication().GetParameterGroupByPath
-        ("User parameter:BaseApp/Preferences/Document")->GetASCII("prefLicenseUrl","http://en.wikipedia.org/wiki/All_rights_reserved");
+        ("User parameter:BaseApp/Preferences/Document")->GetASCII("prefLicenseUrl","");
     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");
 
diff --git a/src/Gui/DlgSettingsDocumentImp.cpp b/src/Gui/DlgSettingsDocumentImp.cpp
index f2fb904..f2a3806 100644
--- a/src/Gui/DlgSettingsDocumentImp.cpp
+++ b/src/Gui/DlgSettingsDocumentImp.cpp
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (c) 2002 J<FC>rgen Riegel <juergen.riegel@web.de>              *
+ *   Copyright (c) 2002 Jürgen Riegel <juergen.riegel@web.de>              *
  *                                                                         *
  *   This file is part of the FreeCAD CAx development system.              *
  *                                                                         *
@@ -128,6 +128,8 @@ void DlgSettingsDocumentImp::changeEvent(QEvent *e)
  */
 void DlgSettingsDocumentImp::onLicenseTypeChanged(int index)
 {
+    prefLicenseUrl->setReadOnly(true);
+
     switch (index) {
         case 0:
             prefLicenseUrl->setText(QString::fromAscii("http://en.wikipedia.org/wiki/All_rights_reserved"));
@@ -158,6 +160,7 @@ void DlgSettingsDocumentImp::onLicenseTypeChanged(int index)
             break;
         default:
             prefLicenseUrl->setText(QString::fromAscii(""));
+            prefLicenseUrl->setReadOnly(false);
     }
 }
triplus
Posts: 8878
Joined: Mon Dec 12, 2011 4:45 pm

Re: Improved handling of document's license

Postby triplus » Mon Sep 07, 2015 7:30 pm

yorik wrote:There is something in your commit, I don't know what, that makes it very difficult to know what has changed becuase all the file content is marked as changed:
https://github.com/f3nix/FreeCAD/commit ... 0311c9c3ce

Besides, the "All rights reserved" license by default is on purpose: If the user doesn't do anything to specify a "cooler" license, he remains in possession of all his rights. Forcing anything else on the user without him explicitely choosing it would be wrong.
Reading this:

https://en.wikipedia.org/wiki/All_right ... solescence

Probably not setting any licence by default could be an option.
wmayer
Site Admin
Posts: 15128
Joined: Thu Feb 19, 2009 10:32 am

Re: Improved handling of document's license

Postby wmayer » Mon Sep 07, 2015 9:19 pm

I miswrote the description of the second change. If You choose "Other license" as default and do not enter the URL the default URL won't be "All rights reserved".
Are you sure? When you delete your user.cfg then in the preferences page License is set to "All rights reserved" and URL shows the appropriate value. If you switch to "Other" and create the a new document and check

Code: Select all

App.ActiveDocument.License # ==> 'Other'

Code: Select all

App.ActiveDocument.LicenseURL # ==> '' 
which is correct behaviour.

However, your code is definitely wrong. When you start again with an empty user.cfg then the preferences page for License and URL shows the correct values "All rights reserved" and "http://en.wikipedia.org/wiki/All_rights_reserved". But when creating a document

Code: Select all

App.ActiveDocument.LicenseURL
is an empty string which is clearly wrong.
User avatar
f3nix
Posts: 319
Joined: Sat May 30, 2015 11:58 am

Re: Improved handling of document's license

Postby f3nix » Mon Sep 07, 2015 10:06 pm

Hi wmayer,
thanks for taking the time and looking into it. My code is wrong. I'll have to take a second look at it.

As a side note. This is what I wanted to fix:

Code: Select all

rm ~/.FreeCAD/user.cfg
Start FreeCAD. Default license is „All rights reserved”

Create new document.

Code: Select all

>>> App.ActiveDocument.License
u'All rights reserved'

>>> App.ActiveDocument.LicenseURL
u'http://en.wikipedia.org/wiki/All_rights_reserved'
Change the license to „Other”. Create new document.

Code: Select all

>>> App.ActiveDocument.License
u'Other'
 
>>> App.ActiveDocument.LicenseURL
u''
Exit FreeCAD. Start it again. Create new document.

Code: Select all

>>> App.ActiveDocument.License
u'Other'

>>> App.ActiveDocument.LicenseURL
u'http://en.wikipedia.org/wiki/All_rights_reserved'
Is it a correct behaviour?

Thanks! :)

Cheers,
Mateusz
User avatar
yorik
Site Admin
Posts: 11618
Joined: Tue Feb 17, 2009 9:16 pm
Location: São Paulo, Brazil
Contact:

Re: Improved handling of document's license

Postby yorik » Mon Sep 07, 2015 11:11 pm

I get normal behaviour here...
With a fresh config, if I change the default license to "Other", the default URL field is empty. On new document creation, even after restarting, the License is correct: "Other" and the URL empty...

But indeed the license URL field should be editable so one can change the URL if one wishes. git commit 98e9dd0
User avatar
f3nix
Posts: 319
Joined: Sat May 30, 2015 11:58 am

Re: Improved handling of document's license

Postby f3nix » Tue Sep 08, 2015 4:43 am

yorik wrote:But indeed the license URL field should be editable so one can change the URL if one wishes. git commit 98e9dd0
Thank You! :)

Cheers,
Mateusz