This commit is contained in:
Martin Rotter 2019-06-04 13:16:48 +02:00
parent 8f7a8f3293
commit 565b07a2e7
16 changed files with 204 additions and 101 deletions

View File

@ -30,7 +30,7 @@
<url type="donation">https://martinrotter.github.io/donate/</url>
<content_rating type="oars-1.1" />
<releases>
<release version="3.5.8" date="2019-06-03"/>
<release version="3.5.9" date="2019-06-04"/>
</releases>
<content_rating type="oars-1.0">
<content_attribute id="violence-cartoon">none</content_attribute>

View File

@ -1,3 +1,12 @@
3.5.9
—————
Added:
▪ Font in message and feed lists is now changeable, including its size. (#187)
Fixed:
▪ Broken backward compatibility to Qt 5.7.
3.5.8
—————

View File

@ -47,7 +47,6 @@ FeedsModel::FeedsModel(QObject* parent) : QAbstractItemModel(parent), m_itemHeig
<< /*: Feed list header "counts" column tooltip.*/ tr("Counts of unread/all mesages.");
setupFonts();
updateItemHeight();
}
FeedsModel::~FeedsModel() {
@ -466,12 +465,14 @@ void FeedsModel::onItemDataChanged(const QList<RootItem*>& items) {
}
void FeedsModel::setupFonts() {
m_normalFont = Application::font("FeedsView");
QFont fon;
fon.fromString(qApp->settings()->value(GROUP(Feeds), Feeds::ListFont, Application::font("FeedsView").toString()).toString());
m_normalFont = fon;
m_boldFont = m_normalFont;
m_boldFont.setBold(true);
}
void FeedsModel::updateItemHeight() {
m_itemHeight = qApp->settings()->value(GROUP(GUI), SETTING(GUI::HeightRowFeeds)).toInt();
if (m_itemHeight > 0) {

View File

@ -17,7 +17,7 @@ class FeedsModel : public QAbstractItemModel {
Q_OBJECT
public:
explicit FeedsModel(QObject* parent = 0);
explicit FeedsModel(QObject* parent = nullptr);
virtual ~FeedsModel();
// Model implementation.
@ -86,6 +86,8 @@ class FeedsModel : public QAbstractItemModel {
// Access to root item.
RootItem* rootItem() const;
void setupFonts();
public slots:
void loadActivatedServiceAccounts();
@ -151,10 +153,6 @@ class FeedsModel : public QAbstractItemModel {
// NOTE: View will probably expand dropped index.
void requireItemValidationAfterDragDrop(const QModelIndex& source_index);
private:
void updateItemHeight();
void setupFonts();
private:
RootItem* m_rootItem;
int m_itemHeight;

View File

@ -22,7 +22,6 @@ MessagesModel::MessagesModel(QObject* parent)
setupIcons();
setupHeaderData();
updateDateFormat();
updateItemHeight();
loadMessages(nullptr);
}
@ -37,17 +36,6 @@ void MessagesModel::setupIcons() {
m_enclosuresIcon = qApp->icons()->fromTheme(QSL("mail-attachment"));
}
void MessagesModel::updateItemHeight() {
m_itemHeight = qApp->settings()->value(GROUP(GUI), SETTING(GUI::HeightRowMessages)).toInt();
if (m_itemHeight > 0) {
m_boldFont.setPixelSize(int(m_itemHeight * 0.6));
m_normalFont.setPixelSize(int(m_itemHeight * 0.6));
m_boldStrikedFont.setPixelSize(int(m_itemHeight * 0.6));
m_normalStrikedFont.setPixelSize(int(m_itemHeight * 0.6));
}
}
void MessagesModel::repopulate() {
m_cache->clear();
setQuery(selectStatement(), m_db);
@ -68,13 +56,26 @@ bool MessagesModel::setData(const QModelIndex& index, const QVariant& value, int
}
void MessagesModel::setupFonts() {
m_normalFont = Application::font("MessagesView");
QFont fon;
fon.fromString(qApp->settings()->value(GROUP(Messages), Messages::ListFont, Application::font("MessagesView").toString()).toString());
m_normalFont = fon;
m_boldFont = m_normalFont;
m_boldFont.setBold(true);
m_normalStrikedFont = m_normalFont;
m_boldStrikedFont = m_boldFont;
m_normalStrikedFont.setStrikeOut(true);
m_boldStrikedFont.setStrikeOut(true);
m_itemHeight = qApp->settings()->value(GROUP(GUI), SETTING(GUI::HeightRowMessages)).toInt();
if (m_itemHeight > 0) {
m_boldFont.setPixelSize(int(m_itemHeight * 0.6));
m_normalFont.setPixelSize(int(m_itemHeight * 0.6));
m_boldStrikedFont.setPixelSize(int(m_itemHeight * 0.6));
m_normalStrikedFont.setPixelSize(int(m_itemHeight * 0.6));
}
}
void MessagesModel::loadMessages(RootItem* item) {

View File

@ -29,7 +29,7 @@ class MessagesModel : public QSqlQueryModel, public MessagesModelSqlLayer {
};
// Constructors and destructors.
explicit MessagesModel(QObject* parent = 0);
explicit MessagesModel(QObject* parent = nullptr);
virtual ~MessagesModel();
// Fetches ALL available data to the model.
@ -50,6 +50,7 @@ class MessagesModel : public QSqlQueryModel, public MessagesModelSqlLayer {
RootItem* loadedItem() const;
void setupFonts();
void updateDateFormat();
void reloadWholeLayout();
@ -77,9 +78,7 @@ class MessagesModel : public QSqlQueryModel, public MessagesModelSqlLayer {
bool setMessageReadById(int id, RootItem::ReadStatus read);
private:
void updateItemHeight();
void setupHeaderData();
void setupFonts();
void setupIcons();
MessagesModelCache* m_cache;

View File

@ -58,7 +58,8 @@ FeedMessageViewer::FeedMessageViewer(QWidget* parent) : TabContent(parent), m_to
initialize();
initializeViews();
loadMessageViewerFonts();
//loadMessageViewerFonts();
createConnections();
}
@ -122,6 +123,8 @@ void FeedMessageViewer::loadSize() {
void FeedMessageViewer::loadMessageViewerFonts() {
m_messagesBrowser->reloadFontSettings();
m_messagesView->reloadFontSettings();
m_feedsView->reloadFontSettings();
}
bool FeedMessageViewer::areToolBarsEnabled() const {

View File

@ -50,6 +50,10 @@ FeedsView::~FeedsView() {
qDebug("Destroying FeedsView instance.");
}
void FeedsView::reloadFontSettings() {
m_sourceModel->setupFonts();
}
void FeedsView::setSortingEnabled(bool enable) {
disconnect(header(), &QHeaderView::sortIndicatorChanged, this, &FeedsView::saveSortState);
QTreeView::setSortingEnabled(enable);

View File

@ -19,7 +19,7 @@ class FeedsView : public QTreeView {
public:
// Constructors and destructors.
explicit FeedsView(QWidget* parent = 0);
explicit FeedsView(QWidget* parent = nullptr);
virtual ~FeedsView();
// Fundamental accessors.
@ -31,6 +31,8 @@ class FeedsView : public QTreeView {
return m_sourceModel;
}
void reloadFontSettings();
void setSortingEnabled(bool enable);
// Returns list of selected/all feeds.

View File

@ -49,12 +49,18 @@ MessagesView::MessagesView(QWidget* parent) : QTreeView(parent), m_contextMenu(n
TreeViewColumnsMenu mm(header());
mm.exec(header()->mapToGlobal(point));
});
reloadFontSettings();
}
MessagesView::~MessagesView() {
qDebug("Destroying MessagesView instance.");
}
void MessagesView::reloadFontSettings() {
m_sourceModel->setupFonts();
}
void MessagesView::sort(int column, Qt::SortOrder order, bool repopulate_data, bool change_header, bool emit_changed_from_header) {
if (change_header && !emit_changed_from_header) {
header()->blockSignals(true);

View File

@ -16,7 +16,7 @@ class MessagesView : public QTreeView {
Q_OBJECT
public:
explicit MessagesView(QWidget* parent = 0);
explicit MessagesView(QWidget* parent = nullptr);
virtual ~MessagesView();
// Model accessors.
@ -28,6 +28,8 @@ class MessagesView : public QTreeView {
return m_sourceModel;
}
void reloadFontSettings();
public slots:
void keyboardSearch(const QString& search);

View File

@ -57,7 +57,18 @@ SettingsFeedsMessages::SettingsFeedsMessages(Settings* settings, QWidget* parent
connect(m_ui->m_cmbCountsFeedList, &QComboBox::currentTextChanged, this, &SettingsFeedsMessages::dirtifySettings);
connect(m_ui->m_cmbCountsFeedList, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
&SettingsFeedsMessages::dirtifySettings);
connect(m_ui->m_btnChangeMessagesFont, &QPushButton::clicked, this, &SettingsFeedsMessages::changeMessagesFont);
connect(m_ui->m_btnChangeMessagesFont, &QPushButton::clicked, this, [&]() {
changeFont(*m_ui->m_lblMessagesFont);
});
connect(m_ui->m_btnChangeFeedListFont, &QPushButton::clicked, this, [&]() {
changeFont(*m_ui->m_lblFeedListFont);
});
connect(m_ui->m_btnChangeMessageListFont, &QPushButton::clicked, this, [&]() {
changeFont(*m_ui->m_lblMessageListFont);
});
if (!m_ui->m_spinFeedUpdateTimeout->suffix().startsWith(' ')) {
m_ui->m_spinFeedUpdateTimeout->setSuffix(QSL(" ") + m_ui->m_spinFeedUpdateTimeout->suffix());
@ -88,14 +99,14 @@ void SettingsFeedsMessages::initializeMessageDateFormats() {
}
}
void SettingsFeedsMessages::changeMessagesFont() {
void SettingsFeedsMessages::changeFont(QLabel& lbl) {
bool ok;
QFont new_font = QFontDialog::getFont(&ok, m_ui->m_lblMessagesFont->font(),
this, tr("Select new font for message viewer"),
QFont new_font = QFontDialog::getFont(&ok, lbl.font(),
this, tr("Select new font"),
QFontDialog::DontUseNativeDialog);
if (ok) {
m_ui->m_lblMessagesFont->setFont(new_font);
lbl.setFont(new_font);
dirtifySettings();
}
}
@ -129,12 +140,28 @@ void SettingsFeedsMessages::loadSettings() {
m_ui->m_cmbMessagesDateTimeFormat->setCurrentIndex(index_format);
}
m_ui->m_lblMessagesFont->setText(tr("Font preview"));
QFont fon;
fon.fromString(settings()->value(GROUP(Messages),
SETTING(Messages::PreviewerFontStandard)).toString());
m_ui->m_lblMessagesFont->setFont(fon);
QFont fon2;
// Keep in sync with void MessagesModel::setupFonts().
fon2.fromString(settings()->value(GROUP(Messages),
Messages::ListFont,
Application::font("MessagesView").toString()).toString());
m_ui->m_lblMessageListFont->setFont(fon2);
QFont fon3;
// Keep in sync with void FeedsModel::setupFonts().
fon3.fromString(settings()->value(GROUP(Feeds),
Feeds::ListFont,
Application::font("FeedsView").toString()).toString());
m_ui->m_lblFeedListFont->setFont(fon3);
onEndLoadSettings();
}
@ -164,12 +191,16 @@ void SettingsFeedsMessages::saveSettings() {
// Save fonts.
settings()->setValue(GROUP(Messages), Messages::PreviewerFontStandard, m_ui->m_lblMessagesFont->font().toString());
qApp->mainForm()->tabWidget()->feedMessageViewer()->loadMessageViewerFonts();
qApp->feedReader()->updateAutoUpdateStatus();
settings()->setValue(GROUP(Messages), Messages::ListFont, m_ui->m_lblMessageListFont->font().toString());
settings()->setValue(GROUP(Feeds), Feeds::ListFont, m_ui->m_lblFeedListFont->font().toString());
qApp->mainForm()->tabWidget()->feedMessageViewer()->loadMessageViewerFonts();
qApp->feedReader()->updateAutoUpdateStatus();
qApp->feedReader()->feedsModel()->reloadWholeLayout();
qApp->feedReader()->messagesModel()->updateDateFormat();
qApp->feedReader()->messagesModel()->reloadWholeLayout();
onEndSaveSettings();
}

View File

@ -22,8 +22,8 @@ class SettingsFeedsMessages : public SettingsPanel {
void saveSettings();
private slots:
void changeMessagesFont();
private:
void changeFont(QLabel& lbl);
private:
void initializeMessageDateFormats();

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>651</width>
<height>295</height>
<height>478</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
@ -26,7 +26,7 @@
<item>
<widget class="QTabWidget" name="m_tabFeedsMessages">
<property name="currentIndex">
<number>1</number>
<number>0</number>
</property>
<widget class="QWidget" name="m_tabFeeds">
<attribute name="title">
@ -78,6 +78,29 @@
</layout>
</item>
<item row="3" column="0">
<widget class="QGroupBox" name="groupBox_6">
<property name="title">
<string>Feed list font</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_18">
<item>
<widget class="QLabel" name="m_lblFeedListFont">
<property name="text">
<string>Font preview</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="m_btnChangeFeedListFont">
<property name="text">
<string>&amp;Change font</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="4" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QLabel" name="label_3">
@ -110,7 +133,7 @@
</item>
</layout>
</item>
<item row="4" column="0">
<item row="5" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_9">
<item>
<widget class="QLabel" name="label_6">
@ -134,7 +157,7 @@
</item>
</layout>
</item>
<item row="5" column="0">
<item row="6" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_8">
<item>
<widget class="QLabel" name="label_8">
@ -158,7 +181,7 @@
</item>
</layout>
</item>
<item row="6" column="0" colspan="2">
<item row="7" column="0" colspan="2">
<widget class="QLabel" name="label_9">
<property name="font">
<font>
@ -190,6 +213,13 @@
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="m_checkDisplayPlaceholders">
<property name="text">
<string>Display placeholders to indicate locations of pictures</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="m_checkKeppMessagesInTheMiddle">
<property name="text">
@ -197,6 +227,30 @@
</property>
</widget>
</item>
<item row="3" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Height or rows in message list (-1 = default height)</string>
</property>
<property name="buddy">
<cstring>m_spinHeightRowsMessages</cstring>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="m_spinHeightRowsMessages">
<property name="minimum">
<number>-1</number>
</property>
<property name="maximum">
<number>100</number>
</property>
</widget>
</item>
</layout>
</item>
<item row="4" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
@ -237,73 +291,56 @@
<item row="5" column="1">
<widget class="QComboBox" name="m_cmbMessagesDateTimeFormat"/>
</item>
<item row="6" column="0" colspan="2">
<widget class="QGroupBox" name="groupBox_4">
<property name="title">
<string>Internal message browser fonts</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_16">
<item>
<widget class="QLabel" name="m_lblMessagesFont">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="m_btnChangeMessagesFont">
<property name="text">
<string>&amp;Change font</string>
</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>
</widget>
</item>
<item row="3" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item row="6" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Height or rows in message list (-1 = default height)</string>
</property>
<property name="buddy">
<cstring>m_spinHeightRowsMessages</cstring>
<widget class="QGroupBox" name="groupBox_5">
<property name="title">
<string>Message list font</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_17">
<item>
<widget class="QLabel" name="m_lblMessageListFont">
<property name="text">
<string>Font preview</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="m_btnChangeMessageListFont">
<property name="text">
<string>&amp;Change font</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QSpinBox" name="m_spinHeightRowsMessages">
<property name="minimum">
<number>-1</number>
</property>
<property name="maximum">
<number>100</number>
<widget class="QGroupBox" name="groupBox_4">
<property name="title">
<string>Internal message browser font</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_16">
<item>
<widget class="QLabel" name="m_lblMessagesFont">
<property name="text">
<string>Font preview</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="m_btnChangeMessagesFont">
<property name="text">
<string>&amp;Change font</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="m_checkDisplayPlaceholders">
<property name="text">
<string>Display placeholders to indicate locations of pictures</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
@ -323,6 +360,7 @@
<tabstop>m_checkAutoUpdateNotification</tabstop>
<tabstop>m_checkAutoUpdate</tabstop>
<tabstop>m_spinAutoUpdateInterval</tabstop>
<tabstop>m_btnChangeFeedListFont</tabstop>
<tabstop>m_spinFeedUpdateTimeout</tabstop>
<tabstop>m_spinHeightRowsFeeds</tabstop>
<tabstop>m_cmbCountsFeedList</tabstop>
@ -333,6 +371,7 @@
<tabstop>m_spinHeightImageAttachments</tabstop>
<tabstop>m_checkMessagesDateTimeFormat</tabstop>
<tabstop>m_cmbMessagesDateTimeFormat</tabstop>
<tabstop>m_btnChangeMessageListFont</tabstop>
<tabstop>m_btnChangeMessagesFont</tabstop>
</tabstops>
<resources/>

View File

@ -55,6 +55,8 @@ DKEY Feeds::ShowOnlyUnreadFeeds = "show_only_unread_feeds";
DVALUE(bool) Feeds::ShowOnlyUnreadFeedsDef = false;
DKEY Feeds::ListFont = "list_font";
// Messages.
DKEY Messages::ID = "messages";
DKEY Messages::MessageHeadImageHeight = "message_head_image_height";
@ -91,6 +93,8 @@ DKEY Messages::PreviewerFontStandard = "previewer_font_standard";
NON_CONST_DVALUE(QString) Messages::PreviewerFontStandardDef = QFont(QFont().family(), 12).toString();
DKEY Messages::ListFont = "list_font";
// GUI.
DKEY GUI::ID = "gui";
DKEY GUI::MessageViewState = "msg_view_state";

View File

@ -75,6 +75,8 @@ namespace Feeds {
KEY ShowOnlyUnreadFeeds;
VALUE(bool) ShowOnlyUnreadFeedsDef;
KEY ListFont;
}
// Messages.
@ -113,6 +115,8 @@ namespace Messages {
KEY PreviewerFontStandard;
NON_CONST_VALUE(QString) PreviewerFontStandardDef;
KEY ListFont;
}
// GUI.