Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ajoute un bouton pour réinitialiser les paramètres à leurs valeurs par défaut #93

Merged
merged 2 commits into from
Sep 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions qtribu/gui/dlg_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ def __init__(self, parent=None):
)
self.btn_reset_read_history.pressed.connect(self.reset_read_history)

self.btn_reset.setIcon(QIcon(QgsApplication.iconPath("mActionUndo.svg")))
self.btn_reset.pressed.connect(self.reset_settings)

# load previously saved settings
self.load_settings()

Expand Down Expand Up @@ -142,6 +145,16 @@ def reset_read_history(self):
push=True,
)

def reset_settings(self):
"""Reset settings to default values (set in preferences.py module)."""
default_settings = PlgSettingsStructure()

# dump default settings into QgsSettings
self.plg_settings.save_from_object(default_settings)

# update the form
self.load_settings()


class PlgOptionsFactory(QgsOptionsWidgetFactory):
"""Factory for options widget."""
Expand Down
56 changes: 42 additions & 14 deletions qtribu/gui/dlg_settings.ui
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>697</width>
<height>437</height>
<height>468</height>
</rect>
</property>
<property name="sizePolicy">
Expand Down Expand Up @@ -300,6 +300,28 @@
<bool>false</bool>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="2" column="1">
<widget class="QLabel" name="lbl_version_saved_value">
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>30</height>
</size>
</property>
<property name="text">
<string notr="true">X.X.x</string>
</property>
<property name="textInteractionFlags">
<set>Qt::NoTextInteraction</set>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="opt_debug">
<property name="minimumSize">
Expand Down Expand Up @@ -350,8 +372,8 @@
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="lbl_version_saved_value">
<item row="0" column="1">
<widget class="QPushButton" name="btn_report">
<property name="minimumSize">
<size>
<width>0</width>
Expand All @@ -365,10 +387,11 @@
</size>
</property>
<property name="text">
<string notr="true">X.X.x</string>
<string>Report an issue</string>
</property>
<property name="textInteractionFlags">
<set>Qt::NoTextInteraction</set>
<property name="icon">
<iconset>
<normaloff>:/plugins/qtribu/resources/images/bullhorn.svg</normaloff>:/plugins/qtribu/resources/images/bullhorn.svg</iconset>
</property>
</widget>
</item>
Expand All @@ -391,26 +414,31 @@
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="btn_report">
<item row="3" column="0" colspan="2">
<widget class="QPushButton" name="btn_reset">
<property name="minimumSize">
<size>
<width>0</width>
<width>200</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<width>1000</width>
<height>30</height>
</size>
</property>
<property name="autoFillBackground">
<bool>true</bool>
</property>
<property name="text">
<string>Report an issue</string>
<string>Reset to factory defaults</string>
</property>
<property name="icon">
<iconset>
<normaloff>:/plugins/qtribu/resources/images/bullhorn.svg</normaloff>:/plugins/qtribu/resources/images/bullhorn.svg</iconset>
<property name="autoDefault">
<bool>false</bool>
</property>
<property name="flat">
<bool>false</bool>
</property>
</widget>
</item>
Expand Down
37 changes: 21 additions & 16 deletions qtribu/resources/i18n/qtribu_fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<context>
<name>ConfigOptionsPage</name>
<message>
<location filename="../../gui/dlg_settings.py" line="137"/>
<location filename="../../gui/dlg_settings.py" line="141"/>
<source>Read history has been reset.</source>
<translation>L&apos;historique de lecture a été réinitialisé.</translation>
</message>
Expand Down Expand Up @@ -108,66 +108,66 @@
<context>
<name>RdpNewsForm</name>
<message>
<location filename="../../gui/form_rdp_news.py" line="182"/>
<location filename="../../gui/form_rdp_news.py" line="179"/>
<source>- A category is required.
</source>
<translation>- Une catégorie est requise.
</translation>
</message>
<message>
<location filename="../../gui/form_rdp_news.py" line="187"/>
<location filename="../../gui/form_rdp_news.py" line="184"/>
<source>- A title is required, with at least 3 characters.
</source>
<translation>- Un titre est requis, avec 3 caractères minimum.
</translation>
</message>
<message>
<location filename="../../gui/form_rdp_news.py" line="194"/>
<location filename="../../gui/form_rdp_news.py" line="191"/>
<source>- News is not long enougth (25 characters at least).
</source>
<translation>- Le contenu de la news n&apos;est pas assez long (25 caractères minimum).
</translation>
</message>
<message>
<location filename="../../gui/form_rdp_news.py" line="201"/>
<location filename="../../gui/form_rdp_news.py" line="198"/>
<source>- License must be accepted.
</source>
<translation>- La licence doit être acceptée.
</translation>
</message>
<message>
<location filename="../../gui/form_rdp_news.py" line="206"/>
<location filename="../../gui/form_rdp_news.py" line="203"/>
<source>- For attribution purpose, author&apos;s firstname is required.
</source>
<translation>- Pour les besoins d&apos;attribution, le prénom de l&apos;auteur/e est requis.
</translation>
</message>
<message>
<location filename="../../gui/form_rdp_news.py" line="213"/>
<location filename="../../gui/form_rdp_news.py" line="210"/>
<source>- For attribution purpose, author&apos;s lastname is required.
</source>
<translation>- Pour les besoins d&apos;attribution, le nom de l&apos;auteur/e est requis.
</translation>
</message>
<message>
<location filename="../../gui/form_rdp_news.py" line="220"/>
<location filename="../../gui/form_rdp_news.py" line="217"/>
<source>- For attribution purpose, author&apos;s email is required.
</source>
<translation>- Pour les besoins d&apos;attribution, l&apos;email de l&apos;auteur/e est requis.
</translation>
</message>
<message>
<location filename="../../gui/form_rdp_news.py" line="226"/>
<location filename="../../gui/form_rdp_news.py" line="223"/>
<source>Some of required fields are incorrectly filled.</source>
<translation>Certains champs requis ne sont pas correctement renseignés.</translation>
</message>
<message>
<location filename="../../gui/form_rdp_news.py" line="226"/>
<location filename="../../gui/form_rdp_news.py" line="223"/>
<source>See details...</source>
<translation>Voir les détails...</translation>
</message>
<message>
<location filename="../../gui/form_rdp_news.py" line="226"/>
<location filename="../../gui/form_rdp_news.py" line="223"/>
<source>Fields in bold must be filled. Missing fields:
</source>
<translation>Les champs dont le nom est en gras sont requis. Champs incorrects :
Expand Down Expand Up @@ -359,27 +359,27 @@ Si c&apos;est le cas, ne pas cocher et donner des précisions en commentaire.</t
<translation>Divers</translation>
</message>
<message>
<location filename="../../gui/dlg_settings.ui" line="318"/>
<location filename="../../gui/dlg_settings.ui" line="340"/>
<source>Enable debug mode.</source>
<translation>Activer le mode DEBUG.</translation>
</message>
<message>
<location filename="../../gui/dlg_settings.ui" line="327"/>
<location filename="../../gui/dlg_settings.ui" line="349"/>
<source>Debug mode (degraded performances)</source>
<translation>Mode DEBUG (performances dégradées)</translation>
</message>
<message>
<location filename="../../gui/dlg_settings.ui" line="349"/>
<location filename="../../gui/dlg_settings.ui" line="371"/>
<source>Version used to save settings:</source>
<translation>Version des paramètres :</translation>
</message>
<message>
<location filename="../../gui/dlg_settings.ui" line="409"/>
<location filename="../../gui/dlg_settings.ui" line="390"/>
<source>Report an issue</source>
<translation>Créer un ticket</translation>
</message>
<message>
<location filename="../../gui/dlg_settings.ui" line="390"/>
<location filename="../../gui/dlg_settings.ui" line="413"/>
<source>Help</source>
<translation>Aide en ligne</translation>
</message>
Expand Down Expand Up @@ -408,5 +408,10 @@ Si c&apos;est le cas, ne pas cocher et donner des précisions en commentaire.</t
<source>Accept publication license globally</source>
<translation>Accepter une fois pour toutes la licence de publication</translation>
</message>
<message>
<location filename="../../gui/dlg_settings.ui" line="435"/>
<source>Reset to factory defaults</source>
<translation>Réinitialise les paramètres à leur valeur par défaut</translation>
</message>
</context>
</TS>