Переглянути джерело

LibGUI: Swap order of InputBox value and parent window args

This is now consistent with the other dialog classes.
Linus Groh 4 роки тому
батько
коміт
3583b62ad3

+ 2 - 2
Userland/Applications/FileManager/DirectoryView.cpp

@@ -499,7 +499,7 @@ void DirectoryView::setup_actions()
 {
     m_mkdir_action = GUI::Action::create("New directory...", { Mod_Ctrl | Mod_Shift, Key_N }, Gfx::Bitmap::load_from_file("/res/icons/16x16/mkdir.png"), [&](const GUI::Action&) {
         String value;
-        if (GUI::InputBox::show(value, window(), "Enter name:", "New directory") == GUI::InputBox::ExecOK && !value.is_empty()) {
+        if (GUI::InputBox::show(window(), value, "Enter name:", "New directory") == GUI::InputBox::ExecOK && !value.is_empty()) {
             auto new_dir_path = LexicalPath::canonicalized_path(String::formatted("{}/{}", path(), value));
             int rc = mkdir(new_dir_path.characters(), 0777);
             if (rc < 0) {
@@ -511,7 +511,7 @@ void DirectoryView::setup_actions()
 
     m_touch_action = GUI::Action::create("New file...", { Mod_Ctrl | Mod_Shift, Key_F }, Gfx::Bitmap::load_from_file("/res/icons/16x16/new.png"), [&](const GUI::Action&) {
         String value;
-        if (GUI::InputBox::show(value, window(), "Enter name:", "New file") == GUI::InputBox::ExecOK && !value.is_empty()) {
+        if (GUI::InputBox::show(window(), value, "Enter name:", "New file") == GUI::InputBox::ExecOK && !value.is_empty()) {
             auto new_file_path = LexicalPath::canonicalized_path(String::formatted("{}/{}", path(), value));
             struct stat st;
             int rc = stat(new_file_path.characters(), &st);

+ 4 - 4
Userland/Applications/HexEditor/HexEditorWidget.cpp

@@ -77,7 +77,7 @@ HexEditorWidget::HexEditorWidget()
         }
 
         String value;
-        if (GUI::InputBox::show(value, window(), "Enter new file size:", "New file size") == GUI::InputBox::ExecOK && !value.is_empty()) {
+        if (GUI::InputBox::show(window(), value, "Enter new file size:", "New file size") == GUI::InputBox::ExecOK && !value.is_empty()) {
             auto file_size = value.to_int();
             if (file_size.has_value() && file_size.value() > 0) {
                 m_document_dirty = false;
@@ -143,7 +143,7 @@ HexEditorWidget::HexEditorWidget()
 
     m_goto_decimal_offset_action = GUI::Action::create("Go To Offset (Decimal)...", { Mod_Ctrl | Mod_Shift, Key_G }, Gfx::Bitmap::load_from_file("/res/icons/16x16/go-forward.png"), [this](const GUI::Action&) {
         String value;
-        if (GUI::InputBox::show(value, window(), "Enter Decimal offset:", "Go To") == GUI::InputBox::ExecOK && !value.is_empty()) {
+        if (GUI::InputBox::show(window(), value, "Enter Decimal offset:", "Go To") == GUI::InputBox::ExecOK && !value.is_empty()) {
             auto new_offset = value.to_int();
             if (new_offset.has_value())
                 m_editor->set_position(new_offset.value());
@@ -152,7 +152,7 @@ HexEditorWidget::HexEditorWidget()
 
     m_goto_hex_offset_action = GUI::Action::create("Go To Offset (Hex)...", { Mod_Ctrl, Key_G }, Gfx::Bitmap::load_from_file("/res/icons/16x16/go-forward.png"), [this](const GUI::Action&) {
         String value;
-        if (GUI::InputBox::show(value, window(), "Enter Hex offset:", "Go To") == GUI::InputBox::ExecOK && !value.is_empty()) {
+        if (GUI::InputBox::show(window(), value, "Enter Hex offset:", "Go To") == GUI::InputBox::ExecOK && !value.is_empty()) {
             auto new_offset = strtol(value.characters(), nullptr, 16);
             m_editor->set_position(new_offset);
         }
@@ -161,7 +161,7 @@ HexEditorWidget::HexEditorWidget()
     auto& edit_menu = menubar->add_menu("Edit");
     edit_menu.add_action(GUI::Action::create("Fill selection...", { Mod_Ctrl, Key_B }, [&](const GUI::Action&) {
         String value;
-        if (GUI::InputBox::show(value, window(), "Fill byte (hex):", "Fill Selection") == GUI::InputBox::ExecOK && !value.is_empty()) {
+        if (GUI::InputBox::show(window(), value, "Fill byte (hex):", "Fill Selection") == GUI::InputBox::ExecOK && !value.is_empty()) {
             auto fill_byte = strtol(value.characters(), nullptr, 16);
             m_editor->fill_selection(fill_byte);
         }

+ 15 - 15
Userland/Applications/IRCClient/IRCAppWindow.cpp

@@ -93,7 +93,7 @@ void IRCAppWindow::setup_client()
 
     if (m_client->hostname().is_empty()) {
         String value;
-        if (GUI::InputBox::show(value, this, "Enter server:", "Connect to server") == GUI::InputBox::ExecCancel)
+        if (GUI::InputBox::show(this, value, "Enter server:", "Connect to server") == GUI::InputBox::ExecCancel)
             ::exit(0);
 
         m_client->set_server(value, 6667);
@@ -107,7 +107,7 @@ void IRCAppWindow::setup_actions()
 {
     m_join_action = GUI::Action::create("Join channel", { Mod_Ctrl, Key_J }, Gfx::Bitmap::load_from_file("/res/icons/16x16/irc-join.png"), [&](auto&) {
         String value;
-        if (GUI::InputBox::show(value, this, "Enter channel name:", "Join channel") == GUI::InputBox::ExecOK && !value.is_empty())
+        if (GUI::InputBox::show(this, value, "Enter channel name:", "Join channel") == GUI::InputBox::ExecOK && !value.is_empty())
             m_client->handle_join_action(value);
     });
 
@@ -125,13 +125,13 @@ void IRCAppWindow::setup_actions()
 
     m_whois_action = GUI::Action::create("Whois user", Gfx::Bitmap::load_from_file("/res/icons/16x16/irc-whois.png"), [&](auto&) {
         String value;
-        if (GUI::InputBox::show(value, this, "Enter nickname:", "IRC WHOIS lookup") == GUI::InputBox::ExecOK && !value.is_empty())
+        if (GUI::InputBox::show(this, value, "Enter nickname:", "IRC WHOIS lookup") == GUI::InputBox::ExecOK && !value.is_empty())
             m_client->handle_whois_action(value);
     });
 
     m_open_query_action = GUI::Action::create("Open query", { Mod_Ctrl, Key_O }, Gfx::Bitmap::load_from_file("/res/icons/16x16/irc-open-query.png"), [&](auto&) {
         String value;
-        if (GUI::InputBox::show(value, this, "Enter nickname:", "Open IRC query with...") == GUI::InputBox::ExecOK && !value.is_empty())
+        if (GUI::InputBox::show(this, value, "Enter nickname:", "Open IRC query with...") == GUI::InputBox::ExecOK && !value.is_empty())
             m_client->handle_open_query_action(value);
     });
 
@@ -141,7 +141,7 @@ void IRCAppWindow::setup_actions()
 
     m_change_nick_action = GUI::Action::create("Change nickname", Gfx::Bitmap::load_from_file("/res/icons/16x16/irc-nick.png"), [this](auto&) {
         String value;
-        if (GUI::InputBox::show(value, this, "Enter nickname:", "Change nickname") == GUI::InputBox::ExecOK && !value.is_empty())
+        if (GUI::InputBox::show(this, value, "Enter nickname:", "Change nickname") == GUI::InputBox::ExecOK && !value.is_empty())
             m_client->handle_change_nick_action(value);
     });
 
@@ -151,7 +151,7 @@ void IRCAppWindow::setup_actions()
             return;
         }
         String value;
-        if (GUI::InputBox::show(value, this, "Enter topic:", "Change topic") == GUI::InputBox::ExecOK && !value.is_empty())
+        if (GUI::InputBox::show(this, value, "Enter topic:", "Change topic") == GUI::InputBox::ExecOK && !value.is_empty())
             m_client->handle_change_topic_action(window->channel().name(), value);
     });
 
@@ -161,7 +161,7 @@ void IRCAppWindow::setup_actions()
             return;
         }
         String value;
-        if (GUI::InputBox::show(value, this, "Enter nick:", "Invite user") == GUI::InputBox::ExecOK && !value.is_empty())
+        if (GUI::InputBox::show(this, value, "Enter nick:", "Invite user") == GUI::InputBox::ExecOK && !value.is_empty())
             m_client->handle_invite_user_action(window->channel().name(), value);
     });
 
@@ -179,7 +179,7 @@ void IRCAppWindow::setup_actions()
             return;
         }
         String value;
-        if (GUI::InputBox::show(value, this, "Enter nick:", "Voice user") == GUI::InputBox::ExecOK && !value.is_empty())
+        if (GUI::InputBox::show(this, value, "Enter nick:", "Voice user") == GUI::InputBox::ExecOK && !value.is_empty())
             m_client->handle_voice_user_action(window->channel().name(), value);
     });
 
@@ -189,7 +189,7 @@ void IRCAppWindow::setup_actions()
             return;
         }
         String value;
-        if (GUI::InputBox::show(value, this, "Enter nick:", "DeVoice user") == GUI::InputBox::ExecOK && !value.is_empty())
+        if (GUI::InputBox::show(this, value, "Enter nick:", "DeVoice user") == GUI::InputBox::ExecOK && !value.is_empty())
             m_client->handle_devoice_user_action(window->channel().name(), value);
     });
 
@@ -199,7 +199,7 @@ void IRCAppWindow::setup_actions()
             return;
         }
         String value;
-        if (GUI::InputBox::show(value, this, "Enter nick:", "Hop user") == GUI::InputBox::ExecOK && !value.is_empty())
+        if (GUI::InputBox::show(this, value, "Enter nick:", "Hop user") == GUI::InputBox::ExecOK && !value.is_empty())
             m_client->handle_hop_user_action(window->channel().name(), value);
     });
 
@@ -209,7 +209,7 @@ void IRCAppWindow::setup_actions()
             return;
         }
         String value;
-        if (GUI::InputBox::show(value, this, "Enter nick:", "DeHop user") == GUI::InputBox::ExecOK && !value.is_empty())
+        if (GUI::InputBox::show(this, value, "Enter nick:", "DeHop user") == GUI::InputBox::ExecOK && !value.is_empty())
             m_client->handle_dehop_user_action(window->channel().name(), value);
     });
 
@@ -219,7 +219,7 @@ void IRCAppWindow::setup_actions()
             return;
         }
         String value;
-        if (GUI::InputBox::show(value, this, "Enter nick:", "Op user") == GUI::InputBox::ExecOK && !value.is_empty())
+        if (GUI::InputBox::show(this, value, "Enter nick:", "Op user") == GUI::InputBox::ExecOK && !value.is_empty())
             m_client->handle_op_user_action(window->channel().name(), value);
     });
 
@@ -229,7 +229,7 @@ void IRCAppWindow::setup_actions()
             return;
         }
         String value;
-        if (GUI::InputBox::show(value, this, "Enter nick:", "DeOp user") == GUI::InputBox::ExecOK && !value.is_empty())
+        if (GUI::InputBox::show(this, value, "Enter nick:", "DeOp user") == GUI::InputBox::ExecOK && !value.is_empty())
             m_client->handle_deop_user_action(window->channel().name(), value);
     });
 
@@ -239,10 +239,10 @@ void IRCAppWindow::setup_actions()
             return;
         }
         String nick_value;
