fix setting row height in lists of feeds and messages
This commit is contained in:
parent
c9ca548ebb
commit
71dd65aef9
18 changed files with 37 additions and 40 deletions
|
@ -26,7 +26,7 @@
|
||||||
<url type="donation">https://github.com/sponsors/martinrotter</url>
|
<url type="donation">https://github.com/sponsors/martinrotter</url>
|
||||||
<content_rating type="oars-1.1" />
|
<content_rating type="oars-1.1" />
|
||||||
<releases>
|
<releases>
|
||||||
<release version="4.0.4" date="2021-11-01"/>
|
<release version="4.0.4" date="2021-11-02"/>
|
||||||
</releases>
|
</releases>
|
||||||
<content_rating type="oars-1.0">
|
<content_rating type="oars-1.0">
|
||||||
<content_attribute id="violence-cartoon">none</content_attribute>
|
<content_attribute id="violence-cartoon">none</content_attribute>
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
|
|
||||||
using RootItemPtr = RootItem*;
|
using RootItemPtr = RootItem*;
|
||||||
|
|
||||||
FeedsModel::FeedsModel(QObject* parent) : QAbstractItemModel(parent), m_itemHeight(-1) {
|
FeedsModel::FeedsModel(QObject* parent) : QAbstractItemModel(parent) {
|
||||||
setObjectName(QSL("FeedsModel"));
|
setObjectName(QSL("FeedsModel"));
|
||||||
|
|
||||||
// Create root item.
|
// Create root item.
|
||||||
|
@ -120,7 +120,7 @@ bool FeedsModel::dropMimeData(const QMimeData* data, Qt::DropAction action, int
|
||||||
qApp->showGuiMessage(Notification::Event::GeneralEvent, {
|
qApp->showGuiMessage(Notification::Event::GeneralEvent, {
|
||||||
tr("Cannot perform drag & drop operation"),
|
tr("Cannot perform drag & drop operation"),
|
||||||
tr("You can't transfer dragged item into different account, this is not supported."),
|
tr("You can't transfer dragged item into different account, this is not supported."),
|
||||||
QSystemTrayIcon::MessageIcon::Warning });
|
QSystemTrayIcon::MessageIcon::Critical });
|
||||||
qDebugNN << LOGSEC_FEEDMODEL
|
qDebugNN << LOGSEC_FEEDMODEL
|
||||||
<< "Dragged item cannot be dragged into different account. Cancelling drag-drop action.";
|
<< "Dragged item cannot be dragged into different account. Cancelling drag-drop action.";
|
||||||
return false;
|
return false;
|
||||||
|
@ -459,13 +459,6 @@ void FeedsModel::setupFonts() {
|
||||||
m_normalFont = fon;
|
m_normalFont = fon;
|
||||||
m_boldFont = m_normalFont;
|
m_boldFont = m_normalFont;
|
||||||
m_boldFont.setBold(true);
|
m_boldFont.setBold(true);
|
||||||
|
|
||||||
m_itemHeight = qApp->settings()->value(GROUP(GUI), SETTING(GUI::HeightRowFeeds)).toInt();
|
|
||||||
|
|
||||||
if (m_itemHeight > 0) {
|
|
||||||
m_boldFont.setPixelSize(int(m_itemHeight * 0.6));
|
|
||||||
m_normalFont.setPixelSize(int(m_itemHeight * 0.6));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FeedsModel::reloadWholeLayout() {
|
void FeedsModel::reloadWholeLayout() {
|
||||||
|
|
|
@ -148,7 +148,6 @@ class RSSGUARD_DLLSPEC FeedsModel : public QAbstractItemModel {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RootItem* m_rootItem;
|
RootItem* m_rootItem;
|
||||||
int m_itemHeight;
|
|
||||||
QList<QString> m_headerData;
|
QList<QString> m_headerData;
|
||||||
QList<QString> m_tooltipData;
|
QList<QString> m_tooltipData;
|
||||||
QIcon m_countsIcon;
|
QIcon m_countsIcon;
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
MessagesModel::MessagesModel(QObject* parent)
|
MessagesModel::MessagesModel(QObject* parent)
|
||||||
: QSqlQueryModel(parent), m_cache(new MessagesModelCache(this)), m_messageHighlighter(MessageHighlighter::NoHighlighting),
|
: QSqlQueryModel(parent), m_cache(new MessagesModelCache(this)), m_messageHighlighter(MessageHighlighter::NoHighlighting),
|
||||||
m_customDateFormat(QString()), m_selectedItem(nullptr), m_itemHeight(-1), m_displayFeedIcons(false) {
|
m_customDateFormat(QString()), m_selectedItem(nullptr), m_displayFeedIcons(false) {
|
||||||
setupFonts();
|
setupFonts();
|
||||||
setupIcons();
|
setupIcons();
|
||||||
setupHeaderData();
|
setupHeaderData();
|
||||||
|
@ -119,15 +119,6 @@ void MessagesModel::setupFonts() {
|
||||||
m_boldStrikedFont = m_boldFont;
|
m_boldStrikedFont = m_boldFont;
|
||||||
m_normalStrikedFont.setStrikeOut(true);
|
m_normalStrikedFont.setStrikeOut(true);
|
||||||
m_boldStrikedFont.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) {
|
void MessagesModel::loadMessages(RootItem* item) {
|
||||||
|
|
|
@ -103,7 +103,6 @@ class MessagesModel : public QSqlQueryModel, public MessagesModelSqlLayer {
|
||||||
QIcon m_unreadIcon;
|
QIcon m_unreadIcon;
|
||||||
QIcon m_enclosuresIcon;
|
QIcon m_enclosuresIcon;
|
||||||
QList<QIcon> m_scoreIcons;
|
QList<QIcon> m_scoreIcons;
|
||||||
int m_itemHeight;
|
|
||||||
bool m_displayFeedIcons;
|
bool m_displayFeedIcons;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -122,7 +122,7 @@ void FormMain::showDbCleanupAssistant() {
|
||||||
qApp->showGuiMessage(Notification::Event::GeneralEvent, {
|
qApp->showGuiMessage(Notification::Event::GeneralEvent, {
|
||||||
tr("Cannot cleanup database"),
|
tr("Cannot cleanup database"),
|
||||||
tr("Cannot cleanup database, because another critical action is running."),
|
tr("Cannot cleanup database, because another critical action is running."),
|
||||||
QSystemTrayIcon::Warning });
|
QSystemTrayIcon::MessageIcon::Warning });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -466,7 +466,7 @@ void FormMain::switchVisibility(bool force_hide) {
|
||||||
qApp->showGuiMessage(Notification::Event::GeneralEvent, {
|
qApp->showGuiMessage(Notification::Event::GeneralEvent, {
|
||||||
tr("Close dialogs"),
|
tr("Close dialogs"),
|
||||||
tr("Close opened modal dialogs first."),
|
tr("Close opened modal dialogs first."),
|
||||||
QSystemTrayIcon::Warning });
|
QSystemTrayIcon::MessageIcon::Warning });
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
hide();
|
hide();
|
||||||
|
|
|
@ -738,7 +738,7 @@ void FeedsView::setupAppearance() {
|
||||||
setAllColumnsShowFocus(false);
|
setAllColumnsShowFocus(false);
|
||||||
setRootIsDecorated(false);
|
setRootIsDecorated(false);
|
||||||
setSelectionMode(QAbstractItemView::SelectionMode::SingleSelection);
|
setSelectionMode(QAbstractItemView::SelectionMode::SingleSelection);
|
||||||
setItemDelegate(new StyledItemDelegateWithoutFocus(this));
|
setItemDelegate(new StyledItemDelegateWithoutFocus(GUI::HeightRowFeeds, this));
|
||||||
}
|
}
|
||||||
|
|
||||||
void FeedsView::selectionChanged(const QItemSelection& selected, const QItemSelection& deselected) {
|
void FeedsView::selectionChanged(const QItemSelection& selected, const QItemSelection& deselected) {
|
||||||
|
|
|
@ -215,7 +215,7 @@ void MessagesView::setupAppearance() {
|
||||||
setAllColumnsShowFocus(false);
|
setAllColumnsShowFocus(false);
|
||||||
setSelectionMode(QAbstractItemView::SelectionMode::ExtendedSelection);
|
setSelectionMode(QAbstractItemView::SelectionMode::ExtendedSelection);
|
||||||
|
|
||||||
setItemDelegate(new StyledItemDelegateWithoutFocus(this));
|
setItemDelegate(new StyledItemDelegateWithoutFocus(GUI::HeightRowMessages, this));
|
||||||
header()->setDefaultSectionSize(MESSAGES_VIEW_DEFAULT_COL);
|
header()->setDefaultSectionSize(MESSAGES_VIEW_DEFAULT_COL);
|
||||||
header()->setMinimumSectionSize(MESSAGES_VIEW_MINIMUM_COL);
|
header()->setMinimumSectionSize(MESSAGES_VIEW_MINIMUM_COL);
|
||||||
header()->setFirstSectionMovable(true);
|
header()->setFirstSectionMovable(true);
|
||||||
|
|
|
@ -2,7 +2,10 @@
|
||||||
|
|
||||||
#include "gui/reusable/styleditemdelegatewithoutfocus.h"
|
#include "gui/reusable/styleditemdelegatewithoutfocus.h"
|
||||||
|
|
||||||
StyledItemDelegateWithoutFocus::StyledItemDelegateWithoutFocus(QObject* parent) : QStyledItemDelegate(parent) {}
|
#include "miscellaneous/application.h"
|
||||||
|
|
||||||
|
StyledItemDelegateWithoutFocus::StyledItemDelegateWithoutFocus(const QString& row_height_settings_key, QObject* parent)
|
||||||
|
: QStyledItemDelegate(parent), m_rowHeightSettingsKey(row_height_settings_key) {}
|
||||||
|
|
||||||
void StyledItemDelegateWithoutFocus::paint(QPainter* painter,
|
void StyledItemDelegateWithoutFocus::paint(QPainter* painter,
|
||||||
const QStyleOptionViewItem& option,
|
const QStyleOptionViewItem& option,
|
||||||
|
@ -15,3 +18,15 @@ void StyledItemDelegateWithoutFocus::paint(QPainter* painter,
|
||||||
|
|
||||||
QStyledItemDelegate::paint(painter, itemOption, index);
|
QStyledItemDelegate::paint(painter, itemOption, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
if (row_height <= 0) {
|
||||||
|
return original_hint;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return QSize(original_hint.width(), row_height);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -15,9 +15,13 @@ class StyledItemDelegateWithoutFocus : public QStyledItemDelegate {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit StyledItemDelegateWithoutFocus(QObject* parent = nullptr);
|
explicit StyledItemDelegateWithoutFocus(const QString& row_height_settings_key, QObject* parent = nullptr);
|
||||||
|
|
||||||
virtual void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const;
|
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;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // STYLEDITEMDELEGATEWITHOUTFOCUS_H
|
#endif // STYLEDITEMDELEGATEWITHOUTFOCUS_H
|
||||||
|
|
|
@ -42,11 +42,6 @@ SettingsFeedsMessages::SettingsFeedsMessages(Settings* settings, QWidget* parent
|
||||||
connect(m_ui->m_checkDisplayPlaceholders, &QCheckBox::toggled, this, &SettingsFeedsMessages::dirtifySettings);
|
connect(m_ui->m_checkDisplayPlaceholders, &QCheckBox::toggled, this, &SettingsFeedsMessages::dirtifySettings);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
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::requireRestart);
|
|
||||||
|
|
||||||
connect(m_ui->m_cbListsRestrictedShortcuts, &QCheckBox::toggled, this, &SettingsFeedsMessages::dirtifySettings);
|
connect(m_ui->m_cbListsRestrictedShortcuts, &QCheckBox::toggled, this, &SettingsFeedsMessages::dirtifySettings);
|
||||||
connect(m_ui->m_cmbIgnoreContentsChanges, &QCheckBox::toggled, this, &SettingsFeedsMessages::dirtifySettings);
|
connect(m_ui->m_cmbIgnoreContentsChanges, &QCheckBox::toggled, this, &SettingsFeedsMessages::dirtifySettings);
|
||||||
connect(m_ui->m_cbHideCountsIfNoUnread, &QCheckBox::toggled, this, &SettingsFeedsMessages::dirtifySettings);
|
connect(m_ui->m_cbHideCountsIfNoUnread, &QCheckBox::toggled, this, &SettingsFeedsMessages::dirtifySettings);
|
||||||
|
|
|
@ -20,7 +20,7 @@ bool TrayIconMenu::event(QEvent* event) {
|
||||||
qApp->showGuiMessage(Notification::Event::GeneralEvent, {
|
qApp->showGuiMessage(Notification::Event::GeneralEvent, {
|
||||||
tr("Close dialogs"),
|
tr("Close dialogs"),
|
||||||
tr("Close opened modal dialogs first."),
|
tr("Close opened modal dialogs first."),
|
||||||
QSystemTrayIcon::Warning });
|
QSystemTrayIcon::MessageIcon::Warning });
|
||||||
}
|
}
|
||||||
|
|
||||||
return QMenu::event(event);
|
return QMenu::event(event);
|
||||||
|
|
|
@ -510,7 +510,7 @@ void Application::showGuiMessage(Notification::Event event,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dest.m_messageBox) {
|
if (dest.m_messageBox || msg.m_type == QSystemTrayIcon::MessageIcon::Critical) {
|
||||||
// Tray icon or OSD is not available, display simple text box.
|
// Tray icon or OSD is not available, display simple text box.
|
||||||
MessageBox::show(parent == nullptr ? mainFormWidget() : parent,
|
MessageBox::show(parent == nullptr ? mainFormWidget() : parent,
|
||||||
QMessageBox::Icon(msg.m_type), msg.m_title, msg.m_message,
|
QMessageBox::Icon(msg.m_type), msg.m_title, msg.m_message,
|
||||||
|
|
|
@ -55,7 +55,7 @@ struct GuiMessage {
|
||||||
|
|
||||||
struct GuiMessageDestination {
|
struct GuiMessageDestination {
|
||||||
public:
|
public:
|
||||||
GuiMessageDestination(bool tray = true, bool message_box = true, bool status_bar = false)
|
GuiMessageDestination(bool tray = true, bool message_box = false, bool status_bar = false)
|
||||||
: m_tray(tray), m_messageBox(message_box), m_statusBar(status_bar) {}
|
: m_tray(tray), m_messageBox(message_box), m_statusBar(status_bar) {}
|
||||||
|
|
||||||
bool m_tray;
|
bool m_tray;
|
||||||
|
|
|
@ -192,7 +192,8 @@ void OAuth2Service::refreshAccessToken(const QString& refresh_token) {
|
||||||
qApp->showGuiMessage(Notification::Event::LoginDataRefreshed, {
|
qApp->showGuiMessage(Notification::Event::LoginDataRefreshed, {
|
||||||
tr("Logging in via OAuth 2.0..."),
|
tr("Logging in via OAuth 2.0..."),
|
||||||
tr("Refreshing login tokens for '%1'...").arg(m_tokenUrl.toString()),
|
tr("Refreshing login tokens for '%1'...").arg(m_tokenUrl.toString()),
|
||||||
QSystemTrayIcon::MessageIcon::Information });
|
QSystemTrayIcon::MessageIcon::Information },
|
||||||
|
{ true, false, true });
|
||||||
|
|
||||||
qDebugNN << LOGSEC_OAUTH << "Posting data for access token refreshing:" << QUOTE_W_SPACE_DOT(content);
|
qDebugNN << LOGSEC_OAUTH << "Posting data for access token refreshing:" << QUOTE_W_SPACE_DOT(content);
|
||||||
m_networkManager.post(networkRequest, content.toUtf8());
|
m_networkManager.post(networkRequest, content.toUtf8());
|
||||||
|
|
|
@ -40,7 +40,7 @@ bool StandardCategory::performDragDropChange(RootItem* target_item) {
|
||||||
<< "Cannot overwrite category:"
|
<< "Cannot overwrite category:"
|
||||||
<< QUOTE_W_SPACE_DOT(ex.message());
|
<< QUOTE_W_SPACE_DOT(ex.message());
|
||||||
qApp->showGuiMessage(Notification::Event::GeneralEvent, {
|
qApp->showGuiMessage(Notification::Event::GeneralEvent, {
|
||||||
tr("Error"),
|
tr("Cannot save category data"),
|
||||||
tr("Cannot save data for category, detailed information was logged via debug log."),
|
tr("Cannot save data for category, detailed information was logged via debug log."),
|
||||||
QSystemTrayIcon::MessageIcon::Critical });
|
QSystemTrayIcon::MessageIcon::Critical });
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -207,7 +207,7 @@ void StandardFeed::fetchMetadataForItself() {
|
||||||
<< "Cannot overwrite feed:"
|
<< "Cannot overwrite feed:"
|
||||||
<< QUOTE_W_SPACE_DOT(ex.message());
|
<< QUOTE_W_SPACE_DOT(ex.message());
|
||||||
qApp->showGuiMessage(Notification::Event::GeneralEvent, {
|
qApp->showGuiMessage(Notification::Event::GeneralEvent, {
|
||||||
tr("Error"),
|
tr("Cannot save feed data"),
|
||||||
tr("Cannot save data for feed: %1").arg(ex.message()),
|
tr("Cannot save data for feed: %1").arg(ex.message()),
|
||||||
QSystemTrayIcon::MessageIcon::Critical });
|
QSystemTrayIcon::MessageIcon::Critical });
|
||||||
}
|
}
|
||||||
|
|
|
@ -396,7 +396,7 @@ void StandardServiceRoot::addNewCategory(RootItem* selected_item) {
|
||||||
qApp->showGuiMessage(Notification::Event::GeneralEvent, {
|
qApp->showGuiMessage(Notification::Event::GeneralEvent, {
|
||||||
tr("Cannot add category"),
|
tr("Cannot add category"),
|
||||||
tr("Cannot add category because another critical operation is ongoing."),
|
tr("Cannot add category because another critical operation is ongoing."),
|
||||||
QSystemTrayIcon::Warning });
|
QSystemTrayIcon::MessageIcon::Warning });
|
||||||
|
|
||||||
// Thus, cannot delete and quit the method.
|
// Thus, cannot delete and quit the method.
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Add table
Reference in a new issue