Switchable feed tree branches/arrows.

This commit is contained in:
Martin Rotter 2020-07-24 10:52:09 +02:00
parent 01618be534
commit fe286a707f
10 changed files with 55 additions and 100 deletions

View File

@ -15,63 +15,6 @@ QMenu {
border: 1px solid #3a4047;
}
QTreeView::branch:has-siblings:!adjoins-item {
border-image: url(qss/dummy.png) 0;
}
QTreeView::branch:has-siblings:adjoins-item {
border-image: url(qss/dummy.png) 0;
}
QTreeView::branch:!has-children:!has-siblings:adjoins-item {
border-image: url(qss/dummy.png) 0;
}
QTreeView::branch:has-children:!has-siblings:closed,
QTreeView::branch:closed:has-children:has-siblings {
border-image: none;
image: url(qss/branch-closed.png);
}
QTreeView::branch:open:has-children:!has-siblings,
QTreeView::branch:open:has-children:has-siblings {
border-image: none;
image: url(qss/branch-open.png);
}
QTreeView[hideTree="true"]::branch:!has-chlidren:hasSiblings {
border-image: none;
image: none;
}
QTreeView::branch {
background-color: rgb(39, 43, 48);
}
QTreeView::item {
padding: 1px 1px 1px 1px;
border: 1px transparent;
border-top-color: transparent;
border-bottom-color: transparent;
}
QTreeView::item:hover {
background-color: #1b8cbc;
border: 1px transparent;
}
QTreeView::item:selected {
border: 1px transparent;
}
QTreeView::item:selected:active{
background-color: #3e444c;
}
QTreeView::item:selected:!active {
background-color: #3e444c;
}
QStatusBar::item {
border: none;
}

View File

@ -1,38 +1,5 @@
/* This is Qt CSS theme file for the overall GUI of the application. */
QTreeView::branch:has-siblings:!adjoins-item {
border-image: url(qss/dummy.png) 0;
}
QTreeView::branch:has-siblings:adjoins-item {
border-image: url(qss/dummy.png) 0;
}
QTreeView::branch:!has-children:!has-siblings:adjoins-item {
border-image: url(qss/dummy.png) 0;
}
QTreeView::branch:has-children:!has-siblings:closed,
QTreeView::branch:closed:has-children:has-siblings {
border-image: none;
image: url(qss/branch-closed.png);
}
QTreeView::branch:open:has-children:!has-siblings,
QTreeView::branch:open:has-children:has-siblings {
border-image: none;
image: url(qss/branch-open.png);
}
QTreeView::item {
padding: 1px 1px 1px 1px;
}
QTreeView[hideTree="true"]::branch:!has-chlidren:hasSiblings {
border-image: none;
image: none;
}
QTextEdit {
selection-background-color: #3297FD;
}

View File

