lay base for a window with no menubar
This commit is contained in:
parent
881a740cab
commit
b2ae4c7dc5
|
@ -76,11 +76,15 @@ void EmuThread::attachWindow(MainWindow* window)
|
||||||
connect(this, SIGNAL(windowEmuStop()), window, SLOT(onEmuStop()));
|
connect(this, SIGNAL(windowEmuStop()), window, SLOT(onEmuStop()));
|
||||||
connect(this, SIGNAL(windowEmuPause(bool)), window, SLOT(onEmuPause(bool)));
|
connect(this, SIGNAL(windowEmuPause(bool)), window, SLOT(onEmuPause(bool)));
|
||||||
connect(this, SIGNAL(windowEmuReset()), window, SLOT(onEmuReset()));
|
connect(this, SIGNAL(windowEmuReset()), window, SLOT(onEmuReset()));
|
||||||
connect(this, SIGNAL(windowLimitFPSChange()), window->actLimitFramerate, SLOT(trigger()));
|
|
||||||
connect(this, SIGNAL(autoScreenSizingChange(int)), window->panel, SLOT(onAutoScreenSizingChanged(int)));
|
connect(this, SIGNAL(autoScreenSizingChange(int)), window->panel, SLOT(onAutoScreenSizingChanged(int)));
|
||||||
connect(this, SIGNAL(windowFullscreenToggle()), window, SLOT(onFullscreenToggled()));
|
connect(this, SIGNAL(windowFullscreenToggle()), window, SLOT(onFullscreenToggled()));
|
||||||
connect(this, SIGNAL(swapScreensToggle()), window->actScreenSwap, SLOT(trigger()));
|
|
||||||
connect(this, SIGNAL(screenEmphasisToggle()), window, SLOT(onScreenEmphasisToggled()));
|
connect(this, SIGNAL(screenEmphasisToggle()), window, SLOT(onScreenEmphasisToggled()));
|
||||||
|
|
||||||
|
if (window->winHasMenu())
|
||||||
|
{
|
||||||
|
connect(this, SIGNAL(windowLimitFPSChange()), window->actLimitFramerate, SLOT(trigger()));
|
||||||
|
connect(this, SIGNAL(swapScreensToggle()), window->actScreenSwap, SLOT(trigger()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmuThread::detachWindow(MainWindow* window)
|
void EmuThread::detachWindow(MainWindow* window)
|
||||||
|
@ -91,11 +95,15 @@ void EmuThread::detachWindow(MainWindow* window)
|
||||||
disconnect(this, SIGNAL(windowEmuStop()), window, SLOT(onEmuStop()));
|
disconnect(this, SIGNAL(windowEmuStop()), window, SLOT(onEmuStop()));
|
||||||
disconnect(this, SIGNAL(windowEmuPause(bool)), window, SLOT(onEmuPause(bool)));
|
disconnect(this, SIGNAL(windowEmuPause(bool)), window, SLOT(onEmuPause(bool)));
|
||||||
disconnect(this, SIGNAL(windowEmuReset()), window, SLOT(onEmuReset()));
|
disconnect(this, SIGNAL(windowEmuReset()), window, SLOT(onEmuReset()));
|
||||||
disconnect(this, SIGNAL(windowLimitFPSChange()), window->actLimitFramerate, SLOT(trigger()));
|
|
||||||
disconnect(this, SIGNAL(autoScreenSizingChange(int)), window->panel, SLOT(onAutoScreenSizingChanged(int)));
|
disconnect(this, SIGNAL(autoScreenSizingChange(int)), window->panel, SLOT(onAutoScreenSizingChanged(int)));
|
||||||
disconnect(this, SIGNAL(windowFullscreenToggle()), window, SLOT(onFullscreenToggled()));
|
disconnect(this, SIGNAL(windowFullscreenToggle()), window, SLOT(onFullscreenToggled()));
|
||||||
disconnect(this, SIGNAL(swapScreensToggle()), window->actScreenSwap, SLOT(trigger()));
|
|
||||||
disconnect(this, SIGNAL(screenEmphasisToggle()), window, SLOT(onScreenEmphasisToggled()));
|
disconnect(this, SIGNAL(screenEmphasisToggle()), window, SLOT(onScreenEmphasisToggled()));
|
||||||
|
|
||||||
|
if (window->winHasMenu())
|
||||||
|
{
|
||||||
|
disconnect(this, SIGNAL(windowLimitFPSChange()), window->actLimitFramerate, SLOT(trigger()));
|
||||||
|
disconnect(this, SIGNAL(swapScreensToggle()), window->actScreenSwap, SLOT(trigger()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmuThread::run()
|
void EmuThread::run()
|
||||||
|
|
|
@ -271,6 +271,10 @@ MainWindow::MainWindow(int id, EmuInstance* inst, QWidget* parent) :
|
||||||
setStyleSheet("QMenuBar::item { padding: 4px 8px; }");
|
setStyleSheet("QMenuBar::item { padding: 4px 8px; }");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
hasMenu = (!parent);
|
||||||
|
|
||||||
|
if (hasMenu)
|
||||||
|
{
|
||||||
QMenuBar * menubar = new QMenuBar();
|
QMenuBar * menubar = new QMenuBar();
|
||||||
{
|
{
|
||||||
QMenu * menu = menubar->addMenu("File");
|
QMenu * menu = menubar->addMenu("File");
|
||||||
|
@ -381,7 +385,8 @@ MainWindow::MainWindow(int id, EmuInstance* inst, QWidget* parent) :
|
||||||
|
|
||||||
menu->addSeparator();
|
menu->addSeparator();
|
||||||
actOpenConfig = menu->addAction("Open melonDS directory");
|
actOpenConfig = menu->addAction("Open melonDS directory");
|
||||||
connect(actOpenConfig, &QAction::triggered, this, [&]() {
|
connect(actOpenConfig, &QAction::triggered, this, [&]()
|
||||||
|
{
|
||||||
QDesktopServices::openUrl(QUrl::fromLocalFile(emuDirectory));
|
QDesktopServices::openUrl(QUrl::fromLocalFile(emuDirectory));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -537,7 +542,8 @@ MainWindow::MainWindow(int id, EmuInstance* inst, QWidget* parent) :
|
||||||
QMenu * submenu = menu->addMenu("Screen sizing");
|
QMenu * submenu = menu->addMenu("Screen sizing");
|
||||||
grpScreenSizing = new QActionGroup(submenu);
|
grpScreenSizing = new QActionGroup(submenu);
|
||||||
|
|
||||||
const char* screensizing[] = {"Even", "Emphasize top", "Emphasize bottom", "Auto", "Top only", "Bottom only"};
|
const char *screensizing[] = {"Even", "Emphasize top", "Emphasize bottom", "Auto", "Top only",
|
||||||
|
"Bottom only"};
|
||||||
|
|
||||||
for (int i = 0; i < screenSizing_MAX; i++)
|
for (int i = 0; i < screenSizing_MAX; i++)
|
||||||
{
|
{
|
||||||
|
@ -663,7 +669,8 @@ MainWindow::MainWindow(int id, EmuInstance* inst, QWidget* parent) :
|
||||||
{
|
{
|
||||||
QMenu * menu = menubar->addMenu("Help");
|
QMenu * menu = menubar->addMenu("Help");
|
||||||
actAbout = menu->addAction("About...");
|
actAbout = menu->addAction("About...");
|
||||||
connect(actAbout, &QAction::triggered, this, [&]{
|
connect(actAbout, &QAction::triggered, this, [&]
|
||||||
|
{
|
||||||
auto dialog = AboutDialog(this);
|
auto dialog = AboutDialog(this);
|
||||||
dialog.exec();
|
dialog.exec();
|
||||||
});
|
});
|
||||||
|
@ -673,6 +680,7 @@ MainWindow::MainWindow(int id, EmuInstance* inst, QWidget* parent) :
|
||||||
|
|
||||||
if (localCfg.GetString("Firmware.Username") == "Arisotura")
|
if (localCfg.GetString("Firmware.Username") == "Arisotura")
|
||||||
actMPNewInstance->setText("Fart");
|
actMPNewInstance->setText("Fart");
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
QPoint screenCenter = screen()->availableGeometry().center();
|
QPoint screenCenter = screen()->availableGeometry().center();
|
||||||
|
@ -695,6 +703,8 @@ MainWindow::MainWindow(int id, EmuInstance* inst, QWidget* parent) :
|
||||||
|
|
||||||
createScreenPanel();
|
createScreenPanel();
|
||||||
|
|
||||||
|
if (hasMenu)
|
||||||
|
{
|
||||||
actEjectCart->setEnabled(false);
|
actEjectCart->setEnabled(false);
|
||||||
actEjectGBACart->setEnabled(false);
|
actEjectGBACart->setEnabled(false);
|
||||||
|
|
||||||
|
@ -777,6 +787,7 @@ MainWindow::MainWindow(int id, EmuInstance* inst, QWidget* parent) :
|
||||||
actPreferences->setEnabled(false);
|
actPreferences->setEnabled(false);
|
||||||
#endif // __APPLE__
|
#endif // __APPLE__
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QObject::connect(qApp, &QApplication::applicationStateChanged, this, &MainWindow::onAppStateChanged);
|
QObject::connect(qApp, &QApplication::applicationStateChanged, this, &MainWindow::onAppStateChanged);
|
||||||
onUpdateInterfaceSettings();
|
onUpdateInterfaceSettings();
|
||||||
|
@ -785,10 +796,13 @@ MainWindow::MainWindow(int id, EmuInstance* inst, QWidget* parent) :
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
|
{
|
||||||
|
if (hasMenu)
|
||||||
{
|
{
|
||||||
delete[] actScreenAspectTop;
|
delete[] actScreenAspectTop;
|
||||||
delete[] actScreenAspectBot;
|
delete[] actScreenAspectBot;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::osdAddMessage(unsigned int color, const char* msg)
|
void MainWindow::osdAddMessage(unsigned int color, const char* msg)
|
||||||
{
|
{
|
||||||
|
@ -834,6 +848,7 @@ void MainWindow::createScreenPanel()
|
||||||
}
|
}
|
||||||
setCentralWidget(panel);
|
setCentralWidget(panel);
|
||||||
|
|
||||||
|
if (hasMenu)
|
||||||
actScreenFiltering->setEnabled(hasOGL);
|
actScreenFiltering->setEnabled(hasOGL);
|
||||||
panel->osdSetEnabled(showOSD);
|
panel->osdSetEnabled(showOSD);
|
||||||
|
|
||||||
|
@ -1635,6 +1650,8 @@ void MainWindow::onNPTest()
|
||||||
|
|
||||||
void MainWindow::updateMPInterface(MPInterfaceType type)
|
void MainWindow::updateMPInterface(MPInterfaceType type)
|
||||||
{
|
{
|
||||||
|
if (!hasMenu) return;
|
||||||
|
|
||||||
// MP interface was changed, reflect it in the UI
|
// MP interface was changed, reflect it in the UI
|
||||||
|
|
||||||
bool enable = (type == MPInterface_Local);
|
bool enable = (type == MPInterface_Local);
|
||||||
|
@ -1995,24 +2012,28 @@ void MainWindow::onTitleUpdate(QString title)
|
||||||
setWindowTitle(title);
|
setWindowTitle(title);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ToggleFullscreen(MainWindow* mainWindow)
|
void MainWindow::toggleFullscreen()
|
||||||
{
|
{
|
||||||
if (!mainWindow->isFullScreen())
|
if (!isFullScreen())
|
||||||
{
|
{
|
||||||
mainWindow->showFullScreen();
|
showFullScreen();
|
||||||
mainWindow->menuBar()->setFixedHeight(0); // Don't use hide() as menubar actions stop working
|
if (hasMenu)
|
||||||
|
menuBar()->setFixedHeight(0); // Don't use hide() as menubar actions stop working
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mainWindow->showNormal();
|
showNormal();
|
||||||
int menuBarHeight = mainWindow->menuBar()->sizeHint().height();
|
if (hasMenu)
|
||||||
mainWindow->menuBar()->setFixedHeight(menuBarHeight);
|
{
|
||||||
|
int menuBarHeight = menuBar()->sizeHint().height();
|
||||||
|
menuBar()->setFixedHeight(menuBarHeight);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onFullscreenToggled()
|
void MainWindow::onFullscreenToggled()
|
||||||
{
|
{
|
||||||
ToggleFullscreen(this);
|
toggleFullscreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onScreenEmphasisToggled()
|
void MainWindow::onScreenEmphasisToggled()
|
||||||
|
@ -2033,6 +2054,8 @@ void MainWindow::onScreenEmphasisToggled()
|
||||||
|
|
||||||
void MainWindow::onEmuStart()
|
void MainWindow::onEmuStart()
|
||||||
{
|
{
|
||||||
|
if (!hasMenu) return;
|
||||||
|
|
||||||
for (int i = 1; i < 9; i++)
|
for (int i = 1; i < 9; i++)
|
||||||
{
|
{
|
||||||
actSaveState[i]->setEnabled(true);
|
actSaveState[i]->setEnabled(true);
|
||||||
|
@ -2056,6 +2079,8 @@ void MainWindow::onEmuStart()
|
||||||
|
|
||||||
void MainWindow::onEmuStop()
|
void MainWindow::onEmuStop()
|
||||||
{
|
{
|
||||||
|
if (!hasMenu) return;
|
||||||
|
|
||||||
for (int i = 0; i < 9; i++)
|
for (int i = 0; i < 9; i++)
|
||||||
{
|
{
|
||||||
actSaveState[i]->setEnabled(false);
|
actSaveState[i]->setEnabled(false);
|
||||||
|
@ -2076,11 +2101,15 @@ void MainWindow::onEmuStop()
|
||||||
|
|
||||||
void MainWindow::onEmuPause(bool pause)
|
void MainWindow::onEmuPause(bool pause)
|
||||||
{
|
{
|
||||||
|
if (!hasMenu) return;
|
||||||
|
|
||||||
actPause->setChecked(pause);
|
actPause->setChecked(pause);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onEmuReset()
|
void MainWindow::onEmuReset()
|
||||||
{
|
{
|
||||||
|
if (!hasMenu) return;
|
||||||
|
|
||||||
actUndoStateLoad->setEnabled(false);
|
actUndoStateLoad->setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -111,6 +111,10 @@ public:
|
||||||
EmuInstance* getEmuInstance() { return emuInstance; }
|
EmuInstance* getEmuInstance() { return emuInstance; }
|
||||||
Config::Table& getWindowConfig() { return windowCfg; }
|
Config::Table& getWindowConfig() { return windowCfg; }
|
||||||
|
|
||||||
|
bool winHasMenu() { return hasMenu; }
|
||||||
|
|
||||||
|
void toggleFullscreen();
|
||||||
|
|
||||||
bool hasOpenGL() { return hasOGL; }
|
bool hasOpenGL() { return hasOGL; }
|
||||||
GL::Context* getOGLContext();
|
GL::Context* getOGLContext();
|
||||||
void initOpenGL();
|
void initOpenGL();
|
||||||
|
@ -263,6 +267,8 @@ private:
|
||||||
public:
|
public:
|
||||||
ScreenPanel* panel;
|
ScreenPanel* panel;
|
||||||
|
|
||||||
|
bool hasMenu;
|
||||||
|
|
||||||
QAction* actOpenROM;
|
QAction* actOpenROM;
|
||||||
QAction* actBootFirmware;
|
QAction* actBootFirmware;
|
||||||
QAction* actCurrentCart;
|
QAction* actCurrentCart;
|
||||||
|
@ -335,6 +341,4 @@ public:
|
||||||
QAction* actAbout;
|
QAction* actAbout;
|
||||||
};
|
};
|
||||||
|
|
||||||
void ToggleFullscreen(MainWindow* mainWindow);
|
|
||||||
|
|
||||||
#endif // WINDOW_H
|
#endif // WINDOW_H
|
||||||
|
|
|
@ -364,7 +364,7 @@ int main(int argc, char** argv)
|
||||||
win->preloadROMs(dsfile, gbafile, options->boot);
|
win->preloadROMs(dsfile, gbafile, options->boot);
|
||||||
|
|
||||||
if (options->fullscreen)
|
if (options->fullscreen)
|
||||||
ToggleFullscreen(win);
|
win->toggleFullscreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
int ret = melon.exec();
|
int ret = melon.exec();
|
||||||
|
|
Loading…
Reference in New Issue