mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 07:08:10 +00:00
GMessageBox: Hide the constructor and fix broken usages
We no longer support creating CObjects on the stack. Use construct().
This commit is contained in:
parent
c5e057438c
commit
1a279c5b2a
3 changed files with 5 additions and 5 deletions
|
@ -50,8 +50,7 @@ int main(int argc, char** argv)
|
||||||
auto filename = picker.selected_file().string();
|
auto filename = picker.selected_file().string();
|
||||||
auto bitmap = load_png(filename);
|
auto bitmap = load_png(filename);
|
||||||
if (!bitmap) {
|
if (!bitmap) {
|
||||||
GMessageBox msgbox(String::format("Failed to load '%s'", filename.characters()), "Open failed", GMessageBox::Type::Error, GMessageBox::InputType::OK, window);
|
GMessageBox::show(String::format("Failed to load '%s'", filename.characters()), "Open failed", GMessageBox::Type::Error, GMessageBox::InputType::OK, window);
|
||||||
msgbox.exec();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
paintable_widget->set_bitmap(*bitmap);
|
paintable_widget->set_bitmap(*bitmap);
|
||||||
|
|
|
@ -118,8 +118,8 @@ TextEditorWidget::TextEditorWidget()
|
||||||
|
|
||||||
m_new_action = GAction::create("New", { Mod_Ctrl, Key_N }, GraphicsBitmap::load_from_file("/res/icons/16x16/new.png"), [this](const GAction&) {
|
m_new_action = GAction::create("New", { Mod_Ctrl, Key_N }, GraphicsBitmap::load_from_file("/res/icons/16x16/new.png"), [this](const GAction&) {
|
||||||
if (m_document_dirty) {
|
if (m_document_dirty) {
|
||||||
GMessageBox save_document_first_box("Save Document First?", "Warning", GMessageBox::Type::Warning, GMessageBox::InputType::OKCancel, window());
|
auto save_document_first_box = GMessageBox::construct("Save Document First?", "Warning", GMessageBox::Type::Warning, GMessageBox::InputType::OKCancel, window());
|
||||||
auto save_document_first_result = save_document_first_box.exec();
|
auto save_document_first_result = save_document_first_box->exec();
|
||||||
|
|
||||||
if (save_document_first_result != GDialog::ExecResult::ExecOK)
|
if (save_document_first_result != GDialog::ExecResult::ExecOK)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -17,12 +17,13 @@ public:
|
||||||
OKCancel,
|
OKCancel,
|
||||||
};
|
};
|
||||||
|
|
||||||
explicit GMessageBox(const StringView& text, const StringView& title, Type type = Type::None, InputType = InputType::OK, CObject* parent = nullptr);
|
|
||||||
virtual ~GMessageBox() override;
|
virtual ~GMessageBox() override;
|
||||||
|
|
||||||
static int show(const StringView& text, const StringView& title, Type type = Type::None, InputType = InputType::OK, CObject* parent = nullptr);
|
static int show(const StringView& text, const StringView& title, Type type = Type::None, InputType = InputType::OK, CObject* parent = nullptr);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
explicit GMessageBox(const StringView& text, const StringView& title, Type type = Type::None, InputType = InputType::OK, CObject* parent = nullptr);
|
||||||
|
|
||||||
bool should_include_ok_button() const;
|
bool should_include_ok_button() const;
|
||||||
bool should_include_cancel_button() const;
|
bool should_include_cancel_button() const;
|
||||||
void build();
|
void build();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue