Changeset View
Changeset View
Standalone View
Standalone View
src/qt/guiutil.cpp
Show All 36 Lines | |||||
#define NOMINMAX | #define NOMINMAX | ||||
#endif | #endif | ||||
#include "shellapi.h" | #include "shellapi.h" | ||||
#include "shlobj.h" | #include "shlobj.h" | ||||
#include "shlwapi.h" | #include "shlwapi.h" | ||||
#endif | #endif | ||||
#include <boost/filesystem/fstream.hpp> | #include <boost/filesystem/fstream.hpp> | ||||
#if BOOST_FILESYSTEM_VERSION >= 3 | |||||
#include <boost/filesystem/detail/utf8_codecvt_facet.hpp> | #include <boost/filesystem/detail/utf8_codecvt_facet.hpp> | ||||
#endif | |||||
#include <boost/scoped_array.hpp> | #include <boost/scoped_array.hpp> | ||||
#include <QAbstractItemView> | #include <QAbstractItemView> | ||||
#include <QApplication> | #include <QApplication> | ||||
#include <QClipboard> | #include <QClipboard> | ||||
#include <QDateTime> | #include <QDateTime> | ||||
#include <QDesktopServices> | #include <QDesktopServices> | ||||
#include <QDesktopWidget> | #include <QDesktopWidget> | ||||
#include <QDoubleValidator> | #include <QDoubleValidator> | ||||
#include <QFileDialog> | #include <QFileDialog> | ||||
#include <QFont> | #include <QFont> | ||||
#include <QLineEdit> | #include <QLineEdit> | ||||
#include <QMouseEvent> | #include <QMouseEvent> | ||||
#include <QSettings> | #include <QSettings> | ||||
#include <QTextDocument> // for Qt::mightBeRichText | #include <QTextDocument> // for Qt::mightBeRichText | ||||
#include <QThread> | #include <QThread> | ||||
#include <QUrlQuery> | #include <QUrlQuery> | ||||
#if QT_VERSION >= 0x50200 | #if QT_VERSION >= 0x50200 | ||||
#include <QFontDatabase> | #include <QFontDatabase> | ||||
#endif | #endif | ||||
#if BOOST_FILESYSTEM_VERSION >= 3 | |||||
static fs::detail::utf8_codecvt_facet utf8; | static fs::detail::utf8_codecvt_facet utf8; | ||||
#endif | |||||
#if defined(Q_OS_MAC) | #if defined(Q_OS_MAC) | ||||
// These Mac includes must be done in the global namespace | // These Mac includes must be done in the global namespace | ||||
#include <CoreFoundation/CoreFoundation.h> | #include <CoreFoundation/CoreFoundation.h> | ||||
#include <CoreServices/CoreServices.h> | #include <CoreServices/CoreServices.h> | ||||
extern double NSAppKitVersionNumber; | extern double NSAppKitVersionNumber; | ||||
#if !defined(NSAppKitVersionNumber10_8) | #if !defined(NSAppKitVersionNumber10_8) | ||||
▲ Show 20 Lines • Show All 778 Lines • ▼ Show 20 Lines | |||||
#endif | #endif | ||||
void setClipboard(const QString &str) { | void setClipboard(const QString &str) { | ||||
QApplication::clipboard()->setText(str, QClipboard::Clipboard); | QApplication::clipboard()->setText(str, QClipboard::Clipboard); | ||||
QApplication::clipboard()->setText(str, QClipboard::Selection); | QApplication::clipboard()->setText(str, QClipboard::Selection); | ||||
} | } | ||||
#if BOOST_FILESYSTEM_VERSION >= 3 | |||||
fs::path qstringToBoostPath(const QString &path) { | fs::path qstringToBoostPath(const QString &path) { | ||||
return fs::path(path.toStdString(), utf8); | return fs::path(path.toStdString(), utf8); | ||||
} | } | ||||
QString boostPathToQString(const fs::path &path) { | QString boostPathToQString(const fs::path &path) { | ||||
return QString::fromStdString(path.string(utf8)); | return QString::fromStdString(path.string(utf8)); | ||||
} | } | ||||
#else | |||||
#warning Conversion between boost path and QString can use invalid character encoding with boost_filesystem v2 and older | |||||
fs::path qstringToBoostPath(const QString &path) { | |||||
return fs::path(path.toStdString()); | |||||
} | |||||
QString boostPathToQString(const fs::path &path) { | |||||
return QString::fromStdString(path.string()); | |||||
} | |||||
#endif | |||||
QString formatDurationStr(int secs) { | QString formatDurationStr(int secs) { | ||||
QStringList strList; | QStringList strList; | ||||
int days = secs / 86400; | int days = secs / 86400; | ||||
int hours = (secs % 86400) / 3600; | int hours = (secs % 86400) / 3600; | ||||
int mins = (secs % 3600) / 60; | int mins = (secs % 3600) / 60; | ||||
int seconds = secs % 60; | int seconds = secs % 60; | ||||
▲ Show 20 Lines • Show All 95 Lines • Show Last 20 Lines |