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

PixelPaint: Allow configuring 'new image' defaults

This allows you to configure the default name, width, and height of
the 'new image' dialog. This is done by editing the config in
~/.config/PixelPaint.ini (no GUI at the moment).

Fixes #13967
MacDue преди 3 години
родител
ревизия
9b4aabbcf9
променени са 1 файла, в които са добавени 7 реда и са изтрити 2 реда
  1. 7 2
      Userland/Applications/PixelPaint/CreateNewImageDialog.cpp

+ 7 - 2
Userland/Applications/PixelPaint/CreateNewImageDialog.cpp

@@ -5,6 +5,7 @@
  */
 
 #include "CreateNewImageDialog.h"
+#include <LibConfig/Client.h>
 #include <LibGUI/BoxLayout.h>
 #include <LibGUI/Button.h>
 #include <LibGUI/Label.h>
@@ -33,6 +34,8 @@ CreateNewImageDialog::CreateNewImageDialog(GUI::Window* parent_window)
     m_name_textbox->on_change = [this] {
         m_image_name = m_name_textbox->text();
     };
+    auto default_name = Config::read_string("PixelPaint", "NewImage", "Name");
+    m_name_textbox->set_text(default_name);
 
     auto& width_label = main_widget.add<GUI::Label>("Width:");
     width_label.set_text_alignment(Gfx::TextAlignment::CenterLeft);
@@ -72,8 +75,10 @@ CreateNewImageDialog::CreateNewImageDialog(GUI::Window* parent_window)
     width_spinbox.set_range(1, 16384);
     height_spinbox.set_range(1, 16384);
 
-    width_spinbox.set_value(510);
-    height_spinbox.set_value(356);
+    auto default_width = Config::read_i32("PixelPaint", "NewImage", "Width", 510);
+    auto default_height = Config::read_i32("PixelPaint", "NewImage", "Height", 356);
+    width_spinbox.set_value(default_width);
+    height_spinbox.set_value(default_height);
 }
 
 }