document License and LicenseURL properties now appear in doc properties dialog

This commit is contained in:
Yorik van Havre 2013-08-01 09:48:05 -03:00
parent c6858f69fd
commit 650b493f6f
3 changed files with 268 additions and 219 deletions

View File

@ -1,10 +1,8 @@
<ui version="4.0" >
<author></author>
<comment></comment>
<exportmacro></exportmacro>
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Gui::Dialog::DlgProjectInformation</class>
<widget class="QDialog" name="Gui::Dialog::DlgProjectInformation" >
<property name="geometry" >
<widget class="QDialog" name="Gui::Dialog::DlgProjectInformation">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
@ -12,220 +10,148 @@
<height>540</height>
</rect>
</property>
<property name="windowTitle" >
<property name="windowTitle">
<string>Project information</string>
</property>
<property name="sizeGripEnabled" >
<property name="sizeGripEnabled">
<bool>true</bool>
</property>
<property name="modal" >
<property name="modal">
<bool>true</bool>
</property>
<layout class="QGridLayout" >
<property name="margin" >
<layout class="QGridLayout">
<property name="margin">
<number>9</number>
</property>
<property name="spacing" >
<property name="spacing">
<number>6</number>
</property>
<item row="0" column="0" >
<widget class="QGroupBox" name="groupBoxInfo" >
<property name="title" >
<item row="0" column="0">
<widget class="QGroupBox" name="groupBoxInfo">
<property name="title">
<string>Information</string>
</property>
<layout class="QGridLayout" >
<property name="margin" >
<layout class="QGridLayout">
<property name="margin">
<number>9</number>
</property>
<property name="spacing" >
<property name="spacing">
<number>6</number>
</property>
<item row="0" column="0" >
<widget class="QLabel" name="textLabelName" >
<property name="text" >
<string>&amp;Name:</string>
</property>
<property name="alignment" >
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy" >
<cstring>lineEditName</cstring>
</property>
</widget>
</item>
<item row="0" column="1" >
<widget class="QLineEdit" name="lineEditName" >
<property name="minimumSize" >
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="readOnly" >
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0" >
<widget class="QLabel" name="textLabelPath" >
<property name="text" >
<string>Path:</string>
</property>
<property name="alignment" >
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="1" >
<widget class="QLineEdit" name="lineEditPath" >
<property name="minimumSize" >
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="readOnly" >
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0" >
<widget class="QLabel" name="textLabelUuid" >
<property name="text" >
<string>UUID:</string>
</property>
<property name="alignment" >
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="2" column="1" >
<widget class="QLineEdit" name="lineEditUuid" >
<property name="minimumSize" >
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="readOnly" >
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="0" >
<widget class="QLabel" name="textLabelCreator" >
<property name="text" >
<string>Created &amp;by:</string>
</property>
<property name="alignment" >
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy" >
<cstring>lineEditCreator</cstring>
</property>
</widget>
</item>
<item row="3" column="1" >
<widget class="QLineEdit" name="lineEditCreator" >
<property name="minimumSize" >
<size>
<width>0</width>
<height>25</height>
</size>
</property>
</widget>
</item>
<item row="4" column="0" >
<widget class="QLabel" name="textLabelCreateDate" >
<property name="text" >
<string>Creation &amp;date:</string>
</property>
<property name="alignment" >
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy" >
<cstring>lineEditDate</cstring>
</property>
</widget>
</item>
<item row="4" column="1" >
<widget class="QLineEdit" name="lineEditDate" >
<property name="minimumSize" >
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="readOnly" >
<bool>true</bool>
</property>
</widget>
</item>
<item row="5" column="0" >
<widget class="QLabel" name="textLabelLastMod" >
<property name="text" >
<string>&amp;Last modified by:</string>
</property>
<property name="alignment" >
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy" >
<cstring>lineEditLastMod</cstring>
</property>
</widget>
</item>
<item row="5" column="1" >
<widget class="QLineEdit" name="lineEditLastMod" >
<property name="minimumSize" >
<size>
<width>0</width>
<height>25</height>
</size>
</property>
</widget>
</item>
<item row="6" column="0" >
<widget class="QLabel" name="textLabelLastModDate" >
<property name="text" >
<item row="6" column="0">
<widget class="QLabel" name="textLabelLastModDate">
<property name="text">
<string>Last &amp;modification date:</string>
</property>
<property name="alignment" >
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy" >
<property name="buddy">
<cstring>lineEditLastModDate</cstring>
</property>
</widget>
</item>
<item row="6" column="1" >
<widget class="QLineEdit" name="lineEditLastModDate" >
<property name="minimumSize" >
<item row="0" column="0">
<widget class="QLabel" name="textLabelName">
<property name="text">
<string>&amp;Name:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>lineEditName</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="lineEditName">
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="readOnly" >
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="7" column="0" >
<widget class="QLabel" name="textLabelCompany" >
<property name="text" >
<string>Com&amp;pany:</string>
<item row="10" column="0">
<widget class="QLabel" name="textLabelComment">
<property name="text">
<string>Commen&amp;t:</string>
</property>
<property name="alignment" >
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy" >
<cstring>lineEditCompany</cstring>
<property name="buddy">
<cstring>textEditComment</cstring>
</property>
</widget>
</item>
<item row="7" column="1" >
<widget class="QLineEdit" name="lineEditCompany" >
<property name="minimumSize" >
<item row="1" column="0">
<widget class="QLabel" name="textLabelPath">
<property name="text">
<string>Path:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="lineEditPath">
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="textLabelUuid">
<property name="text">
<string>UUID:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="lineEditUuid">
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="textLabelCreator">
<property name="text">
<string>Created &amp;by:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>lineEditCreator</cstring>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="lineEditCreator">
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
@ -233,31 +159,103 @@
</property>
</widget>
</item>
<item row="8" column="0" >
<widget class="QLabel" name="textLabelComment" >
<property name="text" >
<string>Commen&amp;t:</string>
<item row="4" column="0">
<widget class="QLabel" name="textLabelCreateDate">
<property name="text">
<string>Creation &amp;date:</string>
</property>
<property name="alignment" >
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy" >
<cstring>textEditComment</cstring>
<property name="buddy">
<cstring>lineEditDate</cstring>
</property>
</widget>
</item>
<item rowspan="2" row="8" column="1" >
<widget class="QTextEdit" name="textEditComment" />
<item row="4" column="1">
<widget class="QLineEdit" name="lineEditDate">
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="9" column="0" >
<item row="5" column="0">
<widget class="QLabel" name="textLabelLastMod">
<property name="text">
<string>&amp;Last modified by:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>lineEditLastMod</cstring>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLineEdit" name="lineEditLastMod">
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QLineEdit" name="lineEditLastModDate">
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="textLabelCompany">
<property name="text">
<string>Com&amp;pany:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>lineEditCompany</cstring>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QLineEdit" name="lineEditCompany">
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
</widget>
</item>
<item row="10" column="1" rowspan="2">
<widget class="QTextEdit" name="textEditComment"/>
</item>
<item row="11" column="0">
<spacer>
<property name="orientation" >
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType" >
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" >
<property name="sizeHint" stdset="0">
<size>
<width>91</width>
<height>240</height>
@ -265,26 +263,63 @@
</property>
</spacer>
</item>
<item row="8" column="0">
<widget class="QLabel" name="textLabelLicense">
<property name="text">
<string>License information:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="QLabel" name="textLabelLicenseURL">
<property name="text">
<string>License URL</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QLineEdit" name="lineEditLicense"/>
</item>
<item row="9" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLineEdit" name="lineEditLicenseURL"/>
</item>
<item>
<widget class="QPushButton" name="pushButtonOpenURL">
<property name="text">
<string>Open in browser</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item row="1" column="0" >
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<item row="1" column="0">
<layout class="QHBoxLayout">
<property name="spacing">
<number>6</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<spacer>
<property name="orientation" >
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType" >
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" >
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
@ -293,30 +328,30 @@
</spacer>
</item>
<item>
<widget class="QPushButton" name="buttonOk" >
<property name="text" >
<widget class="QPushButton" name="buttonOk">
<property name="text">
<string>&amp;OK</string>
</property>
<property name="shortcut" >
<property name="shortcut">
<string/>
</property>
<property name="autoDefault" >
<property name="autoDefault">
<bool>true</bool>
</property>
<property name="default" >
<property name="default">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="buttonCancel" >
<property name="text" >
<widget class="QPushButton" name="buttonCancel">
<property name="text">
<string>&amp;Cancel</string>
</property>
<property name="shortcut" >
<property name="shortcut">
<string/>
</property>
<property name="autoDefault" >
<property name="autoDefault">
<bool>true</bool>
</property>
</widget>
@ -325,9 +360,7 @@
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11" />
<tabstops>
</tabstops>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections>
<connection>
@ -336,11 +369,11 @@
<receiver>Gui::Dialog::DlgProjectInformation</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel" >
<hint type="sourcelabel">
<x>20</x>
<y>20</y>
</hint>
<hint type="destinationlabel" >
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
</hint>
@ -352,11 +385,11 @@
<receiver>Gui::Dialog::DlgProjectInformation</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel" >
<hint type="sourcelabel">
<x>20</x>
<y>20</y>
</hint>
<hint type="destinationlabel" >
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
</hint>

