From 6e1d411f9218645851f0dde54688739390b62736 Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Fri, 3 Apr 2020 21:23:35 +0300 Subject: Remove QMdiArea in MainWindow Kconfig: Change About Dialog shortcut default to F1 (was Ctrl+H) Change close current tab shortcut to Ctrl+W (was Ctrl+X) MainWindow: automatically close window when last subwindow is closed MenuBar: remove Tile/Cascade subwindows actions add show/hide/close subwindow actions SubWindow: remove Subwindow menu shortcut (was F1 by default) add close shortcut (default Ctrl+Shift+W) Minor fixes: Fix PKGBUILD sources --- src/subwindow/subwindow.h | 73 +++++++++++++++++++++++++++++++++++------------ 1 file changed, 55 insertions(+), 18 deletions(-) (limited to 'src/subwindow/subwindow.h') diff --git a/src/subwindow/subwindow.h b/src/subwindow/subwindow.h index c4f96c0..8343a9b 100644 --- a/src/subwindow/subwindow.h +++ b/src/subwindow/subwindow.h @@ -9,51 +9,88 @@ #ifndef SMOLBOTE_SUBWINDOW_H #define SMOLBOTE_SUBWINDOW_H -#include +#include "tabwidget.h" +#include "webengine/webview.h" +#include #include -#include +#include -class TabWidget; -class WebView; class WebProfile; -class SubWindow : public QMdiSubWindow +class SubWindow : public QWidget { Q_OBJECT public: - struct TabData - { + struct TabData { bool closeLocked = false; bool refreshLocked = false; }; explicit SubWindow(QWidget *parent = nullptr, Qt::WindowFlags flags = Qt::WindowFlags()); - ~SubWindow() override; + ~SubWindow() = default; + + [[nodiscard]] int currentTabIndex() const + { + return tabWidget->currentIndex(); + } + + [[nodiscard]] WebView *currentView() + { + return qobject_cast(tabWidget->currentWidget()); + } + + [[nodiscard]] WebView *view(int index) const + { + return qobject_cast(tabWidget->widget(index)); + } - int currentTabIndex() const; - WebView *currentView(); - WebView *view(int index) const; - int tabCount() const; + [[nodiscard]] int tabCount() const + { + return tabWidget->count(); + } void setProfile(WebProfile *profile); - WebProfile *profile() const; + [[nodiscard]] WebProfile *profile() const + { + return m_profile; + } void setTabData(TabData &data, int index); - TabData tabData(int index) const; + [[nodiscard]] TabData tabData(int index) const; signals: void currentViewChanged(WebView *view); void showStatusMessage(const QString &message, int timeout = 0); + void visibilityChanged(bool isVisible); + void aboutToClose(); public slots: int addTab(const QUrl &url = QUrl(), WebProfile *profile = nullptr); - void closeTab(int index); + void closeTab(int index) + { + tabWidget->removeTab(index); + } - void setCurrentTab(int index); + void setCurrentTab(int index) + { + if(index >= 0) + tabWidget->setCurrentIndex(index); + } void moveTab(int from, int to); - int restoreLastTab(); - void restoreTabMenu(QMenu *menu); + int restoreLastTab() + { + return tabWidget->restoreLastTab(); + } + void restoreTabMenu(QMenu *menu) + { + tabWidget->restoreTabMenu(menu); + } + +protected: + void closeEvent(QCloseEvent *event); + void hideEvent(QHideEvent *event); + void showEvent(QShowEvent *event); private: WebProfile *m_profile; -- cgit v1.2.1