Removed MainWindow class, replaced with DiskExplorer

This commit is contained in:
Mark Long 2016-10-28 00:48:18 -05:00
parent 340c9f7fa5
commit ecec14c2d0
10 changed files with 372 additions and 366 deletions

View File

@ -41,7 +41,6 @@ SOURCES += \
src/binaryfile/binaryfile.cxx \
src/textfile/textfile.cxx \
src/ui/catalogwidget.cxx \
src/ui/mainwindow.cxx \
src/ui/viewers/hiresviewwidget.cxx \
src/ui/viewers/applesoftfileviewer.cxx \
src/ui/viewers/disassemblerviewer.cpp \
@ -85,7 +84,6 @@ HEADERS += \
src/binaryfile/binaryfile.h \
src/textfile/textfile.h \
src/ui/catalogwidget.h \
src/ui/mainwindow.h \
src/ui/viewers/hiresviewwidget.h \
src/ui/viewers/applesoftfileviewer.h \
src/applesoftfile/applesoftformatter.h \
@ -119,7 +117,6 @@ HEADERS += \
FORMS += \
src/ui/catalogwidget.ui \
src/ui/mainwindow.ui \
src/ui/viewers/applesoftfileviewer.ui \
src/ui/viewers/disassemblerviewer.ui \
src/ui/viewers/hexdumpviewer.ui \

View File

