Added for channel composer default size settings

This commit is contained in:
defnax 2025-02-10 19:41:19 +01:00
parent 3ffa362079
commit 6d394c9f55
7 changed files with 149 additions and 91 deletions

View File

@ -34,6 +34,7 @@
#include <QDesktopWidget>
#include <QMenu>
#include <QToolButton>
#include <QShowEvent>
#include <stdint.h>
@ -67,6 +68,8 @@ GroupTreeWidget::GroupTreeWidget(QWidget *parent) :
connect(ui->treeWidget, SIGNAL(itemClicked(QTreeWidgetItem*,int)), this, SLOT(itemActivated(QTreeWidgetItem*,int)));
}
updateFontSize();
int H = QFontMetricsF(ui->treeWidget->font()).height() ;
#if QT_VERSION < QT_VERSION_CHECK(5,11,0)
int W = QFontMetricsF(ui->treeWidget->font()).width("_") ;
@ -667,3 +670,26 @@ void GroupTreeWidget::sort()
{
ui->treeWidget->resort();
}
void GroupTreeWidget::showEvent(QShowEvent *event)
{
if (!event->spontaneous()) {
updateFontSize();
}
}
void GroupTreeWidget::updateFontSize()
{
#if defined(Q_OS_DARWIN)
int customFontSize = Settings->valueFromGroup("File", "MinimumFontSize", 13).toInt();
#else
int customFontSize = Settings->valueFromGroup("File", "MinimumFontSize", 11).toInt();
#endif
QFont newFont = ui->treeWidget->font();
if (newFont.pointSize() != customFontSize) {
newFont.setPointSize(customFontSize);
QFontMetricsF fontMetrics(newFont);
ui->treeWidget->setFont(newFont);
}
}

View File

@ -30,6 +30,7 @@ class QToolButton;
class RshareSettings;
class RSTreeWidgetItemCompareRole;
class RSTreeWidget;
class QShowEvent;
#define GROUPTREEWIDGET_COLOR_STANDARD -1
#define GROUPTREEWIDGET_COLOR_CATEGORY 0
@ -142,6 +143,7 @@ signals:
protected:
void changeEvent(QEvent *e);
virtual void showEvent(QShowEvent *) override;
private slots:
void customContextMenuRequested(const QPoint &pos);
@ -151,6 +153,7 @@ private slots:
void distantSearch();
void sort();
void updateFontSize();
private:
void calculateScore(QTreeWidgetItem *item, const QString &filterText);

View File

@ -193,9 +193,6 @@ void GxsGroupFrameDialog::showEvent(QShowEvent* /*event*/)
bool empty = mCachedGroupMetas.empty() || children==0;
updateDisplay( empty );
updateFontSize();
}
void GxsGroupFrameDialog::paintEvent(QPaintEvent *pe)
@ -1277,19 +1274,3 @@ void GxsGroupFrameDialog::distantRequestGroupData()
checkRequestGroup(group_id) ;
}
void GxsGroupFrameDialog::updateFontSize()
{
#if defined(Q_OS_DARWIN)
int customFontSize = Settings->valueFromGroup("File", "MinimumFontSize", 13).toInt();
#else
int customFontSize = Settings->valueFromGroup("File", "MinimumFontSize", 11).toInt();
#endif
QFont newFont = ui->groupTreeWidget->font();
if (newFont.pointSize() != customFontSize) {
newFont.setPointSize(customFontSize);
QFontMetricsF fontMetrics(newFont);
ui->groupTreeWidget->setFont(newFont);
}
}

View File

@ -110,8 +110,7 @@ protected:
void updateGroupStatisticsReal(const RsGxsGroupId &groupId);
void updateMessageSummaryListReal(RsGxsGroupId groupId);
void updateFontSize();
private slots:
void todo();

View File

@ -17,43 +17,14 @@
</sizepolicy>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>Distant messages:</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="2">
<widget class="RSComboBox" name="comboBox">
<item>
<property name="text">
<string>Everyone</string>
</property>
</item>
<item>
<property name="text">
<string>Contacts</string>
</property>
</item>
<item>
<property name="text">
<string>Nobody</string>
</property>
</item>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Accept encrypted distant messages from</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="0">
<widget class="QGroupBox" name="groupBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Reading</string>
</property>
@ -65,40 +36,6 @@
</property>
</widget>
</item>
<item row="0" column="1">
<layout class="QHBoxLayout" name="minimumFontSizeHLayout">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="minimumFontSizeLabel">
<property name="text">
<string>Minimum font size </string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="minimumFontSize_SB">
<property name="minimum">
<number>10</number>
</property>
<property name="maximum">
<number>64</number>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="loadEmbeddedImages">
<property name="text">
@ -130,7 +67,7 @@
</layout>
</widget>
</item>
<item row="2" column="0">
<item row="3" column="0" colspan="2">
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Tags</string>
@ -206,6 +143,93 @@
</layout>
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>Distant messages:</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="2">
<widget class="RSComboBox" name="comboBox">
<item>
<property name="text">
<string>Everyone</string>
</property>
</item>
<item>
<property name="text">
<string>Contacts</string>
</property>
</item>
<item>
<property name="text">
<string>Nobody</string>
</property>
</item>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Accept encrypted distant messages from</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="2" column="0">
<widget class="QGroupBox" name="groupBox_4">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Fonts</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="minimumFontSizeHLayout">
<item>
<widget class="QLabel" name="minimumFontSizeLabel">
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string>Minimum font size </string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="minimumFontSize_SB">
<property name="minimum">
<number>10</number>
</property>
<property name="maximum">
<number>64</number>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<customwidgets>

View File

@ -614,3 +614,26 @@ void RichTextEdit::checkLength(){
void RichTextEdit::setPlaceHolderTextPosted() {
f_textedit->setPlaceholderText(tr("Text (optional)"));
}
void RichTextEdit::showEvent(QShowEvent *event)
{
if (!event->spontaneous()) {
updateFontSize();
}
}
void RichTextEdit::updateFontSize()
{
#if defined(Q_OS_DARWIN)
int customFontSize = Settings->valueFromGroup("Messages", "MinimumFontSize", 13).toInt();
#else
int customFontSize = Settings->valueFromGroup("Messages", "MinimumFontSize", 12).toInt();
#endif
QFont newFont = f_textedit->font();
if (newFont.pointSize() != customFontSize) {
newFont.setPointSize(customFontSize);
QFontMetricsF fontMetrics(newFont);
f_textedit->setFont(newFont);
f_fontsize->setCurrentIndex(f_fontsize->findText(QString::number(newFont.pointSize())));
}
}

View File

@ -69,6 +69,7 @@ signals:
void insertImage();
void textSource();
void checkLength();
void updateFontSize();
protected:
void mergeFormatOnWordOrSelection(const QTextCharFormat &format);
@ -78,6 +79,7 @@ signals:
void list(bool checked, QTextListFormat::Style style);
void indent(int delta);
void focusInEvent(QFocusEvent *event);
virtual void showEvent(QShowEvent *);
QStringList m_paragraphItems;
int m_fontsize_h1;