Skip to content

Commit f21fde6

Browse files
committed
returning to LC via Command+Tab won't always activate a subwindow LibreCAD#821 LibreCAD#814
1 parent 313c642 commit f21fde6

File tree

2 files changed

+32
-5
lines changed

2 files changed

+32
-5
lines changed

librecad/src/main/qc_applicationwindow.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
**
2626
**********************************************************************/
2727

28+
2829
#include "qc_applicationwindow.h"
2930

3031
#include <QStatusBar>
@@ -128,6 +129,7 @@ QC_ApplicationWindow::QC_ApplicationWindow()
128129
, ag_manager(new LC_ActionGroupManager(this))
129130
, autosaveTimer(nullptr)
130131
, actionHandler(new QG_ActionHandler(this))
132+
, current_subwindow(nullptr)
131133
{
132134
RS_DEBUG->print("QC_ApplicationWindow::QC_ApplicationWindow");
133135

@@ -3193,3 +3195,26 @@ void QC_ApplicationWindow::destroyMenu(const QString& menu_name)
31933195
}
31943196
settings.endGroup();
31953197
}
3198+
3199+
void QC_ApplicationWindow::changeEvent(QEvent* event)
3200+
{
3201+
// author: ravas
3202+
3203+
#if defined(Q_OS_MAC)
3204+
// returning to LC via Command+Tab won't always activate a subwindow
3205+
// https://github.com/LibreCAD/LibreCAD/issues/821
3206+
3207+
if (event->type() == QEvent::ActivationChange)
3208+
{
3209+
if (isActiveWindow())
3210+
{
3211+
if (current_subwindow)
3212+
mdiAreaCAD->setActiveSubWindow(current_subwindow);
3213+
}
3214+
else
3215+
{
3216+
current_subwindow = mdiAreaCAD->currentSubWindow();
3217+
}
3218+
}
3219+
#endif
3220+
}

librecad/src/main/qc_applicationwindow.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ class QC_ApplicationWindow: public MainWindowX
8888
bool queryExit(bool force);
8989

9090
/** Catch hotkey for giving focus to command line. */
91-
virtual void keyPressEvent(QKeyEvent* e);
91+
virtual void keyPressEvent(QKeyEvent* e) override;
9292
void setRedoEnable(bool enable);
9393
void setUndoEnable(bool enable);
9494
bool loadStyleSheet(QString path);
@@ -276,15 +276,16 @@ public slots:
276276
}
277277

278278
protected:
279-
void closeEvent(QCloseEvent*);
279+
void closeEvent(QCloseEvent*) override;
280280
//! \{ accept drop files to open
281-
virtual void dropEvent(QDropEvent* e);
282-
virtual void dragEnterEvent(QDragEnterEvent * event);
281+
virtual void dropEvent(QDropEvent* e) override;
282+
virtual void dragEnterEvent(QDragEnterEvent * event) override;
283+
void changeEvent(QEvent *) override;
283284
//! \}
284285

285286
private:
286287

287-
QMenu* createPopupMenu();
288+
QMenu* createPopupMenu() override;
288289

289290
QString format_filename_caption(const QString &qstring_in);
290291
/** Helper function for Menu file -> New & New.... */
@@ -313,6 +314,7 @@ public slots:
313314
/** MdiArea for MDI */
314315
QMdiArea* mdiAreaCAD{nullptr};
315316
QMdiSubWindow* activedMdiSubWindow;
317+
QMdiSubWindow* current_subwindow;
316318

317319
/** Dialog factory */
318320
QC_DialogFactory* dialogFactory;

0 commit comments

Comments
 (0)