refactor: Transform launcher into QMainWindow

This commit is contained in:
Lars Toenning
2024-02-14 22:48:10 +01:00
parent b8a376701b
commit 9da0630063
4 changed files with 790 additions and 798 deletions

View File

@@ -40,11 +40,13 @@ int main(int argc, char *argv[])
}
//! [SwiftApplicationDemo]
// Dialog to decide external or internal core
CSwiftLauncher launcher;
CGuiApplication::registerAsRunning(); // needed because launcher's exec is called (normally application exec)
if (launcher.exec() == QDialog::Rejected) { return EXIT_SUCCESS; }
launcher.close();
const int res = CGuiApplication::exec();
if (res != EXIT_SUCCESS || !launcher.shouldStartAppDetached())
{
return res;
}
const bool s = launcher.startDetached();
return s ? EXIT_SUCCESS : EXIT_FAILURE;
}

View File

@@ -50,7 +50,7 @@ using namespace BlackMisc::Simulation;
using namespace BlackMisc::Simulation::Data;
using namespace BlackMisc::Simulation::FsCommon;
CSwiftLauncher::CSwiftLauncher(QWidget *parent) : QDialog(parent, CEnableForFramelessWindow::modeToWindowFlags(CEnableForFramelessWindow::WindowNormal)),
CSwiftLauncher::CSwiftLauncher(QWidget *parent) : QMainWindow(parent, CEnableForFramelessWindow::modeToWindowFlags(CEnableForFramelessWindow::WindowNormal)),
CEnableForFramelessWindow(CEnableForFramelessWindow::WindowFrameless, true, "framelessMainWindow", this),
CCentralMultiSimulatorModelSetCachesAware(),
CIdentifiable(this),
@@ -116,6 +116,8 @@ CSwiftLauncher::CSwiftLauncher(QWidget *parent) : QDialog(parent, CEnableForFram
this->requestMacMicrophoneAccess();
this->installerMode();
});
this->show();
}
void CSwiftLauncher::installerMode()
@@ -204,18 +206,18 @@ CoreModes::CoreMode CSwiftLauncher::getCoreMode() const
void CSwiftLauncher::mousePressEvent(QMouseEvent *event)
{
if (!handleMousePressEvent(event)) { QDialog::mousePressEvent(event); }
if (!handleMousePressEvent(event)) { QMainWindow::mousePressEvent(event); }
}
void CSwiftLauncher::mouseMoveEvent(QMouseEvent *event)
{
if (!handleMouseMoveEvent(event)) { QDialog::mouseMoveEvent(event); }
if (!handleMouseMoveEvent(event)) { QMainWindow::mouseMoveEvent(event); }
}
void CSwiftLauncher::mouseReleaseEvent(QMouseEvent *event)
{
m_framelessDragPosition = QPoint();
QDialog::mouseReleaseEvent(event);
QMainWindow::mouseReleaseEvent(event);
}
void CSwiftLauncher::updateInfoAvailable()
@@ -443,7 +445,7 @@ void CSwiftLauncher::startButtonPressed()
}
else
{
this->accept();
close();
}
}
}
@@ -459,7 +461,7 @@ void CSwiftLauncher::startButtonPressed()
}
else
{
this->accept();
close();
}
}
}
@@ -612,6 +614,11 @@ void CSwiftLauncher::showSimulatorConfigDirs()
m_textEditDialog->show();
}
bool CSwiftLauncher::shouldStartAppDetached() const
{
return !m_executable.isEmpty();
}
void CSwiftLauncher::requestMacMicrophoneAccess()
{
// needed to be able to start core/GUI which need MIC access

View File

@@ -21,7 +21,7 @@
# include "blackmisc/macos/microphoneaccess.h"
#endif
#include <QDialog>
#include <QMainWindow>
#include <QTimer>
#include <QScopedPointer>
#include <QNetworkReply>
@@ -41,10 +41,9 @@ namespace BlackGui::Components
* \note Besides the fact the launcher makes it easy to start our applications it also pre-fetches some
* cache files, hence reducing load times in the subsequent applications. Therefor starting via the launcher
* is preferable, but not mandatory.
* \fixme it was better if launcher was a QMainWindow, because we have to deal with main widgets QDialog and QMainWindow because of launcher
*/
class CSwiftLauncher :
public QDialog,
public QMainWindow,
public BlackGui::CEnableForFramelessWindow,
public BlackGui::IMainWindowAccess,
public BlackMisc::Simulation::Data::CCentralMultiSimulatorModelSetCachesAware,
@@ -82,6 +81,9 @@ public:
//! \remark simplifies debugging
bool startDetached();
//! Check if an app is set that should be started detached
bool shouldStartAppDetached() const;
protected:
//! Mouse events for frameless window
//! @{

File diff suppressed because it is too large Load Diff