2 // mainwin.cpp - Qt-based GUI for Virtual Jaguar: Main Application Window
4 // (C) 2009 Underground Software
6 // JLH = James L. Hammons <jlhamm@acm.org>
9 // --- ---------- -------------------------------------------------------------
10 // JLH 12/23/2009 Created this file
20 // Uncomment this for debugging...
22 //#define DEBUGFOO // Various tool debugging...
23 //#define DEBUGTP // Toolpalette debugging...
30 //#include "editwindow.h"
31 //#include "charwindow.h"
36 // The way BSNES controls things is by setting a timer with a zero
37 // timeout, sleeping if not emulating anything. Seems there has to be a
40 // It has a novel approach to plugging-in/using different video/audio/input
41 // methods, can we do something similar or should we just use the built-in
44 // ((TTEdit *)qApp)->charWnd = new CharWindow(this);
45 videoWidget = new GLWidget(this);
46 setCentralWidget(videoWidget);
47 setWindowIcon(QIcon(":/res/vj.xpm"));
48 setWindowTitle("Virtual Jaguar v2.0.0");
52 newAct = new QAction(QIcon(":/images/new.png"), tr("&New"), this);
53 newAct->setShortcuts(QKeySequence::New);
54 newAct->setStatusTip(tr("Create a new file"));
55 connect(newAct, SIGNAL(triggered()), this, SLOT(newFile()));
57 openAct = new QAction(QIcon(":/images/open.png"), tr("&Open..."), this);
58 openAct->setShortcuts(QKeySequence::Open);
59 openAct->setStatusTip(tr("Open an existing file"));
60 connect(openAct, SIGNAL(triggered()), this, SLOT(open()));
62 aboutQtAct = new QAction(tr("About &Qt"), this);
63 aboutQtAct->setStatusTip(tr("Show the Qt library's About box"));
64 connect(aboutQtAct, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
67 fileMenu = menuBar()->addMenu(tr("&File"));
68 fileMenu->addAction(newAct);
69 fileMenu->addAction(openAct);
70 fileMenu->addAction(saveAct);
71 fileMenu->addAction(saveAsAct);
72 fileMenu->addSeparator();
73 fileMenu->addAction(exitAct);
75 editMenu = menuBar()->addMenu(tr("&Edit"));
76 editMenu->addAction(cutAct);
77 editMenu->addAction(copyAct);
78 editMenu->addAction(pasteAct);
80 menuBar()->addSeparator();
82 helpMenu = menuBar()->addMenu(tr("&Help"));
83 helpMenu->addAction(aboutAct);
84 helpMenu->addAction(aboutQtAct);
87 fileToolBar = addToolBar(tr("File"));
88 fileToolBar->addAction(newAct);
89 fileToolBar->addAction(openAct);
90 fileToolBar->addAction(saveAct);
92 editToolBar = addToolBar(tr("Edit"));
93 editToolBar->addAction(cutAct);
94 editToolBar->addAction(copyAct);
95 editToolBar->addAction(pasteAct);
99 statusBar()->showMessage(tr("Ready"));
103 // connect(textEdit->document(), SIGNAL(contentsChanged()),
104 // this, SLOT(documentWasModified()));
106 // setCurrentFile("");
107 setUnifiedTitleAndToolBarOnMac(true);
109 // Set up timer based loop for animation...
110 timer = new QTimer(this);
111 connect(timer, SIGNAL(timeout()), this, SLOT(Timer()));
115 void MainWin::closeEvent(QCloseEvent * event)
118 event->accept(); // ignore() if can't close for some reason
121 void MainWin::Open(void)
125 void MainWin::Timer(void)
127 // Random hash & trash
128 // We try to simulate an untuned tank circuit here... :-)
129 for(int x=0; x<videoWidget->rasterWidth; x++)
131 for(int y=0; y<videoWidget->rasterHeight; y++)
133 videoWidget->buffer[(y * videoWidget->textureWidth) + x] = (rand() & 0xFF) << 8 | (rand() & 0xFF) << 16 | (rand() & 0xFF) << 24;// | (rand() & 0xFF);//0x000000FF;
134 // buffer[(y * textureWidth) + x] = x*y;
138 videoWidget->updateGL();
141 void MainWin::ReadSettings(void)
143 QSettings settings("Underground Software", "Virtual Jaguar");
144 QPoint pos = settings.value("pos", QPoint(200, 200)).toPoint();
145 QSize size = settings.value("size", QSize(400, 400)).toSize();
148 //videoWidget->updateGL();
149 // pos = settings.value("charWndPos", QPoint(0, 0)).toPoint();
150 // size = settings.value("charWndSize", QSize(200, 200)).toSize();
151 // ((TTEdit *)qApp)->charWnd->resize(size);
152 // ((TTEdit *)qApp)->charWnd->move(pos);
155 void MainWin::WriteSettings(void)
157 QSettings settings("Underground Software", "Virtual Jaguar");
158 settings.setValue("pos", pos());
159 settings.setValue("size", size());
160 // settings.setValue("charWndPos", ((TTEdit *)qApp)->charWnd->pos());
161 // settings.setValue("charWndSize", ((TTEdit *)qApp)->charWnd->size());