From 1c39673c55228aa9e49eaec1abd2a2f41da7874a Mon Sep 17 00:00:00 2001 From: dev-claw <53543762+dev-claw@users.noreply.github.com> Date: Sun, 17 Aug 2025 19:27:07 +0100 Subject: [PATCH] wip #247 --- .../src/main/kotlin/me/vripper/gui/Module.kt | 4 + .../me/vripper/gui/VripperGuiApplication.kt | 45 ++--- .../me/vripper/gui/components/Fragment.kt | 30 +++ .../gui/components/fragments/AboutFragment.kt | 189 ++++++++++-------- .../fragments/DownloadSettingsFragment.kt | 6 +- .../components/fragments/SessionFragment.kt | 6 +- .../fragments/SystemSettingsFragment.kt | 6 +- .../fragments/ThreadSelectionTableFragment.kt | 6 +- .../vripper/gui/components/views/AppView.kt | 14 +- .../gui/components/views/ImagesTableView.kt | 6 +- .../gui/components/views/LoadingView.kt | 6 +- .../gui/components/views/LogTableView.kt | 6 +- .../gui/components/views/MenuBarView.kt | 11 +- .../gui/components/views/PostsTabView.kt | 6 +- .../gui/components/views/PostsTableView.kt | 6 +- .../gui/components/views/StatusBarView.kt | 6 +- .../gui/components/views/ThreadTableView.kt | 6 +- .../gui/controller/WidgetsController.kt | 3 +- 18 files changed, 218 insertions(+), 144 deletions(-) create mode 100644 vripper-gui/src/main/kotlin/me/vripper/gui/components/Fragment.kt diff --git a/vripper-gui/src/main/kotlin/me/vripper/gui/Module.kt b/vripper-gui/src/main/kotlin/me/vripper/gui/Module.kt index 1879858..71ac3d2 100644 --- a/vripper-gui/src/main/kotlin/me/vripper/gui/Module.kt +++ b/vripper-gui/src/main/kotlin/me/vripper/gui/Module.kt @@ -1,5 +1,6 @@ package me.vripper.gui +import me.vripper.gui.controller.WidgetsController import me.vripper.gui.services.GrpcEndpointService import me.vripper.services.IAppEndpointService import org.koin.core.qualifier.named @@ -10,6 +11,9 @@ val guiModule = module { single((named("remoteAppEndpointService"))) { GrpcEndpointService() } bind IAppEndpointService::class + single { + WidgetsController() + } } val modules = module { diff --git a/vripper-gui/src/main/kotlin/me/vripper/gui/VripperGuiApplication.kt b/vripper-gui/src/main/kotlin/me/vripper/gui/VripperGuiApplication.kt index 85f873a..c76cdb2 100644 --- a/vripper-gui/src/main/kotlin/me/vripper/gui/VripperGuiApplication.kt +++ b/vripper-gui/src/main/kotlin/me/vripper/gui/VripperGuiApplication.kt @@ -1,7 +1,7 @@ package me.vripper.gui -import atlantafx.base.theme.CupertinoDark -import atlantafx.base.theme.CupertinoLight +import atlantafx.base.theme.NordDark +import atlantafx.base.theme.NordLight import javafx.application.Application import javafx.scene.image.Image import javafx.stage.Stage @@ -15,22 +15,19 @@ import me.vripper.gui.utils.WidgetSettings import me.vripper.utilities.AppLock import me.vripper.utilities.ApplicationProperties.VRIPPER_DIR import me.vripper.utilities.LoggerDelegate -import org.koin.core.context.GlobalContext +import org.koin.core.component.KoinComponent +import org.koin.core.component.inject import org.koin.core.context.startKoin -import org.koin.core.qualifier.named import tornadofx.App -import tornadofx.DIContainer -import tornadofx.FX -import kotlin.reflect.KClass import kotlin.system.exitProcess class VripperGuiApplication : App( LoadingView::class -) { +), KoinComponent { private val log by LoggerDelegate() private var initialized = false - private val widgetsController: WidgetsController by inject() + private val widgetsController: WidgetsController by inject() private val coroutineScope = CoroutineScope(SupervisorJob() + Dispatchers.Default) init { @@ -38,13 +35,14 @@ class VripperGuiApplication : App( } override fun start(stage: Stage) { + PRIMARY_STAGE = stage Thread.setDefaultUncaughtExceptionHandler(Thread.UncaughtExceptionHandler { t, e -> log.error("Thread $t threw an exception: ${e.message}", e) }) if (widgetsController.currentSettings.darkMode) { - setUserAgentStylesheet(CupertinoDark().userAgentStylesheet) + setUserAgentStylesheet(NordDark().userAgentStylesheet) } else { - setUserAgentStylesheet(CupertinoLight().userAgentStylesheet) + setUserAgentStylesheet(NordLight().userAgentStylesheet) } with(stage) { width = widgetsController.currentSettings.width @@ -77,18 +75,15 @@ class VripperGuiApplication : App( } } stage.addEventFilter(WindowEvent.WINDOW_SHOWN) { - startKoin { - modules(modules) - } - FX.dicontainer = - object : DIContainer { - override fun getInstance(type: KClass): T = - GlobalContext.get().get(type) - - override fun getInstance(type: KClass, name: String): T = - GlobalContext.get().get(type, named(name)) - - } +// FX.dicontainer = +// object : DIContainer { +// override fun getInstance(type: KClass): T = +// GlobalContext.get().get(type) +// +// override fun getInstance(type: KClass, name: String): T = +// GlobalContext.get().get(type, named(name)) +// +// } coroutineScope.launch { GuiEventBus.publishEvent(GuiEventBus.ApplicationInitialized(parameters.raw)) initialized = true @@ -105,6 +100,7 @@ class VripperGuiApplication : App( companion object { lateinit var APP_INSTANCE: Application + lateinit var PRIMARY_STAGE: Stage } } @@ -130,6 +126,9 @@ fun main(args: Array) { Watcher.notify(threadId) exitProcess(0) } + startKoin { + modules(modules) + } Watcher.init() Application.launch( VripperGuiApplication::class.java, diff --git a/vripper-gui/src/main/kotlin/me/vripper/gui/components/Fragment.kt b/vripper-gui/src/main/kotlin/me/vripper/gui/components/Fragment.kt new file mode 100644 index 0000000..af0aa6a --- /dev/null +++ b/vripper-gui/src/main/kotlin/me/vripper/gui/components/Fragment.kt @@ -0,0 +1,30 @@ +package me.vripper.gui.components + +import javafx.scene.Node +import javafx.scene.Parent +import javafx.scene.Scene +import javafx.stage.Modality +import javafx.stage.Stage +import me.vripper.gui.VripperGuiApplication.Companion.PRIMARY_STAGE + + +abstract class Fragment( + private val title: String = "", + private val width: Double = 0.0, + private val height: Double = 0.0 +) { + abstract val root: Node + + fun openModal(owner: Stage = PRIMARY_STAGE): Stage { + val modalStage = Stage() + modalStage.initModality(Modality.WINDOW_MODAL) + modalStage.initOwner(owner) + modalStage.title = title + modalStage.setScene(Scene(root as Parent, width, height)) + + modalStage.x = owner.x + (owner.width / 2) - width / 2 + modalStage.y = owner.y + (owner.height / 2) - height / 2 + modalStage.show() + return modalStage + } +} \ No newline at end of file diff --git a/vripper-gui/src/main/kotlin/me/vripper/gui/components/fragments/AboutFragment.kt b/vripper-gui/src/main/kotlin/me/vripper/gui/components/fragments/AboutFragment.kt index 7eab83a..920588c 100644 --- a/vripper-gui/src/main/kotlin/me/vripper/gui/components/fragments/AboutFragment.kt +++ b/vripper-gui/src/main/kotlin/me/vripper/gui/components/fragments/AboutFragment.kt @@ -1,112 +1,132 @@ package me.vripper.gui.components.fragments +import javafx.event.EventHandler import javafx.geometry.Insets -import javafx.scene.control.TabPane -import javafx.scene.text.FontWeight +import javafx.geometry.Pos +import javafx.scene.control.* +import javafx.scene.image.ImageView +import javafx.scene.layout.GridPane +import javafx.scene.layout.HBox +import javafx.scene.layout.Priority +import javafx.scene.layout.VBox +import javafx.scene.text.Text +import me.vripper.gui.components.Fragment import me.vripper.gui.controller.WidgetsController import me.vripper.gui.utils.openLink import me.vripper.utilities.ApplicationProperties -import tornadofx.* +import org.koin.core.component.KoinComponent +import org.koin.core.component.inject import kotlin.io.path.pathString -class AboutFragment : Fragment("About") { + +class AboutFragment(width: Double, height: Double) : Fragment("About", width, height), KoinComponent { private val widgetsController: WidgetsController by inject() - override val root = tabpane() + override val root = TabPane() init { with(root) { - tab("About") { + Tab("About").apply { tabClosingPolicy = TabPane.TabClosingPolicy.UNAVAILABLE - hbox { + HBox().apply { padding = Insets(15.0, 15.0, 15.0, 15.0) spacing = 15.0 - imageview("icons/64x64.png") - vbox(spacing = 5.0) { - text("VRipper ${ApplicationProperties.VERSION}") { - style { - fontWeight = FontWeight.BOLD - fontSize = Dimension(18.0, Dimension.LinearUnits.px) - } - } - text("Developed by dev-claw and VRipper working group") - hbox(spacing = 5.0) { - hyperlink { + ImageView("icons/64x64.png").also { children.add(it) } + VBox(5.0).apply { + Text("VRipper ${ApplicationProperties.VERSION}").apply { + style = "-fx-font-weight: 700; -fx-font-size: 18px" + }.also { children.add(it) } + Text("Developed by dev-claw and VRipper working group").also { children.add(it) } + HBox(5.0).apply { + Hyperlink().apply { if (widgetsController.currentSettings.darkMode) { - imageview("icons/github-mark-white.png").apply { + ImageView("icons/github-mark-white.png").apply { isPreserveRatio = true fitHeight = 32.0 - } + }.also { graphic = it } } else { - imageview("icons/github-mark.png").apply { + ImageView("icons/github-mark.png").apply { isPreserveRatio = true fitHeight = 32.0 - } + }.also { graphic = it } } - action { + onAction = EventHandler { openLink("https://github.com/dev-claw/vripper-project") } + }.also { children.add(it) } + }.also { children.add(it) } + Text("Donation").apply { style = "-fx-font-weight: 700; -fx-font-size: 16px" } + .also { children.add(it) } + Hyperlink().apply { + ImageView("icons/buymeacoffee-logo.png").apply { + isPreserveRatio = true + fitHeight = 32.0 + }.also { graphic = it } + onAction = EventHandler { + openLink("https://buymeacoffee.com/devclaw") } + }.also { children.add(it) } + GridPane().apply { + alignment = Pos.TOP_LEFT + hgap = 10.0 + vgap = 10.0 + minWidth = 400.0 + Text("ETH").also { add(it, 0, 0) } + TextField("0xDdac82B16dC5E3D742fc915ffF583D8548A301cA").apply { + GridPane.setHgrow(this, Priority.ALWAYS) + isEditable = false + }.also { add(it, 1, 0) } + Text("BTC").also { add(it, 0, 1) } + TextField("bc1qcqudnkrndwyadsjwrxww42svkf8trnzx3c8vlr").apply { + GridPane.setHgrow(this, Priority.ALWAYS) + isEditable = false + } + .also { add(it, 1, 1) } + }.also { children.add(it) } + }.also { children.add(it) } + }.also { content = it } + tabs.add(this) + } + Tab("System").apply { + GridPane().apply { + alignment = Pos.TOP_LEFT + hgap = 10.0 + vgap = 10.0 + minWidth = 400.0 + Text("Application data folder").apply { add(this, 0, 0) } + TextField(ApplicationProperties.VRIPPER_DIR.pathString).apply { + isEditable = false + add(this, 1, 0) + } + Text("Previews Path").apply { add(this, 0, 1) } + TextField().apply { + textProperty().bind(widgetsController.currentSettings.cachePathProperty) + isEditable = false + add(this, 1, 1) + } + Button("Browse").apply { + onAction = EventHandler { +// val directory = chooseDirectory(title = "Select previews folder") +// if (directory != null) { +// widgetsController.currentSettings.cachePathProperty.set(directory.path) +// } } - form { - fieldset("Donation") { - minWidth = 400.0 - field { - hyperlink { - imageview("icons/buymeacoffee-logo.png").apply { - isPreserveRatio = true - fitHeight = 32.0 - } - action { - openLink("https://buymeacoffee.com/devclaw") - } - } - } - field("ETH:") { - textfield("0xDdac82B16dC5E3D742fc915ffF583D8548A301cA") { + add(this, 2, 1) + } + content = this + } + tabs.add(this) + } + Tab("License").apply { + TextArea(LICENSE).apply { isEditable = false }.also { content = it } + tabs.add(this) + } + } + } +} - isEditable = false - } - } - field("BTC:") { - textfield("bc1qcqudnkrndwyadsjwrxww42svkf8trnzx3c8vlr") { - isEditable = false - } - } - } - } - } - } - } - tab("System") { - form { - fieldset { - field("Application data folder") { - textfield { - text = ApplicationProperties.VRIPPER_DIR.pathString - isEditable = false - } - } - field("Previews Path") { - textfield(widgetsController.currentSettings.cachePathProperty) { - isEditable = false - } - button("Browse") { - action { - val directory = chooseDirectory(title = "Select previews folder") - if (directory != null) { - widgetsController.currentSettings.cachePathProperty.set(directory.path) - } - } - } - } - } - } - } - tab("License") { - textarea( - """ +val LICENSE = """ GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 @@ -781,11 +801,4 @@ may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . - """.trimIndent() - ).apply { - isEditable = false - } - } - } - } -} \ No newline at end of file + """.trimIndent() \ No newline at end of file diff --git a/vripper-gui/src/main/kotlin/me/vripper/gui/components/fragments/DownloadSettingsFragment.kt b/vripper-gui/src/main/kotlin/me/vripper/gui/components/fragments/DownloadSettingsFragment.kt index 3ae93ca..904c2c0 100644 --- a/vripper-gui/src/main/kotlin/me/vripper/gui/components/fragments/DownloadSettingsFragment.kt +++ b/vripper-gui/src/main/kotlin/me/vripper/gui/components/fragments/DownloadSettingsFragment.kt @@ -7,12 +7,14 @@ import me.vripper.gui.controller.SettingsController import me.vripper.gui.controller.WidgetsController import me.vripper.gui.model.settings.DownloadSettingsModel import me.vripper.model.DownloadSettings +import org.koin.core.component.KoinComponent +import org.koin.core.component.inject import tornadofx.* -class DownloadSettingsFragment : Fragment("Download Settings") { +class DownloadSettingsFragment : Fragment("Download Settings"), KoinComponent { private val settingsController: SettingsController by inject() - private val widgetsController: WidgetsController by inject() + private val widgetsController: WidgetsController by inject() private val coroutineScope = CoroutineScope(SupervisorJob() + Dispatchers.IO) private lateinit var downloadSettings: DownloadSettings val downloadSettingsModel = DownloadSettingsModel() diff --git a/vripper-gui/src/main/kotlin/me/vripper/gui/components/fragments/SessionFragment.kt b/vripper-gui/src/main/kotlin/me/vripper/gui/components/fragments/SessionFragment.kt index 16ccc28..08e7d92 100644 --- a/vripper-gui/src/main/kotlin/me/vripper/gui/components/fragments/SessionFragment.kt +++ b/vripper-gui/src/main/kotlin/me/vripper/gui/components/fragments/SessionFragment.kt @@ -14,11 +14,13 @@ import me.vripper.gui.event.GuiEventBus import me.vripper.gui.services.GrpcEndpointService import me.vripper.gui.utils.AppEndpointManager import me.vripper.listeners.AppManager +import org.koin.core.component.KoinComponent +import org.koin.core.component.inject import tornadofx.* -class SessionFragment : Fragment("Change Session") { +class SessionFragment : Fragment("Change Session"), KoinComponent { - private val widgetsController: WidgetsController by inject() + private val widgetsController: WidgetsController by inject() private val grpcEndpointService: GrpcEndpointService by di("remoteAppEndpointService") private val toggleGroup = ToggleGroup() override val root = VBox().apply { diff --git a/vripper-gui/src/main/kotlin/me/vripper/gui/components/fragments/SystemSettingsFragment.kt b/vripper-gui/src/main/kotlin/me/vripper/gui/components/fragments/SystemSettingsFragment.kt index 3b83800..bfb4e89 100644 --- a/vripper-gui/src/main/kotlin/me/vripper/gui/components/fragments/SystemSettingsFragment.kt +++ b/vripper-gui/src/main/kotlin/me/vripper/gui/components/fragments/SystemSettingsFragment.kt @@ -8,11 +8,13 @@ import me.vripper.gui.controller.SettingsController import me.vripper.gui.controller.WidgetsController import me.vripper.gui.model.settings.SystemSettingsModel import me.vripper.model.SystemSettings +import org.koin.core.component.KoinComponent +import org.koin.core.component.inject import tornadofx.* -class SystemSettingsFragment : Fragment("System Settings") { +class SystemSettingsFragment : Fragment("System Settings"), KoinComponent { private val settingsController: SettingsController by inject() - private val widgetsController: WidgetsController by inject() + private val widgetsController: WidgetsController by inject() private val coroutineScope = CoroutineScope(SupervisorJob() + Dispatchers.IO) private lateinit var systemSettings: SystemSettings val systemSettingsModel = SystemSettingsModel() diff --git a/vripper-gui/src/main/kotlin/me/vripper/gui/components/fragments/ThreadSelectionTableFragment.kt b/vripper-gui/src/main/kotlin/me/vripper/gui/components/fragments/ThreadSelectionTableFragment.kt index b2f8952..ff96800 100644 --- a/vripper-gui/src/main/kotlin/me/vripper/gui/components/fragments/ThreadSelectionTableFragment.kt +++ b/vripper-gui/src/main/kotlin/me/vripper/gui/components/fragments/ThreadSelectionTableFragment.kt @@ -19,16 +19,18 @@ import me.vripper.gui.controller.WidgetsController import me.vripper.gui.model.ThreadSelectionModel import me.vripper.gui.utils.Preview import me.vripper.gui.utils.openLink +import org.koin.core.component.KoinComponent +import org.koin.core.component.inject import org.kordamp.ikonli.feather.Feather import org.kordamp.ikonli.javafx.FontIcon import tornadofx.* import kotlin.io.path.Path -class ThreadSelectionTableFragment : Fragment("Thread") { +class ThreadSelectionTableFragment : Fragment("Thread"), KoinComponent { private lateinit var tableView: TableView private val threadController: ThreadController by inject() - private val widgetsController: WidgetsController by inject() + private val widgetsController: WidgetsController by inject() private var items = SortedFilteredList() private var preview: Preview? = null private val searchInput = SimpleStringProperty() diff --git a/vripper-gui/src/main/kotlin/me/vripper/gui/components/views/AppView.kt b/vripper-gui/src/main/kotlin/me/vripper/gui/components/views/AppView.kt index 546395f..bac77f1 100644 --- a/vripper-gui/src/main/kotlin/me/vripper/gui/components/views/AppView.kt +++ b/vripper-gui/src/main/kotlin/me/vripper/gui/components/views/AppView.kt @@ -1,18 +1,20 @@ package me.vripper.gui.components.views -import atlantafx.base.theme.CupertinoDark -import atlantafx.base.theme.CupertinoLight +import atlantafx.base.theme.NordDark +import atlantafx.base.theme.NordLight import javafx.application.Application import kotlinx.coroutines.runBlocking import me.vripper.gui.controller.MainController import me.vripper.gui.controller.WidgetsController import me.vripper.gui.event.GuiEventBus +import org.koin.core.component.KoinComponent +import org.koin.core.component.inject import tornadofx.View import tornadofx.onChange import tornadofx.runLater import tornadofx.vbox -class AppView : View() { +class AppView : View(), KoinComponent { override val root = vbox { } private val mainController: MainController by inject() @@ -20,7 +22,7 @@ class AppView : View() { private val mainView: MainView by inject() private val statusBarView: StatusBarView by inject() private val actionBarView: ActionBarView by inject() - private val widgetsController: WidgetsController by inject() + private val widgetsController: WidgetsController by inject() init { title = "VRipper ${mainController.version}" with(root) { @@ -54,9 +56,9 @@ class AppView : View() { widgetsController.currentSettings.darkModeProperty.onChange { if (it) { - Application.setUserAgentStylesheet(CupertinoDark().userAgentStylesheet) + Application.setUserAgentStylesheet(NordDark().userAgentStylesheet) } else { - Application.setUserAgentStylesheet(CupertinoLight().userAgentStylesheet) + Application.setUserAgentStylesheet(NordLight().userAgentStylesheet) } } diff --git a/vripper-gui/src/main/kotlin/me/vripper/gui/components/views/ImagesTableView.kt b/vripper-gui/src/main/kotlin/me/vripper/gui/components/views/ImagesTableView.kt index afa2fc0..98b0bf1 100644 --- a/vripper-gui/src/main/kotlin/me/vripper/gui/components/views/ImagesTableView.kt +++ b/vripper-gui/src/main/kotlin/me/vripper/gui/components/views/ImagesTableView.kt @@ -22,16 +22,18 @@ import me.vripper.gui.controller.WidgetsController import me.vripper.gui.model.ImageModel import me.vripper.gui.utils.Preview import me.vripper.gui.utils.openLink +import org.koin.core.component.KoinComponent +import org.koin.core.component.inject import org.kordamp.ikonli.feather.Feather import org.kordamp.ikonli.javafx.FontIcon import tornadofx.* import kotlin.io.path.Path -class ImagesTableView : View("Photos") { +class ImagesTableView : View("Photos"), KoinComponent { private val tableView: TableView private val imageController: ImageController by inject() - private val widgetsController: WidgetsController by inject() + private val widgetsController: WidgetsController by inject() private val coroutineScope = CoroutineScope(SupervisorJob() + Dispatchers.IO) private val items: ObservableList = FXCollections.observableArrayList() private var preview: Preview? = null diff --git a/vripper-gui/src/main/kotlin/me/vripper/gui/components/views/LoadingView.kt b/vripper-gui/src/main/kotlin/me/vripper/gui/components/views/LoadingView.kt index faee138..247f651 100644 --- a/vripper-gui/src/main/kotlin/me/vripper/gui/components/views/LoadingView.kt +++ b/vripper-gui/src/main/kotlin/me/vripper/gui/components/views/LoadingView.kt @@ -12,11 +12,13 @@ import me.vripper.gui.utils.ClipboardManager import me.vripper.gui.utils.Watcher import me.vripper.listeners.AppManager import me.vripper.utilities.DatabaseManager +import org.koin.core.component.KoinComponent +import org.koin.core.component.inject import tornadofx.* -class LoadingView : View("VRipper") { +class LoadingView : View("VRipper"), KoinComponent { - private val widgetsController: WidgetsController by inject() + private val widgetsController: WidgetsController by inject() private val grpcEndpointService: GrpcEndpointService by di("remoteAppEndpointService") private val coroutineScope: CoroutineScope = CoroutineScope(SupervisorJob() + Dispatchers.IO) diff --git a/vripper-gui/src/main/kotlin/me/vripper/gui/components/views/LogTableView.kt b/vripper-gui/src/main/kotlin/me/vripper/gui/components/views/LogTableView.kt index ae06d73..a5afcc4 100644 --- a/vripper-gui/src/main/kotlin/me/vripper/gui/components/views/LogTableView.kt +++ b/vripper-gui/src/main/kotlin/me/vripper/gui/components/views/LogTableView.kt @@ -13,14 +13,16 @@ import me.vripper.gui.controller.LogController import me.vripper.gui.controller.WidgetsController import me.vripper.gui.event.GuiEventBus import me.vripper.gui.model.LogModel +import org.koin.core.component.KoinComponent +import org.koin.core.component.inject import org.kordamp.ikonli.feather.Feather import org.kordamp.ikonli.javafx.FontIcon import tornadofx.* -class LogTableView : View() { +class LogTableView : View(), KoinComponent { private val logController: LogController by inject() - private val widgetsController: WidgetsController by inject() + private val widgetsController: WidgetsController by inject() private val tableView: TableView private val coroutineScope = CoroutineScope(SupervisorJob() + Dispatchers.IO) private val items: ObservableList = FXCollections.observableArrayList() diff --git a/vripper-gui/src/main/kotlin/me/vripper/gui/components/views/MenuBarView.kt b/vripper-gui/src/main/kotlin/me/vripper/gui/components/views/MenuBarView.kt index d58bc81..5c345d3 100644 --- a/vripper-gui/src/main/kotlin/me/vripper/gui/components/views/MenuBarView.kt +++ b/vripper-gui/src/main/kotlin/me/vripper/gui/components/views/MenuBarView.kt @@ -18,15 +18,17 @@ import me.vripper.gui.controller.WidgetsController import me.vripper.gui.utils.openLink import me.vripper.services.IAppEndpointService import me.vripper.utilities.ApplicationProperties +import org.koin.core.component.KoinComponent +import org.koin.core.component.inject import org.kordamp.ikonli.feather.Feather import org.kordamp.ikonli.javafx.FontIcon import tornadofx.* -class MenuBarView : View() { +class MenuBarView : View(), KoinComponent { private val coroutineScope = CoroutineScope(SupervisorJob() + Dispatchers.IO) private val downloadActiveProperty = SimpleBooleanProperty(false) private val postsTableView: PostsTableView by inject() - private val widgetsController: WidgetsController by inject() + private val widgetsController: WidgetsController by inject() private val postController: PostController by inject() private val actionBarController: ActionBarController by inject() private lateinit var appEndpointService: IAppEndpointService @@ -190,7 +192,10 @@ class MenuBarView : View() { item("About").apply { graphic = FontIcon.of(Feather.INFO) action { - find().openModal()?.apply { + AboutFragment( + width = 500.0, + height = 300.0 + ).openModal().apply { this.minWidth = 100.0 this.minHeight = 100.0 } diff --git a/vripper-gui/src/main/kotlin/me/vripper/gui/components/views/PostsTabView.kt b/vripper-gui/src/main/kotlin/me/vripper/gui/components/views/PostsTabView.kt index b131885..b792f4a 100644 --- a/vripper-gui/src/main/kotlin/me/vripper/gui/components/views/PostsTabView.kt +++ b/vripper-gui/src/main/kotlin/me/vripper/gui/components/views/PostsTabView.kt @@ -6,14 +6,16 @@ import javafx.scene.layout.Priority import kotlinx.coroutines.* import me.vripper.gui.controller.WidgetsController import me.vripper.gui.utils.WidgetSettings +import org.koin.core.component.KoinComponent +import org.koin.core.component.inject import tornadofx.* -class PostsTabView : View() { +class PostsTabView : View(), KoinComponent { override val root: SplitPane = splitpane() private val postsTableView: PostsTableView by inject() private val postInfoView: PostInfoView by inject() - private val widgetsController: WidgetsController by inject() + private val widgetsController: WidgetsController by inject() private val coroutineScope = CoroutineScope(SupervisorJob()) init { diff --git a/vripper-gui/src/main/kotlin/me/vripper/gui/components/views/PostsTableView.kt b/vripper-gui/src/main/kotlin/me/vripper/gui/components/views/PostsTableView.kt index 3a54954..539a5dd 100644 --- a/vripper-gui/src/main/kotlin/me/vripper/gui/components/views/PostsTableView.kt +++ b/vripper-gui/src/main/kotlin/me/vripper/gui/components/views/PostsTableView.kt @@ -31,15 +31,17 @@ import me.vripper.gui.model.PostModel import me.vripper.gui.utils.Preview import me.vripper.gui.utils.openFileDirectory import me.vripper.gui.utils.openLink +import org.koin.core.component.KoinComponent +import org.koin.core.component.inject import org.kordamp.ikonli.feather.Feather import org.kordamp.ikonli.javafx.FontIcon import tornadofx.* import kotlin.io.path.Path -class PostsTableView : View() { +class PostsTableView : View(), KoinComponent { private val coroutineScope = CoroutineScope(SupervisorJob() + Dispatchers.IO) private val postController: PostController by inject() - private val widgetsController: WidgetsController by inject() + private val widgetsController: WidgetsController by inject() private val mainView: MainView by inject() val tableView: TableView diff --git a/vripper-gui/src/main/kotlin/me/vripper/gui/components/views/StatusBarView.kt b/vripper-gui/src/main/kotlin/me/vripper/gui/components/views/StatusBarView.kt index cb0c647..81f293c 100644 --- a/vripper-gui/src/main/kotlin/me/vripper/gui/components/views/StatusBarView.kt +++ b/vripper-gui/src/main/kotlin/me/vripper/gui/components/views/StatusBarView.kt @@ -10,10 +10,12 @@ import me.vripper.gui.controller.StatusBarController import me.vripper.gui.controller.WidgetsController import me.vripper.gui.event.GuiEventBus import me.vripper.utilities.formatSI +import org.koin.core.component.KoinComponent +import org.koin.core.component.inject import tornadofx.* -class StatusBarView : View("Status bar") { - private val widgetsController: WidgetsController by inject() +class StatusBarView : View("Status bar"), KoinComponent { + private val widgetsController: WidgetsController by inject() private val statusBarController: StatusBarController by inject() private val coroutineScope = CoroutineScope(SupervisorJob() + Dispatchers.IO) private val remoteText = SimpleStringProperty() diff --git a/vripper-gui/src/main/kotlin/me/vripper/gui/components/views/ThreadTableView.kt b/vripper-gui/src/main/kotlin/me/vripper/gui/components/views/ThreadTableView.kt index 300d071..5730f24 100644 --- a/vripper-gui/src/main/kotlin/me/vripper/gui/components/views/ThreadTableView.kt +++ b/vripper-gui/src/main/kotlin/me/vripper/gui/components/views/ThreadTableView.kt @@ -20,15 +20,17 @@ import me.vripper.gui.controller.WidgetsController import me.vripper.gui.event.GuiEventBus import me.vripper.gui.model.ThreadModel import me.vripper.gui.utils.openLink +import org.koin.core.component.KoinComponent +import org.koin.core.component.inject import org.kordamp.ikonli.feather.Feather import org.kordamp.ikonli.javafx.FontIcon import tornadofx.* -class ThreadTableView : View() { +class ThreadTableView : View(), KoinComponent { private val coroutineScope = CoroutineScope(SupervisorJob() + Dispatchers.IO) private val threadController: ThreadController by inject() - private val widgetsController: WidgetsController by inject() + private val widgetsController: WidgetsController by inject() private val mainView: MainView by inject() private val tableView: TableView private val items: ObservableList = FXCollections.observableArrayList() diff --git a/vripper-gui/src/main/kotlin/me/vripper/gui/controller/WidgetsController.kt b/vripper-gui/src/main/kotlin/me/vripper/gui/controller/WidgetsController.kt index 8bf68ab..cf80669 100644 --- a/vripper-gui/src/main/kotlin/me/vripper/gui/controller/WidgetsController.kt +++ b/vripper-gui/src/main/kotlin/me/vripper/gui/controller/WidgetsController.kt @@ -3,10 +3,9 @@ package me.vripper.gui.controller import me.vripper.gui.model.WidgetsViewModel import me.vripper.gui.utils.WidgetSettings import me.vripper.gui.utils.WidgetSettings.loadSettings -import tornadofx.Controller import tornadofx.onChange -class WidgetsController : Controller() { +class WidgetsController { var currentSettings: WidgetsViewModel = loadSettings().let { WidgetsViewModel(