Add --db and let the user choose where the database lives
- `kareer --db <path>` works for the GUI and every subcommand, before or after the subcommand name, and creates the file if missing. main() strips it from argv before CLI/GUI routing; every parser declares it so it shows in --help. - Path precedence: --db > KAREER_DB_PATH > the location chosen in the GUI (kareerrc [Database] Path, read at startup for GUI and CLI alike) > $XDG_DATA_HOME/kareer/kareer.sqlite. - First GUI run (nothing forced, no file yet, or the configured file has gone missing): DatabaseSetupDialog offers the default location, a folder of the user's choice, or an existing database used in place. Until then JobsDatabase opens nothing. - Preferences gains a Database section: Move to... (copies, leaves the original), Open Existing..., Use Default Location. Refuses foreign SQLite files and unwritable ones. - Models call JobsDatabase::reopenIfPathChanged() on refresh, so switching databases needs no restart. - Link KF6::ConfigCore; add a QuickDialogs2 configure-time guard; add kconfig to the Arch dependencies and a note to the Flatpak manifest. - README documents --db, the precedence, and the first-run choice, and gains Fedora 44 build dependencies; CONTRIBUTING gets a dev recipe. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01BxDf7HqD1xPnsZP8wt3NTk
This commit is contained in:
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2026 ToServeTheKing <[email protected]>
|
||||
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
pragma ComponentBehavior: Bound
|
||||
|
||||
// First-run choice of where the database lives. Shown by Main.qml while
|
||||
// DatabaseLocation.setupPending is true; it cannot be dismissed until a
|
||||
// location has been picked, since nothing can be saved before then.
|
||||
import QtQuick
|
||||
import QtQuick.Controls as QQC2
|
||||
import QtQuick.Dialogs
|
||||
import QtQuick.Layouts
|
||||
import org.kde.kirigami as Kirigami
|
||||
import org.kde.kirigamiaddons.formcard as FormCard
|
||||
import io.github.toservetheking.Kareer
|
||||
|
||||
Kirigami.Dialog {
|
||||
id: root
|
||||
|
||||
title: i18nc("@title:window", "Welcome to Kareer")
|
||||
showCloseButton: false
|
||||
closePolicy: QQC2.Popup.NoAutoClose
|
||||
modal: true
|
||||
preferredWidth: Kirigami.Units.gridUnit * 26
|
||||
standardButtons: Kirigami.Dialog.NoButton
|
||||
|
||||
onOpened: DatabaseLocation.clearMessages()
|
||||
|
||||
ColumnLayout {
|
||||
spacing: 0
|
||||
|
||||
QQC2.Label {
|
||||
Layout.fillWidth: true
|
||||
Layout.margins: Kirigami.Units.largeSpacing
|
||||
wrapMode: Text.Wrap
|
||||
text: DatabaseLocation.missingPath.length > 0
|
||||
? xi18nc("@info", "The database at <filename>%1</filename> could not be found. Choose where Kareer should keep your applications.", DatabaseLocation.missingPath)
|
||||
: i18nc("@info", "Choose where Kareer should keep your applications.")
|
||||
}
|
||||
|
||||
Kirigami.InlineMessage {
|
||||
Layout.fillWidth: true
|
||||
Layout.leftMargin: Kirigami.Units.largeSpacing
|
||||
Layout.rightMargin: Kirigami.Units.largeSpacing
|
||||
Layout.bottomMargin: Kirigami.Units.smallSpacing
|
||||
type: Kirigami.MessageType.Error
|
||||
text: DatabaseLocation.lastError
|
||||
visible: text.length > 0
|
||||
}
|
||||
|
||||
FormCard.FormButtonDelegate {
|
||||
Layout.fillWidth: true
|
||||
icon.name: "document-new"
|
||||
text: i18nc("@action:button", "Create in the default location")
|
||||
description: DatabaseLocation.standardPath
|
||||
onClicked: {
|
||||
if (DatabaseLocation.useDefault()) {
|
||||
root.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FormCard.FormButtonDelegate {
|
||||
Layout.fillWidth: true
|
||||
icon.name: "folder-new"
|
||||
text: i18nc("@action:button", "Choose a folder…")
|
||||
description: i18nc("@info", "Create a new database in a folder of your choice, for example a synced folder.")
|
||||
onClicked: folderDialog.open()
|
||||
}
|
||||
|
||||
FormCard.FormButtonDelegate {
|
||||
Layout.fillWidth: true
|
||||
icon.name: "document-open"
|
||||
text: i18nc("@action:button", "Open an existing database…")
|
||||
description: i18nc("@info", "Use a kareer.sqlite file you already have, where it is.")
|
||||
onClicked: fileDialog.open()
|
||||
}
|
||||
}
|
||||
|
||||
FolderDialog {
|
||||
id: folderDialog
|
||||
title: i18nc("@title:window", "Choose a Folder for the Database")
|
||||
onAccepted: {
|
||||
if (DatabaseLocation.createIn(selectedFolder)) {
|
||||
root.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FileDialog {
|
||||
id: fileDialog
|
||||
title: i18nc("@title:window", "Open Database")
|
||||
fileMode: FileDialog.OpenFile
|
||||
nameFilters: [i18nc("@item:inlistbox", "Kareer databases (*.sqlite)"), i18nc("@item:inlistbox", "All files (*)")]
|
||||
onAccepted: {
|
||||
if (DatabaseLocation.useFile(selectedFile)) {
|
||||
root.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user