mirror of
https://github.com/wownero/wowlet.git
synced 2026-10-20 00:28:39 +02:00
refactor: move ModelUtils into Utils
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
#include <QClipboard>
|
||||
#include <QDesktopServices>
|
||||
#include <QPushButton>
|
||||
#include <QFontDatabase>
|
||||
|
||||
#include "constants.h"
|
||||
#include "networktype.h"
|
||||
@@ -229,6 +230,16 @@ QString copyFromClipboard() {
|
||||
return clipboard->text();
|
||||
}
|
||||
|
||||
void copyColumn(QModelIndex *index, int column) {
|
||||
QString string(index->model()->data(index->siblingAtColumn(column), Qt::UserRole).toString());
|
||||
QClipboard * clipboard = QApplication::clipboard();
|
||||
if (!clipboard) {
|
||||
qWarning() << "Unable to access clipboard";
|
||||
return;
|
||||
}
|
||||
clipboard->setText(string);
|
||||
}
|
||||
|
||||
QString xdgDesktopEntry(){
|
||||
return QString(
|
||||
"[Desktop Entry]\n"
|
||||
@@ -507,6 +518,19 @@ void desktopNotify(const QString &title, const QString &message, int duration) {
|
||||
}
|
||||
}
|
||||
|
||||
QString displayAddress(const QString& address, int sections, const QString& sep) {
|
||||
QStringList list;
|
||||
if (sections < 1) sections = 1;
|
||||
for (int i = 0; i < sections; i += 1) {
|
||||
list << address.mid(i*5, 5);
|
||||
}
|
||||
list << "…"; // utf-8 Horizontal Ellipsis
|
||||
for (int i = sections; i > 0; i -= 1) {
|
||||
list << address.mid(address.length() - i * 5, 5);
|
||||
}
|
||||
return list.join(sep);
|
||||
}
|
||||
|
||||
QTextCharFormat addressTextFormat(const SubaddressIndex &index, quint64 amount) {
|
||||
QTextCharFormat rec;
|
||||
if (index.isPrimary()) {
|
||||
@@ -566,6 +590,14 @@ QString getAccountName() {
|
||||
return accountName;
|
||||
}
|
||||
|
||||
QFont getMonospaceFont()
|
||||
{
|
||||
if (QFontInfo(QApplication::font()).fixedPitch()) {
|
||||
return QApplication::font();
|
||||
}
|
||||
return QFontDatabase::systemFont(QFontDatabase::FixedFont);
|
||||
}
|
||||
|
||||
QFont relativeFont(int delta) {
|
||||
auto font = QApplication::font();
|
||||
font.setPointSize(font.pointSize() + delta);
|
||||
|
||||
Reference in New Issue
Block a user