This commit is contained in:
Martin Rotter 2023-04-21 09:32:12 +02:00
parent eac63ff867
commit 47b5156374
7 changed files with 51 additions and 9 deletions

View File

@ -95,6 +95,7 @@
#define COOKIE_URL_IDENTIFIER ":COOKIE:"
#define DEFAULT_NOTIFICATION_VOLUME 50
#define MAX_THREADPOOL_THREADS 32
#define WEB_BROWSER_SCROLL_STEP 50.0
#define GOOGLE_SEARCH_URL "https://www.google.com/search?q=%1&ie=utf-8&oe=utf-8"
#define GOOGLE_SUGGEST_URL "http://suggestqueries.google.com/complete/search?output=toolbar&hl=en&q=%1"

View File

@ -236,6 +236,8 @@ QList<QAction*> FormMain::allActions() const {
actions << m_ui->m_actionTabsCloseCurrent;
actions << m_ui->m_actionTabsCloseAll;
actions << m_ui->m_actionTabsCloseAllExceptCurrent;
actions << m_ui->m_actionBrowserScrollUp;
actions << m_ui->m_actionBrowserScrollDown;
actions << m_actionToolbarMainMenu;
return actions;
@ -794,6 +796,9 @@ void FormMain::createConnections() {
connect(qApp->feedReader(), &FeedReader::feedUpdatesProgress, this, &FormMain::onFeedUpdatesProgress);
connect(qApp->feedReader(), &FeedReader::feedUpdatesFinished, this, &FormMain::onFeedUpdatesFinished);
connect(m_ui->m_actionBrowserScrollUp, &QAction::triggered, tabWidget(), &TabWidget::scrollUpCurrentBrowser);
connect(m_ui->m_actionBrowserScrollDown, &QAction::triggered, tabWidget(), &TabWidget::scrollDownCurrentBrowser);
// Toolbar forwardings.
connect(m_ui->m_actionFocusSearchFeeds,
&QAction::triggered,

View File

@ -201,6 +201,9 @@
<addaction name="separator"/>
<addaction name="m_actionTabsNext"/>
<addaction name="m_actionTabsPrevious"/>
<addaction name="separator"/>
<addaction name="m_actionBrowserScrollUp"/>
<addaction name="m_actionBrowserScrollDown"/>
</widget>
<addaction name="m_menuFile"/>
<addaction name="m_menuView"/>
@ -904,6 +907,16 @@
<string>Focus articles search box</string>
</property>
</action>
<action name="m_actionBrowserScrollUp">
<property name="text">
<string>Scroll &amp;up browser</string>
</property>
</action>
<action name="m_actionBrowserScrollDown">
<property name="text">
<string>Scroll &amp;down browser</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>

View File

@ -152,6 +152,14 @@ void TabWidget::setupIcons() {
}
}
void TabWidget::scrollUpCurrentBrowser() {
currentWidget()->webBrowser()->scrollUp();
}
void TabWidget::scrollDownCurrentBrowser() {
currentWidget()->webBrowser()->scrollDown();
}
bool TabWidget::closeTab(int index) {
if (tabBar()->tabType(index) == TabBar::TabType::Closable) {
removeTab(index, true);

View File

@ -17,23 +17,25 @@ class RootItem;
class FeedMessageViewer;
class TabWidget : public QTabWidget {
Q_OBJECT
Q_OBJECT
public:
// Constructors and destructors.
explicit TabWidget(QWidget* parent = nullptr);
virtual ~TabWidget();
// Manimulators for tabs.
int addTab(TabContent* widget, const QString&,
int addTab(TabContent* widget, const QString&, TabBar::TabType type = TabBar::TabType::NonClosable);
int addTab(TabContent* widget,
const QIcon& icon,
const QString& label,
TabBar::TabType type = TabBar::TabType::NonClosable);
int addTab(TabContent* widget, const QIcon& icon,
const QString& label, TabBar::TabType type = TabBar::TabType::NonClosable);
int insertTab(int index, QWidget* widget, const QString& label,
TabBar::TabType type = TabBar::TabType::Closable);
int insertTab(int index, QWidget* widget, const QIcon& icon,
const QString& label, TabBar::TabType type = TabBar::TabType::NonClosable);
int insertTab(int index, QWidget* widget, const QString& label, TabBar::TabType type = TabBar::TabType::Closable);
int insertTab(int index,
QWidget* widget,
const QIcon& icon,
const QString& label,
TabBar::TabType type = TabBar::TabType::NonClosable);
void removeTab(int index, bool clear_from_memory);
// Returns tab bar.
@ -55,6 +57,8 @@ class TabWidget : public QTabWidget {
FeedMessageViewer* feedMessageViewer() const;
public slots:
void scrollUpCurrentBrowser();
void scrollDownCurrentBrowser();
// Called when number of tab pages changes.
void checkTabBarVisibility();

View File

@ -113,6 +113,14 @@ void WebBrowser::setVerticalScrollBarPosition(double pos) {
m_webView->setVerticalScrollBarPosition(pos);
}
void WebBrowser::scrollUp() {
setVerticalScrollBarPosition(verticalScrollBarPosition() - WEB_BROWSER_SCROLL_STEP);
}
void WebBrowser::scrollDown() {
setVerticalScrollBarPosition(verticalScrollBarPosition() + WEB_BROWSER_SCROLL_STEP);
}
void WebBrowser::reloadFontSettings() {
QFont fon;

View File

@ -44,6 +44,9 @@ class WebBrowser : public TabContent {
double verticalScrollBarPosition() const;
void setVerticalScrollBarPosition(double pos);
void scrollUp();
void scrollDown();
public slots:
void clear(bool also_hide);
void loadUrl(const QString& url);