Avoids Locallab treeview search popup, fixes #5265

Thanks to Beep6581

Others:
- Cleanup/improvements of controlspotpanel constructor
This commit is contained in:
Pandagrapher
2019-04-18 20:09:45 +02:00
parent 152d8c3879
commit 853a6f0e2c
3 changed files with 101 additions and 77 deletions

View File

@@ -34,12 +34,15 @@ ControlSpotPanel::ControlSpotPanel():
EditSubscriber(ET_OBJECTS), EditSubscriber(ET_OBJECTS),
FoldableToolPanel(this, "controlspotpanel", M("TP_LOCALLAB_SETTINGS")), FoldableToolPanel(this, "controlspotpanel", M("TP_LOCALLAB_SETTINGS")),
button_add_(M("TP_LOCALLAB_BUTTON_ADD")), scrolledwindow_(Gtk::manage(new Gtk::ScrolledWindow())),
button_delete_(M("TP_LOCALLAB_BUTTON_DEL")), treeview_(Gtk::manage(new Gtk::TreeView())),
button_duplicate_(M("TP_LOCALLAB_BUTTON_DUPL")),
button_rename_(M("TP_LOCALLAB_BUTTON_REN")), button_add_(Gtk::manage(new Gtk::Button(M("TP_LOCALLAB_BUTTON_ADD")))),
button_visibility_(M("TP_LOCALLAB_BUTTON_VIS")), button_delete_(Gtk::manage(new Gtk::Button(M("TP_LOCALLAB_BUTTON_DEL")))),
button_duplicate_(Gtk::manage(new Gtk::Button(M("TP_LOCALLAB_BUTTON_DUPL")))),
button_rename_(Gtk::manage(new Gtk::Button(M("TP_LOCALLAB_BUTTON_REN")))),
button_visibility_(Gtk::manage(new Gtk::Button(M("TP_LOCALLAB_BUTTON_VIS")))),
shape_(Gtk::manage(new MyComboBoxText())), shape_(Gtk::manage(new MyComboBoxText())),
spotMethod_(Gtk::manage(new MyComboBoxText())), spotMethod_(Gtk::manage(new MyComboBoxText())),
@@ -75,46 +78,42 @@ ControlSpotPanel::ControlSpotPanel():
excluFrame(Gtk::manage(new Gtk::Frame(M("TP_LOCALLAB_EXCLUF")))) excluFrame(Gtk::manage(new Gtk::Frame(M("TP_LOCALLAB_EXCLUF"))))
{ {
Gtk::HBox* const hbox1_ = Gtk::manage(new Gtk::HBox(true, 4)); Gtk::HBox* const hbox1_ = Gtk::manage(new Gtk::HBox(true, 4));
hbox1_->pack_start(button_add_); buttonaddconn_ = button_add_->signal_clicked().connect(
hbox1_->pack_start(button_delete_); sigc::mem_fun(*this, &ControlSpotPanel::on_button_add));
hbox1_->pack_start(button_duplicate_); buttondeleteconn_ = button_delete_->signal_clicked().connect(
sigc::mem_fun(*this, &ControlSpotPanel::on_button_delete));
buttonduplicateconn_ = button_duplicate_->signal_clicked().connect(
sigc::mem_fun(*this, &ControlSpotPanel::on_button_duplicate));
hbox1_->pack_start(*button_add_);
hbox1_->pack_start(*button_delete_);
hbox1_->pack_start(*button_duplicate_);
pack_start(*hbox1_); pack_start(*hbox1_);
Gtk::HBox* const hbox2_ = Gtk::manage(new Gtk::HBox(true, 4)); Gtk::HBox* const hbox2_ = Gtk::manage(new Gtk::HBox(true, 4));
hbox2_->pack_start(button_rename_); buttonrenameconn_ = button_rename_->signal_clicked().connect(
hbox2_->pack_start(button_visibility_); sigc::mem_fun(*this, &ControlSpotPanel::on_button_rename));
buttonvisibilityconn_ = button_visibility_->signal_clicked().connect(
sigc::mem_fun(*this, &ControlSpotPanel::on_button_visibility));
hbox2_->pack_start(*button_rename_);
hbox2_->pack_start(*button_visibility_);
pack_start(*hbox2_); pack_start(*hbox2_);
buttonaddconn_ = button_add_.signal_clicked().connect(
sigc::mem_fun(*this, &ControlSpotPanel::on_button_add));
buttondeleteconn_ = button_delete_.signal_clicked().connect(
sigc::mem_fun(*this, &ControlSpotPanel::on_button_delete));
buttonduplicateconn_ = button_duplicate_.signal_clicked().connect(
sigc::mem_fun(*this, &ControlSpotPanel::on_button_duplicate));
buttonrenameconn_ = button_rename_.signal_clicked().connect(
sigc::mem_fun(*this, &ControlSpotPanel::on_button_rename));
buttonvisibilityconn_ = button_visibility_.signal_clicked().connect(
sigc::mem_fun(*this, &ControlSpotPanel::on_button_visibility));
treeview_.set_grid_lines(Gtk::TREE_VIEW_GRID_LINES_VERTICAL);
scrolledwindow_.add(treeview_);
scrolledwindow_.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
scrolledwindow_.set_min_content_height(150);
pack_start(scrolledwindow_);
treemodel_ = Gtk::ListStore::create(spots_); treemodel_ = Gtk::ListStore::create(spots_);
treeview_->set_model(treemodel_);
treeview_.set_model(treemodel_); treeviewconn_ = treeview_->get_selection()->signal_changed().connect(
treeviewconn_ = treeview_.get_selection()->signal_changed().connect(
sigc::mem_fun( sigc::mem_fun(
*this, &ControlSpotPanel::controlspotChanged)); *this, &ControlSpotPanel::controlspotChanged));
treeview_->set_grid_lines(Gtk::TREE_VIEW_GRID_LINES_VERTICAL);
// Disable search to prevent hijacking keyboard shortcuts #5265
treeview_->set_enable_search(false);
treeview_->signal_key_press_event().connect(
sigc::mem_fun(
*this, &ControlSpotPanel::blockTreeviewSearch), false);
auto cell = Gtk::manage(new Gtk::CellRendererText()); auto cell = Gtk::manage(new Gtk::CellRendererText());
int cols_count = treeview_.append_column("ID", *cell); int cols_count = treeview_->append_column("ID", *cell);
auto col = treeview_.get_column(cols_count - 1); auto col = treeview_->get_column(cols_count - 1);
if (col) { if (col) {
col->set_cell_data_func( col->set_cell_data_func(
@@ -123,8 +122,8 @@ ControlSpotPanel::ControlSpotPanel():
} }
cell = Gtk::manage(new Gtk::CellRendererText()); cell = Gtk::manage(new Gtk::CellRendererText());
cols_count = treeview_.append_column(M("TP_LOCALLAB_COL_NAME"), *cell); cols_count = treeview_->append_column(M("TP_LOCALLAB_COL_NAME"), *cell);
col = treeview_.get_column(cols_count - 1); col = treeview_->get_column(cols_count - 1);
if (col) { if (col) {
col->set_cell_data_func( col->set_cell_data_func(
@@ -133,8 +132,8 @@ ControlSpotPanel::ControlSpotPanel():
} }
cell = Gtk::manage(new Gtk::CellRendererText()); cell = Gtk::manage(new Gtk::CellRendererText());
cols_count = treeview_.append_column(M("TP_LOCALLAB_COL_VIS"), *cell); cols_count = treeview_->append_column(M("TP_LOCALLAB_COL_VIS"), *cell);
col = treeview_.get_column(cols_count - 1); col = treeview_->get_column(cols_count - 1);
if (col) { if (col) {
col->set_cell_data_func( col->set_cell_data_func(
@@ -142,6 +141,11 @@ ControlSpotPanel::ControlSpotPanel():
*this, &ControlSpotPanel::render_isvisible)); *this, &ControlSpotPanel::render_isvisible));
} }
scrolledwindow_->add(*treeview_);
scrolledwindow_->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
scrolledwindow_->set_min_content_height(150);
pack_start(*scrolledwindow_);
Gtk::HBox* const ctboxshape = Gtk::manage(new Gtk::HBox()); Gtk::HBox* const ctboxshape = Gtk::manage(new Gtk::HBox());
Gtk::Label* const labelshape = Gtk::manage(new Gtk::Label(M("TP_LOCALLAB_SHAPETYPE") + ":")); Gtk::Label* const labelshape = Gtk::manage(new Gtk::Label(M("TP_LOCALLAB_SHAPETYPE") + ":"));
ctboxshape->pack_start(*labelshape, Gtk::PACK_SHRINK, 4); ctboxshape->pack_start(*labelshape, Gtk::PACK_SHRINK, 4);
@@ -218,7 +222,6 @@ ControlSpotPanel::ControlSpotPanel():
Gtk::Label* const labelqualitymethod = Gtk::manage(new Gtk::Label(M("TP_LOCALLAB_QUAL_METHOD") + ":")); Gtk::Label* const labelqualitymethod = Gtk::manage(new Gtk::Label(M("TP_LOCALLAB_QUAL_METHOD") + ":"));
ctboxqualitymethod->pack_start(*labelqualitymethod, Gtk::PACK_SHRINK, 4); ctboxqualitymethod->pack_start(*labelqualitymethod, Gtk::PACK_SHRINK, 4);
ctboxqualitymethod->set_tooltip_markup(M("TP_LOCALLAB_METHOD_TOOLTIP")); ctboxqualitymethod->set_tooltip_markup(M("TP_LOCALLAB_METHOD_TOOLTIP"));
// qualityMethod_->append(M("TP_LOCALLAB_STD"));
qualityMethod_->append(M("TP_LOCALLAB_ENH")); qualityMethod_->append(M("TP_LOCALLAB_ENH"));
qualityMethod_->append(M("TP_LOCALLAB_ENHDEN")); qualityMethod_->append(M("TP_LOCALLAB_ENHDEN"));
qualityMethod_->set_active(1); qualityMethod_->set_active(1);
@@ -242,7 +245,6 @@ ControlSpotPanel::ControlSpotPanel():
transitFrame->add(*transitBox); transitFrame->add(*transitBox);
pack_start(*transitFrame); pack_start(*transitFrame);
Gtk::Frame* const artifFrame = Gtk::manage(new Gtk::Frame(M("TP_LOCALLAB_ARTIF"))); Gtk::Frame* const artifFrame = Gtk::manage(new Gtk::Frame(M("TP_LOCALLAB_ARTIF")));
artifFrame->set_label_align(0.025, 0.5); artifFrame->set_label_align(0.025, 0.5);
artifFrame->set_tooltip_text(M("TP_LOCALLAB_ARTIF_TOOLTIP")); artifFrame->set_tooltip_text(M("TP_LOCALLAB_ARTIF_TOOLTIP"));
@@ -408,7 +410,7 @@ void ControlSpotPanel::on_button_rename()
} }
// Get actual control spot name // Get actual control spot name
const auto s = treeview_.get_selection(); const auto s = treeview_->get_selection();
if (!s->count_selected_rows()) { if (!s->count_selected_rows()) {
return; return;
@@ -429,7 +431,7 @@ void ControlSpotPanel::on_button_rename()
if (newname != actualname) { // Event is only raised if name is updated if (newname != actualname) { // Event is only raised if name is updated
nameChanged_ = true; nameChanged_ = true;
row[spots_.name] = newname; row[spots_.name] = newname;
treeview_.columns_autosize(); treeview_->columns_autosize();
listener->panelChanged(EvLocallabSpotName, newname); listener->panelChanged(EvLocallabSpotName, newname);
} }
} }
@@ -444,7 +446,7 @@ void ControlSpotPanel::on_button_visibility()
} }
// Get selected control spot // Get selected control spot
const auto s = treeview_.get_selection(); const auto s = treeview_->get_selection();
if (!s->count_selected_rows()) { if (!s->count_selected_rows()) {
return; return;
@@ -468,12 +470,27 @@ void ControlSpotPanel::on_button_visibility()
} }
} }
bool ControlSpotPanel::blockTreeviewSearch(GdkEventKey* event)
{
// printf("blockTreeviewSearch\n");
if (event->state & Gdk::CONTROL_MASK) { // Ctrl
if (event->keyval == GDK_KEY_f || event->keyval == GDK_KEY_F) {
// No action is performed to avoid activating treeview search
return true;
}
}
// Otherwise key action is transfered to treeview widget
return false;
}
void ControlSpotPanel::load_ControlSpot_param() void ControlSpotPanel::load_ControlSpot_param()
{ {
// printf("load_ControlSpot_param\n"); // printf("load_ControlSpot_param\n");
// Get selected control spot // Get selected control spot
const auto s = treeview_.get_selection(); const auto s = treeview_->get_selection();
if (!s->count_selected_rows()) { if (!s->count_selected_rows()) {
return; return;
@@ -525,7 +542,7 @@ void ControlSpotPanel::shapeChanged()
// printf("shapeChanged\n"); // printf("shapeChanged\n");
// Get selected control spot // Get selected control spot
const auto s = treeview_.get_selection(); const auto s = treeview_->get_selection();
if (!s->count_selected_rows()) { if (!s->count_selected_rows()) {
return; return;
@@ -548,7 +565,7 @@ void ControlSpotPanel::spotMethodChanged()
// printf("spotMethodChanged\n"); // printf("spotMethodChanged\n");
// Get selected control spot // Get selected control spot
const auto s = treeview_.get_selection(); const auto s = treeview_->get_selection();
if (!s->count_selected_rows()) { if (!s->count_selected_rows()) {
return; return;
@@ -581,7 +598,7 @@ void ControlSpotPanel::shapeMethodChanged()
const int method = shapeMethod_->get_active_row_number(); const int method = shapeMethod_->get_active_row_number();
// Get selected control spot // Get selected control spot
const auto s = treeview_.get_selection(); const auto s = treeview_->get_selection();
if (!s->count_selected_rows()) { if (!s->count_selected_rows()) {
return; return;
@@ -659,7 +676,7 @@ void ControlSpotPanel::qualityMethodChanged()
// printf("qualityMethodChanged\n"); // printf("qualityMethodChanged\n");
// Get selected control spot // Get selected control spot
const auto s = treeview_.get_selection(); const auto s = treeview_->get_selection();
if (!s->count_selected_rows()) { if (!s->count_selected_rows()) {
return; return;
@@ -760,7 +777,7 @@ void ControlSpotPanel::adjusterChanged(Adjuster* a, double newval)
const int method = shapeMethod_->get_active_row_number(); const int method = shapeMethod_->get_active_row_number();
// Get selected control spot // Get selected control spot
const auto s = treeview_.get_selection(); const auto s = treeview_->get_selection();
if (!s->count_selected_rows()) { if (!s->count_selected_rows()) {
return; return;
@@ -931,7 +948,7 @@ void ControlSpotPanel::avoidChanged()
// printf("avoidChanged\n"); // printf("avoidChanged\n");
// Get selected control spot // Get selected control spot
const auto s = treeview_.get_selection(); const auto s = treeview_->get_selection();
if (!s->count_selected_rows()) { if (!s->count_selected_rows()) {
return; return;
@@ -1300,7 +1317,7 @@ CursorShape ControlSpotPanel::getCursor(int objectID) const
// printf("Object ID: %d\n", objectID); // printf("Object ID: %d\n", objectID);
// When there is no control spot (i.e. no selected row), objectID can unexpectedly be different from -1 and produced not desired behavior // When there is no control spot (i.e. no selected row), objectID can unexpectedly be different from -1 and produced not desired behavior
const auto s = treeview_.get_selection(); const auto s = treeview_->get_selection();
if (!s->count_selected_rows()) { if (!s->count_selected_rows()) {
return CSHandOpen; return CSHandOpen;
} }
@@ -1337,7 +1354,7 @@ CursorShape ControlSpotPanel::getCursor(int objectID) const
bool ControlSpotPanel::mouseOver(int modifierKey) bool ControlSpotPanel::mouseOver(int modifierKey)
{ {
EditDataProvider* editProvider_ = getEditProvider(); EditDataProvider* editProvider_ = getEditProvider();
const auto s = treeview_.get_selection(); const auto s = treeview_->get_selection();
if (!editProvider_ || !s->count_selected_rows()) { // When there is no control spot (i.e. no selected row), objectID can unexpectedly be different from -1 and produced not desired behavior if (!editProvider_ || !s->count_selected_rows()) { // When there is no control spot (i.e. no selected row), objectID can unexpectedly be different from -1 and produced not desired behavior
return false; return false;
@@ -1460,7 +1477,7 @@ bool ControlSpotPanel::button1Pressed(int modifierKey)
// printf("button1Pressed\n"); // printf("button1Pressed\n");
EditDataProvider *provider = getEditProvider(); EditDataProvider *provider = getEditProvider();
const auto s = treeview_.get_selection(); const auto s = treeview_->get_selection();
if (!provider || lastObject_ == -1 || !s->count_selected_rows()) { // When there is no control spot (i.e. no selected row), objectID can unexpectedly be different from -1 and produced not desired behavior if (!provider || lastObject_ == -1 || !s->count_selected_rows()) { // When there is no control spot (i.e. no selected row), objectID can unexpectedly be different from -1 and produced not desired behavior
return false; return false;
@@ -1474,7 +1491,7 @@ bool ControlSpotPanel::button1Pressed(int modifierKey)
Gtk::TreeModel::Row r = *iter; Gtk::TreeModel::Row r = *iter;
if (r[spots_.curveid] == curveId_) { if (r[spots_.curveid] == curveId_) {
treeview_.set_cursor(treemodel_->get_path(r)); treeview_->set_cursor(treemodel_->get_path(r));
break; break;
} }
} }
@@ -1496,7 +1513,7 @@ bool ControlSpotPanel::drag1(int modifierKey)
// printf("drag1\n"); // printf("drag1\n");
EditDataProvider *provider = getEditProvider(); EditDataProvider *provider = getEditProvider();
const auto s = treeview_.get_selection(); const auto s = treeview_->get_selection();
if (!provider || lastObject_ == -1 || !s->count_selected_rows()) { // When there is no control spot (i.e. no selected row), objectID can unexpectedly be different from -1 and produced not desired behavior if (!provider || lastObject_ == -1 || !s->count_selected_rows()) { // When there is no control spot (i.e. no selected row), objectID can unexpectedly be different from -1 and produced not desired behavior
return false; return false;
@@ -1687,7 +1704,7 @@ int ControlSpotPanel::getSelectedSpot()
MyMutex::MyLock lock(mTreeview); MyMutex::MyLock lock(mTreeview);
const auto s = treeview_.get_selection(); const auto s = treeview_->get_selection();
// Check if treeview has row, otherwise return 0 // Check if treeview has row, otherwise return 0
if (!s->count_selected_rows()) { if (!s->count_selected_rows()) {
@@ -1716,7 +1733,7 @@ void ControlSpotPanel::setSelectedSpot(int id)
Gtk::TreeModel::Row row = *iter; Gtk::TreeModel::Row row = *iter;
if (row[spots_.id] == id) { if (row[spots_.id] == id) {
treeview_.set_cursor(treemodel_->get_path(row)); treeview_->set_cursor(treemodel_->get_path(row));
load_ControlSpot_param(); load_ControlSpot_param();
updateParamVisibility(); updateParamVisibility();
updateCurveOpacity(row); updateCurveOpacity(row);
@@ -1935,19 +1952,19 @@ void ControlSpotPanel::setEditedStates(SpotEdited* se)
// Set widgets edited states // Set widgets edited states
if (!se->nbspot || !se->selspot) { if (!se->nbspot || !se->selspot) {
treeview_.set_sensitive(false); treeview_->set_sensitive(false);
button_add_.set_sensitive(false); button_add_->set_sensitive(false);
button_delete_.set_sensitive(false); button_delete_->set_sensitive(false);
button_duplicate_.set_sensitive(false); button_duplicate_->set_sensitive(false);
button_rename_.set_sensitive(false); button_rename_->set_sensitive(false);
button_visibility_.set_sensitive(false); button_visibility_->set_sensitive(false);
} else { } else {
treeview_.set_sensitive(true); treeview_->set_sensitive(true);
button_add_.set_sensitive(true); button_add_->set_sensitive(true);
button_delete_.set_sensitive(true); button_delete_->set_sensitive(true);
button_duplicate_.set_sensitive(true); button_duplicate_->set_sensitive(true);
button_rename_.set_sensitive(se->name); button_rename_->set_sensitive(se->name);
button_visibility_.set_sensitive(se->isvisible); button_visibility_->set_sensitive(se->isvisible);
} }
if (!se->shape) { if (!se->shape) {

View File

@@ -225,6 +225,8 @@ private:
void on_button_rename(); void on_button_rename();
void on_button_visibility(); void on_button_visibility();
bool blockTreeviewSearch(GdkEventKey* event);
void load_ControlSpot_param(); void load_ControlSpot_param();
void controlspotChanged(); void controlspotChanged();
@@ -309,21 +311,21 @@ private:
ControlSpots spots_; ControlSpots spots_;
// Child widgets // Child widgets
Gtk::ScrolledWindow scrolledwindow_; Gtk::ScrolledWindow* const scrolledwindow_;
Gtk::TreeView treeview_; Gtk::TreeView* const treeview_;
sigc::connection treeviewconn_; sigc::connection treeviewconn_;
Glib::RefPtr<Gtk::ListStore> treemodel_; Glib::RefPtr<Gtk::ListStore> treemodel_;
Gtk::Button button_add_; Gtk::Button* const button_add_;
sigc::connection buttonaddconn_; sigc::connection buttonaddconn_;
Gtk::Button button_delete_; Gtk::Button* const button_delete_;
sigc::connection buttondeleteconn_; sigc::connection buttondeleteconn_;
Gtk::Button button_duplicate_; Gtk::Button* const button_duplicate_;
sigc::connection buttonduplicateconn_; sigc::connection buttonduplicateconn_;
Gtk::Button button_rename_; Gtk::Button* const button_rename_;
sigc::connection buttonrenameconn_; sigc::connection buttonrenameconn_;
Gtk::Button button_visibility_; Gtk::Button* const button_visibility_;
sigc::connection buttonvisibilityconn_; sigc::connection buttonvisibilityconn_;
MyComboBoxText* const shape_; MyComboBoxText* const shape_;

View File

@@ -1687,6 +1687,11 @@ bool EditorPanel::handleShortcutKey (GdkEventKey* event)
case GDK_KEY_F5: case GDK_KEY_F5:
openThm->openDefaultViewer (3); openThm->openDefaultViewer (3);
return true; return true;
case GDK_KEY_f:
case GDK_KEY_F:
// No action is performed to avoid Gtk-CRITICAL due to Locallab treeview when treeview isn't focused
return true;
} }
} //if (!ctrl) } //if (!ctrl)
} //if (!alt) } //if (!alt)