diff options
Diffstat (limited to 'src/qt/guiutil.cpp')
-rw-r--r-- | src/qt/guiutil.cpp | 77 |
1 files changed, 21 insertions, 56 deletions
diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp index acd9f7b35c..f8f031041c 100644 --- a/src/qt/guiutil.cpp +++ b/src/qt/guiutil.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2011-2017 The Bitcoin Core developers +// Copyright (c) 2011-2018 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. @@ -49,6 +49,7 @@ #include <QDoubleValidator> #include <QFileDialog> #include <QFont> +#include <QKeyEvent> #include <QLineEdit> #include <QSettings> #include <QTextDocument> // for Qt::mightBeRichText @@ -63,16 +64,6 @@ static fs::detail::utf8_codecvt_facet utf8; -#if defined(Q_OS_MAC) -extern double NSAppKitVersionNumber; -#if !defined(NSAppKitVersionNumber10_8) -#define NSAppKitVersionNumber10_8 1187 -#endif -#if !defined(NSAppKitVersionNumber10_9) -#define NSAppKitVersionNumber10_9 1265 -#endif -#endif - namespace GUIUtil { QString dateTimeStr(const QDateTime &date) @@ -381,52 +372,16 @@ bool openBitcoinConf() /* Create the file */ boost::filesystem::ofstream configFile(pathConfig, std::ios_base::app); - + if (!configFile.good()) return false; - + configFile.close(); - + /* Open bitcoin.conf with the associated application */ return QDesktopServices::openUrl(QUrl::fromLocalFile(boostPathToQString(pathConfig))); } -void SubstituteFonts(const QString& language) -{ -#if defined(Q_OS_MAC) -// Background: -// OSX's default font changed in 10.9 and Qt is unable to find it with its -// usual fallback methods when building against the 10.7 sdk or lower. -// The 10.8 SDK added a function to let it find the correct fallback font. -// If this fallback is not properly loaded, some characters may fail to -// render correctly. -// -// The same thing happened with 10.10. .Helvetica Neue DeskInterface is now default. -// -// Solution: If building with the 10.7 SDK or lower and the user's platform -// is 10.9 or higher at runtime, substitute the correct font. This needs to -// happen before the QApplication is created. -#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) - /* On a 10.9 - 10.9.x system */ - QFont::insertSubstitution(".Lucida Grande UI", "Lucida Grande"); - else - { - /* 10.10 or later system */ - if (language == "zh_CN" || language == "zh_TW" || language == "zh_HK") // traditional or simplified Chinese - QFont::insertSubstitution(".Helvetica Neue DeskInterface", "Heiti SC"); - else if (language == "ja") // Japanese - QFont::insertSubstitution(".Helvetica Neue DeskInterface", "Songti SC"); - else - QFont::insertSubstitution(".Helvetica Neue DeskInterface", "Lucida Grande"); - } - } -#endif -#endif -} - ToolTipToRichTextFilter::ToolTipToRichTextFilter(int _size_threshold, QObject *parent) : QObject(parent), size_threshold(_size_threshold) @@ -741,7 +696,7 @@ LSSharedFileListItemRef findStartupItemInList(LSSharedFileListRef list, CFURLRef if (listSnapshot == nullptr) { return nullptr; } - + // loop through the list of startup items and try to find the bitcoin app for(int i = 0; i < CFArrayGetCount(listSnapshot); i++) { LSSharedFileListItemRef item = (LSSharedFileListItemRef)CFArrayGetValueAtIndex(listSnapshot, i); @@ -769,7 +724,7 @@ LSSharedFileListItemRef findStartupItemInList(LSSharedFileListRef list, CFURLRef CFRelease(currentItemURL); } } - + CFRelease(listSnapshot); return nullptr; } @@ -780,7 +735,7 @@ bool GetStartOnSystemStartup() if (bitcoinAppUrl == nullptr) { return false; } - + LSSharedFileListRef loginItems = LSSharedFileListCreate(nullptr, kLSSharedFileListSessionLoginItems, nullptr); LSSharedFileListItemRef foundItem = findStartupItemInList(loginItems, bitcoinAppUrl); @@ -794,7 +749,7 @@ bool SetStartOnSystemStartup(bool fAutoStart) if (bitcoinAppUrl == nullptr) { return false; } - + LSSharedFileListRef loginItems = LSSharedFileListCreate(nullptr, kLSSharedFileListSessionLoginItems, nullptr); LSSharedFileListItemRef foundItem = findStartupItemInList(loginItems, bitcoinAppUrl); @@ -806,7 +761,7 @@ bool SetStartOnSystemStartup(bool fAutoStart) // remove item LSSharedFileListItemRemove(loginItems, foundItem); } - + CFRelease(bitcoinAppUrl); return true; } @@ -967,10 +922,20 @@ void ClickableLabel::mouseReleaseEvent(QMouseEvent *event) { Q_EMIT clicked(event->pos()); } - + void ClickableProgressBar::mouseReleaseEvent(QMouseEvent *event) { Q_EMIT clicked(event->pos()); } +bool ItemDelegate::eventFilter(QObject *object, QEvent *event) +{ + if (event->type() == QEvent::KeyPress) { + if (static_cast<QKeyEvent*>(event)->key() == Qt::Key_Escape) { + Q_EMIT keyEscapePressed(); + } + } + return QItemDelegate::eventFilter(object, event); +} + } // namespace GUIUtil |