mirror of
https://github.com/RGBCube/serenity
synced 2025-07-23 12:37:40 +00:00
SQLStudio: Convert SQLStudio to GML
This commit is contained in:
parent
82363aa1c4
commit
9b1e754d56
3 changed files with 42 additions and 12 deletions
|
@ -4,11 +4,17 @@ serenity_component(
|
||||||
TARGETS SQLStudio
|
TARGETS SQLStudio
|
||||||
)
|
)
|
||||||
|
|
||||||
|
compile_gml(SQLStudio.gml SQLStudioGML.h sql_studio_gml)
|
||||||
|
|
||||||
set(SOURCES
|
set(SOURCES
|
||||||
main.cpp
|
main.cpp
|
||||||
MainWidget.cpp
|
MainWidget.cpp
|
||||||
ScriptEditor.cpp
|
ScriptEditor.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
set(GENERATED_SOURCES
|
||||||
|
SQLStudioGML.h
|
||||||
|
)
|
||||||
|
|
||||||
serenity_app(SQLStudio ICON app-sql-studio)
|
serenity_app(SQLStudio ICON app-sql-studio)
|
||||||
target_link_libraries(SQLStudio PRIVATE LibCore LibDesktop LibGfx LibGUI LibIPC LibMain LibSQL LibSyntax)
|
target_link_libraries(SQLStudio PRIVATE LibCore LibDesktop LibGfx LibGUI LibIPC LibMain LibSQL LibSyntax)
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <DevTools/SQLStudio/SQLStudioGML.h>
|
||||||
#include <LibDesktop/Launcher.h>
|
#include <LibDesktop/Launcher.h>
|
||||||
#include <LibGUI/Action.h>
|
#include <LibGUI/Action.h>
|
||||||
#include <LibGUI/Application.h>
|
#include <LibGUI/Application.h>
|
||||||
|
@ -29,12 +30,14 @@
|
||||||
#include "MainWidget.h"
|
#include "MainWidget.h"
|
||||||
#include "ScriptEditor.h"
|
#include "ScriptEditor.h"
|
||||||
|
|
||||||
|
REGISTER_WIDGET(SQLStudio, MainWidget);
|
||||||
|
|
||||||
namespace SQLStudio {
|
namespace SQLStudio {
|
||||||
|
|
||||||
MainWidget::MainWidget()
|
MainWidget::MainWidget()
|
||||||
{
|
{
|
||||||
set_fill_with_background_color(true);
|
if (!load_from_gml(sql_studio_gml))
|
||||||
set_layout<GUI::VerticalBoxLayout>();
|
VERIFY_NOT_REACHED();
|
||||||
|
|
||||||
m_new_action = GUI::Action::create("&New", { Mod_Ctrl, Key_N }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/new.png"sv).release_value_but_fixme_should_propagate_errors(), [this](auto&) {
|
m_new_action = GUI::Action::create("&New", { Mod_Ctrl, Key_N }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/new.png"sv).release_value_but_fixme_should_propagate_errors(), [this](auto&) {
|
||||||
open_new_script();
|
open_new_script();
|
||||||
|
@ -158,9 +161,7 @@ MainWidget::MainWidget()
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
auto& toolbar_container = add<GUI::ToolbarContainer>();
|
auto& toolbar = *find_descendant_of_type_named<GUI::Toolbar>("toolbar"sv);
|
||||||
auto& toolbar = toolbar_container.add<GUI::Toolbar>();
|
|
||||||
|
|
||||||
toolbar.add_action(*m_new_action);
|
toolbar.add_action(*m_new_action);
|
||||||
toolbar.add_action(*m_open_action);
|
toolbar.add_action(*m_open_action);
|
||||||
toolbar.add_action(*m_save_action);
|
toolbar.add_action(*m_save_action);
|
||||||
|
@ -175,9 +176,7 @@ MainWidget::MainWidget()
|
||||||
toolbar.add_separator();
|
toolbar.add_separator();
|
||||||
toolbar.add_action(*m_run_script_action);
|
toolbar.add_action(*m_run_script_action);
|
||||||
|
|
||||||
m_tab_widget = add<GUI::TabWidget>();
|
m_tab_widget = find_descendant_of_type_named<GUI::TabWidget>("script_tab_widget"sv);
|
||||||
m_tab_widget->set_close_button_enabled(true);
|
|
||||||
m_tab_widget->set_reorder_allowed(true);
|
|
||||||
|
|
||||||
m_tab_widget->on_tab_close_click = [&](auto& widget) {
|
m_tab_widget->on_tab_close_click = [&](auto& widget) {
|
||||||
auto editor = dynamic_cast<ScriptEditor*>(&widget);
|
auto editor = dynamic_cast<ScriptEditor*>(&widget);
|
||||||
|
@ -200,9 +199,7 @@ MainWidget::MainWidget()
|
||||||
on_editor_change();
|
on_editor_change();
|
||||||
};
|
};
|
||||||
|
|
||||||
m_action_tab_widget = add<GUI::TabWidget>();
|
m_action_tab_widget = find_descendant_of_type_named<GUI::TabWidget>("action_tab_widget"sv);
|
||||||
m_action_tab_widget->set_fixed_height(0);
|
|
||||||
m_action_tab_widget->set_close_button_enabled(true);
|
|
||||||
|
|
||||||
m_query_results_widget = m_action_tab_widget->add_tab<GUI::Widget>("Results");
|
m_query_results_widget = m_action_tab_widget->add_tab<GUI::Widget>("Results");
|
||||||
m_query_results_widget->set_layout<GUI::VerticalBoxLayout>();
|
m_query_results_widget->set_layout<GUI::VerticalBoxLayout>();
|
||||||
|
@ -213,7 +210,7 @@ MainWidget::MainWidget()
|
||||||
m_action_tab_widget->set_fixed_height(0);
|
m_action_tab_widget->set_fixed_height(0);
|
||||||
};
|
};
|
||||||
|
|
||||||
m_statusbar = add<GUI::Statusbar>(3);
|
m_statusbar = find_descendant_of_type_named<GUI::Statusbar>("statusbar"sv);
|
||||||
|
|
||||||
m_statusbar->segment(1).set_mode(GUI::Statusbar::Segment::Mode::Fixed);
|
m_statusbar->segment(1).set_mode(GUI::Statusbar::Segment::Mode::Fixed);
|
||||||
m_statusbar->segment(1).set_fixed_width(font().width("000000 characters (00000 words) selected"sv) + font().max_glyph_width());
|
m_statusbar->segment(1).set_fixed_width(font().width("000000 characters (00000 words) selected"sv) + font().max_glyph_width());
|
||||||
|
|
27
Userland/DevTools/SQLStudio/SQLStudio.gml
Normal file
27
Userland/DevTools/SQLStudio/SQLStudio.gml
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
@SQLStudio::MainWidget {
|
||||||
|
layout: @GUI::VerticalBoxLayout {}
|
||||||
|
fill_with_background_color: true
|
||||||
|
|
||||||
|
@GUI::ToolbarContainer {
|
||||||
|
@GUI::Toolbar {
|
||||||
|
name: "toolbar"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@GUI::TabWidget {
|
||||||
|
name: "script_tab_widget"
|
||||||
|
reorder_allowed: true
|
||||||
|
show_close_buttons: true
|
||||||
|
}
|
||||||
|
|
||||||
|
@GUI::TabWidget {
|
||||||
|
name: "action_tab_widget"
|
||||||
|
show_close_buttons: true
|
||||||
|
fixed_height: 0
|
||||||
|
}
|
||||||
|
|
||||||
|
@GUI::Statusbar {
|
||||||
|
name: "statusbar"
|
||||||
|
segment_count: 3
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue