Drop redundant Kiwixapp::mp_tabWidget pointer

No need to story what can be easily get.
This commit is contained in:
Alexander Sashnov 2022-01-26 15:37:30 +07:00
parent 6ac401c1f0
commit 5e7b856f72
2 changed files with 11 additions and 13 deletions

View File

@ -81,9 +81,8 @@ void KiwixApp::init()
createAction();
mp_mainWindow = new MainWindow;
mp_tabWidget = mp_mainWindow->getTabBar();
mp_tabWidget->setContentManagerView(mp_manager->getView());
mp_tabWidget->setNewTabButton();
getTabWidget()->setContentManagerView(mp_manager->getView());
getTabWidget()->setNewTabButton();
postInit();
mp_errorDialog = new QErrorMessage(mp_mainWindow);
setActivationWindow(mp_mainWindow);
@ -186,14 +185,14 @@ void KiwixApp::openZimFile(const QString &zimfile)
void KiwixApp::printPage()
{
if(!mp_tabWidget->currentZimView())
if(!getTabWidget()->currentZimView())
return;
QPrinter* printer = new QPrinter();
QPrintDialog printDialog(printer, mp_mainWindow);
printDialog.setStyle(nullptr);
printDialog.setStyleSheet("");
if (printDialog.exec() == QDialog::Accepted) {
auto webview = mp_tabWidget->currentWebView();
auto webview = getTabWidget()->currentWebView();
if(!webview)
return;
webview->page()->print(printer, [=](bool success) {
@ -210,12 +209,12 @@ void KiwixApp::openUrl(const QString &url, bool newTab) {
}
void KiwixApp::openUrl(const QUrl &url, bool newTab) {
mp_tabWidget->openUrl(url, newTab);
getTabWidget()->openUrl(url, newTab);
}
void KiwixApp::openRandomUrl(bool newTab)
{
auto zimId = mp_tabWidget->currentZimId();
auto zimId = getTabWidget()->currentZimId();
if (zimId.isEmpty()) {
return;
}
@ -354,7 +353,7 @@ void KiwixApp::createAction()
CREATE_ACTION(FindInPageAction, gt("find-in-page"));
mpa_actions[FindInPageAction]->setShortcuts({QKeySequence::Find, Qt::Key_F3});
connect(mpa_actions[FindInPageAction], &QAction::triggered,
this, [=]() { mp_tabWidget->openFindInPageBar(); });
this, [=]() { getTabWidget()->openFindInPageBar(); });
CREATE_ACTION_ICON_SHORTCUT(ToggleFullscreenAction, "full-screen-enter", gt("set-fullscreen"), QKeySequence::FullScreen);
connect(mpa_actions[ToggleFullscreenAction], &QAction::toggled,
@ -399,11 +398,11 @@ void KiwixApp::createAction()
}
void KiwixApp::postInit() {
connect(mp_tabWidget, &TabBar::webActionEnabledChanged,
connect(getTabWidget(), &TabBar::webActionEnabledChanged,
mp_mainWindow->getTopWidget(), &TopWidget::handleWebActionEnabledChanged);
connect(mp_tabWidget, &TabBar::currentTitleChanged, this,
connect(getTabWidget(), &TabBar::currentTitleChanged, this,
[=](const QString& title) { emit currentTitleChanged(title); });
connect(mp_tabWidget, &TabBar::libraryPageDisplayed,
connect(getTabWidget(), &TabBar::libraryPageDisplayed,
this, &KiwixApp::disableItemsOnLibraryPage);
emit(m_library.booksChanged());
connect(&m_library, &Library::booksChanged, this, &KiwixApp::updateNameMapper);

View File

@ -74,7 +74,7 @@ public:
MainWindow* getMainWindow() { return mp_mainWindow; }
ContentManager* getContentManager() { return mp_manager; }
kiwix::Downloader* getDownloader() { return mp_downloader; }
TabBar* getTabWidget() { return mp_tabWidget; }
TabBar* getTabWidget() { return getMainWindow()->getTabBar(); }
QAction* getAction(Actions action);
QString getLibraryDirectory() { return m_libraryDirectory; };
kiwix::Server* getLocalServer() { return &m_server; }
@ -108,7 +108,6 @@ private:
kiwix::Downloader* mp_downloader;
ContentManager* mp_manager;
MainWindow* mp_mainWindow;
TabBar* mp_tabWidget;
QErrorMessage* mp_errorDialog;
kiwix::UpdatableNameMapper m_nameMapper;
kiwix::Server m_server;