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

Reset options, notify user about backup creation #617

Merged
merged 1 commit into from
Jun 28, 2022

Conversation

furszy
Copy link
Member

@furszy furszy commented Jun 12, 2022

Quick follow-up to first point of #602 (review)

@hebasto hebasto changed the title gui: reset options, notify user about backup creation Reset options, notify user about backup creation Jun 12, 2022
@DrahtBot
Copy link
Contributor

DrahtBot commented Jun 12, 2022

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

No conflicts as of last run.

@Rspigler
Copy link
Contributor

make check

make[4]: Leaving directory '/home/user/gui/src'
Running tests: addrman_tests from test/addrman_tests.cpp
/bin/bash: line 2: test/test_bitcoin: Permission denied
make[3]: *** [Makefile:20843: test/addrman_tests.cpp.test] Error 1
make[3]: Leaving directory '/home/user/gui/src'
make[2]: *** [Makefile:18948: check-am] Error 2
make[2]: Leaving directory '/home/user/gui/src'
make[1]: *** [Makefile:18605: check-recursive] Error 1
make[1]: Leaving directory '/home/user/gui/src'
make: *** [Makefile:818: check-recursive] Error 1

@furszy
Copy link
Member Author

furszy commented Jun 13, 2022

@Rspigler issue is on your environment, this PR has no link to it.

