Fix inspector window sometimes not hiding

When the f shortcut is quickly pressed, the inspector window will
sometimes open and remain open even though it should automatically
close. This commit ensures the window closes by capturing the f key
release event from the main window in addition to the inspector window.
This commit is contained in:
Lawrence Lee 2021-04-25 17:05:02 -07:00
parent 61aba8ad08
commit 67e18b5c53
8 changed files with 46 additions and 0 deletions

View File

@ -2524,6 +2524,21 @@ bool FileCatalog::handleShortcutKey (GdkEventKey* event)
return fileBrowser->keyPressed(event);
}
bool FileCatalog::handleShortcutKeyRelease(GdkEventKey* event)
{
bool ctrl = event->state & GDK_CONTROL_MASK;
bool alt = event->state & GDK_MOD1_MASK;
if (!ctrl && !alt) {
switch (event->keyval) {
case GDK_KEY_f:
case GDK_KEY_F:
fileBrowser->getInspector()->hideWindow();
return true;
}
}
}
void FileCatalog::showToolBar()
{
if (hbToolBar1STB) {

View File

@ -276,6 +276,7 @@ public:
void openNextPreviousEditorImage (Glib::ustring fname, bool clearFilters, eRTNav nextPrevious);
bool handleShortcutKey (GdkEventKey* event);
bool handleShortcutKeyRelease(GdkEventKey *event);
bool CheckSidePanelsVisibility();
void toggleSidePanels();

View File

@ -412,6 +412,15 @@ bool FilePanel::handleShortcutKey (GdkEventKey* event)
return false;
}
bool FilePanel::handleShortcutKeyRelease(GdkEventKey *event)
{
if(fileCatalog->handleShortcutKeyRelease(event)) {
return true;
}
return false;
}
void FilePanel::loadingThumbs(Glib::ustring str, double rate)
{
GThreadLock lock; // All GUI access from idle_add callbacks or separate thread HAVE to be protected

View File

@ -81,6 +81,7 @@ public:
bool imageLoaded( Thumbnail* thm, ProgressConnector<rtengine::InitialImage*> * );
bool handleShortcutKey (GdkEventKey* event);
bool handleShortcutKeyRelease(GdkEventKey *event);
void updateTPVScrollbar (bool hide);
private:

View File

@ -144,6 +144,11 @@ void Inspector::showWindow(bool scaled, bool fullscreen)
mouseMove(next_image_pos, 0);
}
void Inspector::hideWindow()
{
window->set_visible(false);
}
bool Inspector::on_key_release(GdkEventKey *event)
{
if (!window)

View File

@ -91,6 +91,11 @@ public:
*/
void showWindow(bool scaled, bool fullscreen = true);
/**
* Hide the window.
*/
void hideWindow();
/** @brief Mouse movement to a new position
* @param pos Location of the mouse, in percentage (i.e. [0;1] range) relative to the full size image ; -1,-1 == out of the image
* @param transform H/V flip and coarse rotation transformation

View File

@ -285,6 +285,7 @@ RTWindow::RTWindow ()
property_destroy_with_parent().set_value (false);
signal_window_state_event().connect ( sigc::mem_fun (*this, &RTWindow::on_window_state_event) );
signal_key_press_event().connect ( sigc::mem_fun (*this, &RTWindow::keyPressed) );
signal_key_release_event().connect(sigc::mem_fun(*this, &RTWindow::keyReleased));
if (simpleEditor) {
epanel = Gtk::manage ( new EditorPanel (nullptr) );
@ -756,6 +757,14 @@ bool RTWindow::keyPressed (GdkEventKey* event)
return false;
}
bool RTWindow::keyReleased(GdkEventKey *event)
{
if (mainNB->get_current_page() == mainNB->page_num(*fpanel)) {
return fpanel->handleShortcutKeyRelease(event);
}
return false;
}
void RTWindow::addBatchQueueJob (BatchQueueEntry* bqe, bool head)
{

View File

@ -85,6 +85,7 @@ public:
void addBatchQueueJobs (const std::vector<BatchQueueEntry*>& entries);
bool keyPressed (GdkEventKey* event);
bool keyReleased(GdkEventKey *event);
bool on_configure_event (GdkEventConfigure* event) override;
bool on_delete_event (GdkEventAny* event) override;
bool on_window_state_event (GdkEventWindowState* event) override;