mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-12-18 16:42:54 +01:00
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.
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
#include "intro.h"
|
||||
#include "networkstyle.h"
|
||||
#include "optionsmodel.h"
|
||||
#include "platformstyle.h"
|
||||
#include "splashscreen.h"
|
||||
#include "utilitydialog.h"
|
||||
#include "winshutdownmonitor.h"
|
||||
@@ -241,6 +242,7 @@ private:
|
||||
WalletModel *walletModel;
|
||||
#endif
|
||||
int returnValue;
|
||||
const PlatformStyle *platformStyle;
|
||||
|
||||
void startThread();
|
||||
};
|
||||
@@ -310,6 +312,22 @@ BitcoinApplication::BitcoinApplication(int &argc, char **argv):
|
||||
returnValue(0)
|
||||
{
|
||||
setQuitOnLastWindowClosed(false);
|
||||
|
||||
// UI per-platform customization
|
||||
// This must be done inside the BitcoinApplication constructor, or after it, because
|
||||
// PlatformStyle::instantiate requires a QApplication
|
||||
#if defined(Q_OS_MAC)
|
||||
std::string platformName = "macosx";
|
||||
#elif defined(Q_OS_WIN)
|
||||
std::string platformName = "windows";
|
||||
#else
|
||||
std::string platformName = "other";
|
||||
#endif
|
||||
platformName = GetArg("-uiplatform", platformName);
|
||||
platformStyle = PlatformStyle::instantiate(QString::fromStdString(platformName));
|
||||
if (!platformStyle) // Fall back to "other" if specified name not found
|
||||
platformStyle = PlatformStyle::instantiate("other");
|
||||
assert(platformStyle);
|
||||
}
|
||||
|
||||
BitcoinApplication::~BitcoinApplication()
|
||||
@@ -330,6 +348,8 @@ BitcoinApplication::~BitcoinApplication()
|
||||
#endif
|
||||
delete optionsModel;
|
||||
optionsModel = 0;
|
||||
delete platformStyle;
|
||||
platformStyle = 0;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_WALLET
|
||||
@@ -346,7 +366,7 @@ void BitcoinApplication::createOptionsModel()
|
||||
|
||||
void BitcoinApplication::createWindow(const NetworkStyle *networkStyle)
|
||||
{
|
||||
window = new BitcoinGUI(networkStyle, 0);
|
||||
window = new BitcoinGUI(platformStyle, networkStyle, 0);
|
||||
|
||||
pollShutdownTimer = new QTimer(window);
|
||||
connect(pollShutdownTimer, SIGNAL(timeout()), window, SLOT(detectShutdown()));
|
||||
@@ -421,6 +441,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();
|
||||
#ifdef ENABLE_WALLET
|
||||
PaymentServer::LoadRootCAs();
|
||||
paymentServer->setOptionsModel(optionsModel);
|
||||
@@ -432,7 +454,7 @@ void BitcoinApplication::initializeResult(int retval)
|
||||
#ifdef ENABLE_WALLET
|
||||
if(pwalletMain)
|
||||
{
|
||||
walletModel = new WalletModel(pwalletMain, optionsModel);
|
||||
walletModel = new WalletModel(platformStyle, pwalletMain, optionsModel);
|
||||
|
||||
window->addWallet(BitcoinGUI::DEFAULT_WALLET, walletModel);
|
||||
window->setCurrentWallet(BitcoinGUI::DEFAULT_WALLET);
|
||||
|
||||
Reference in New Issue
Block a user