focus existing window instead of opening duplicate project instance

master
zetaPRIME 2022-03-13 18:38:10 -04:00
parent 4782eedf9c
commit 59f45ab382
3 changed files with 12 additions and 2 deletions

2
notes
View File

@ -35,7 +35,7 @@ TODO {
multi-window accounting {
- keep list of active windows
- quit (just trigger close on all sequentially)
if opening project already in other window, focus/flash that window
- if opening project already in other window, focus/flash that window
open project from command line
IPC to open/new window in existing instance
revert action

View File

@ -552,9 +552,17 @@ bool MainWindow::eventFilter(QObject *obj [[maybe_unused]], QEvent *event) {
return false;
}
void MainWindow::tryFocus() {
raise();
activateWindow();
}
void MainWindow::openProject(const QString& fileName, bool failSilent) {
auto pw = projectWindow(fileName);
if (pw && pw != this) {
pw->tryFocus();
return;
}
auto np = FileOps::loadProject(fileName);
if (!np) {
if (!failSilent) QMessageBox::critical(this, qs("Error"), qs("Error loading project \"%1\".").arg(QFileInfo(fileName).fileName()));

View File

@ -71,6 +71,8 @@ namespace Xybrid {
bool eventFilter(QObject *obj, QEvent *event) override;
public slots:
void tryFocus();
void menuFileNew();
void menuFileOpen();
void menuFileSave();