diff options
author | Aqua-sama <aqua@iserlohn-fortress.net> | 2020-04-03 21:23:35 +0300 |
---|---|---|
committer | Aqua-sama <aqua@iserlohn-fortress.net> | 2020-04-03 21:23:35 +0300 |
commit | 6e1d411f9218645851f0dde54688739390b62736 (patch) | |
tree | 7cc4af0155a3ce9dc5a0fb4014975b0aa9d2d165 /src/subwindow/subwindow.h | |
parent | Fix various compiler warnings (diff) | |
download | smolbote-6e1d411f9218645851f0dde54688739390b62736.tar.xz |
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
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; |