mirror of
https://github.com/kiwix/kiwix-desktop.git
synced 2025-09-22 19:46:12 -04:00
parent
2f2d66d45c
commit
c081b3a665
@ -364,6 +364,8 @@ void KiwixApp::createAction()
|
||||
}
|
||||
|
||||
void KiwixApp::postInit() {
|
||||
connect(mp_tabWidget, &TabBar::webActionEnabledChanged,
|
||||
mp_mainWindow->getTopWidget(), &TopWidget::handleWebActionEnabledChanged);
|
||||
connect(mp_tabWidget, &TabBar::currentTitleChanged, this,
|
||||
[=](const QString& title) { emit currentTitleChanged(title); });
|
||||
emit(m_library.booksChanged());
|
||||
|
@ -45,6 +45,11 @@ TabBar* MainWindow::getTabBar()
|
||||
return mp_ui->tabBar;
|
||||
}
|
||||
|
||||
TopWidget *MainWindow::getTopWidget()
|
||||
{
|
||||
return mp_ui->mainToolBar;
|
||||
}
|
||||
|
||||
QStackedWidget *MainWindow::getSideDockWidget()
|
||||
{
|
||||
return mp_ui->sideBar;
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include <QDockWidget>
|
||||
#include "webview.h"
|
||||
#include "tabbar.h"
|
||||
#include "topwidget.h"
|
||||
#include "tocsidebar.h"
|
||||
#include "about.h"
|
||||
#include "contentmanagerside.h"
|
||||
@ -22,6 +23,7 @@ public:
|
||||
~MainWindow();
|
||||
|
||||
TabBar* getTabBar();
|
||||
TopWidget* getTopWidget();
|
||||
QStackedWidget* getSideDockWidget();
|
||||
ContentManagerSide* getSideContentManager();
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include "kiwixapp.h"
|
||||
#include <QAction>
|
||||
#include <QTimer>
|
||||
#include <QWebEnginePage>
|
||||
|
||||
#define QUITIFNULL(VIEW) if (nullptr==(VIEW)) { return; }
|
||||
#define QUITIFNOTCURRENT(VIEW) if((VIEW)!=currentWidget()) {return;}
|
||||
@ -95,8 +96,17 @@ WebView* TabBar::createNewTab(bool setCurrent)
|
||||
[=](const QString& zimId) {
|
||||
QUITIFNOTCURRENT(webView);
|
||||
emit currentZimIdChanged(zimId);
|
||||
}
|
||||
);
|
||||
});
|
||||
connect(webView->page()->action(QWebEnginePage::Back), &QAction::changed,
|
||||
[=]() {
|
||||
QUITIFNOTCURRENT(webView);
|
||||
emit webActionEnabledChanged(QWebEnginePage::Back, webView->isWebActionEnabled(QWebEnginePage::Back));
|
||||
});
|
||||
connect(webView->page()->action(QWebEnginePage::Forward), &QAction::changed,
|
||||
[=]() {
|
||||
QUITIFNOTCURRENT(webView);
|
||||
emit webActionEnabledChanged(QWebEnginePage::Forward, webView->isWebActionEnabled(QWebEnginePage::Forward));
|
||||
});
|
||||
// Ownership of webview is passed to the tabWidget
|
||||
mp_stackedWidget->addWidget(webView);
|
||||
auto index = addTab("");
|
||||
|
@ -14,6 +14,7 @@ TopWidget::TopWidget(QWidget *parent) :
|
||||
mp_historyBackAction->setIcon(QIcon(":/icons/back.svg"));
|
||||
mp_historyBackAction->setText(tr("back"));
|
||||
mp_historyBackAction->setToolTip(tr("back"));
|
||||
mp_historyBackAction->setEnabled(false);
|
||||
connect(mp_historyBackAction, &QAction::triggered, [](){
|
||||
KiwixApp::instance()->getTabWidget()->triggerWebPageAction(QWebEnginePage::Back);
|
||||
});
|
||||
@ -22,6 +23,7 @@ TopWidget::TopWidget(QWidget *parent) :
|
||||
mp_historyForwardAction->setIcon(QIcon(":/icons/forward.svg"));
|
||||
mp_historyForwardAction->setText(tr("forward"));
|
||||
mp_historyForwardAction->setToolTip(tr("forward"));
|
||||
mp_historyForwardAction->setEnabled(false);
|
||||
connect(mp_historyForwardAction, &QAction::triggered, [](){
|
||||
KiwixApp::instance()->getTabWidget()->triggerWebPageAction(QWebEnginePage::Forward);
|
||||
});
|
||||
|
@ -25,7 +25,7 @@ private:
|
||||
QPoint m_cursorPos;
|
||||
ulong m_timestamp;
|
||||
|
||||
private slots:
|
||||
public slots:
|
||||
void handleWebActionEnabledChanged(QWebEnginePage::WebAction action, bool enabled);
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user