mirror of
https://github.com/wownero/wowlet.git
synced 2026-10-21 17:18:43 +02:00
Feather, a free Monero desktop wallet
Co-Authored-By: tobtoht <thotbot@protonmail.com>
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
// Copyright (c) 2020, The Monero Project.
|
||||
|
||||
#include "ModelUtils.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QStringList>
|
||||
#include <QClipboard>
|
||||
#include <QApplication>
|
||||
#include <QFont>
|
||||
#include <QFontDatabase>
|
||||
#include <QFontInfo>
|
||||
|
||||
QString ModelUtils::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 << "...";
|
||||
for (int i = sections; i > 0; i -= 1) {
|
||||
list << address.mid(address.length() - i * 5, 5);
|
||||
}
|
||||
return list.join(sep);
|
||||
}
|
||||
|
||||
void ModelUtils::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);
|
||||
}
|
||||
|
||||
QFont ModelUtils::getMonospaceFont()
|
||||
{
|
||||
if (QFontInfo(QApplication::font()).fixedPitch()) {
|
||||
return QApplication::font();
|
||||
}
|
||||
return QFontDatabase::systemFont(QFontDatabase::FixedFont);
|
||||
}
|
||||
Reference in New Issue
Block a user