Files
Kareer/src/qml/Main.qml
T
austinandClaude Opus 5 260704cf9b 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
2026-09-11 15:42:00 -05:00

135 lines
3.8 KiB
QML

/*
SPDX-FileCopyrightText: 2026 ToServeTheKing <[email protected]>
SPDX-License-Identifier: GPL-3.0-or-later
*/
pragma ComponentBehavior: Bound
import QtQuick
import org.kde.kirigami as Kirigami
import org.kde.kirigamiaddons.formcard as FormCard
import io.github.toservetheking.Kareer
Kirigami.ApplicationWindow {
id: root
title: i18nc("@title:window", "Kareer")
minimumWidth: Kirigami.Units.gridUnit * 32
minimumHeight: Kirigami.Units.gridUnit * 24
width: Kirigami.Units.gridUnit * 50
height: Kirigami.Units.gridUnit * 36
JobsModel {
id: jobsModel
}
// The database moved (first-run choice or Preferences): reload the list,
// which cascades to the dashboard via countChanged, and leave any open
// edit form, since its job id belonged to the previous database.
Connections {
target: DatabaseLocation
function onChanged(): void {
jobsModel.refresh();
root.showDashboard();
}
}
DatabaseSetupDialog {
id: setupDialog
}
Component.onCompleted: {
if (DatabaseLocation.setupPending) {
setupDialog.open();
}
}
// The job currently open in the edit form, so the sidebar can keep it highlighted.
property int currentJobId: -1
pageStack.defaultColumnWidth: Kirigami.Units.gridUnit * 16
pageStack.globalToolBar.style: Kirigami.ApplicationHeaderStyle.ToolBar
globalDrawer: Kirigami.GlobalDrawer {
isMenu: true
actions: [
Kirigami.Action {
text: i18nc("@action:inmenu", "Preferences…")
icon.name: "configure"
onTriggered: root.pageStack.pushDialogLayer(settingsPageComponent, {
width: root.width
}, {
width: Kirigami.Units.gridUnit * 24,
height: Kirigami.Units.gridUnit * 20,
modality: Qt.NonModal
})
},
Kirigami.Action {
text: i18nc("@action:inmenu", "About %1", root.title)
icon.name: "help-about"
onTriggered: root.pageStack.pushDialogLayer(aboutPageComponent, {
width: root.width
}, {
width: Kirigami.Units.gridUnit * 30,
height: Kirigami.Units.gridUnit * 30,
modality: Qt.NonModal
})
}
]
}
Component {
id: aboutPageComponent
FormCard.AboutPage {}
}
Component {
id: settingsPageComponent
SettingsPage {}
}
// Two static columns: the applications list (sidebar) and the dashboard.
// "Add Application" (and clicking a row) replaces just the dashboard
// column with the edit form - the sidebar and its list are untouched.
pageStack.initialPage: [applicationsComponent, dashboardComponent]
function showDashboard(): void {
root.currentJobId = -1;
root.pageStack.currentIndex = 1;
root.pageStack.replace(dashboardComponent);
}
function showEditPage(jobId: int): void {
root.currentJobId = jobId;
root.pageStack.currentIndex = 1;
root.pageStack.replace(editPageComponent, {editingJobId: jobId});
}
Component {
id: applicationsComponent
ApplicationsPage {
jobsModel: jobsModel
currentJobId: root.currentJobId
onEditRequested: jobId => root.showEditPage(jobId)
}
}
Component {
id: dashboardComponent
DashboardPage {
jobsModel: jobsModel
onAddRequested: root.showEditPage(-1)
}
}
Component {
id: editPageComponent
ApplicationEditPage {
jobsModel: jobsModel
onDone: root.showDashboard()
}
}
}