瀏覽代碼

ImageViewer: Don't resize the window after the first image is displayed

Aziz Berkay Yesilyurt 4 年之前
父節點
當前提交
dd476c35cb
共有 2 個文件被更改,包括 5 次插入1 次删除
  1. 3 0
      Userland/Applications/ImageViewer/ViewWidget.h
  2. 2 1
      Userland/Applications/ImageViewer/main.cpp

+ 3 - 0
Userland/Applications/ImageViewer/ViewWidget.h

@@ -32,6 +32,8 @@ public:
     int scale() { return m_scale; }
     void set_toolbar_height(int height) { m_toolbar_height = height; }
     int toolbar_height() { return m_toolbar_height; }
+    bool scaled_for_first_image() { return m_scaled_for_first_image; }
+    void set_scaled_for_first_image(bool val) { m_scaled_for_first_image = val; }
 
     void clear();
     void flip(Gfx::Orientation);
@@ -73,6 +75,7 @@ private:
 
     int m_scale { -1 };
     int m_toolbar_height { 28 };
+    bool m_scaled_for_first_image { false };
     Gfx::FloatPoint m_pan_origin;
     Gfx::IntPoint m_click_position;
     Gfx::FloatPoint m_saved_pan_origin;

+ 2 - 1
Userland/Applications/ImageViewer/main.cpp

@@ -92,7 +92,8 @@ int main(int argc, char** argv)
         if (window->is_maximized())
             return;
 
-        if (scale == 100) {
+        if (scale == 100 && !widget.scaled_for_first_image()) {
+            widget.set_scaled_for_first_image(true);
             auto w = min(GUI::Desktop::the().rect().width(), rect.width() + 4);
             auto h = min(GUI::Desktop::the().rect().height(), rect.height() + widget.toolbar_height() + 6);
             window->resize(w, h);