From: Olaf Wintermann Date: Sun, 24 May 2026 08:05:59 +0000 (+0200) Subject: disable add-feed button, if no group exists X-Git-Url: https://uap-core.de/gitweb/?a=commitdiff_plain;h=df8619c3afc1de3a6a9b6986d2b9601f93e75153;p=rssreader.git disable add-feed button, if no group exists --- diff --git a/rss-application/src/main/kotlin/de/unixwork/rssreader/MainWindow.kt b/rss-application/src/main/kotlin/de/unixwork/rssreader/MainWindow.kt index da13006..4616009 100644 --- a/rss-application/src/main/kotlin/de/unixwork/rssreader/MainWindow.kt +++ b/rss-application/src/main/kotlin/de/unixwork/rssreader/MainWindow.kt @@ -18,6 +18,7 @@ import java.time.format.DateTimeFormatter class MainWindow() { companion object { + const val HAS_FOLDERS = 100 const val ITEM_SELETED = 900 const val ITEM_HAS_AUTHOR = 1000 const val ITEM_HAS_CATEGORY = 1001 @@ -144,6 +145,9 @@ class MainWindow() { onClick = { ev -> if(ev.intValue == 4) { sourceList.removeFeedGroup(feedGroup) + if(sourceList.groups.size == 0) { + window.unsetState(HAS_FOLDERS) + } GlobalScope.launch(Dispatchers.IO) { if(move!!.booleanValue() && groups!!.selected != null) { // move and delete @@ -163,10 +167,12 @@ class MainWindow() { row { label(label = "Delete ${feedGroup.name}?", colspan = 2, style = LabelStyle.TITLE, hexpand = true, hfill = true) } - row { - checkbox(label = "Move feeds to other group", value = move, vfill = true, enableState = 1) - dropdown(value = groups, vfill = true, states = intArrayOf(1)) { elm, i -> - elm.name + if(sourceList.groups.size > 1) { + row { + checkbox(label = "Move feeds to other group", value = move, vfill = true, enableState = 1) + dropdown(value = groups, vfill = true, states = intArrayOf(HAS_FOLDERS)) { elm, i -> + elm.name + } } } } @@ -234,7 +240,7 @@ class MainWindow() { item } hbox(margin = 4, spacing = 4) { - button(icon = "list-add") { + button(icon = "list-add", states = intArrayOf(HAS_FOLDERS)) { createFeedDialog() } button(icon = "folder-new") { @@ -340,6 +346,10 @@ class MainWindow() { window.attach(sourceList) window.attach(feedList) + + if(sourceList.groups.size > 0) { + window.setState(HAS_FOLDERS) + } } fun reload() { @@ -401,6 +411,7 @@ class MainWindow() { try { val group = Database.newFeedGroup(sourceList,nameStr) sourceList.addFeedGroup(group) + window.setState(HAS_FOLDERS) } catch (e: Exception) { e.printStackTrace() }