View File

@ -28,6 +28,8 @@
#include "DlgProjectInformationImp.h"
#include "Document.h"
#include <QUrl>
#include <QDesktopServices>
using namespace Gui::Dialog;
@ -52,6 +54,8 @@ DlgProjectInformationImp::DlgProjectInformationImp( App::Document* doc, QWidget*
lineEditLastMod->setText(QString::fromUtf8(doc->LastModifiedBy.getValue()));
lineEditLastModDate->setText(QString::fromUtf8(doc->LastModifiedDate.getValue()));
lineEditCompany->setText(QString::fromUtf8(doc->Company.getValue()));
lineEditLicense->setText(QString::fromUtf8(doc->License.getValue()));
lineEditLicenseURL->setText(QString::fromUtf8(doc->LicenseURL.getValue()));
// When saving the text to XML the newlines get lost. So we store also the newlines as '\n'.
// See also accept().
@ -59,6 +63,7 @@ DlgProjectInformationImp::DlgProjectInformationImp( App::Document* doc, QWidget*
QStringList lines = comment.split(QLatin1String("\\n"), QString::KeepEmptyParts);
QString text = lines.join(QLatin1String("\n"));
textEditComment->setPlainText( text );
connect(pushButtonOpenURL, SIGNAL(clicked()),this, SLOT(open_url()));
}
/**
@ -77,6 +82,8 @@ void DlgProjectInformationImp::accept()
_doc->CreatedBy.setValue(lineEditCreator->text().toUtf8());
_doc->LastModifiedBy.setValue(lineEditCreator->text().toUtf8());
_doc->Company.setValue(lineEditCompany->text().toUtf8());
_doc->License.setValue(lineEditLicense->text().toUtf8());
_doc->LicenseURL.setValue(lineEditLicenseURL->text().toUtf8());
// Replace newline escape sequence trough '\\n' string
QStringList lines = textEditComment->toPlainText().split
@ -87,3 +94,11 @@ void DlgProjectInformationImp::accept()
QDialog::accept();
}
/**
* Opens the text in the LicenseURL property in external browser.
*/
void DlgProjectInformationImp::open_url()
{
QString url = QString::fromUtf8(_doc->LicenseURL.getValue());
QDesktopServices::openUrl(QUrl(url, QUrl::TolerantMode));
}

View File

@ -42,6 +42,7 @@ public:
protected:
void accept();
void open_url();
App::Document* _doc;
};