You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
73 lines
2.9 KiB
73 lines
2.9 KiB
#[Copyright 2023 ITwrx.
|
|
This file is part of EZ-Bkup.
|
|
EZ-Bkup is released under the General Public License 3.0.
|
|
See COPYING or <https://www.gnu.org/licenses/> for details.]#
|
|
|
|
import owlkettle
|
|
import "models/routine", "shared"
|
|
import views/[edit_routine_dialog, routine_list, app_menu_button]
|
|
|
|
const APP_NAME = "EZ-Bkup"
|
|
|
|
viewable App:
|
|
## The main application
|
|
routineModel: RoutineModel ## The RoutineModel that stores all routines.
|
|
|
|
method view(app: AppState): Widget =
|
|
result = gui:
|
|
Window:
|
|
title = APP_NAME
|
|
defaultSize = (1024, 768)
|
|
HeaderBar {.addTitlebar.}:
|
|
Icon {.addLeft.}:
|
|
name = "ez_bkup"
|
|
pixelSize = 40
|
|
margin = 4
|
|
# Button to open the main menu
|
|
AppMenuButton {.addRight.}:
|
|
routineModel = app.routineModel
|
|
Box:
|
|
orient = OrientY
|
|
spacing = 6
|
|
#don't use available vertical space from parent. Only what's needed for children.
|
|
Box(orient = OrientX) {.expand: false.}:
|
|
Label:
|
|
text = "<span size=\"x-large\">Bkup Routines</span>"
|
|
xAlign = 0.05
|
|
useMarkup = true
|
|
#expand horizontally to push buttons to the right.
|
|
Box(orient = OrientX) {.expand: true.}
|
|
#expanding box containing buttons would fight the previous box for available horiz space placing buttons in the middle.
|
|
Box(orient = OrientX, spacing = 6, margin = 6) {.expand: false.}:
|
|
# Button to create a new routine
|
|
Button:
|
|
style = [ButtonSuggested]
|
|
text = "+ Routine"
|
|
tooltip = "Create a new Bkup Routine"
|
|
proc clicked() =
|
|
## Opens the EditRoutineDialog for creating a new routine
|
|
let (res, state) = app.open: gui:
|
|
EditRoutineDialog(mode = EditRoutineCreate)
|
|
if res.kind == DialogAccept:
|
|
# The "Create" button was clicked
|
|
app.routineModel.add(EditRoutineDialogState(state).routine)
|
|
|
|
# Main content of the window: Contains the list of all routines.
|
|
Box:
|
|
orient = OrientY
|
|
margin = 6
|
|
spacing = 12
|
|
Frame:
|
|
RoutineList:
|
|
routineModel = app.routineModel
|
|
|
|
when isMainModule:
|
|
# Entry point for the application.
|
|
# Loads the model from the database and starts the application.
|
|
#databasePath is coming from shared.nim
|
|
let model = newRoutineModel(databasePath)
|
|
#if running manually from src directory.
|
|
#brew("org.itwrx.EZ-Bkup", gui(App(routineModel = model)), darkTheme = true, icons=["icons/"], stylesheets=[loadStylesheet("styles.css")])
|
|
#if installed.
|
|
brew("org.itwrx.EZ-Bkup", gui(App(routineModel = model)), darkTheme = true, icons=["/usr/local/share/ez_bkup/icons/"], stylesheets=[loadStylesheet("/usr/local/share/ez_bkup/styles.css")])
|
|
|