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++
2.6 KB
Raw Blame
#pragma once

#include "Models/ConnectionConfig.h"
#include <vector>
#include "HomePage.g.h"

namespace winrt::Gridex::implementation
{
    struct HomePage : HomePageT<HomePage>
    {
        HomePage();

        void NewConnection_Click(
            winrt::Windows::Foundation::IInspectable const& sender,
            winrt::Microsoft::UI::Xaml::RoutedEventArgs const& e);
        void NewGroup_Click(
            winrt::Windows::Foundation::IInspectable const& sender,
            winrt::Microsoft::UI::Xaml::RoutedEventArgs const& e);
        winrt::fire_and_forget ShowNewGroupDialogAsync();
        void Settings_Click(
            winrt::Windows::Foundation::IInspectable const& sender,
            winrt::Microsoft::UI::Xaml::RoutedEventArgs const& e);
        void OpenMcp_Click(
            winrt::Windows::Foundation::IInspectable const& sender,
            winrt::Microsoft::UI::Xaml::RoutedEventArgs const& e);

        // Opens the import wizard for TablePlus / DBeaver /
        // DataGrip / Navicat connections. See ImportConnections.cpp
        // for the dialog build-up; too much UI code to keep inline.
        winrt::fire_and_forget ImportConnections_Click(
            winrt::Windows::Foundation::IInspectable const& sender,
            winrt::Microsoft::UI::Xaml::RoutedEventArgs const& e);
        // Spawns a worker thread for the connect probe so the UI
        // thread stays responsive (loading overlay animates), then
        // bounces back via DispatcherQueue::TryEnqueue to navigate
        // or surface the error dialog.
        void ConnectionItem_Click(
            winrt::Windows::Foundation::IInspectable const& sender,
            winrt::Microsoft::UI::Xaml::Controls::ItemClickEventArgs const& e);
        void SearchBox_TextChanged(
            winrt::Microsoft::UI::Xaml::Controls::AutoSuggestBox const& sender,
            winrt::Microsoft::UI::Xaml::Controls::AutoSuggestBoxTextChangedEventArgs const& e);

    private:
        std::vector<DBModels::ConnectionConfig> allConnections_;
        void RefreshList(const std::wstring& searchQuery = L"");
        void UpdateEmptyState();
        void ShowNewConnectionFlow();
        void AddConnectionCard(const DBModels::ConnectionConfig& config);
        void AddGroupHeader(const std::wstring& name, int count);
        void DeleteConnection(const std::wstring& id);
        void EditConnection(const std::wstring& id);
        void TestConnectionAsync(
            const DBModels::ConnectionConfig& config, const std::wstring& password);
    };
}

namespace winrt::Gridex::factory_implementation
{
    struct HomePage : HomePageT<HomePage, implementation::HomePage>
    {
    };
}