@ -160,6 +160,7 @@ QList<QAction*> FormMain::allActions() const {
actions << m_ui->m_actionClearSelectedItems;
actions << m_ui->m_actionClearAllItems;
actions << m_ui->m_actionShowOnlyUnreadItems;
actions << m_ui->m_actionShowTreeBranches;
actions << m_ui->m_actionShowOnlyUnreadMessages;
actions << m_ui->m_actionMarkSelectedMessagesAsRead;
actions << m_ui->m_actionMarkSelectedMessagesAsUnread;
@ -586,6 +587,8 @@ void FormMain::loadSize() {
// Make sure that only unread feeds/messages are shown if user has that feature set on.
m_ui->m_actionShowOnlyUnreadItems->setChecked(settings->value(GROUP(Feeds),
SETTING(Feeds::ShowOnlyUnreadFeeds)).toBool());
m_ui->m_actionShowTreeBranches->setChecked(settings->value(GROUP(Feeds),
SETTING(Feeds::ShowTreeBranches)).toBool());
m_ui->m_actionShowOnlyUnreadMessages->setChecked(settings->value(GROUP(Messages),
SETTING(Messages::ShowOnlyUnreadMessages)).toBool());
}
@ -747,6 +750,8 @@ void FormMain::createConnections() {
tabWidget()->feedMessageViewer(), &FeedMessageViewer::switchMessageSplitterOrientation);
connect(m_ui->m_actionShowOnlyUnreadItems, &QAction::toggled,
tabWidget()->feedMessageViewer(), &FeedMessageViewer::toggleShowOnlyUnreadFeeds);
connect(m_ui->m_actionShowTreeBranches, &QAction::toggled,
tabWidget()->feedMessageViewer(), &FeedMessageViewer::toggleShowFeedTreeBranches);
connect(m_ui->m_actionShowOnlyUnreadMessages, &QAction::toggled,
tabWidget()->feedMessageViewer(), &FeedMessageViewer::toggleShowOnlyUnreadMessages);
connect(m_ui->m_actionRestoreSelectedMessages, &QAction::triggered,

View File

@ -114,6 +114,7 @@
<addaction name="m_actionDeleteSelectedItem"/>
<addaction name="separator"/>
<addaction name="m_actionShowOnlyUnreadItems"/>
<addaction name="m_actionShowTreeBranches"/>
<addaction name="m_actionExpandCollapseItem"/>
<addaction name="separator"/>
<addaction name="m_actionSelectNextItem"/>
@ -766,6 +767,14 @@
<string>Message &amp;filters</string>
</property>
</action>
<action name="m_actionShowTreeBranches">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>&amp;Show tree branches</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>

View File

@ -189,6 +189,13 @@ void FeedMessageViewer::toggleShowOnlyUnreadFeeds() {
}
}
void FeedMessageViewer::toggleShowFeedTreeBranches() {
const QAction* origin = qobject_cast<QAction*>(sender());
m_feedsView->setRootIsDecorated(origin->isChecked());
qApp->settings()->setValue(GROUP(Feeds), Feeds::ShowTreeBranches, origin->isChecked());
}
void FeedMessageViewer::displayMessage(const Message& message, RootItem* root) {
if (qApp->settings()->value(GROUP(Messages), SETTING(Messages::EnableMessagePreview)).toBool()) {
m_messagesBrowser->loadMessage(message, root);

View File

@ -66,6 +66,7 @@ class RSSGUARD_DLLSPEC FeedMessageViewer : public TabContent {
void toggleShowOnlyUnreadMessages();
void toggleShowOnlyUnreadFeeds();
void toggleShowFeedTreeBranches();
private slots:
void displayMessage(const Message& message, RootItem* root);

View File

@ -476,6 +476,19 @@ void FeedsView::switchVisibility() {
setVisible(!isVisible());
}
void FeedsView::drawBranches(QPainter* painter, const QRect& rect, const QModelIndex& index) const {
if (!rootIsDecorated()) {
painter->save();
painter->setOpacity(0.0);
}
QTreeView::drawBranches(painter, rect, index);
if (!rootIsDecorated()) {
painter->restore();
}
}
void FeedsView::focusInEvent(QFocusEvent* event) {
QTreeView::focusInEvent(event);
@ -608,6 +621,7 @@ void FeedsView::setupAppearance() {
setAnimated(true);
setSortingEnabled(true);
setItemsExpandable(true);
setAutoExpandDelay(0);
setExpandsOnDoubleClick(true);
setEditTriggers(QAbstractItemView::NoEditTriggers);
setIndentation(FEEDS_VIEW_INDENTATION);

View File

@ -17,19 +17,11 @@ class RSSGUARD_DLLSPEC FeedsView : public QTreeView {
Q_OBJECT
public:
// Constructors and destructors.
explicit FeedsView(QWidget* parent = nullptr);
virtual ~FeedsView();
// Fundamental accessors.
inline FeedsProxyModel* model() const {
return m_proxyModel;
}
inline FeedsModel* sourceModel() const {
return m_sourceModel;
}
FeedsProxyModel* model() const;
FeedsModel* sourceModel() const;
void reloadFontSettings();
@ -89,6 +81,7 @@ class RSSGUARD_DLLSPEC FeedsView : public QTreeView {
void openMessagesInNewspaperView(RootItem* root, const QList<Message>& messages);
protected:
void drawBranches(QPainter* painter, const QRect& rect, const QModelIndex& index) const;
void focusInEvent(QFocusEvent* event);
void selectionChanged(const QItemSelection& selected, const QItemSelection& deselected);
void keyPressEvent(QKeyEvent* event);
@ -132,4 +125,12 @@ class RSSGUARD_DLLSPEC FeedsView : public QTreeView {
FeedsProxyModel* m_proxyModel;
};
inline FeedsProxyModel* FeedsView::model() const {
return m_proxyModel;
}
inline FeedsModel* FeedsView::sourceModel() const {
return m_sourceModel;
}
#endif // FEEDSVIEW_H

View File

@ -63,6 +63,10 @@ DKEY Feeds::ShowOnlyUnreadFeeds = "show_only_unread_feeds";
DVALUE(bool) Feeds::ShowOnlyUnreadFeedsDef = false;
DKEY Feeds::ShowTreeBranches = "show_tree_branches";
DVALUE(bool) Feeds::ShowTreeBranchesDef = true;
DKEY Feeds::ListFont = "list_font";
// Messages.

View File

@ -84,6 +84,10 @@ namespace Feeds {
VALUE(bool) ShowOnlyUnreadFeedsDef;
KEY ShowTreeBranches;
VALUE(bool) ShowTreeBranchesDef;
KEY ListFont;
}