qt: Introduce PlatformStyle #6487

Merged
merged 1 commit into from Jul 31, 2015

Conversation

Projects
None yet
3 participants
@laanwj
Member

laanwj commented Jul 28, 2015

Introduce a PlatformStyle to handle platform-specific customization of the UI.

This replaces 'scicon', as well as #ifdefs to determine whether to place icons on buttons.

The selected PlatformStyle defaults to the platform that the application was compiled on, but can be overridden from the command line with -uiplatform=<x>.

Also fixes the warning from #6328.

@laanwj laanwj added the GUI label Jul 28, 2015

@jonasschnelli

This comment has been minimized.

Show comment
Hide comment
@jonasschnelli

jonasschnelli Jul 28, 2015

Member

Very nice!
Plans to test this in detail.

Wouldn't it be possible to crate a PlattformBase class inherited from QObject, instead of passing PlatformStyle in most of the ui based constructors? Or is this not possible because of different superclasses?

Member

jonasschnelli commented Jul 28, 2015

Very nice!
Plans to test this in detail.

Wouldn't it be possible to crate a PlattformBase class inherited from QObject, instead of passing PlatformStyle in most of the ui based constructors? Or is this not possible because of different superclasses?

@laanwj

This comment has been minimized.

Show comment
Hide comment
@laanwj

laanwj Jul 28, 2015

Member

Wouldn't it be possible to crate a PlattformBase class inherited from QObject, instead of passing PlatformStyle in most of the ui based constructors? Or is this not possible because of different superclasses?

I don't think that would work. There are various other ways to 'hide' the dependency, for example a singleton pattern, but I strongly prefer passing dependencies explicitly.

The only place it is unfortunate is in the WalletModel / TransactionTableModel. Ideally only the view cares about the style, not the model. But the decoration icon has to be in the platform style. Could be fixed later with a delegate but this is the most straightforward.

Member

laanwj commented Jul 28, 2015

Wouldn't it be possible to crate a PlattformBase class inherited from QObject, instead of passing PlatformStyle in most of the ui based constructors? Or is this not possible because of different superclasses?

I don't think that would work. There are various other ways to 'hide' the dependency, for example a singleton pattern, but I strongly prefer passing dependencies explicitly.

The only place it is unfortunate is in the WalletModel / TransactionTableModel. Ideally only the view cares about the style, not the model. But the decoration icon has to be in the platform style. Could be fixed later with a delegate but this is the most straightforward.

@jonasschnelli

This comment has been minimized.

Show comment
Hide comment
@jonasschnelli

jonasschnelli Jul 28, 2015

Member

Fair enough. Better pass – like you introduce it in this PR – than a singleton.

Member

jonasschnelli commented Jul 28, 2015

Fair enough. Better pass – like you introduce it in this PR – than a singleton.

@@ -421,6 +439,8 @@ void BitcoinApplication::initializeResult(int retval)
returnValue = retval ? 0 : 1;
if(retval)
{
+ // Log this only after AppInit2 finishes, as then logging setup is guaranteed complete
+ qWarning() << "Platform customization:" << platformStyle->getName();

This comment has been minimized.

@Diapolo

Diapolo Jul 29, 2015

Nit: Misses a space after :.

@Diapolo

Diapolo Jul 29, 2015

Nit: Misses a space after :.

This comment has been minimized.

@laanwj

laanwj Jul 29, 2015

Member

qt adds that, somehow

@laanwj

laanwj Jul 29, 2015

Member

qt adds that, somehow

+ /* Other: linux, unix, ... */
+ {"other", true, true, false}
+};
+static const unsigned platform_styles_count = sizeof(platform_styles)/sizeof(*platform_styles);

This comment has been minimized.

@Diapolo

Diapolo Jul 29, 2015

This is only used once, do we need this const here?

@Diapolo

Diapolo Jul 29, 2015

This is only used once, do we need this const here?

This comment has been minimized.

