LibGUI: Convert GWindow to ObjectPtr

This commit is contained in:
Andreas Kling 2019-09-21 18:34:06 +02:00
parent 70412c7d4f
commit 7584480f62
Notes: sideshowbarker 2024-07-19 12:01:24 +09:00
25 changed files with 37 additions and 37 deletions

View file

@ -10,7 +10,7 @@ int main(int argc, char** argv)
{
GApplication app(argc, argv);
auto* window = new GWindow;
auto window = GWindow::construct();
window->set_title("About Serenity");
Rect window_rect { 0, 0, 240, 150 };
window_rect.center_within(GDesktop::the().rect());

View file

@ -6,7 +6,7 @@ int main(int argc, char** argv)
{
GApplication app(argc, argv);
auto* window = new GWindow;
auto window = GWindow::construct();
window->set_title("Calculator");
window->set_resizable(false);
window->set_rect({ 300, 200, 254, 213 });

View file

@ -12,7 +12,7 @@ int main(int argc, char** argv)
{
GApplication app(argc, argv);
auto* window = new GWindow;
auto window = GWindow::construct();
window->set_title("ChanViewer");
window->set_rect(100, 100, 800, 500);
window->set_icon(load_png("/res/icons/16x16/app-chanviewer.png"));

View file

@ -40,7 +40,7 @@ int main(int argc, char** argv)
GApplication app(argc, argv);
auto* window = new GWindow;
auto window = GWindow::construct();
window->set_title("File Manager");
window->set_rect(20, 200, 640, 480);

View file

@ -25,7 +25,7 @@ int main(int argc, char** argv)
else
edited_font = Font::default_font().clone();
auto* window = new GWindow;
auto window = GWindow::construct();
window->set_title("Font Editor");
window->set_rect({ 50, 50, 390, 342 });
auto* font_editor = new FontEditorWidget(path, move(edited_font));

View file

@ -12,7 +12,7 @@
#include <sys/wait.h>
#include <unistd.h>
static GWindow* make_launcher_window();
static ObjectPtr<GWindow> make_launcher_window();
void handle_sigchld(int)
{
@ -31,7 +31,7 @@ int main(int argc, char** argv)
signal(SIGCHLD, handle_sigchld);
auto* launcher_window = make_launcher_window();
auto launcher_window = make_launcher_window();
launcher_window->show();
return app.exec();
@ -63,12 +63,12 @@ private:
String m_executable_path;
};
GWindow* make_launcher_window()
ObjectPtr<GWindow> make_launcher_window()
{
auto config = CConfigFile::get_for_app("Launcher");
auto vertical = config->read_bool_entry("Launcher", "Vertical", true);
auto* window = new GWindow;
auto window = GWindow::construct();
window->set_title("Launcher");
int launcher_size = (config->groups().size() - 1) * 50;
window->set_rect(50, 50, vertical ? 50 : launcher_size, vertical ? launcher_size : 50);

View file

@ -15,7 +15,7 @@ int main(int argc, char** argv)
{
GApplication app(argc, argv);
auto* window = new GWindow;
auto window = GWindow::construct();
window->set_title("PaintBrush");
window->set_rect(100, 100, 640, 480);

View file

@ -17,7 +17,7 @@ int main(int argc, char** argv)
AClientConnection audio_connection;
audio_connection.handshake();
auto* window = new GWindow;
auto window = GWindow::construct();
window->set_title("Piano");
window->set_rect(100, 100, 512, 512);

View file

@ -50,7 +50,7 @@ int main(int argc, char** argv)
return 1;
}
auto* window = new GWindow;
auto window = GWindow::construct();
auto update_window_title = [&](int scale) {
window->set_title(String::format("QuickShow: %s %s %d%%", path, bitmap->size().to_string().characters(), scale));

View file

@ -30,7 +30,7 @@ int main(int argc, char** argv)
AClientConnection audio_client;
audio_client.handshake();
auto* window = new GWindow;
auto window = GWindow::construct();
window->set_title("SoundPlayer");
window->set_rect(300, 300, 300, 200);

View file

@ -88,9 +88,9 @@ static void run_command(int ptm_fd, String command)
}
}
GWindow* create_settings_window(TerminalWidget& terminal, RefPtr<CConfigFile> config)
ObjectPtr<GWindow> create_settings_window(TerminalWidget& terminal, RefPtr<CConfigFile> config)
{
auto* window = new GWindow;
auto window = GWindow::construct();
window->set_title("Terminal Settings");
window->set_rect(50, 50, 200, 140);
@ -156,7 +156,7 @@ int main(int argc, char** argv)
run_command(ptm_fd, args.get("e"));
auto* window = new GWindow;
auto window = GWindow::construct();
window->set_title("Terminal");
window->set_background_color(Color::Black);
window->set_double_buffering_enabled(false);
@ -170,7 +170,7 @@ int main(int argc, char** argv)
window->set_icon(load_png("/res/icons/16x16/app-terminal.png"));
terminal->set_should_beep(config->read_bool_entry("Window", "AudibleBeep", false));
WeakPtr<GWindow> settings_window;
ObjectPtr<GWindow> settings_window;
auto new_opacity = config->read_num_entry("Window", "Opacity", 255);
terminal->set_opacity(new_opacity);
@ -180,9 +180,9 @@ int main(int argc, char** argv)
auto app_menu = make<GMenu>("Terminal");
app_menu->add_action(GAction::create("Settings...", load_png("/res/icons/gear16.png"),
[&settings_window, terminal, &config](const GAction&) {
[&](const GAction&) {
if (!settings_window)
settings_window = create_settings_window(*terminal, config)->make_weak_ptr();
settings_window = create_settings_window(*terminal, config);
settings_window->show();
settings_window->move_to_front();
}));

View file

@ -5,7 +5,7 @@ int main(int argc, char** argv)
{
GApplication app(argc, argv);
auto* window = new GWindow;
auto window = GWindow::construct();
window->set_title("Text Editor");
window->set_rect(20, 200, 640, 400);

View file

@ -62,7 +62,7 @@ int main(int argc, char** argv)
GApplication app(argc, argv);
auto* window = new GWindow;
auto window = GWindow::construct();
window->set_title("Welcome to Serenity");
Rect window_rect { 0, 0, 640, 360 };
window_rect.center_within(GDesktop::the().rect());

View file

@ -214,7 +214,7 @@ int main(int argc, char** argv)
{
GApplication app(argc, argv);
auto* window = new GWindow;
auto window = GWindow::construct();
window->set_double_buffering_enabled(false);
window->set_title("Fire");
window->set_resizable(false);

View file

@ -9,7 +9,7 @@ int main(int argc, char** argv)
{
GApplication app(argc, argv);
auto* window = new GWindow;
auto window = GWindow::construct();
window->set_rect(100, 100, 240, 160);
window->set_title("Hello World!");

View file

@ -10,7 +10,7 @@ int main(int argc, char** argv)
{
GApplication app(argc, argv);
auto* window = new GWindow;
auto window = GWindow::construct();
window->set_rect(100, 100, 240, 160);
window->set_title("Hello World!");

View file

@ -38,7 +38,7 @@ int main(int argc, char** argv)
{
GApplication app(argc, argv);
auto* window = new GWindow;
auto window = GWindow::construct();
window->set_rect(100, 100, 400, 400);
window->set_title("Paint test");

View file

@ -18,7 +18,7 @@ int main(int argc, char** argv)
{
GApplication app(argc, argv);
auto* window = new GWindow;
auto window = GWindow::construct();
window->set_rect(100, 100, 320, 620);
window->set_title("Widget Gallery");

View file

@ -28,7 +28,7 @@ int main(int argc, char** argv)
GApplication app(argc, argv);
auto* window = new GWindow;
auto window = GWindow::construct();
window->set_title("Inspector");
window->set_rect(150, 150, 300, 500);

View file

@ -17,7 +17,7 @@
#include <stdio.h>
#include <unistd.h>
static GWindow* make_toolbox_window();
static ObjectPtr<GWindow> make_toolbox_window();
int main(int argc, char** argv)
{
@ -47,7 +47,7 @@ int main(int argc, char** argv)
}));
menubar->add_menu(move(file_menu));
auto* window = new GWindow;
auto window = GWindow::construct();
window->set_title(form1->name());
window->set_rect(120, 200, 640, 400);
window->set_main_widget(form1);
@ -62,7 +62,7 @@ int main(int argc, char** argv)
app.set_menubar(move(menubar));
auto* toolbox = make_toolbox_window();
auto toolbox = make_toolbox_window();
toolbox->show();
propbox->show();
@ -74,9 +74,9 @@ int main(int argc, char** argv)
return app.exec();
}
GWindow* make_toolbox_window()
ObjectPtr<GWindow> make_toolbox_window()
{
auto* window = new GWindow;
auto window = GWindow::construct();
window->set_title("Widgets");
window->set_rect(20, 200, 80, 300);

View file

@ -14,7 +14,7 @@ int main(int argc, char** argv)
{
GApplication app(argc, argv);
auto* window = new GWindow;
auto window = GWindow::construct();
window->set_resizable(false);
window->set_title("Minesweeper");
window->set_rect(100, 100, 139, 175);

View file

@ -12,7 +12,7 @@ int main(int argc, char** argv)
{
GApplication app(argc, argv);
auto* window = new GWindow;
auto window = GWindow::construct();
window->set_double_buffering_enabled(false);
window->set_title("Snake");

View file

@ -28,7 +28,7 @@ GComboBox::GComboBox(GWidget* parent)
open();
};
m_list_window = new GWindow(this);
m_list_window = GWindow::construct(this);
// FIXME: This is obviously not a tooltip window, but it's the closest thing to what we want atm.
m_list_window->set_window_type(GWindowType::Tooltip);
m_list_window->set_should_destroy_on_close(false);

View file

@ -38,7 +38,7 @@ protected:
private:
ObjectPtr<GTextEditor> m_editor;
GButton* m_open_button { nullptr };
GWindow* m_list_window { nullptr };
ObjectPtr<GWindow> m_list_window;
ObjectPtr<GListView> m_list_view;
bool m_only_allow_values_from_model { false };
};

View file

@ -24,7 +24,6 @@ enum class GStandardCursor {
class GWindow : public CObject {
C_OBJECT(GWindow)
public:
GWindow(CObject* parent = nullptr);
virtual ~GWindow() override;
static GWindow* from_window_id(int);
@ -135,6 +134,7 @@ public:
virtual void save_to(AK::JsonObject&) override;
protected:
GWindow(CObject* parent = nullptr);
virtual void wm_event(GWMEvent&);
private: