Hidden DiskExplorer at startup, Viewers close w/ main app exit.

This commit is contained in:
Mark Long 2016-10-30 11:59:03 -05:00
parent dab8f1e7d4
commit c3c80f9f1e
8 changed files with 154 additions and 32 deletions

View File

@ -10,6 +10,18 @@
<height>560</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="font">
<font>
<family>Courier 10 Pitch</family>

View File

@ -5,6 +5,8 @@
#include <QAction>
#include <QSettings>
#include <QFileDialog>
#include <QShowEvent>
#include <QDebug>
#include "genericfile.h"
#include "viewerbase.h"
@ -13,10 +15,16 @@ DiskExplorer::DiskExplorer(QWidget *parent) : QMainWindow(parent)
{
m_action_Unload_Disk_Image = 0;
m_disk = 0;
m_horizSizePref = -1;
resize(300,800);
initUi();
}
DiskExplorer::~DiskExplorer()
{
}
void DiskExplorer::initUi()
{
QMenuBar *menuBar = new QMenuBar(this);
@ -33,6 +41,8 @@ void DiskExplorer::initUi()
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);
@ -45,6 +55,16 @@ void DiskExplorer::initUi()
QAction *action_Hex_Converter = new QAction(tr("&Hex Converter..."),this);
menu->addAction(action_Hex_Converter);
menu->addSeparator();
m_setDiskToolsVisibleAction = new QAction(tr("Show &Disk tools"),this);
m_setDiskToolsVisibleAction->setCheckable(true);
m_setDiskToolsVisibleAction->setChecked(false);
connect(m_setDiskToolsVisibleAction, SIGNAL(toggled(bool)),
SLOT(setDiskToolsVisible(bool)));
menu->addAction(m_setDiskToolsVisibleAction);
menu = new QMenu(tr("&Misc"),this);
menuBar->addMenu(menu);
@ -59,38 +79,40 @@ void DiskExplorer::initUi()
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);
QWidget *widget = new QWidget(0);
m_gridLayout = new QGridLayout();
m_gridLayout->setVerticalSpacing(4);
m_gridLayout->setHorizontalSpacing(4);
widget->setLayout(m_gridLayout);
//m_gridLayout->setSizeConstraint(QLayout::SetFixedSize);
m_cw = new CatalogWidget(widget);
m_demw = new DiskExplorerMapWidget(35,16,widget);
m_frame = new QFrame(widget);
m_frame->setFrameStyle(QFrame::Raised);
m_frame->setMinimumSize(200,200);
QGridLayout *frameLayout = new QGridLayout(this);
QGridLayout *frameLayout = new QGridLayout(0);
m_frame->setLayout(frameLayout);
m_hdv = new HexDumpViewer(this);
frameLayout->addWidget(m_hdv);
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(m_frame,1,2);
m_gridLayout->setColumnStretch(0,4);
m_gridLayout->setColumnStretch(1,1);
m_gridLayout->setColumnStretch(2,4);
m_gridLayout->addWidget(m_cw,0,0,2,1);
m_gridLayout->addWidget(m_demw,0,1,1,2);
m_key = m_demw->makeKeyWidget();
m_gridLayout->addWidget(m_key,1,1);
m_gridLayout->addWidget(m_frame,1,2);
this->setCentralWidget(widget);
connect(m_cw,SIGNAL(openWithDefaultViewer(DiskFile*,FileDescriptiveEntry)),
SLOT(handleDiskItemSelectedDefaultOpen(DiskFile*,FileDescriptiveEntry)));
connect(m_demw, SIGNAL(showSectorData(QByteArray,int,int,QVariant)),
SLOT(handleShowSectorData(QByteArray,int,int,QVariant)));
setDiskToolsVisible(false);
}
@ -153,6 +175,68 @@ void DiskExplorer::handleDiskItemSelectedDefaultOpen(DiskFile *disk, FileDescrip
file->setFilename(AppleString(fde.filename).printable().trimmed());
ViewerBase *vb = new ViewerBase();
qDebug() << "Adding viewer" << vb;
m_viewerList.append(vb);
connect(vb,SIGNAL(viewerClosing(ViewerBase*)), SLOT(handleViewerClosing(ViewerBase*)));
vb->setFile(file);
vb->show();
}
void DiskExplorer::setDiskToolsVisible(bool visible)
{
if (visible)
{
m_gridLayout->setColumnStretch(0,4);
m_gridLayout->setColumnStretch(1,1);
m_gridLayout->setColumnStretch(2,4);
}
else
{
m_gridLayout->setColumnStretch(0,0);
m_gridLayout->setColumnStretch(1,0);
m_gridLayout->setColumnStretch(2,0);
}
m_demw->setVisible(visible);
m_frame->setVisible(visible);
m_hdv->setVisible(visible);
m_key->setVisible(visible);
if (!visible)
{
QTimer::singleShot(100, this, SLOT(doResize()));
}
}
void DiskExplorer::handleViewerClosing(ViewerBase *viewer)
{
m_viewerList.removeAll(viewer);
}
void DiskExplorer::doResize()
{
resize(m_horizSizePref, this->height());
}
void DiskExplorer::showEvent(QShowEvent *event)
{
Q_UNUSED(event);
if (m_horizSizePref == -1)
{
m_horizSizePref = this->width();
}
}
void DiskExplorer::closeEvent(QCloseEvent *)
{
foreach (ViewerBase *viewer, m_viewerList)
{
if (viewer)
{
viewer->deleteLater();
}
}
}

View File

