gui: file: add power to change font size for displayed shared files

Added one more settings group "File".
This commit is contained in:
chelovechishko 2022-05-09 00:27:50 +09:00
parent ed0ea3aa01
commit ca0a441f3b
6 changed files with 67 additions and 10 deletions

View file

@ -241,10 +241,6 @@ SharedFilesDialog::SharedFilesDialog(bool remote_mode, QWidget *parent)
/* Set Multi Selection */
ui.dirTreeView->setSelectionMode(QAbstractItemView::ExtendedSelection);
QFontMetricsF fontMetrics(ui.dirTreeView->font());
int iconHeight = fontMetrics.height() * 1.5;
ui.dirTreeView->setIconSize(QSize(iconHeight, iconHeight));
/* Hide platform specific features */
copylinkAct = new QAction(QIcon(IMAGE_COPYLINK), tr( "Copy retroshare Links to Clipboard" ), this );
connect( copylinkAct , SIGNAL( triggered() ), this, SLOT( copyLink() ) );
@ -323,7 +319,7 @@ void SharedFilesDialog::hideEvent(QHideEvent *)
model->setVisible(false) ;
}
void SharedFilesDialog::showEvent(QShowEvent *)
void SharedFilesDialog::showEvent(QShowEvent *event)
{
if(model!=NULL)
{
@ -336,6 +332,10 @@ void SharedFilesDialog::showEvent(QShowEvent *)
restoreExpandedPathsAndSelection(expanded_indexes,hidden_indexes,selected_indexes);
}
if (!event->spontaneous()) {
updateFontSize();
}
}
RemoteSharedFilesDialog::~RemoteSharedFilesDialog()
{
@ -1686,3 +1686,16 @@ bool SharedFilesDialog::tree_FilterItem(const QModelIndex &index, const QString
return (visible || visibleChildCount);
}
#endif
void SharedFilesDialog::updateFontSize()
{
int customFontSize = Settings->valueFromGroup("File", "MinimumFontSize", 11).toInt();
QFont newFont = ui.dirTreeView->font();
if (newFont.pointSize() != customFontSize) {
newFont.setPointSize(customFontSize);
QFontMetricsF fontMetrics(newFont);
int iconHeight = fontMetrics.height();
ui.dirTreeView->setFont(newFont);
ui.dirTreeView->setIconSize(QSize(iconHeight, iconHeight));
}
}

View file

@ -117,6 +117,8 @@ protected:
QModelIndexList getSelected();
void updateFontSize();
/** Defines the actions for the context menu for QTreeWidget */
QAction* copylinkAct;
QAction* sendlinkAct;

View file

@ -356,11 +356,6 @@ border-image: url(:/images/closepressed.png)
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>