aboutsummaryrefslogtreecommitdiff
path: root/src/qt/guiutil.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/qt/guiutil.h')
-rw-r--r--src/qt/guiutil.h94
1 files changed, 88 insertions, 6 deletions
diff --git a/src/qt/guiutil.h b/src/qt/guiutil.h
index 52124ff20a..bcbb540c37 100644
--- a/src/qt/guiutil.h
+++ b/src/qt/guiutil.h
@@ -1,13 +1,21 @@
-// Copyright (c) 2011-2013 The Bitcoin developers
-// Distributed under the MIT/X11 software license, see the accompanying
+// Copyright (c) 2011-2013 The Bitcoin Core developers
+// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#ifndef GUIUTIL_H
-#define GUIUTIL_H
+#ifndef BITCOIN_QT_GUIUTIL_H
+#define BITCOIN_QT_GUIUTIL_H
+#include "amount.h"
+
+#include <QEvent>
+#include <QHeaderView>
#include <QMessageBox>
#include <QObject>
+#include <QProgressBar>
#include <QString>
+#include <QTableView>
+
+#include <boost/filesystem.hpp>
class QValidatedLineEdit;
class SendCoinsRecipient;
@@ -42,7 +50,7 @@ namespace GUIUtil
QString formatBitcoinURI(const SendCoinsRecipient &info);
// Returns true if given address+amount meets "dust" definition
- bool isDust(const QString& address, qint64 amount);
+ bool isDust(const QString& address, const CAmount& amount);
// HTML escaping for rich text controls
QString HtmlEscape(const QString& str, bool fMultiLine=false);
@@ -98,6 +106,9 @@ namespace GUIUtil
// Open debug.log
void openDebugLogfile();
+ // Replace invalid default fonts with known good ones
+ void SubstituteFonts(const QString& language);
+
/** Qt event filter that intercepts ToolTipChange events, and replaces the tooltip with a rich text
representation if needed. This assures that Qt can word-wrap long tooltip messages.
Tooltips longer than the provided size threshold (in characters) are wrapped.
@@ -116,6 +127,45 @@ namespace GUIUtil
int size_threshold;
};
+ /**
+ * Makes a QTableView last column feel as if it was being resized from its left border.
+ * Also makes sure the column widths are never larger than the table's viewport.
+ * In Qt, all columns are resizable from the right, but it's not intuitive resizing the last column from the right.
+ * Usually our second to last columns behave as if stretched, and when on strech mode, columns aren't resizable
+ * interactively or programatically.
+ *
+ * This helper object takes care of this issue.
+ *
+ */
+ class TableViewLastColumnResizingFixer: public QObject
+ {
+ Q_OBJECT
+
+ public:
+ TableViewLastColumnResizingFixer(QTableView* table, int lastColMinimumWidth, int allColsMinimumWidth);
+ void stretchColumnWidth(int column);
+
+ private:
+ QTableView* tableView;
+ int lastColumnMinimumWidth;
+ int allColumnsMinimumWidth;
+ int lastColumnIndex;
+ int columnCount;
+ int secondToLastColumnIndex;
+
+ void adjustTableColumnsWidth();
+ int getAvailableWidthForColumn(int column);
+ int getColumnsWidth();
+ void connectViewHeadersSignals();
+ void disconnectViewHeadersSignals();
+ void setViewHeaderResizeMode(int logicalIndex, QHeaderView::ResizeMode resizeMode);
+ void resizeColumn(int nColumnIndex, int width);
+
+ private slots:
+ void on_sectionResized(int logicalIndex, int oldSize, int newSize);
+ void on_geometriesChanged();
+ };
+
bool GetStartOnSystemStartup();
bool SetStartOnSystemStartup(bool fAutoStart);
@@ -124,6 +174,38 @@ namespace GUIUtil
/** Restore window size and position */
void restoreWindowGeometry(const QString& strSetting, const QSize &defaultSizeIn, QWidget *parent);
+ /* Convert QString to OS specific boost path through UTF-8 */
+ boost::filesystem::path qstringToBoostPath(const QString &path);
+
+ /* Convert OS specific boost path to QString through UTF-8 */
+ QString boostPathToQString(const boost::filesystem::path &path);
+
+ /* Convert seconds into a QString with days, hours, mins, secs */
+ QString formatDurationStr(int secs);
+
+ /* Format CNodeStats.nServices bitmask into a user-readable string */
+ QString formatServicesStr(quint64 mask);
+
+ /* Format a CNodeCombinedStats.dPingTime into a user-readable string or display N/A, if 0*/
+ QString formatPingTime(double dPingTime);
+
+ /* Format a CNodeCombinedStats.nTimeOffset into a user-readable string. */
+ QString formatTimeOffset(int64_t nTimeOffset);
+
+#if defined(Q_OS_MAC) && QT_VERSION >= 0x050000
+ // workaround for Qt OSX Bug:
+ // https://bugreports.qt-project.org/browse/QTBUG-15631
+ // QProgressBar uses around 10% CPU even when app is in background
+ class ProgressBar : public QProgressBar
+ {
+ bool event(QEvent *e) {
+ return (e->type() != QEvent::StyleAnimationUpdate) ? QProgressBar::event(e) : false;
+ }
+ };
+#else
+ typedef QProgressBar ProgressBar;
+#endif
+
} // namespace GUIUtil
-#endif // GUIUTIL_H
+#endif // BITCOIN_QT_GUIUTIL_H