Various improvements over the QLabel based approach.
Signed-off-by: Andrea Odetti <mariofutire@gmail.com>
This commit is contained in:
parent
facf9aec25
commit
c9fb116464
10 changed files with 76 additions and 42 deletions
1
source/frontends/qapple/applen.conf
Symbolic link
1
source/frontends/qapple/applen.conf
Symbolic link
|
@ -0,0 +1 @@
|
|||
../../../applen.conf
|
12
source/frontends/qapple/emulator.cpp
Normal file
12
source/frontends/qapple/emulator.cpp
Normal file
|
@ -0,0 +1,12 @@
|
|||
#include "emulator.h"
|
||||
|
||||
Emulator::Emulator(QWidget *parent) :
|
||||
QFrame(parent)
|
||||
{
|
||||
setupUi(this);
|
||||
}
|
||||
|
||||
void Emulator::redrawScreen()
|
||||
{
|
||||
video->update();
|
||||
}
|
16
source/frontends/qapple/emulator.h
Normal file
16
source/frontends/qapple/emulator.h
Normal file
|
@ -0,0 +1,16 @@
|
|||
#ifndef EMULATOR_H
|
||||
#define EMULATOR_H
|
||||
|
||||
#include "ui_emulator.h"
|
||||
|
||||
class Emulator : public QFrame, private Ui::Emulator
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit Emulator(QWidget *parent = 0);
|
||||
|
||||
void redrawScreen();
|
||||
};
|
||||
|
||||
#endif // EMULATOR_H
|
|
@ -1,21 +1,15 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Video</class>
|
||||
<widget class="QFrame" name="Video">
|
||||
<class>Emulator</class>
|
||||
<widget class="QFrame" name="Emulator">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>580</width>
|
||||
<height>404</height>
|
||||
<width>683</width>
|
||||
<height>523</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Apple ][ Video</string>
|
||||
</property>
|
||||
|
@ -27,20 +21,25 @@
|
|||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<widget class="Video" name="video" native="true">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>560</width>
|
||||
<height>384</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>Video</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>video.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
|
@ -16,6 +16,8 @@
|
|||
#include "linux/data.h"
|
||||
#include "linux/configuration.h"
|
||||
|
||||
#include "emulator.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
|
@ -24,7 +26,7 @@ namespace
|
|||
g_fh = fopen("/tmp/applewin.txt", "w");
|
||||
setbuf(g_fh, NULL);
|
||||
|
||||
InitializeRegistry("/home/andrea/projects/cvs/A2E/applen.conf");
|
||||
InitializeRegistry("../qapple/applen.conf");
|
||||
|
||||
LogFileOutput("Initialisation\n");
|
||||
|
||||
|
@ -83,8 +85,8 @@ QApple::QApple(QWidget *parent) :
|
|||
{
|
||||
setupUi(this);
|
||||
|
||||
myVideo = new Video(mdiArea);
|
||||
mdiArea->addSubWindow(myVideo, Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint);
|
||||
myEmulator = new Emulator(mdiArea);
|
||||
mdiArea->addSubWindow(myEmulator, Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint);
|
||||
|
||||
myMSGap = 5;
|
||||
|
||||
|
@ -107,7 +109,7 @@ void QApple::timerEvent(QTimerEvent *event)
|
|||
if (g_dwCyclesThisFrame >= dwClksPerFrame)
|
||||
{
|
||||
g_dwCyclesThisFrame -= dwClksPerFrame;
|
||||
myVideo->redrawScreen();
|
||||
myEmulator->redrawScreen();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include "ui_qapple.h"
|
||||
|
||||
#include "video.h"
|
||||
class Emulator;
|
||||
|
||||
class QApple : public QMainWindow, private Ui::QApple
|
||||
{
|
||||
|
@ -21,7 +21,7 @@ private slots:
|
|||
void on_actionPause_triggered();
|
||||
|
||||
private:
|
||||
Video * myVideo;
|
||||
Emulator * myEmulator;
|
||||
|
||||
int myMSGap;
|
||||
int myTimerID;
|
||||
|
|
|
@ -14,14 +14,16 @@ TEMPLATE = app
|
|||
|
||||
SOURCES += main.cpp\
|
||||
qapple.cpp \
|
||||
video.cpp \
|
||||
qresources.cpp
|
||||
qresources.cpp \
|
||||
emulator.cpp \
|
||||
video.cpp
|
||||
|
||||
HEADERS += qapple.h \
|
||||
emulator.h \
|
||||
video.h
|
||||
|
||||
FORMS += qapple.ui \
|
||||
video.ui
|
||||
emulator.ui
|
||||
|
||||
RESOURCES += \
|
||||
qapple.qrc
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "StdAfx.h"
|
||||
|
||||
#include <qfile.h>
|
||||
#include <QFile>
|
||||
|
||||
#include "Log.h"
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#include "video.h"
|
||||
|
||||
#include <qpainter.h>
|
||||
#include <string>
|
||||
#include <QPainter>
|
||||
|
||||
#include "StdAfx.h"
|
||||
#include "Video.h"
|
||||
|
@ -72,18 +71,21 @@ bool Video::UpdateDHiResCell(QPainter & painter, int x, int y, int xpixel, int y
|
|||
return true;
|
||||
}
|
||||
|
||||
Video::Video(QWidget *parent) :
|
||||
QFrame(parent)
|
||||
Video::Video(QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
setupUi(this);
|
||||
|
||||
myCharset.reset(new QPixmap(":/resources/CHARSET4.BMP"));
|
||||
myVideo.reset(new QPixmap(14 * 40, 16 * 24));
|
||||
}
|
||||
|
||||
void Video::redrawScreen()
|
||||
void Video::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
QPainter painter(myVideo.get());
|
||||
QPainter painter(this);
|
||||
|
||||
const QSize min = minimumSize();
|
||||
const QSize actual = size();
|
||||
const double sx = double(actual.width()) / double(min.width());
|
||||
const double sy = double(actual.height()) / double(min.height());
|
||||
|
||||
painter.scale(sx, sy);
|
||||
|
||||
const int displaypage2 = (SW_PAGE2) == 0 ? 0 : 1;
|
||||
|
||||
|
@ -140,7 +142,4 @@ void Video::redrawScreen()
|
|||
++y;
|
||||
ypixel += 16;
|
||||
}
|
||||
painter.end();
|
||||
|
||||
label->setPixmap(*myVideo);
|
||||
}
|
||||
|
|
|
@ -1,18 +1,22 @@
|
|||
#ifndef VIDEO_H
|
||||
#define VIDEO_H
|
||||
|
||||
#include "ui_video.h"
|
||||
#include <QWidget>
|
||||
|
||||
#include <memory>
|
||||
|
||||
class Video : public QFrame, private Ui::Video
|
||||
class Video : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit Video(QWidget *parent = 0);
|
||||
|
||||
void redrawScreen();
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *event);
|
||||
|
||||
private:
|
||||
bool Update40ColCell(QPainter & painter, int x, int y, int xpixel, int ypixel, int offset);
|
||||
|
@ -23,7 +27,6 @@ private:
|
|||
bool UpdateDHiResCell(QPainter & painter, int x, int y, int xpixel, int ypixel, int offset);
|
||||
|
||||
std::shared_ptr<QPixmap> myCharset;
|
||||
std::shared_ptr<QPixmap> myVideo;
|
||||
};
|
||||
|
||||
#endif // FRAME_H
|
||||
#endif // VIDEO_H
|
||||
|
|
Loading…
Add table
Reference in a new issue