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

refactor: Pass interfaces::Node references to OptionsModel constructor #601

Merged
merged 1 commit into from
May 24, 2022

Conversation

ryanofsky
Copy link
Contributor

@ryanofsky ryanofsky commented May 19, 2022

Giving OptionsModel access to the node interface is needed as part of #602 to get bitcoind and bitcoin-qt to use the same settings instead of different settings.

It has been split off from #602 to simplify that PR. Previously these commits were part of bitcoin/bitcoin#15936 and also had some review discussion there.

Will allow OptionsModel to read/write settings to the node settings.json
file and share settings with the node, instead of storing them
externally in QSettings.

Co-authored-by: Vasil Dimov <vd@FreeBSD.org>
@DrahtBot
Copy link
Contributor

DrahtBot commented May 20, 2022

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

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #363 (Peers window: Show direction in a new column, with clearer icon by luke-jr)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

Copy link
Contributor

@vasild vasild left a comment

Choose a reason for hiding this comment

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

ACK 945e467

Copy link
Member

@furszy furszy 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 945e467

src/qt/splashscreen.cpp Outdated Show resolved Hide resolved
Copy link
Contributor Author

@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.

Updated 945e467 -> 31122aa (pr/qtnode.1 -> pr/qtnode.2, compare) removing code that was changing splash screen init, now initializing OptionsModel after the splash screen, instead of before.

src/qt/splashscreen.cpp Outdated Show resolved Hide resolved
Copy link

@chetooo40 chetooo40 left a comment

Choose a reason for hiding this comment

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

Till me

Copy link
Contributor

@promag promag 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 31122aa.

@@ -261,7 +261,7 @@ void BitcoinApplication::createPaymentServer()

void BitcoinApplication::createOptionsModel(bool resetSettings)
{
optionsModel = new OptionsModel(this, resetSettings);
optionsModel = new OptionsModel(node(), this, resetSettings);
Copy link
Contributor

Choose a reason for hiding this comment

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

Just noting that node() asserts for m_node.

@@ -633,6 +632,12 @@ int GuiMain(int argc, char* argv[])
// Allow parameter interaction before we create the options model
app.parameterSetup();
GUIUtil::LogQtInfo();

Copy link
Contributor

Choose a reason for hiding this comment

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

This hunk was moved because now createOptionsModel needs m_node instanced.

Copy link
Member

@furszy furszy left a comment

Choose a reason for hiding this comment

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

Code ACK 31122aa

With a small note for:

now initializing OptionsModel after the splash screen, instead of before.

We can probably initialize the SplashScreen after the OptionsModel, so at presentation time (show()) the widget can get access to the user selected language from there and not fallback to the system's language.
Still.. probably a big meh as we aren't having anything to translate in that screen atm.

@ryanofsky
Copy link
Contributor Author

We can probably initialize the SplashScreen after the OptionsModel, so at presentation time (show()) the widget can get access to the user selected language from there and not fallback to the system's language

I think it actually shouldn't need OptionsModel for this, should just use gArgs.GetArg("-lang"). The early-init gui code uses ArgsManager and QSettings directly to get started, then it switches to interfaces::Node when the node is running. Probably unless the splash screen gets really fancy, it shouldn't need an OptionsModel pointer, and if it does it could be passed after it is started.

@@ -41,7 +41,7 @@ class OptionsModel : public QAbstractListModel
Q_OBJECT

public:
explicit OptionsModel(QObject *parent = nullptr, bool resetSettings = false);
explicit OptionsModel(interfaces::Node& node, QObject *parent = nullptr, bool resetSettings = false);
Copy link
Member

Choose a reason for hiding this comment

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

It seems to not be strictly necessary to have to initialize OptionsModel with a reference to interfaces::Node and instead could just be set at a later point which is similar to how we do it now. Wondering what is the justification to add this to the constructor?

Copy link
Member

Choose a reason for hiding this comment

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

nevermind, I see how this is needed in consideration of future changes :D

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.

ACK 31122aa

Reviewed the code and agree it can be merged. Tested this with future changes in #602.

@hebasto hebasto merged commit 1368634 into bitcoin-core:master May 24, 2022
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request May 28, 2022
…s to OptionsModel constructor

31122aa refactor: Pass interfaces::Node references to OptionsModel constructor (Ryan Ofsky)

Pull request description:

  Giving OptionsModel access to the node interface is needed as part of bitcoin#602 to get bitcoind and bitcoin-qt to use the same settings instead of different settings.

  It has been split off from bitcoin#602 to simplify that PR. Previously these commits were part of bitcoin#15936 and also had some review discussion there.

ACKs for top commit:
  promag:
    Code review ACK 31122aa.
  furszy:
    Code ACK 31122aa
  jarolrod:
    ACK 31122aa

Tree-SHA512: b8529322fd7ba97e19864129e6cf5f9acc58c124f2e5a7c50aca15772c8549de3c24e8b0c27e8cf2c06fd26529e9cdb898b0788a1de3cbfdfbdd3f85c9f0fe69
@bitcoin-core bitcoin-core locked and limited conversation to collaborators May 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants