From: Shamus Hammons Date: Thu, 21 Jan 2010 22:09:01 +0000 (+0000) Subject: More GUI fill in, new About box X-Git-Tag: 2.0.0~34^2~48 X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e6b7d61963423b7f9cb4c6c24d2befca50328d4f;p=virtualjaguar More GUI fill in, new About box --- diff --git a/Makefile b/Makefile index ab65a75..ebce4f7 100644 --- a/Makefile +++ b/Makefile @@ -72,6 +72,7 @@ OBJS = \ obj/m68kopnz.o \ obj/m68kdasm.o \ \ + obj/about.o \ obj/app.o \ obj/mainwin.o \ obj/moc_mainwin.o \ diff --git a/src/gui/about.cpp b/src/gui/about.cpp new file mode 100644 index 0000000..c354307 --- /dev/null +++ b/src/gui/about.cpp @@ -0,0 +1,73 @@ +// +// about.cpp - Credits +// +// by James L. Hammons +// (C) 2010 Underground Software +// +// JLH = James L. Hammons +// +// Who When What +// --- ---------- ------------------------------------------------------------- +// JLH 01/21/2010 Created this file +// + +#include "about.h" + +AboutWindow::AboutWindow(QWidget * parent/*= 0*/): QWidget() +{ + layout = new QVBoxLayout(); + layout->setSizeConstraint(QLayout::SetFixedSize); +// layout->setMargin(Style::WindowMargin); +// layout->setSpacing(Style::WidgetSpacing); + setLayout(layout); + +// logo = new Logo; +// logo->setFixedSize(600, 106); +// layout->addWidget(logo); + + text = new QLabel(tr( + "" + "" + "" + "" + "
Version: 2.0.0
Author: byuu
Homepage: http://byuu.org/
" + )); + layout->addWidget(text); +} + + +// Byuu's version... +#if 0 +#include "about.moc" +AboutWindow *aboutWindow; + +AboutWindow::AboutWindow() : QbWindow(config().geometry.aboutWindow) { + setObjectName("about-window"); + setWindowTitle("About bsnes ..."); + + layout = new QVBoxLayout; + layout->setSizeConstraint(QLayout::SetFixedSize); + layout->setMargin(Style::WindowMargin); + layout->setSpacing(Style::WidgetSpacing); + setLayout(layout); + + logo = new Logo; + logo->setFixedSize(600, 106); + layout->addWidget(logo); + + info = new QLabel(string() << + "" + "" + "" + "" + "
Version: " << bsnesVersion << "
Author: byuu
Homepage: http://byuu.org/
" + ); + layout->addWidget(info); +} + +void AboutWindow::Logo::paintEvent(QPaintEvent*) { + QPainter painter(this); + QPixmap pixmap(":/logo.png"); + painter.drawPixmap(0, 0, pixmap); +} +#endif diff --git a/src/gui/about.h b/src/gui/about.h new file mode 100644 index 0000000..c448651 --- /dev/null +++ b/src/gui/about.h @@ -0,0 +1,41 @@ +// +// about.h: Credits where credits are due ;-) +// +// by James L. Hammons +// (C) 2010 Underground Software +// + +#ifndef __ABOUT_H__ +#define __ABOUT_H__ + +#include + +class AboutWindow: public QWidget +{ + public: + AboutWindow(QWidget * parent = 0); + + private: + QVBoxLayout * layout; + QLabel * text; +}; + +#endif // __ABOUT_H__ + + +#if 0 +class AboutWindow : public QbWindow { + Q_OBJECT + +public: + QVBoxLayout *layout; + struct Logo : public QWidget { + void paintEvent(QPaintEvent*); + } *logo; + QLabel *info; + + AboutWindow(); +}; + +extern AboutWindow *aboutWindow; +#endif diff --git a/src/gui/glwidget.cpp b/src/gui/glwidget.cpp index d4a65ec..e32dde3 100644 --- a/src/gui/glwidget.cpp +++ b/src/gui/glwidget.cpp @@ -16,8 +16,7 @@ #include "settings.h" GLWidget::GLWidget(QWidget * parent/*= 0*/): QGLWidget(parent), texture(0), - textureWidth(0), textureHeight(0), buffer(0), rasterWidth(64), rasterHeight(64) -// textureWidth(0), textureHeight(0), buffer(0), rasterWidth(256), rasterHeight(256) + textureWidth(0), textureHeight(0), buffer(0), rasterWidth(320), rasterHeight(240) { } @@ -42,6 +41,9 @@ void GLWidget::initializeGL() void GLWidget::paintGL() { +//kludge +rasterHeight = (vjs.hardwareTypeNTSC ? 240 : 256); + unsigned outputWidth = width(); unsigned outputHeight = height(); diff --git a/src/gui/mainwin.cpp b/src/gui/mainwin.cpp index deef6b4..40af9eb 100644 --- a/src/gui/mainwin.cpp +++ b/src/gui/mainwin.cpp @@ -28,6 +28,7 @@ //#include //#include #include "glwidget.h" +#include "about.h" #include "settings.h" // The way BSNES controls things is by setting a timer with a zero @@ -49,6 +50,11 @@ MainWin::MainWin() setWindowIcon(QIcon(":/res/vj.xpm")); setWindowTitle("Virtual Jaguar v2.0.0"); + aboutWin = new AboutWindow(this); + + videoWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + // Create actions quitAppAct = new QAction(tr("E&xit"), this); @@ -56,92 +62,67 @@ MainWin::MainWin() quitAppAct->setStatusTip(tr("Quit Virtual Jaguar")); connect(quitAppAct, SIGNAL(triggered()), this, SLOT(close())); - action = new QAction(QIcon(":/res/power.png"), tr("&Power"), this); - action->setStatusTip(tr("Toggle running state")); - action->setCheckable(true); - connect(action, SIGNAL(triggered()), this, SLOT(ToggleRunState())); + powerAct = new QAction(QIcon(":/res/power.png"), tr("&Power"), this); + powerAct->setStatusTip(tr("Toggle running state")); + powerAct->setCheckable(true); + connect(powerAct, SIGNAL(triggered()), this, SLOT(ToggleRunState())); zoomActs = new QActionGroup(this); x1Act = new QAction(QIcon(":/res/zoom100.png"), tr("Zoom 100%"), zoomActs); x1Act->setStatusTip(tr("Set window zoom to 100%")); x1Act->setCheckable(true); -// connect(x1Act, SIGNAL(triggered()), this, SLOT(???())); + connect(x1Act, SIGNAL(triggered()), this, SLOT(SetZoom100())); x2Act = new QAction(QIcon(":/res/zoom200.png"), tr("Zoom 200%"), zoomActs); x2Act->setStatusTip(tr("Set window zoom to 200%")); x2Act->setCheckable(true); -// connect(x2Act, SIGNAL(triggered()), this, SLOT(???())); + connect(x2Act, SIGNAL(triggered()), this, SLOT(SetZoom200())); x3Act = new QAction(QIcon(":/res/zoom300.png"), tr("Zoom 300%"), zoomActs); x3Act->setStatusTip(tr("Set window zoom to 300%")); x3Act->setCheckable(true); -// connect(x3Act, SIGNAL(triggered()), this, SLOT(???())); + connect(x3Act, SIGNAL(triggered()), this, SLOT(SetZoom300())); + + tvTypeActs = new QActionGroup(this); + + ntscAct = new QAction(QIcon(":/res/generic.png"), tr("NTSC"), tvTypeActs); + ntscAct->setStatusTip(tr("Sets OpenGL rendering to GL_NEAREST")); + ntscAct->setCheckable(true); + connect(ntscAct, SIGNAL(triggered()), this, SLOT(SetNTSC())); + + palAct = new QAction(QIcon(":/res/generic.png"), tr("PAL"), tvTypeActs); + palAct->setStatusTip(tr("Sets OpenGL rendering to GL_NEAREST")); + palAct->setCheckable(true); + connect(palAct, SIGNAL(triggered()), this, SLOT(SetPAL())); blurAct = new QAction(QIcon(":/res/generic.png"), tr("Blur"), this); blurAct->setStatusTip(tr("Sets OpenGL rendering to GL_NEAREST")); blurAct->setCheckable(true); connect(blurAct, SIGNAL(triggered()), this, SLOT(ToggleBlur())); + aboutAct = new QAction(QIcon(":/res/generic.png"), tr("&About..."), this); + aboutAct->setStatusTip(tr("Shows self-serving credits")); +// aboutAct->setCheckable(true); + connect(aboutAct, SIGNAL(triggered()), this, SLOT(ShowAboutWin())); + // Create menus & toolbars - QMenu * fileMenu = menuBar()->addMenu(tr("&File")); - fileMenu->addAction(action); + fileMenu = menuBar()->addMenu(tr("&File")); + fileMenu->addAction(powerAct); fileMenu->addAction(quitAppAct); + fileMenu = menuBar()->addMenu(tr("&Help")); + fileMenu->addAction(aboutAct); + QToolBar * toolbar = addToolBar(tr("Stuff")); - toolbar->addAction(action); + toolbar->addAction(powerAct); toolbar->addAction(x1Act); toolbar->addAction(x2Act); toolbar->addAction(x3Act); + toolbar->addAction(ntscAct); + toolbar->addAction(palAct); toolbar->addAction(blurAct); -#if 0 -// createActions(); - newAct = new QAction(QIcon(":/images/new.png"), tr("&New"), this); - newAct->setShortcuts(QKeySequence::New); - newAct->setStatusTip(tr("Create a new file")); - connect(newAct, SIGNAL(triggered()), this, SLOT(newFile())); - - openAct = new QAction(QIcon(":/images/open.png"), tr("&Open..."), this); - openAct->setShortcuts(QKeySequence::Open); - openAct->setStatusTip(tr("Open an existing file")); - connect(openAct, SIGNAL(triggered()), this, SLOT(open())); - - aboutQtAct = new QAction(tr("About &Qt"), this); - aboutQtAct->setStatusTip(tr("Show the Qt library's About box")); - connect(aboutQtAct, SIGNAL(triggered()), qApp, SLOT(aboutQt())); - -// createMenus(); - fileMenu = menuBar()->addMenu(tr("&File")); - fileMenu->addAction(newAct); - fileMenu->addAction(openAct); - fileMenu->addAction(saveAct); - fileMenu->addAction(saveAsAct); - fileMenu->addSeparator(); - fileMenu->addAction(exitAct); - - editMenu = menuBar()->addMenu(tr("&Edit")); - editMenu->addAction(cutAct); - editMenu->addAction(copyAct); - editMenu->addAction(pasteAct); - - menuBar()->addSeparator(); - - helpMenu = menuBar()->addMenu(tr("&Help")); - helpMenu->addAction(aboutAct); - helpMenu->addAction(aboutQtAct); - -// createToolBars(); - fileToolBar = addToolBar(tr("File")); - fileToolBar->addAction(newAct); - fileToolBar->addAction(openAct); - fileToolBar->addAction(saveAct); - - editToolBar = addToolBar(tr("Edit")); - editToolBar->addAction(cutAct); - editToolBar->addAction(copyAct); - editToolBar->addAction(pasteAct); -#endif // Create status bar statusBar()->showMessage(tr("Ready")); @@ -151,8 +132,15 @@ MainWin::MainWin() // Set toolbar button based on setting read in (sync the UI)... blurAct->setChecked(vjs.glFilter); - x1Act->setChecked(true); - running = action->isChecked(); + x1Act->setChecked(zoomLevel == 1); + x2Act->setChecked(zoomLevel == 2); + x3Act->setChecked(zoomLevel == 3); + running = powerAct->isChecked(); + ntscAct->setChecked(vjs.hardwareTypeNTSC); + palAct->setChecked(!vjs.hardwareTypeNTSC); + + // Do this in case original size isn't correct + ResizeMainWindow(); // Set up timer based loop for animation... timer = new QTimer(this); @@ -205,14 +193,32 @@ void MainWin::ToggleRunState(void) void MainWin::SetZoom100(void) { + zoomLevel = 1; + ResizeMainWindow(); } void MainWin::SetZoom200(void) { + zoomLevel = 2; + ResizeMainWindow(); } void MainWin::SetZoom300(void) { + zoomLevel = 3; + ResizeMainWindow(); +} + +void MainWin::SetNTSC(void) +{ + vjs.hardwareTypeNTSC = true; + ResizeMainWindow(); +} + +void MainWin::SetPAL(void) +{ + vjs.hardwareTypeNTSC = false; + ResizeMainWindow(); } void MainWin::ToggleBlur(void) @@ -220,6 +226,28 @@ void MainWin::ToggleBlur(void) vjs.glFilter = !vjs.glFilter; } +void MainWin::ShowAboutWin(void) +{ + aboutWin->show(); +// QMessageBox::about(this, tr("About Application"), +// tr("The Application example demonstrates how to " +// "write modern GUI applications using Qt, with a menu bar, " +// "toolbars, and a status bar.")); +} + +void MainWin::ResizeMainWindow(void) +{ + videoWidget->setFixedSize(zoomLevel * 320, zoomLevel * (vjs.hardwareTypeNTSC ? 240 : 256)); + show(); + + for(int i=0; i<2; i++) + { + resize(0, 0); + usleep(2000); + QApplication::processEvents(); + } +} + void MainWin::ReadSettings(void) { QSettings settings("Underground Software", "Virtual Jaguar"); @@ -228,6 +256,8 @@ void MainWin::ReadSettings(void) resize(size); move(pos); + zoomLevel = settings.value("zoom", 1).toInt(); + vjs.useJoystick = settings.value("useJoystick", false).toBool(); vjs.joyport = settings.value("joyport", 0).toInt(); vjs.hardwareTypeNTSC = settings.value("hardwareTypeNTSC", true).toBool(); @@ -247,6 +277,8 @@ void MainWin::WriteSettings(void) settings.setValue("pos", pos()); settings.setValue("size", size()); + settings.setValue("zoom", zoomLevel); + settings.setValue("useJoystick", vjs.useJoystick); settings.setValue("joyport", vjs.joyport); settings.setValue("hardwareTypeNTSC", vjs.hardwareTypeNTSC); @@ -260,3 +292,89 @@ void MainWin::WriteSettings(void) settings.setValue("renderType", vjs.renderType); } +// Here's how Byuu does it... +// I think I have it working now... :-) +#if 0 +void Utility::resizeMainWindow() +{ + unsigned region = config().video.context->region; + unsigned multiplier = config().video.context->multiplier; + unsigned width = 256 * multiplier; + unsigned height = (region == 0 ? 224 : 239) * multiplier; + + if(config().video.context->correctAspectRatio) + { + if(region == 0) + { + width = (double)width * config().video.ntscAspectRatio + 0.5; //NTSC adjust + } + else + { + width = (double)width * config().video.palAspectRatio + 0.5; //PAL adjust + } + } + + if(config().video.isFullscreen == false) + { + //get effective desktop work area region (ignore Windows taskbar, OS X dock, etc.) + QRect deskRect = QApplication::desktop()->availableGeometry(mainWindow); + + //ensure window size will not be larger than viewable desktop area + constrainSize(height, width, deskRect.height()); //- frameHeight); + constrainSize(width, height, deskRect.width()); //- frameWidth ); + + mainWindow->canvas->setFixedSize(width, height); + mainWindow->show(); + } + else + { + for(unsigned i = 0; i < 2; i++) + { + unsigned iWidth = width, iHeight = height; + + constrainSize(iHeight, iWidth, mainWindow->canvasContainer->size().height()); + constrainSize(iWidth, iHeight, mainWindow->canvasContainer->size().width()); + + //center canvas onscreen; ensure it is not larger than viewable area + mainWindow->canvas->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + mainWindow->canvas->setFixedSize(iWidth, iHeight); + mainWindow->canvas->setMinimumSize(0, 0); + + usleep(2000); + QApplication::processEvents(); + } + } + + //workaround for Qt/Xlib bug: + //if window resize occurs with cursor over it, Qt shows Qt::Size*DiagCursor; + //so force it to show Qt::ArrowCursor, as expected + mainWindow->setCursor(Qt::ArrowCursor); + mainWindow->canvasContainer->setCursor(Qt::ArrowCursor); + mainWindow->canvas->setCursor(Qt::ArrowCursor); + + //workaround for DirectSound(?) bug: + //window resizing sometimes breaks audio sync, this call re-initializes it + updateAvSync(); +} + +void Utility::setScale(unsigned scale) +{ + config().video.context->multiplier = scale; + resizeMainWindow(); + mainWindow->shrink(); + mainWindow->syncUi(); +} + +void QbWindow::shrink() +{ + if(config().video.isFullscreen == false) + { + for(unsigned i = 0; i < 2; i++) + { + resize(0, 0); + usleep(2000); + QApplication::processEvents(); + } + } +} +#endif diff --git a/src/gui/mainwin.h b/src/gui/mainwin.h index 781ac29..a3a26cc 100644 --- a/src/gui/mainwin.h +++ b/src/gui/mainwin.h @@ -14,6 +14,7 @@ // Forward declarations class GLWidget; +class AboutWindow; //class EditWindow; //class CharWindow; @@ -35,26 +36,38 @@ class MainWin: public QMainWindow void SetZoom100(void); void SetZoom200(void); void SetZoom300(void); + void SetNTSC(void); + void SetPAL(void); void ToggleBlur(void); + void ShowAboutWin(void); private: + void ResizeMainWindow(void); void ReadSettings(void); void WriteSettings(void); // public: GLWidget * videoWidget; + AboutWindow * aboutWin; QTimer * timer; bool running; -// EditWindow * editWnd; -// CharWindow * charWnd; + int zoomLevel; + + QMenu * fileMenu; + QMenu * helpMenu; + QActionGroup * zoomActs; + QActionGroup * tvTypeActs; - QAction * action; QAction * quitAppAct; + QAction * powerAct; QAction * x1Act; QAction * x2Act; QAction * x3Act; + QAction * ntscAct; + QAction * palAct; QAction * blurAct; + QAction * aboutAct; }; #endif // __MAINWIN_H__ diff --git a/src/gui/vj.pro b/src/gui/vj.pro index 106f79b..f95b90e 100644 --- a/src/gui/vj.pro +++ b/src/gui/vj.pro @@ -9,10 +9,12 @@ QT += opengl HEADERS += app.h HEADERS += mainwin.h HEADERS += glwidget.h +HEADERS += about.h SOURCES += app.cpp SOURCES += mainwin.cpp SOURCES += glwidget.cpp +SOURCES += about.cpp RESOURCES += vj.qrc diff --git a/src/gui/vj.qrc b/src/gui/vj.qrc index 159f890..4a23d8c 100644 --- a/src/gui/vj.qrc +++ b/src/gui/vj.qrc @@ -6,5 +6,6 @@ ../../res/zoom200.png ../../res/zoom300.png ../../res/generic.png + ../../res/vj_title_small.png