]> git.lyx.org Git - features.git/blobdiff - src/frontends/qt4/GuiBranches.cpp
* GuiBranches.{cpp,h}: UI polishment.
[features.git] / src / frontends / qt4 / GuiBranches.cpp
index 45e60de9624c0a101de3a247dc9de2b1c4d8a02c..08bca169840d263a87013bf30ef16fad1af9c134 100644 (file)
@@ -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)