From 51660301747e746851ecbe10e8ca57dd8ba15b60 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=BCrgen=20Spitzm=C3=BCller?= Date: Sat, 11 Jul 2009 06:12:27 +0000 Subject: [PATCH] * GuiBranches.{cpp,h}: UI polishment. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@30461 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt4/GuiBranches.cpp | 17 ++++++++++++++++- src/frontends/qt4/GuiBranches.h | 1 + 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/frontends/qt4/GuiBranches.cpp b/src/frontends/qt4/GuiBranches.cpp index 45e60de962..08bca16984 100644 --- a/src/frontends/qt4/GuiBranches.cpp +++ b/src/frontends/qt4/GuiBranches.cpp @@ -108,6 +108,10 @@ void GuiBranches::updateView() } } unknownPB->setEnabled(!unknown_branches_.isEmpty()); + bool const have_sel = + !branchesTW->selectedItems().isEmpty(); + removePB->setEnabled(have_sel); + renamePB->setEnabled(have_sel); // emit signal changed(); } @@ -154,7 +158,9 @@ void GuiBranches::on_renamePB_pressed() docstring newname; docstring const oldname = qstring_to_ucs4(sel_branch); bool success = false; - if (Alert::askForText(newname, _("Enter new branch name"))) { + if (Alert::askForText(newname, _("Enter new branch name"), oldname)) { + if (newname.empty() || oldname == newname) + return; if (branchlist_.find(newname)) { docstring text = support::bformat( _("A branch with the name \"%1$s\" already exists.\n" @@ -193,6 +199,15 @@ void GuiBranches::on_branchesTW_itemDoubleClicked(QTreeWidgetItem * item, int co } +void GuiBranches::on_branchesTW_itemSelectionChanged() +{ + bool const have_sel = + !branchesTW->selectedItems().isEmpty(); + removePB->setEnabled(have_sel); + renamePB->setEnabled(have_sel); +} + + void GuiBranches::toggleBranch(QTreeWidgetItem * item) { if (item == 0) diff --git a/src/frontends/qt4/GuiBranches.h b/src/frontends/qt4/GuiBranches.h index 514878ce20..b42cc5e362 100644 --- a/src/frontends/qt4/GuiBranches.h +++ b/src/frontends/qt4/GuiBranches.h @@ -63,6 +63,7 @@ protected Q_SLOTS: void on_renamePB_pressed(); void on_activatePB_pressed(); void on_branchesTW_itemDoubleClicked(QTreeWidgetItem *, int); + void on_branchesTW_itemSelectionChanged(); void on_colorPB_clicked(); void on_unknownPB_pressed(); void addUnknown(); -- 2.39.2