diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp --- a/src/qt/guiutil.cpp +++ b/src/qt/guiutil.cpp @@ -306,7 +306,9 @@ } void copyEntryData(QAbstractItemView *view, int column, int role) { - if (!view || !view->selectionModel()) return; + if (!view || !view->selectionModel()) { + return; + } QModelIndexList selection = view->selectionModel()->selectedRows(column); if (!selection.isEmpty()) { @@ -316,7 +318,9 @@ } QList getEntryData(QAbstractItemView *view, int column) { - if (!view || !view->selectionModel()) return QList(); + if (!view || !view->selectionModel()) { + return QList(); + } return view->selectionModel()->selectedRows(column); } @@ -349,7 +353,9 @@ if (!result.isEmpty()) { if (info.suffix().isEmpty() && !selectedSuffix.isEmpty()) { /* No suffix specified, add selected suffix */ - if (!result.endsWith(".")) result.append("."); + if (!result.endsWith(".")) { + result.append("."); + } result.append(selectedSuffix); } } @@ -366,8 +372,8 @@ QString *selectedSuffixOut) { QString selectedFilter; QString myDir; - if (dir.isEmpty()) // Default to user documents location - { + // Default to user documents location + if (dir.isEmpty()) { myDir = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation); } else { @@ -400,7 +406,9 @@ bool checkPoint(const QPoint &p, const QWidget *w) { QWidget *atW = QApplication::widgetAt(w->mapToGlobal(p)); - if (!atW) return false; + if (!atW) { + return false; + } return atW->topLevelWidget() == w; } @@ -416,9 +424,10 @@ fs::path pathDebug = GetDataDir() / "debug.log"; /* Open debug.log with the associated application */ - if (fs::exists(pathDebug)) + if (fs::exists(pathDebug)) { QDesktopServices::openUrl( QUrl::fromLocalFile(boostPathToQString(pathDebug))); + } } void SubstituteFonts(const QString &language) { @@ -439,21 +448,24 @@ #if defined(MAC_OS_X_VERSION_MAX_ALLOWED) && \ MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_8 if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_8) { - if (floor(NSAppKitVersionNumber) <= NSAppKitVersionNumber10_9) + if (floor(NSAppKitVersionNumber) <= NSAppKitVersionNumber10_9) { /* On a 10.9 - 10.9.x system */ QFont::insertSubstitution(".Lucida Grande UI", "Lucida Grande"); - else { + } else { /* 10.10 or later system */ if (language == "zh_CN" || language == "zh_TW" || - language == "zh_HK") // traditional or simplified Chinese + language == "zh_HK") { + // traditional or simplified Chinese QFont::insertSubstitution(".Helvetica Neue DeskInterface", "Heiti SC"); - else if (language == "ja") // Japanesee + } else if (language == "ja") { + // Japanesee QFont::insertSubstitution(".Helvetica Neue DeskInterface", "Songti SC"); - else + } else { QFont::insertSubstitution(".Helvetica Neue DeskInterface", "Lucida Grande"); + } } } #endif @@ -602,11 +614,13 @@ #ifdef WIN32 static fs::path StartupShortcutPath() { std::string chain = gArgs.GetChainName(); - if (chain == CBaseChainParams::MAIN) + if (chain == CBaseChainParams::MAIN) { return GetSpecialFolderPath(CSIDL_STARTUP) / "Bitcoin.lnk"; + } // Remove this special case when CBaseChainParams::TESTNET = "testnet4" - if (chain == CBaseChainParams::TESTNET) + if (chain == CBaseChainParams::TESTNET) { return GetSpecialFolderPath(CSIDL_STARTUP) / "Bitcoin (testnet).lnk"; + } return GetSpecialFolderPath(CSIDL_STARTUP) / strprintf("Bitcoin (%s).lnk", chain); } @@ -692,29 +706,37 @@ static fs::path GetAutostartDir() { char *pszConfigHome = getenv("XDG_CONFIG_HOME"); - if (pszConfigHome) return fs::path(pszConfigHome) / "autostart"; + if (pszConfigHome) { + return fs::path(pszConfigHome) / "autostart"; + } char *pszHome = getenv("HOME"); - if (pszHome) return fs::path(pszHome) / ".config" / "autostart"; + if (pszHome) { + return fs::path(pszHome) / ".config" / "autostart"; + } return fs::path(); } static fs::path GetAutostartFilePath() { std::string chain = gArgs.GetChainName(); - if (chain == CBaseChainParams::MAIN) + if (chain == CBaseChainParams::MAIN) { return GetAutostartDir() / "bitcoin.desktop"; + } return GetAutostartDir() / strprintf("bitcoin-%s.lnk", chain); } bool GetStartOnSystemStartup() { fs::ifstream optionFile(GetAutostartFilePath()); - if (!optionFile.good()) return false; + if (!optionFile.good()) { + return false; + } // Scan through file for "Hidden=true": std::string line; while (!optionFile.eof()) { getline(optionFile, line); if (line.find("Hidden") != std::string::npos && - line.find("true") != std::string::npos) + line.find("true") != std::string::npos) { return false; + } } optionFile.close(); @@ -722,28 +744,32 @@ } bool SetStartOnSystemStartup(bool fAutoStart) { - if (!fAutoStart) + if (!fAutoStart) { fs::remove(GetAutostartFilePath()); - else { + } else { char pszExePath[MAX_PATH + 1]; memset(pszExePath, 0, sizeof(pszExePath)); if (readlink("/proc/self/exe", pszExePath, sizeof(pszExePath) - 1) == - -1) + -1) { return false; + } fs::create_directories(GetAutostartDir()); fs::ofstream optionFile(GetAutostartFilePath(), std::ios_base::out | std::ios_base::trunc); - if (!optionFile.good()) return false; + if (!optionFile.good()) { + return false; + } std::string chain = gArgs.GetChainName(); // Write a bitcoin.desktop file to the autostart directory: optionFile << "[Desktop Entry]\n"; optionFile << "Type=Application\n"; - if (chain == CBaseChainParams::MAIN) + if (chain == CBaseChainParams::MAIN) { optionFile << "Name=Bitcoin\n"; - else + } else { optionFile << strprintf("Name=Bitcoin (%s)\n", chain); + } optionFile << "Exec=" << pszExePath << strprintf(" -min -testnet=%d -regtest=%d\n", gArgs.GetBoolArg("-testnet", false), @@ -778,14 +804,16 @@ #if defined(MAC_OS_X_VERSION_MAX_ALLOWED) && \ MAC_OS_X_VERSION_MAX_ALLOWED >= 10100 - if (&LSSharedFileListItemCopyResolvedURL) + if (&LSSharedFileListItemCopyResolvedURL) { currentItemURL = LSSharedFileListItemCopyResolvedURL( item, resolutionFlags, nullptr); + } #if defined(MAC_OS_X_VERSION_MIN_REQUIRED) && \ MAC_OS_X_VERSION_MIN_REQUIRED < 10100 - else + else { LSSharedFileListItemResolve(item, resolutionFlags, ¤tItemURL, nullptr); + } #endif #else LSSharedFileListItemResolve(item, resolutionFlags, ¤tItemURL, @@ -875,11 +903,18 @@ int mins = (secs % 3600) / 60; int seconds = secs % 60; - if (days) strList.append(QString(QObject::tr("%1 d")).arg(days)); - if (hours) strList.append(QString(QObject::tr("%1 h")).arg(hours)); - if (mins) strList.append(QString(QObject::tr("%1 m")).arg(mins)); - if (seconds || (!days && !hours && !mins)) + if (days) { + strList.append(QString(QObject::tr("%1 d")).arg(days)); + } + if (hours) { + strList.append(QString(QObject::tr("%1 h")).arg(hours)); + } + if (mins) { + strList.append(QString(QObject::tr("%1 m")).arg(mins)); + } + if (seconds || (!days && !hours && !mins)) { strList.append(QString(QObject::tr("%1 s")).arg(seconds)); + } return strList.join(" "); } @@ -916,10 +951,11 @@ } } - if (strList.size()) + if (strList.size()) { return strList.join(" & "); - else + } else { return QObject::tr("None"); + } } QString formatPingTime(double dPingTime) {