Compare commits
44 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 89bd3ed27a | |||
| 2a22e92be4 | |||
| 5d829befca | |||
| 2eb7385516 | |||
| 543f573c7f | |||
| 463daba2cf | |||
| 9588e5189e | |||
| 30716df112 | |||
| ad8af93545 | |||
| c306a6d1a5 | |||
| 6a90605bd1 | |||
| c69089841a | |||
| ddbc30ed01 | |||
| 292e13a3e0 | |||
| 7aa6703ee0 | |||
| f90f76c097 | |||
| 134d4cf290 | |||
| 773470b30c | |||
| f55ab455be | |||
| b77ea21378 | |||
| 002298b4ff | |||
| 293627ab17 | |||
| 14219d6d49 | |||
| 37a6f479b8 | |||
| 176c51549c | |||
| 17c0fb3332 | |||
| 4a4e8a76a3 | |||
| af77b83e27 | |||
| 6b187c4142 | |||
| da56321624 | |||
| 4447e149b9 | |||
| 5850ba8836 | |||
| 81206ae1f0 | |||
| 5be200c672 | |||
| 25d8af1043 | |||
| 6abb5b6159 | |||
| 1a20ca1a9c | |||
| 38c5b88055 | |||
| fb20955bf1 | |||
| 8f76b5858d | |||
| d8cad1e59e | |||
| 6bb1d0ab9f | |||
| 35e06396e1 | |||
| 649cff7178 |
34
Makefile
@@ -1,28 +1,47 @@
|
||||
SHELL:=/bin/bash
|
||||
SOURCES=$(find . -name '*.go' -type f)
|
||||
SOURCES := $(shell find . -name '*.go' -type f)
|
||||
GIT_REV := $(shell git describe --exact-match --tags 2>/dev/null || printf "%s-%s" $$(git describe --tags --abbrev=0) $$(git rev-parse HEAD | head -c8))
|
||||
.DEFAULT_GOAL := dist
|
||||
MIQT_UIC ?= ~/go/bin/miqt-uic
|
||||
MIQT_RCC ?= ~/go/bin/miqt-rcc
|
||||
MIQT_DOCKER ?= ~/go/bin/miqt-docker
|
||||
GO_WINRES ?= ~/go/bin/go-winres
|
||||
|
||||
.PHONY: generate
|
||||
generate:
|
||||
~/go/bin/miqt-uic -InFile mainwindow.ui -OutFile mainwindow.go -Qt6
|
||||
~/go/bin/miqt-uic -InFile connectionDialog.ui -OutFile connectionDialog.go -Qt6
|
||||
~/go/bin/miqt-rcc -Input embed.qrc -Qt6
|
||||
$(MIQT_UIC) -InFile mainwindow.ui -OutFile mainwindow.go -Qt6
|
||||
$(MIQT_UIC) -InFile connectionDialog.ui -OutFile connectionDialog.go -Qt6
|
||||
$(MIQT_UIC) -InFile connectionManagerDialog.ui -OutFile connectionManagerDialog.go -Qt6
|
||||
$(MIQT_RCC) -Input embed.qrc -Qt6
|
||||
|
||||
.PHONY: designer
|
||||
designer:
|
||||
/usr/lib/qt6/bin/designer &
|
||||
|
||||
.PHONY: optimize-images
|
||||
optimize-images:
|
||||
# Strip iCCC colour chunks that libpng/Qt complain about at runtime
|
||||
for f in assets/*.png ; do convert "$$f" -strip "$$f" ; done
|
||||
optipng -quiet -o5 assets/*.png
|
||||
make generate
|
||||
|
||||
yvbolt: $(SOURCES)
|
||||
~/go/bin/miqt-docker native -minify-build
|
||||
# Target a debian-12 baseline build
|
||||
sed -i -re 's/".+"/"$(GIT_REV)"/g' version.go
|
||||
$(MIQT_DOCKER) linux64-go1.25-qt6.4-dynamic -minify-build
|
||||
git checkout -- version.go
|
||||
chmod 755 yvbolt
|
||||
upx --lzma yvbolt
|
||||
|
||||
yvbolt.exe: $(SOURCES)
|
||||
~/go/bin/miqt-docker win64-cross-go1.24-qt6.5-static -windows-build --tags=windowsqtstatic
|
||||
sed -i -re 's/".+"/"$(GIT_REV)"/g' version.go
|
||||
$(MIQT_DOCKER) win64-cross-go1.24-qt6.5-static -windows-build --tags=windowsqtstatic
|
||||
git checkout -- version.go
|
||||
$(GO_WINRES) patch --in winres.json --no-backup --product-version git-tag --file-version git-tag yvbolt.exe
|
||||
upx --lzma yvbolt.exe
|
||||
|
||||
yvbolt.apk: $(SOURCES)
|
||||
~/go/bin/miqt-docker android-armv8a-go1.23-qt6.6-dynamic -android-build
|
||||
$(MIQT_DOCKER) android-armv8a-go1.23-qt6.6-dynamic -android-build
|
||||
|
||||
yvbolt.linux64.tar.xz: yvbolt
|
||||
rm -f yvbolt.linux64.tar.xz
|
||||
@@ -37,4 +56,5 @@ dist: yvbolt.linux64.tar.xz yvbolt.win64.zip
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
git checkout -- version.go
|
||||
rm -f yvbolt.exe yvbolt yvbolt.linux64.tar.xz yvbolt.win64.zip
|
||||
|
||||
36
README.md
@@ -11,31 +11,59 @@ A graphical interface for multiple databases.
|
||||
- Run custom SQL queries
|
||||
- Select text to run partial query
|
||||
- Safe handling for non-UTF8 key and data fields
|
||||
- Connection Manager saves connections with AEAD AES256-GCM using OS keychain
|
||||
|
||||
See also [qbolt](https://code.ivysaur.me/qbolt) for more/different functionality.
|
||||
|
||||
## Supported databases
|
||||
|
||||
There are currently 10 supported databases:
|
||||
|
||||
Database |Read |Editing |Connection options |Context menu actions
|
||||
-------------|------|---------|--------------------|--------
|
||||
Badger v4 |Yes |No |Encrypted, readonly, in-memory |Backup, restore, compact
|
||||
Bolt |Yes |Yes |Readonly |Create/delete child buckets
|
||||
Debconf |Yes |No | |
|
||||
Freedesktop.org Secret Service |Yes |No | |Unlock, create new collection
|
||||
LevelDB |Yes |No |Readonly |
|
||||
LMDB |Yes |Yes |Multi-DB, readonly |Create/delete child databases
|
||||
Pebble |Yes |No |Readonly, in-memory |
|
||||
Redis |Yes |No |SSH tunnel, RESP v3 |
|
||||
SQLite |Yes |Yes |CLI driver, in-memory |Vacuum, export
|
||||
Starskey |Yes |No |Compression |
|
||||
|
||||
## License
|
||||
|
||||
The code in this project is licensed under the ISC license (see `LICENSE` file for details).
|
||||
The code in this project is licensed under the ISC license (see `LICENSE` file for details) with the following caveats:
|
||||
|
||||
This project redistributes images from the famfamfam/silk icon set under the [CC-BY 2.5 license](http://creativecommons.org/licenses/by/2.5/).
|
||||
|
||||
This project includes trademarked logo images for each supported database type.
|
||||
- This project depends on third-party libraries under additional open source licenses.
|
||||
- This project redistributes images from the [famfamfam/silk icon set](https://github.com/markjames/famfamfam-silk-icons) under the [CC-BY 2.5 license](http://creativecommons.org/licenses/by/2.5/).
|
||||
- This project includes trademarked logo images for each supported database type.
|
||||
- The Windows binary is released under LGPL-3+ owing to the static copy of Qt.
|
||||
|
||||
## Changelog
|
||||
|
||||
2025-12-02 v0.9.0
|
||||
|
||||
- LMDB: Initial support, including multi-database mode, data editing, and managing child databases
|
||||
- Starskey: Initial support
|
||||
- Freedesktop.org Secret Service: Initial support, including unlocking collections and creating child collections
|
||||
- App: Use global toolbar style
|
||||
- App: Add connection manager, encrypting credentials with AEAD AES256-GCM using OS keychain
|
||||
- App: Offer to save valid quick-connection to the connection manager
|
||||
- App: Add 'About Qt' menu option
|
||||
- App: Fixed file extension filter for database files with no extension
|
||||
- App: Fixed background colour for Properties area on different OSes
|
||||
- App: Fixed libpng warnings about greyscale image data for embedded logo images
|
||||
- App: Fixed issue with non-UTF8 child database names
|
||||
- Debconf: Improve navigation speed by splitting applications into virtual tables
|
||||
- SSH: Redesign options to pick only one of the available auth methods
|
||||
- Fixed running release binary on Debian 12
|
||||
|
||||
[⬇️ Download for Windows x86_64](https://git.ivysaur.me/code.ivysaur.me/yvbolt/releases/download/v0.9.0/yvbolt.win64.zip)
|
||||
|
||||
[⬇️ Download for Linux x86_64](https://git.ivysaur.me/code.ivysaur.me/yvbolt/releases/download/v0.9.0/yvbolt.linux64.tar.xz)
|
||||
|
||||
2025-11-23 v0.8.0
|
||||
|
||||
- Port from [liblcl](https://github.com/ying32/liblcl) to [MIQT Qt 6](https://github.com/mappu/miqt)
|
||||
|
||||
40
TODO
@@ -1,15 +1,24 @@
|
||||
- Bolt, LMDB: Editing primary key causes duplicate field
|
||||
- Parity with QBolt, merge projects together
|
||||
- Portable mode (portable.txt or portable/ dir)
|
||||
- Syntax highlighting in editor
|
||||
- Mutation
|
||||
- Badger: Support insert/update/delete
|
||||
- Pebble: Support insert/update/delete
|
||||
- Debconf: Support insert/update/delete
|
||||
- Redis: Support insert/update/delete
|
||||
- LevelDB: Support insert/update/delete
|
||||
- Starskey: Support insert/update/delete
|
||||
- SecretService: Support insert/update/delete
|
||||
- Binary data viewer
|
||||
- Detect jpg/png and show as image
|
||||
- Prevent editing invalid-utf8 fields as text (binary data editor?)
|
||||
- More DB types
|
||||
- MySQL
|
||||
- MySQL (& MariaDB/TiDB)
|
||||
- Postgres
|
||||
- CLI using psql
|
||||
- MongoDB
|
||||
- Lungo: Mini embeddable Mongo - https://github.com/256dpi/lungo
|
||||
- MSSQL (recursive navigation for instances)
|
||||
- Other K/V stores from https://github.com/smallnest/kvbench
|
||||
- Windows registry
|
||||
@@ -20,16 +29,33 @@
|
||||
- Dolt
|
||||
- Memcache
|
||||
- Listing all keys is not well supported, needs hacks
|
||||
- DBus SecretStore
|
||||
- Starskey https://github.com/starskey-io/starskey
|
||||
- Chai (built on Pebble) - https://github.com/chaisql/chai
|
||||
- CloverDB (built on Bolt/Badger) - https://github.com/ostafen/clover
|
||||
- APCu - need some sort of hook into the storage engine
|
||||
- VoidDB - https://github.com/voidDB/voidDB
|
||||
- UnisonDB - https://github.com/ankur-anand/unisondb
|
||||
- Etcd
|
||||
- v2: hierarchal
|
||||
- v3: flat key namespace
|
||||
- Tokyo Cabinet, Kyoto Cabinet, Tkrzw
|
||||
- https://github.com/TerraTech/go-tokyocabinet needs pkg-config tokyocabinet
|
||||
- https://github.com/estraier/tkrzw-go needs pkg-config tkrzw
|
||||
- CSV file
|
||||
- Allow querying with sqlite or duckDB?
|
||||
- Parquet file
|
||||
- Allow querying with duckDB?
|
||||
- IRC client
|
||||
- SSDB (Redis-compatible)
|
||||
- Time-series DBs
|
||||
- Prometheus
|
||||
- VictoriaMetrics
|
||||
- FrostDB https://github.com/polarsignals/frostdb
|
||||
- https://dbdb.io/browse?programming=go-lang&q=
|
||||
- Connection dialog
|
||||
- Saved connections w/ storage encryption
|
||||
- SSH over Cockpit
|
||||
- SQLite CLI driver:
|
||||
- Context support
|
||||
- Write support
|
||||
- Attach to SSH tunnel
|
||||
- Configure binary path
|
||||
- https://ricardoanderegg.com/posts/sqlite-remote-explorer-gui/
|
||||
@@ -37,8 +63,8 @@
|
||||
- Badger:
|
||||
- v1/v2/v3 support
|
||||
- option to use namespace separators for virtual buckets
|
||||
- Debconf: separate groups by first slash in name
|
||||
- SQLite: drop table doesn't autorefresh nav since callback is late
|
||||
- LMDB: dupsort mode (duplicate keys / entries-per-key)
|
||||
- Build
|
||||
- Win32 icon resource
|
||||
- Performance
|
||||
@@ -50,4 +76,6 @@
|
||||
- `CREATE TABLE foo (id integer primary key, aaa text not null, bbb text not null);`
|
||||
- Ability to convert database types
|
||||
- Export all data from grid
|
||||
- Export all data from all buckets within a DB
|
||||
- Export all data from all buckets within a DB
|
||||
- Reconnect
|
||||
- Connecting to multiple DBs from connection manager: if one has an error, the error popup from the others is lost
|
||||
|
||||
BIN
assets/add.png
|
Before Width: | Height: | Size: 733 B After Width: | Height: | Size: 714 B |
|
Before Width: | Height: | Size: 685 B After Width: | Height: | Size: 707 B |
|
Before Width: | Height: | Size: 541 B After Width: | Height: | Size: 637 B |
BIN
assets/connect.png
Normal file
|
After Width: | Height: | Size: 754 B |
|
Before Width: | Height: | Size: 390 B After Width: | Height: | Size: 337 B |
|
Before Width: | Height: | Size: 658 B After Width: | Height: | Size: 685 B |
|
Before Width: | Height: | Size: 659 B After Width: | Height: | Size: 715 B |
BIN
assets/database_key.png
Normal file
|
After Width: | Height: | Size: 803 B |
|
Before Width: | Height: | Size: 775 B After Width: | Height: | Size: 819 B |
|
Before Width: | Height: | Size: 755 B After Width: | Height: | Size: 812 B |
|
Before Width: | Height: | Size: 715 B After Width: | Height: | Size: 692 B |
BIN
assets/disconnect.png
Normal file
|
After Width: | Height: | Size: 793 B |
BIN
assets/help.png
Normal file
|
After Width: | Height: | Size: 755 B |
|
Before Width: | Height: | Size: 634 B After Width: | Height: | Size: 644 B |
|
Before Width: | Height: | Size: 739 B After Width: | Height: | Size: 770 B |
|
Before Width: | Height: | Size: 444 B After Width: | Height: | Size: 391 B |
|
Before Width: | Height: | Size: 589 B After Width: | Height: | Size: 540 B |
|
Before Width: | Height: | Size: 603 B After Width: | Height: | Size: 558 B |
|
Before Width: | Height: | Size: 666 B After Width: | Height: | Size: 615 B |
|
Before Width: | Height: | Size: 395 B After Width: | Height: | Size: 348 B |
BIN
assets/table.png
|
Before Width: | Height: | Size: 566 B After Width: | Height: | Size: 551 B |
|
Before Width: | Height: | Size: 663 B After Width: | Height: | Size: 629 B |
|
Before Width: | Height: | Size: 660 B After Width: | Height: | Size: 645 B |
|
Before Width: | Height: | Size: 723 B After Width: | Height: | Size: 744 B |
|
Before Width: | Height: | Size: 752 B After Width: | Height: | Size: 353 B |
|
Before Width: | Height: | Size: 831 B After Width: | Height: | Size: 622 B |
|
Before Width: | Height: | Size: 948 B After Width: | Height: | Size: 763 B |
BIN
assets/vendor_freedesktop.png
Normal file
|
After Width: | Height: | Size: 821 B |
|
Before Width: | Height: | Size: 704 B After Width: | Height: | Size: 303 B |
|
Before Width: | Height: | Size: 597 B After Width: | Height: | Size: 624 B |
BIN
assets/vendor_lmdb.png
Normal file
|
After Width: | Height: | Size: 738 B |
|
Before Width: | Height: | Size: 824 B After Width: | Height: | Size: 545 B |
BIN
assets/vendor_qt.png
Normal file
|
After Width: | Height: | Size: 384 B |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 825 B |
|
Before Width: | Height: | Size: 919 B After Width: | Height: | Size: 665 B |
BIN
assets/vendor_starskey.png
Normal file
|
After Width: | Height: | Size: 203 B |
403
config.go
@@ -2,7 +2,11 @@ package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"reflect"
|
||||
"time"
|
||||
|
||||
"github.com/mappu/autoconfig"
|
||||
qt "github.com/mappu/miqt/qt6"
|
||||
@@ -12,52 +16,98 @@ type DBConnector interface {
|
||||
Connect(context.Context) (loadedDatabase, string, error)
|
||||
}
|
||||
|
||||
type registeredDatabase struct {
|
||||
label string
|
||||
iconPath string
|
||||
conn DBConnector
|
||||
type ConnectionConfig struct {
|
||||
Type autoconfig.OneOf
|
||||
|
||||
Badger *badgerConnection `ylabel:"BadgerDB v4" yicon:":/assets/vendor_dgraph.png" json:",omitempty"`
|
||||
Bolt *boltConfig `yicon:":/assets/vendor_github.png" json:",omitempty"`
|
||||
Debconf *debconfConnection `yicon:":/assets/vendor_debian.png" json:",omitempty"`
|
||||
SecretService *secretServiceConnection `ylabel:"Freedesktop.org Secret Service" yicon:":/assets/vendor_freedesktop.png" json:",omitempty"`
|
||||
LevelDB *leveldbConnection `ylabel:"LevelDB" yicon:":/assets/vendor_leveldb.png" json:",omitempty"`
|
||||
LMDB *lmdbConnection `yicon:":/assets/vendor_lmdb.png" json:",omitempty"`
|
||||
Pebble *pebbleConnection `yicon:":/assets/vendor_cockroach.png" json:",omitempty"`
|
||||
Redis *redisConnectionOptions `yicon:":/assets/vendor_redis.png" json:",omitempty"`
|
||||
SQLite *sqliteConnection `ylabel:"SQLite" yicon:":/assets/vendor_sqlite.png" json:",omitempty"`
|
||||
Starskey *starskeyConnection `yicon:":/assets/vendor_starskey.png" json:",omitempty"`
|
||||
}
|
||||
|
||||
var (
|
||||
registeredDatabases []registeredDatabase
|
||||
)
|
||||
|
||||
func registerDatabase(conn DBConnector, label, iconPath string) {
|
||||
registeredDatabases = append(registeredDatabases, registeredDatabase{
|
||||
label: label,
|
||||
iconPath: iconPath,
|
||||
conn: conn,
|
||||
})
|
||||
func NewConnectionConfig() *ConnectionConfig {
|
||||
return &ConnectionConfig{
|
||||
Type: "Bolt", // favouritism
|
||||
}
|
||||
}
|
||||
|
||||
// Icon gets the Qt string name for the icon of this database by parsing the
|
||||
// 'yicon' struct tag with reflection.
|
||||
// If there is no selection or if it's misconfigured, falls back to a generic
|
||||
// database icon.
|
||||
func (cc *ConnectionConfig) Icon() string {
|
||||
taginfo, ok := reflect.ValueOf(cc).Type().Elem().FieldByName(string(cc.Type))
|
||||
if !ok {
|
||||
return ":/assets/database.png"
|
||||
}
|
||||
|
||||
yicon, ok := taginfo.Tag.Lookup("yicon")
|
||||
if !ok {
|
||||
return ":/assets/database.png"
|
||||
}
|
||||
|
||||
return yicon
|
||||
}
|
||||
|
||||
func (cc *ConnectionConfig) String() string {
|
||||
if selection, err := cc.selection(); err == nil {
|
||||
if stringer, ok := selection.(fmt.Stringer); ok {
|
||||
return stringer.String()
|
||||
}
|
||||
}
|
||||
|
||||
if string(cc.Type) == "" {
|
||||
return "Not configured"
|
||||
}
|
||||
|
||||
return string(cc.Type)
|
||||
}
|
||||
|
||||
func (cc *ConnectionConfig) selection() (DBConnector, error) {
|
||||
selection := reflect.ValueOf(cc).Elem().FieldByName(string(cc.Type))
|
||||
if !selection.IsValid() {
|
||||
return nil, fmt.Errorf("Invalid database engine %q", cc.Type)
|
||||
}
|
||||
|
||||
con, ok := selection.Interface().(DBConnector)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("Can't connect to database on type %q (weird)", cc.Type)
|
||||
}
|
||||
|
||||
return con, nil
|
||||
}
|
||||
|
||||
func (cc *ConnectionConfig) Connect(ctx context.Context) (loadedDatabase, string, error) {
|
||||
dbc, err := cc.selection()
|
||||
if err != nil {
|
||||
return nil, "", fmt.Errorf("Invalid database engine %q", cc.Type)
|
||||
}
|
||||
|
||||
return dbc.Connect(ctx)
|
||||
}
|
||||
|
||||
var _ DBConnector = &ConnectionConfig{}
|
||||
|
||||
func (f *App) OnMnuConnectClick() {
|
||||
|
||||
// autoconfig.OpenDialog() does not give us a "yes/no" result back from the
|
||||
// dialog, so we still have to custom construct the dialog and use the
|
||||
// formlayout option instead
|
||||
|
||||
dlg := NewConnectDialogUi()
|
||||
dlg.ConnectDialog.SetParent2(f.ui.MainWindow.QWidget, qt.Dialog)
|
||||
dlg.ConnectDialog.SetModal(true)
|
||||
dlg.ConnectDialog.SetAttribute(qt.WA_DeleteOnClose)
|
||||
|
||||
var resultingConfigs []DBConnector
|
||||
var getters []func()
|
||||
config := NewConnectionConfig()
|
||||
|
||||
for _, db := range registeredDatabases {
|
||||
dlg.databaseEngine.AddItem2(qt.NewQIcon4(db.iconPath), db.label)
|
||||
|
||||
frame := qt.NewQWidget2()
|
||||
layout := qt.NewQFormLayout(frame)
|
||||
|
||||
// Deep-copy the provided default object
|
||||
// useConn := deep_copy(db.conn)
|
||||
useConn := db.conn // FIXME can't deep copy?!
|
||||
|
||||
resultingConfigs = append(resultingConfigs, useConn)
|
||||
getters = append(getters, autoconfig.MakeConfigArea(useConn, layout))
|
||||
|
||||
dlg.stackedWidget.AddWidget(frame)
|
||||
}
|
||||
|
||||
dlg.databaseEngine.OnCurrentIndexChanged(func(index int) {
|
||||
dlg.stackedWidget.SetCurrentIndex(index)
|
||||
})
|
||||
saver := autoconfig.MakeConfigArea(config, dlg.formLayout)
|
||||
|
||||
dlg.ConnectDialog.OnAccept(func(super func()) {
|
||||
// Validate connection before closing
|
||||
@@ -66,18 +116,14 @@ func (f *App) OnMnuConnectClick() {
|
||||
defer dlg.buttonBox.SetEnabled(true)
|
||||
dlg.buttonBox.Repaint()
|
||||
|
||||
// Selected index
|
||||
idx := dlg.databaseEngine.CurrentIndex()
|
||||
|
||||
// Save changes from UI into struct
|
||||
getters[idx]()
|
||||
config := resultingConfigs[idx]
|
||||
saver()
|
||||
|
||||
// Connect -> get ld
|
||||
ctx := context.Background() // TODO do in background thread?
|
||||
ld, displayName, err := config.Connect(ctx)
|
||||
if err != nil {
|
||||
_ = qt.QMessageBox_Critical(dlg.ConnectDialog.QWidget, APPNAME, fmt.Sprintf("Connecting to %s database: %s", registeredDatabases[idx].label, err.Error()))
|
||||
_ = qt.QMessageBox_Critical(dlg.ConnectDialog.QWidget, APPNAME, fmt.Sprintf("Connecting to %s database: %s", config.Type, err.Error()))
|
||||
// Prevent the dialog from closing: do not call super()
|
||||
return
|
||||
}
|
||||
@@ -85,6 +131,12 @@ func (f *App) OnMnuConnectClick() {
|
||||
// Add ld to mainwindow
|
||||
f.addTopLevelDatabaseConnection(ld, displayName)
|
||||
|
||||
// Connection OK
|
||||
// Offer to save into connection-manager
|
||||
if res := qt.QMessageBox_Question2(dlg.ConnectDialog.QWidget, APPNAME, "Connection successful. Save the details into Connection Manager?", qt.QMessageBox__Save, qt.QMessageBox__Ignore); res == int(qt.QMessageBox__Save) {
|
||||
f.TrySaveIntoConnectionManager(config)
|
||||
}
|
||||
|
||||
// Default accept behaviour is: setResult(Accepted), emits onFinished; && Hide()
|
||||
super()
|
||||
})
|
||||
@@ -92,3 +144,272 @@ func (f *App) OnMnuConnectClick() {
|
||||
dlg.ConnectDialog.Open() // Modal, unlike .Show()
|
||||
|
||||
}
|
||||
|
||||
type ConnMgrLoadError struct {
|
||||
e error
|
||||
}
|
||||
|
||||
func (c ConnMgrLoadError) Error() string {
|
||||
return fmt.Sprintf("Failed to load saved connections: %s", c.e)
|
||||
}
|
||||
|
||||
func (c ConnMgrLoadError) Unwrap() error {
|
||||
return c.e
|
||||
}
|
||||
|
||||
type ConnMgrSaveError struct {
|
||||
e error
|
||||
}
|
||||
|
||||
func (c ConnMgrSaveError) Error() string {
|
||||
return fmt.Sprintf("Failed to save connections: %s", c.e)
|
||||
}
|
||||
|
||||
func (c ConnMgrSaveError) Unwrap() error {
|
||||
return c.e
|
||||
}
|
||||
|
||||
func (f *App) TrySaveIntoConnectionManager(cc *ConnectionConfig) {
|
||||
data, err := f.getConnectionManagerContents()
|
||||
if err != nil {
|
||||
qt.QMessageBox_Warning(f.ui.MainWindow.QWidget, APPNAME, ConnMgrLoadError{err}.Error())
|
||||
}
|
||||
|
||||
data.Entries = append(data.Entries, SavedConfigEntry{
|
||||
Description: cc.String(),
|
||||
Connection: *cc,
|
||||
})
|
||||
|
||||
err = f.saveConnectionManagerContents(data)
|
||||
if err != nil {
|
||||
qt.QMessageBox_Warning(f.ui.MainWindow.QWidget, APPNAME, ConnMgrSaveError{err}.Error())
|
||||
}
|
||||
}
|
||||
|
||||
func (f *App) OnMnuConnectionManagerClick() {
|
||||
|
||||
data, err := f.getConnectionManagerContents()
|
||||
if err != nil {
|
||||
qt.QMessageBox_Warning(f.ui.MainWindow.QWidget, APPNAME, ConnMgrSaveError{err}.Error())
|
||||
return
|
||||
}
|
||||
|
||||
dlg := NewconnectionManagerDialogUi()
|
||||
dlg.connectionManagerDialog.SetParent2(f.ui.MainWindow.QWidget, qt.Dialog)
|
||||
dlg.connectionManagerDialog.SetModal(true)
|
||||
dlg.connectionManagerDialog.SetAttribute(qt.WA_DeleteOnClose)
|
||||
dlg.treeWidget.SetRootIsDecorated(false)
|
||||
dlg.treeWidget.SetSelectionMode(qt.QAbstractItemView__ExtendedSelection)
|
||||
|
||||
addEntryFor := func(entry SavedConfigEntry) {
|
||||
itm := qt.NewQTreeWidgetItem()
|
||||
itm.SetText(0, entry.Description)
|
||||
itm.SetIcon(0, qt.NewQIcon4(entry.Connection.Icon()))
|
||||
|
||||
dlg.treeWidget.AddTopLevelItem(itm)
|
||||
}
|
||||
|
||||
refreshEntryFor := func(idx *qt.QModelIndex, entry SavedConfigEntry) {
|
||||
itm := dlg.treeWidget.ItemFromIndex(idx)
|
||||
itm.SetText(0, entry.Description) // Update label
|
||||
itm.SetIcon(0, qt.NewQIcon4(entry.Connection.Icon())) // Update icon
|
||||
}
|
||||
|
||||
// Populate entries
|
||||
for _, entry := range data.Entries {
|
||||
addEntryFor(entry)
|
||||
}
|
||||
|
||||
refreshButtonState := func() {
|
||||
ct := len(dlg.treeWidget.SelectedItems())
|
||||
|
||||
dlg.connectBtn.SetEnabled(ct > 0)
|
||||
dlg.connDelete.SetEnabled(ct > 0)
|
||||
dlg.connEdit.SetEnabled(ct == 1)
|
||||
}
|
||||
|
||||
connectToItem := func(itm *qt.QTreeWidgetItem) bool {
|
||||
ctx := context.Background() // TODO do in background thread?
|
||||
|
||||
dlg.connectBtn.SetEnabled(false)
|
||||
dlg.treeWidget.SetEnabled(false)
|
||||
defer func() {
|
||||
dlg.connectBtn.SetEnabled(true)
|
||||
dlg.treeWidget.SetEnabled(true) // FIXME block the other buttons too!
|
||||
}()
|
||||
|
||||
entry := data.Entries[dlg.treeWidget.IndexFromItem(itm).Row()]
|
||||
|
||||
ld, _, err := entry.Connection.Connect(ctx)
|
||||
if err != nil {
|
||||
_ = qt.QMessageBox_Critical(dlg.connectionManagerDialog.QWidget, APPNAME, fmt.Sprintf("Connecting to %s database: %s", entry.Connection.Type, err.Error()))
|
||||
return false
|
||||
}
|
||||
|
||||
// Add ld to mainwindow
|
||||
// Don't use the displayName from the Connect() function - use the saved
|
||||
// displayname instead
|
||||
f.addTopLevelDatabaseConnection(ld, entry.Description)
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
dlg.treeWidget.OnItemDoubleClicked(func(itm *qt.QTreeWidgetItem, _ int) {
|
||||
// connect to specific item
|
||||
if connectToItem(itm) {
|
||||
dlg.connectionManagerDialog.Accept()
|
||||
}
|
||||
})
|
||||
|
||||
dlg.connectBtn.OnClicked(func() {
|
||||
// Based on selectedItems, not currentItem
|
||||
itms := dlg.treeWidget.SelectedItems()
|
||||
var ok bool = true
|
||||
for _, itm := range itms {
|
||||
ok = ok && connectToItem(itm) // connect to selected
|
||||
}
|
||||
|
||||
if ok {
|
||||
dlg.connectionManagerDialog.Accept()
|
||||
}
|
||||
})
|
||||
|
||||
dlg.connDelete.SetEnabled(false)
|
||||
dlg.connEdit.SetEnabled(false)
|
||||
dlg.treeWidget.OnItemSelectionChanged(refreshButtonState)
|
||||
|
||||
dlg.connDelete.OnClicked(func() {
|
||||
|
||||
itms := dlg.treeWidget.SelectedItems()
|
||||
for _, itm := range itms {
|
||||
|
||||
idx := dlg.treeWidget.IndexFromItem(itm).Row() // n.b. will dynamically change as the item is removed
|
||||
itm.Delete()
|
||||
|
||||
data.Entries = slice_remove_index(data.Entries, idx)
|
||||
|
||||
}
|
||||
|
||||
// All changes made in both ui + data model
|
||||
// Save data model changes
|
||||
err := f.saveConnectionManagerContents(data)
|
||||
if err != nil {
|
||||
qt.QMessageBox_Warning(f.ui.MainWindow.QWidget, APPNAME, ConnMgrSaveError{err}.Error())
|
||||
return
|
||||
}
|
||||
})
|
||||
|
||||
dlg.connEdit.OnClicked(func() {
|
||||
// Edit is based on selectedIndex, not currentIndex
|
||||
items := dlg.treeWidget.SelectedItems()
|
||||
if len(items) != 1 {
|
||||
return
|
||||
}
|
||||
|
||||
idx := dlg.treeWidget.IndexFromItem(items[0])
|
||||
|
||||
row := idx.Row()
|
||||
props := data.Entries[row]
|
||||
|
||||
autoconfig.OpenDialog(&props, dlg.connectionManagerDialog.QWidget, "Editing connection", func() {
|
||||
data.Entries[row] = props
|
||||
refreshEntryFor(idx, props)
|
||||
|
||||
err := f.saveConnectionManagerContents(data)
|
||||
if err != nil {
|
||||
qt.QMessageBox_Warning(f.ui.MainWindow.QWidget, APPNAME, ConnMgrSaveError{err}.Error())
|
||||
return
|
||||
}
|
||||
|
||||
})
|
||||
})
|
||||
|
||||
dlg.connAdd.OnClicked(func() {
|
||||
|
||||
obj := SavedConfigEntry{
|
||||
Description: "New connection (" + time.Now().Format(time.DateTime) + ")",
|
||||
}
|
||||
vv := NewConnectionConfig()
|
||||
obj.Connection = *vv
|
||||
|
||||
autoconfig.OpenDialog(&obj, dlg.connectionManagerDialog.QWidget, "New connection", func() {
|
||||
|
||||
data.Entries = append(data.Entries, obj)
|
||||
addEntryFor(obj)
|
||||
|
||||
err := f.saveConnectionManagerContents(data)
|
||||
if err != nil {
|
||||
qt.QMessageBox_Warning(f.ui.MainWindow.QWidget, APPNAME, ConnMgrSaveError{err}.Error())
|
||||
return
|
||||
}
|
||||
|
||||
})
|
||||
})
|
||||
|
||||
miniMenu := qt.NewQMenu(dlg.toolsBtn.QWidget)
|
||||
exportAction := miniMenu.AddActionWithText("Export connections...")
|
||||
importAction := miniMenu.AddActionWithText("Import connections...")
|
||||
dlg.toolsBtn.SetMenu(miniMenu)
|
||||
dlg.toolsBtn.SetPopupMode(qt.QToolButton__InstantPopup)
|
||||
|
||||
exportAction.OnTriggered(func() {
|
||||
saveAs := qt.QFileDialog_GetSaveFileName4(dlg.toolsBtn.QWidget, "Export connections...", "", "JSON files (*.json);;All files (*)")
|
||||
if saveAs == "" {
|
||||
return // cancelled
|
||||
}
|
||||
|
||||
jbytes, err := json.MarshalIndent(data, "", " ")
|
||||
if err != nil {
|
||||
qt.QMessageBox_Warning(dlg.toolsBtn.QWidget, APPNAME, ConnMgrSaveError{err}.Error())
|
||||
return
|
||||
}
|
||||
|
||||
err = os.WriteFile(saveAs, jbytes, 0600)
|
||||
if err != nil {
|
||||
qt.QMessageBox_Warning(dlg.toolsBtn.QWidget, APPNAME, ConnMgrSaveError{err}.Error())
|
||||
return
|
||||
}
|
||||
|
||||
// OK
|
||||
qt.QMessageBox_Information(dlg.toolsBtn.QWidget, APPNAME, "The connections have been exported successfully.")
|
||||
})
|
||||
|
||||
importAction.OnTriggered(func() {
|
||||
loadFile := qt.QFileDialog_GetOpenFileName4(dlg.toolsBtn.QWidget, "Import connections...", "", "JSON files (*.json);;All files (*)")
|
||||
if loadFile == "" {
|
||||
return // cancelled
|
||||
}
|
||||
|
||||
jbytes, err := os.ReadFile(loadFile)
|
||||
if err != nil {
|
||||
qt.QMessageBox_Warning(dlg.toolsBtn.QWidget, APPNAME, ConnMgrLoadError{err}.Error())
|
||||
return
|
||||
}
|
||||
|
||||
var importData SavedConfig
|
||||
err = json.Unmarshal(jbytes, &importData)
|
||||
if err != nil {
|
||||
qt.QMessageBox_Warning(dlg.toolsBtn.QWidget, APPNAME, ConnMgrLoadError{err}.Error())
|
||||
return
|
||||
}
|
||||
|
||||
// Add to UI
|
||||
for _, newEntry := range importData.Entries {
|
||||
addEntryFor(newEntry)
|
||||
}
|
||||
|
||||
// Add to data model
|
||||
data.Entries = append(data.Entries, importData.Entries...)
|
||||
|
||||
// Save data model to disk
|
||||
err = f.saveConnectionManagerContents(data)
|
||||
if err != nil {
|
||||
qt.QMessageBox_Warning(f.ui.MainWindow.QWidget, APPNAME, ConnMgrSaveError{err}.Error())
|
||||
return
|
||||
}
|
||||
})
|
||||
|
||||
refreshButtonState()
|
||||
|
||||
dlg.connectionManagerDialog.Show()
|
||||
}
|
||||
|
||||
200
configSave.go
Normal file
@@ -0,0 +1,200 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"crypto/aes"
|
||||
"crypto/cipher"
|
||||
"crypto/rand"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/zalando/go-keyring"
|
||||
)
|
||||
|
||||
type SavedConfigEntry struct {
|
||||
Description string
|
||||
Connection ConnectionConfig
|
||||
}
|
||||
|
||||
type SavedConfig struct {
|
||||
UserAgent string // APPNAME/{ver}
|
||||
Entries []SavedConfigEntry
|
||||
}
|
||||
|
||||
const (
|
||||
saveSettingsFilename = `settings.dat`
|
||||
keychainUserName = `settings-encryption-key`
|
||||
)
|
||||
|
||||
func (f *App) getConnectionManagerContents() (*SavedConfig, error) {
|
||||
cfgd, err := os.UserConfigDir()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
_ = os.MkdirAll(filepath.Join(cfgd, APPNAME), 0700)
|
||||
|
||||
ciphertext, err := os.ReadFile(filepath.Join(cfgd, APPNAME, saveSettingsFilename))
|
||||
if err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
// No file exists. Use blank
|
||||
return &SavedConfig{
|
||||
UserAgent: APPNAME,
|
||||
}, nil
|
||||
}
|
||||
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Get decryption key from OS keychain
|
||||
// Since we successfully loaded the file on disk, the keychain entry must exist
|
||||
|
||||
details, err := keyring.Get(APPNAME, keychainUserName)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Decrypt
|
||||
// The encryption key is random 256 bytes, no need for a KDF
|
||||
encryptionKeyBytes, err := hex.DecodeString(details)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
cc, err := aes.NewCipher(encryptionKeyBytes)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
cw, err := cipher.NewGCMWithRandomNonce(cc)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
plaintext, err := cw.Open(ciphertext[:0], nil, ciphertext, nil) // @ref https://pkg.go.dev/crypto/cipher#AEAD
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var ret SavedConfig
|
||||
err = json.Unmarshal(plaintext, &ret)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Success
|
||||
return &ret, nil
|
||||
}
|
||||
|
||||
func (f *App) saveConnectionManagerContents(sc *SavedConfig) error {
|
||||
cfgd, err := os.UserConfigDir()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// If the file exists already, we must have an existing encryption key
|
||||
var exists bool
|
||||
savePath := filepath.Join(cfgd, APPNAME, saveSettingsFilename)
|
||||
if _, err := os.Stat(savePath); err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
|
||||
_ = os.MkdirAll(filepath.Join(cfgd, APPNAME), 0700)
|
||||
exists = false
|
||||
} else {
|
||||
return err // some other real error
|
||||
}
|
||||
} else {
|
||||
exists = true
|
||||
}
|
||||
|
||||
details, err := keyring.Get(APPNAME, keychainUserName)
|
||||
if err != nil {
|
||||
if errors.Is(err, keyring.ErrNotFound) {
|
||||
// Does not exist in keyring
|
||||
// That is OK if there is no saved file yet / we can generate a random
|
||||
// key. But if the file does already exist, this is fatal
|
||||
if exists {
|
||||
// File exists on disk but there is no encryption key to parse it
|
||||
// Fatal
|
||||
return fmt.Errorf(
|
||||
"There is already a saved file on disk (%q), but there is no matching encryption key in the system keychain provider. Has your keychain been destroyed? To confirm, please delete the saved settings file.",
|
||||
savePath,
|
||||
)
|
||||
} else {
|
||||
// Generate new
|
||||
// 256 bits (32 bytes) of cryto-random data, and then hex encode
|
||||
randBuff := make([]byte, 32)
|
||||
n, err := rand.Read(randBuff)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if n != len(randBuff) {
|
||||
return io.ErrShortWrite
|
||||
}
|
||||
|
||||
details = hex.EncodeToString(randBuff)
|
||||
err = keyring.Set(APPNAME, keychainUserName, details)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Safe
|
||||
}
|
||||
} else {
|
||||
// Real keychain error
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// Force update the saved version
|
||||
sc.UserAgent = APPNAME // TODO get app's own version
|
||||
|
||||
// When saving, the version that gets saved always has descriptions sorted
|
||||
// alphabetically.
|
||||
// But, you won't know this until you reload the contents.
|
||||
sort.Slice(sc.Entries, func(i, j int) bool {
|
||||
// FIXME there is probably a slightly more efficient way of doing this
|
||||
return strings.ToLower(sc.Entries[i].Description) < strings.ToLower(sc.Entries[j].Description)
|
||||
})
|
||||
|
||||
// Marshal
|
||||
|
||||
plaintext, err := json.Marshal(sc)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Encrypt
|
||||
|
||||
encryptionKeyBytes, err := hex.DecodeString(details)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
cc, err := aes.NewCipher(encryptionKeyBytes)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
cw, err := cipher.NewGCMWithRandomNonce(cc)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
ciphertext := cw.Seal(plaintext[:0], nil, plaintext, nil)
|
||||
|
||||
// Save to disk
|
||||
err = os.WriteFile(savePath, ciphertext, 0600)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Save OK
|
||||
return nil
|
||||
}
|
||||
@@ -10,11 +10,11 @@ import (
|
||||
)
|
||||
|
||||
type ConnectDialogUi struct {
|
||||
ConnectDialog *qt.QDialog
|
||||
gridLayout *qt.QGridLayout
|
||||
databaseEngine *qt.QComboBox
|
||||
stackedWidget *qt.QStackedWidget
|
||||
buttonBox *qt.QDialogButtonBox
|
||||
ConnectDialog *qt.QDialog
|
||||
gridLayout *qt.QGridLayout
|
||||
buttonBox *qt.QDialogButtonBox
|
||||
formWidget *qt.QWidget
|
||||
formLayout *qt.QFormLayout
|
||||
}
|
||||
|
||||
// NewConnectDialogUi creates all Qt widget classes for ConnectDialog.
|
||||
@@ -34,18 +34,6 @@ func NewConnectDialogUi() *ConnectDialogUi {
|
||||
gridLayout__objectName.Delete() // setter copied value
|
||||
ui.gridLayout.SetContentsMargins(11, 11, 11, 11)
|
||||
ui.gridLayout.SetSpacing(6)
|
||||
ui.databaseEngine = qt.NewQComboBox(ui.ConnectDialog.QWidget)
|
||||
databaseEngine__objectName := qt.NewQAnyStringView3("databaseEngine")
|
||||
ui.databaseEngine.SetObjectName(*databaseEngine__objectName)
|
||||
databaseEngine__objectName.Delete() // setter copied value
|
||||
|
||||
ui.gridLayout.AddWidget2(ui.databaseEngine.QWidget, 0, 1)
|
||||
ui.stackedWidget = qt.NewQStackedWidget(ui.ConnectDialog.QWidget)
|
||||
stackedWidget__objectName := qt.NewQAnyStringView3("stackedWidget")
|
||||
ui.stackedWidget.SetObjectName(*stackedWidget__objectName)
|
||||
stackedWidget__objectName.Delete() // setter copied value
|
||||
|
||||
ui.gridLayout.AddWidget2(ui.stackedWidget.QWidget, 1, 1)
|
||||
ui.buttonBox = qt.NewQDialogButtonBox(ui.ConnectDialog.QWidget)
|
||||
buttonBox__objectName := qt.NewQAnyStringView3("buttonBox")
|
||||
ui.buttonBox.SetObjectName(*buttonBox__objectName)
|
||||
@@ -53,7 +41,19 @@ func NewConnectDialogUi() *ConnectDialogUi {
|
||||
ui.buttonBox.SetOrientation(qt.Horizontal)
|
||||
ui.buttonBox.SetStandardButtons(qt.QDialogButtonBox__Cancel | qt.QDialogButtonBox__Ok)
|
||||
|
||||
ui.gridLayout.AddWidget3(ui.buttonBox.QWidget, 2, 0, 1, 2)
|
||||
ui.gridLayout.AddWidget2(ui.buttonBox.QWidget, 2, 0)
|
||||
ui.formWidget = qt.NewQWidget(ui.ConnectDialog.QWidget)
|
||||
formWidget__objectName := qt.NewQAnyStringView3("formWidget")
|
||||
ui.formWidget.SetObjectName(*formWidget__objectName)
|
||||
formWidget__objectName.Delete() // setter copied value
|
||||
ui.formLayout = qt.NewQFormLayout(ui.formWidget)
|
||||
formLayout__objectName := qt.NewQAnyStringView3("formLayout")
|
||||
ui.formLayout.SetObjectName(*formLayout__objectName)
|
||||
formLayout__objectName.Delete() // setter copied value
|
||||
ui.formLayout.SetContentsMargins(0, 0, 0, 11)
|
||||
ui.formLayout.SetSpacing(6)
|
||||
|
||||
ui.gridLayout.AddWidget2(ui.formWidget, 1, 0)
|
||||
|
||||
ui.buttonBox.OnAccepted(ui.ConnectDialog.Accept)
|
||||
ui.buttonBox.OnRejected(ui.ConnectDialog.Reject)
|
||||
|
||||
@@ -18,13 +18,7 @@
|
||||
<normaloff>:/assets/database_add.png</normaloff>:/assets/database_add.png</iconset>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="databaseEngine"/>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QStackedWidget" name="stackedWidget"/>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<item row="2" column="0">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
@@ -34,6 +28,21 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QWidget" name="formWidget" native="true">
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
|
||||
136
connectionManagerDialog.go
Normal file
@@ -0,0 +1,136 @@
|
||||
// Generated by miqt-uic. To update this file, edit the .ui file in
|
||||
// Qt Designer, and then run 'go generate'.
|
||||
//
|
||||
//go:generate miqt-uic -InFile connectionManagerDialog.ui -OutFile connectionManagerDialog.go -Qt6
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
qt "github.com/mappu/miqt/qt6"
|
||||
)
|
||||
|
||||
type connectionManagerDialogUi struct {
|
||||
connectionManagerDialog *qt.QDialog
|
||||
verticalLayout_2 *qt.QVBoxLayout
|
||||
horizontalLayout *qt.QHBoxLayout
|
||||
treeWidget *qt.QTreeWidget
|
||||
verticalLayout *qt.QVBoxLayout
|
||||
connAdd *qt.QToolButton
|
||||
connEdit *qt.QToolButton
|
||||
connDelete *qt.QToolButton
|
||||
verticalSpacer *qt.QSpacerItem
|
||||
horizontalLayout_2 *qt.QHBoxLayout
|
||||
toolsBtn *qt.QToolButton
|
||||
horizontalSpacer *qt.QSpacerItem
|
||||
connectBtn *qt.QPushButton
|
||||
}
|
||||
|
||||
// NewconnectionManagerDialogUi creates all Qt widget classes for connectionManagerDialog.
|
||||
func NewconnectionManagerDialogUi() *connectionManagerDialogUi {
|
||||
ui := &connectionManagerDialogUi{}
|
||||
ui.connectionManagerDialog = qt.NewQDialog(nil)
|
||||
connectionManagerDialog__objectName := qt.NewQAnyStringView3("connectionManagerDialog")
|
||||
ui.connectionManagerDialog.SetObjectName(*connectionManagerDialog__objectName)
|
||||
connectionManagerDialog__objectName.Delete() // setter copied value
|
||||
ui.connectionManagerDialog.Resize(332, 449)
|
||||
ui.verticalLayout_2 = qt.NewQVBoxLayout(ui.connectionManagerDialog.QWidget)
|
||||
verticalLayout_2__objectName := qt.NewQAnyStringView3("verticalLayout_2")
|
||||
ui.verticalLayout_2.SetObjectName(*verticalLayout_2__objectName)
|
||||
verticalLayout_2__objectName.Delete() // setter copied value
|
||||
ui.verticalLayout_2.SetContentsMargins(11, 11, 11, 11)
|
||||
ui.verticalLayout_2.SetSpacing(6)
|
||||
ui.horizontalLayout = qt.NewQHBoxLayout2()
|
||||
horizontalLayout__objectName := qt.NewQAnyStringView3("horizontalLayout")
|
||||
ui.horizontalLayout.SetObjectName(*horizontalLayout__objectName)
|
||||
horizontalLayout__objectName.Delete() // setter copied value
|
||||
ui.horizontalLayout.SetContentsMargins(0, 0, 0, 0)
|
||||
ui.horizontalLayout.SetSpacing(6)
|
||||
ui.treeWidget = qt.NewQTreeWidget(ui.connectionManagerDialog.QWidget)
|
||||
treeWidget__objectName := qt.NewQAnyStringView3("treeWidget")
|
||||
ui.treeWidget.SetObjectName(*treeWidget__objectName)
|
||||
treeWidget__objectName.Delete() // setter copied value
|
||||
|
||||
ui.horizontalLayout.AddWidget(ui.treeWidget.QWidget)
|
||||
ui.verticalLayout = qt.NewQVBoxLayout2()
|
||||
verticalLayout__objectName := qt.NewQAnyStringView3("verticalLayout")
|
||||
ui.verticalLayout.SetObjectName(*verticalLayout__objectName)
|
||||
verticalLayout__objectName.Delete() // setter copied value
|
||||
ui.verticalLayout.SetContentsMargins(0, 0, 0, 0)
|
||||
ui.verticalLayout.SetSpacing(6)
|
||||
ui.connAdd = qt.NewQToolButton(ui.connectionManagerDialog.QWidget)
|
||||
connAdd__objectName := qt.NewQAnyStringView3("connAdd")
|
||||
ui.connAdd.SetObjectName(*connAdd__objectName)
|
||||
connAdd__objectName.Delete() // setter copied value
|
||||
icon0 := qt.NewQIcon()
|
||||
icon0.AddFile4(":/assets/add.png", qt.NewQSize(), qt.QIcon__Normal, qt.QIcon__Off)
|
||||
ui.connAdd.SetIcon(icon0)
|
||||
ui.connAdd.SetAutoRaise(true)
|
||||
|
||||
ui.verticalLayout.AddWidget(ui.connAdd.QWidget)
|
||||
ui.connEdit = qt.NewQToolButton(ui.connectionManagerDialog.QWidget)
|
||||
connEdit__objectName := qt.NewQAnyStringView3("connEdit")
|
||||
ui.connEdit.SetObjectName(*connEdit__objectName)
|
||||
connEdit__objectName.Delete() // setter copied value
|
||||
icon1 := qt.NewQIcon()
|
||||
icon1.AddFile4(":/assets/pencil.png", qt.NewQSize(), qt.QIcon__Normal, qt.QIcon__Off)
|
||||
ui.connEdit.SetIcon(icon1)
|
||||
ui.connEdit.SetAutoRaise(true)
|
||||
|
||||
ui.verticalLayout.AddWidget(ui.connEdit.QWidget)
|
||||
ui.connDelete = qt.NewQToolButton(ui.connectionManagerDialog.QWidget)
|
||||
connDelete__objectName := qt.NewQAnyStringView3("connDelete")
|
||||
ui.connDelete.SetObjectName(*connDelete__objectName)
|
||||
connDelete__objectName.Delete() // setter copied value
|
||||
icon2 := qt.NewQIcon()
|
||||
icon2.AddFile4(":/assets/delete.png", qt.NewQSize(), qt.QIcon__Normal, qt.QIcon__Off)
|
||||
ui.connDelete.SetIcon(icon2)
|
||||
ui.connDelete.SetAutoRaise(true)
|
||||
|
||||
ui.verticalLayout.AddWidget(ui.connDelete.QWidget)
|
||||
ui.verticalSpacer = qt.NewQSpacerItem4(20, 40, qt.QSizePolicy__Minimum, qt.QSizePolicy__Expanding)
|
||||
|
||||
ui.verticalLayout.AddItem(ui.verticalSpacer.QLayoutItem)
|
||||
|
||||
ui.horizontalLayout.AddLayout(ui.verticalLayout.QLayout)
|
||||
|
||||
ui.verticalLayout_2.AddLayout(ui.horizontalLayout.QLayout)
|
||||
ui.horizontalLayout_2 = qt.NewQHBoxLayout2()
|
||||
horizontalLayout_2__objectName := qt.NewQAnyStringView3("horizontalLayout_2")
|
||||
ui.horizontalLayout_2.SetObjectName(*horizontalLayout_2__objectName)
|
||||
horizontalLayout_2__objectName.Delete() // setter copied value
|
||||
ui.horizontalLayout_2.SetContentsMargins(0, 0, 0, 0)
|
||||
ui.horizontalLayout_2.SetSpacing(6)
|
||||
ui.toolsBtn = qt.NewQToolButton(ui.connectionManagerDialog.QWidget)
|
||||
toolsBtn__objectName := qt.NewQAnyStringView3("toolsBtn")
|
||||
ui.toolsBtn.SetObjectName(*toolsBtn__objectName)
|
||||
toolsBtn__objectName.Delete() // setter copied value
|
||||
ui.toolsBtn.SetAutoRaise(true)
|
||||
|
||||
ui.horizontalLayout_2.AddWidget(ui.toolsBtn.QWidget)
|
||||
ui.horizontalSpacer = qt.NewQSpacerItem4(40, 20, qt.QSizePolicy__Expanding, qt.QSizePolicy__Minimum)
|
||||
|
||||
ui.horizontalLayout_2.AddItem(ui.horizontalSpacer.QLayoutItem)
|
||||
ui.connectBtn = qt.NewQPushButton(ui.connectionManagerDialog.QWidget)
|
||||
connectBtn__objectName := qt.NewQAnyStringView3("connectBtn")
|
||||
ui.connectBtn.SetObjectName(*connectBtn__objectName)
|
||||
connectBtn__objectName.Delete() // setter copied value
|
||||
icon3 := qt.NewQIcon()
|
||||
icon3.AddFile4(":/assets/database_lightning.png", qt.NewQSize(), qt.QIcon__Normal, qt.QIcon__Off)
|
||||
ui.connectBtn.SetIcon(icon3)
|
||||
|
||||
ui.horizontalLayout_2.AddWidget(ui.connectBtn.QWidget)
|
||||
|
||||
ui.verticalLayout_2.AddLayout(ui.horizontalLayout_2.QLayout)
|
||||
|
||||
ui.Retranslate()
|
||||
|
||||
return ui
|
||||
}
|
||||
|
||||
// Retranslate reapplies all text translations.
|
||||
func (ui *connectionManagerDialogUi) Retranslate() {
|
||||
ui.connectionManagerDialog.SetWindowTitle(qt.QCoreApplication_Tr("Connection Manager"))
|
||||
ui.treeWidget.HeaderItem().SetText(0, qt.QTreeWidget_Tr("Connection"))
|
||||
ui.toolsBtn.SetText(qt.QDialog_Tr("Tools"))
|
||||
ui.connectBtn.SetText(qt.QDialog_Tr("Connect"))
|
||||
}
|
||||
124
connectionManagerDialog.ui
Normal file
@@ -0,0 +1,124 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>connectionManagerDialog</class>
|
||||
<widget class="QDialog" name="connectionManagerDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>332</width>
|
||||
<height>449</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Connection Manager</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QTreeWidget" name="treeWidget">
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Connection</string>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QToolButton" name="connAdd">
|
||||
<property name="icon">
|
||||
<iconset resource="embed.qrc">
|
||||
<normaloff>:/assets/add.png</normaloff>:/assets/add.png</iconset>
|
||||
</property>
|
||||
<property name="autoRaise">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="connEdit">
|
||||
<property name="icon">
|
||||
<iconset resource="embed.qrc">
|
||||
<normaloff>:/assets/pencil.png</normaloff>:/assets/pencil.png</iconset>
|
||||
</property>
|
||||
<property name="autoRaise">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="connDelete">
|
||||
<property name="icon">
|
||||
<iconset resource="embed.qrc">
|
||||
<normaloff>:/assets/delete.png</normaloff>:/assets/delete.png</iconset>
|
||||
</property>
|
||||
<property name="autoRaise">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QToolButton" name="toolsBtn">
|
||||
<property name="text">
|
||||
<string>Tools</string>
|
||||
</property>
|
||||
<property name="autoRaise">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="connectBtn">
|
||||
<property name="text">
|
||||
<string>Connect</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="embed.qrc">
|
||||
<normaloff>:/assets/database_lightning.png</normaloff>:/assets/database_lightning.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="embed.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
80
db_badger.go
@@ -138,59 +138,55 @@ var _ loadedDatabase = &badgerLoadedDatabase{} // interface assertion
|
||||
|
||||
//
|
||||
|
||||
type badgerMemConnection struct{}
|
||||
|
||||
func (bmc *badgerMemConnection) Connect(ctx context.Context) (loadedDatabase, string, error) {
|
||||
db, err := badger.Open(badger.DefaultOptions("").WithInMemory(true))
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
type badgerConnection struct {
|
||||
Type autoconfig.OneOf
|
||||
Disk *struct {
|
||||
Directory autoconfig.ExistingDirectory
|
||||
Readonly bool
|
||||
Encryption_Method autoconfig.EnumList `yenum:"None;;Hex (AES-128/192/256);;Passphrase (SHA256 KDF to AES-256)"`
|
||||
Encryption_Key autoconfig.Password
|
||||
}
|
||||
|
||||
return &badgerLoadedDatabase{db: db}, `:memory:`, nil // SQLite-style naming
|
||||
Memory *struct{}
|
||||
}
|
||||
|
||||
//
|
||||
func (bdc *badgerConnection) Connect(ctx context.Context) (loadedDatabase, string, error) {
|
||||
if bdc.Disk != nil {
|
||||
opts := badger.DefaultOptions(string(bdc.Disk.Directory))
|
||||
opts.ReadOnly = bdc.Disk.Readonly
|
||||
opts.MetricsEnabled = false
|
||||
|
||||
type badgerDirConnection struct {
|
||||
Directory autoconfig.ExistingDirectory
|
||||
Readonly bool
|
||||
Encryption_Method autoconfig.EnumList `yenum:"None;;Hex (AES-128/192/256);;Passphrase (SHA256 KDF to AES-256)"`
|
||||
Encryption_Key autoconfig.Password
|
||||
}
|
||||
switch bdc.Disk.Encryption_Method {
|
||||
case 0: // None
|
||||
case 1: // Hex (AES-128/192/256) - must be 16/24/32 bytes
|
||||
ehx, err := hex.DecodeString(string(bdc.Disk.Encryption_Key))
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
|
||||
func (bdc *badgerDirConnection) Connect(ctx context.Context) (loadedDatabase, string, error) {
|
||||
opts := badger.DefaultOptions(string(bdc.Directory))
|
||||
opts.ReadOnly = bdc.Readonly
|
||||
opts.MetricsEnabled = false
|
||||
if !(len(ehx) == 16 || len(ehx) == 24 || len(ehx) == 32) {
|
||||
return nil, "", fmt.Errorf("Hex encryption key must be 16/24/32 bytes long, got %d", len(ehx))
|
||||
}
|
||||
opts.EncryptionKey = ehx
|
||||
|
||||
switch bdc.Encryption_Method {
|
||||
case 0: // None
|
||||
case 1: // Hex (AES-128/192/256) - must be 16/24/32 bytes
|
||||
ehx, err := hex.DecodeString(string(bdc.Encryption_Key))
|
||||
case 2: // Passphrase (SHA256 KDF to AES-256)
|
||||
hasher := sha256.New()
|
||||
hasher.Write([]byte(bdc.Disk.Encryption_Key))
|
||||
opts.EncryptionKey = hasher.Sum(nil)
|
||||
}
|
||||
|
||||
db, err := badger.Open(opts)
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
|
||||
if !(len(ehx) == 16 || len(ehx) == 24 || len(ehx) == 32) {
|
||||
return nil, "", fmt.Errorf("Hex encryption key must be 16/24/32 bytes long, got %d", len(ehx))
|
||||
return &badgerLoadedDatabase{db: db}, filepath.Base(string(bdc.Disk.Directory)), nil
|
||||
} else { // memory
|
||||
db, err := badger.Open(badger.DefaultOptions("").WithInMemory(true))
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
opts.EncryptionKey = ehx
|
||||
|
||||
case 2: // Passphrase (SHA256 KDF to AES-256)
|
||||
hasher := sha256.New()
|
||||
hasher.Write([]byte(bdc.Encryption_Key))
|
||||
opts.EncryptionKey = hasher.Sum(nil)
|
||||
return &badgerLoadedDatabase{db: db}, `:memory:`, nil // SQLite-style naming
|
||||
|
||||
}
|
||||
|
||||
db, err := badger.Open(opts)
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
|
||||
return &badgerLoadedDatabase{db: db}, filepath.Base(string(bdc.Directory)), nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
registerDatabase(&badgerMemConnection{}, "BadgerDB v4 (Memory)", `:/assets/vendor_dgraph.png`)
|
||||
registerDatabase(&badgerDirConnection{}, "BadgerDB v4", `:/assets/vendor_dgraph.png`)
|
||||
}
|
||||
|
||||
12
db_bolt.go
@@ -21,10 +21,14 @@ type boltLoadedDatabase struct {
|
||||
}
|
||||
|
||||
type boltConfig struct {
|
||||
Path autoconfig.ExistingFile `yfilter:"Bolt database (*.db);;All files (*.*)"`
|
||||
Path autoconfig.ExistingFile `yfilter:"Bolt database (*.db);;All files (*)"`
|
||||
Readonly bool
|
||||
}
|
||||
|
||||
func (bc *boltConfig) String() string { // n.b. only used for default names in connection manager
|
||||
return filepath.Base(string(bc.Path))
|
||||
}
|
||||
|
||||
func (bc *boltConfig) Connect(ctx context.Context) (loadedDatabase, string, error) {
|
||||
|
||||
opts := bbolt.Options{
|
||||
@@ -50,10 +54,6 @@ func (bc *boltConfig) Connect(ctx context.Context) (loadedDatabase, string, erro
|
||||
return ld, displayName, nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
registerDatabase(&boltConfig{}, "Bolt", ":/assets/vendor_github.png")
|
||||
}
|
||||
|
||||
func (ld *boltLoadedDatabase) DriverName() string {
|
||||
return "Bolt " + version.Version
|
||||
}
|
||||
@@ -201,6 +201,8 @@ func (ld *boltLoadedDatabase) AddChildBucket(sender *qt.QTreeWidgetItem, bucketP
|
||||
}
|
||||
|
||||
func (ld *boltLoadedDatabase) DeleteBucket(sender *qt.QTreeWidgetItem, bucketPath []string) error {
|
||||
// TODO add confirmation
|
||||
|
||||
err := ld.db.Update(func(tx *bbolt.Tx) error {
|
||||
// Find parent of this bucket.
|
||||
if len(bucketPath) >= 2 {
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
|
||||
"yvbolt/debconf"
|
||||
|
||||
@@ -24,11 +25,30 @@ func (ld *debconfLoadedDatabase) RenderForNav(f *MainWindowUi, bucketPath []stri
|
||||
|
||||
// Load properties
|
||||
|
||||
content := fmt.Sprintf("Entries: %d\nUnique attributes: %d\n", len(ld.db.Entries), len(ld.db.AllColumnNames))
|
||||
content := fmt.Sprintf("Applications: %d\nUnique attributes: %d\n", len(ld.db.Entries), len(ld.db.AllColumnNames))
|
||||
f.propertiesBox.SetText(content)
|
||||
|
||||
// Load data
|
||||
|
||||
if len(bucketPath) == 0 {
|
||||
return nil // No data at root level
|
||||
}
|
||||
|
||||
// Find application entry for bucketPath
|
||||
|
||||
var appInfo *debconf.Application
|
||||
|
||||
for idx, app := range ld.db.Entries {
|
||||
if app.Name == bucketPath[0] {
|
||||
appInfo = &ld.db.Entries[idx] // TODO faster lookup?
|
||||
}
|
||||
}
|
||||
if appInfo == nil {
|
||||
return fmt.Errorf("Invalid application %q", bucketPath[0])
|
||||
}
|
||||
|
||||
// Process entries for specific application
|
||||
|
||||
indexes := make(map[string]int)
|
||||
|
||||
f.contentBox.SetColumnCount(len(ld.db.AllColumnNames))
|
||||
@@ -38,7 +58,7 @@ func (ld *debconfLoadedDatabase) RenderForNav(f *MainWindowUi, bucketPath []stri
|
||||
indexes[cname] = i
|
||||
}
|
||||
|
||||
for _, entry := range ld.db.Entries {
|
||||
for _, entry := range appInfo.Entries {
|
||||
|
||||
rpos := f.contentBox.RowCount()
|
||||
f.contentBox.SetRowCount(rpos + 1)
|
||||
@@ -56,7 +76,16 @@ func (ld *debconfLoadedDatabase) RenderForNav(f *MainWindowUi, bucketPath []stri
|
||||
}
|
||||
|
||||
func (ld *debconfLoadedDatabase) NavChildren(bucketPath []string) ([]string, error) {
|
||||
return []string{}, nil // No children
|
||||
if len(bucketPath) == 0 {
|
||||
ret := make([]string, 0, len(ld.db.Entries))
|
||||
for _, app := range ld.db.Entries {
|
||||
ret = append(ret, app.Name)
|
||||
}
|
||||
return ret, nil
|
||||
|
||||
} else {
|
||||
return []string{}, nil // No further children
|
||||
}
|
||||
}
|
||||
|
||||
func (ld *debconfLoadedDatabase) NavContext(bucketPath []string) ([]contextAction, error) {
|
||||
@@ -73,7 +102,13 @@ var _ loadedDatabase = &debconfLoadedDatabase{} // interface assertion
|
||||
//
|
||||
|
||||
type debconfConnection struct {
|
||||
Database autoconfig.ExistingFile `yfilter:"Debconf database (*.dat);;All files (*.*)"`
|
||||
Database autoconfig.ExistingFile `yfilter:"Debconf database (*.dat);;All files (*)"`
|
||||
}
|
||||
|
||||
func (dc *debconfConnection) Reset() {
|
||||
if runtime.GOOS == "linux" {
|
||||
dc.Database = "/var/cache/debconf/config.dat" // Prefill default path
|
||||
}
|
||||
}
|
||||
|
||||
func (dc *debconfConnection) Connect(ctx context.Context) (loadedDatabase, string, error) {
|
||||
@@ -90,9 +125,3 @@ func (dc *debconfConnection) Connect(ctx context.Context) (loadedDatabase, strin
|
||||
|
||||
return &debconfLoadedDatabase{db: db}, filepath.Base(string(dc.Database)), nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
registerDatabase(&debconfConnection{
|
||||
Database: "/var/cache/debconf/config.dat", // Prefill default path
|
||||
}, "Debconf", `:/assets/vendor_debian.png`)
|
||||
}
|
||||
|
||||
@@ -72,12 +72,12 @@ var _ loadedDatabase = &leveldbLoadedDatabase{} // interface assertion
|
||||
|
||||
//
|
||||
|
||||
type leveldbDirConnection struct {
|
||||
type leveldbConnection struct {
|
||||
Directory autoconfig.ExistingDirectory
|
||||
Readonly bool
|
||||
}
|
||||
|
||||
func (pdc *leveldbDirConnection) Connect(ctx context.Context) (loadedDatabase, string, error) {
|
||||
func (pdc *leveldbConnection) Connect(ctx context.Context) (loadedDatabase, string, error) {
|
||||
var o opt.Options
|
||||
o.ReadOnly = pdc.Readonly
|
||||
|
||||
@@ -88,7 +88,3 @@ func (pdc *leveldbDirConnection) Connect(ctx context.Context) (loadedDatabase, s
|
||||
|
||||
return &leveldbLoadedDatabase{db: db}, filepath.Base(string(pdc.Directory)), nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
registerDatabase(&leveldbDirConnection{}, "LevelDB", `:/assets/vendor_leveldb.png`)
|
||||
}
|
||||
|
||||
299
db_lmdb.go
Normal file
@@ -0,0 +1,299 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/ledgerwatch/lmdb-go/lmdb"
|
||||
"github.com/mappu/autoconfig"
|
||||
qt "github.com/mappu/miqt/qt6"
|
||||
)
|
||||
|
||||
type lmdbDatabase struct {
|
||||
db *lmdb.Env
|
||||
isMulti bool
|
||||
}
|
||||
|
||||
func (ld *lmdbDatabase) DriverName() string {
|
||||
return lmdb.VersionString() // Already includes "LMDB" prefix
|
||||
}
|
||||
|
||||
func (ld *lmdbDatabase) RenderForNav(f *MainWindowUi, bucketPath []string) error {
|
||||
|
||||
// Properties
|
||||
|
||||
if info, err := ld.db.Info(); err == nil {
|
||||
f.propertiesBox.SetPlainText(fmt.Sprintf("LMDB info: %#v", info))
|
||||
}
|
||||
|
||||
// Load data
|
||||
|
||||
if ld.isMulti && len(bucketPath) == 0 {
|
||||
// In multi-database mode, the only things in the root DB are keys
|
||||
// naming the child databases
|
||||
// Show no data, it will be shown in the nav area instead
|
||||
return nil
|
||||
}
|
||||
|
||||
// LMDB always uses Key + Value as the columns
|
||||
|
||||
f.contentBox.SetColumnCount(2)
|
||||
f.contentBox.SetHorizontalHeaderLabels([]string{"Key", "Value"})
|
||||
|
||||
err := ld.db.View(func(txn *lmdb.Txn) error {
|
||||
var dbi lmdb.DBI
|
||||
var err error
|
||||
|
||||
if len(bucketPath) == 0 {
|
||||
dbi, err = txn.OpenRoot(0)
|
||||
} else {
|
||||
dbi, err = txn.OpenDBI(bucketPath[0], 0)
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// defer ld.db.CloseDBI(dbi)
|
||||
|
||||
itn, err := txn.OpenCursor(dbi)
|
||||
defer itn.Close()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// FIXME is this correct?
|
||||
kbuff := make([]byte, ld.db.MaxKeySize())
|
||||
vbuff := make([]byte, 4096)
|
||||
|
||||
var op uint = lmdb.First
|
||||
for {
|
||||
key, val, err := itn.Get(kbuff, vbuff, op)
|
||||
if err != nil {
|
||||
if lmdb.IsNotFound(err) {
|
||||
break // reached end of iteration
|
||||
}
|
||||
return err // a real error
|
||||
}
|
||||
|
||||
op = lmdb.Next
|
||||
|
||||
rpos := f.contentBox.RowCount()
|
||||
f.contentBox.SetRowCount(rpos + 1)
|
||||
|
||||
f.contentBox.SetItem(rpos, 0, qt.NewQTableWidgetItem2(string(key)))
|
||||
f.contentBox.SetItem(rpos, 1, qt.NewQTableWidgetItem2(string(val)))
|
||||
}
|
||||
|
||||
// Done
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Valid
|
||||
f.contentBox.ResizeColumnsToContents()
|
||||
f.contentBox.SetEnabled(true)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ld *lmdbDatabase) ApplyChanges(f *App, bucketPath []string) error {
|
||||
return ld.db.Update(func(txn *lmdb.Txn) error {
|
||||
var dbi lmdb.DBI
|
||||
var err error
|
||||
|
||||
if len(bucketPath) == 0 {
|
||||
dbi, err = txn.OpenRoot(0)
|
||||
} else {
|
||||
dbi, err = txn.OpenDBI(bucketPath[0], 0)
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Insert
|
||||
|
||||
for rowid, _ := range f.insertRows {
|
||||
key := f.ui.contentBox.Item(rowid, 0).Text()
|
||||
val := f.ui.contentBox.Item(rowid, 1).Text()
|
||||
err = txn.Put(dbi, []byte(key), []byte(val), 0)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Inserting %q: %w", key, err)
|
||||
}
|
||||
}
|
||||
|
||||
// Edit
|
||||
|
||||
for rowid, _ := range f.updateRows {
|
||||
_ = rowid
|
||||
// FIXME need to support delete+reinsert if the key column is edited
|
||||
// TODO
|
||||
}
|
||||
|
||||
// Delete
|
||||
for rowid, _ := range f.deleteRows {
|
||||
key := f.ui.contentBox.Item(rowid, 0).Text()
|
||||
err = txn.Del(dbi, []byte(key), nil)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Removing %q: %w", key, err)
|
||||
}
|
||||
}
|
||||
|
||||
// Done
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func (ld *lmdbDatabase) NavChildren(bucketPath []string) ([]string, error) {
|
||||
// """To use named databases (with name != NULL), mdb_env_set_maxdbs() must
|
||||
// be called before opening the environment. Database names are keys in the
|
||||
// unnamed database, and may be read but not written."""
|
||||
|
||||
if len(bucketPath) == 0 && ld.isMulti {
|
||||
|
||||
// Read all keys from root DB
|
||||
var allKeys []string
|
||||
err := ld.db.View(func(txn *lmdb.Txn) error {
|
||||
dbi, err := txn.OpenRoot(0)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
//defer ld.db.CloseDBI(dbi)
|
||||
|
||||
itn, err := txn.OpenCursor(dbi)
|
||||
defer itn.Close()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
kbuff := make([]byte, ld.db.MaxKeySize())
|
||||
|
||||
var op uint = lmdb.First
|
||||
for {
|
||||
key, _, err := itn.Get(kbuff, nil, op)
|
||||
if err != nil {
|
||||
if lmdb.IsNotFound(err) {
|
||||
break // reached end of iteration
|
||||
}
|
||||
return err // a real error
|
||||
}
|
||||
|
||||
op = lmdb.Next
|
||||
|
||||
allKeys = append(allKeys, string(key))
|
||||
}
|
||||
|
||||
// Done
|
||||
return nil
|
||||
})
|
||||
return allKeys, err
|
||||
|
||||
} else {
|
||||
return []string{}, nil // No children
|
||||
}
|
||||
}
|
||||
|
||||
func (ld *lmdbDatabase) createChildDatabase(sender *qt.QTreeWidgetItem, bucketPath []string) error {
|
||||
// Prompt for child database name
|
||||
ok := false
|
||||
childDbName := qt.QInputDialog_GetText4(sender.TreeWidget().QWidget, APPNAME, "Enter a name for the child database:", qt.QLineEdit__Normal, "", &ok)
|
||||
if !ok {
|
||||
return nil // Cancelled
|
||||
}
|
||||
|
||||
return ld.db.Update(func(txn *lmdb.Txn) error {
|
||||
_, err := txn.CreateDBI(childDbName)
|
||||
return err
|
||||
})
|
||||
}
|
||||
|
||||
//func (ld *lmdbDatabase) truncateAllContent(sender *qt.QTreeWidgetItem, bucketPath []string) error {
|
||||
// TODO add warning
|
||||
//}
|
||||
|
||||
func (ld *lmdbDatabase) deleteChildDatabase(sender *qt.QTreeWidgetItem, bucketPath []string) error {
|
||||
|
||||
// TODO add warning
|
||||
return ld.db.Update(func(txn *lmdb.Txn) error {
|
||||
dbi, err := txn.OpenDBI(bucketPath[0], 0)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return txn.Drop(dbi, true)
|
||||
})
|
||||
}
|
||||
|
||||
func (ld *lmdbDatabase) NavContext(bucketPath []string) ([]contextAction, error) {
|
||||
|
||||
if ld.isMulti {
|
||||
// Allow create/delete databases
|
||||
if len(bucketPath) == 0 {
|
||||
return []contextAction{
|
||||
contextAction{"Add child database...", ld.createChildDatabase},
|
||||
}, nil
|
||||
} else {
|
||||
return []contextAction{
|
||||
contextAction{"Remove child database...", ld.deleteChildDatabase},
|
||||
}, nil
|
||||
}
|
||||
}
|
||||
|
||||
return nil, nil // No special actions are supported
|
||||
}
|
||||
|
||||
func (ld *lmdbDatabase) Close() {
|
||||
_ = ld.db.Close()
|
||||
}
|
||||
|
||||
var _ loadedDatabase = &lmdbDatabase{} // interface assertion
|
||||
|
||||
//
|
||||
|
||||
type lmdbConnection struct {
|
||||
Storage struct {
|
||||
Type autoconfig.OneOf
|
||||
Directory *autoconfig.ExistingDirectory
|
||||
File *struct {
|
||||
Path autoconfig.ExistingFile `yfilter:"LMDB database (*.mdb);;All files (*)"`
|
||||
}
|
||||
}
|
||||
MultiDB *struct {
|
||||
Slots int
|
||||
} `ylabel:"Multiple databases mode"`
|
||||
Readonly bool
|
||||
}
|
||||
|
||||
func (pdc *lmdbConnection) Connect(ctx context.Context) (loadedDatabase, string, error) {
|
||||
|
||||
env, err := lmdb.NewEnv()
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
|
||||
var openPath string
|
||||
var flags uint = 0
|
||||
if pdc.Readonly {
|
||||
flags |= lmdb.Readonly
|
||||
}
|
||||
if pdc.Storage.Directory != nil {
|
||||
openPath = string(*pdc.Storage.Directory)
|
||||
} else if pdc.Storage.File != nil {
|
||||
openPath = string(pdc.Storage.File.Path)
|
||||
flags |= lmdb.NoSubdir
|
||||
}
|
||||
|
||||
isMulti := false
|
||||
if pdc.MultiDB != nil {
|
||||
env.SetMaxDBs(pdc.MultiDB.Slots)
|
||||
isMulti = true
|
||||
}
|
||||
|
||||
err = env.Open(openPath, flags, 0644)
|
||||
if err != nil {
|
||||
_ = env.Close()
|
||||
return nil, "", err
|
||||
}
|
||||
|
||||
return &lmdbDatabase{db: env, isMulti: isMulti}, filepath.Base(openPath), nil
|
||||
}
|
||||
51
db_pebble.go
@@ -102,37 +102,36 @@ var _ loadedDatabase = &pebbleLoadedDatabase{} // interface assertion
|
||||
|
||||
//
|
||||
|
||||
type pebbleMemConnection struct{}
|
||||
type pebbleConnection struct {
|
||||
Type autoconfig.OneOf
|
||||
|
||||
func (pmc *pebbleMemConnection) Connect(ctx context.Context) (loadedDatabase, string, error) {
|
||||
db, err := pebble.Open("", &pebble.Options{FS: vfs.NewMem()})
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
Disk *struct {
|
||||
Directory autoconfig.ExistingDirectory
|
||||
Readonly bool
|
||||
}
|
||||
|
||||
return &pebbleLoadedDatabase{db: db}, `:memory:`, nil // SQLite-style naming
|
||||
Memory *struct{}
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
type pebbleDirConnection struct {
|
||||
Directory autoconfig.ExistingDirectory
|
||||
Readonly bool
|
||||
}
|
||||
|
||||
func (pdc *pebbleDirConnection) Connect(ctx context.Context) (loadedDatabase, string, error) {
|
||||
func (pdc *pebbleConnection) Connect(ctx context.Context) (loadedDatabase, string, error) {
|
||||
opts := (&pebble.Options{}).EnsureDefaults()
|
||||
opts.ReadOnly = pdc.Readonly
|
||||
|
||||
db, err := pebble.Open(string(pdc.Directory), opts)
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
if pdc.Disk != nil {
|
||||
opts.ReadOnly = pdc.Disk.Readonly
|
||||
|
||||
db, err := pebble.Open(string(pdc.Disk.Directory), opts)
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
|
||||
return &pebbleLoadedDatabase{db: db}, filepath.Base(string(pdc.Disk.Directory)), nil
|
||||
|
||||
} else {
|
||||
// Memory != nil
|
||||
db, err := pebble.Open("", &pebble.Options{FS: vfs.NewMem()})
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
|
||||
return &pebbleLoadedDatabase{db: db}, `:memory:`, nil // SQLite-style naming
|
||||
}
|
||||
|
||||
return &pebbleLoadedDatabase{db: db}, filepath.Base(string(pdc.Directory)), nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
registerDatabase(&pebbleMemConnection{}, "Pebble (Memory)", `:/assets/vendor_cockroach.png`)
|
||||
registerDatabase(&pebbleDirConnection{}, "Pebble", `:/assets/vendor_cockroach.png`)
|
||||
}
|
||||
|
||||
@@ -20,10 +20,8 @@ type redisConnectionOptions struct {
|
||||
SSH_Tunnel *SSHTunnel
|
||||
}
|
||||
|
||||
func init() {
|
||||
registerDatabase(&redisConnectionOptions{
|
||||
Address: autoconfig.AddressPort{Port: 6379}, // default value
|
||||
}, "Redis", ":/assets/vendor_redis.png")
|
||||
func (config *redisConnectionOptions) Reset() {
|
||||
config.Address.Port = 6379
|
||||
}
|
||||
|
||||
func (config *redisConnectionOptions) Connect(ctx context.Context) (loadedDatabase, string, error) {
|
||||
|
||||
189
db_secretsvc_linux.go
Normal file
@@ -0,0 +1,189 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
dbus "github.com/godbus/dbus/v5"
|
||||
qt "github.com/mappu/miqt/qt6"
|
||||
secretservice "github.com/zalando/go-keyring/secret_service"
|
||||
)
|
||||
|
||||
type secretServiceDb struct {
|
||||
svc *secretservice.SecretService
|
||||
session dbus.BusObject
|
||||
}
|
||||
|
||||
func (ld *secretServiceDb) DriverName() string {
|
||||
return "FreeDesktop.org Secret Service"
|
||||
}
|
||||
|
||||
func (ld *secretServiceDb) RenderForNav(f *MainWindowUi, bucketPath []string) error {
|
||||
|
||||
const (
|
||||
collectionBasePath = "/org/freedesktop/secrets/collection/"
|
||||
itemInterface = "org.freedesktop.Secret.Item"
|
||||
serviceName = "org.freedesktop.secrets"
|
||||
)
|
||||
|
||||
// No properties
|
||||
|
||||
// No data
|
||||
|
||||
if len(bucketPath) == 0 {
|
||||
// No data
|
||||
} else if len(bucketPath) == 1 {
|
||||
|
||||
f.contentBox.SetColumnCount(6)
|
||||
f.contentBox.SetHorizontalHeaderLabels([]string{"ID", "Label", "Attributes", "ContentType", "Parameters", "Value"})
|
||||
|
||||
// Collection is selected
|
||||
collection := ld.svc.GetCollection(bucketPath[0])
|
||||
|
||||
// Perform an empty search to find all items
|
||||
allItems, err := ld.svc.SearchItems(collection, map[string]string{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, item := range allItems {
|
||||
|
||||
//
|
||||
|
||||
obj := ld.svc.Object(serviceName, item)
|
||||
label, err := obj.GetProperty(itemInterface + ".Label")
|
||||
if err != nil {
|
||||
return fmt.Errorf("Reading label %q: %w", item, err)
|
||||
}
|
||||
|
||||
// Attributes: a map[string]string{}
|
||||
// Is this optional?
|
||||
// Calling attrs.String() gives a JSON representation
|
||||
attrs, err := obj.GetProperty(itemInterface + ".Attributes")
|
||||
if err != nil {
|
||||
return fmt.Errorf("Reading attributes %q: %w", item, err)
|
||||
}
|
||||
|
||||
secr, err := ld.svc.GetSecret(item, ld.session.Path())
|
||||
if err != nil {
|
||||
return fmt.Errorf("Reading secret %q: %w", item, err)
|
||||
}
|
||||
|
||||
rpos := f.contentBox.RowCount()
|
||||
f.contentBox.SetRowCount(rpos + 1)
|
||||
|
||||
f.contentBox.SetItem(rpos, 0, qt.NewQTableWidgetItem2(string(item))) // ID
|
||||
f.contentBox.SetItem(rpos, 1, qt.NewQTableWidgetItem2(label.Value().(string))) // Label
|
||||
f.contentBox.SetItem(rpos, 2, qt.NewQTableWidgetItem2(attrs.String())) // Attributes (JSON)
|
||||
f.contentBox.SetItem(rpos, 3, qt.NewQTableWidgetItem2(secr.ContentType)) // ContentType
|
||||
f.contentBox.SetItem(rpos, 4, qt.NewQTableWidgetItem2(string(secr.Parameters))) // Parameters
|
||||
f.contentBox.SetItem(rpos, 5, qt.NewQTableWidgetItem2(string(secr.Value))) // Value
|
||||
}
|
||||
|
||||
// Valid
|
||||
f.contentBox.ResizeColumnsToContents()
|
||||
f.contentBox.SetEnabled(true)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ld *secretServiceDb) listCollections() ([]string, error) {
|
||||
|
||||
const (
|
||||
serviceName = "org.freedesktop.secrets"
|
||||
servicePath = "/org/freedesktop/secrets"
|
||||
collectionsInterface = "org.freedesktop.Secret.Service.Collections"
|
||||
collectionBasePath = "/org/freedesktop/secrets/collection/"
|
||||
)
|
||||
|
||||
obj := ld.svc.Conn.Object(serviceName, servicePath)
|
||||
|
||||
val, err := obj.GetProperty(collectionsInterface)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
paths := val.Value().([]dbus.ObjectPath)
|
||||
|
||||
ret := make([]string, 0, len(paths))
|
||||
for _, p := range paths {
|
||||
// They are expected to have {collectionBasePath} as prefix
|
||||
colName := string(p)
|
||||
if strings.HasPrefix(colName, collectionBasePath) {
|
||||
colName = colName[len(collectionBasePath):]
|
||||
}
|
||||
ret = append(ret, colName)
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (ld *secretServiceDb) NavChildren(bucketPath []string) ([]string, error) {
|
||||
if len(bucketPath) == 0 {
|
||||
return ld.listCollections()
|
||||
}
|
||||
|
||||
return []string{}, nil // No children
|
||||
}
|
||||
|
||||
func (ld *secretServiceDb) newCollection(sender *qt.QTreeWidgetItem, bucketPath []string) error {
|
||||
name := qt.QInputDialog_GetText(sender.TreeWidget().QWidget, APPNAME, "Enter a name for the new collection:")
|
||||
if name == "" {
|
||||
return nil // cancelled
|
||||
}
|
||||
|
||||
_, err := ld.svc.CreateCollection(name)
|
||||
return err
|
||||
}
|
||||
|
||||
func (ld *secretServiceDb) unlockKeychain(sender *qt.QTreeWidgetItem, bucketPath []string) error {
|
||||
if len(bucketPath) != 1 {
|
||||
return errors.New("Invalid selection")
|
||||
}
|
||||
|
||||
coll := ld.svc.GetCollection(bucketPath[0])
|
||||
return ld.svc.Unlock(coll.Path())
|
||||
}
|
||||
|
||||
func (ld *secretServiceDb) NavContext(bucketPath []string) ([]contextAction, error) {
|
||||
if len(bucketPath) == 0 {
|
||||
return []contextAction{
|
||||
contextAction{"Create collection...", ld.newCollection},
|
||||
}, nil
|
||||
|
||||
} else if len(bucketPath) == 1 {
|
||||
return []contextAction{
|
||||
contextAction{"Unlock", ld.unlockKeychain},
|
||||
}, nil
|
||||
|
||||
} else {
|
||||
return nil, nil // Unreachable
|
||||
}
|
||||
}
|
||||
|
||||
func (ld *secretServiceDb) Close() {
|
||||
_ = ld.svc.Close(ld.session)
|
||||
}
|
||||
|
||||
var _ loadedDatabase = &secretServiceDb{} // interface assertion
|
||||
|
||||
//
|
||||
|
||||
type secretServiceConnection struct {
|
||||
}
|
||||
|
||||
func (ssc *secretServiceConnection) Connect(ctx context.Context) (loadedDatabase, string, error) {
|
||||
|
||||
svc, err := secretservice.NewSecretService()
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
|
||||
session, err := svc.OpenSession()
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
|
||||
return &secretServiceDb{svc: svc, session: session}, "dbus://SessionBus/org.freedesktop.secrets", nil
|
||||
}
|
||||
19
db_secretsvc_other.go
Normal file
@@ -0,0 +1,19 @@
|
||||
//go:build !linux
|
||||
// +build !linux
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"github.com/mappu/autoconfig"
|
||||
)
|
||||
|
||||
type secretServiceConnection struct {
|
||||
H1 autoconfig.Header `ylabel:"Not supported on this operating system"`
|
||||
}
|
||||
|
||||
func (ssc *secretServiceConnection) Connect(ctx context.Context) (loadedDatabase, string, error) {
|
||||
return nil, "", errors.New("Not supported on this operating system")
|
||||
}
|
||||
53
db_sqlite.go
@@ -422,37 +422,34 @@ var _ queryableLoadedDatabase = &sqliteLoadedDatabase{} // interface assertion
|
||||
//
|
||||
|
||||
type sqliteConnection struct {
|
||||
Database autoconfig.ExistingFile `yfilter:"SQLite database (*.db *.db3 *.sqlite *.sqlite3);;All files (*.*)"`
|
||||
CliDriver bool `ylabel:"Use experimental CLI driver"`
|
||||
Type autoconfig.OneOf
|
||||
Disk *struct {
|
||||
Database autoconfig.ExistingFile `yfilter:"SQLite database (*.db *.db3 *.sqlite *.sqlite3);;All files (*)"`
|
||||
CliDriver bool `ylabel:"Use experimental CLI driver"`
|
||||
}
|
||||
Memory *struct{}
|
||||
}
|
||||
|
||||
func (sc *sqliteConnection) Connect(ctx context.Context) (loadedDatabase, string, error) {
|
||||
if sc.Disk != nil {
|
||||
driver := "sqlite3"
|
||||
if sc.Disk.CliDriver {
|
||||
driver = "sqliteclidriver"
|
||||
}
|
||||
|
||||
driver := "sqlite3"
|
||||
if sc.CliDriver {
|
||||
driver = "sqliteclidriver"
|
||||
db, err := sql.Open(driver, string(sc.Disk.Database))
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
|
||||
return &sqliteLoadedDatabase{db: db}, filepath.Base(string(sc.Disk.Database)), nil
|
||||
|
||||
} else { // memory
|
||||
db, err := sql.Open("sqlite3", ":memory:")
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
|
||||
return &sqliteLoadedDatabase{db: db}, ":memory:", nil
|
||||
}
|
||||
|
||||
db, err := sql.Open(driver, string(sc.Database))
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
|
||||
return &sqliteLoadedDatabase{db: db}, filepath.Base(string(sc.Database)), nil
|
||||
}
|
||||
|
||||
type sqliteMemoryConnection struct{}
|
||||
|
||||
func (sc *sqliteMemoryConnection) Connect(ctx context.Context) (loadedDatabase, string, error) {
|
||||
db, err := sql.Open("sqlite3", ":memory:")
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
|
||||
return &sqliteLoadedDatabase{db: db}, ":memory:", nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
registerDatabase(&sqliteConnection{}, "SQLite", `:/assets/vendor_sqlite.png`)
|
||||
registerDatabase(&sqliteMemoryConnection{}, "SQLite (Memory)", `:/assets/vendor_sqlite.png`)
|
||||
}
|
||||
|
||||
109
db_starskey.go
Normal file
@@ -0,0 +1,109 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/mappu/autoconfig"
|
||||
qt "github.com/mappu/miqt/qt6"
|
||||
"github.com/starskey-io/starskey"
|
||||
)
|
||||
|
||||
type starskeyLdb struct {
|
||||
db *starskey.Starskey
|
||||
}
|
||||
|
||||
func (ld *starskeyLdb) DriverName() string {
|
||||
return "Starskey"
|
||||
}
|
||||
|
||||
func (ld *starskeyLdb) RenderForNav(f *MainWindowUi, bucketPath []string) error {
|
||||
|
||||
// No properties
|
||||
|
||||
// Load data
|
||||
// Starskey always uses Key + Value as the columns
|
||||
|
||||
f.contentBox.SetColumnCount(2)
|
||||
f.contentBox.SetHorizontalHeaderLabels([]string{"Key", "Value"})
|
||||
|
||||
// It's possible to create a transaction in Starskey, but you can't enumerate keys
|
||||
// within the transaction - doesn't really help us
|
||||
|
||||
// We have to supply valid bounds that work for bytes.Compare
|
||||
// FIXME any better way to find all keys?
|
||||
earliestPossibleKey := []byte{0x00}
|
||||
lastPossibleKey := []byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}
|
||||
allKeys, err := ld.db.Range(earliestPossibleKey, lastPossibleKey)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, key := range allKeys {
|
||||
val, err := ld.db.Get(key)
|
||||
if err != nil {
|
||||
// We get <nil, nil> if not found, so any error is a real error
|
||||
return fmt.Errorf("Reading key %q: %w", string(key), err)
|
||||
}
|
||||
|
||||
rpos := f.contentBox.RowCount()
|
||||
f.contentBox.SetRowCount(rpos + 1)
|
||||
|
||||
f.contentBox.SetItem(rpos, 0, qt.NewQTableWidgetItem2(string(key)))
|
||||
f.contentBox.SetItem(rpos, 1, qt.NewQTableWidgetItem2(string(val)))
|
||||
}
|
||||
|
||||
// Valid
|
||||
f.contentBox.ResizeColumnsToContents()
|
||||
f.contentBox.SetEnabled(true)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ld *starskeyLdb) NavChildren(bucketPath []string) ([]string, error) {
|
||||
return []string{}, nil // No children
|
||||
}
|
||||
|
||||
func (ld *starskeyLdb) NavContext(bucketPath []string) ([]contextAction, error) {
|
||||
return nil, nil // No special actions are supported
|
||||
}
|
||||
|
||||
func (ld *starskeyLdb) Close() {
|
||||
_ = ld.db.Close()
|
||||
}
|
||||
|
||||
var _ loadedDatabase = &starskeyLdb{} // interface assertion
|
||||
|
||||
//
|
||||
|
||||
type starskeyConnection struct {
|
||||
Directory autoconfig.ExistingDirectory
|
||||
Compression autoconfig.EnumList `yenum:"No compression;;Snappy;;S2"`
|
||||
}
|
||||
|
||||
func (pdc *starskeyConnection) Connect(ctx context.Context) (loadedDatabase, string, error) {
|
||||
|
||||
cfg := starskey.Config{
|
||||
Permission: 0755,
|
||||
Directory: string(pdc.Directory),
|
||||
FlushThreshold: (1024 * 1024) * 24, // Upstream default (24 MiB)
|
||||
MaxLevel: 3, // Upstream default
|
||||
SizeFactor: 10, // Upstream default
|
||||
}
|
||||
|
||||
if pdc.Compression == 0 {
|
||||
} else if pdc.Compression == 1 {
|
||||
cfg.Compression = true
|
||||
cfg.CompressionOption = starskey.SnappyCompression
|
||||
} else if pdc.Compression == 2 {
|
||||
cfg.Compression = true
|
||||
cfg.CompressionOption = starskey.S2Compression
|
||||
}
|
||||
|
||||
db, err := starskey.Open(&cfg)
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
|
||||
return &starskeyLdb{db: db}, filepath.Base(string(pdc.Directory)), nil
|
||||
}
|
||||
@@ -18,8 +18,13 @@ type Entry struct {
|
||||
Properties [][2]string
|
||||
}
|
||||
|
||||
type Application struct {
|
||||
Name string
|
||||
Entries []Entry
|
||||
}
|
||||
|
||||
type Database struct {
|
||||
Entries []Entry
|
||||
Entries []Application
|
||||
AllColumnNames []string
|
||||
}
|
||||
|
||||
@@ -87,8 +92,31 @@ func Parse(r io.Reader) (*Database, error) {
|
||||
entries = append(entries, wip)
|
||||
}
|
||||
|
||||
// Group all entries by Application
|
||||
|
||||
apps := make([]Application, 0)
|
||||
appIndexes := make(map[string]int, 0)
|
||||
|
||||
for _, entry := range entries {
|
||||
spos := strings.Index(entry.Name, `/`)
|
||||
appName := entry.Name[0:spos]
|
||||
|
||||
idx, ok := appIndexes[appName]
|
||||
if !ok {
|
||||
appIndexes[appName] = len(apps)
|
||||
apps = append(apps, Application{
|
||||
Name: appName,
|
||||
Entries: []Entry{entry},
|
||||
})
|
||||
} else {
|
||||
tmp := apps[idx]
|
||||
tmp.Entries = append(tmp.Entries, entry)
|
||||
apps[idx] = tmp
|
||||
}
|
||||
}
|
||||
|
||||
return &Database{
|
||||
Entries: entries,
|
||||
Entries: apps,
|
||||
AllColumnNames: discoveredColumns,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file>assets/vendor_qt.png</file>
|
||||
<file>assets/connect.png</file>
|
||||
<file>assets/disconnect.png</file>
|
||||
<file>assets/database_key.png</file>
|
||||
<file>assets/help.png</file>
|
||||
<file>assets/add.png</file>
|
||||
<file>assets/arrow_refresh.png</file>
|
||||
<file>assets/chart_bar.png</file>
|
||||
@@ -23,10 +28,13 @@
|
||||
<file>assets/vendor_cockroach.png</file>
|
||||
<file>assets/vendor_debian.png</file>
|
||||
<file>assets/vendor_dgraph.png</file>
|
||||
<file>assets/vendor_freedesktop.png</file>
|
||||
<file>assets/vendor_github.png</file>
|
||||
<file>assets/vendor_leveldb.png</file>
|
||||
<file>assets/vendor_lmdb.png</file>
|
||||
<file>assets/vendor_mysql.png</file>
|
||||
<file>assets/vendor_redis.png</file>
|
||||
<file>assets/vendor_sqlite.png</file>
|
||||
<file>assets/vendor_starskey.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
||||
11
go.mod
@@ -8,7 +8,7 @@ require (
|
||||
github.com/cockroachdb/pebble v1.1.5
|
||||
github.com/dgraph-io/badger/v4 v4.8.0
|
||||
github.com/google/uuid v1.6.0
|
||||
github.com/mappu/autoconfig v0.2.0
|
||||
github.com/mappu/autoconfig v0.4.1
|
||||
github.com/mappu/miqt v0.12.1-0.20251106063543-466b60e47edf
|
||||
github.com/mattn/go-sqlite3 v1.14.32
|
||||
github.com/redis/go-redis/v9 v9.16.0
|
||||
@@ -19,6 +19,7 @@ require (
|
||||
)
|
||||
|
||||
require (
|
||||
al.essio.dev/pkg/shellescape v1.5.1 // indirect
|
||||
github.com/DataDog/zstd v1.5.7 // indirect
|
||||
github.com/beorn7/perks v1.0.1 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
||||
@@ -27,6 +28,7 @@ require (
|
||||
github.com/cockroachdb/logtags v0.0.0-20241215232642-bb51bb14a506 // indirect
|
||||
github.com/cockroachdb/redact v1.1.6 // indirect
|
||||
github.com/cockroachdb/tokenbucket v0.0.0-20250429170803-42689b6311bb // indirect
|
||||
github.com/danieljoos/wincred v1.2.2 // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/dgraph-io/ristretto/v2 v2.3.0 // indirect
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
|
||||
@@ -34,12 +36,15 @@ require (
|
||||
github.com/getsentry/sentry-go v0.36.2 // indirect
|
||||
github.com/go-logr/logr v1.4.3 // indirect
|
||||
github.com/go-logr/stdr v1.2.2 // indirect
|
||||
github.com/godbus/dbus/v5 v5.1.0 // indirect
|
||||
github.com/gogo/protobuf v1.3.2 // indirect
|
||||
github.com/golang/snappy v1.0.0 // indirect
|
||||
github.com/google/flatbuffers v25.9.23+incompatible // indirect
|
||||
github.com/klauspost/compress v1.18.1 // indirect
|
||||
github.com/klauspost/cpuid/v2 v2.0.9 // indirect
|
||||
github.com/kr/pretty v0.3.1 // indirect
|
||||
github.com/kr/text v0.2.0 // indirect
|
||||
github.com/ledgerwatch/lmdb-go v1.18.2 // indirect
|
||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
|
||||
github.com/pkg/errors v0.9.1 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
@@ -48,6 +53,10 @@ require (
|
||||
github.com/prometheus/common v0.67.2 // indirect
|
||||
github.com/prometheus/procfs v0.19.2 // indirect
|
||||
github.com/rogpeppe/go-internal v1.14.1 // indirect
|
||||
github.com/starskey-io/starskey v0.1.9 // indirect
|
||||
github.com/zalando/go-keyring v0.2.6 // indirect
|
||||
github.com/zeebo/xxh3 v1.0.2 // indirect
|
||||
go.mongodb.org/mongo-driver v1.17.2 // indirect
|
||||
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
|
||||
go.opentelemetry.io/otel v1.38.0 // indirect
|
||||
go.opentelemetry.io/otel/metric v1.38.0 // indirect
|
||||
|
||||
26
go.sum
@@ -1,3 +1,5 @@
|
||||
al.essio.dev/pkg/shellescape v1.5.1 h1:86HrALUujYS/h+GtqoB26SBEdkWfmMI6FubjXlsXyho=
|
||||
al.essio.dev/pkg/shellescape v1.5.1/go.mod h1:6sIqp7X2P6mThCQ7twERpZTuigpr6KbZWtls1U8I890=
|
||||
github.com/DataDog/zstd v1.5.7 h1:ybO8RBeh29qrxIhCA9E8gKY6xfONU9T6G6aP9DTKfLE=
|
||||
github.com/DataDog/zstd v1.5.7/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw=
|
||||
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
|
||||
@@ -23,6 +25,8 @@ github.com/cockroachdb/redact v1.1.6/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZ
|
||||
github.com/cockroachdb/tokenbucket v0.0.0-20250429170803-42689b6311bb h1:3bCgBvB8PbJVMX1ouCcSIxvsqKPYM7gs72o0zC76n9g=
|
||||
github.com/cockroachdb/tokenbucket v0.0.0-20250429170803-42689b6311bb/go.mod h1:7nc4anLGjupUW/PeY5qiNYsdNXj7zopG+eqsS7To5IQ=
|
||||
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||
github.com/danieljoos/wincred v1.2.2 h1:774zMFJrqaeYCK2W57BgAem/MLi6mtSE47MB6BOJ0i0=
|
||||
github.com/danieljoos/wincred v1.2.2/go.mod h1:w7w4Utbrz8lqeMbDAK0lkNJUv5sAOkFi7nd/ogr0Uh8=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/dgraph-io/badger/v4 v4.8.0 h1:JYph1ChBijCw8SLeybvPINizbDKWZ5n/GYbz2yhN/bs=
|
||||
@@ -45,6 +49,8 @@ github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI=
|
||||
github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
||||
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
|
||||
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
|
||||
github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk=
|
||||
github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
||||
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
|
||||
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
@@ -63,14 +69,26 @@ github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI
|
||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||
github.com/klauspost/compress v1.18.1 h1:bcSGx7UbpBqMChDtsF28Lw6v/G94LPrrbMbdC3JH2co=
|
||||
github.com/klauspost/compress v1.18.1/go.mod h1:ZQFFVG+MdnR0P+l6wpXgIL4NTtwiKIdBnrBd8Nrxr+0=
|
||||
github.com/klauspost/cpuid/v2 v2.0.9 h1:lgaqFMSdTdQYdZ04uHyN2d/eKdOMyi2YLSvlQIBFYa4=
|
||||
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
|
||||
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
||||
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/ledgerwatch/lmdb-go v1.18.2 h1:6YKp/KYcqGunNRHKZBBhiYADcIcWKzvu5QZv89RhnFQ=
|
||||
github.com/ledgerwatch/lmdb-go v1.18.2/go.mod h1:NKRpCxksoTQPyxsUcBiVOe0135uqnJsnf6cElxmOL0o=
|
||||
github.com/mappu/autoconfig v0.1.0 h1:T740iW7/rkqi+pxJIlP+WB433h34jNRjqqG9ABTSScs=
|
||||
github.com/mappu/autoconfig v0.1.0/go.mod h1:kca6kaYjqOwkZnY9z5YKo0oI/7Bxe2fMIHhYzXwGHEE=
|
||||
github.com/mappu/autoconfig v0.2.0 h1:5auhryqiubVBFq9CdY+VHU36bysG70tRGPpyT+M4ycs=
|
||||
github.com/mappu/autoconfig v0.2.0/go.mod h1:kca6kaYjqOwkZnY9z5YKo0oI/7Bxe2fMIHhYzXwGHEE=
|
||||
github.com/mappu/autoconfig v0.3.1-0.20251126064959-64718706eb2a h1:3vhzzO7RLT9qx3kWaPrHTS52pt7ENCRNbeJlkyWfEzw=
|
||||
github.com/mappu/autoconfig v0.3.1-0.20251126064959-64718706eb2a/go.mod h1:kca6kaYjqOwkZnY9z5YKo0oI/7Bxe2fMIHhYzXwGHEE=
|
||||
github.com/mappu/autoconfig v0.4.0 h1:MlclKKe1aAInei2V06uLE4wm4UlFxDAW+tMt/G/wlgY=
|
||||
github.com/mappu/autoconfig v0.4.0/go.mod h1:kca6kaYjqOwkZnY9z5YKo0oI/7Bxe2fMIHhYzXwGHEE=
|
||||
github.com/mappu/autoconfig v0.4.1-0.20251203061113-3f3e7118918b h1:8GyYnPw4E7YRaKeM0NzA9IsM/OqjkjaIec10W7i/UWs=
|
||||
github.com/mappu/autoconfig v0.4.1-0.20251203061113-3f3e7118918b/go.mod h1:kca6kaYjqOwkZnY9z5YKo0oI/7Bxe2fMIHhYzXwGHEE=
|
||||
github.com/mappu/autoconfig v0.4.1 h1:ekO7mzN+beFu7VhNfJxNlL/5wkYcP9PAl9VTG4EDxYs=
|
||||
github.com/mappu/autoconfig v0.4.1/go.mod h1:kca6kaYjqOwkZnY9z5YKo0oI/7Bxe2fMIHhYzXwGHEE=
|
||||
github.com/mappu/miqt v0.12.0 h1:bBMBDeACmV8TbdLfoN51la7kF6QT3sNAcG+ZdRDgmxU=
|
||||
github.com/mappu/miqt v0.12.0/go.mod h1:xFg7ADaO1QSkmXPsPODoKe/bydJpRG9fgCYyIDl/h1U=
|
||||
github.com/mappu/miqt v0.12.1-0.20251106063543-466b60e47edf h1:SmBzNUevLUzu1msJ5xzWH/Kot+GtOtoz0u9la42dRU4=
|
||||
@@ -104,14 +122,22 @@ github.com/redis/go-redis/v9 v9.16.0/go.mod h1:u410H11HMLoB+TP67dz8rL9s6QW2j76l0
|
||||
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
|
||||
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
|
||||
github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
|
||||
github.com/starskey-io/starskey v0.1.9 h1:lABmD5KQgkpJZTCwSt+BHSOPXe82B9smbuScRL6T8Zk=
|
||||
github.com/starskey-io/starskey v0.1.9/go.mod h1:qly4ec2C/4Y45jhpL+q4m+Uxzg3mjj0t7RjpJslB3ao=
|
||||
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
|
||||
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
|
||||
github.com/syndtr/goleveldb v1.0.0 h1:fBdIW9lB4Iz0n9khmH8w27SJ3QEJ7+IgjPEwGSZiFdE=
|
||||
github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpPAyBWyWuQ=
|
||||
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/zalando/go-keyring v0.2.6 h1:r7Yc3+H+Ux0+M72zacZoItR3UDxeWfKTcabvkI8ua9s=
|
||||
github.com/zalando/go-keyring v0.2.6/go.mod h1:2TCrxYrbUNYfNS/Kgy/LSrkSQzZ5UPVH85RwfczwvcI=
|
||||
github.com/zeebo/xxh3 v1.0.2 h1:xZmwmqxHZA8AI603jOQ0tMqmBr9lPeFwGg6d+xy9DC0=
|
||||
github.com/zeebo/xxh3 v1.0.2/go.mod h1:5NWz9Sef7zIDm2JHfFlcQvNekmcEl9ekUZQQKCYaDcA=
|
||||
go.etcd.io/bbolt v1.4.3 h1:dEadXpI6G79deX5prL3QRNP6JB8UxVkqo4UPnHaNXJo=
|
||||
go.etcd.io/bbolt v1.4.3/go.mod h1:tKQlpPaYCVFctUIgFKFnAlvbmB3tpy1vkTnDWohtc0E=
|
||||
go.mongodb.org/mongo-driver v1.17.2 h1:gvZyk8352qSfzyZ2UMWcpDpMSGEr1eqE4T793SqyhzM=
|
||||
go.mongodb.org/mongo-driver v1.17.2/go.mod h1:Hy04i7O2kC4RS06ZrhPRqj/u4DTYkFDAAccj+rVKqgQ=
|
||||
go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64=
|
||||
go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y=
|
||||
go.opentelemetry.io/otel v1.38.0 h1:RkfdswUDRimDg0m2Az18RKOsnI8UDzppJAtj01/Ymk8=
|
||||
|
||||
146
main.go
@@ -1,13 +1,11 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"runtime"
|
||||
"runtime/debug"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
qt "github.com/mappu/miqt/qt6"
|
||||
@@ -51,26 +49,14 @@ func newApp() *App {
|
||||
|
||||
a.ui = NewMainWindowUi()
|
||||
|
||||
// "Midlight" is pretty close on Breeze but wrong on Fusion and Windows
|
||||
// AlternateBase ^
|
||||
// Window --> too dark
|
||||
// Button --> too light on Breeze; close on Fusion; too light on Windows
|
||||
// Light --> too light on Breeze; correct on Fusion; too light on Windows
|
||||
|
||||
currentStyle := strings.ToLower(qt.QApplication_Style().Name())
|
||||
|
||||
effectiveTabBackground := qt.QPalette__Window // correct on Windows
|
||||
if currentStyle == "fusion" {
|
||||
effectiveTabBackground = qt.QPalette__Light
|
||||
} else if currentStyle == "breeze" {
|
||||
effectiveTabBackground = qt.QPalette__Midlight // ?? how does this look on dark mode...?
|
||||
}
|
||||
|
||||
a.ui.propertiesBox.Viewport().SetBackgroundRole(effectiveTabBackground)
|
||||
// Using stylesheet works better than picking a palette colour across all
|
||||
// different QStyles
|
||||
a.ui.propertiesBox.SetStyleSheet("background-color: transparent;")
|
||||
|
||||
//
|
||||
|
||||
a.ui.actionConnect.OnTriggered(a.OnMnuConnectClick)
|
||||
a.ui.actionConnectionManager.OnTriggered(a.OnMnuConnectionManagerClick)
|
||||
|
||||
a.ui.actionE_xit.OnTriggered(a.OnMnuFileExitClick)
|
||||
|
||||
@@ -99,10 +85,14 @@ func newApp() *App {
|
||||
|
||||
//
|
||||
|
||||
a.ui.dataRefreshBtn.OnClicked(a.RefreshCurrentItem)
|
||||
a.ui.dataInsertBtn.OnClicked(a.OnDataInsertClick)
|
||||
a.ui.dataDelRowBtn.OnClicked(a.OnDataDeleteRowClick)
|
||||
a.ui.dataCommitBtn.OnClicked(a.OnDataCommitClick)
|
||||
a.ui.actionRefresh.OnTriggered(a.RefreshCurrentItem)
|
||||
a.ui.actionAddRow.OnTriggered(a.OnDataInsertClick)
|
||||
a.ui.actionDelete_row.OnTriggered(a.OnDataDeleteRowClick)
|
||||
a.ui.actionApply_changes.OnTriggered(a.OnDataCommitClick)
|
||||
|
||||
a.ui.actionAbout_Qt.OnTriggered(func() {
|
||||
qt.QMessageBox_AboutQt2(a.ui.MainWindow.QWidget, APPNAME)
|
||||
})
|
||||
|
||||
// contentBox: set editable
|
||||
vcl_clear_grid(a.ui.contentBox)
|
||||
@@ -112,7 +102,7 @@ func newApp() *App {
|
||||
|
||||
// a.ui.queryInput.OnTextChanged(a.OnQueryTextChanged) // apply syntax highlighting
|
||||
|
||||
a.ui.queryExecBtn.OnClicked(a.OnQueryExecute)
|
||||
a.ui.mnuExecute.OnTriggered(a.OnQueryExecute)
|
||||
|
||||
if runtime.GOOS == "windows" {
|
||||
a.ui.queryInput.SetFontFamily("Consolas")
|
||||
@@ -131,11 +121,10 @@ func newApp() *App {
|
||||
}
|
||||
|
||||
func main() {
|
||||
qt.NewQApplication(os.Args)
|
||||
// Qt 6 already uses PassThrough as the default fractional scaling policy,
|
||||
// no need to change anything here
|
||||
|
||||
sort.Slice(registeredDatabases, func(i, j int) bool {
|
||||
return registeredDatabases[i].label < registeredDatabases[j].label
|
||||
}) // might not have been done yet
|
||||
qt.NewQApplication(os.Args)
|
||||
|
||||
app := newApp()
|
||||
app.ui.MainWindow.Show()
|
||||
@@ -179,7 +168,7 @@ func (f *App) OnMenuHelpVersion() {
|
||||
}
|
||||
}
|
||||
|
||||
qt.QMessageBox_About(f.ui.MainWindow.QWidget, APPNAME, info)
|
||||
qt.QMessageBox_About(f.ui.MainWindow.QWidget, APPNAME+" "+appVersion, info)
|
||||
}
|
||||
|
||||
func (f *App) OnNavContextPopup(pos *qt.QPoint) {
|
||||
@@ -296,7 +285,7 @@ func (f *App) OnDataCellEdited(aRow, aCol int) {
|
||||
|
||||
if chk, ok := f.updateRows[aRow]; ok {
|
||||
if slice_contains(chk, aCol) {
|
||||
// nothing to do
|
||||
return // nothing to do
|
||||
} else {
|
||||
chk = append(chk, aCol)
|
||||
f.updateRows[aRow] = chk
|
||||
@@ -309,19 +298,21 @@ func (f *App) OnDataCellEdited(aRow, aCol int) {
|
||||
delete(f.deleteRows, aRow)
|
||||
|
||||
// Recolour the row
|
||||
explicitCol := qt.NewQBrush4(CO_EDIT_EXPLICIT)
|
||||
implicitCol := qt.NewQBrush4(CO_EDIT_IMPLICIT)
|
||||
|
||||
numCols := f.ui.contentBox.ColumnCount()
|
||||
for i := 0; i < numCols; i++ {
|
||||
cell := f.ui.contentBox.Item(aRow, i)
|
||||
vcl_grid_set_row_colour(f.ui.contentBox, aRow, qt.NewQBrush4(CO_EDIT_IMPLICIT))
|
||||
|
||||
if i == aCol {
|
||||
cell.SetBackground(explicitCol)
|
||||
} else {
|
||||
cell.SetBackground(implicitCol) // FIXME preserve explicitCol for other changed cells too!
|
||||
}
|
||||
explicitColour := qt.NewQBrush4(CO_EDIT_EXPLICIT)
|
||||
for _, explicitCol := range f.updateRows[aRow] {
|
||||
|
||||
// NOTICE: This triggers a cellChanged event because we are changing
|
||||
// the cell's background colour. However the recursion is blocked by
|
||||
// the above "nothing to do" check
|
||||
|
||||
cell := f.ui.contentBox.Item(aRow, explicitCol)
|
||||
cell.SetBackground(explicitColour)
|
||||
}
|
||||
|
||||
f.ui.actionApply_changes.SetEnabled(true) // There are currently some edits again
|
||||
}
|
||||
|
||||
func (f *App) OnDataInsertClick() {
|
||||
@@ -345,6 +336,8 @@ func (f *App) OnDataInsertClick() {
|
||||
|
||||
// Scroll to bottom
|
||||
f.ui.contentBox.ScrollToBottom()
|
||||
|
||||
f.ui.actionApply_changes.SetEnabled(true) // There are currently some edits again
|
||||
}
|
||||
|
||||
func (f *App) OnDataDeleteRowClick() {
|
||||
@@ -352,6 +345,11 @@ func (f *App) OnDataDeleteRowClick() {
|
||||
return // Not an active data view
|
||||
}
|
||||
|
||||
f.isEditing = false
|
||||
defer func() {
|
||||
f.isEditing = true
|
||||
}()
|
||||
|
||||
rpos := f.ui.contentBox.CurrentRow()
|
||||
f.deleteRows[rpos] = struct{}{}
|
||||
|
||||
@@ -360,6 +358,8 @@ func (f *App) OnDataDeleteRowClick() {
|
||||
|
||||
// Repaint cells
|
||||
vcl_grid_set_row_colour(f.ui.contentBox, rpos, qt.NewQBrush4(CO_DELETE))
|
||||
|
||||
f.ui.actionApply_changes.SetEnabled(true) // There are currently some edits again
|
||||
}
|
||||
|
||||
func (f *App) OnDataCommitClick() {
|
||||
@@ -394,6 +394,8 @@ func (f *App) OnDataCommitClick() {
|
||||
// Refresh content
|
||||
f.OnNavChange(node, node) // Refresh RHS pane/data content
|
||||
|
||||
f.ui.actionApply_changes.SetEnabled(false) // There are currently no edits again
|
||||
|
||||
// Preserve scroll position
|
||||
// TODO
|
||||
}
|
||||
@@ -506,7 +508,11 @@ func (f *App) OnNavChange(node *qt.QTreeWidgetItem, _ *qt.QTreeWidgetItem) {
|
||||
|
||||
if node != nil {
|
||||
ld = f.getLoadedDatabaseFor(node)
|
||||
bucketPath, _ = f.getBucketPathFor(node) // FIXME suppressing error
|
||||
var err error
|
||||
bucketPath, err = f.getBucketPathFor(node)
|
||||
if err != nil {
|
||||
panic(err) // shouldn't happen
|
||||
}
|
||||
}
|
||||
|
||||
// Reset some controls that the render function is expected to populate
|
||||
@@ -519,7 +525,7 @@ func (f *App) OnNavChange(node *qt.QTreeWidgetItem, _ *qt.QTreeWidgetItem) {
|
||||
|
||||
err := ld.RenderForNav(f.ui, bucketPath) // Handover to the database type's own renderer function
|
||||
if err != nil {
|
||||
qt.QMessageBox_Warning(f.ui.MainWindow.QWidget, APPNAME, err.Error())
|
||||
qt.QMessageBox_Warning(f.ui.MainWindow.QWidget, APPNAME, fmt.Sprintf("Loading contents of bucket %v: %s", bucketPath, err.Error()))
|
||||
|
||||
// Ensure elements are disabled
|
||||
f.ui.contentBox.SetEnabled(false)
|
||||
@@ -527,16 +533,16 @@ func (f *App) OnNavChange(node *qt.QTreeWidgetItem, _ *qt.QTreeWidgetItem) {
|
||||
|
||||
// Toggle the Edit functionality
|
||||
_, ok := ld.(editableLoadedDatabase)
|
||||
f.ui.dataCommitBtn.SetEnabled(ok)
|
||||
f.ui.dataDelRowBtn.SetEnabled(ok)
|
||||
f.ui.dataInsertBtn.SetEnabled(ok)
|
||||
f.ui.actionApply_changes.SetEnabled(false) // will be enabled after add/delete/edit
|
||||
f.ui.actionDelete_row.SetEnabled(ok)
|
||||
f.ui.actionAddRow.SetEnabled(ok)
|
||||
f.isEditing = ok
|
||||
|
||||
// Toggle the Query functionality
|
||||
_, ok = ld.(queryableLoadedDatabase)
|
||||
f.ui.queryInput.SetEnabled(ok)
|
||||
f.ui.queryResult.SetEnabled(ok)
|
||||
f.ui.queryExecBtn.SetEnabled(ok)
|
||||
f.ui.mnuExecute.SetEnabled(ok)
|
||||
|
||||
// We're in charge of common status bar text updates
|
||||
// Find database displayname
|
||||
@@ -561,7 +567,11 @@ func (f *App) DatabaseDisplayName(item *qt.QTreeWidgetItem) string {
|
||||
return item.Text(0)
|
||||
}
|
||||
|
||||
func (f *App) OnNavExpanding(item *qt.QTreeWidgetItem) {
|
||||
func (f *App) handleNavExpansion(item *qt.QTreeWidgetItem, recurseDepth int) {
|
||||
|
||||
if item == nil {
|
||||
panic("Expanding a nil item?")
|
||||
}
|
||||
|
||||
if item.ChildCount() > 0 {
|
||||
// We've already virtual-expanded this item once, don't repeat it
|
||||
@@ -590,21 +600,26 @@ func (f *App) OnNavExpanding(item *qt.QTreeWidgetItem) {
|
||||
return
|
||||
}
|
||||
|
||||
// While we're here - preload one single level deep (not any deeper)
|
||||
// This makes it "seem" like we don't have empty virtual subfolders most of the time
|
||||
if recurseDepth > 0 {
|
||||
// While we're here - preload one single level deep (not any deeper)
|
||||
// This makes it "seem" like we don't have empty virtual subfolders most of the time
|
||||
|
||||
childCt := item.ChildCount()
|
||||
for i := 0; i < childCt; i++ {
|
||||
childCt := item.ChildCount()
|
||||
for i := 0; i < childCt; i++ {
|
||||
|
||||
cc := item.Child(i)
|
||||
f.OnNavExpanding(cc)
|
||||
cc := item.Child(i)
|
||||
f.handleNavExpansion(cc, recurseDepth-1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (f *App) OnNavExpanding(item *qt.QTreeWidgetItem) {
|
||||
f.handleNavExpansion(item, 1)
|
||||
}
|
||||
|
||||
const (
|
||||
LoadedDatabaseIdRole = int(qt.UserRole + 100)
|
||||
BucketPathStringRole = int(qt.UserRole + 101)
|
||||
BucketPathBSliceRole = int(qt.UserRole + 101)
|
||||
DataPrimaryKeyRole = int(qt.UserRole + 102) // sqlite
|
||||
)
|
||||
|
||||
@@ -616,15 +631,9 @@ func (f *App) getLoadedDatabaseFor(item *qt.QTreeWidgetItem) loadedDatabase {
|
||||
|
||||
// getBucketPathFor gets the bucketPath array out of a child nav item.
|
||||
func (f *App) getBucketPathFor(item *qt.QTreeWidgetItem) ([]string, error) {
|
||||
bucketPathJsonArr := item.Data(0, BucketPathStringRole).ToString()
|
||||
bucketPathJsonArr := item.Data(0, BucketPathBSliceRole).ToByteArray()
|
||||
|
||||
var ret []string
|
||||
err := json.Unmarshal([]byte(bucketPathJsonArr), &ret)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return ret, nil
|
||||
return pathlist_decode(bucketPathJsonArr)
|
||||
}
|
||||
|
||||
func (f *App) NavLoadChildren(item *qt.QTreeWidgetItem, bucketPath []string) error {
|
||||
@@ -652,10 +661,13 @@ func (f *App) NavLoadChildren(item *qt.QTreeWidgetItem, bucketPath []string) err
|
||||
childPath = append(childPath, bucketPath...)
|
||||
childPath = append(childPath, bucketName)
|
||||
|
||||
childPathJson, _ := json.Marshal(childPath)
|
||||
childPathJson, err := pathlist_encode(childPath)
|
||||
if err != nil {
|
||||
panic(err) // Shouldn't happen
|
||||
}
|
||||
|
||||
node.SetData(0, LoadedDatabaseIdRole, qt.NewQVariant4(ldID))
|
||||
node.SetData(0, BucketPathStringRole, qt.NewQVariant11(string(childPathJson)))
|
||||
node.SetData(0, BucketPathBSliceRole, qt.NewQVariant12(childPathJson))
|
||||
|
||||
item.AddChild(node)
|
||||
}
|
||||
@@ -675,10 +687,16 @@ func (f *App) addTopLevelDatabaseConnection(ld loadedDatabase, displayName strin
|
||||
f.dbs_next++
|
||||
f.dbs[ldID] = ld
|
||||
|
||||
emptyData, err := pathlist_encode([]string{}) // Initial browse position
|
||||
if err != nil {
|
||||
panic(err) // can't happen
|
||||
}
|
||||
|
||||
nav.SetData(0, LoadedDatabaseIdRole, qt.NewQVariant4(ldID))
|
||||
nav.SetData(0, BucketPathStringRole, qt.NewQVariant11(`[]`)) // empty array
|
||||
nav.SetData(0, BucketPathBSliceRole, qt.NewQVariant12(emptyData))
|
||||
|
||||
f.ui.Buckets.AddTopLevelItem(nav)
|
||||
f.ui.Buckets.SetCurrentItem(nav) // Select new element
|
||||
|
||||
f.handleNavExpansion(nav, 0) // Load child contents but do not recurse further
|
||||
}
|
||||
|
||||
379
mainwindow.go
@@ -10,54 +10,41 @@ import (
|
||||
)
|
||||
|
||||
type MainWindowUi struct {
|
||||
MainWindow *qt.QMainWindow
|
||||
centralwidget *qt.QWidget
|
||||
gridLayout *qt.QGridLayout
|
||||
splitter *qt.QSplitter
|
||||
Buckets *qt.QTreeWidget
|
||||
tabWidget *qt.QTabWidget
|
||||
tabProperties *qt.QWidget
|
||||
gridLayout_2 *qt.QGridLayout
|
||||
propertiesBox *qt.QTextEdit
|
||||
tabData *qt.QWidget
|
||||
verticalLayout *qt.QVBoxLayout
|
||||
horizontalLayout *qt.QHBoxLayout
|
||||
dataRefreshBtn *qt.QToolButton
|
||||
dataInsertBtn *qt.QToolButton
|
||||
dataDelRowBtn *qt.QToolButton
|
||||
dataCommitBtn *qt.QToolButton
|
||||
horizontalSpacer *qt.QSpacerItem
|
||||
contentBox *qt.QTableWidget
|
||||
tabQuery *qt.QWidget
|
||||
verticalLayout_2 *qt.QVBoxLayout
|
||||
horizontalLayout_2 *qt.QHBoxLayout
|
||||
queryExecBtn *qt.QToolButton
|
||||
horizontalSpacer_2 *qt.QSpacerItem
|
||||
splitter_2 *qt.QSplitter
|
||||
queryInput *qt.QTextEdit
|
||||
queryResult *qt.QTableWidget
|
||||
menubar *qt.QMenuBar
|
||||
menu_File *qt.QMenu
|
||||
menu_Query *qt.QMenu
|
||||
menu_Help *qt.QMenu
|
||||
statusbar *qt.QStatusBar
|
||||
actionE_xit *qt.QAction
|
||||
mnuBadgerOpen *qt.QAction
|
||||
mnuBadgerNewInMemory *qt.QAction
|
||||
mnuBoltNew *qt.QAction
|
||||
mnuBoltOpenDatabase *qt.QAction
|
||||
mnuBoltOpenDatabaseReadonly *qt.QAction
|
||||
mnuDebconfOpen *qt.QAction
|
||||
mnuPebbleOpenDatabase *qt.QAction
|
||||
mnuPebbleNewInMemory *qt.QAction
|
||||
mnuRedisConnect *qt.QAction
|
||||
mnuSqliteOpenDatabase *qt.QAction
|
||||
mnuSqliteNewInMemory *qt.QAction
|
||||
mnuSqliteExperimentalDriver *qt.QAction
|
||||
mnuExecute *qt.QAction
|
||||
mnuDriverVersions *qt.QAction
|
||||
mnuHelpAbout *qt.QAction
|
||||
actionConnect *qt.QAction
|
||||
MainWindow *qt.QMainWindow
|
||||
centralwidget *qt.QWidget
|
||||
gridLayout *qt.QGridLayout
|
||||
splitter *qt.QSplitter
|
||||
Buckets *qt.QTreeWidget
|
||||
tabWidget *qt.QTabWidget
|
||||
tabProperties *qt.QWidget
|
||||
gridLayout_2 *qt.QGridLayout
|
||||
propertiesBox *qt.QTextEdit
|
||||
tabData *qt.QWidget
|
||||
verticalLayout *qt.QVBoxLayout
|
||||
contentBox *qt.QTableWidget
|
||||
tabQuery *qt.QWidget
|
||||
verticalLayout_2 *qt.QVBoxLayout
|
||||
splitter_2 *qt.QSplitter
|
||||
queryInput *qt.QTextEdit
|
||||
queryResult *qt.QTableWidget
|
||||
menubar *qt.QMenuBar
|
||||
menu_File *qt.QMenu
|
||||
menu_Query *qt.QMenu
|
||||
menu_Help *qt.QMenu
|
||||
menu_Data *qt.QMenu
|
||||
statusbar *qt.QStatusBar
|
||||
toolBar *qt.QToolBar
|
||||
actionE_xit *qt.QAction
|
||||
mnuExecute *qt.QAction
|
||||
mnuDriverVersions *qt.QAction
|
||||
mnuHelpAbout *qt.QAction
|
||||
actionConnect *qt.QAction
|
||||
actionRefresh *qt.QAction
|
||||
actionAbout_Qt *qt.QAction
|
||||
actionAddRow *qt.QAction
|
||||
actionDelete_row *qt.QAction
|
||||
actionApply_changes *qt.QAction
|
||||
actionConnectionManager *qt.QAction
|
||||
}
|
||||
|
||||
// NewMainWindowUi creates all Qt widget classes for MainWindow.
|
||||
@@ -75,95 +62,14 @@ func NewMainWindowUi() *MainWindowUi {
|
||||
actionE_xit__objectName := qt.NewQAnyStringView3("actionE_xit")
|
||||
ui.actionE_xit.SetObjectName(*actionE_xit__objectName)
|
||||
actionE_xit__objectName.Delete() // setter copied value
|
||||
ui.mnuBadgerOpen = qt.NewQAction()
|
||||
mnuBadgerOpen__objectName := qt.NewQAnyStringView3("mnuBadgerOpen")
|
||||
ui.mnuBadgerOpen.SetObjectName(*mnuBadgerOpen__objectName)
|
||||
mnuBadgerOpen__objectName.Delete() // setter copied value
|
||||
icon1 := qt.NewQIcon()
|
||||
icon1.AddFile4(":/assets/database_add.png", qt.NewQSize(), qt.QIcon__Normal, qt.QIcon__Off)
|
||||
ui.mnuBadgerOpen.SetIcon(icon1)
|
||||
ui.mnuBadgerNewInMemory = qt.NewQAction()
|
||||
mnuBadgerNewInMemory__objectName := qt.NewQAnyStringView3("mnuBadgerNewInMemory")
|
||||
ui.mnuBadgerNewInMemory.SetObjectName(*mnuBadgerNewInMemory__objectName)
|
||||
mnuBadgerNewInMemory__objectName.Delete() // setter copied value
|
||||
icon2 := qt.NewQIcon()
|
||||
icon2.AddFile4(":/assets/database_add.png", qt.NewQSize(), qt.QIcon__Normal, qt.QIcon__Off)
|
||||
ui.mnuBadgerNewInMemory.SetIcon(icon2)
|
||||
ui.mnuBoltNew = qt.NewQAction()
|
||||
mnuBoltNew__objectName := qt.NewQAnyStringView3("mnuBoltNew")
|
||||
ui.mnuBoltNew.SetObjectName(*mnuBoltNew__objectName)
|
||||
mnuBoltNew__objectName.Delete() // setter copied value
|
||||
icon3 := qt.NewQIcon()
|
||||
icon3.AddFile4(":/assets/database_add.png", qt.NewQSize(), qt.QIcon__Normal, qt.QIcon__Off)
|
||||
ui.mnuBoltNew.SetIcon(icon3)
|
||||
ui.mnuBoltOpenDatabase = qt.NewQAction()
|
||||
mnuBoltOpenDatabase__objectName := qt.NewQAnyStringView3("mnuBoltOpenDatabase")
|
||||
ui.mnuBoltOpenDatabase.SetObjectName(*mnuBoltOpenDatabase__objectName)
|
||||
mnuBoltOpenDatabase__objectName.Delete() // setter copied value
|
||||
icon4 := qt.NewQIcon()
|
||||
icon4.AddFile4(":/assets/database_add.png", qt.NewQSize(), qt.QIcon__Normal, qt.QIcon__Off)
|
||||
ui.mnuBoltOpenDatabase.SetIcon(icon4)
|
||||
ui.mnuBoltOpenDatabaseReadonly = qt.NewQAction()
|
||||
mnuBoltOpenDatabaseReadonly__objectName := qt.NewQAnyStringView3("mnuBoltOpenDatabaseReadonly")
|
||||
ui.mnuBoltOpenDatabaseReadonly.SetObjectName(*mnuBoltOpenDatabaseReadonly__objectName)
|
||||
mnuBoltOpenDatabaseReadonly__objectName.Delete() // setter copied value
|
||||
icon5 := qt.NewQIcon()
|
||||
icon5.AddFile4(":/assets/database_add.png", qt.NewQSize(), qt.QIcon__Normal, qt.QIcon__Off)
|
||||
ui.mnuBoltOpenDatabaseReadonly.SetIcon(icon5)
|
||||
ui.mnuDebconfOpen = qt.NewQAction()
|
||||
mnuDebconfOpen__objectName := qt.NewQAnyStringView3("mnuDebconfOpen")
|
||||
ui.mnuDebconfOpen.SetObjectName(*mnuDebconfOpen__objectName)
|
||||
mnuDebconfOpen__objectName.Delete() // setter copied value
|
||||
icon6 := qt.NewQIcon()
|
||||
icon6.AddFile4(":/assets/database_add.png", qt.NewQSize(), qt.QIcon__Normal, qt.QIcon__Off)
|
||||
ui.mnuDebconfOpen.SetIcon(icon6)
|
||||
ui.mnuPebbleOpenDatabase = qt.NewQAction()
|
||||
mnuPebbleOpenDatabase__objectName := qt.NewQAnyStringView3("mnuPebbleOpenDatabase")
|
||||
ui.mnuPebbleOpenDatabase.SetObjectName(*mnuPebbleOpenDatabase__objectName)
|
||||
mnuPebbleOpenDatabase__objectName.Delete() // setter copied value
|
||||
icon7 := qt.NewQIcon()
|
||||
icon7.AddFile4(":/assets/database_add.png", qt.NewQSize(), qt.QIcon__Normal, qt.QIcon__Off)
|
||||
ui.mnuPebbleOpenDatabase.SetIcon(icon7)
|
||||
ui.mnuPebbleNewInMemory = qt.NewQAction()
|
||||
mnuPebbleNewInMemory__objectName := qt.NewQAnyStringView3("mnuPebbleNewInMemory")
|
||||
ui.mnuPebbleNewInMemory.SetObjectName(*mnuPebbleNewInMemory__objectName)
|
||||
mnuPebbleNewInMemory__objectName.Delete() // setter copied value
|
||||
icon8 := qt.NewQIcon()
|
||||
icon8.AddFile4(":/assets/database_add.png", qt.NewQSize(), qt.QIcon__Normal, qt.QIcon__Off)
|
||||
ui.mnuPebbleNewInMemory.SetIcon(icon8)
|
||||
ui.mnuRedisConnect = qt.NewQAction()
|
||||
mnuRedisConnect__objectName := qt.NewQAnyStringView3("mnuRedisConnect")
|
||||
ui.mnuRedisConnect.SetObjectName(*mnuRedisConnect__objectName)
|
||||
mnuRedisConnect__objectName.Delete() // setter copied value
|
||||
icon9 := qt.NewQIcon()
|
||||
icon9.AddFile4(":/assets/database_add.png", qt.NewQSize(), qt.QIcon__Normal, qt.QIcon__Off)
|
||||
ui.mnuRedisConnect.SetIcon(icon9)
|
||||
ui.mnuSqliteOpenDatabase = qt.NewQAction()
|
||||
mnuSqliteOpenDatabase__objectName := qt.NewQAnyStringView3("mnuSqliteOpenDatabase")
|
||||
ui.mnuSqliteOpenDatabase.SetObjectName(*mnuSqliteOpenDatabase__objectName)
|
||||
mnuSqliteOpenDatabase__objectName.Delete() // setter copied value
|
||||
icon10 := qt.NewQIcon()
|
||||
icon10.AddFile4(":/assets/database_add.png", qt.NewQSize(), qt.QIcon__Normal, qt.QIcon__Off)
|
||||
ui.mnuSqliteOpenDatabase.SetIcon(icon10)
|
||||
ui.mnuSqliteNewInMemory = qt.NewQAction()
|
||||
mnuSqliteNewInMemory__objectName := qt.NewQAnyStringView3("mnuSqliteNewInMemory")
|
||||
ui.mnuSqliteNewInMemory.SetObjectName(*mnuSqliteNewInMemory__objectName)
|
||||
mnuSqliteNewInMemory__objectName.Delete() // setter copied value
|
||||
icon11 := qt.NewQIcon()
|
||||
icon11.AddFile4(":/assets/database_add.png", qt.NewQSize(), qt.QIcon__Normal, qt.QIcon__Off)
|
||||
ui.mnuSqliteNewInMemory.SetIcon(icon11)
|
||||
ui.mnuSqliteExperimentalDriver = qt.NewQAction()
|
||||
mnuSqliteExperimentalDriver__objectName := qt.NewQAnyStringView3("mnuSqliteExperimentalDriver")
|
||||
ui.mnuSqliteExperimentalDriver.SetObjectName(*mnuSqliteExperimentalDriver__objectName)
|
||||
mnuSqliteExperimentalDriver__objectName.Delete() // setter copied value
|
||||
/* miqt-uic: no handler for QAction property 'checkable' */
|
||||
/* miqt-uic: no handler for QAction property 'menuRole' */
|
||||
ui.mnuExecute = qt.NewQAction()
|
||||
mnuExecute__objectName := qt.NewQAnyStringView3("mnuExecute")
|
||||
ui.mnuExecute.SetObjectName(*mnuExecute__objectName)
|
||||
mnuExecute__objectName.Delete() // setter copied value
|
||||
icon12 := qt.NewQIcon()
|
||||
icon12.AddFile4(":/assets/resultset_next.png", qt.NewQSize(), qt.QIcon__Normal, qt.QIcon__Off)
|
||||
ui.mnuExecute.SetIcon(icon12)
|
||||
icon1 := qt.NewQIcon()
|
||||
icon1.AddFile4(":/assets/resultset_next.png", qt.NewQSize(), qt.QIcon__Normal, qt.QIcon__Off)
|
||||
ui.mnuExecute.SetIcon(icon1)
|
||||
ui.mnuDriverVersions = qt.NewQAction()
|
||||
mnuDriverVersions__objectName := qt.NewQAnyStringView3("mnuDriverVersions")
|
||||
ui.mnuDriverVersions.SetObjectName(*mnuDriverVersions__objectName)
|
||||
@@ -172,13 +78,65 @@ func NewMainWindowUi() *MainWindowUi {
|
||||
mnuHelpAbout__objectName := qt.NewQAnyStringView3("mnuHelpAbout")
|
||||
ui.mnuHelpAbout.SetObjectName(*mnuHelpAbout__objectName)
|
||||
mnuHelpAbout__objectName.Delete() // setter copied value
|
||||
icon2 := qt.NewQIcon()
|
||||
icon2.AddFile4(":/assets/help.png", qt.NewQSize(), qt.QIcon__Normal, qt.QIcon__Off)
|
||||
ui.mnuHelpAbout.SetIcon(icon2)
|
||||
/* miqt-uic: no handler for QAction property 'menuRole' */
|
||||
ui.actionConnect = qt.NewQAction()
|
||||
actionConnect__objectName := qt.NewQAnyStringView3("actionConnect")
|
||||
ui.actionConnect.SetObjectName(*actionConnect__objectName)
|
||||
actionConnect__objectName.Delete() // setter copied value
|
||||
icon13 := qt.NewQIcon()
|
||||
icon13.AddFile4(":/assets/database_add.png", qt.NewQSize(), qt.QIcon__Normal, qt.QIcon__Off)
|
||||
ui.actionConnect.SetIcon(icon13)
|
||||
icon3 := qt.NewQIcon()
|
||||
icon3.AddFile4(":/assets/database_add.png", qt.NewQSize(), qt.QIcon__Normal, qt.QIcon__Off)
|
||||
ui.actionConnect.SetIcon(icon3)
|
||||
ui.actionRefresh = qt.NewQAction()
|
||||
actionRefresh__objectName := qt.NewQAnyStringView3("actionRefresh")
|
||||
ui.actionRefresh.SetObjectName(*actionRefresh__objectName)
|
||||
actionRefresh__objectName.Delete() // setter copied value
|
||||
icon4 := qt.NewQIcon()
|
||||
icon4.AddFile4(":/assets/arrow_refresh.png", qt.NewQSize(), qt.QIcon__Normal, qt.QIcon__Off)
|
||||
ui.actionRefresh.SetIcon(icon4)
|
||||
/* miqt-uic: no handler for QAction property 'menuRole' */
|
||||
ui.actionAbout_Qt = qt.NewQAction()
|
||||
actionAbout_Qt__objectName := qt.NewQAnyStringView3("actionAbout_Qt")
|
||||
ui.actionAbout_Qt.SetObjectName(*actionAbout_Qt__objectName)
|
||||
actionAbout_Qt__objectName.Delete() // setter copied value
|
||||
icon5 := qt.NewQIcon()
|
||||
icon5.AddFile4(":/assets/vendor_qt.png", qt.NewQSize(), qt.QIcon__Normal, qt.QIcon__Off)
|
||||
ui.actionAbout_Qt.SetIcon(icon5)
|
||||
/* miqt-uic: no handler for QAction property 'menuRole' */
|
||||
ui.actionAddRow = qt.NewQAction()
|
||||
actionAddRow__objectName := qt.NewQAnyStringView3("actionAddRow")
|
||||
ui.actionAddRow.SetObjectName(*actionAddRow__objectName)
|
||||
actionAddRow__objectName.Delete() // setter copied value
|
||||
icon6 := qt.NewQIcon()
|
||||
icon6.AddFile4(":/assets/add.png", qt.NewQSize(), qt.QIcon__Normal, qt.QIcon__Off)
|
||||
ui.actionAddRow.SetIcon(icon6)
|
||||
/* miqt-uic: no handler for QAction property 'menuRole' */
|
||||
ui.actionDelete_row = qt.NewQAction()
|
||||
actionDelete_row__objectName := qt.NewQAnyStringView3("actionDelete_row")
|
||||
ui.actionDelete_row.SetObjectName(*actionDelete_row__objectName)
|
||||
actionDelete_row__objectName.Delete() // setter copied value
|
||||
icon7 := qt.NewQIcon()
|
||||
icon7.AddFile4(":/assets/delete.png", qt.NewQSize(), qt.QIcon__Normal, qt.QIcon__Off)
|
||||
ui.actionDelete_row.SetIcon(icon7)
|
||||
/* miqt-uic: no handler for QAction property 'menuRole' */
|
||||
ui.actionApply_changes = qt.NewQAction()
|
||||
actionApply_changes__objectName := qt.NewQAnyStringView3("actionApply_changes")
|
||||
ui.actionApply_changes.SetObjectName(*actionApply_changes__objectName)
|
||||
actionApply_changes__objectName.Delete() // setter copied value
|
||||
icon8 := qt.NewQIcon()
|
||||
icon8.AddFile4(":/assets/pencil_go.png", qt.NewQSize(), qt.QIcon__Normal, qt.QIcon__Off)
|
||||
ui.actionApply_changes.SetIcon(icon8)
|
||||
/* miqt-uic: no handler for QAction property 'menuRole' */
|
||||
ui.actionConnectionManager = qt.NewQAction()
|
||||
actionConnectionManager__objectName := qt.NewQAnyStringView3("actionConnectionManager")
|
||||
ui.actionConnectionManager.SetObjectName(*actionConnectionManager__objectName)
|
||||
actionConnectionManager__objectName.Delete() // setter copied value
|
||||
icon9 := qt.NewQIcon()
|
||||
icon9.AddFile4(":/assets/database_key.png", qt.NewQSize(), qt.QIcon__Normal, qt.QIcon__Off)
|
||||
ui.actionConnectionManager.SetIcon(icon9)
|
||||
/* miqt-uic: no handler for QAction property 'menuRole' */
|
||||
ui.centralwidget = qt.NewQWidget(ui.MainWindow.QWidget)
|
||||
centralwidget__objectName := qt.NewQAnyStringView3("centralwidget")
|
||||
ui.centralwidget.SetObjectName(*centralwidget__objectName)
|
||||
@@ -234,9 +192,9 @@ func NewMainWindowUi() *MainWindowUi {
|
||||
ui.propertiesBox.SetReadOnly(true)
|
||||
|
||||
ui.gridLayout_2.AddWidget2(ui.propertiesBox.QWidget, 0, 0)
|
||||
icon14 := qt.NewQIcon()
|
||||
icon14.AddFile4(":/assets/chart_bar.png", qt.NewQSize(), qt.QIcon__Normal, qt.QIcon__Off)
|
||||
ui.tabWidget.AddTab2(ui.tabProperties, icon14, "")
|
||||
icon10 := qt.NewQIcon()
|
||||
icon10.AddFile4(":/assets/chart_bar.png", qt.NewQSize(), qt.QIcon__Normal, qt.QIcon__Off)
|
||||
ui.tabWidget.AddTab2(ui.tabProperties, icon10, "")
|
||||
ui.tabData = qt.NewQWidget(ui.tabWidget.QWidget)
|
||||
tabData__objectName := qt.NewQAnyStringView3("tabData")
|
||||
ui.tabData.SetObjectName(*tabData__objectName)
|
||||
@@ -247,57 +205,6 @@ func NewMainWindowUi() *MainWindowUi {
|
||||
verticalLayout__objectName.Delete() // setter copied value
|
||||
ui.verticalLayout.SetContentsMargins(11, 11, 11, 11)
|
||||
ui.verticalLayout.SetSpacing(6)
|
||||
ui.horizontalLayout = qt.NewQHBoxLayout2()
|
||||
horizontalLayout__objectName := qt.NewQAnyStringView3("horizontalLayout")
|
||||
ui.horizontalLayout.SetObjectName(*horizontalLayout__objectName)
|
||||
horizontalLayout__objectName.Delete() // setter copied value
|
||||
ui.horizontalLayout.SetContentsMargins(0, 0, 0, 0)
|
||||
ui.horizontalLayout.SetSpacing(6)
|
||||
ui.dataRefreshBtn = qt.NewQToolButton(ui.tabData)
|
||||
dataRefreshBtn__objectName := qt.NewQAnyStringView3("dataRefreshBtn")
|
||||
ui.dataRefreshBtn.SetObjectName(*dataRefreshBtn__objectName)
|
||||
dataRefreshBtn__objectName.Delete() // setter copied value
|
||||
icon15 := qt.NewQIcon()
|
||||
icon15.AddFile4(":/assets/arrow_refresh.png", qt.NewQSize(), qt.QIcon__Normal, qt.QIcon__Off)
|
||||
ui.dataRefreshBtn.SetIcon(icon15)
|
||||
ui.dataRefreshBtn.SetAutoRaise(true)
|
||||
|
||||
ui.horizontalLayout.AddWidget(ui.dataRefreshBtn.QWidget)
|
||||
ui.dataInsertBtn = qt.NewQToolButton(ui.tabData)
|
||||
dataInsertBtn__objectName := qt.NewQAnyStringView3("dataInsertBtn")
|
||||
ui.dataInsertBtn.SetObjectName(*dataInsertBtn__objectName)
|
||||
dataInsertBtn__objectName.Delete() // setter copied value
|
||||
icon16 := qt.NewQIcon()
|
||||
icon16.AddFile4(":/assets/add.png", qt.NewQSize(), qt.QIcon__Normal, qt.QIcon__Off)
|
||||
ui.dataInsertBtn.SetIcon(icon16)
|
||||
ui.dataInsertBtn.SetAutoRaise(true)
|
||||
|
||||
ui.horizontalLayout.AddWidget(ui.dataInsertBtn.QWidget)
|
||||
ui.dataDelRowBtn = qt.NewQToolButton(ui.tabData)
|
||||
dataDelRowBtn__objectName := qt.NewQAnyStringView3("dataDelRowBtn")
|
||||
ui.dataDelRowBtn.SetObjectName(*dataDelRowBtn__objectName)
|
||||
dataDelRowBtn__objectName.Delete() // setter copied value
|
||||
icon17 := qt.NewQIcon()
|
||||
icon17.AddFile4(":/assets/delete.png", qt.NewQSize(), qt.QIcon__Normal, qt.QIcon__Off)
|
||||
ui.dataDelRowBtn.SetIcon(icon17)
|
||||
ui.dataDelRowBtn.SetAutoRaise(true)
|
||||
|
||||
ui.horizontalLayout.AddWidget(ui.dataDelRowBtn.QWidget)
|
||||
ui.dataCommitBtn = qt.NewQToolButton(ui.tabData)
|
||||
dataCommitBtn__objectName := qt.NewQAnyStringView3("dataCommitBtn")
|
||||
ui.dataCommitBtn.SetObjectName(*dataCommitBtn__objectName)
|
||||
dataCommitBtn__objectName.Delete() // setter copied value
|
||||
icon18 := qt.NewQIcon()
|
||||
icon18.AddFile4(":/assets/pencil_go.png", qt.NewQSize(), qt.QIcon__Normal, qt.QIcon__Off)
|
||||
ui.dataCommitBtn.SetIcon(icon18)
|
||||
ui.dataCommitBtn.SetAutoRaise(true)
|
||||
|
||||
ui.horizontalLayout.AddWidget(ui.dataCommitBtn.QWidget)
|
||||
ui.horizontalSpacer = qt.NewQSpacerItem4(40, 20, qt.QSizePolicy__Expanding, qt.QSizePolicy__Minimum)
|
||||
|
||||
ui.horizontalLayout.AddItem(ui.horizontalSpacer.QLayoutItem)
|
||||
|
||||
ui.verticalLayout.AddLayout(ui.horizontalLayout.QLayout)
|
||||
ui.contentBox = qt.NewQTableWidget(ui.tabData)
|
||||
contentBox__objectName := qt.NewQAnyStringView3("contentBox")
|
||||
ui.contentBox.SetObjectName(*contentBox__objectName)
|
||||
@@ -306,9 +213,9 @@ func NewMainWindowUi() *MainWindowUi {
|
||||
ui.contentBox.SetHorizontalScrollMode(qt.QAbstractItemView__ScrollPerPixel)
|
||||
|
||||
ui.verticalLayout.AddWidget(ui.contentBox.QWidget)
|
||||
icon19 := qt.NewQIcon()
|
||||
icon19.AddFile4(":/assets/table.png", qt.NewQSize(), qt.QIcon__Normal, qt.QIcon__Off)
|
||||
ui.tabWidget.AddTab2(ui.tabData, icon19, "")
|
||||
icon11 := qt.NewQIcon()
|
||||
icon11.AddFile4(":/assets/table.png", qt.NewQSize(), qt.QIcon__Normal, qt.QIcon__Off)
|
||||
ui.tabWidget.AddTab2(ui.tabData, icon11, "")
|
||||
ui.tabQuery = qt.NewQWidget(ui.tabWidget.QWidget)
|
||||
tabQuery__objectName := qt.NewQAnyStringView3("tabQuery")
|
||||
ui.tabQuery.SetObjectName(*tabQuery__objectName)
|
||||
@@ -319,27 +226,6 @@ func NewMainWindowUi() *MainWindowUi {
|
||||
verticalLayout_2__objectName.Delete() // setter copied value
|
||||
ui.verticalLayout_2.SetContentsMargins(11, 11, 11, 11)
|
||||
ui.verticalLayout_2.SetSpacing(6)
|
||||
ui.horizontalLayout_2 = qt.NewQHBoxLayout2()
|
||||
horizontalLayout_2__objectName := qt.NewQAnyStringView3("horizontalLayout_2")
|
||||
ui.horizontalLayout_2.SetObjectName(*horizontalLayout_2__objectName)
|
||||
horizontalLayout_2__objectName.Delete() // setter copied value
|
||||
ui.horizontalLayout_2.SetContentsMargins(0, 0, 0, 0)
|
||||
ui.horizontalLayout_2.SetSpacing(6)
|
||||
ui.queryExecBtn = qt.NewQToolButton(ui.tabQuery)
|
||||
queryExecBtn__objectName := qt.NewQAnyStringView3("queryExecBtn")
|
||||
ui.queryExecBtn.SetObjectName(*queryExecBtn__objectName)
|
||||
queryExecBtn__objectName.Delete() // setter copied value
|
||||
icon20 := qt.NewQIcon()
|
||||
icon20.AddFile4(":/assets/resultset_next.png", qt.NewQSize(), qt.QIcon__Normal, qt.QIcon__Off)
|
||||
ui.queryExecBtn.SetIcon(icon20)
|
||||
ui.queryExecBtn.SetAutoRaise(true)
|
||||
|
||||
ui.horizontalLayout_2.AddWidget(ui.queryExecBtn.QWidget)
|
||||
ui.horizontalSpacer_2 = qt.NewQSpacerItem4(40, 20, qt.QSizePolicy__Expanding, qt.QSizePolicy__Minimum)
|
||||
|
||||
ui.horizontalLayout_2.AddItem(ui.horizontalSpacer_2.QLayoutItem)
|
||||
|
||||
ui.verticalLayout_2.AddLayout(ui.horizontalLayout_2.QLayout)
|
||||
ui.splitter_2 = qt.NewQSplitter(ui.tabQuery)
|
||||
splitter_2__objectName := qt.NewQAnyStringView3("splitter_2")
|
||||
ui.splitter_2.SetObjectName(*splitter_2__objectName)
|
||||
@@ -361,9 +247,9 @@ func NewMainWindowUi() *MainWindowUi {
|
||||
ui.splitter_2.AddWidget(ui.queryResult.QWidget)
|
||||
|
||||
ui.verticalLayout_2.AddWidget(ui.splitter_2.QWidget)
|
||||
icon21 := qt.NewQIcon()
|
||||
icon21.AddFile4(":/assets/lightning.png", qt.NewQSize(), qt.QIcon__Normal, qt.QIcon__Off)
|
||||
ui.tabWidget.AddTab2(ui.tabQuery, icon21, "")
|
||||
icon12 := qt.NewQIcon()
|
||||
icon12.AddFile4(":/assets/lightning.png", qt.NewQSize(), qt.QIcon__Normal, qt.QIcon__Off)
|
||||
ui.tabWidget.AddTab2(ui.tabQuery, icon12, "")
|
||||
ui.splitter.AddWidget(ui.tabWidget.QWidget)
|
||||
|
||||
ui.gridLayout.AddWidget2(ui.splitter.QWidget, 0, 0)
|
||||
@@ -377,6 +263,7 @@ func NewMainWindowUi() *MainWindowUi {
|
||||
menu_File__objectName := qt.NewQAnyStringView3("menu_File")
|
||||
ui.menu_File.SetObjectName(*menu_File__objectName)
|
||||
menu_File__objectName.Delete() // setter copied value
|
||||
ui.menu_File.QWidget.AddAction(ui.actionConnectionManager)
|
||||
ui.menu_File.QWidget.AddAction(ui.actionConnect)
|
||||
ui.menu_File.AddSeparator()
|
||||
ui.menu_File.QWidget.AddAction(ui.actionE_xit)
|
||||
@@ -390,8 +277,20 @@ func NewMainWindowUi() *MainWindowUi {
|
||||
ui.menu_Help.SetObjectName(*menu_Help__objectName)
|
||||
menu_Help__objectName.Delete() // setter copied value
|
||||
ui.menu_Help.QWidget.AddAction(ui.mnuDriverVersions)
|
||||
ui.menu_Help.AddSeparator()
|
||||
ui.menu_Help.QWidget.AddAction(ui.actionAbout_Qt)
|
||||
ui.menu_Help.QWidget.AddAction(ui.mnuHelpAbout)
|
||||
ui.menu_Data = qt.NewQMenu(ui.menubar.QWidget)
|
||||
menu_Data__objectName := qt.NewQAnyStringView3("menu_Data")
|
||||
ui.menu_Data.SetObjectName(*menu_Data__objectName)
|
||||
menu_Data__objectName.Delete() // setter copied value
|
||||
ui.menu_Data.QWidget.AddAction(ui.actionRefresh)
|
||||
ui.menu_Data.AddSeparator()
|
||||
ui.menu_Data.QWidget.AddAction(ui.actionAddRow)
|
||||
ui.menu_Data.QWidget.AddAction(ui.actionDelete_row)
|
||||
ui.menu_Data.QWidget.AddAction(ui.actionApply_changes)
|
||||
ui.menubar.AddMenu(ui.menu_File)
|
||||
ui.menubar.AddMenu(ui.menu_Data)
|
||||
ui.menubar.AddMenu(ui.menu_Query)
|
||||
ui.menubar.AddMenu(ui.menu_Help)
|
||||
ui.MainWindow.SetMenuBar(ui.menubar)
|
||||
@@ -400,6 +299,23 @@ func NewMainWindowUi() *MainWindowUi {
|
||||
ui.statusbar.SetObjectName(*statusbar__objectName)
|
||||
statusbar__objectName.Delete() // setter copied value
|
||||
ui.MainWindow.SetStatusBar(ui.statusbar)
|
||||
ui.toolBar = qt.NewQToolBar(ui.MainWindow.QWidget)
|
||||
toolBar__objectName := qt.NewQAnyStringView3("toolBar")
|
||||
ui.toolBar.SetObjectName(*toolBar__objectName)
|
||||
toolBar__objectName.Delete() // setter copied value
|
||||
/* miqt-uic: no handler for toolBar property 'iconSize' */
|
||||
ui.toolBar.SetToolButtonStyle(qt.ToolButtonIconOnly)
|
||||
ui.MainWindow.AddToolBar(qt.TopToolBarArea, ui.toolBar)
|
||||
/* miqt-uic: no handler for toolBar attribute 'toolBarBreak' */
|
||||
ui.toolBar.QWidget.AddAction(ui.actionConnectionManager)
|
||||
ui.toolBar.QWidget.AddAction(ui.actionConnect)
|
||||
ui.toolBar.AddSeparator()
|
||||
ui.toolBar.QWidget.AddAction(ui.actionRefresh)
|
||||
ui.toolBar.QWidget.AddAction(ui.actionAddRow)
|
||||
ui.toolBar.QWidget.AddAction(ui.actionDelete_row)
|
||||
ui.toolBar.QWidget.AddAction(ui.actionApply_changes)
|
||||
ui.toolBar.AddSeparator()
|
||||
ui.toolBar.QWidget.AddAction(ui.mnuExecute)
|
||||
|
||||
ui.Retranslate()
|
||||
|
||||
@@ -412,18 +328,6 @@ func NewMainWindowUi() *MainWindowUi {
|
||||
func (ui *MainWindowUi) Retranslate() {
|
||||
ui.MainWindow.SetWindowTitle(qt.QCoreApplication_Tr("yvbolt"))
|
||||
ui.actionE_xit.SetText(qt.QMainWindow_Tr("E&xit"))
|
||||
ui.mnuBadgerOpen.SetText(qt.QMainWindow_Tr("Open database..."))
|
||||
ui.mnuBadgerNewInMemory.SetText(qt.QMainWindow_Tr("New in-memory database"))
|
||||
ui.mnuBoltNew.SetText(qt.QMainWindow_Tr("New database..."))
|
||||
ui.mnuBoltOpenDatabase.SetText(qt.QMainWindow_Tr("Open database..."))
|
||||
ui.mnuBoltOpenDatabaseReadonly.SetText(qt.QMainWindow_Tr("Open database (read-only)..."))
|
||||
ui.mnuDebconfOpen.SetText(qt.QMainWindow_Tr("Open database..."))
|
||||
ui.mnuPebbleOpenDatabase.SetText(qt.QMainWindow_Tr("Open database..."))
|
||||
ui.mnuPebbleNewInMemory.SetText(qt.QMainWindow_Tr("New in-memory database"))
|
||||
ui.mnuRedisConnect.SetText(qt.QMainWindow_Tr("Connect..."))
|
||||
ui.mnuSqliteOpenDatabase.SetText(qt.QMainWindow_Tr("Open database..."))
|
||||
ui.mnuSqliteNewInMemory.SetText(qt.QMainWindow_Tr("New in-memory database"))
|
||||
ui.mnuSqliteExperimentalDriver.SetText(qt.QMainWindow_Tr("Connect using CLI driver (experimental)"))
|
||||
ui.mnuExecute.SetText(qt.QMainWindow_Tr("E&xecute"))
|
||||
ui.mnuExecute.SetShortcut(qt.NewQKeySequence2(qt.QMainWindow_Tr("F9")))
|
||||
ui.mnuDriverVersions.SetText(qt.QMainWindow_Tr("Driver versions..."))
|
||||
@@ -431,16 +335,21 @@ func (ui *MainWindowUi) Retranslate() {
|
||||
ui.mnuHelpAbout.SetShortcut(qt.NewQKeySequence2(qt.QMainWindow_Tr("F1")))
|
||||
ui.actionConnect.SetText(qt.QMainWindow_Tr("Connect..."))
|
||||
ui.actionConnect.SetShortcut(qt.NewQKeySequence2(qt.QMainWindow_Tr("Ctrl+O")))
|
||||
ui.actionRefresh.SetText(qt.QMainWindow_Tr("Refresh"))
|
||||
ui.actionRefresh.SetShortcut(qt.NewQKeySequence2(qt.QMainWindow_Tr("F5")))
|
||||
ui.actionAbout_Qt.SetText(qt.QMainWindow_Tr("About Qt"))
|
||||
ui.actionAddRow.SetText(qt.QMainWindow_Tr("Add row"))
|
||||
ui.actionAddRow.SetToolTip(qt.QMainWindow_Tr("Add row"))
|
||||
ui.actionDelete_row.SetText(qt.QMainWindow_Tr("Delete row"))
|
||||
ui.actionApply_changes.SetText(qt.QMainWindow_Tr("Apply changes"))
|
||||
ui.actionConnectionManager.SetText(qt.QMainWindow_Tr("Connection Manager"))
|
||||
ui.actionConnectionManager.SetToolTip(qt.QMainWindow_Tr("Connection Manager"))
|
||||
ui.tabWidget.SetTabText(ui.tabWidget.IndexOf(ui.tabProperties), qt.QTabWidget_Tr("Properties"))
|
||||
ui.tabWidget.SetTabText(ui.tabWidget.IndexOf(ui.tabData), qt.QTabWidget_Tr("Data"))
|
||||
ui.dataRefreshBtn.SetToolTip(qt.QWidget_Tr("Refresh"))
|
||||
ui.dataRefreshBtn.SetShortcut(qt.NewQKeySequence2(qt.QWidget_Tr("F5")))
|
||||
ui.dataInsertBtn.SetToolTip(qt.QWidget_Tr("Insert"))
|
||||
ui.dataDelRowBtn.SetToolTip(qt.QWidget_Tr("Delete Row"))
|
||||
ui.dataCommitBtn.SetToolTip(qt.QWidget_Tr("Commit"))
|
||||
ui.tabWidget.SetTabText(ui.tabWidget.IndexOf(ui.tabQuery), qt.QTabWidget_Tr("Query"))
|
||||
ui.queryExecBtn.SetText(qt.QWidget_Tr("Execute"))
|
||||
ui.menu_File.SetTitle(qt.QMenuBar_Tr("&File"))
|
||||
ui.menu_Query.SetTitle(qt.QMenuBar_Tr("&Query"))
|
||||
ui.menu_Help.SetTitle(qt.QMenuBar_Tr("&Help"))
|
||||
ui.menu_Data.SetTitle(qt.QMenuBar_Tr("&Data"))
|
||||
ui.toolBar.SetWindowTitle(qt.QMainWindow_Tr("toolBar"))
|
||||
}
|
||||
|
||||
346
mainwindow.ui
@@ -83,82 +83,6 @@
|
||||
<string>Data</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QToolButton" name="dataRefreshBtn">
|
||||
<property name="toolTip">
|
||||
<string>Refresh</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="embed.qrc">
|
||||
<normaloff>:/assets/arrow_refresh.png</normaloff>:/assets/arrow_refresh.png</iconset>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>F5</string>
|
||||
</property>
|
||||
<property name="autoRaise">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="dataInsertBtn">
|
||||
<property name="toolTip">
|
||||
<string>Insert</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="embed.qrc">
|
||||
<normaloff>:/assets/add.png</normaloff>:/assets/add.png</iconset>
|
||||
</property>
|
||||
<property name="autoRaise">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="dataDelRowBtn">
|
||||
<property name="toolTip">
|
||||
<string>Delete Row</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="embed.qrc">
|
||||
<normaloff>:/assets/delete.png</normaloff>:/assets/delete.png</iconset>
|
||||
</property>
|
||||
<property name="autoRaise">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="dataCommitBtn">
|
||||
<property name="toolTip">
|
||||
<string>Commit</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="embed.qrc">
|
||||
<normaloff>:/assets/pencil_go.png</normaloff>:/assets/pencil_go.png</iconset>
|
||||
</property>
|
||||
<property name="autoRaise">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTableWidget" name="contentBox">
|
||||
<property name="verticalScrollMode">
|
||||
@@ -180,37 +104,6 @@
|
||||
<string>Query</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QToolButton" name="queryExecBtn">
|
||||
<property name="text">
|
||||
<string>Execute</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="embed.qrc">
|
||||
<normaloff>:/assets/resultset_next.png</normaloff>:/assets/resultset_next.png</iconset>
|
||||
</property>
|
||||
<property name="autoRaise">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSplitter" name="splitter_2">
|
||||
<property name="orientation">
|
||||
@@ -256,6 +149,7 @@
|
||||
<property name="title">
|
||||
<string>&File</string>
|
||||
</property>
|
||||
<addaction name="actionConnectionManager"/>
|
||||
<addaction name="actionConnect"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionE_xit"/>
|
||||
@@ -271,123 +165,61 @@
|
||||
<string>&Help</string>
|
||||
</property>
|
||||
<addaction name="mnuDriverVersions"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionAbout_Qt"/>
|
||||
<addaction name="mnuHelpAbout"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menu_Data">
|
||||
<property name="title">
|
||||
<string>&Data</string>
|
||||
</property>
|
||||
<addaction name="actionRefresh"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionAddRow"/>
|
||||
<addaction name="actionDelete_row"/>
|
||||
<addaction name="actionApply_changes"/>
|
||||
</widget>
|
||||
<addaction name="menu_File"/>
|
||||
<addaction name="menu_Data"/>
|
||||
<addaction name="menu_Query"/>
|
||||
<addaction name="menu_Help"/>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
<widget class="QToolBar" name="toolBar">
|
||||
<property name="windowTitle">
|
||||
<string>toolBar</string>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolButtonStyle">
|
||||
<enum>Qt::ToolButtonStyle::ToolButtonIconOnly</enum>
|
||||
</property>
|
||||
<attribute name="toolBarArea">
|
||||
<enum>TopToolBarArea</enum>
|
||||
</attribute>
|
||||
<attribute name="toolBarBreak">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<addaction name="actionConnectionManager"/>
|
||||
<addaction name="actionConnect"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionRefresh"/>
|
||||
<addaction name="actionAddRow"/>
|
||||
<addaction name="actionDelete_row"/>
|
||||
<addaction name="actionApply_changes"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="mnuExecute"/>
|
||||
</widget>
|
||||
<action name="actionE_xit">
|
||||
<property name="text">
|
||||
<string>E&xit</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="mnuBadgerOpen">
|
||||
<property name="icon">
|
||||
<iconset resource="embed.qrc">
|
||||
<normaloff>:/assets/database_add.png</normaloff>:/assets/database_add.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Open database...</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="mnuBadgerNewInMemory">
|
||||
<property name="icon">
|
||||
<iconset resource="embed.qrc">
|
||||
<normaloff>:/assets/database_add.png</normaloff>:/assets/database_add.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>New in-memory database</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="mnuBoltNew">
|
||||
<property name="icon">
|
||||
<iconset resource="embed.qrc">
|
||||
<normaloff>:/assets/database_add.png</normaloff>:/assets/database_add.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>New database...</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="mnuBoltOpenDatabase">
|
||||
<property name="icon">
|
||||
<iconset resource="embed.qrc">
|
||||
<normaloff>:/assets/database_add.png</normaloff>:/assets/database_add.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Open database...</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="mnuBoltOpenDatabaseReadonly">
|
||||
<property name="icon">
|
||||
<iconset resource="embed.qrc">
|
||||
<normaloff>:/assets/database_add.png</normaloff>:/assets/database_add.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Open database (read-only)...</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="mnuDebconfOpen">
|
||||
<property name="icon">
|
||||
<iconset resource="embed.qrc">
|
||||
<normaloff>:/assets/database_add.png</normaloff>:/assets/database_add.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Open database...</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="mnuPebbleOpenDatabase">
|
||||
<property name="icon">
|
||||
<iconset resource="embed.qrc">
|
||||
<normaloff>:/assets/database_add.png</normaloff>:/assets/database_add.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Open database...</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="mnuPebbleNewInMemory">
|
||||
<property name="icon">
|
||||
<iconset resource="embed.qrc">
|
||||
<normaloff>:/assets/database_add.png</normaloff>:/assets/database_add.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>New in-memory database</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="mnuRedisConnect">
|
||||
<property name="icon">
|
||||
<iconset resource="embed.qrc">
|
||||
<normaloff>:/assets/database_add.png</normaloff>:/assets/database_add.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Connect...</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="mnuSqliteOpenDatabase">
|
||||
<property name="icon">
|
||||
<iconset resource="embed.qrc">
|
||||
<normaloff>:/assets/database_add.png</normaloff>:/assets/database_add.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Open database...</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="mnuSqliteNewInMemory">
|
||||
<property name="icon">
|
||||
<iconset resource="embed.qrc">
|
||||
<normaloff>:/assets/database_add.png</normaloff>:/assets/database_add.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>New in-memory database</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="mnuSqliteExperimentalDriver">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Connect using CLI driver (experimental)</string>
|
||||
<property name="menuRole">
|
||||
<enum>QAction::MenuRole::QuitRole</enum>
|
||||
</property>
|
||||
</action>
|
||||
<action name="mnuExecute">
|
||||
@@ -408,12 +240,19 @@
|
||||
</property>
|
||||
</action>
|
||||
<action name="mnuHelpAbout">
|
||||
<property name="icon">
|
||||
<iconset resource="embed.qrc">
|
||||
<normaloff>:/assets/help.png</normaloff>:/assets/help.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&About yvbolt</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>F1</string>
|
||||
</property>
|
||||
<property name="menuRole">
|
||||
<enum>QAction::MenuRole::AboutRole</enum>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionConnect">
|
||||
<property name="icon">
|
||||
@@ -427,6 +266,87 @@
|
||||
<string>Ctrl+O</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionRefresh">
|
||||
<property name="icon">
|
||||
<iconset resource="embed.qrc">
|
||||
<normaloff>:/assets/arrow_refresh.png</normaloff>:/assets/arrow_refresh.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Refresh</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>F5</string>
|
||||
</property>
|
||||
<property name="menuRole">
|
||||
<enum>QAction::MenuRole::NoRole</enum>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionAbout_Qt">
|
||||
<property name="icon">
|
||||
<iconset resource="embed.qrc">
|
||||
<normaloff>:/assets/vendor_qt.png</normaloff>:/assets/vendor_qt.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>About Qt</string>
|
||||
</property>
|
||||
<property name="menuRole">
|
||||
<enum>QAction::MenuRole::AboutQtRole</enum>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionAddRow">
|
||||
<property name="icon">
|
||||
<iconset resource="embed.qrc">
|
||||
<normaloff>:/assets/add.png</normaloff>:/assets/add.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Add row</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Add row</string>
|
||||
</property>
|
||||
<property name="menuRole">
|
||||
<enum>QAction::MenuRole::NoRole</enum>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionDelete_row">
|
||||
<property name="icon">
|
||||
<iconset resource="embed.qrc">
|
||||
<normaloff>:/assets/delete.png</normaloff>:/assets/delete.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Delete row</string>
|
||||
</property>
|
||||
<property name="menuRole">
|
||||
<enum>QAction::MenuRole::NoRole</enum>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionApply_changes">
|
||||
<property name="icon">
|
||||
<iconset resource="embed.qrc">
|
||||
<normaloff>:/assets/pencil_go.png</normaloff>:/assets/pencil_go.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Apply changes</string>
|
||||
</property>
|
||||
<property name="menuRole">
|
||||
<enum>QAction::MenuRole::NoRole</enum>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionConnectionManager">
|
||||
<property name="icon">
|
||||
<iconset resource="embed.qrc">
|
||||
<normaloff>:/assets/database_key.png</normaloff>:/assets/database_key.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Connection Manager</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Connection Manager</string>
|
||||
</property>
|
||||
<property name="menuRole">
|
||||
<enum>QAction::MenuRole::NoRole</enum>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="embed.qrc"/>
|
||||
|
||||
46
sshTunnel.go
@@ -12,15 +12,26 @@ import (
|
||||
)
|
||||
|
||||
type SSHTunnel struct {
|
||||
Server autoconfig.AddressPort
|
||||
Username string
|
||||
Password autoconfig.Password
|
||||
PrivateKeyContent autoconfig.MultiLineString
|
||||
PrivateKeyFile autoconfig.ExistingFile
|
||||
PrivateKeyPassword autoconfig.Password
|
||||
Server autoconfig.AddressPort
|
||||
Username string
|
||||
H1 autoconfig.Header `ylabel:"Authentication:" json:",omitempty"`
|
||||
Auth struct {
|
||||
Type autoconfig.OneOf
|
||||
Password *struct {
|
||||
Password autoconfig.Password
|
||||
}
|
||||
PrivateKeyExternal *struct {
|
||||
PrivateKeyFile autoconfig.ExistingFile `ylabel:"Private Key"`
|
||||
PrivateKeyFilePassword autoconfig.Password `ylabel:"Password (optional)"`
|
||||
} `ylabel:"Private key (External)"`
|
||||
PrivateKeyInternal *struct {
|
||||
PrivateKeyContent autoconfig.MultiLineString `ylabel:"Private Key"`
|
||||
PrivateKeyContentPassword autoconfig.Password `ylabel:"Password (optional)"`
|
||||
} `ylabel:"Private key (Internal)"`
|
||||
}
|
||||
}
|
||||
|
||||
func (s *SSHTunnel) InitDefaults() { // Used by autoconfig package when creating a new value
|
||||
func (s *SSHTunnel) Reset() { // Used by autoconfig package when creating a new value
|
||||
s.Server.Port = 22
|
||||
}
|
||||
|
||||
@@ -49,25 +60,28 @@ func (s SSHTunnel) Open(ctx context.Context) (*ssh.Client, error) {
|
||||
User: s.Username,
|
||||
}
|
||||
|
||||
if s.Password != "" {
|
||||
cfg.Auth = append(cfg.Auth, ssh.Password(string(s.Password)))
|
||||
}
|
||||
if s.Auth.Password != nil {
|
||||
cfg.Auth = append(cfg.Auth, ssh.Password(string(s.Auth.Password.Password)))
|
||||
|
||||
if s.PrivateKeyContent != "" {
|
||||
signer, err := parseMaybePasswordedKey([]byte(s.PrivateKeyContent), []byte(s.PrivateKeyPassword))
|
||||
} else if s.Auth.PrivateKeyInternal != nil {
|
||||
|
||||
signer, err := parseMaybePasswordedKey(
|
||||
[]byte(s.Auth.PrivateKeyInternal.PrivateKeyContent),
|
||||
[]byte(s.Auth.PrivateKeyInternal.PrivateKeyContentPassword),
|
||||
)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Parsing private key: %w", err)
|
||||
}
|
||||
cfg.Auth = append(cfg.Auth, ssh.PublicKeys(signer))
|
||||
}
|
||||
|
||||
if s.PrivateKeyFile != "" {
|
||||
keyBytes, err := os.ReadFile(string(s.PrivateKeyFile))
|
||||
} else if s.Auth.PrivateKeyExternal != nil {
|
||||
|
||||
keyBytes, err := os.ReadFile(string(s.Auth.PrivateKeyExternal.PrivateKeyFile))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Loading private key: %w", err)
|
||||
}
|
||||
|
||||
signer, err := parseMaybePasswordedKey(keyBytes, []byte(s.PrivateKeyPassword))
|
||||
signer, err := parseMaybePasswordedKey(keyBytes, []byte(s.Auth.PrivateKeyExternal.PrivateKeyFilePassword))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Parsing private key: %w", err)
|
||||
}
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/gob"
|
||||
)
|
||||
|
||||
// box_interface creates a slice where all elements of the input slice are boxed
|
||||
// in an interface{} type.
|
||||
func box_interface[T any](input []T) []interface{} {
|
||||
@@ -24,3 +29,25 @@ func slice_find[T comparable](haystack []T, needle T) (int, bool) {
|
||||
|
||||
return -1, false
|
||||
}
|
||||
|
||||
func slice_remove_index[T comparable](slice []T, s int) []T {
|
||||
return append(slice[:s], slice[s+1:]...)
|
||||
}
|
||||
|
||||
func pathlist_encode(bp []string) ([]byte, error) {
|
||||
buff := bytes.Buffer{}
|
||||
enc := gob.NewEncoder(&buff)
|
||||
err := enc.Encode(bp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return buff.Bytes(), nil
|
||||
}
|
||||
|
||||
func pathlist_decode(input []byte) ([]string, error) {
|
||||
dec := gob.NewDecoder(bytes.NewReader(input))
|
||||
var ret []string
|
||||
err := dec.Decode(&ret)
|
||||
return ret, err
|
||||
}
|
||||
|
||||
33
util_types_test.go
Normal file
@@ -0,0 +1,33 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestPathlistEncode(t *testing.T) {
|
||||
// Ensure that invalid UTF-8 data is not corrupted in a pathlist encoding
|
||||
// roundtrip
|
||||
|
||||
input := []string{
|
||||
"\x00\x01\x02\x03\x04\x05\x06\x07",
|
||||
"\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7",
|
||||
"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7",
|
||||
"hello",
|
||||
"world",
|
||||
}
|
||||
|
||||
buff, err := pathlist_encode(input)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
ret, err := pathlist_decode(buff)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(input, ret) {
|
||||
t.Error("Mismatch")
|
||||
}
|
||||
}
|
||||
@@ -22,6 +22,13 @@ func vcl_confirm_dialog(parent *qt.QWidget, title string, message string) bool {
|
||||
|
||||
func vcl_grid_set_row_colour(grid *qt.QTableWidget, rowId int, colour *qt.QBrush) {
|
||||
|
||||
// Avoid triggering onCellChanged events while we update the background
|
||||
// colours
|
||||
if !grid.SignalsBlocked() {
|
||||
grid.BlockSignals(true)
|
||||
defer grid.BlockSignals(false)
|
||||
}
|
||||
|
||||
numCols := grid.ColumnCount()
|
||||
for i := 0; i < numCols; i++ {
|
||||
cell := grid.Item(rowId, i)
|
||||
|
||||
3
version.go
Normal file
@@ -0,0 +1,3 @@
|
||||
package main
|
||||
|
||||
const appVersion = "v0.0.0-devel"
|
||||
54
winres.json
Normal file
@@ -0,0 +1,54 @@
|
||||
{
|
||||
"RT_GROUP_ICON": {
|
||||
"APP": {
|
||||
"0000": "assets/database_lightning.png"
|
||||
}
|
||||
},
|
||||
"RT_VERSION": {
|
||||
"#1": {
|
||||
"0000": {
|
||||
"fixed": {
|
||||
"file_version": "0.0.0.0",
|
||||
"product_version": "0.0.0.0"
|
||||
},
|
||||
"info": {
|
||||
"0409": {
|
||||
"Comments": "",
|
||||
"CompanyName": "code.ivysaur.me",
|
||||
"FileDescription": "yvbolt Database Editor",
|
||||
"FileVersion": "0.0.0.0",
|
||||
"LegalCopyright": "code.ivysaur.me",
|
||||
"LegalTrademarks": "",
|
||||
"ProductName": "yvbolt",
|
||||
"ProductVersion": "0.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"RT_MANIFEST": {
|
||||
"#1": {
|
||||
"0409": {
|
||||
"identity": {
|
||||
"name": "",
|
||||
"version": ""
|
||||
},
|
||||
"description": "",
|
||||
"minimum-os": "win7",
|
||||
"execution-level": "as invoker",
|
||||
"ui-access": false,
|
||||
"auto-elevate": false,
|
||||
"dpi-awareness": "per monitor v2",
|
||||
"disable-theming": false,
|
||||
"disable-window-filtering": false,
|
||||
"high-resolution-scrolling-aware": false,
|
||||
"ultra-high-resolution-scrolling-aware": false,
|
||||
"long-path-aware": false,
|
||||
"printer-driver-isolation": false,
|
||||
"gdi-scaling": false,
|
||||
"segment-heap": false,
|
||||
"use-common-controls-v6": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||