Skip to content
This repository has been archived by the owner on Sep 7, 2023. It is now read-only.

Commit

Permalink
Show link button to settings in messagebar
Browse files Browse the repository at this point in the history
  • Loading branch information
AsgerPetersen committed Aug 23, 2019
1 parent 90f6c40 commit ac8cb71
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 38 deletions.
Binary file modified Kortforsyningen/i18n/da.qm
Binary file not shown.
58 changes: 28 additions & 30 deletions Kortforsyningen/i18n/da.ts
Original file line number Diff line number Diff line change
@@ -1,83 +1,81 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS><TS version="2.0">
<context>
<name>KfConfig</name>
<message>
<location filename="kf_config.py" line="140"/>
<source>No contact to Kortforsyningen</source>
<translation>Ingen kontakt til Kortforsyningen</translation>
</message>
</context>
<!DOCTYPE TS>
<TS version="2.1" language="en_DK" sourcelanguage="en">
<context>
<name>Kortforsyningen</name>
<message>
<location filename="kortforsyningen.py" line="115"/>
<location filename="../kortforsyningen.py" line="123"/>
<source>Kortforsyningen</source>
<translation>Kortforsyningen</translation>
</message>
<message>
<location filename="kortforsyningen.py" line="95"/>
<source>Check connection and click menu Settings -&gt; Options - &gt; Kortforsyningen -&gt; OK</source>
<translation>Tjek forbindelse og klik menu Indstillinger -&gt; Generelle Indstillinger - &gt; Kortforsyningen -&gt; OK</translation>
<location filename="../kortforsyningen.py" line="99"/>
<source>No contact to Kortforsyningen</source>
<translation>Ingen kontakt til Kortforsyningen</translation>
</message>
<message>
<location filename="kortforsyningen.py" line="96"/>
<source>No contact to Kortforsyningen</source>
<translation>Ingen kontaskt til Kortforsyningen</translation>
<location filename="../kortforsyningen.py" line="181"/>
<source>About the plugin</source>
<translation>Om dette plugin</translation>
</message>
<message>
<location filename="kortforsyningen.py" line="100"/>
<source>Token not set or wrong. Select menu Settings -&gt; Options - &gt; Kortforsyningen</source>
<translation>Token ikke angivet eller forkert. Klik menu Indstillinger -&gt; Generelle Indstillinger - &gt; Kortforsyningen</translation>
<location filename="../kortforsyningen.py" line="100"/>
<source>Check internet connection and Kortforsyningen settings</source>
<translation>Kontroller internetforbindelse og indstillinger for Kortforsyningen</translation>
</message>
<message>
<location filename="kortforsyningen.py" line="165"/>
<source>About the plugin</source>
<translation>Om dette plugin</translation>
<location filename="../kortforsyningen.py" line="106"/>
<source>Token not set or wrong</source>
<translation>Token er forkert eller ikke angivet</translation>
</message>
<message>
<location filename="../kortforsyningen.py" line="111"/>
<source>Open settings</source>
<translation>Åbn indstillinger</translation>
</message>
</context>
<context>
<name>LayerLocatorFilter</name>
<message>
<location filename="layerlocatorfilter.py" line="24"/>
<location filename="../layerlocatorfilter.py" line="24"/>
<source>Kortforsyningen</source>
<translation>Kortforsyningen</translation>
</message>
</context>
<context>
<name>s</name>
<message>
<location filename="settings.ui" line="14"/>
<location filename="../mysettings/settings.ui" line="14"/>
<source>Kortforsyningen - Settings</source>
<translation>Kortforsyning - Indstillinger</translation>
</message>
<message>
<location filename="settings.ui" line="83"/>
<location filename="../mysettings/settings.ui" line="92"/>
<source>Enter token to Kortforsyning</source>
<translation>Angiv token til Kortforsyning</translation>
</message>
<message>
<location filename="settings.ui" line="163"/>
<location filename="../mysettings/settings.ui" line="124"/>
<source>Extend Kortforsyningsplugin with qlr-file</source>
<translation>Udvid Kortforsyningsplugin med qlr-fil</translation>
</message>
<message>
<location filename="settings.ui" line="79"/>
<location filename="../mysettings/settings.ui" line="150"/>
<source>Select qlr-file</source>
<translation>Vælg qlr-fil</translation>
</message>
<message>
<location filename="settings.ui" line="153"/>
<location filename="../mysettings/settings.ui" line="160"/>
<source>Only display backgroundmap from Kortforsyningen</source>
<translation>Vis kun baggrundskort fra Kortforsyningen</translation>
</message>
<message>
<location filename="settings.ui" line="83"/>
<location filename="../mysettings/settings.ui" line="83"/>
<source>Token</source>
<translation>Token</translation>
</message>
<message>
<location filename="settings.ui" line="99"/>
<location filename="../mysettings/settings.ui" line="99"/>
<source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;a href=&quot;https://kortforsyningen.dk/indhold/min-side-0&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;Find your token to Kortforsyningen&lt;/span&gt;&lt;/a&gt; or &lt;a href=&quot;https://kortforsyningen.dk/indhold/min-side-0&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;create a new token&lt;/span&gt;&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;Not registered as a user at Kortforsyningen? &lt;a href=&quot;http://download.kortforsyningen.dk//content/opret-mig-som-bruger&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;Create user &lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
<translation>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;a href=&quot;https://kortforsyningen.dk/indhold/min-side-0&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;Find dit token til Kortforsyningen&lt;/span&gt;&lt;/a&gt; eller &lt;a href=&quot;https://kortforsyningen.dk/indhold/min-side-0&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt; opret nyt token&lt;/span&gt;&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;Ikke registreret som bruger på Kortforsyningen? &lt;a href=&quot;http://download.kortforsyningen.dk//content/opret-mig-som-bruger&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;Opret bruger&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</translation>
</message>
Expand Down
28 changes: 20 additions & 8 deletions Kortforsyningen/kortforsyningen.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ def __init__(self, iface):
# initialize locale
path = QFileInfo(os.path.realpath(__file__)).path()
try:
locale = self.config.value("locale/userLocale")[0:2]
settings = QSettings()
locale = settings.value("locale/userLocale")[0:2]
except:
locale = 'da'
locale_path = os.path.join(
Expand All @@ -96,21 +97,32 @@ def initGui(self):
self.createMenu()

def show_kf_error(self):
message = self.tr('Check connection and click menu Settings -> Options - > Kortforsyningen -> OK')
self.iface.messageBar().pushMessage(self.tr( 'No contact to Kortforsyningen'), message, level=Qgis.Warning, duration=5)
title = self.tr( 'No contact to Kortforsyningen')
message = self.tr('Check internet connection and Kortforsyningen settings')
log_message(message)
self.show_messagebar_linked_to_settings(title, message)

def show_kf_settings_warning(self):
message = self.tr('Token not set or wrong. Select menu Settings -> Options - > Kortforsyningen')
self.iface.messageBar().pushMessage(self.tr('Kortforsyningen'), message, level=Qgis.Warning, duration=5)
title = self.tr('Kortforsyningen')
message = self.tr('Token not set or wrong')
log_message(message)
self.show_messagebar_linked_to_settings(title, message)

def show_messagebar_linked_to_settings(self, title, message, level=Qgis.Warning, duration=15):
button_text = self.tr(u'Open settings')
widget = self.iface.messageBar().createMessage(title, message)
button = QPushButton(widget)
button.setText(button_text)
button.pressed.connect(lambda : self.iface.showOptionsDialog(currentPage='kortforsyningenOptions'))
widget.layout().addWidget(button)
self.iface.messageBar().pushWidget(widget, level=level, duration=duration)

def createMenu(self):
"""Create the menu entries and toolbar icons inside the QGIS GUI."""
self.menu = QMenu(self.iface.mainWindow().menuBar())
"""Create the menu entries and toolbar icons inside the QGIS GUI."""
menu_bar = self.iface.mainWindow().menuBar()
self.menu = QMenu(menu_bar)
self.menu.setObjectName(self.tr('Kortforsyningen'))
self.menu.setTitle(self.tr('Kortforsyningen'))
menu_bar = self.iface.mainWindow().menuBar()
menu_bar.insertMenu(
self.iface.firstRightStandardMenu().menuAction(), self.menu
)
Expand Down

0 comments on commit ac8cb71

Please sign in to comment.