-        if (GUI::InputBox::show(nick_value, this, "Enter nick:", "Kick user") != GUI::InputBox::ExecOK || nick_value.is_empty())
+        if (GUI::InputBox::show(this, nick_value, "Enter nick:", "Kick user") != GUI::InputBox::ExecOK || nick_value.is_empty())
             return;
         String reason_value;
-        if (GUI::InputBox::show(reason_value, this, "Enter reason:", "Reason") == GUI::InputBox::ExecOK)
+        if (GUI::InputBox::show(this, reason_value, "Enter reason:", "Reason") == GUI::InputBox::ExecOK)
             m_client->handle_kick_user_action(window->channel().name(), nick_value, reason_value.characters());
     });
 

+ 1 - 1
Userland/Applications/IRCClient/IRCWindow.cpp

@@ -142,7 +142,7 @@ IRCWindow::IRCWindow(IRCClient& client, void* owner, Type type, const String& na
                 if (IRCClient::is_nick_prefix(nick[0]))
                     nick = nick.substring(1, nick.length() - 1);
                 String value;
-                if (GUI::InputBox::show(value, window(), "Enter reason:", "Reason") == GUI::InputBox::ExecOK)
+                if (GUI::InputBox::show(window(), value, "Enter reason:", "Reason") == GUI::InputBox::ExecOK)
                     m_client->handle_kick_user_action(m_name.characters(), m_client->nick_without_prefix(nick.characters()), value);
             }));
 

