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 COOKIE_URL_IDENTIFIER ":COOKIE:"
#define DEFAULT_NOTIFICATION_VOLUME 50 #define DEFAULT_NOTIFICATION_VOLUME 50
#define MAX_THREADPOOL_THREADS 32 #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_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" #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_actionTabsCloseCurrent;
actions << m_ui->m_actionTabsCloseAll; actions << m_ui->m_actionTabsCloseAll;
actions << m_ui->m_actionTabsCloseAllExceptCurrent; actions << m_ui->m_actionTabsCloseAllExceptCurrent;
actions << m_ui->m_actionBrowserScrollUp;
actions << m_ui->m_actionBrowserScrollDown;
actions << m_actionToolbarMainMenu; actions << m_actionToolbarMainMenu;
return actions; return actions;
@ -794,6 +796,9 @@ void FormMain::createConnections() {
connect(qApp->feedReader(), &FeedReader::feedUpdatesProgress, this, &FormMain::onFeedUpdatesProgress); connect(qApp->feedReader(), &FeedReader::feedUpdatesProgress, this, &FormMain::onFeedUpdatesProgress);
connect(qApp->feedReader(), &FeedReader::feedUpdatesFinished, this, &FormMain::onFeedUpdatesFinished); 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. // Toolbar forwardings.
connect(m_ui->m_actionFocusSearchFeeds, connect(m_ui->m_actionFocusSearchFeeds,
&QAction::triggered, &QAction::triggered,

View File

@ -201,6 +201,9 @@
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="m_actionTabsNext"/> <addaction name="m_actionTabsNext"/>
<addaction name="m_actionTabsPrevious"/> <addaction name="m_actionTabsPrevious"/>
<addaction name="separator"/>
<addaction name="m_actionBrowserScrollUp"/>
<addaction name="m_actionBrowserScrollDown"/>
</widget> </widget>
<addaction name="m_menuFile"/> <addaction name="m_menuFile"/>
<addaction name="m_menuView"/> <addaction name="m_menuView"/>
@ -904,6 +907,16 @@
<string>Focus articles search box</string> <string>Focus articles search box</string>
</property> </property>
</action> </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> </widget>
<customwidgets> <customwidgets>
<customwidget> <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) { bool TabWidget::closeTab(int index) {
if (tabBar()->tabType(index) == TabBar::TabType::Closable) { if (tabBar()->tabType(index) == TabBar::TabType::Closable) {
removeTab(index, true); removeTab(index, true);

View File

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

View File

@ -113,6 +113,14 @@ void WebBrowser::setVerticalScrollBarPosition(double pos) {
m_webView->setVerticalScrollBarPosition(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() { void WebBrowser::reloadFontSettings() {
QFont fon; QFont fon;

View File

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