From 8712dac1a2fcc06399c78c97ba2ce4d03e3996db Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Wed, 28 Jun 2023 08:56:40 +0200 Subject: [PATCH] Minot fix: Honor Ctrl+Q hotkey in pl_editor and pcb_calculator --- bitmap2component/bitmap2cmp_frame.cpp | 13 +++++++++++++ bitmap2component/bitmap2cmp_frame.h | 10 ++++++++-- pcb_calculator/pcb_calculator_frame.cpp | 16 ++++++++++++++++ pcb_calculator/pcb_calculator_frame.h | 7 +++++++ 4 files changed, 44 insertions(+), 2 deletions(-) diff --git a/bitmap2component/bitmap2cmp_frame.cpp b/bitmap2component/bitmap2cmp_frame.cpp index 2be13cf7d9..a610e88bb1 100644 --- a/bitmap2component/bitmap2cmp_frame.cpp +++ b/bitmap2component/bitmap2cmp_frame.cpp @@ -137,6 +137,12 @@ void IMAGE_SIZE::SetUnit( EDA_UNITS aUnit ) } +BEGIN_EVENT_TABLE( BITMAP2CMP_FRAME, EDA_BASE_FRAME ) + EVT_MENU( wxID_CLOSE, BITMAP2CMP_FRAME::OnExit ) + EVT_MENU( wxID_EXIT, BITMAP2CMP_FRAME::OnExit ) +END_EVENT_TABLE() + + BITMAP2CMP_FRAME::BITMAP2CMP_FRAME( KIWAY* aKiway, wxWindow* aParent ) : KIWAY_PLAYER( aKiway, aParent, FRAME_BM2CMP, _( "Image Converter" ), wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE, wxT( "bitmap2cmp" ), unityScale ), @@ -200,6 +206,13 @@ BITMAP2CMP_FRAME::~BITMAP2CMP_FRAME() } +void BITMAP2CMP_FRAME::OnExit( wxCommandEvent& aEvent ) +{ + // Just generate a wxCloseEvent + Close( false ); +} + + wxWindow* BITMAP2CMP_FRAME::GetToolCanvas() const { return m_panel->GetCurrentPage(); diff --git a/bitmap2component/bitmap2cmp_frame.h b/bitmap2component/bitmap2cmp_frame.h index d639e17590..b6942592b9 100644 --- a/bitmap2component/bitmap2cmp_frame.h +++ b/bitmap2component/bitmap2cmp_frame.h @@ -1,7 +1,7 @@ /* * This program source code file is part of KICAD, a free EDA CAD application. * - * Copyright (C) 2019-2022 Kicad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2019-2023 Kicad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -40,7 +40,6 @@ public: // overload KIWAY_PLAYER virtual bool OpenProjectFiles( const std::vector& aFilenames, int aCtl = 0 ) override; - void OnExit( wxCommandEvent& event ); void OnLoadFile(); /** @@ -72,9 +71,16 @@ public: wxWindow* GetToolCanvas() const override; + /** + * Event handler for the wxID_EXIT and wxID_CLOSE events. + */ + void OnExit( wxCommandEvent& aEvent ); + protected: void doReCreateMenuBar() override; + DECLARE_EVENT_TABLE(); + private: BITMAP2CMP_PANEL* m_panel; wxStatusBar* m_statusBar; diff --git a/pcb_calculator/pcb_calculator_frame.cpp b/pcb_calculator/pcb_calculator_frame.cpp index 6a8a4e5437..ae3b136800 100644 --- a/pcb_calculator/pcb_calculator_frame.cpp +++ b/pcb_calculator/pcb_calculator_frame.cpp @@ -53,6 +53,12 @@ #include "widgets/wx_menubar.h" +BEGIN_EVENT_TABLE( PCB_CALCULATOR_FRAME, EDA_BASE_FRAME ) + EVT_MENU( wxID_CLOSE, PCB_CALCULATOR_FRAME::OnExit ) + EVT_MENU( wxID_EXIT, PCB_CALCULATOR_FRAME::OnExit ) +END_EVENT_TABLE() + + PCB_CALCULATOR_FRAME::PCB_CALCULATOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) : KIWAY_PLAYER( aKiway, aParent, FRAME_CALC, _( "Calculator Tools" ), wxDefaultPosition, wxDefaultSize, @@ -138,6 +144,16 @@ PCB_CALCULATOR_FRAME::~PCB_CALCULATOR_FRAME() } +void PCB_CALCULATOR_FRAME::OnExit( wxCommandEvent& aEvent ) +{ + if( aEvent.GetId() == wxID_EXIT ) + Kiway().OnKiCadExit(); + + if( aEvent.GetId() == wxID_CLOSE || Kiface().IsSingle() ) + Close( false ); +} + + void PCB_CALCULATOR_FRAME::loadPages() { m_treebook->AddPage( nullptr, _( "General system design" ) ); diff --git a/pcb_calculator/pcb_calculator_frame.h b/pcb_calculator/pcb_calculator_frame.h index b0c0880c73..7ccd399652 100644 --- a/pcb_calculator/pcb_calculator_frame.h +++ b/pcb_calculator/pcb_calculator_frame.h @@ -69,9 +69,16 @@ public: void LoadSettings( APP_SETTINGS_BASE* aCfg ) override; void SaveSettings( APP_SETTINGS_BASE* aCfg ) override; + /** + * Event handler for the wxID_EXIT and wxID_CLOSE events. + */ + void OnExit( wxCommandEvent& aEvent ); + protected: void doReCreateMenuBar() override; + DECLARE_EVENT_TABLE(); + private: // Event handlers void OnClosePcbCalc( wxCloseEvent& event );