@ -9,8 +9,10 @@
#include "hrcgcontrolsinfo.h"
#include "hexconverter.h"
#include "hexdumpviewer.h"
#include "viewerbase.h"
#include <QFrame>
#include <QTimer>
class DiskExplorer : public QMainWindow
@ -18,6 +20,7 @@ class DiskExplorer : public QMainWindow
Q_OBJECT
public:
explicit DiskExplorer(QWidget *parent = 0);
virtual ~DiskExplorer();
signals:
void diskFileLoading(QString filename, DiskFile *file);
@ -35,15 +38,26 @@ private slots:
void handleShowSectorData(QByteArray data, int track, int sector, QVariant metadata);
void handleDiskItemSelectedDefaultOpen(DiskFile *disk, FileDescriptiveEntry fde);
void setDiskToolsVisible(bool visible);
void handleViewerClosing(ViewerBase *viewer);
protected:
void initUi();
void showEvent(QShowEvent *event);
void closeEvent(QCloseEvent *);
protected slots:
void doResize();
private:
QAction *m_setDiskToolsVisibleAction;
CatalogWidget *m_cw;
DiskExplorerMapWidget *m_demw;
QFrame *m_frame;
HexDumpViewer *m_hdv;
QWidget *m_key;
QGridLayout *m_gridLayout;
DiskFile *m_disk;
@ -53,6 +67,9 @@ private:
QAction *m_action_Unload_Disk_Image;
int m_horizSizePref;
QList<ViewerBase*> m_viewerList;
};
#endif // DISKEXPLORER_H

View File

@ -4,6 +4,7 @@
#include <QWidget>
#include "applesoftline.h"
#include "applesofttoken.h"
#include <QDebug>
namespace Ui {
class ApplesoftFileDetailViewer;
@ -18,7 +19,7 @@ public:
~ApplesoftFileDetailViewer();
void setLineData(QVector<ApplesoftLine> lineData);
void foo() { qDebug() << "AFDV::foo!"; }
private:
void process();

View File

@ -1,11 +1,11 @@
#include "applesoftfileviewer.h"
#include "ui_applesoftfileviewer.h"
#include "applesoftformatter.h"
#include "applesoftfiledetailviewer.h"
#include <QDebug>
#include <QSettings>
#include <QPrinter>
#include <QPrintDialog>
#include <QCloseEvent>
ApplesoftFileViewer::ApplesoftFileViewer(QWidget *parent) :
@ -13,6 +13,7 @@ ApplesoftFileViewer::ApplesoftFileViewer(QWidget *parent) :
ui(new Ui::ApplesoftFileViewer)
{
ui->setupUi(this);
m_afdv = Q_NULLPTR;
QSettings settings;
QString title = QString("AppleSoft Viewer");
@ -46,6 +47,10 @@ ApplesoftFileViewer::ApplesoftFileViewer(QWidget *parent) :
ApplesoftFileViewer::~ApplesoftFileViewer()
{
delete ui;
if (m_afdv)
{ m_afdv->foo();
delete m_afdv;
}
}
bool ApplesoftFileViewer::makeMenuOptions(QMenu *menu)
@ -283,10 +288,14 @@ void ApplesoftFileViewer::setText(QString text)
void ApplesoftFileViewer::launchVarBrowser()
{
ApplesoftFileDetailViewer *afdv = new ApplesoftFileDetailViewer();
afdv->setLineData(m_file->getLines());
afdv->show();
if (!m_afdv)
{
m_afdv = new ApplesoftFileDetailViewer();
qDebug() << "m_afdv = " << m_afdv;
m_afdv->setLineData(m_file->getLines());
m_afdv->setWindowTitle(QString("Variables - %1").arg(m_file->filename()));
}
m_afdv->show();
}
void ApplesoftFileViewer::findText()

View File

@ -8,6 +8,8 @@
#include "applesoftfile.h"
#include "applesoftformatter.h"
#include "viewerbase.h"
#include "applesoftfiledetailviewer.h"
namespace Ui {
class ApplesoftFileViewer;
@ -27,8 +29,6 @@ public:
ApplesoftFileViewer(QWidget *parent = 0);
~ApplesoftFileViewer();
// void setFormatter(ApplesoftFormatter *formatter);
virtual bool optionsMenuItems(QMenu *menu);
virtual bool canPrint() const;
@ -61,7 +61,7 @@ private:
ApplesoftFormatter *m_formatter;
bool m_isFirstFind;
Ui::ApplesoftFileViewer *ui;
ApplesoftFileDetailViewer *m_afdv;
QAction *m_showIntsAction;
QAction *m_reindentCodeAction;
QAction *m_blankAfterReturnsAction;

View File

@ -21,16 +21,11 @@ ViewerBase::ViewerBase(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::ViewerBase)
{
setAttribute(Qt::WA_DeleteOnClose);
m_stack = new QStackedWidget(this);
ui->setupUi(this);
// QScrollArea *scroller = new QScrollArea(this);
// scroller->setWidgetResizable(true);
// setCentralWidget(scroller);
// scroller->setWidget(m_stack);
setCentralWidget(m_stack);
m_toolbar = new QToolBar(this);
@ -49,6 +44,7 @@ ViewerBase::ViewerBase(QWidget *parent) :
ViewerBase::~ViewerBase()
{
emit viewerClosing(this);
delete ui;
}

View File

@ -23,6 +23,9 @@ public:
void setFile(GenericFile *file);
signals:
void viewerClosing(ViewerBase *me);
public slots:
void showViewer(QString descriptor);