Skip to content

A native macOS / windows / Linux database IDE built with Swift and AppKit. Connect to PostgreSQL, MySQL, SQLite, and Redis from a single app with a fast, keyboard-driven interface.

C++

feat(windows): grid context menu + regroup top-right toolbar

DangHuynhc44bb26bf831
diff --git a/windows/Gridex/DataGridView.cpp b/windows/Gridex/DataGridView.cpp
index 42d2985..ba2ccd0 100644
--- a/windows/Gridex/DataGridView.cpp
+++ b/windows/Gridex/DataGridView.cpp
@@ -58,6 +58,47 @@ namespace winrt::Gridex::implementation
{
Grid_KeyDown(sender, e);
});
+
+ // Right-click context menu. Host wires OnRefreshRequested /
+ // OnDeleteRequested in WorkspacePage; unset = no-op. Delete is
+ // disabled for read-only grids (e.g. Redis projections) and when
+ // no row is selected.
+ {
+ muxc::MenuFlyout contextMenu;
+
+ muxc::MenuFlyoutItem refreshItem;
+ refreshItem.Text(L"Refresh");
+ muxc::FontIcon refreshIcon;
+ refreshIcon.Glyph(L"\xE72C");
+ refreshItem.Icon(refreshIcon);
+ refreshItem.Click([this](auto&&, auto&&)
+ {
+ if (OnRefreshRequested) OnRefreshRequested();
+ });
+ contextMenu.Items().Append(refreshItem);
+
+ contextMenu.Items().Append(muxc::MenuFlyoutSeparator{});
+
+ muxc::MenuFlyoutItem deleteItem;
+ deleteItem.Text(L"Delete Row");
+ muxc::FontIcon deleteIcon;
+ deleteIcon.Glyph(L"\xE74D");
+ deleteItem.Icon(deleteIcon);
+ deleteItem.Click([this](auto&&, auto&&)
+ {
+ if (OnDeleteRequested) OnDeleteRequested();
+ });
+ contextMenu.Items().Append(deleteItem);
+
+ // Gate Delete on read-only mode + row selection at open time so
+ // the menu reflects the grid's actual state each right-click.
+ contextMenu.Opening([this, deleteItem](auto&&, auto&&)
+ {
+ deleteItem.IsEnabled(!readOnly_ && selectedRow_ >= 0);
+ });
+
+ this->ContextFlyout(contextMenu);
+ }
this->Loaded([this](winrt::Windows::Foundation::IInspectable const&, mux::RoutedEventArgs const&)
{
DataScroller().ViewChanged(
diff --git a/windows/Gridex/DataGridView.h b/windows/Gridex/DataGridView.h
index 20dad22..4f26a4a 100644
--- a/windows/Gridex/DataGridView.h
+++ b/windows/Gridex/DataGridView.h
@@ -33,6 +33,10 @@ namespace winrt::Gridex::implementation
// deleted (pending commit). Host routes this to DeleteSelectedRow.
std::function<void()> OnDeleteRequested;
+ // Callback when user picks "Refresh" from the grid context menu —
+ // host re-runs the current tab's query to pull fresh rows.
+ std::function<void()> OnRefreshRequested;
+
// Get selected row data for copy
const DBModels::TableRow* GetSelectedRow() const;
diff --git a/windows/Gridex/WorkspacePage.cpp b/windows/Gridex/WorkspacePage.cpp
index 901eed7..db8696a 100644
--- a/windows/Gridex/WorkspacePage.cpp
+++ b/windows/Gridex/WorkspacePage.cpp
@@ -173,6 +173,12 @@ namespace winrt::Gridex::implementation
DeleteSelectedRow();
};
+ // Right-click → Refresh: re-run the active tab's query.
+ DataGrid().as<DataGridView>()->OnRefreshRequested = [this]()
+ {
+ ReloadCurrentTable();
+ };
+
// Wire structure view ALTER apply
Structure().as<StructureView>()->OnApplyAlter = [this](const std::vector<std::wstring>& sqls)
{
@@ -760,18 +766,9 @@ namespace winrt::Gridex::implementation
SidebarToggleBtn().Click([this](winrt::Windows::Foundation::IInspectable const&, mux::RoutedEventArgs const&)
{ ToggleSidebar_Click({}, {}); });
- DeleteBtn().Click([this](winrt::Windows::Foundation::IInspectable const&, mux::RoutedEventArgs const&)
- { DeleteSelectedRow(); });
-
- CommitToolbarBtn().Click([this](winrt::Windows::Foundation::IInspectable const&, mux::RoutedEventArgs const&)
- { CommitChanges(); });
-
DetailsToggleBtn().Click([this](winrt::Windows::Foundation::IInspectable const&, mux::RoutedEventArgs const&)
{ ToggleDetails_Click({}, {}); });
- AiToggleBtn().Click([this](winrt::Windows::Foundation::IInspectable const&, mux::RoutedEventArgs const&)
- { ToggleAI_Click({}, {}); });
-
DumpBtn().Click([this](winrt::Windows::Foundation::IInspectable const&, mux::RoutedEventArgs const&)
{ DumpDatabaseAsync(); });
diff --git a/windows/Gridex/WorkspacePage.xaml b/windows/Gridex/WorkspacePage.xaml
index edd09b0..caa60d6 100644
--- a/windows/Gridex/WorkspacePage.xaml
+++ b/windows/Gridex/WorkspacePage.xaml
@@ -61,8 +61,9 @@
Foreground="{ThemeResource TextFillColorTertiaryBrush}" />
</StackPanel>
- <!-- Right: Delete + Commit | Details + AI -->
+ <!-- Right toolbar, grouped: [Backup] | [Schema] | [App] -->
<StackPanel Grid.Column="3" Orientation="Horizontal" Spacing="4">
+ <!-- Group 1: Backup / Restore -->
<Button x:Name="DumpBtn" Width="32" Height="32" Padding="0"
Background="Transparent" BorderThickness="0"
ToolTipService.ToolTip="Dump Database">
@@ -73,33 +74,26 @@
ToolTipService.ToolTip="Restore Database">
<FontIcon Glyph="&#xE777;" FontSize="14" />
</Button>
+
+ <Border Width="1" Height="20" Margin="4,0"
+ Background="{ThemeResource DividerStrokeColorDefaultBrush}" />
+
+ <!-- Group 2: Schema visualization -->
<Button x:Name="ERDiagramBtn" Width="32" Height="32" Padding="0"
Background="Transparent" BorderThickness="0"
ToolTipService.ToolTip="ER Diagram (current schema)">
<FontIcon Glyph="&#xF169;" FontSize="14" />
</Button>
- <Button x:Name="DeleteBtn" Width="32" Height="32" Padding="0"
- Background="Transparent" BorderThickness="0"
- ToolTipService.ToolTip="Delete Selected Rows">
- <FontIcon Glyph="&#xE74D;" FontSize="14" />
- </Button>
- <Button x:Name="CommitToolbarBtn" Width="32" Height="32" Padding="0"
- Background="Transparent" BorderThickness="0"
- ToolTipService.ToolTip="Commit Changes">
- <FontIcon Glyph="&#xE73E;" FontSize="14" />
- </Button>
+
<Border Width="1" Height="20" Margin="4,0"
Background="{ThemeResource DividerStrokeColorDefaultBrush}" />
+
+ <!-- Group 3: UI toggles + app settings -->
<Button x:Name="DetailsToggleBtn" Width="32" Height="32" Padding="0"
Background="Transparent" BorderThickness="0"
ToolTipService.ToolTip="Toggle Details Panel">
<FontIcon Glyph="&#xE146;" FontSize="14" />
</Button>
- <Button x:Name="AiToggleBtn" Width="32" Height="32" Padding="0"
- Background="Transparent" BorderThickness="0"
- ToolTipService.ToolTip="Toggle AI Assistant">
- <FontIcon Glyph="&#xE945;" FontSize="14" />
- </Button>
<Button x:Name="SettingsBtn" Width="32" Height="32" Padding="0"
Background="Transparent" BorderThickness="0"
ToolTipService.ToolTip="Settings (Ctrl+Shift+P)">