mirror of
https://github.com/martinrotter/rssguard.git
synced 2025-01-27 07:46:17 +01:00
customize padding for msg list
This commit is contained in:
parent
01efdab258
commit
6242bfa60c
@ -450,8 +450,6 @@ QVariant MessagesModel::data(const QModelIndex& idx, int role) const {
|
||||
Qt::AlignmentFlag::AlignVCenter,
|
||||
str).size();
|
||||
|
||||
//rct.setHeight(rct.height() + 20);
|
||||
|
||||
return rct;
|
||||
}
|
||||
}
|
||||
|
@ -805,7 +805,10 @@ void FeedsView::setupAppearance() {
|
||||
setAllColumnsShowFocus(false);
|
||||
setRootIsDecorated(false);
|
||||
setSelectionMode(QAbstractItemView::SelectionMode::SingleSelection);
|
||||
setItemDelegate(new StyledItemDelegateWithoutFocus(GUI::HeightRowFeeds, this));
|
||||
setItemDelegate(new StyledItemDelegateWithoutFocus(qApp->settings()->value(GROUP(GUI),
|
||||
SETTING(GUI::HeightRowFeeds)).toInt(),
|
||||
-1,
|
||||
this));
|
||||
}
|
||||
|
||||
void FeedsView::invalidateReadFeedsFilter(bool set_new_value, bool show_unread_only) {
|
||||
|
@ -251,7 +251,11 @@ void MessagesView::setupAppearance() {
|
||||
setSortingEnabled(true);
|
||||
setAllColumnsShowFocus(false);
|
||||
setSelectionMode(QAbstractItemView::SelectionMode::ExtendedSelection);
|
||||
setItemDelegate(new StyledItemDelegateWithoutFocus(GUI::HeightRowMessages, this));
|
||||
setItemDelegate(new StyledItemDelegateWithoutFocus(qApp->settings()->value(GROUP(GUI),
|
||||
SETTING(GUI::HeightRowMessages)).toInt(),
|
||||
qApp->settings()->value(GROUP(Messages),
|
||||
SETTING(Messages::ArticleListPadding)).toInt(),
|
||||
this));
|
||||
|
||||
header()->setDefaultSectionSize(MESSAGES_VIEW_DEFAULT_COL);
|
||||
header()->setMinimumSectionSize(MESSAGES_VIEW_MINIMUM_COL);
|
||||
|
@ -4,8 +4,8 @@
|
||||
|
||||
#include "miscellaneous/application.h"
|
||||
|
||||
StyledItemDelegateWithoutFocus::StyledItemDelegateWithoutFocus(const QString& row_height_settings_key, QObject* parent)
|
||||
: QStyledItemDelegate(parent), m_rowHeightSettingsKey(row_height_settings_key) {}
|
||||
StyledItemDelegateWithoutFocus::StyledItemDelegateWithoutFocus(int height_row, int padding_row, QObject* parent)
|
||||
: QStyledItemDelegate(parent), m_rowHeight(height_row), m_rowPadding(padding_row) {}
|
||||
|
||||
void StyledItemDelegateWithoutFocus::paint(QPainter* painter,
|
||||
const QStyleOptionViewItem& option,
|
||||
@ -26,13 +26,19 @@ void StyledItemDelegateWithoutFocus::paint(QPainter* painter,
|
||||
}
|
||||
|
||||
QSize StyledItemDelegateWithoutFocus::sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const {
|
||||
auto row_height = qApp->settings()->value(GROUP(GUI), m_rowHeightSettingsKey).toInt();
|
||||
auto original_hint = QStyledItemDelegate::sizeHint(option, index);
|
||||
QSize new_hint;
|
||||
|
||||
if (row_height <= 0) {
|
||||
return original_hint;
|
||||
if (m_rowHeight <= 0) {
|
||||
new_hint = original_hint;
|
||||
}
|
||||
else {
|
||||
return QSize(original_hint.width(), row_height);
|
||||
new_hint = QSize(original_hint.width(), m_rowHeight);
|
||||
}
|
||||
|
||||
if (m_rowPadding > 0) {
|
||||
new_hint.setHeight(new_hint.height() + (2 * m_rowPadding));
|
||||
}
|
||||
|
||||
return new_hint;
|
||||
}
|
||||
|
@ -15,13 +15,14 @@ class StyledItemDelegateWithoutFocus : public QStyledItemDelegate {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit StyledItemDelegateWithoutFocus(const QString& row_height_settings_key, QObject* parent = nullptr);
|
||||
explicit StyledItemDelegateWithoutFocus(int height_row, int padding_row, QObject* parent = nullptr);
|
||||
|
||||
virtual void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const;
|
||||
virtual QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const;
|
||||
|
||||
private:
|
||||
QString m_rowHeightSettingsKey;
|
||||
int m_rowHeight;
|
||||
int m_rowPadding;
|
||||
};
|
||||
|
||||
#endif // STYLEDITEMDELEGATEWITHOUTFOCUS_H
|
||||
|
@ -72,8 +72,16 @@ SettingsFeedsMessages::SettingsFeedsMessages(Settings* settings, QWidget* parent
|
||||
this, &SettingsFeedsMessages::dirtifySettings);
|
||||
connect(m_ui->m_spinHeightRowsMessages, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged),
|
||||
this, &SettingsFeedsMessages::dirtifySettings);
|
||||
connect(m_ui->m_spinHeightRowsMessages, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged),
|
||||
this, &SettingsFeedsMessages::requireRestart);
|
||||
connect(m_ui->m_spinHeightRowsFeeds, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged),
|
||||
this, &SettingsFeedsMessages::dirtifySettings);
|
||||
connect(m_ui->m_spinHeightRowsFeeds, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged),
|
||||
this, &SettingsFeedsMessages::requireRestart);
|
||||
connect(m_ui->m_spinPaddingRowsMessages, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged),
|
||||
this, &SettingsFeedsMessages::dirtifySettings);
|
||||
connect(m_ui->m_spinPaddingRowsMessages, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged),
|
||||
this, &SettingsFeedsMessages::requireRestart);
|
||||
connect(m_ui->m_checkAutoUpdate, &QCheckBox::toggled, m_ui->m_spinAutoUpdateInterval, &TimeSpinBox::setEnabled);
|
||||
connect(m_ui->m_checkUpdateAllFeedsOnStartup, &QCheckBox::toggled, m_ui->m_spinStartupUpdateDelay, &TimeSpinBox::setEnabled);
|
||||
connect(m_ui->m_spinFeedUpdateTimeout, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this,
|
||||
@ -154,6 +162,7 @@ void SettingsFeedsMessages::changeFont(QLabel& lbl) {
|
||||
void SettingsFeedsMessages::loadSettings() {
|
||||
onBeginLoadSettings();
|
||||
|
||||
m_ui->m_spinPaddingRowsMessages->setValue(settings()->value(GROUP(Messages), SETTING(Messages::ArticleListPadding)).toInt());
|
||||
m_ui->m_spinHeightRowsMessages->setValue(settings()->value(GROUP(GUI), SETTING(GUI::HeightRowMessages)).toInt());
|
||||
m_ui->m_spinHeightRowsFeeds->setValue(settings()->value(GROUP(GUI), SETTING(GUI::HeightRowFeeds)).toInt());
|
||||
|
||||
@ -235,6 +244,7 @@ void SettingsFeedsMessages::loadSettings() {
|
||||
void SettingsFeedsMessages::saveSettings() {
|
||||
onBeginSaveSettings();
|
||||
|
||||
settings()->setValue(GROUP(Messages), Messages::ArticleListPadding, m_ui->m_spinPaddingRowsMessages->value());
|
||||
settings()->setValue(GROUP(GUI), GUI::HeightRowMessages, m_ui->m_spinHeightRowsMessages->value());
|
||||
settings()->setValue(GROUP(GUI), GUI::HeightRowFeeds, m_ui->m_spinHeightRowsFeeds->value());
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>489</width>
|
||||
<height>476</height>
|
||||
<height>531</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
@ -339,7 +339,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="0">
|
||||
<item row="11" column="0">
|
||||
<widget class="QLabel" name="m_lblHeightImageAttachments">
|
||||
<property name="text">
|
||||
<string>Image attachments height</string>
|
||||
@ -349,7 +349,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="1">
|
||||
<item row="11" column="1">
|
||||
<widget class="QSpinBox" name="m_spinHeightImageAttachments">
|
||||
<property name="suffix">
|
||||
<string notr="true"> px</string>
|
||||
@ -362,7 +362,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="11" column="0">
|
||||
<item row="12" column="0">
|
||||
<widget class="QCheckBox" name="m_checkMessagesDateTimeFormat">
|
||||
<property name="text">
|
||||
<string>Use custom date/time format</string>
|
||||
@ -375,7 +375,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="11" column="1">
|
||||
<item row="12" column="1">
|
||||
<widget class="QComboBox" name="m_cmbMessagesDateTimeFormat">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
@ -385,7 +385,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="12" column="0">
|
||||
<item row="13" column="0">
|
||||
<widget class="QCheckBox" name="m_checkMessagesTimeFormat">
|
||||
<property name="text">
|
||||
<string>Show only time for today articles</string>
|
||||
@ -398,7 +398,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="12" column="1">
|
||||
<item row="13" column="1">
|
||||
<widget class="QComboBox" name="m_cmbMessagesTimeFormat">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
@ -408,7 +408,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="13" column="0" colspan="2">
|
||||
<item row="14" column="0" colspan="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_5">
|
||||
@ -477,7 +477,7 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="15" column="0" colspan="2">
|
||||
<item row="16" column="0" colspan="2">
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
@ -507,6 +507,35 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="1">
|
||||
<widget class="QSpinBox" name="m_spinPaddingRowsMessages">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<string notr="true"> px</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>-1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>100</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Article list top/bottom row padding</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>m_spinPaddingRowsMessages</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
@ -549,6 +578,7 @@
|
||||
<tabstop>m_checkKeppMessagesInTheMiddle</tabstop>
|
||||
<tabstop>m_checkMultilineArticleList</tabstop>
|
||||
<tabstop>m_spinHeightRowsMessages</tabstop>
|
||||
<tabstop>m_spinPaddingRowsMessages</tabstop>
|
||||
<tabstop>m_spinHeightImageAttachments</tabstop>
|
||||
<tabstop>m_checkMessagesDateTimeFormat</tabstop>
|
||||
<tabstop>m_cmbMessagesDateTimeFormat</tabstop>
|
||||
|
@ -105,6 +105,9 @@ DVALUE(bool) Messages::UseCustomDateDef = false;
|
||||
DKEY Messages::CustomDateFormat = "custom_date_format";
|
||||
DVALUE(char*) Messages::CustomDateFormatDef = "";
|
||||
|
||||
DKEY Messages::ArticleListPadding = "article_list_padding";
|
||||
DVALUE(int) Messages::ArticleListPaddingDef = -1;
|
||||
|
||||
DKEY Messages::MultilineArticleList = "multiline_article_list";
|
||||
DVALUE(bool) Messages::MultilineArticleListDef = false;
|
||||
|
||||
|
@ -125,6 +125,9 @@ namespace Messages {
|
||||
KEY UseCustomTime;
|
||||
VALUE(bool) UseCustomTimeDef;
|
||||
|
||||
KEY ArticleListPadding;
|
||||
VALUE(int) ArticleListPaddingDef;
|
||||
|
||||
KEY MultilineArticleList;
|
||||
VALUE(bool) MultilineArticleListDef;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user