allow backspace for message restore, add backend for restricted shortcut mode for article/feed view

This commit is contained in:
Martin Rotter 2021-09-14 10:47:24 +02:00
parent 95ac855d16
commit 9af79b3ca3
18 changed files with 241 additions and 112 deletions

View File

@ -26,7 +26,7 @@
<url type="donation">https://github.com/sponsors/martinrotter</url>
<content_rating type="oars-1.1" />
<releases>
<release version="4.0.2" date="2021-09-13"/>
<release version="4.0.2" date="2021-09-14"/>
</releases>
<content_rating type="oars-1.0">
<content_attribute id="violence-cartoon">none</content_attribute>

View File

@ -130,8 +130,19 @@ void FormSettings::cancelSettings() {
void FormSettings::addSettingsPanel(SettingsPanel* panel) {
m_ui.m_listSettings->addItem(panel->title());
m_panels.append(panel);
m_ui.m_stackedSettings->addWidget(panel);
QScrollArea* scr = new QScrollArea(m_ui.m_stackedSettings);
scr->setWidgetResizable(true);
scr->setFrameShape(QFrame::Shape::NoFrame);
//panel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
scr->setWidget(panel);
m_ui.m_stackedSettings->addWidget(scr);
panel->loadSettings();
connect(panel, &SettingsPanel::settingsChanged, this, [this]() {
m_btnApply->setEnabled(true);
});

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>1000</width>
<height>680</height>
<width>800</width>
<height>550</height>
</rect>
</property>
<property name="windowTitle">
@ -45,13 +45,6 @@
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QStackedWidget" name="m_stackedSettings">
<property name="currentIndex">
<number>-1</number>
</property>
</widget>
</item>
<item row="1" column="0" colspan="3">
<widget class="QDialogButtonBox" name="m_buttonBox">
<property name="orientation">
@ -62,6 +55,13 @@
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QStackedWidget" name="m_stackedSettings">
<property name="currentIndex">
<number>-1</number>
</property>
</widget>
</item>
</layout>
</widget>
<tabstops>

View File

@ -28,7 +28,7 @@
#include <QTimer>
FeedsView::FeedsView(QWidget* parent)
: QTreeView(parent), m_contextMenuService(nullptr), m_contextMenuBin(nullptr), m_contextMenuCategories(nullptr),
: BaseTreeView(parent), m_contextMenuService(nullptr), m_contextMenuBin(nullptr), m_contextMenuCategories(nullptr),
m_contextMenuFeeds(nullptr), m_contextMenuImportant(nullptr), m_contextMenuEmptySpace(nullptr), m_contextMenuOtherItems(nullptr),
m_contextMenuLabel(nullptr) {
setObjectName(QSL("FeedsView"));
@ -774,9 +774,9 @@ void FeedsView::selectionChanged(const QItemSelection& selected, const QItemSele
}
void FeedsView::keyPressEvent(QKeyEvent* event) {
QTreeView::keyPressEvent(event);
BaseTreeView::keyPressEvent(event);
if (event->key() == Qt::Key_Delete) {
if (event->key() == Qt::Key::Key_Delete) {
deleteSelectedItem();
}
}

View File

@ -3,7 +3,7 @@
#ifndef FEEDSVIEW_H
#define FEEDSVIEW_H
#include <QTreeView>
#include "gui/reusable/basetreeview.h"
#include "core/feedsmodel.h"
@ -13,7 +13,7 @@ class FeedsProxyModel;
class Feed;
class Category;
class RSSGUARD_DLLSPEC FeedsView : public QTreeView {
class RSSGUARD_DLLSPEC FeedsView : public BaseTreeView {
Q_OBJECT
public:

View File

@ -27,7 +27,7 @@
#include <QTimer>
MessagesView::MessagesView(QWidget* parent)
: QTreeView(parent), m_contextMenu(nullptr), m_columnsAdjusted(false), m_processingMouse(false) {
: BaseTreeView(parent), m_contextMenu(nullptr), m_columnsAdjusted(false), m_processingMouse(false) {
m_sourceModel = qApp->feedReader()->messagesModel();
m_proxyModel = qApp->feedReader()->messagesProxyModel();
@ -227,11 +227,14 @@ void MessagesView::focusInEvent(QFocusEvent* event) {
}
void MessagesView::keyPressEvent(QKeyEvent* event) {
QTreeView::keyPressEvent(event);
BaseTreeView::keyPressEvent(event);
if (event->key() == Qt::Key::Key_Delete) {
deleteSelectedMessages();
}
else if (event->key() == Qt::Key::Key_Backspace) {
restoreSelectedMessages();
}
}
void MessagesView::contextMenuEvent(QContextMenuEvent* event) {

View File

@ -3,16 +3,16 @@
#ifndef MESSAGESVIEW_H
#define MESSAGESVIEW_H
#include "core/messagesmodel.h"
#include "gui/reusable/basetreeview.h"
#include "core/messagesmodel.h"
#include "services/abstract/rootitem.h"
#include <QHeaderView>
#include <QTreeView>
class MessagesProxyModel;
class MessagesView : public QTreeView {
class MessagesView : public BaseTreeView {
Q_OBJECT
public:

View File

@ -0,0 +1,42 @@
// For license of this file, see <project-root-folder>/LICENSE.md.
#include "gui/reusable/basetreeview.h"
#include <QKeyEvent>
BaseTreeView::BaseTreeView(QWidget* parent) : QTreeView(parent), m_keyboardShortcutsLimited(false) {
m_allowedKeyboardKeys = {
Qt::Key::Key_Back,
Qt::Key::Key_Select,
Qt::Key::Key_Copy,
Qt::Key::Key_Shift,
Qt::Key::Key_Control,
Qt::Key::Key_Up,
Qt::Key::Key_Down,
Qt::Key::Key_Left,
Qt::Key::Key_Right,
Qt::Key::Key_Home,
Qt::Key::Key_End,
Qt::Key::Key_PageUp,
Qt::Key::Key_PageDown
};
}
bool BaseTreeView::keyboardShortcutsLimited() const {
return m_keyboardShortcutsLimited;
}
void BaseTreeView::setKeyboardShortcutsLimited(bool limited) {
m_keyboardShortcutsLimited = limited;
}
void BaseTreeView::keyPressEvent(QKeyEvent* event) {
if (m_keyboardShortcutsLimited &&
!m_allowedKeyboardKeys.contains(event->key()) &&
!event->matches(QKeySequence::StandardKey::SelectAll)) {
event->ignore();
}
else {
QTreeView::keyPressEvent(event);
}
}

View File

@ -0,0 +1,25 @@
// For license of this file, see <project-root-folder>/LICENSE.md.
#ifndef BASETREEVIEW_H
#define BASETREEVIEW_H
#include <QTreeView>
class BaseTreeView : public QTreeView {
Q_OBJECT
public:
explicit BaseTreeView(QWidget* parent = nullptr);
bool keyboardShortcutsLimited() const;
void setKeyboardShortcutsLimited(bool limited);
protected:
virtual void keyPressEvent(QKeyEvent* event);
private:
bool m_keyboardShortcutsLimited;
QList<int> m_allowedKeyboardKeys;
};
#endif // BASETREEVIEW_H

View File

@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>658</width>
<width>481</width>
<height>330</height>
</rect>
</property>
@ -36,10 +36,23 @@
<item row="1" column="0">
<widget class="QCheckBox" name="m_checkOpenLinksInExternal">
<property name="text">
<string>Always open links from simple internal text browser in external web browser</string>
<string>Always open hyperlinks in external web browser</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0" colspan="2">
<widget class="QGroupBox" name="m_grpCustomExternalBrowser">
<property name="toolTip">
@ -135,8 +148,15 @@
</layout>
</widget>
</item>
<item row="2" column="0" colspan="2">
<spacer name="verticalSpacer_3">
</layout>
</widget>
<widget class="QWidget" name="tab">
<attribute name="title">
<string>External e-mail client</string>
</attribute>
<layout class="QFormLayout" name="formLayout_22">
<item row="1" column="0" colspan="2">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
@ -148,13 +168,6 @@
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab">
<attribute name="title">
<string>External e-mail client</string>
</attribute>
<layout class="QFormLayout" name="formLayout_22">
<item row="0" column="0" colspan="2">
<widget class="QGroupBox" name="m_grpCustomExternalEmail">
<property name="toolTip">
@ -255,19 +268,6 @@
</layout>
</widget>
</item>
<item row="1" column="0" colspan="2">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_2">
@ -275,13 +275,6 @@
<string>External tools</string>
</attribute>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="m_lblToolInfo">
<property name="text">
<string>On this page, you can setup a list of external tools which can open URLs of selected messages.</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QTreeWidget" name="m_listTools">
<property name="showDropIndicator" stdset="0">
@ -309,6 +302,37 @@
</column>
</widget>
</item>
<item row="2" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QPushButton" name="m_btnAddTool">
<property name="text">
<string>&amp;Add tool</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="m_btnEditTool">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>&amp;Edit selected tool</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="m_btnDeleteTool">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>&amp;Delete selected tool</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="3" column="0" colspan="2">
<spacer name="verticalSpacer">
<property name="orientation">
@ -322,36 +346,12 @@
</property>
</spacer>
</item>
<item row="2" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QPushButton" name="m_btnAddTool">
<property name="text">
<string>&amp;Add new external tool</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="m_btnEditTool">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>&amp;Edit selected external tool</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="m_btnDeleteTool">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>&amp;Delete selected external tool</string>
</property>
</widget>
</item>
</layout>
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="m_lblToolInfo">
<property name="text">
<string>On this page, you can setup a list of external tools which can open URLs of selected messages.</string>
</property>
</widget>
</item>
</layout>
</widget>

View File

@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>558</width>
<width>547</width>
<height>356</height>
</rect>
</property>

View File

@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>758</width>
<width>469</width>
<height>300</height>
</rect>
</property>
@ -36,13 +36,6 @@
<string>Target directory for downloaded files</string>
</property>
<layout class="QFormLayout" name="formLayout_20">
<item row="1" column="0">
<widget class="QRadioButton" name="m_rbDownloadsAskEachFile">
<property name="text">
<string>Ask for each individual downloaded file</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_12">
<item>
@ -87,6 +80,13 @@
</property>
</spacer>
</item>
<item row="1" column="0" colspan="2">
<widget class="QRadioButton" name="m_rbDownloadsAskEachFile">
<property name="text">
<string>Ask for each individual downloaded file</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>

View File

@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>788</width>
<width>479</width>
<height>433</height>
</rect>
</property>
@ -26,7 +26,7 @@
<item>
<widget class="QTabWidget" name="m_tabFeedsMessages">
<property name="currentIndex">
<number>0</number>
<number>1</number>
</property>
<widget class="QWidget" name="m_tabFeeds">
<attribute name="title">
@ -36,7 +36,7 @@
<item row="0" column="0">
<widget class="QCheckBox" name="m_checkUpdateAllFeedsOnStartup">
<property name="text">
<string>Fetch articles for all feeds on application startup with initial delay of</string>
<string>Fetch all articles on startup with initial delay of</string>
</property>
</widget>
</item>
@ -45,6 +45,12 @@
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="readOnly">
<bool>false</bool>
</property>
@ -65,6 +71,12 @@
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="readOnly">
<bool>false</bool>
</property>
@ -124,6 +136,12 @@
</item>
<item row="4" column="1">
<widget class="QSpinBox" name="m_spinFeedUpdateTimeout">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Connection timeout is time interval which is reserved for downloading new messages for the feed. If this time interval elapses, then download process is aborted.</string>
</property>
@ -144,7 +162,7 @@
<item row="5" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Height or rows in feed list (-1 = default height)</string>
<string>Feed list row height (-1 = default)</string>
</property>
<property name="buddy">
<cstring>m_spinHeightRowsFeeds</cstring>
@ -153,6 +171,12 @@
</item>
<item row="5" column="1">
<widget class="QSpinBox" name="m_spinHeightRowsFeeds">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="minimum">
<number>-1</number>
</property>
@ -173,6 +197,12 @@
</item>
<item row="6" column="1">
<widget class="QComboBox" name="m_cmbCountsFeedList">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string notr="true"/>
</property>
@ -278,7 +308,7 @@
<item row="7" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Height or rows in article list (-1 = default height)</string>
<string>Article list row height (-1 = default)</string>
</property>
<property name="buddy">
<cstring>m_spinHeightRowsMessages</cstring>
@ -287,6 +317,12 @@
</item>
<item row="7" column="1">
<widget class="QSpinBox" name="m_spinHeightRowsMessages">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="minimum">
<number>-1</number>
</property>
@ -307,6 +343,12 @@
</item>
<item row="8" column="1">
<widget class="QSpinBox" name="m_spinHeightImageAttachments">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="minimum">
<number>22</number>
</property>
@ -318,7 +360,7 @@
<item row="9" column="0">
<widget class="QCheckBox" name="m_checkMessagesDateTimeFormat">
<property name="text">
<string>Use custom date/time format (overrides format loaded from active localization)</string>
<string>Use custom date/time format</string>
</property>
<property name="checkable">
<bool>true</bool>
@ -329,7 +371,14 @@
</widget>
</item>
<item row="9" column="1">
<widget class="QComboBox" name="m_cmbMessagesDateTimeFormat"/>
<widget class="QComboBox" name="m_cmbMessagesDateTimeFormat">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item row="10" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_4">

View File

@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>552</width>
<width>360</width>
<height>148</height>
</rect>
</property>

View File

@ -6,10 +6,16 @@
<rect>
<x>0</x>
<y>0</y>
<width>670</width>
<width>667</width>
<height>394</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="leftMargin">
<number>0</number>
@ -71,12 +77,6 @@
</item>
<item row="2" column="1">
<widget class="QTreeWidget" name="m_treeSkins">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="indentation">
<number>0</number>
</property>

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
<width>435</width>
<height>263</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">

View File

@ -6,13 +6,10 @@
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<width>367</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QFormLayout" name="formLayout">
<property name="leftMargin">
<number>0</number>

View File

@ -64,6 +64,7 @@ HEADERS += core/feeddownloader.h \
gui/notifications/notificationseditor.h \
gui/notifications/singlenotificationeditor.h \
gui/reusable/baselineedit.h \
gui/reusable/basetreeview.h \
gui/reusable/helpspoiler.h \
gui/reusable/progressbarwithtext.h \
gui/reusable/resizablestackedwidget.h \
@ -246,6 +247,7 @@ SOURCES += core/feeddownloader.cpp \
gui/notifications/notificationseditor.cpp \
gui/notifications/singlenotificationeditor.cpp \
gui/reusable/baselineedit.cpp \
gui/reusable/basetreeview.cpp \
gui/reusable/helpspoiler.cpp \
gui/reusable/progressbarwithtext.cpp \
gui/reusable/resizablestackedwidget.cpp \