Преглед на файлове

UI/Qt: Don't save size and location of popup windows on exit

Tim Ledbetter преди 1 година
родител
ревизия
2d95cc01dc
променени са 4 файла, в които са добавени 18 реда и са изтрити 9 реда
  1. 2 2
      Ladybird/Qt/Application.cpp
  2. 1 1
      Ladybird/Qt/Application.h
  3. 8 5
      Ladybird/Qt/BrowserWindow.cpp
  4. 7 1
      Ladybird/Qt/BrowserWindow.h

+ 2 - 2
Ladybird/Qt/Application.cpp

@@ -96,9 +96,9 @@ void Application::close_task_manager_window()
     }
 }
 
-BrowserWindow& Application::new_window(Vector<URL::URL> const& initial_urls, WebView::CookieJar& cookie_jar, WebContentOptions const& web_content_options, StringView webdriver_content_ipc_path, bool allow_popups, Tab* parent_tab, Optional<u64> page_index)
+BrowserWindow& Application::new_window(Vector<URL::URL> const& initial_urls, WebView::CookieJar& cookie_jar, WebContentOptions const& web_content_options, StringView webdriver_content_ipc_path, bool allow_popups, BrowserWindow::IsPopupWindow is_popup_window, Tab* parent_tab, Optional<u64> page_index)
 {
-    auto* window = new BrowserWindow(initial_urls, cookie_jar, web_content_options, webdriver_content_ipc_path, allow_popups, parent_tab, move(page_index));
+    auto* window = new BrowserWindow(initial_urls, cookie_jar, web_content_options, webdriver_content_ipc_path, allow_popups, is_popup_window, parent_tab, move(page_index));
     set_active_window(*window);
     window->show();
     if (initial_urls.is_empty()) {

+ 1 - 1
Ladybird/Qt/Application.h

@@ -31,7 +31,7 @@ public:
     NonnullRefPtr<ImageDecoderClient::Client> image_decoder_client() const { return *m_image_decoder_client; }
     ErrorOr<void> initialize_image_decoder();
 
-    BrowserWindow& new_window(Vector<URL::URL> const& initial_urls, WebView::CookieJar&, WebContentOptions const&, StringView webdriver_content_ipc_path, bool allow_popups, Tab* parent_tab = nullptr, Optional<u64> page_index = {});
+    BrowserWindow& new_window(Vector<URL::URL> const& initial_urls, WebView::CookieJar&, WebContentOptions const&, StringView webdriver_content_ipc_path, bool allow_popups, BrowserWindow::IsPopupWindow is_popup_window = BrowserWindow::IsPopupWindow::No, Tab* parent_tab = nullptr, Optional<u64> page_index = {});
 
     void show_task_manager_window(WebContentOptions const&);
     void close_task_manager_window();

+ 8 - 5
Ladybird/Qt/BrowserWindow.cpp

@@ -70,13 +70,14 @@ public:
     }
 };
 
-BrowserWindow::BrowserWindow(Vector<URL::URL> const& initial_urls, WebView::CookieJar& cookie_jar, WebContentOptions const& web_content_options, StringView webdriver_content_ipc_path, bool allow_popups, Tab* parent_tab, Optional<u64> page_index)
+BrowserWindow::BrowserWindow(Vector<URL::URL> const& initial_urls, WebView::CookieJar& cookie_jar, WebContentOptions const& web_content_options, StringView webdriver_content_ipc_path, bool allow_popups, IsPopupWindow is_popup_window, Tab* parent_tab, Optional<u64> page_index)
     : m_tabs_container(new TabWidget(this))
     , m_new_tab_button_toolbar(new QToolBar("New Tab", m_tabs_container))
     , m_cookie_jar(cookie_jar)
     , m_web_content_options(web_content_options)
     , m_webdriver_content_ipc_path(webdriver_content_ipc_path)
     , m_allow_popups(allow_popups)
+    , m_is_popup_window(is_popup_window)
 {
     setWindowIcon(app_icon());
 
@@ -786,7 +787,7 @@ void BrowserWindow::initialize_tab(Tab* tab)
 
     tab->view().on_new_web_view = [this, tab](auto activate_tab, Web::HTML::WebViewHints hints, Optional<u64> page_index) {
         if (hints.popup) {
-            auto& window = static_cast<Ladybird::Application*>(QApplication::instance())->new_window({}, m_cookie_jar, m_web_content_options, m_webdriver_content_ipc_path, m_allow_popups, tab, AK::move(page_index));
+            auto& window = static_cast<Ladybird::Application*>(QApplication::instance())->new_window({}, m_cookie_jar, m_web_content_options, m_webdriver_content_ipc_path, m_allow_popups, IsPopupWindow::Yes, tab, AK::move(page_index));
             window.set_window_rect(hints.screen_x, hints.screen_y, hints.width, hints.height);
             return window.current_tab()->view().handle();
         }
@@ -1238,9 +1239,11 @@ bool BrowserWindow::eventFilter(QObject* obj, QEvent* event)
 
 void BrowserWindow::closeEvent(QCloseEvent* event)
 {
-    Settings::the()->set_last_position(pos());
-    Settings::the()->set_last_size(size());
-    Settings::the()->set_is_maximized(isMaximized());
+    if (m_is_popup_window == IsPopupWindow::No) {
+        Settings::the()->set_last_position(pos());
+        Settings::the()->set_last_size(size());
+        Settings::the()->set_is_maximized(isMaximized());
+    }
 
     QObject::deleteLater();
 

+ 7 - 1
Ladybird/Qt/BrowserWindow.h

@@ -31,7 +31,12 @@ class BrowserWindow : public QMainWindow {
     Q_OBJECT
 
 public:
-    BrowserWindow(Vector<URL::URL> const& initial_urls, WebView::CookieJar&, WebContentOptions const&, StringView webdriver_content_ipc_path, bool allow_popups, Tab* parent_tab = nullptr, Optional<u64> page_index = {});
+    enum class IsPopupWindow {
+        No,
+        Yes,
+    };
+
+    BrowserWindow(Vector<URL::URL> const& initial_urls, WebView::CookieJar&, WebContentOptions const&, StringView webdriver_content_ipc_path, bool allow_popups, IsPopupWindow is_popup_window = IsPopupWindow::No, Tab* parent_tab = nullptr, Optional<u64> page_index = {});
 
     WebContentView& view() const { return m_current_tab->view(); }
 
@@ -216,6 +221,7 @@ private:
     StringView m_webdriver_content_ipc_path;
 
     bool m_allow_popups { false };
+    IsPopupWindow m_is_popup_window { IsPopupWindow::No };
 };
 
 }