Jump to content

Kexi/Plugins/Forms/Button hyperlinks: Difference between revisions

From KDE Community Wiki
Jstaniek (talk | contribs)
Jstaniek (talk | contribs)
Line 13: Line 13:


==Details==
==Details==
===Hyperlink Type===
===Hyperlink Type property===
Distinction between Static/Dynamic URL has to be encoded somehow. To do so, add ''hyperlinkType'' property for Push button, of enum type:
Distinction between Static/Dynamic URL has to be encoded somehow. To do so, add ''hyperlinkType'' property (translated name "Hyperlink Type") for Push button, of enum type:
*NoHyperlink - clicking on button will not lead to opening of URL even if it has been provided in the ''hyperlink'' property or if a field has been bound
*NoHyperlink - clicking on button will not lead to opening of URL even if it has been provided in the ''hyperlink'' property or if a field has been bound
*StaticHyperlink - clicking on button will lead to opening of URL provided in the ''hyperlink'' property; if not provided, nothing happens
*StaticHyperlink - clicking on button will lead to opening of URL provided in the ''hyperlink'' property; if not provided, nothing happens
*DynamicHyperlink - clicking on button will lead to opening of URL provided in the bound field; if not bound or value is empty, nothing happens; ''hyperlink'' property is ignored in any case
*DynamicHyperlink - clicking on button will lead to opening of URL provided in the bound field; if not bound or value is empty, nothing happens; ''hyperlink'' property is ignored in any case
===Hyperlink property===
When hyperlinkType == StaticHyperlink, ''hyperlink'' property of type string is used (translated name "Hyperlink") for Push button. It encoded single URL to open.
===Hyperlink property===
===URLs===
URL values are used for value of ''hyperlink'' property (for StaticHyperlink type) or for value bound field (for DynamicHyperlink type). The property can be:
*empty (then, clicking the button has no effect)
*local path relative to the ''database path''
**TODO: ''database path'' is well defined for SQLite-based driver but not for server databases...
*local absolute path
URL can lead to folder or file.
===Opening URLs===
See [http://techbase.kde.org/Development/Architecture/KDE4/Starting_Other_Programs#KRun KRun] explanation. Use ''KRun::runUrl()'':
QString type = KMimeType::findByUrl(url)->name();
KRun::runUrl(url, parentWidget, type);
If ''hyperlinkExecutable'' property is false, check if the URL points to executable:
if (KRun::isExecutableFile(url, type)) {
  // show "<URL> is executable file" error message
}
If ''hyperlinkLocal'' property is true, check if the URL points to local:
if (!KUrl::isLocalFile(url)) {
  // show "<URL> is not local file" error message
}


==Further work==
==Further work==
...
...

Revision as of 21:51, 22 October 2012

Design page for task: "Add support for opening hyperlink via a form button".

Rationale

It should be possible to assign hyperlink (URL) to a form button. URL could be:

  1. Static (assigned to a button via 'hyperlink' property of type string)
  2. Dynamic (bound to one of form's field)

Details

Hyperlink Type property

Distinction between Static/Dynamic URL has to be encoded somehow. To do so, add hyperlinkType property (translated name "Hyperlink Type") for Push button, of enum type:

  • NoHyperlink - clicking on button will not lead to opening of URL even if it has been provided in the hyperlink property or if a field has been bound
  • StaticHyperlink - clicking on button will lead to opening of URL provided in the hyperlink property; if not provided, nothing happens
  • DynamicHyperlink - clicking on button will lead to opening of URL provided in the bound field; if not bound or value is empty, nothing happens; hyperlink property is ignored in any case

Hyperlink property

When hyperlinkType == StaticHyperlink, hyperlink property of type string is used (translated name "Hyperlink") for Push button. It encoded single URL to open.

Hyperlink property

URLs

URL values are used for value of hyperlink property (for StaticHyperlink type) or for value bound field (for DynamicHyperlink type). The property can be:

  • empty (then, clicking the button has no effect)
  • local path relative to the database path
    • TODO: database path is well defined for SQLite-based driver but not for server databases...
  • local absolute path

URL can lead to folder or file.

Opening URLs

See KRun explanation. Use KRun::runUrl():

QString type = KMimeType::findByUrl(url)->name();
KRun::runUrl(url, parentWidget, type);

If hyperlinkExecutable property is false, check if the URL points to executable:

if (KRun::isExecutableFile(url, type)) {
  // show "<URL> is executable file" error message
}

If hyperlinkLocal property is true, check if the URL points to local:

if (!KUrl::isLocalFile(url)) {
  // show "<URL> is not local file" error message
}

Further work

...