"Permission denied" from bash usually means that the binary is not executable. Try cleaning your environment first (git clean -dfx) and recompile the sources (./autogen.sh && ./configure && make check). (plus, if doesn't work, could try with chmod +x src/test/test_bitcoin).

@jarolrod jarolrod added the UX All about "how to get things done" label Jun 13, 2022
@Rspigler
Copy link
Contributor

tACK 52372cb
It writes settings.json.bak, but then continues to overwrite the file rather than create settings1.json.bak, settings2...., etc.

Tests do pass

Copy link
Contributor

@shaavan shaavan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 52372cb

  • I agree with the idea of this PR. Displaying where the settings are getting backup lets the user know where to access them when needed.
  • I successfully compiled this PR on Ubuntu 22.04 with Qt version 5.15.3.

Screenshot:

Master PR
Screenshot from 2022-06-14 17-42-23 Screenshot from 2022-06-14 17-59-59

Observations:

  • Verified that the settings are correctly backed up on the displayed location.
  • The latest custom settings overwrite the settings.json.bak file. Hence leading to backing up only the latest set of settings.

@furszy
Copy link
Member Author

furszy commented Jun 14, 2022

thanks for the reviews!

It writes settings.json.bak, but then continues to overwrite the file rather than create settings1.json.bak, settings2...., etc.

Yeah, I didn't implement those changes here. Only implemented the GUI changes. Those are coming in a following-up PR, test included :)

tr("Client restart required to activate changes.") + "<br><br>" + tr("Client will be shut down. Do you want to proceed?"),
tr("Client restart required to activate changes.") + "<br><br>" +
tr("Current settings will be backed up at \"%1\".").arg(GUIUtil::getDefaultDataDirectory()) + "<br><br>" +
tr("Client will be shut down. Do you want to proceed?"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add translator comments to these translatable strings. I've written some documentation on crafting translator comments here: https://github.com/bitcoin-core/gui-qml/blob/main/src/qml/doc/translator-comments.md

I can suggest the comments if you'd like

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

re: #617 (comment)

Please add translator comments to these translatable strings. I've written some documentation on crafting translator comments here: https://github.com/bitcoin-core/gui-qml/blob/main/src/qml/doc/translator-comments.md

I can suggest the comments if you'd like

This seems worth following up on. It's not obvious to me what translator comments would be helpful here so maybe suggesting specific comments would be helpful

// confirmation dialog
QMessageBox::StandardButton btnRetVal = QMessageBox::question(this, tr("Confirm options reset"),
tr("Client restart required to activate changes.") + "<br><br>" + tr("Client will be shut down. Do you want to proceed?"),
tr("Client restart required to activate changes.") + "<br><br>" +
tr("Current settings will be backed up at \"%1\".").arg(GUIUtil::getDefaultDataDirectory()) + "<br><br>" +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In commit "gui: reset options, notify user about the backup creation" (52372cb)

I think this is mentioning the wrong backup directory. Should be gArgs.GetDataDirNet() not GUIUtil::getDefaultDataDirectory()

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, good catch.
but one thing, will better provide client model access so we don't access gArgs from the widget (at least in my head, the ideal architecture would be widget -> model -> interfaces -> backend).

@furszy furszy force-pushed the 2022_gui_settings_backup branch from 52372cb to ac4fb3b Compare June 28, 2022 13:34
@furszy
Copy link
Member Author

furszy commented Jun 28, 2022

Updated per ryanofsky feedback.

Now the flow uses m_client_model->dataDir() instead of GUIUtil::getDefaultDataDirectory().

Copy link
Contributor

@ryanofsky ryanofsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review ACK ac4fb3b, just fixing displayed backup directory since last review

tr("Client restart required to activate changes.") + "<br><br>" + tr("Client will be shut down. Do you want to proceed?"),
tr("Client restart required to activate changes.") + "<br><br>" +
tr("Current settings will be backed up at \"%1\".").arg(GUIUtil::getDefaultDataDirectory()) + "<br><br>" +
tr("Client will be shut down. Do you want to proceed?"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

re: #617 (comment)

Please add translator comments to these translatable strings. I've written some documentation on crafting translator comments here: https://github.com/bitcoin-core/gui-qml/blob/main/src/qml/doc/translator-comments.md

I can suggest the comments if you'd like

This seems worth following up on. It's not obvious to me what translator comments would be helpful here so maybe suggesting specific comments would be helpful

@jarolrod
Copy link
Member

@ryanofsky

This seems worth following up on. It's not obvious to me what translator comments would be helpful here so maybe suggesting specific comments would be helpful

suggesting the following translator comments:

diff --git a/src/qt/optionsdialog.cpp b/src/qt/optionsdialog.cpp
index 462b923d6..3cf165004 100644
--- a/src/qt/optionsdialog.cpp
+++ b/src/qt/optionsdialog.cpp
@@ -286,9 +286,17 @@ void OptionsDialog::on_resetButton_clicked()
 {
     if (model) {
         // confirmation dialog
+        //: Window title text of pop-up window shown when the user has chosen to reset options.
         QMessageBox::StandardButton btnRetVal = QMessageBox::question(this, tr("Confirm options reset"),
+            /*: Text explaining that the settings the user changed will not come
+                into effect until the client is restarted. */
             tr("Client restart required to activate changes.") + "<br><br>" +
+            /*: Text explaining to the user that the client's current settings
+                will be backed up at a specific location. %1 is a stand-in
+                argument for the backup location's path. */
             tr("Current settings will be backed up at \"%1\".").arg(m_client_model->dataDir()) + "<br><br>" +
+            /*: Text asking the user to confirm if they would like to proceed
+                with a client shutdown. */
             tr("Client will be shut down. Do you want to proceed?"),
             QMessageBox::Yes | QMessageBox::Cancel, QMessageBox::Cancel);

But, there is a problem with this. The translator comment for the first tr(), being "Client restart required to activate changes", will pick up the translator comment; but the other two tr() will not. This is because, while the tr() are on their own line, they are being appended together and the Qt Translator doesn't seem to like this in respect to adding the appropriate extracomment field to the translator file.

I would suggest to just create a variable that will hold the text and then pass that to the dialog, like so:

@@ -278,14 +284,23 @@ void OptionsDialog::setOkButtonState(bool fState)

 void OptionsDialog::on_resetButton_clicked()
 {
-    if(model)
-    {
+    if (model) {
         // confirmation dialog
+        /*: Text explaining that the settings the user changed will not come
+            into effect until the client is restarted. */
+        QString reset_window_text = tr("Client restart required to activate changes.") + "<br><br>";
+        /*: Text explaining to the user that the client's current settings
+            will be backed up at a specific location. %1 is a stand-in
+            argument for the backup location's path. */
+        reset_window_text.append(tr("Current settings will be backed up at \"%1\".").arg(m_client_model->dataDir()) + "<br><br>");
+        /*: Text asking the user to confirm if they would like to proceed
+            with a client shutdown. */
+        reset_window_text.append(tr("Client will be shut down. Do you want to proceed?"));
+        //: Window title text of pop-up window shown when the user has chosen to reset options.
         QMessageBox::StandardButton btnRetVal = QMessageBox::question(this, tr("Confirm options reset"),
-            tr("Client restart required to activate changes.") + "<br><br>" + tr("Client will be shut down. Do you want to proceed?"),
-            QMessageBox::Yes | QMessageBox::Cancel, QMessageBox::Cancel);
+            reset_window_text,QMessageBox::Yes | QMessageBox::Cancel, QMessageBox::Cancel);

To not prevent this from moving along, this could just be picked up as a follow-up.

@ryanofsky
Copy link
Contributor

suggesting the following translator comments:

This is great. Thanks!

@furszy
Copy link
Member Author

furszy commented Jun 28, 2022

Oh, sorry @jarolrod. I missed your comment there. Thanks for the suggestion 👌🏼 .

I'm fine either way, could add it here under your authorship or you could create a follow-up PR for it.


Have to say that mixing source code written in c++ with comments for translators isn't convincing me. There should be another way, some external file/s where we could map every text being translated to its own translator comment so we don't end up adding external stuff to the sources (if something like this doesn't exist then maybe we should create it).

@jarolrod
Copy link
Member

@furszy

Have to say that mixing source code written in c++ with comments for translators isn't convincing me. There should be another way, some external file/s where we could map every text being translated to its own translator comment so we don't end up adding external stuff to the sources (if something like this doesn't exist then maybe we should create it).

this is nothing new, we just follow Qt's process for writing source code for translation. We've chosen to provide context to translators to help them with translating from english to a target language, and to do this we need to provide a translator comment. I am not aware of any other way to provide translator context and nicely integrate it with transifex. Custom tooling seems like an unnecessary effort.

Translator comments are part of the burden of developing an application that needs to be localized; it is a worthwhile burden.

Copy link
Member

@jarolrod jarolrod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tACK ac4fb3b

Will pick up translation fixup in a follow-up.

@hebasto hebasto merged commit 1b4d660 into bitcoin-core:master Jun 28, 2022
@furszy
Copy link
Member Author

furszy commented Jun 28, 2022

@furszy

Have to say that mixing source code written in c++ with comments for translators isn't convincing me. There should be another way, some external file/s where we could map every text being translated to its own translator comment so we don't end up adding external stuff to the sources (if something like this doesn't exist then maybe we should create it).

this is nothing new, we just follow Qt's process for writing source code for translation. We've chosen to provide context to translators to help them with translating from english to a target language, and to do this we need to provide a translator comment. I am not aware of any other way to provide translator context and nicely integrate it with transifex. Custom tooling seems like an unnecessary effort.

Translator comments are part of the burden of developing an application that needs to be localized; it is a worthwhile burden.

Yeah, I understood the rationale behind it (not the first time working with localized applications), I'm just not happy mixing code (which should be as clean as possible) with comments that should be properly crafted for non-technical people. We might end up having large cpp files full of non-technical comments that would make readability harder which is one of the main bug causes.

I'm not saying to not have them. Just check if there are other options, primarily to have them located elsewhere.

@jarolrod
Copy link
Member

We might end up having large cpp files full of non-technical comments that would make readability harder which is one of the main bug causes.

Won't be an issue with the switch to qml :)

sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Jun 29, 2022
jarolrod added a commit to jarolrod/gui that referenced this pull request Jun 30, 2022
Follow-up to bitcoin-core#617. This applies translator strings to the
reset options confirmation dialog and also refactors the way we pass the
strings to the dialog in order to allow the comments to be applied.
Because the strings were being concatenated, we can not apply translator
comments to all of the relevant strings. What we want to do instead is
have a variable in which the translatable strings are appended to using
the QString append function. This satisfies the Qt translator engine and
the comments are then properly applied within the `extracomment` field
in the translation file.
hebasto added a commit that referenced this pull request Jul 12, 2022
…ialog

d5c141f qt: apply translator comments to reset options confirmation dialog (Jarol Rodriguez)

Pull request description:

  This is a followup to #617. Because the strings were being concatenated, we can not apply translator comments to all of the revelant strings. This can be tested by applying the following diff to current master and running `make translate`; then check the resulting diff:

  ```diff
  diff --git a/src/qt/optionsdialog.cpp b/src/qt/optionsdialog.cpp
  index 462b923d6..3cf165004 100644
  --- a/src/qt/optionsdialog.cpp
  +++ b/src/qt/optionsdialog.cpp
  @@ -286,9 +286,17 @@ void OptionsDialog::on_resetButton_clicked()
   {
       if (model) {
           // confirmation dialog
  +        //: Window title text of pop-up window shown when the user has chosen to reset options.
           QMessageBox::StandardButton btnRetVal = QMessageBox::question(this, tr("Confirm options reset"),
  +            /*: Text explaining that the settings the user changed will not come
  +                into effect until the client is restarted. */
               tr("Client restart required to activate changes.") + "<br><br>" +
  +            /*: Text explaining to the user that the client's current settings
  +                will be backed up at a specific location. %1 is a stand-in
  +                argument for the backup location's path. */
               tr("Current settings will be backed up at \"%1\".").arg(m_client_model->dataDir()) + "<br><br>" +
  +            /*: Text asking the user to confirm if they would like to proceed
  +                with a client shutdown. */
               tr("Client will be shut down. Do you want to proceed?"),
               QMessageBox::Yes | QMessageBox::Cancel, QMessageBox::Cancel);
  ```

  To apply the above translator comments, what we want to do instead is have a variable in which the translatable strings are appended to using the [QString append function](https://doc.qt.io/qt-5/qstring.html#append).

  When you run `make translate` with this PR, you will see the translator comments properly applied, as shown below:
  ``` diff
  diff --git a/src/qt/locale/bitcoin_en.ts b/src/qt/locale/bitcoin_en.ts
  index 35d820187..9e5158b3e 100644
  --- a/src/qt/locale/bitcoin_en.ts
  +++ b/src/qt/locale/bitcoin_en.ts
  @@ -1942,28 +1942,37 @@ Signing is only possible with addresses of the type &apos;legacy&apos;.</source>
           <translation>default</translation>
       </message>
       <message>
  -        <location line="+81"/>
  +        <location line="+86"/>
           <source>none</source>
           <translation type="unfinished"></translation>
       </message>
       <message>
  -        <location line="+97"/>
  +        <location line="+107"/>
           <source>Confirm options reset</source>
  +        <extracomment>Window title text of pop-up window shown when the user has chosen to reset options.</extracomment>
           <translation>Confirm options reset</translation>
       </message>
       <message>
  -        <location line="+1"/>
  -        <location line="+70"/>
  +        <location line="-9"/>
  +        <location line="+79"/>
           <source>Client restart required to activate changes.</source>
  +        <extracomment>Text explaining that the settings changed will not come into effect until the client is restarted.</extracomment>
  +        <translation type="unfinished"></translation>
  +    </message>
  +    <message>
  +        <location line="-75"/>
  +        <source>Current settings will be backed up at &quot;%1&quot;.</source>
  +        <extracomment>Text explaining to the user that the client&apos;s current settings will be backed up at a specific location. %1 is a stand-in argument for the backup location&apos;s path.</extracomment>
           <translation type="unfinished"></translation>
       </message>
       <message>
  -        <location line="-70"/>
  +        <location line="+3"/>
           <source>Client will be shut down. Do you want to proceed?</source>
  +        <extracomment>Text asking the user to confirm if they would like to proceed with a client shutdown.</extracomment>
           <translation type="unfinished"></translation>
       </message>
       <message>
  -        <location line="+18"/>
  +        <location line="+20"/>
           <source>Configuration options</source>
           <extracomment>Window title text of pop-up box that allows opening up of configuration file.</extracomment>
           <translation type="unfinished"></translation>
  ```

  No difference in rendering between master and PR

  | master | PR |
  | ------- | --- |
  <img width="532" alt="Screen Shot 2022-06-29 at 11 39 17 PM" src="https://user-images.githubusercontent.com/23396902/176588495-9d3761b6-9d96-489a-bbe5-a8907f7d5f99.png"> | <img width="532" alt="Screen Shot 2022-06-29 at 11 39 51 PM" src="https://user-images.githubusercontent.com/23396902/176588513-92e29564-b74a-46f5-a5dd-469c4ee953f7.png"> |

ACKs for top commit:
  shaavan:
    ACK d5c141f
  furszy:
    Tested ACK d5c141f, no functional changes.
  w0xlt:
    tACK d5c141f

Tree-SHA512: 6175a096c6f99edb3041cc2429e1ea0670a10cd2cab0364f664a56c7dee1aa8631d52c0a36edb5d571f6ef934e947d45017e446cea7dddae044085c39c8835ef
@bitcoin-core bitcoin-core locked and limited conversation to collaborators Jun 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
UX All about "how to get things done"
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants