diff options
Diffstat (limited to 'src/subwindow/subwindow.h')
-rw-r--r-- | src/subwindow/subwindow.h | 73 |
1 files changed, 55 insertions, 18 deletions
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 <QMdiSubWindow> +#include "tabwidget.h" +#include "webengine/webview.h" +#include <QMenu> #include <QUrl> -#include <memory> +#include <QWidget> -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<WebView *>(tabWidget->currentWidget()); + } + + [[nodiscard]] WebView *view(int index) const + { + return qobject_cast<WebView *>(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; |