@laanwj

laanwj Jul 29, 2015

Member

Why not? It's analogous to networkstyle.cpp, and it makes the code more readable by using a name instead of a long in-line expression.

@laanwj

laanwj Jul 29, 2015

Member

Why not? It's analogous to networkstyle.cpp, and it makes the code more readable by using a name instead of a long in-line expression.

@jonasschnelli

This comment has been minimized.

Show comment
Hide comment
@jonasschnelli

jonasschnelli Jul 29, 2015

Member

Tested ACK.
It works.
Binaries: https://builds.jonasschnelli.ch/pulls/6487/

Screens OSX:
Other platform on OSX, icons on button, colored (but black as expected):
bildschirmfoto 2015-07-29 um 14 59 41

No parameter passed:
bildschirmfoto 2015-07-29 um 15 14 38

Screens Ubuntu:
OSX:
bildschirmfoto 2015-07-29 um 15 17 15

No parameter passed:
bildschirmfoto 2015-07-29 um 15 17 28

Screens Windows:
OSX on Windows (no icons):
bildschirmfoto 2015-07-29 um 15 12 09

Other Platform on Windows (colored icons):
bildschirmfoto 2015-07-29 um 15 11 51

No -uiplatform parameter passed (standard):
bildschirmfoto 2015-07-29 um 15 11 36

Member

jonasschnelli commented Jul 29, 2015

Tested ACK.
It works.
Binaries: https://builds.jonasschnelli.ch/pulls/6487/

Screens OSX:
Other platform on OSX, icons on button, colored (but black as expected):
bildschirmfoto 2015-07-29 um 14 59 41

No parameter passed:
bildschirmfoto 2015-07-29 um 15 14 38

Screens Ubuntu:
OSX:
bildschirmfoto 2015-07-29 um 15 17 15

No parameter passed:
bildschirmfoto 2015-07-29 um 15 17 28

Screens Windows:
OSX on Windows (no icons):
bildschirmfoto 2015-07-29 um 15 12 09

Other Platform on Windows (colored icons):
bildschirmfoto 2015-07-29 um 15 11 51

No -uiplatform parameter passed (standard):
bildschirmfoto 2015-07-29 um 15 11 36

@laanwj

This comment has been minimized.

Show comment
Hide comment
@laanwj

laanwj Jul 29, 2015

Member

Again thanks for the extensive testing @jonasschnelli !

Squashed into one commit.

Member

laanwj commented Jul 29, 2015

Again thanks for the extensive testing @jonasschnelli !

Squashed into one commit.

qt: Introduce PlatformStyle
Introduce a PlatformStyle to handle platform-specific customization of
the UI.

This replaces 'scicon', as well as #ifdefs to determine whether to place
icons on buttons.

The selected PlatformStyle defaults to the platform that the application
was compiled on, but can be overridden from the command line with
`-uiplatform=<x>`.

Also fixes the warning from #6328.
@laanwj

This comment has been minimized.

Show comment
Hide comment
@laanwj

laanwj Jul 31, 2015

Member

Added a comment to per-platform initialization in BitcoinApplication::BitcoinApplication.

    // This must be done inside the BitcoinApplication constructor, or after it, because
    // PlatformStyle::instantiate requires a QApplication
Member

laanwj commented Jul 31, 2015

Added a comment to per-platform initialization in BitcoinApplication::BitcoinApplication.

    // This must be done inside the BitcoinApplication constructor, or after it, because
    // PlatformStyle::instantiate requires a QApplication

@laanwj laanwj merged commit eec7757 into bitcoin:master Jul 31, 2015

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

laanwj added a commit that referenced this pull request Jul 31, 2015

Merge pull request #6487
eec7757 qt: Introduce PlatformStyle (Wladimir J. van der Laan)

@rnicoll rnicoll referenced this pull request in dogecoin/dogecoin Aug 11, 2015

Merged

Introduce upstream UI changes #1239

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment