From b58d60e62bf2ba03f1c242d158215802531a2ee8 Mon Sep 17 00:00:00 2001 From: Olaf Wintermann Date: Fri, 23 Jan 2026 16:51:41 +0100 Subject: [PATCH] hide notebook input fields that are not relevant for groups --- application/nbconfig.c | 28 ++++++++++++++++++------- application/nbconfig.h | 2 ++ ui/gtk/list.c | 6 ++++++ ui/qt/text.cpp | 47 ++++++++++++++++++++++++++++++++++++++++++ ui/ui/list.h | 1 + 5 files changed, 77 insertions(+), 7 deletions(-) diff --git a/application/nbconfig.c b/application/nbconfig.c index 03ab7f2..2786593 100644 --- a/application/nbconfig.c +++ b/application/nbconfig.c @@ -236,6 +236,12 @@ static void nbconfig_notebooklist_onselect(UiEvent *event, void *userdata) { nbconfig_load_notebook(wdata, res); nbconfig_build_current_names_map(wdata, res); + + if(res->parent_id == wdata->root_resource_id) { + ui_unset_state(wdata->obj->ctx, NBCONFIG_STATE_NOTEBOOK_SELECTED); + } else { + ui_set_state(wdata->obj->ctx, NBCONFIG_STATE_NOTEBOOK_SELECTED); + } } static int get_notebook_insertpos(NotebookConfigDialog *wdata, int64_t parent_id) { @@ -535,25 +541,33 @@ void notebook_config_dialog(void) { .model = model, .getvalue2 = reslist_getvalue, .getvalue2data = wdata, .getstyle = reslist_getstyle, .getstyledata = wdata, - .width = 300, .fill = TRUE, + .width = 300, .fill = TRUE, .hide_header = TRUE, .onselection = nbconfig_notebooklist_onselect); } ui_grid(obj, .columnspacing = 10, .rowspacing = 10, .fill = TRUE, .def_vfill = TRUE) { - ui_rlabel(obj, .label = "Group"); - ui_dropdown(obj, .list = wdata->tab1_groups, .getvalue2 = reslist_getvalue, .getvalue2data = wdata, .onactivate = nbconfig_group_onselect); + int notebook_visible[] = { NBCONFIG_STATE_NOTEBOOK_SELECTED, -1 }; + + UIWIDGET w = ui_rlabel(obj, .label = "Group"); + ui_widget_set_visibility_states(obj->ctx, w, notebook_visible, 1); + w = ui_dropdown(obj, .list = wdata->tab1_groups, .getvalue2 = reslist_getvalue, .getvalue2data = wdata, .onactivate = nbconfig_group_onselect); + ui_widget_set_visibility_states(obj->ctx, w, notebook_visible, 1); ui_newline(obj); ui_rlabel(obj, .label = "Name"); wdata->tab1_notebook_name_textfield = ui_textfield(obj, .value = wdata->tab1_notebook_name, .onchange = nbconfig_notebooklist_name_changed); ui_newline(obj); - ui_rlabel(obj, .label = "Repository"); - ui_dropdown(obj, .list = wdata->tab1_repositories); + w = ui_rlabel(obj, .label = "Repository"); + ui_widget_set_visibility_states(obj->ctx, w, notebook_visible, 1); + w = ui_dropdown(obj, .list = wdata->tab1_repositories); + ui_widget_set_visibility_states(obj->ctx, w, notebook_visible, 1); ui_newline(obj); - ui_rlabel(obj, .label = "Type"); - ui_dropdown(obj, .list = wdata->tab1_types); + w = ui_rlabel(obj, .label = "Type"); + ui_widget_set_visibility_states(obj->ctx, w, notebook_visible, 1); + w = ui_dropdown(obj, .list = wdata->tab1_types); + ui_widget_set_visibility_states(obj->ctx, w, notebook_visible, 1); ui_newline(obj); } } diff --git a/application/nbconfig.h b/application/nbconfig.h index 6f41974..414f35b 100644 --- a/application/nbconfig.h +++ b/application/nbconfig.h @@ -35,6 +35,8 @@ #ifdef __cplusplus extern "C" { #endif + +#define NBCONFIG_STATE_NOTEBOOK_SELECTED 10 typedef struct NotebookConfigDialog { MainWindow *parent; diff --git a/ui/gtk/list.c b/ui/gtk/list.c index e8b649c..3914bf2 100644 --- a/ui/gtk/list.c +++ b/ui/gtk/list.c @@ -661,6 +661,9 @@ UIWIDGET ui_table_create(UiObject *obj, UiListArgs *args) { GtkSelectionModel *selection_model = create_selection_model(tableview, ls, args->multiselection); GtkWidget *view = gtk_column_view_new(GTK_SELECTION_MODEL(selection_model)); + if(args->hide_header) { + gtk_widget_set_visible(gtk_widget_get_first_child(view), FALSE); + } UiVar* var = uic_widget_var(obj->ctx, obj->ctx, args->list, args->varname, UI_VAR_LIST); @@ -1385,6 +1388,9 @@ static void table_cell_edited( UIWIDGET ui_table_create(UiObject *obj, UiListArgs *args) { // create treeview GtkWidget *view = gtk_tree_view_new(); + if(args->hide_header) { + gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(view), FALSE); + } UiModel *model = args->model; int columns = model ? model->columns : 0; diff --git a/ui/qt/text.cpp b/ui/qt/text.cpp index 32871a2..9582478 100644 --- a/ui/qt/text.cpp +++ b/ui/qt/text.cpp @@ -278,3 +278,50 @@ void ui_textfield_set(UiString *str, const char *value) { } str->value.ptr = NULL; } + +void ui_textfield_focus(UIWIDGET textfield) { + QLineEdit *edit = static_cast(textfield); + edit->setFocus(); + edit->selectAll(); +} + +void ui_textfield_focus_without_selecting(UIWIDGET textfield) { + QLineEdit *edit = static_cast(textfield); + edit->setFocus(); +} + +void ui_textfield_set_selection(UIWIDGET textfield, int begin, int end) { + QLineEdit *edit = static_cast(textfield); + if (begin < 0) { + begin = 0; + } + if (end < begin) { + end = begin; + } + edit->setSelection(begin, end - begin); +} + +void ui_textfield_select_all(UIWIDGET textfield) { + QLineEdit *edit = static_cast(textfield); + edit->selectAll(); +} + +void ui_textfield_set_editable(UIWIDGET textfield, UiBool editable) { + QLineEdit *edit = static_cast(textfield); + edit->setReadOnly(!editable); +} + +UiBool ui_textfield_is_editable(UIWIDGET textfield) { + QLineEdit *edit = static_cast(textfield); + return !edit->isReadOnly(); +} + +void ui_textfield_set_position(UIWIDGET textfield, int pos) { + QLineEdit *edit = static_cast(textfield); + edit->setCursorPosition(pos); +} + +int ui_textfield_get_position(UIWIDGET textfield) { + QLineEdit *edit = static_cast(textfield); + return edit->cursorPosition(); +} diff --git a/ui/ui/list.h b/ui/ui/list.h index 7cfbfbb..d74a2d9 100644 --- a/ui/ui/list.h +++ b/ui/ui/list.h @@ -175,6 +175,7 @@ struct UiListArgs { ui_callback ondrop; void *ondropdata; UiBool multiselection; + UiBool hide_header; UiMenuBuilder *contextmenu; ui_list_savefunc onsave; void *onsavedata; -- 2.47.3