diff --git a/retroshare-gui/src/gui/FileTransfer/SearchDialog.cpp b/retroshare-gui/src/gui/FileTransfer/SearchDialog.cpp index b3d74d6c4..db11ab613 100644 --- a/retroshare-gui/src/gui/FileTransfer/SearchDialog.cpp +++ b/retroshare-gui/src/gui/FileTransfer/SearchDialog.cpp @@ -38,6 +38,7 @@ #include "gui/common/RSTreeWidgetItem.h" #include "util/QtVersion.h" #include "util/qtthreadsutils.h" +#include "util/misc.h" #include #include @@ -167,8 +168,8 @@ SearchDialog::SearchDialog(QWidget *parent) // To allow a proper sorting, be careful to pad at right with spaces. This // is achieved by using QString("%1").arg(number,15,10). // - ui.searchResultWidget->setItemDelegateForColumn(SR_SIZE_COL, mSizeColumnDelegate=new RSHumanReadableSizeDelegate()) ; - ui.searchResultWidget->setItemDelegateForColumn(SR_AGE_COL, mAgeColumnDelegate=new RSHumanReadableAgeDelegate()) ; + //ui.searchResultWidget->setItemDelegateForColumn(SR_SIZE_COL, mSizeColumnDelegate=new RSHumanReadableSizeDelegate()) ; + //ui.searchResultWidget->setItemDelegateForColumn(SR_AGE_COL, mAgeColumnDelegate=new RSHumanReadableAgeDelegate()) ; /* make it extended selection */ ui.searchResultWidget -> setSelectionMode(QAbstractItemView::ExtendedSelection); @@ -255,8 +256,8 @@ SearchDialog::~SearchDialog() delete mSizeColumnDelegate; delete mAgeColumnDelegate; - ui.searchResultWidget->setItemDelegateForColumn(SR_SIZE_COL, nullptr); - ui.searchResultWidget->setItemDelegateForColumn(SR_AGE_COL, nullptr); + //ui.searchResultWidget->setItemDelegateForColumn(SR_SIZE_COL, nullptr); + //ui.searchResultWidget->setItemDelegateForColumn(SR_AGE_COL, nullptr); rsEvents->unregisterEventsHandler(mEventHandlerId); } @@ -1325,11 +1326,13 @@ void SearchDialog::insertFile(qulonglong searchId, const FileDetail& file, int s * to facilitate downloads we need to save the file size too */ - item->setText(SR_SIZE_COL, QString::number(file.size)); + item->setText(SR_SIZE_COL, misc::friendlyUnit(file.size)); item->setData(SR_SIZE_COL, ROLE_SORT, (qulonglong) file.size); - item->setText(SR_AGE_COL, QString::number(file.mtime)); + item->setText(SR_AGE_COL, misc::timeRelativeToNow(file.mtime)); item->setData(SR_AGE_COL, ROLE_SORT, file.mtime); item->setTextAlignment( SR_SIZE_COL, Qt::AlignRight ); + item->setTextAlignment( SR_AGE_COL, Qt::AlignCenter ); + int friendSource = 0; int anonymousSource = 0; if(searchType == FRIEND_SEARCH) @@ -1627,3 +1630,26 @@ void SearchDialog::openFolderSearch() } } } + +void SearchDialog::showEvent(QShowEvent *event) +{ + if (!event->spontaneous()) { + updateFontSize(); + } +} + +void SearchDialog::updateFontSize() +{ +#if defined(Q_OS_DARWIN) + int customFontSize = Settings->valueFromGroup("File", "MinimumFontSize", 13).toInt(); +#else + int customFontSize = Settings->valueFromGroup("File", "MinimumFontSize", 12).toInt(); +#endif + QFont newFont = ui.searchSummaryWidget->font(); + if (newFont.pointSize() != customFontSize) { + newFont.setPointSize(customFontSize); + QFontMetricsF fontMetrics(newFont); + ui.searchSummaryWidget->setFont(newFont); + ui.searchResultWidget->setFont(newFont); + } +} diff --git a/retroshare-gui/src/gui/FileTransfer/SearchDialog.h b/retroshare-gui/src/gui/FileTransfer/SearchDialog.h index 8aa7bac64..aa5c4e2b4 100644 --- a/retroshare-gui/src/gui/FileTransfer/SearchDialog.h +++ b/retroshare-gui/src/gui/FileTransfer/SearchDialog.h @@ -66,6 +66,9 @@ public: void updateFiles(qulonglong request_id, const FileDetail& file) ; +protected: + virtual void showEvent(QShowEvent *) override; + private slots: /** Create the context popup menu and it's submenus */ @@ -116,6 +119,8 @@ private slots: void filterItems(); + void updateFontSize(); + private: /** render the results to the tree widget display */ void initSearchResult(const QString& txt,qulonglong searchId, int fileType, bool advanced) ;