]> uap-core.de Git - rssreader.git/commitdiff
disable add-feed button, if no group exists
authorOlaf Wintermann <olaf.wintermann@gmail.com>
Sun, 24 May 2026 08:05:59 +0000 (10:05 +0200)
committerOlaf Wintermann <olaf.wintermann@gmail.com>
Sun, 24 May 2026 08:05:59 +0000 (10:05 +0200)
rss-application/src/main/kotlin/de/unixwork/rssreader/MainWindow.kt

index da130061cce1988cfa52028fb84756dce9773f2d..46160091aa7027cf240e24612fe446bfcd992ff9 100644 (file)
@@ -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<FeedGroup>(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<FeedGroup>(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()
                         }