@ -2,12 +2,12 @@
#include <QSettings>
#include <QString>
#include "mainwindow.h"
#include "binaryfile.h"
#include "genericfile.h"
#include "diskfile.h"
#include "catalogsector.h"
#include "applesoftfile.h"
#include "DiskExplorer.h"
int main(int argc, char** argv)
{
@ -15,7 +15,7 @@ int main(int argc, char** argv)
QCoreApplication::setOrganizationName("AppleSAWS");
QCoreApplication::setOrganizationDomain("ml.com");
QCoreApplication::setApplicationName("AppleSAWS");
MainWindow w;
DiskExplorer w;
QSettings settings;
QString lastOpened = settings.value("lastOpened").toString();
if (!lastOpened.isEmpty())

View File

@ -1,6 +1,145 @@
#include "DiskExplorer.h"
#include <QGridLayout>
#include <QMenuBar>
#include <QAction>
#include <QSettings>
#include <QFileDialog>
#include "genericfile.h"
#include "viewerbase.h"
DiskExplorer::DiskExplorer(QWidget *parent) : QMainWindow(parent)
{
m_action_Unload_Disk_Image = 0;
m_disk = 0;
initUi();
}
void DiskExplorer::initUi()
{
QMenuBar *menuBar = new QMenuBar(this);
setMenuBar(menuBar);
QMenu *menu = new QMenu(tr("&File"),this);
menuBar->addMenu(menu);
QAction *action_Load_Disk_Image = new QAction(tr("&Load Disk Image..."),this);
menu->addAction(action_Load_Disk_Image);
connect(action_Load_Disk_Image, SIGNAL(triggered()), SLOT(showLoadDialog()));
m_action_Unload_Disk_Image = new QAction(tr("&Unload Disk Image"),this);
m_action_Unload_Disk_Image->setEnabled(false);
menu->addAction(m_action_Unload_Disk_Image);
connect(m_action_Unload_Disk_Image, SIGNAL(triggered()), SLOT(unloadDiskFile()));
menu->addSeparator();
QAction *action_Quit = new QAction(tr("&Quit"),this);
menu->addAction(action_Quit);
connect(action_Quit, SIGNAL(triggered()), qApp, SLOT(quit()));
menu = new QMenu(tr("&Util"),this);
menuBar->addMenu(menu);
QAction *action_Hex_Converter = new QAction(tr("&Hex Converter..."),this);
menu->addAction(action_Hex_Converter);
menu = new QMenu(tr("&Misc"),this);
menuBar->addMenu(menu);
QAction *action_HRCG_Commands = new QAction(tr("&HRCG Commands..."),this);
menu->addAction(action_HRCG_Commands);
m_hrcgDialog = new HRCGControlsInfo(this);
connect(action_HRCG_Commands, SIGNAL(triggered()), m_hrcgDialog, SLOT(show()));
m_hexConverter = new HexConverter(this);
connect(action_Hex_Converter, SIGNAL(triggered()), m_hexConverter, SLOT(show()));
QWidget *widget = new QWidget(this);
this->setCentralWidget(widget);
QGridLayout *layout = new QGridLayout();
layout->setVerticalSpacing(4);
layout->setHorizontalSpacing(4);
widget->setLayout(layout);
m_cw = new CatalogWidget(widget);
m_demw = new DiskExplorerMapWidget(35,16,widget);
QFrame *frame = new QFrame(widget);
frame->setFrameStyle(QFrame::Raised);
frame->setStyleSheet("background-color: darkGray");
frame->setMinimumSize(200,200);
layout->setColumnStretch(0,4);
layout->setColumnStretch(1,1);
layout->setColumnStretch(2,4);
layout->addWidget(m_cw,0,0,2,1);
layout->addWidget(m_demw,0,1,1,2);
layout->addWidget(m_demw->makeKeyWidget(),1,1);
layout->addWidget(frame,1,2);
connect(m_cw,SIGNAL(openWithDefaultViewer(DiskFile*,FileDescriptiveEntry)),
SLOT(handleDiskItemSelectedDefaultOpen(DiskFile*,FileDescriptiveEntry)));
}
void DiskExplorer::unloadDiskFile()
{
if (m_disk)
{
m_cw->unloadDisk(m_disk);
m_demw->unloadDisk();
}
}
void DiskExplorer::loadDiskFile(QString filename)
{
if (m_disk) {
unloadDiskFile();
}
m_disk = new DiskFile();
m_cw->prepForNewDisk(filename,m_disk);
if (m_disk->read(filename)) {
m_action_Unload_Disk_Image->setEnabled(true);
QSettings settings;
settings.setValue("lastOpened",filename);
m_cw->processNewlyLoadedDisk(filename,m_disk);
m_demw->setDisk(m_disk);
} else {
emit diskFileLoadFailed(filename,m_disk);
delete m_disk;
m_disk = 0;
}
}
void DiskExplorer::showLoadDialog()
{
QSettings settings;
QString last = settings.value("lastOpened",".").toString();
QString filename = QFileDialog::getOpenFileName(this,
tr("Open Disk Image"),
last,
"Disk Images (*.do *.dsk)");
if (!filename.isEmpty()) {
loadDiskFile(filename);
}
}
void DiskExplorer::handleDiskItemSelectedDefaultOpen(DiskFile *disk, FileDescriptiveEntry fde)
{
GenericFile *file = disk->getFile(fde);
file->setFilename(AppleString(fde.filename).printable().trimmed());
ViewerBase *vb = new ViewerBase();
vb->setFile(file);
vb->show();
}

View File

@ -3,6 +3,15 @@
#include <QMainWindow>
#include "catalogwidget.h"
#include "DiskExplorerMapWidget.h"
#include "diskfile.h"
#include "hrcgcontrolsinfo.h"
#include "hexconverter.h"
#include <QFrame>
class DiskExplorer : public QMainWindow
{
Q_OBJECT
@ -10,8 +19,35 @@ public:
explicit DiskExplorer(QWidget *parent = 0);
signals:
void diskFileLoading(QString filename, DiskFile *file);
void diskFileLoaded(QString filename, DiskFile *file);
void diskFileLoadFailed(QString filename, DiskFile *file);
void diskFileUnloading(DiskFile *file);
void diskFileUnloaded();
public slots:
void unloadDiskFile();
void loadDiskFile(QString filename);
void showLoadDialog();
private slots:
void handleDiskItemSelectedDefaultOpen(DiskFile *disk, FileDescriptiveEntry fde);
protected:
void initUi();
private:
CatalogWidget *m_cw;
DiskExplorerMapWidget *m_demw;
DiskFile *m_disk;
HRCGControlsInfo *m_hrcgDialog;
HexConverter *m_hexConverter;
QAction *m_action_Unload_Disk_Image;
};
#endif // DISKEXPLORER_H
#endif // DISKEXPLORER_H

View File

@ -2,11 +2,11 @@
//#include "vtoc.h"
//#include "catalogsector.h"
#include "util.h"
#include <QToolButton>
#include <QPushButton>
#include <QGridLayout>
#include <QLabel>
#include <QButtonGroup>
#include <QDebug>
DiskExplorerMapWidget::DiskExplorerMapWidget(int numtracks, int numsectors, QWidget *parent) : QWidget(parent)
@ -15,28 +15,32 @@ DiskExplorerMapWidget::DiskExplorerMapWidget(int numtracks, int numsectors, QWid
m_numsectors = numsectors;
setWindowTitle("Disk Explorer");
// m_disk = Q_NULLPTR;
m_currentClicked = Q_NULLPTR;
m_currentChecked = Q_NULLPTR;
initColors();
QGridLayout *layout = new QGridLayout();
layout->setSizeConstraint(QLayout::SetFixedSize);
layout->setHorizontalSpacing(1);
layout->setVerticalSpacing(0);
layout->setHorizontalSpacing(2);
layout->setVerticalSpacing(1);
m_bgroup = new QButtonGroup(this);
setLayout(layout);
QLabel *tracklabel = new QLabel("Track",this);
layout->addWidget(tracklabel,0,0,1,m_numtracks+1,Qt::AlignHCenter);
for (int track= 0; track < numtracks; track++)
{
QLabel *label = new QLabel(QString("%1").arg(track));
label->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
layout->addWidget(label,0,track+1);
layout->addWidget(label,1,track+1);
}
for (int sec = 0; sec < numsectors; sec++)
{
QLabel *label = new QLabel(QString("Sec %1").arg(sec));
label->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
layout->addWidget(label,sec+1,0);
layout->addWidget(label,sec+2,0);
}
for (int track = 0; track < 35; track++)
{
@ -45,35 +49,41 @@ DiskExplorerMapWidget::DiskExplorerMapWidget(int numtracks, int numsectors, QWid
DEButton *tb = new DEButton(this,track,sec);
tb->setObjectName(QString("BtnT%1S%2").arg(track).arg(sec));
tb->setBgColor(m_defaultColor);
connect(tb,SIGNAL(clicked(int,int,bool)),SLOT(handleButtonClick(int,int)));
tb->setCheckable(true);
m_bgroup->addButton(tb,(track * numsectors) + sec);
connect(tb,SIGNAL(checked(int,int,bool)),SLOT(handleButtonCheck(int,int,bool)));
m_buttons[track][sec] = tb;
tb->setAutoFillBackground(true);
layout->addWidget(tb,sec+1,track+1);
layout->addWidget(tb,sec+2,track+1);
}
}
}
void DiskExplorerMapWidget::handleButtonClick(int track, int sector)
void DiskExplorerMapWidget::handleButtonCheck(int track, int sector, bool checked)
{
if (m_currentClicked)
if (m_currentChecked)
{
// Do anything needed to clean up after previous button click
// m_currentClicked->setHighlighted(false);
}
qDebug() << "Checked: " << checked << "t/s" << track << sector;
DEButton *currbutton = buttonAt(track,sector);
if (currbutton == m_currentClicked)
if (currbutton == m_currentChecked)
{
// currbutton->setHighlighted(false);
// Handle reclicking on the same button
}
else
{
// currbutton->setHighlighted(true);
// Handle clicking on a new button;
}
m_currentClicked = currbutton;
m_currentChecked = currbutton;
}
void DiskExplorerMapWidget::setButtonBgColor(int track, int sector, QColor color)
@ -85,12 +95,81 @@ void DiskExplorerMapWidget::setDisk(DiskFile *disk)
{
if (disk)
{
m_disk = disk;
setWindowTitle(QString("Disk Explorer - %1").arg(m_disk->getDiskImageName()));
mapDiskToButtons();
m_disk = disk;
setWindowTitle(QString("Disk Explorer - %1").arg(m_disk->getDiskImageName()));
mapDiskToButtons();
}
}
void DiskExplorerMapWidget::unloadDisk()
{
if (m_disk)
{
m_bgroup->setExclusive(false);
for (int track = 0; track < m_numtracks; track++)
{
for (int sec = 0; sec < m_numsectors; sec++)
{
DEButton *button = buttonAt(track,sec);
button->setText("");
button->setBgColor(m_defaultColor);
button->setChecked(false);
}
}
setAllButtonsEnabled(false);
}
}
void DiskExplorerMapWidget::setAllButtonsEnabled(bool enabled)
{
for (int track = 0; track < m_numtracks; track++)
{
for (int sec = 0; sec < m_numsectors; sec++)
{
DEButton *button = buttonAt(track,sec);
button->setEnabled(enabled);
}
}
}
QLabel *DiskExplorerMapWidget::makeKeyLabel(QWidget *parent, QString name, QColor color)
{
QLabel *label = new QLabel(name,parent);
label->setStyleSheet(QString("background-color:%1; color: %2")
.arg(color.name())
.arg(determineFgColor(color).name()));
label->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
return label;
}
QGroupBox *DiskExplorerMapWidget::makeKeyWidget()
{
int idx = 0;
QGroupBox *groupbox= new QGroupBox(this);
groupbox->setTitle("Key");
QGridLayout *layout = new QGridLayout();
layout->setVerticalSpacing(0);
layout->setHorizontalSpacing(0);
groupbox->setLayout(layout);
layout->addWidget(makeKeyLabel(groupbox,"Unused Sector",m_defaultColor),idx++,0);
layout->addWidget(makeKeyLabel(groupbox,"Boot Sector",m_bootSectorColor),idx++,0);
layout->addWidget(makeKeyLabel(groupbox,"DOS Image",m_dosImageColor),idx++,0);
layout->addWidget(makeKeyLabel(groupbox,"VTOC",m_vtocColor),idx++,0);
layout->addWidget(makeKeyLabel(groupbox,"Dir Entry",m_dirEntryColor),idx++,0);
layout->addWidget(makeKeyLabel(groupbox,"T/S List",m_tsListColor),idx++,0);
layout->addWidget(makeKeyLabel(groupbox,"Applesoft File",m_applesoftFileColor),idx++,0);
layout->addWidget(makeKeyLabel(groupbox,"Int. Basic File",m_intBasicFileColor),idx++,0);
layout->addWidget(makeKeyLabel(groupbox,"Binary File",m_binaryFileColor),idx++,0);
layout->addWidget(makeKeyLabel(groupbox,"Text File",m_textFileColor),idx++,0);
layout->addWidget(makeKeyLabel(groupbox,"Relocatable File",m_reloFileColor),idx++,0);
layout->addWidget(makeKeyLabel(groupbox,"Type-A File",m_typeAFileColor),idx++,0);
layout->addWidget(makeKeyLabel(groupbox,"Type-B File",m_typeBFileColor),idx++,0);
layout->addWidget(makeKeyLabel(groupbox,"Type-S File",m_typeSFileColor),idx++,0);
return groupbox;
}
DEButton *DiskExplorerMapWidget::buttonAt(int track, int sector)
{
if (track >= m_numtracks || sector >= m_numsectors)
@ -105,36 +184,47 @@ DEButton *DiskExplorerMapWidget::buttonAt(int track, int sector)
void DiskExplorerMapWidget::initColors()
{
m_defaultColor = QColor(Qt::lightGray);
m_bootSectorColor = QColor(Qt::darkGreen);
m_dosImageColor = QColor(Qt::green);
m_vtocColor = QColor("#808000");
m_bootSectorColor = QColor("#20b060");
m_dosImageColor = QColor("#30d000");
m_vtocColor = QColor("#efc010");
m_tsListColor = QColor("#ff8000");
m_dirEntryColor = QColor("#ffff00");
m_applesoftFileColor = QColor(Qt::blue);
m_intBasicFileColor = QColor(Qt::darkBlue);
m_binaryFileColor = QColor(Qt::magenta);
m_textFileColor = QColor("#00ffff");
m_reloFileColor = QColor(Qt::darkMagenta);
m_typeAFileColor = QColor(Qt::red);
m_typeBFileColor = QColor(Qt::darkRed);
m_typeSFileColor = QColor(Qt::darkCyan);
m_dirEntryColor = QColor("#dfdf00");
m_applesoftFileColor = QColor("#3030e0");
m_intBasicFileColor = QColor("#00d0d0");
m_binaryFileColor = QColor("#d060d0");
m_textFileColor = QColor("#F05060");
m_reloFileColor = QColor("#d00000");
m_typeAFileColor = QColor("#c040a0");
m_typeBFileColor = QColor("#c03030");
m_typeSFileColor = QColor("#20a0a0");
}
void DiskExplorerMapWidget::mapDiskToButtons()
{
setAllButtonsEnabled(true);
m_bgroup->setExclusive(false);
int idx = 0;
for (int sec = 0; sec < m_numsectors; sec++)
for (int track = 0; track < 3; track++)
{
buttonAt(0,sec)->setBgColor(m_bootSectorColor);
buttonAt(1,sec)->setBgColor(m_dosImageColor);
buttonAt(2,sec)->setBgColor(m_dosImageColor);
for (int sec = 0; sec < m_numsectors; sec++)
{
if (track == 0)
buttonAt(track,sec)->setBgColor(m_bootSectorColor);
else
buttonAt(track,sec)->setBgColor(m_dosImageColor);
buttonAt(track,sec)->setText(QString("%1").arg(idx++));
}
}
buttonAt(17,0)->setBgColor(m_vtocColor);
buttonAt(17,0)->setText(QString("%1").arg(idx++));
foreach (CatalogSector cs, m_disk->getCatalogSectors())
{
Sector *sec = cs.getSector();
buttonAt(sec->track(),sec->sector())->setBgColor(m_dirEntryColor);
buttonAt(sec->track(),sec->sector())->setText(QString("%1").arg(idx++));
foreach(FileDescriptiveEntry fde, cs.getFDEs())
{
@ -176,7 +266,6 @@ void DiskExplorerMapWidget::mapDiskToButtons()
tslse = tsl.getNextTSList().sector;
tsl = m_disk->getSector(tsl.getNextTSList()).promoteToTrackSectorList();
}
}
}
}

View File

@ -6,9 +6,13 @@
#include <QMap>
#include <QPushButton>
#include <QColor>
#include <QGroupBox>
#include <QLabel>
#include "diskfile.h"
class DEButton : public QPushButton
{
Q_OBJECT
@ -18,6 +22,7 @@ public:
setTrack(track);
setSector(sec);
connect(this,SIGNAL(clicked(bool)),SLOT(handleClick(bool)));
m_isHighlighted = false;
}
void setTrack(int track) { m_track = track; }
void setSector(int sector) { m_sector = sector; }
@ -25,15 +30,36 @@ public:
int track() const { return m_track; }
int sector() const { return m_sector; }
void clearBgColor() { m_backgroundColor = ""; setStyleSheet(makeStyleSheet());}
void setBgColor(QColor color) { m_backgroundColor = color.name(); setStyleSheet(makeStyleSheet()); }
void clearBgColor() { m_backgroundColor = ""; setText(""); setStyleSheet(makeStyleSheet());}
void setBgColor(QColor color) {
m_fgColor = determineFgColor(color).name();
m_backgroundColor = color.name();
m_hlColor = color.lighter(155).name();
setStyleSheet(makeStyleSheet());
}
bool highlighted() const { return m_isHighlighted; }
void setHighlighted(bool highlighted) { m_isHighlighted = highlighted;setStyleSheet(makeStyleSheet()); }
void reset() { setHighlighted(false); setChecked(false); makeStyleSheet(); qDebug() << "Reset";}
void resetToDefault() { clearBgColor(); reset(); }
QColor determineFgColor(QColor bgColor)
{
if (qGray(bgColor.rgb()) > 128)
{
return QColor(Qt::black);
}
return Qt::white;
}
signals:
void clicked(int track, int sec,bool );
void checked(int track, int sec,bool );
private slots:
void handleClick(bool checked) { emit clicked(m_track,m_sector,checked); }
void handleClick(bool isChecked) { emit checked(m_track,m_sector,isChecked); }
QSize minimumSizeHint() const Q_DECL_OVERRIDE { return QSize(24,24); }
QSize sizeHint() const Q_DECL_OVERRIDE { return QSize(24,24); }
@ -41,12 +67,32 @@ private slots:
int heightForWidth(int width) const Q_DECL_OVERRIDE { return width; }
private:
QString makeStyleSheet() const { return QString("background-color:%1;").arg(m_backgroundColor); }
QString makeStyleSheet() const {
return QString(" QPushButton { font: 10px; border-width: 1px; color: %1; background-color: %2} "
" QPushButton:checked { font: bold italic 11px; } "
) .arg(m_fgColor)
.arg(m_backgroundColor);
// return QString(
// "background-color: %1;"
// "font: %2; "
// "border-radius: 0px; "
// "color: %3;"
// ).arg(m_isHighlighted?m_hlColor:m_backgroundColor)
// .arg(m_isHighlighted?"bold italic 11px":"10px")
// .arg(m_fgColor)
// ;
}
int m_track;
int m_sector;
bool m_isHighlighted;
QString m_fgColor;
QString m_backgroundColor;
QString m_hlColor;
};
@ -67,10 +113,14 @@ public:
void setDisk(DiskFile *disk);
QGroupBox *makeKeyWidget();
void unloadDisk();
void setAllButtonsEnabled(bool enabled);
signals:
public slots:
void handleButtonClick(int track, int sector);
void handleButtonCheck(int track, int sector, bool checked);
protected:
void mapDiskToButtons();
@ -78,10 +128,20 @@ protected:
void initColors();
QColor determineFgColor(QColor bgColor)
{
if (qGray(bgColor.rgb()) > 128)
{
return QColor(Qt::black);
}
return Qt::white;
}
QLabel *makeKeyLabel(QWidget *parent, QString name, QColor color);
private:
QMap<int, QMap<int,DEButton*> > m_buttons;
DEButton *m_currentClicked;
DEButton *m_currentChecked;
int m_numtracks;
int m_numsectors;
@ -101,7 +161,9 @@ private:
QColor m_typeBFileColor;
QColor m_typeSFileColor;
QButtonGroup *m_bgroup;
DiskFile *m_disk;
};
#endif // DISKEXPLORERMAPWIDGET_H