+ 1 - 1
Userland/Applications/KeyboardMapper/KeyboardMapperWidget.cpp

@@ -67,7 +67,7 @@ void KeyboardMapperWidget::create_frame()
 
         tmp_button.on_click = [this, &tmp_button]() {
             String value;
-            if (GUI::InputBox::show(value, window(), "New Character:", "Select Character") == GUI::InputBox::ExecOK) {
+            if (GUI::InputBox::show(window(), value, "New Character:", "Select Character") == GUI::InputBox::ExecOK) {
                 int i = m_keys.find_first_index(&tmp_button).value_or(0);
                 ASSERT(i > 0);
 

+ 2 - 2
Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp

@@ -100,7 +100,7 @@ SpreadsheetWidget::SpreadsheetWidget(NonnullRefPtrVector<Sheet>&& sheets, bool s
 
         auto& sheet = m_tab_context_menu_sheet_view->sheet();
         String new_name;
-        if (GUI::InputBox::show(new_name, window(), String::formatted("New name for '{}'", sheet.name()), "Rename sheet") == GUI::Dialog::ExecOK) {
+        if (GUI::InputBox::show(window(), new_name, String::formatted("New name for '{}'", sheet.name()), "Rename sheet") == GUI::Dialog::ExecOK) {
             sheet.set_name(new_name);
             sheet.update();
             m_tab_widget->set_tab_title(static_cast<GUI::Widget&>(*m_tab_context_menu_sheet_view), new_name);
@@ -109,7 +109,7 @@ SpreadsheetWidget::SpreadsheetWidget(NonnullRefPtrVector<Sheet>&& sheets, bool s
     m_tab_context_menu->add_action(rename_action);
     m_tab_context_menu->add_action(GUI::Action::create("Add new sheet...", [this](auto&) {
         String name;
-        if (GUI::InputBox::show(name, window(), "Name for new sheet", "Create sheet") == GUI::Dialog::ExecOK) {
+        if (GUI::InputBox::show(window(), name, "Name for new sheet", "Create sheet") == GUI::Dialog::ExecOK) {
             NonnullRefPtrVector<Sheet> new_sheets;
             new_sheets.append(m_workbook->add_sheet(name));
             setup_tabs(move(new_sheets));

+ 1 - 1
Userland/Demos/WidgetGallery/main.cpp

@@ -462,7 +462,7 @@ int main(int argc, char** argv)
     auto& input_button = input_button_container.add<GUI::Button>("Input...");
     String value;
     input_button.on_click = [&](auto) {
-        if (GUI::InputBox::show(value, window, "Enter input:", "Input Box") == GUI::InputBox::ExecOK && !value.is_empty())
+        if (GUI::InputBox::show(window, value, "Enter input:", "Input Box") == GUI::InputBox::ExecOK && !value.is_empty())
             input_label.set_text(value);
     };
 

+ 1 - 1
Userland/DevTools/HackStudio/Debugger/DebugInfoWidget.cpp

@@ -126,7 +126,7 @@ NonnullRefPtr<GUI::Widget> DebugInfoWidget::build_variables_tab()
             return;
 
         String value;
-        if (GUI::InputBox::show(value, window(), "Enter new value:", "Set variable value") == GUI::InputBox::ExecOK) {
+        if (GUI::InputBox::show(window(), value, "Enter new value:", "Set variable value") == GUI::InputBox::ExecOK) {
             auto& model = static_cast<VariablesModel&>(*m_variables_view->model());
             model.set_variable_value(index, value, window());
         }

+ 1 - 1
Userland/DevTools/HackStudio/Git/GitWidget.cpp

@@ -153,7 +153,7 @@ void GitWidget::unstage_file(const LexicalPath& file)
 void GitWidget::commit()
 {
     String message;
-    auto res = GUI::InputBox::show(message, window(), "Commit message:", "Commit");
+    auto res = GUI::InputBox::show(window(), message, "Commit message:", "Commit");
     if (res != GUI::InputBox::ExecOK || message.is_empty())
         return;
     dbgln("commit message: {}", message);

+ 2 - 2
Userland/DevTools/HackStudio/HackStudioWidget.cpp

@@ -310,7 +310,7 @@ NonnullRefPtr<GUI::Action> HackStudioWidget::create_new_file_action()
 {
     return GUI::Action::create("Add new file to project...", { Mod_Ctrl, Key_N }, Gfx::Bitmap::load_from_file("/res/icons/16x16/new.png"), [this](const GUI::Action&) {
         String filename;
-        if (GUI::InputBox::show(filename, window(), "Enter name of new file:", "Add new file to project") != GUI::InputBox::ExecOK)
+        if (GUI::InputBox::show(window(), filename, "Enter name of new file:", "Add new file to project") != GUI::InputBox::ExecOK)
             return;
         auto file = Core::File::construct(filename);
         if (!file->open((Core::IODevice::OpenMode)(Core::IODevice::WriteOnly | Core::IODevice::MustBeNew))) {
@@ -325,7 +325,7 @@ NonnullRefPtr<GUI::Action> HackStudioWidget::create_new_directory_action()
 {
     return GUI::Action::create("Add new directory to project...", { Mod_Ctrl | Mod_Shift, Key_N }, Gfx::Bitmap::load_from_file("/res/icons/16x16/mkdir.png"), [this](const GUI::Action&) {
         String directory_name;
-        if (GUI::InputBox::show(directory_name, window(), "Enter name of new directory:", "Add new folder to project") != GUI::InputBox::ExecOK)
+        if (GUI::InputBox::show(window(), directory_name, "Enter name of new directory:", "Add new folder to project") != GUI::InputBox::ExecOK)
             return;
         auto formatted_dir_name = LexicalPath::canonicalized_path(String::formatted("{}/{}", m_project->model().root_path(), directory_name));
         int rc = mkdir(formatted_dir_name.characters(), 0755);

+ 1 - 1
Userland/Libraries/LibGUI/FilePicker.cpp

@@ -139,7 +139,7 @@ FilePicker::FilePicker(Window* parent_window, Mode mode, const StringView& file_
 
     auto mkdir_action = Action::create("New directory...", Gfx::Bitmap::load_from_file("/res/icons/16x16/mkdir.png"), [this](const Action&) {
         String value;
-        if (InputBox::show(value, this, "Enter name:", "New directory") == InputBox::ExecOK && !value.is_empty()) {
+        if (InputBox::show(this, value, "Enter name:", "New directory") == InputBox::ExecOK && !value.is_empty()) {
             auto new_dir_path = LexicalPath::canonicalized_path(String::formatted("{}/{}", m_model->root_path(), value));
             int rc = mkdir(new_dir_path.characters(), 0777);
             if (rc < 0) {

+ 1 - 1
Userland/Libraries/LibGUI/InputBox.cpp

@@ -46,7 +46,7 @@ InputBox::~InputBox()
 {
 }
 
-int InputBox::show(String& text_value, Window* parent_window, const StringView& prompt, const StringView& title)
+int InputBox::show(Window* parent_window, String& text_value, const StringView& prompt, const StringView& title)
 {
     auto box = InputBox::construct(parent_window, prompt, title);
     box->set_resizable(false);

+ 1 - 1
Userland/Libraries/LibGUI/InputBox.h

@@ -35,7 +35,7 @@ class InputBox : public Dialog {
 public:
     virtual ~InputBox() override;
 
-    static int show(String& text_value, Window* parent_window, const StringView& prompt, const StringView& title);
+    static int show(Window* parent_window, String& text_value, const StringView& prompt, const StringView& title);
 
 private:
     explicit InputBox(Window* parent_window, const StringView& prompt, const StringView& title);

+ 1 - 1
Userland/Libraries/LibGUI/TextEditor.cpp

@@ -105,7 +105,7 @@ void TextEditor::create_actions()
         m_go_to_line_action = Action::create(
             "Go to line...", { Mod_Ctrl, Key_L }, Gfx::Bitmap::load_from_file("/res/icons/16x16/go-forward.png"), [this](auto&) {
                 String value;
-                if (InputBox::show(value, window(), "Line:", "Go to line") == InputBox::ExecOK) {
+                if (InputBox::show(window(), value, "Line:", "Go to line") == InputBox::ExecOK) {
                     auto line_target = value.to_uint();
                     if (line_target.has_value()) {
                         set_cursor_and_focus_line(line_target.value() - 1, 0);