-
-
Notifications
You must be signed in to change notification settings - Fork 264
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(desktop): new desktop application project
this is a thin wrapper consisting of a tray icon only
- Loading branch information
Showing
17 changed files
with
786 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
5 changes: 3 additions & 2 deletions
5
.idea/runConfigurations/komga__bootRun__dev_localdb_noclaim_oauth2.xml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
plugins { | ||
run { | ||
kotlin("jvm") | ||
kotlin("plugin.spring") | ||
} | ||
id("com.gorylenko.gradle-git-properties") version "2.4.1" | ||
id("org.jetbrains.compose") version "1.4.3" | ||
id("dev.hydraulic.conveyor") version "1.5" | ||
application | ||
} | ||
|
||
group = "org.gotson" | ||
|
||
kotlin { | ||
jvmToolchain(19) // for NightMonkeys | ||
} | ||
|
||
dependencies { | ||
implementation(project(":komga")) | ||
implementation(platform("org.springframework.boot:spring-boot-dependencies:3.1.1")) | ||
implementation("org.springframework.boot:spring-boot-starter-web") | ||
|
||
implementation(compose.desktop.common) | ||
|
||
linuxAmd64(compose.desktop.linux_x64) | ||
macAmd64(compose.desktop.macos_x64) | ||
macAarch64(compose.desktop.macos_arm64) | ||
windowsAmd64(compose.desktop.windows_x64) | ||
} | ||
|
||
application { | ||
mainClass.set("org.gotson.komga.DesktopApplicationKt") | ||
} | ||
|
||
// Work around temporary Compose bugs | ||
configurations.all { | ||
attributes { | ||
attribute(Attribute.of("ui", String::class.java), "awt") | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
komga-tray/src/main/kotlin/org/gotson/komga/DesktopApplication.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package org.gotson.komga | ||
|
||
import org.springframework.boot.builder.SpringApplicationBuilder | ||
|
||
fun main(args: Array<String>) { | ||
System.setProperty("apple.awt.UIElement", "true") | ||
System.setProperty("org.jooq.no-logo", "true") | ||
System.setProperty("org.jooq.no-tips", "true") | ||
val builder = SpringApplicationBuilder(Application::class.java) | ||
builder.headless(false) | ||
builder.run(*args) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package org.gotson.komga | ||
|
||
import java.awt.Desktop | ||
import java.net.URI | ||
|
||
fun openUrl(url: String) { | ||
if (Desktop.isDesktopSupported()) | ||
Desktop.getDesktop().let { | ||
if (it.isSupported(Desktop.Action.BROWSE)) it.browse(URI.create(url)) | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
komga-tray/src/main/kotlin/org/gotson/komga/application/gui/TrayIconRunner.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package org.gotson.komga.application.gui | ||
|
||
import androidx.compose.ui.platform.LocalDensity | ||
import androidx.compose.ui.res.loadSvgPainter | ||
import androidx.compose.ui.window.Tray | ||
import androidx.compose.ui.window.application | ||
import org.gotson.komga.openUrl | ||
import org.springframework.beans.factory.annotation.Value | ||
import org.springframework.boot.ApplicationArguments | ||
import org.springframework.boot.ApplicationRunner | ||
import org.springframework.context.annotation.Profile | ||
import org.springframework.core.env.Environment | ||
import org.springframework.core.io.ClassPathResource | ||
import org.springframework.stereotype.Component | ||
|
||
@Profile("!test") | ||
@Component | ||
class TrayIconRunner( | ||
@Value("#{servletContext.contextPath}") servletContextPath: String, | ||
@Value("\${server.port}") serverPort: Int, | ||
env: Environment, | ||
) : ApplicationRunner { | ||
|
||
val komgaUrl = "http://localhost:$serverPort$servletContextPath" | ||
val iconFileName = if (env.activeProfiles.contains("mac")) "komga-gray-minimal.svg" else "komga-color.svg" | ||
override fun run(args: ApplicationArguments) { | ||
runTray() | ||
} | ||
|
||
private fun runTray() { | ||
application { | ||
Tray( | ||
icon = loadSvgPainter(ClassPathResource("icons/$iconFileName").inputStream, LocalDensity.current), | ||
menu = { | ||
Item("Open Komga", onClick = { openUrl(komgaUrl) }) | ||
Item("Quit Komga", onClick = ::exitApplication) | ||
}, | ||
) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
logging: | ||
file: | ||
name: ${user.home}/Library/Logs/Komga/komga.log | ||
komga: | ||
config-dir: ${user.home}/Library/Application Support/Komga |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
komga: | ||
config-dir: ${LOCALAPPDATA}/Komga |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.