View File

@ -1,133 +0,0 @@
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "hiresviewwidget.h"
#include "applesoftfileviewer.h"
#include "applesoftfile.h"
#include "textfile.h"
#include "memory.h"
#include "disassembler.h"
#include "disassemblerviewer.h"
#include "hexdumpviewer.h"
#include "mazeviewer.h"
#include "texthexdumpviewer.h"
#include "charsetviewer.h"
#include "relocatablefile.h"
#include "hrcgcontrolsinfo.h"
#include <QFileDialog>
#include <QTextDocument>
#include <QSettings>
#include <QString>
#include <QDebug>
#include "DiskExplorerMapWidget.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
m_disk = 0;
ui->action_Unload_Disk_Image->setEnabled(false);
connect(ui->action_Quit, SIGNAL(triggered()), qApp, SLOT(quit()));
connect(ui->action_Load_Disk_Image, SIGNAL(triggered()), SLOT(showLoadDialog()));
connect(ui->action_Unload_Disk_Image, SIGNAL(triggered()), SLOT(unloadDiskFile()));
connect(ui->catalogWidget,SIGNAL(openWithDefaultViewer(DiskFile*,FileDescriptiveEntry)),
SLOT(handleDiskItemSelectedDefaultOpen(DiskFile*,FileDescriptiveEntry)));
connect(this, SIGNAL(diskFileLoading(QString, DiskFile*)),
ui->catalogWidget, SLOT(prepForNewDisk(QString,DiskFile*)));
connect(this, SIGNAL(diskFileLoaded(QString,DiskFile*)),
ui->catalogWidget, SLOT(processNewlyLoadedDisk(QString,DiskFile*)));
connect(this, SIGNAL(diskFileUnloading(DiskFile*)),
ui->catalogWidget, SLOT(unloadDisk(DiskFile*)));
connect(this->ui->action_Disk_Explorer, SIGNAL(triggered(bool)),
SLOT(showDiskExplorer()));
m_hrcgDialog = new HRCGControlsInfo(this);
connect(ui->action_HRCG_Commands, SIGNAL(triggered()), m_hrcgDialog, SLOT(show()));
m_hexConverter = new HexConverter(this);
connect(ui->action_Hex_Converter, SIGNAL(triggered()), m_hexConverter, SLOT(show()));
}
MainWindow::~MainWindow()
{
if (m_disk) {
unloadDiskFile();
}
delete ui;
}
void MainWindow::loadDiskFile(QString filename)
{
if (m_disk) {
unloadDiskFile();
}
m_disk = new DiskFile();
emit diskFileLoading(filename,m_disk);
if (m_disk->read(filename)) {
ui->action_Unload_Disk_Image->setEnabled(true);
QSettings settings;
settings.setValue("lastOpened",filename);
emit diskFileLoaded(filename,m_disk);
} else {
emit diskFileLoadFailed(filename,m_disk);
delete m_disk;
m_disk = 0;
}
showDiskExplorer();
}
void MainWindow::unloadDiskFile()
{
emit diskFileUnloading(m_disk);
delete m_disk;
m_disk = 0;
ui->action_Unload_Disk_Image->setEnabled(false);
emit diskFileUnloaded();
}
void MainWindow::showLoadDialog()
{
QSettings settings;
QString last = settings.value("lastOpened",".").toString();
QString filename = QFileDialog::getOpenFileName(this,
tr("Open Disk Image"),
last,
"Disk Images (*.do *.dsk)");
if (!filename.isEmpty()) {
loadDiskFile(filename);
}
}
void MainWindow::handleDiskItemSelectedDefaultOpen(DiskFile *disk, FileDescriptiveEntry fde)
{
GenericFile *file = disk->getFile(fde);
file->setFilename(AppleString(fde.filename).printable().trimmed());
ViewerBase *vb = new ViewerBase();
vb->setFile(file);
vb->show();
}
void MainWindow::showDiskExplorer()
{
if (m_disk)
{
DiskExplorerMapWidget *demw = new DiskExplorerMapWidget(35,16,Q_NULLPTR);
demw->setDisk(m_disk);
demw->show();
}
}

