mirror of
https://github.com/markdavidlong/AppleSAWS.git
synced 2025-04-16 16:42:23 +00:00
Work on sequencer view, etc.
This commit is contained in:
parent
34b3310aa4
commit
6303dd1228
@ -29,6 +29,7 @@ INCLUDEPATH += src/ui
|
||||
INCLUDEPATH += src/memory
|
||||
INCLUDEPATH += src/memory/roles
|
||||
INCLUDEPATH += src/sequence
|
||||
INCLUDEPATH += src/ui/central
|
||||
|
||||
|
||||
|
||||
@ -52,8 +53,13 @@ SOURCES += \
|
||||
src/sequence/sequenceevent.cpp \
|
||||
src/sequence/sequenceeventlist.cpp \
|
||||
src/sequence/sequenceeventlistwidget.cpp \
|
||||
src/sequence/sequenceoutputview.cpp \
|
||||
src/sequence/sequencetool.cpp \
|
||||
src/sequence/sequencetoolbox.cpp \
|
||||
src/sequence/sequenceviewer.cpp \
|
||||
src/sequence/textblockuserdata.cpp \
|
||||
src/ui/central/centralappwindow.cpp \
|
||||
src/ui/central/mainapptoolbar.cpp \
|
||||
src/ui/startupdialog.cpp \
|
||||
src/ui/viewers/intbasicfileviewer.cxx \
|
||||
src/ui/widgets/notesdialog.cpp \
|
||||
@ -112,8 +118,13 @@ HEADERS += \
|
||||
src/sequence/sequenceevent.h \
|
||||
src/sequence/sequenceeventlist.h \
|
||||
src/sequence/sequenceeventlistwidget.h \
|
||||
src/sequence/sequenceoutputview.h \
|
||||
src/sequence/sequencetool.h \
|
||||
src/sequence/sequencetoolbox.h \
|
||||
src/sequence/sequenceviewer.h \
|
||||
src/sequence/textblockuserdata.h \
|
||||
src/ui/central/centralappwindow.h \
|
||||
src/ui/central/mainapptoolbar.h \
|
||||
src/ui/startupdialog.h \
|
||||
src/ui/viewers/intbasicfileviewer.h \
|
||||
src/ui/widgets/notesdialog.h \
|
||||
@ -162,6 +173,7 @@ HEADERS += \
|
||||
src/ui/widgets/asciiinfodialog.h
|
||||
|
||||
FORMS += \
|
||||
src/sequence/sequenceviewer.ui \
|
||||
src/ui/catalogwidget.ui \
|
||||
src/ui/startupdialog.ui \
|
||||
src/ui/viewers/applesoftfileviewer.ui \
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "role_asm_operand.h"
|
||||
|
||||
RoleAsmOperand::RoleAsmOperand()
|
||||
{
|
||||
|
||||
}
|
||||
#include "role_asm_operand.h"
|
||||
|
||||
RoleAsmOperand::RoleAsmOperand()
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -1,33 +1,33 @@
|
||||
#ifndef ROLEASMOPERAND_H
|
||||
#define ROLEASMOPERAND_H
|
||||
|
||||
#include <QString>
|
||||
#include "memrole.h"
|
||||
|
||||
class RoleAsmOperand : public MemRole
|
||||
{
|
||||
|
||||
public:
|
||||
static const int RoleID = 2;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
Byte,
|
||||
WordLo,
|
||||
WordHi,
|
||||
} Type;
|
||||
|
||||
RoleAsmOperand();
|
||||
|
||||
virtual int id() const override { return RoleID; }
|
||||
virtual QString name() const override { return "RoleAsmOperand"; }
|
||||
|
||||
void setOperandType(Type type) { m_optype = type; }
|
||||
Type operandType() const { return m_optype; }
|
||||
|
||||
protected:
|
||||
Type m_optype;
|
||||
|
||||
};
|
||||
|
||||
#endif // ROLEASMOPERAND_H
|
||||
#ifndef ROLEASMOPERAND_H
|
||||
#define ROLEASMOPERAND_H
|
||||
|
||||
#include <QString>
|
||||
#include "memrole.h"
|
||||
|
||||
class RoleAsmOperand : public MemRole
|
||||
{
|
||||
|
||||
public:
|
||||
static const int RoleID = 2;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
Byte,
|
||||
WordLo,
|
||||
WordHi,
|
||||
} Type;
|
||||
|
||||
RoleAsmOperand();
|
||||
|
||||
virtual int id() const override { return RoleID; }
|
||||
virtual QString name() const override { return "RoleAsmOperand"; }
|
||||
|
||||
void setOperandType(Type type) { m_optype = type; }
|
||||
Type operandType() const { return m_optype; }
|
||||
|
||||
protected:
|
||||
Type m_optype;
|
||||
|
||||
};
|
||||
|
||||
#endif // ROLEASMOPERAND_H
|
||||
|
BIN
src/resource/redblob.png
Normal file
BIN
src/resource/redblob.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
@ -7,4 +7,7 @@
|
||||
<qresource prefix="/notes">
|
||||
<file>notes.txt</file>
|
||||
</qresource>
|
||||
<qresource prefix="/images">
|
||||
<file>redblob.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "sequenceevent.h"
|
||||
|
||||
SequenceEvent::SequenceEvent()
|
||||
{
|
||||
|
||||
}
|
||||
#include "sequenceevent.h"
|
||||
|
||||
SequenceEvent::SequenceEvent()
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -1,16 +1,16 @@
|
||||
#ifndef SEQUENCEEVENT_H
|
||||
#define SEQUENCEEVENT_H
|
||||
|
||||
#include <QString>
|
||||
|
||||
class SequenceEvent
|
||||
{
|
||||
public:
|
||||
SequenceEvent();
|
||||
virtual ~SequenceEvent() { }
|
||||
|
||||
virtual QString basename() = 0;
|
||||
virtual QString extendedName() { return basename(); }
|
||||
};
|
||||
|
||||
#endif // SEQUENCEEVENT_H
|
||||
#ifndef SEQUENCEEVENT_H
|
||||
#define SEQUENCEEVENT_H
|
||||
|
||||
#include <QString>
|
||||
|
||||
class SequenceEvent
|
||||
{
|
||||
public:
|
||||
SequenceEvent();
|
||||
virtual ~SequenceEvent() { }
|
||||
|
||||
virtual QString basename() = 0;
|
||||
virtual QString extendedName() { return basename(); }
|
||||
};
|
||||
|
||||
#endif // SEQUENCEEVENT_H
|
||||
|
@ -1,11 +1,11 @@
|
||||
#include "sequenceeventlist.h"
|
||||
|
||||
SequenceEventList::SequenceEventList(QObject *parent) : QAbstractListModel(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
SequenceEventList::~SequenceEventList()
|
||||
{
|
||||
|
||||
}
|
||||
#include "sequenceeventlist.h"
|
||||
|
||||
SequenceEventList::SequenceEventList(QObject *parent) : QAbstractListModel(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
SequenceEventList::~SequenceEventList()
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -1,18 +1,18 @@
|
||||
#ifndef SEQUENCEEVENTLIST_H
|
||||
#define SEQUENCEEVENTLIST_H
|
||||
|
||||
#include "sequenceevent.h"
|
||||
|
||||
#include <QAbstractListModel>
|
||||
|
||||
class SequenceEventList : public QAbstractListModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SequenceEventList(QObject *parent = nullptr);
|
||||
virtual ~SequenceEventList();
|
||||
|
||||
};
|
||||
|
||||
#endif // SEQUENCEEVENTLIST_H
|
||||
#ifndef SEQUENCEEVENTLIST_H
|
||||
#define SEQUENCEEVENTLIST_H
|
||||
|
||||
#include "sequenceevent.h"
|
||||
|
||||
#include <QAbstractListModel>
|
||||
|
||||
class SequenceEventList : public QAbstractListModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SequenceEventList(QObject *parent = nullptr);
|
||||
virtual ~SequenceEventList();
|
||||
|
||||
};
|
||||
|
||||
#endif // SEQUENCEEVENTLIST_H
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "sequenceeventlistwidget.h"
|
||||
|
||||
SequenceEventListWidget::SequenceEventListWidget(QWidget *parent) : QListView(parent)
|
||||
{
|
||||
|
||||
}
|
||||
#include "sequenceeventlistwidget.h"
|
||||
|
||||
SequenceEventListWidget::SequenceEventListWidget(QWidget *parent) : QListView(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -1,16 +1,16 @@
|
||||
#ifndef SEQUENCEEVENTLISTWIDGET_H
|
||||
#define SEQUENCEEVENTLISTWIDGET_H
|
||||
|
||||
#include <QListView>
|
||||
|
||||
class SequenceEventListWidget : public QListView
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit SequenceEventListWidget(QWidget *parent = nullptr);
|
||||
|
||||
signals:
|
||||
|
||||
};
|
||||
|
||||
#endif // SEQUENCEEVENTLISTWIDGET_H
|
||||
#ifndef SEQUENCEEVENTLISTWIDGET_H
|
||||
#define SEQUENCEEVENTLISTWIDGET_H
|
||||
|
||||
#include <QListView>
|
||||
|
||||
class SequenceEventListWidget : public QListView
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit SequenceEventListWidget(QWidget *parent = nullptr);
|
||||
|
||||
signals:
|
||||
|
||||
};
|
||||
|
||||
#endif // SEQUENCEEVENTLISTWIDGET_H
|
||||
|
103
src/sequence/sequenceoutputview.cpp
Normal file
103
src/sequence/sequenceoutputview.cpp
Normal file
@ -0,0 +1,103 @@
|
||||
#include "sequenceoutputview.h"
|
||||
|
||||
#include <QRect>
|
||||
#include <QPainter>
|
||||
#include <QTextBlock>
|
||||
|
||||
SequenceOutputView::SequenceOutputView(QWidget *parent) : QPlainTextEdit(parent)
|
||||
{
|
||||
lineNumberArea = new SOVNumberPanel(this);
|
||||
m_curdoc = nullptr;
|
||||
setFont(QFont("Courier",12));
|
||||
connect(this, &SequenceOutputView::blockCountChanged, this, &SequenceOutputView::updateLineNumberAreaWidth);
|
||||
connect(this, &SequenceOutputView::updateRequest, this, &SequenceOutputView::updateLineNumberArea);
|
||||
connect(this, &SequenceOutputView::cursorPositionChanged, this, &SequenceOutputView::highlightCurrentLine);
|
||||
|
||||
updateLineNumberAreaWidth(0);
|
||||
highlightCurrentLine();
|
||||
|
||||
auto hl = new TestHighlighter(document());
|
||||
}
|
||||
|
||||
void SequenceOutputView::lineNumberAreaPaintEvent(QPaintEvent *event)
|
||||
{
|
||||
QPainter painter(lineNumberArea);
|
||||
painter.fillRect(event->rect(), Qt::lightGray);
|
||||
QTextBlock block = firstVisibleBlock();
|
||||
int blockNumber = block.blockNumber();
|
||||
int top = qRound(blockBoundingGeometry(block).translated(contentOffset()).top());
|
||||
int bottom = top + qRound(blockBoundingRect(block).height());
|
||||
while (block.isValid() && top <= event->rect().bottom()) {
|
||||
if (block.isVisible() && bottom >= event->rect().top()) {
|
||||
QString number = QString::number(blockNumber + 1);
|
||||
painter.setPen(Qt::black);
|
||||
painter.drawText(0, top, lineNumberArea->width()-10, fontMetrics().height(),
|
||||
Qt::AlignRight, number);
|
||||
}
|
||||
|
||||
block = block.next();
|
||||
top = bottom;
|
||||
bottom = top + qRound(blockBoundingRect(block).height());
|
||||
++blockNumber;
|
||||
}
|
||||
}
|
||||
|
||||
int SequenceOutputView::lineNumberAreaWidth() const
|
||||
{
|
||||
int digits = 1;
|
||||
int max = qMax(1, blockCount());
|
||||
while (max >= 10) {
|
||||
max /= 10;
|
||||
++digits;
|
||||
}
|
||||
|
||||
digits = qMax(digits,5); // Reserve at least 5 digits worth. More if needed.
|
||||
|
||||
int space = 13 + fontMetrics().horizontalAdvance(QLatin1Char('9')) * digits;
|
||||
|
||||
return space;
|
||||
}
|
||||
|
||||
void SequenceOutputView::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
QPlainTextEdit::resizeEvent(event);
|
||||
|
||||
QRect cr = contentsRect();
|
||||
lineNumberArea->setGeometry(QRect(cr.left(), cr.top(), lineNumberAreaWidth(), cr.height()));
|
||||
|
||||
}
|
||||
|
||||
|
||||
void SequenceOutputView::updateLineNumberAreaWidth(int /*newBlockCount*/)
|
||||
{
|
||||
setViewportMargins(lineNumberAreaWidth(), 0, 0, 0);
|
||||
}
|
||||
|
||||
void SequenceOutputView::highlightCurrentLine()
|
||||
{
|
||||
QList<QTextEdit::ExtraSelection> extraSelections;
|
||||
|
||||
if (!isReadOnly()) {
|
||||
QTextEdit::ExtraSelection selection;
|
||||
|
||||
QColor lineColor = QColor(0x303030);
|
||||
|
||||
selection.format.setBackground(lineColor);
|
||||
selection.format.setProperty(QTextFormat::FullWidthSelection, true);
|
||||
selection.cursor = textCursor();
|
||||
selection.cursor.clearSelection();
|
||||
extraSelections.append(selection);
|
||||
}
|
||||
|
||||
setExtraSelections(extraSelections);
|
||||
}
|
||||
|
||||
void SequenceOutputView::updateLineNumberArea(const QRect &rect, int dy)
|
||||
{
|
||||
if (dy)
|
||||
lineNumberArea->scroll(0, dy);
|
||||
else
|
||||
lineNumberArea->update(0, rect.y(), lineNumberArea->width(), rect.height());
|
||||
|
||||
if (rect.contains(viewport()->rect()))
|
||||
updateLineNumberAreaWidth(0);}
|
114
src/sequence/sequenceoutputview.h
Normal file
114
src/sequence/sequenceoutputview.h
Normal file
@ -0,0 +1,114 @@
|
||||
#ifndef SEQUENCEOUTPUTVIEW_H
|
||||
#define SEQUENCEOUTPUTVIEW_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QPlainTextEdit>
|
||||
#include <QSyntaxHighlighter>
|
||||
#include <QTextBlock>
|
||||
#include <QRegularExpression>
|
||||
|
||||
class SOVNumberPanel;
|
||||
|
||||
|
||||
class SequenceOutputView : public QPlainTextEdit
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit SequenceOutputView(QWidget *parent = nullptr);
|
||||
|
||||
void lineNumberAreaPaintEvent(QPaintEvent *event);
|
||||
int lineNumberAreaWidth() const;
|
||||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *event) override;
|
||||
|
||||
|
||||
private slots:
|
||||
void updateLineNumberAreaWidth(int newBlockCount);
|
||||
void highlightCurrentLine();
|
||||
void updateLineNumberArea(const QRect &rect, int dy);
|
||||
|
||||
private:
|
||||
SOVNumberPanel *lineNumberArea;
|
||||
QTextDocument *m_curdoc;
|
||||
};
|
||||
|
||||
|
||||
class SOVNumberPanel : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit SOVNumberPanel(SequenceOutputView *sov) : QWidget(sov), m_sov(sov) { }
|
||||
QSize sizeHint() const override { return QSize(m_sov->lineNumberAreaWidth(), 0); }
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *event) override {
|
||||
m_sov->lineNumberAreaPaintEvent(event);}
|
||||
SequenceOutputView *m_sov;
|
||||
};
|
||||
|
||||
|
||||
class TestHighlighter : public QSyntaxHighlighter
|
||||
{
|
||||
public:
|
||||
explicit TestHighlighter(QTextDocument *doc):QSyntaxHighlighter(doc) { }
|
||||
void highlightBlock(const QString &text) {
|
||||
for (int idx = 0; idx< text.length(); idx++)
|
||||
{
|
||||
QTextCharFormat format;
|
||||
// auto block = currentBlock();
|
||||
format.setForeground(QColor("green"));
|
||||
setFormat(0,5,format);
|
||||
QTextCharFormat format2;
|
||||
format2.setForeground(QColor("yellow"));
|
||||
setFormat(5,10,format2);
|
||||
QTextCharFormat format3;
|
||||
format3.setForeground(QColor("magenta"));
|
||||
setFormat(15,text.length()-15,format3);
|
||||
QRegularExpression re("'.'");
|
||||
auto match = re.match(text);
|
||||
if (match.hasMatch())
|
||||
{
|
||||
auto y = match.capturedStart();
|
||||
y++;
|
||||
|
||||
QRegularExpression re2("; *\\d+");
|
||||
auto m = re2.match(text);
|
||||
auto x = match.capturedStart();
|
||||
x++;
|
||||
|
||||
QTextCharFormat atformat;
|
||||
if (m.hasMatch())
|
||||
{
|
||||
auto txt = m.captured().right(m.capturedLength()-2);
|
||||
int num = txt.toInt();
|
||||
|
||||
// qDebug("Number: %s %d", qPrintable(txt), num);
|
||||
|
||||
if (num > 0x7f)
|
||||
{
|
||||
atformat.setForeground(QColor("white"));
|
||||
atformat.setBackground(QColor("black"));
|
||||
}
|
||||
else
|
||||
{
|
||||
atformat.setForeground(QColor("black"));
|
||||
atformat.setBackground(QColor("white"));
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
atformat.setForeground(QColor("white"));
|
||||
atformat.setForeground(QColor("black"));
|
||||
}
|
||||
|
||||
atformat.setFontFamily("Print Char 21");
|
||||
setFormat(y,1,atformat);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#endif // SEQUENCEOUTPUTVIEW_H
|
@ -1,23 +1,23 @@
|
||||
#include "sequencetool.h"
|
||||
|
||||
SequenceTool::SequenceTool(SequenceEvent *event, QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
setSequenceEvent(event);
|
||||
}
|
||||
|
||||
SequenceTool::~SequenceTool()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void SequenceTool::setSequenceEvent(SequenceEvent *event)
|
||||
{
|
||||
m_seqevent = event;
|
||||
|
||||
|
||||
}
|
||||
|
||||
void SequenceTool::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
|
||||
}
|
||||
#include "sequencetool.h"
|
||||
|
||||
SequenceTool::SequenceTool(SequenceEvent *event, QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
setSequenceEvent(event);
|
||||
}
|
||||
|
||||
SequenceTool::~SequenceTool()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void SequenceTool::setSequenceEvent(SequenceEvent *event)
|
||||
{
|
||||
m_seqevent = event;
|
||||
|
||||
|
||||
}
|
||||
|
||||
void SequenceTool::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -1,33 +1,30 @@
|
||||
#ifndef SEQUENCETOOL_H
|
||||
#define SEQUENCETOOL_H
|
||||
|
||||
#include "sequenceevent.h"
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class SequenceTool : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit SequenceTool(SequenceEvent *event = nullptr, QWidget *parent = nullptr);
|
||||
virtual ~SequenceTool();
|
||||
|
||||
virtual void setSequenceEvent(SequenceEvent *event);
|
||||
|
||||
virtual void setCategory(QString category) { m_category = category; }
|
||||
virtual QString category() const { return m_category; }
|
||||
|
||||
|
||||
signals:
|
||||
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent *event);
|
||||
|
||||
protected:
|
||||
SequenceEvent *m_seqevent;
|
||||
QString m_category;
|
||||
|
||||
};
|
||||
|
||||
#endif // SEQUENCETOOL_H
|
||||
#ifndef SEQUENCETOOL_H
|
||||
#define SEQUENCETOOL_H
|
||||
|
||||
#include "sequenceevent.h"
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class SequenceTool : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit SequenceTool(SequenceEvent *event = nullptr, QWidget *parent = nullptr);
|
||||
virtual ~SequenceTool();
|
||||
|
||||
virtual void setSequenceEvent(SequenceEvent *event);
|
||||
|
||||
virtual void setCategory(QString category) { m_category = category; }
|
||||
virtual QString category() const { return m_category; }
|
||||
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent *event);
|
||||
|
||||
protected:
|
||||
SequenceEvent *m_seqevent;
|
||||
QString m_category;
|
||||
|
||||
};
|
||||
|
||||
#endif // SEQUENCETOOL_H
|
||||
|
@ -1,84 +1,84 @@
|
||||
#include "sequencetoolbox.h"
|
||||
|
||||
SequenceToolBox::SequenceToolBox(QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
m_layout = new QVBoxLayout(this);
|
||||
}
|
||||
|
||||
void SequenceToolBox::addTool(SequenceTool *tool)
|
||||
{
|
||||
QString catname = tool->category();
|
||||
if (!m_category.contains(catname))
|
||||
{
|
||||
QList<SequenceTool *> list;
|
||||
list.append(tool);
|
||||
m_categories.append(catname);
|
||||
m_category.insert(catname, list);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_category[catname].append(tool);
|
||||
}
|
||||
|
||||
int count = m_layout->count();
|
||||
for (int idx = 0; idx < count; idx++)
|
||||
{
|
||||
auto item = m_layout->itemAt(0);
|
||||
m_layout->removeItem(item);
|
||||
}
|
||||
|
||||
foreach (QString cat, m_categories)
|
||||
{
|
||||
m_layout->addWidget(getHeader(cat));
|
||||
auto catitems = m_category[cat];
|
||||
bool headerchecked = m_headers[cat]->isChecked();
|
||||
foreach (auto item, catitems)
|
||||
{
|
||||
m_layout->addWidget(item);
|
||||
item->setVisible(headerchecked);
|
||||
};
|
||||
}
|
||||
m_layout->addStretch();
|
||||
}
|
||||
|
||||
void SequenceToolBox::updateItems()
|
||||
{
|
||||
foreach (auto item, m_layout->children())
|
||||
{
|
||||
auto widget = qobject_cast<SequenceTool *>(item);
|
||||
if (widget)
|
||||
{
|
||||
widget->setVisible(m_headers[widget->category()]->isChecked());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QList<SequenceTool *> SequenceToolBox::toolsInCategory(QString category)
|
||||
{
|
||||
if (m_category.contains(category))
|
||||
{
|
||||
return m_category[category];
|
||||
}
|
||||
else
|
||||
{
|
||||
return QList<SequenceTool *>();
|
||||
}
|
||||
}
|
||||
|
||||
SequenceToolBoxHeader *SequenceToolBox::getHeader(const QString &text)
|
||||
{
|
||||
SequenceToolBoxHeader *header;
|
||||
|
||||
if (m_headers.contains(text))
|
||||
{
|
||||
header = m_headers[text];
|
||||
}
|
||||
else
|
||||
{
|
||||
header = new SequenceToolBoxHeader(text);
|
||||
m_headers.insert(text,header);
|
||||
connect(header,SIGNAL(toggled(bool)),
|
||||
this, SLOT(updateItems()));
|
||||
}
|
||||
return header;
|
||||
}
|
||||
#include "sequencetoolbox.h"
|
||||
|
||||
SequenceToolBox::SequenceToolBox(QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
m_layout = new QVBoxLayout(this);
|
||||
}
|
||||
|
||||
void SequenceToolBox::addTool(SequenceTool *tool)
|
||||
{
|
||||
QString catname = tool->category();
|
||||
if (!m_category.contains(catname))
|
||||
{
|
||||
QList<SequenceTool *> list;
|
||||
list.append(tool);
|
||||
m_categories.append(catname);
|
||||
m_category.insert(catname, list);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_category[catname].append(tool);
|
||||
}
|
||||
|
||||
int count = m_layout->count();
|
||||
for (int idx = 0; idx < count; idx++)
|
||||
{
|
||||
auto item = m_layout->itemAt(0);
|
||||
m_layout->removeItem(item);
|
||||
}
|
||||
|
||||
foreach (QString cat, m_categories)
|
||||
{
|
||||
m_layout->addWidget(getHeader(cat));
|
||||
auto catitems = m_category[cat];
|
||||
bool headerchecked = m_headers[cat]->isChecked();
|
||||
foreach (auto item, catitems)
|
||||
{
|
||||
m_layout->addWidget(item);
|
||||
item->setVisible(headerchecked);
|
||||
};
|
||||
}
|
||||
m_layout->addStretch();
|
||||
}
|
||||
|
||||
void SequenceToolBox::updateItems()
|
||||
{
|
||||
foreach (auto item, m_layout->children())
|
||||
{
|
||||
auto widget = qobject_cast<SequenceTool *>(item);
|
||||
if (widget)
|
||||
{
|
||||
widget->setVisible(m_headers[widget->category()]->isChecked());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QList<SequenceTool *> SequenceToolBox::toolsInCategory(QString category)
|
||||
{
|
||||
if (m_category.contains(category))
|
||||
{
|
||||
return m_category[category];
|
||||
}
|
||||
else
|
||||
{
|
||||
return QList<SequenceTool *>();
|
||||
}
|
||||
}
|
||||
|
||||
SequenceToolBoxHeader *SequenceToolBox::getHeader(const QString &text)
|
||||
{
|
||||
SequenceToolBoxHeader *header;
|
||||
|
||||
if (m_headers.contains(text))
|
||||
{
|
||||
header = m_headers[text];
|
||||
}
|
||||
else
|
||||
{
|
||||
header = new SequenceToolBoxHeader(text);
|
||||
m_headers.insert(text,header);
|
||||
connect(header,SIGNAL(toggled(bool)),
|
||||
this, SLOT(updateItems()));
|
||||
}
|
||||
return header;
|
||||
}
|
||||
|
@ -1,47 +1,48 @@
|
||||
#ifndef SEQUENCETOOLBOX_H
|
||||
#define SEQUENCETOOLBOX_H
|
||||
|
||||
#include "sequencetool.h"
|
||||
|
||||
#include <QWidget>
|
||||
#include <QVBoxLayout>
|
||||
#include <QPushButton>
|
||||
#include <QMap>
|
||||
#include <QList>
|
||||
#include <QCheckBox>
|
||||
|
||||
class SequenceToolBoxHeader : public QCheckBox
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
SequenceToolBoxHeader(const QString &text,
|
||||
QWidget *parent = 0) : QCheckBox(text,parent)
|
||||
{
|
||||
setCheckable(true);
|
||||
setChecked(true);
|
||||
}
|
||||
};
|
||||
|
||||
class SequenceToolBox : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SequenceToolBox(QWidget *parent = nullptr);
|
||||
void addTool(SequenceTool *tool);
|
||||
|
||||
public slots:
|
||||
void updateItems();
|
||||
|
||||
protected:
|
||||
QList<SequenceTool *> toolsInCategory(QString category);
|
||||
SequenceToolBoxHeader *getHeader(const QString &text);
|
||||
|
||||
protected:
|
||||
QVBoxLayout *m_layout;
|
||||
QStringList m_categories;
|
||||
QMap<QString, QList<SequenceTool *> > m_category;
|
||||
QMap<QString, SequenceToolBoxHeader *> m_headers;
|
||||
};
|
||||
|
||||
#endif // SEQUENCETOOLBOX_H
|
||||
#ifndef SEQUENCETOOLBOX_H
|
||||
#define SEQUENCETOOLBOX_H
|
||||
|
||||
#include "sequencetool.h"
|
||||
|
||||
#include <QWidget>
|
||||
#include <QVBoxLayout>
|
||||
#include <QPushButton>
|
||||
#include <QMap>
|
||||
#include <QList>
|
||||
#include <QCheckBox>
|
||||
|
||||
class SequenceToolBoxHeader : public QCheckBox
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SequenceToolBoxHeader(const QString &text,
|
||||
QWidget *parent = 0) : QCheckBox(text,parent)
|
||||
{
|
||||
setCheckable(true);
|
||||
setChecked(true);
|
||||
}
|
||||
};
|
||||
|
||||
class SequenceToolBox : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SequenceToolBox(QWidget *parent = nullptr);
|
||||
void addTool(SequenceTool *tool);
|
||||
|
||||
public slots:
|
||||
void updateItems();
|
||||
|
||||
protected:
|
||||
QList<SequenceTool *> toolsInCategory(QString category);
|
||||
SequenceToolBoxHeader *getHeader(const QString &text);
|
||||
|
||||
protected:
|
||||
QVBoxLayout *m_layout;
|
||||
QStringList m_categories;
|
||||
QMap<QString, QList<SequenceTool *> > m_category;
|
||||
QMap<QString, SequenceToolBoxHeader *> m_headers;
|
||||
};
|
||||
|
||||
#endif // SEQUENCETOOLBOX_H
|
||||
|
15
src/sequence/sequenceviewer.cpp
Normal file
15
src/sequence/sequenceviewer.cpp
Normal file
@ -0,0 +1,15 @@
|
||||
#include "sequenceviewer.h"
|
||||
#include "ui_sequenceviewer.h"
|
||||
|
||||
SequenceViewer::SequenceViewer(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::SequenceViewer)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
}
|
||||
|
||||
SequenceViewer::~SequenceViewer()
|
||||
{
|
||||
delete ui;
|
||||
}
|
22
src/sequence/sequenceviewer.h
Normal file
22
src/sequence/sequenceviewer.h
Normal file
@ -0,0 +1,22 @@
|
||||
#ifndef SEQUENCEVIEWER_H
|
||||
#define SEQUENCEVIEWER_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
namespace Ui {
|
||||
class SequenceViewer;
|
||||
}
|
||||
|
||||
class SequenceViewer : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SequenceViewer(QWidget *parent = nullptr);
|
||||
~SequenceViewer();
|
||||
|
||||
private:
|
||||
Ui::SequenceViewer *ui;
|
||||
};
|
||||
|
||||
#endif // SEQUENCEVIEWER_H
|
92
src/sequence/sequenceviewer.ui
Normal file
92
src/sequence/sequenceviewer.ui
Normal file
@ -0,0 +1,92 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>SequenceViewer</class>
|
||||
<widget class="QWidget" name="SequenceViewer">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>747</width>
|
||||
<height>452</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QSplitter" name="splitter_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<widget class="SequenceOutputView" name="viewer" native="true">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">background:black</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QSplitter" name="splitter">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>100</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<widget class="SequenceEventListWidget" name="steps" native="true">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>50</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">background:lightgrey </string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QWidget" name="properties" native="true">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>50</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">background:lightgray</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>SequenceOutputView</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>sequenceoutputview.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>SequenceEventListWidget</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>sequenceeventlistwidget.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
7
src/sequence/textblockuserdata.cpp
Normal file
7
src/sequence/textblockuserdata.cpp
Normal file
@ -0,0 +1,7 @@
|
||||
#include "textblockuserdata.h"
|
||||
|
||||
TextBlockUserData::TextBlockUserData()
|
||||
{
|
||||
|
||||
}
|
||||
|
16
src/sequence/textblockuserdata.h
Normal file
16
src/sequence/textblockuserdata.h
Normal file
@ -0,0 +1,16 @@
|
||||
#ifndef TEXTBLOCKUSERDATA_H
|
||||
#define TEXTBLOCKUSERDATA_H
|
||||
|
||||
#include <QTextBlockUserData>
|
||||
#include <QSyntaxHighlighter>
|
||||
|
||||
class TextBlockUserData : public QTextBlockUserData
|
||||
{
|
||||
public:
|
||||
TextBlockUserData();
|
||||
virtual ~TextBlockUserData() { }
|
||||
|
||||
virtual void applySyntaxHighlighting(QSyntaxHighlighter &highlighter) = 0;
|
||||
};
|
||||
|
||||
#endif // TEXTBLOCKUSERDATA_H
|
74
src/ui/central/centralappwindow.cpp
Normal file
74
src/ui/central/centralappwindow.cpp
Normal file
@ -0,0 +1,74 @@
|
||||
#include "centralappwindow.h"
|
||||
#include "sequenceviewer.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QMenuBar>
|
||||
#include <QMenu>
|
||||
#include <QApplication>
|
||||
#include <QSplitter>
|
||||
#include <QDockWidget>
|
||||
#include <QGridLayout>
|
||||
|
||||
CentralAppWindow::CentralAppWindow(QWidget *parent) : QMainWindow(parent)
|
||||
{
|
||||
createActions();
|
||||
initMenuBar();
|
||||
initToolBars();
|
||||
initDockWidgets();
|
||||
initStatusBar();
|
||||
|
||||
setCentralWidget(new SequenceViewer());
|
||||
}
|
||||
|
||||
void CentralAppWindow::createActions()
|
||||
{
|
||||
m_quitAction = new QAction(QIcon(":/images/redblob.png"),tr("E&xit"));
|
||||
connect(m_quitAction, &QAction::triggered,
|
||||
qApp, &QApplication::quit);
|
||||
}
|
||||
|
||||
void CentralAppWindow::initMenuBar()
|
||||
{
|
||||
auto filemenu = menuBar()->addMenu(tr("&File"));
|
||||
filemenu->addAction(m_quitAction);
|
||||
|
||||
}
|
||||
|
||||
void CentralAppWindow::initStatusBar()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CentralAppWindow::initToolBars()
|
||||
{
|
||||
m_mainToolBar = new MainAppToolbar(this);
|
||||
m_mainToolBar->setIconSize(QSize(64,64));
|
||||
m_mainToolBar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
|
||||
m_mainToolBar->addAction(m_quitAction);
|
||||
m_mainToolBar->setFont(QFont("Ariel",14));
|
||||
addToolBar(Qt::LeftToolBarArea, m_mainToolBar);
|
||||
|
||||
}
|
||||
|
||||
void CentralAppWindow::initDockWidgets()
|
||||
{
|
||||
QDockWidget *container = new QDockWidget(this);
|
||||
container->setLayout(new QGridLayout());
|
||||
container->setMinimumWidth(200);
|
||||
container->setFeatures(QDockWidget::DockWidgetMovable);
|
||||
m_project_area = new QWidget(container);
|
||||
m_project_area->setMinimumSize(200,200);
|
||||
m_project_area->setStyleSheet("background:black");
|
||||
m_directory_area = new QWidget(container);
|
||||
m_directory_area->setMinimumSize(200,200);
|
||||
m_directory_area->setStyleSheet("background:black");
|
||||
QSplitter *split = new QSplitter(container);
|
||||
split->setOrientation(Qt::Vertical);
|
||||
split->addWidget(m_directory_area);
|
||||
split->addWidget(m_project_area);
|
||||
container->setWidget(split);
|
||||
|
||||
addDockWidget(Qt::LeftDockWidgetArea,container);
|
||||
|
||||
|
||||
}
|
32
src/ui/central/centralappwindow.h
Normal file
32
src/ui/central/centralappwindow.h
Normal file
@ -0,0 +1,32 @@
|
||||
#ifndef CENTRALAPPWINDOW_H
|
||||
#define CENTRALAPPWINDOW_H
|
||||
|
||||
#include <QMainWindow>
|
||||
|
||||
#include "mainapptoolbar.h"
|
||||
|
||||
class QAction;
|
||||
|
||||
class CentralAppWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CentralAppWindow(QWidget *parent = nullptr);
|
||||
|
||||
private:
|
||||
void createActions();
|
||||
void initMenuBar();
|
||||
void initStatusBar();
|
||||
void initToolBars();
|
||||
void initDockWidgets();
|
||||
|
||||
private:
|
||||
QAction *m_quitAction;
|
||||
|
||||
MainAppToolbar *m_mainToolBar;
|
||||
QWidget *m_directory_area;
|
||||
QWidget *m_project_area;
|
||||
|
||||
};
|
||||
|
||||
#endif // CENTRALAPPWINDOW_H
|
8
src/ui/central/mainapptoolbar.cpp
Normal file
8
src/ui/central/mainapptoolbar.cpp
Normal file
@ -0,0 +1,8 @@
|
||||
#include "mainapptoolbar.h"
|
||||
|
||||
MainAppToolbar::MainAppToolbar(QWidget *parent) : QToolBar(parent)
|
||||
{
|
||||
setStyleSheet("background: #4f4f4f; color: #ffffff; font-size: 12pt");
|
||||
setMovable(false);
|
||||
setFloatable(false);
|
||||
}
|
13
src/ui/central/mainapptoolbar.h
Normal file
13
src/ui/central/mainapptoolbar.h
Normal file
@ -0,0 +1,13 @@
|
||||
#ifndef MAINAPPTOOLBAR_H
|
||||
#define MAINAPPTOOLBAR_H
|
||||
|
||||
#include <QToolBar>
|
||||
|
||||
class MainAppToolbar : public QToolBar
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MainAppToolbar(QWidget *parent = nullptr);
|
||||
};
|
||||
|
||||
#endif // MAINAPPTOOLBAR_H
|
@ -4,6 +4,7 @@
|
||||
#include "diskexplorer/DiskExplorer.h"
|
||||
|
||||
#include <QFileDialog>
|
||||
#include "centralappwindow.h"
|
||||
|
||||
StartupDialog::StartupDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
@ -22,9 +23,13 @@ void StartupDialog::on_exploreContentsBtn_clicked()
|
||||
{
|
||||
DiskExplorer *w = new DiskExplorer(this);
|
||||
w->showLoadDialog(false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void StartupDialog::on_newStuffButton_clicked()
|
||||
{
|
||||
CentralAppWindow *w = new CentralAppWindow(this);
|
||||
w->showMaximized();
|
||||
}
|
||||
|
||||
void StartupDialog::on_exploreDiskImageBtn_clicked()
|
||||
|
@ -29,6 +29,8 @@ private slots:
|
||||
|
||||
void on_infoBtn_clicked();
|
||||
|
||||
void on_newStuffButton_clicked();
|
||||
|
||||
private:
|
||||
Ui::StartupDialog *ui;
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>312</width>
|
||||
<height>197</height>
|
||||
<height>231</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -29,6 +29,13 @@
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="newStuffButton">
|
||||
<property name="text">
|
||||
<string>New Display Stuff</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="exploreContentsBtn">
|
||||
<property name="text">
|
||||
@ -100,7 +107,7 @@
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>V. 0.0.3pr</string>
|
||||
<string>V. 0.2.0pr</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
Loading…
x
Reference in New Issue
Block a user