Change proeprly font - requires app restart.
This commit is contained in:
parent
c759c0d6fd
commit
cbfa6d042b
@ -60,6 +60,7 @@ FeedsModel::FeedsModel(QObject* parent) : QAbstractItemModel(parent), m_itemHeig
|
|||||||
<< /*: Feed list header "titles" column tooltip.*/ tr("Titles of feeds/categories.")
|
<< /*: Feed list header "titles" column tooltip.*/ tr("Titles of feeds/categories.")
|
||||||
<< /*: Feed list header "counts" column tooltip.*/ tr("Counts of unread/all mesages.");
|
<< /*: Feed list header "counts" column tooltip.*/ tr("Counts of unread/all mesages.");
|
||||||
|
|
||||||
|
setupFonts();
|
||||||
updateItemHeight();
|
updateItemHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -478,16 +479,19 @@ void FeedsModel::onItemDataChanged(const QList<RootItem*>& items) {
|
|||||||
notifyWithCounts();
|
notifyWithCounts();
|
||||||
}
|
}
|
||||||
|
|
||||||
int FeedsModel::itemHeight() const {
|
void FeedsModel::setupFonts() {
|
||||||
return m_itemHeight;
|
m_normalFont = Application::font("FeedsView");
|
||||||
}
|
m_boldFont = m_normalFont;
|
||||||
|
m_boldFont.setBold(true);
|
||||||
void FeedsModel::setItemHeight(int item_height) {
|
|
||||||
m_itemHeight = item_height;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FeedsModel::updateItemHeight() {
|
void FeedsModel::updateItemHeight() {
|
||||||
m_itemHeight = qApp->settings()->value(GROUP(GUI), SETTING(GUI::HeightRowFeeds)).toInt();
|
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() {
|
||||||
|
@ -102,10 +102,6 @@ class FeedsModel : public QAbstractItemModel {
|
|||||||
// Access to root item.
|
// Access to root item.
|
||||||
RootItem* rootItem() const;
|
RootItem* rootItem() const;
|
||||||
|
|
||||||
int itemHeight() const;
|
|
||||||
void setItemHeight(int item_height);
|
|
||||||
void updateItemHeight();
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void loadActivatedServiceAccounts();
|
void loadActivatedServiceAccounts();
|
||||||
|
|
||||||
@ -171,6 +167,10 @@ class FeedsModel : public QAbstractItemModel {
|
|||||||
// NOTE: View will probably expand dropped index.
|
// NOTE: View will probably expand dropped index.
|
||||||
void requireItemValidationAfterDragDrop(const QModelIndex& source_index);
|
void requireItemValidationAfterDragDrop(const QModelIndex& source_index);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void updateItemHeight();
|
||||||
|
void setupFonts();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RootItem* m_rootItem;
|
RootItem* m_rootItem;
|
||||||
int m_itemHeight;
|
int m_itemHeight;
|
||||||
@ -178,18 +178,14 @@ class FeedsModel : public QAbstractItemModel {
|
|||||||
QList<QString> m_headerData;
|
QList<QString> m_headerData;
|
||||||
QList<QString> m_tooltipData;
|
QList<QString> m_tooltipData;
|
||||||
QIcon m_countsIcon;
|
QIcon m_countsIcon;
|
||||||
|
QFont m_normalFont;
|
||||||
|
QFont m_boldFont;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline QVariant FeedsModel::data(const QModelIndex& index, int role) const {
|
inline QVariant FeedsModel::data(const QModelIndex& index, int role) const {
|
||||||
switch (role) {
|
switch (role) {
|
||||||
case Qt::SizeHintRole: {
|
case Qt::FontRole:
|
||||||
if (m_itemHeight > 0) {
|
return itemForIndex(index)->countOfUnreadMessages() > 0 ? m_boldFont : m_normalFont;
|
||||||
return QSize(-1, m_itemHeight);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return QVariant();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return itemForIndex(index)->data(index.column(), role);;
|
return itemForIndex(index)->data(index.column(), role);;
|
||||||
|
@ -51,16 +51,15 @@ void MessagesModel::setupIcons() {
|
|||||||
m_unreadIcon = qApp->icons()->fromTheme(QSL("mail-mark-unread"));
|
m_unreadIcon = qApp->icons()->fromTheme(QSL("mail-mark-unread"));
|
||||||
}
|
}
|
||||||
|
|
||||||
int MessagesModel::itemHeight() const {
|
|
||||||
return m_itemHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MessagesModel::setItemHeight(int item_height) {
|
|
||||||
m_itemHeight = item_height;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MessagesModel::updateItemHeight() {
|
void MessagesModel::updateItemHeight() {
|
||||||
m_itemHeight = qApp->settings()->value(GROUP(GUI), SETTING(GUI::HeightRowMessages)).toInt();
|
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() {
|
void MessagesModel::repopulate() {
|
||||||
@ -299,18 +298,6 @@ QVariant MessagesModel::data(const QModelIndex& idx, int role) const {
|
|||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
case Qt::SizeHintRole: {
|
|
||||||
if (m_itemHeight > 0) {
|
|
||||||
QSize siz = QSqlQueryModel::data(idx, Qt::SizeHintRole).toSize();
|
|
||||||
|
|
||||||
siz.setHeight(m_itemHeight);
|
|
||||||
return siz;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return QVariant();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
case Qt::DecorationRole: {
|
case Qt::DecorationRole: {
|
||||||
const int index_column = idx.column();
|
const int index_column = idx.column();
|
||||||
|
|
||||||
|
@ -85,10 +85,6 @@ class MessagesModel : public QSqlQueryModel, public MessagesModelSqlLayer {
|
|||||||
// Loads messages of given feeds.
|
// Loads messages of given feeds.
|
||||||
void loadMessages(RootItem* item);
|
void loadMessages(RootItem* item);
|
||||||
|
|
||||||
int itemHeight() const;
|
|
||||||
void setItemHeight(int item_height);
|
|
||||||
void updateItemHeight();
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
// NOTE: These methods DO NOT actually change data in the DB, just in the model.
|
// NOTE: These methods DO NOT actually change data in the DB, just in the model.
|
||||||
@ -97,6 +93,7 @@ class MessagesModel : public QSqlQueryModel, public MessagesModelSqlLayer {
|
|||||||
bool setMessageReadById(int id, RootItem::ReadStatus read);
|
bool setMessageReadById(int id, RootItem::ReadStatus read);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void updateItemHeight();
|
||||||
void setupHeaderData();
|
void setupHeaderData();
|
||||||
void setupFonts();
|
void setupFonts();
|
||||||
void setupIcons();
|
void setupIcons();
|
||||||
|
@ -39,6 +39,11 @@ SettingsFeedsMessages::SettingsFeedsMessages(Settings* settings, QWidget* parent
|
|||||||
initializeMessageDateFormats();
|
initializeMessageDateFormats();
|
||||||
GuiUtilities::setLabelAsNotice(*m_ui->label_9, false);
|
GuiUtilities::setLabelAsNotice(*m_ui->label_9, false);
|
||||||
|
|
||||||
|
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_checkAutoUpdateNotification, &QCheckBox::toggled, this, &SettingsFeedsMessages::dirtifySettings);
|
connect(m_ui->m_checkAutoUpdateNotification, &QCheckBox::toggled, this, &SettingsFeedsMessages::dirtifySettings);
|
||||||
connect(m_ui->m_checkAutoUpdate, &QCheckBox::toggled, this, &SettingsFeedsMessages::dirtifySettings);
|
connect(m_ui->m_checkAutoUpdate, &QCheckBox::toggled, this, &SettingsFeedsMessages::dirtifySettings);
|
||||||
connect(m_ui->m_checkKeppMessagesInTheMiddle, &QCheckBox::toggled, this, &SettingsFeedsMessages::dirtifySettings);
|
connect(m_ui->m_checkKeppMessagesInTheMiddle, &QCheckBox::toggled, this, &SettingsFeedsMessages::dirtifySettings);
|
||||||
@ -162,11 +167,9 @@ void SettingsFeedsMessages::saveSettings() {
|
|||||||
qApp->mainForm()->tabWidget()->feedMessageViewer()->loadMessageViewerFonts();
|
qApp->mainForm()->tabWidget()->feedMessageViewer()->loadMessageViewerFonts();
|
||||||
qApp->feedReader()->updateAutoUpdateStatus();
|
qApp->feedReader()->updateAutoUpdateStatus();
|
||||||
|
|
||||||
qApp->feedReader()->feedsModel()->updateItemHeight();
|
|
||||||
qApp->feedReader()->feedsModel()->reloadWholeLayout();
|
qApp->feedReader()->feedsModel()->reloadWholeLayout();
|
||||||
|
|
||||||
qApp->feedReader()->messagesModel()->updateDateFormat();
|
qApp->feedReader()->messagesModel()->updateDateFormat();
|
||||||
qApp->feedReader()->messagesModel()->updateItemHeight();
|
|
||||||
qApp->feedReader()->messagesModel()->reloadWholeLayout();
|
qApp->feedReader()->messagesModel()->reloadWholeLayout();
|
||||||
onEndSaveSettings();
|
onEndSaveSettings();
|
||||||
}
|
}
|
||||||
|
@ -29,9 +29,7 @@
|
|||||||
RootItem::RootItem(RootItem* parent_item)
|
RootItem::RootItem(RootItem* parent_item)
|
||||||
: QObject(nullptr), m_kind(RootItemKind::Root), m_id(NO_PARENT_CATEGORY), m_customId(QSL("")),
|
: QObject(nullptr), m_kind(RootItemKind::Root), m_id(NO_PARENT_CATEGORY), m_customId(QSL("")),
|
||||||
m_title(QString()), m_description(QString()), m_icon(QIcon()), m_creationDate(QDateTime()),
|
m_title(QString()), m_description(QString()), m_icon(QIcon()), m_creationDate(QDateTime()),
|
||||||
m_childItems(QList<RootItem*>()), m_parentItem(parent_item) {
|
m_childItems(QList<RootItem*>()), m_parentItem(parent_item) {}
|
||||||
setupFonts();
|
|
||||||
}
|
|
||||||
|
|
||||||
RootItem::RootItem(const RootItem& other) : RootItem(nullptr) {
|
RootItem::RootItem(const RootItem& other) : RootItem(nullptr) {
|
||||||
setTitle(other.title());
|
setTitle(other.title());
|
||||||
@ -120,12 +118,6 @@ void RootItem::updateCounts(bool including_total_count) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RootItem::setupFonts() {
|
|
||||||
m_normalFont = Application::font("FeedsView");
|
|
||||||
m_boldFont = m_normalFont;
|
|
||||||
m_boldFont.setBold(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
int RootItem::row() const {
|
int RootItem::row() const {
|
||||||
if (m_parentItem) {
|
if (m_parentItem) {
|
||||||
return m_parentItem->m_childItems.indexOf(const_cast<RootItem*>(this));
|
return m_parentItem->m_childItems.indexOf(const_cast<RootItem*>(this));
|
||||||
@ -176,9 +168,6 @@ QVariant RootItem::data(int column, int role) const {
|
|||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
case Qt::FontRole:
|
|
||||||
return countOfUnreadMessages() > 0 ? m_boldFont : m_normalFont;
|
|
||||||
|
|
||||||
case Qt::DisplayRole:
|
case Qt::DisplayRole:
|
||||||
if (column == FDS_MODEL_TITLE_INDEX) {
|
if (column == FDS_MODEL_TITLE_INDEX) {
|
||||||
return m_title;
|
return m_title;
|
||||||
@ -437,22 +426,6 @@ void RootItem::setDescription(const QString& description) {
|
|||||||
m_description = description;
|
m_description = description;
|
||||||
}
|
}
|
||||||
|
|
||||||
QFont RootItem::normalFont() const {
|
|
||||||
return m_normalFont;
|
|
||||||
}
|
|
||||||
|
|
||||||
void RootItem::setNormalFont(const QFont& normal_font) {
|
|
||||||
m_normalFont = normal_font;
|
|
||||||
}
|
|
||||||
|
|
||||||
QFont RootItem::boldFont() const {
|
|
||||||
return m_boldFont;
|
|
||||||
}
|
|
||||||
|
|
||||||
void RootItem::setBoldFont(const QFont& bold_font) {
|
|
||||||
m_boldFont = bold_font;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool RootItem::removeChild(RootItem* child) {
|
bool RootItem::removeChild(RootItem* child) {
|
||||||
return m_childItems.removeOne(child);
|
return m_childItems.removeOne(child);
|
||||||
}
|
}
|
||||||
|
@ -208,12 +208,6 @@ class RootItem : public QObject {
|
|||||||
QString description() const;
|
QString description() const;
|
||||||
void setDescription(const QString& description);
|
void setDescription(const QString& description);
|
||||||
|
|
||||||
QFont normalFont() const;
|
|
||||||
void setNormalFont(const QFont& normal_font);
|
|
||||||
|
|
||||||
QFont boldFont() const;
|
|
||||||
void setBoldFont(const QFont& bold_font);
|
|
||||||
|
|
||||||
// NOTE: For standard feed/category, this WILL equal to id().
|
// NOTE: For standard feed/category, this WILL equal to id().
|
||||||
QString customId() const;
|
QString customId() const;
|
||||||
int customNumericId() const;
|
int customNumericId() const;
|
||||||
@ -225,8 +219,6 @@ class RootItem : public QObject {
|
|||||||
ServiceRoot* toServiceRoot() const;
|
ServiceRoot* toServiceRoot() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setupFonts();
|
|
||||||
|
|
||||||
RootItemKind::Kind m_kind;
|
RootItemKind::Kind m_kind;
|
||||||
int m_id;
|
int m_id;
|
||||||
QString m_customId;
|
QString m_customId;
|
||||||
@ -234,8 +226,6 @@ class RootItem : public QObject {
|
|||||||
QString m_description;
|
QString m_description;
|
||||||
QIcon m_icon;
|
QIcon m_icon;
|
||||||
QDateTime m_creationDate;
|
QDateTime m_creationDate;
|
||||||
QFont m_normalFont;
|
|
||||||
QFont m_boldFont;
|
|
||||||
|
|
||||||
QList<RootItem*> m_childItems;
|
QList<RootItem*> m_childItems;
|
||||||
RootItem* m_parentItem;
|
RootItem* m_parentItem;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user