View File

@ -1,52 +0,0 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include "diskfile.h"
#include "binaryfile.h"
#include "applesoftfile.h"
//#include "relocatablefile.h"
#include "hexconverter.h"
#include "hrcgcontrolsinfo.h"
#include "viewerbase.h"
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
public slots:
void loadDiskFile(QString filename);
void unloadDiskFile();
void showLoadDialog();
private slots:
void handleDiskItemSelectedDefaultOpen(DiskFile *disk, FileDescriptiveEntry fde);
signals:
void diskFileLoading(QString filename, DiskFile *file);
void diskFileLoaded(QString filename, DiskFile *file);
void diskFileLoadFailed(QString filename, DiskFile *file);
void diskFileUnloading(DiskFile *file);
void diskFileUnloaded();
protected slots:
void showDiskExplorer();
private:
Ui::MainWindow *ui;
HRCGControlsInfo *m_hrcgDialog;
HexConverter *m_hexConverter;
DiskFile *m_disk;
};
#endif // MAINWINDOW_H

View File

@ -1,130 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>273</width>
<height>600</height>
</rect>
</property>
<property name="windowTitle">
<string>AppleSAWS</string>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="CatalogWidget" name="catalogWidget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>2</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>200</width>
<height>0</height>
</size>
</property>
<property name="baseSize">
<size>
<width>300</width>
<height>0</height>
</size>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>273</width>
<height>21</height>
</rect>
</property>
<widget class="QMenu" name="menu_File">
<property name="title">
<string>&amp;File</string>
</property>
<addaction name="action_Load_Disk_Image"/>
<addaction name="action_Unload_Disk_Image"/>
<addaction name="separator"/>
<addaction name="action_Quit"/>
</widget>
<widget class="QMenu" name="menu_Util">
<property name="title">
<string>&amp;Util</string>
</property>
<addaction name="action_Hex_Converter"/>
<addaction name="action_Disk_Explorer"/>
</widget>
<widget class="QMenu" name="menuDocs">
<property name="title">
<string>&amp;Misc</string>
</property>
<addaction name="action_HRCG_Commands"/>
</widget>
<addaction name="menu_File"/>
<addaction name="menu_Util"/>
<addaction name="menuDocs"/>
</widget>
<widget class="QStatusBar" name="statusbar"/>
<widget class="QToolBar" name="toolBar">
<property name="windowTitle">
<string>toolBar</string>
</property>
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
</widget>
<action name="action_Load_Disk_Image">
<property name="text">
<string>&amp;Load Disk Image</string>
</property>
</action>
<action name="action_Quit">
<property name="text">
<string>&amp;Quit</string>
</property>
</action>
<action name="action_Unload_Disk_Image">
<property name="text">
<string>&amp;Unload Disk Image</string>
</property>
</action>
<action name="action_Hex_Converter">
<property name="text">
<string>&amp;Hex Converter...</string>
</property>
</action>
<action name="action_HRCG_Commands">
<property name="text">
<string>&amp;HRCG Commands</string>
</property>
</action>
<action name="action_Disk_Explorer">
<property name="text">
<string>&amp;Disk Explorer...</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>
<class>CatalogWidget</class>
<extends>QWidget</extends>
<header>catalogwidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@ -4,6 +4,7 @@
#include <QPair>
#include <QByteArray>
#include <QDebug>
#include <QColor>
typedef enum {
DOSTextFile = 0x00,
@ -72,7 +73,4 @@ inline QString uint32ToHex(quint32 val) {
#endif // UTIL_H