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