Made everything in SkDebuggerGUI live on the stack

Review URL: https://codereview.appspot.com/6389043

git-svn-id: http://skia.googlecode.com/svn/trunk@4502 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
chudy@google.com 2012-07-10 13:19:25 +00:00
parent 7fe6409ecb
commit c432f00a84
3 changed files with 296 additions and 360 deletions

View File

@ -10,43 +10,70 @@
#include <QListWidgetItem>
SkDebuggerGUI::SkDebuggerGUI(QWidget *parent) :
QMainWindow(parent) {
QMainWindow(parent)
, fActionOpen(this)
, fActionBreakpoint(this)
, fActionCancel(this)
, fActionClose(this)
, fActionDelete(this)
, fActionDirectory(this)
, fActionGoToLine(this)
, fActionInspector(this)
, fActionPlay(this)
, fActionReload(this)
, fActionRewind(this)
, fActionSettings(this)
, fActionStepBack(this)
, fActionStepForward(this)
, fCentralWidget(this)
, fFilter(&fCentralWidget)
, fContainerLayout(&fCentralWidget)
, fListWidget(&fCentralWidget)
, fDirectoryWidget(&fCentralWidget)
, fCanvasWidget(&fCentralWidget)
, fSettingsWidget(&fCentralWidget)
, fStatusBar(this)
, fMenuBar(this)
, fMenuFile(this)
, fMenuNavigate(this)
, fMenuView(this)
, fToolBar(this)
{
setupUi(this);
connect(fListWidget, SIGNAL(currentItemChanged(QListWidgetItem*,
connect(&fListWidget, SIGNAL(currentItemChanged(QListWidgetItem*,
QListWidgetItem*)), this,
SLOT(registerListClick(QListWidgetItem *)));
connect(fActionOpen, SIGNAL(triggered()), this, SLOT(openFile()));
connect(fActionDirectory, SIGNAL(triggered()), this,
connect(&fActionOpen, SIGNAL(triggered()), this, SLOT(openFile()));
connect(&fActionDirectory, SIGNAL(triggered()), this,
SLOT(toggleDirectory()));
connect(fDirectoryWidget, SIGNAL(currentItemChanged(QListWidgetItem*,
connect(&fDirectoryWidget, SIGNAL(currentItemChanged(QListWidgetItem*,
QListWidgetItem*)), this,
SLOT(loadFile(QListWidgetItem *)));
connect(fActionDelete, SIGNAL(triggered()), this, SLOT(actionDelete()));
connect(fActionReload, SIGNAL(triggered()), this, SLOT(actionReload()));
connect(fListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this,
connect(&fActionDelete, SIGNAL(triggered()), this, SLOT(actionDelete()));
connect(&fActionReload, SIGNAL(triggered()), this, SLOT(actionReload()));
connect(&fListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this,
SLOT(toggleBreakpoint()));
connect(fActionRewind, SIGNAL(triggered()), this, SLOT(actionRewind()));
connect(fActionPlay, SIGNAL(triggered()), this, SLOT(actionPlay()));
connect(fActionStepBack, SIGNAL(triggered()), this, SLOT(actionStepBack()));
connect(fActionStepForward, SIGNAL(triggered()), this,
connect(&fActionRewind, SIGNAL(triggered()), this, SLOT(actionRewind()));
connect(&fActionPlay, SIGNAL(triggered()), this, SLOT(actionPlay()));
connect(&fActionStepBack, SIGNAL(triggered()), this, SLOT(actionStepBack()));
connect(&fActionStepForward, SIGNAL(triggered()), this,
SLOT(actionStepForward()));
connect(fActionBreakpoint, SIGNAL(triggered()), this,
connect(&fActionBreakpoint, SIGNAL(triggered()), this,
SLOT(actionBreakpoints()));
connect(fActionInspector, SIGNAL(triggered()), this,
connect(&fActionInspector, SIGNAL(triggered()), this,
SLOT(actionInspector()));
connect(fFilter, SIGNAL(activated(QString)), this,
connect(&fFilter, SIGNAL(activated(QString)), this,
SLOT(toggleFilter(QString)));
connect(fActionCancel, SIGNAL(triggered()), this, SLOT(actionCancel()));
connect(fActionClose, SIGNAL(triggered()), this, SLOT(actionClose()));
connect(fActionSettings, SIGNAL(triggered()), this, SLOT(actionSettings()));
connect(fSettingsWidget->getVisibilityButton(), SIGNAL(toggled(bool)), this,
connect(&fActionCancel, SIGNAL(triggered()), this, SLOT(actionCancel()));
connect(&fActionClose, SIGNAL(triggered()), this, SLOT(actionClose()));
connect(&fActionSettings, SIGNAL(triggered()), this, SLOT(actionSettings()));
connect(fSettingsWidget.getVisibilityButton(), SIGNAL(toggled(bool)), this,
SLOT(actionCommandFilter()));
connect(fCanvasWidget, SIGNAL(scaleFactorChanged(float)), this,
connect(&fCanvasWidget, SIGNAL(scaleFactorChanged(float)), this,
SLOT(actionScale(float)));
connect(fSettingsWidget->getCommandCheckBox(), SIGNAL(stateChanged(int)),
connect(fSettingsWidget.getCommandCheckBox(), SIGNAL(stateChanged(int)),
this, SLOT(pauseDrawing(int)));
connect(fCanvasWidget, SIGNAL(commandChanged(int)), fSettingsWidget,
connect(&fCanvasWidget, SIGNAL(commandChanged(int)), &fSettingsWidget,
SLOT(updateCommand(int)));
}
@ -60,8 +87,8 @@ void SkDebuggerGUI::actionBreakpoints() {
fBreakpointsActivated = false;
}
for (int row = 0; row < fListWidget->count(); row++) {
QListWidgetItem *item = fListWidget->item(row);
for (int row = 0; row < fListWidget.count(); row++) {
QListWidgetItem *item = fListWidget.item(row);
if (item->checkState() == Qt::Unchecked && fBreakpointsActivated) {
item->setHidden(true);
@ -72,14 +99,15 @@ void SkDebuggerGUI::actionBreakpoints() {
}
void SkDebuggerGUI::actionCancel() {
for (int row = 0; row < fListWidget->count(); row++) {
fListWidget->item(row)->setHidden(false);
for (int row = 0; row < fListWidget.count(); row++) {
fListWidget.item(row)->setHidden(false);
}
}
void SkDebuggerGUI::actionCommandFilter() {
fCanvasWidget->toggleCurrentCommandFilter(fSettingsWidget->getVisibilityButton()->isChecked());
fCanvasWidget->drawTo(fListWidget->currentRow());
fCanvasWidget.toggleCurrentCommandFilter(
fSettingsWidget.getVisibilityButton()->isChecked());
fCanvasWidget.drawTo(fListWidget.currentRow());
}
void SkDebuggerGUI::actionClose() {
@ -87,7 +115,7 @@ void SkDebuggerGUI::actionClose() {
}
void SkDebuggerGUI::actionDelete() {
QListWidgetItem* item = fListWidget->currentItem();
QListWidgetItem* item = fListWidget.currentItem();
if (item->data(Qt::UserRole + 2) == true) {
item->setData(Qt::UserRole + 2, false);
item->setData(Qt::DecorationRole, QPixmap(":/images/Icons/delete.png"));
@ -101,75 +129,73 @@ void SkDebuggerGUI::actionDelete() {
QPixmap(":/images/Icons/breakpoint_16x16.png"));
}
}
int currentRow = fListWidget->currentRow();
int currentRow = fListWidget.currentRow();
// NOTE(chudy): Forces a redraw up to current selected command.
if (fCanvasWidget) {
fCanvasWidget->toggleCommand(currentRow);
fCanvasWidget->drawTo(currentRow);
}
fCanvasWidget.toggleCommand(currentRow);
fCanvasWidget.drawTo(currentRow);
}
void SkDebuggerGUI::actionInspector() {
if (fInspectorWidget->isHidden()) {
fInspectorWidget->setHidden(false);
if (fInspectorWidget.isHidden()) {
fInspectorWidget.setHidden(false);
} else {
fInspectorWidget->setHidden(true);
fInspectorWidget.setHidden(true);
}
}
void SkDebuggerGUI::actionPlay() {
for (int row = fListWidget->currentRow() + 1; row < fListWidget->count();
for (int row = fListWidget.currentRow() + 1; row < fListWidget.count();
row++) {
QListWidgetItem *item = fListWidget->item(row);
QListWidgetItem *item = fListWidget.item(row);
if (item->checkState() == Qt::Checked) {
fListWidget->setCurrentItem(item);
fListWidget.setCurrentItem(item);
return;
}
}
fListWidget->setCurrentRow(fListWidget->count() - 1);
fListWidget.setCurrentRow(fListWidget.count() - 1);
}
void SkDebuggerGUI::actionReload() {
for (int row = 0; row < fListWidget->count(); row++) {
QListWidgetItem* item = fListWidget->item(row);
for (int row = 0; row < fListWidget.count(); row++) {
QListWidgetItem* item = fListWidget.item(row);
item->setData(Qt::UserRole + 2, true);
item->setData(Qt::DecorationRole, QPixmap(":/images/Icons/blank.png"));
fCanvasWidget->toggleCommand(row, true);
fCanvasWidget.toggleCommand(row, true);
}
fCanvasWidget->drawTo(fListWidget->currentRow());
fCanvasWidget.drawTo(fListWidget.currentRow());
}
void SkDebuggerGUI::actionRewind() {
/* NOTE(chudy): Hack. All skps opened so far start with save and concat
* commands that don't clear or reset the canvas. */
fListWidget->setCurrentRow(2);
fListWidget.setCurrentRow(2);
}
void SkDebuggerGUI::actionScale(float scaleFactor) {
fSettingsWidget->setZoomText(scaleFactor);
fSettingsWidget.setZoomText(scaleFactor);
}
void SkDebuggerGUI::actionSettings() {
if (fSettingsWidget->isHidden()) {
fSettingsWidget->setHidden(false);
if (fSettingsWidget.isHidden()) {
fSettingsWidget.setHidden(false);
} else {
fSettingsWidget->setHidden(true);
fSettingsWidget.setHidden(true);
}
}
void SkDebuggerGUI::actionStepBack() {
int currentRow = fListWidget->currentRow();
int currentRow = fListWidget.currentRow();
if (currentRow != 0) {
fListWidget->setCurrentRow(currentRow - 1);
fListWidget.setCurrentRow(currentRow - 1);
}
}
void SkDebuggerGUI::actionStepForward() {
int currentRow = fListWidget->currentRow();
int currentRow = fListWidget.currentRow();
QString curRow = QString::number(currentRow);
QString curCount = QString::number(fListWidget->count());
if (currentRow < fListWidget->count() - 1) {
fListWidget->setCurrentRow(currentRow + 1);
QString curCount = QString::number(fListWidget.count());
if (currentRow < fListWidget.count() - 1) {
fListWidget.setCurrentRow(currentRow + 1);
}
}
@ -196,22 +222,22 @@ void SkDebuggerGUI::openFile() {
fDirectoryWidgetActive = true;
}
void SkDebuggerGUI::pauseDrawing(int state) {
void SkDebuggerGUI::pauseDrawing(bool isPaused) {
// Qt uses 0 for unchecked, 1 for partially enabled and 2 for checked.
if (state == 2) {
if (isPaused) {
fPause = true;
} else {
fPause = false;
fCanvasWidget->drawTo(fListWidget->currentRow());
fCanvasWidget.drawTo(fListWidget.currentRow());
}
}
void SkDebuggerGUI::registerListClick(QListWidgetItem *item) {
int currentRow = fListWidget->currentRow();
int currentRow = fListWidget.currentRow();
if (!fPause) {
fCanvasWidget->drawTo(currentRow);
fCanvasWidget.drawTo(currentRow);
}
std::vector<std::string> *v = fCanvasWidget->getCurrentCommandInfo(
std::vector<std::string> *v = fCanvasWidget.getCurrentCommandInfo(
currentRow);
/* TODO(chudy): Add command type before parameters. Rename v
@ -225,15 +251,15 @@ void SkDebuggerGUI::registerListClick(QListWidgetItem *item) {
info.append(QString((*it).c_str()));
info.append("<br/>");
}
fInspectorWidget->setDetailText(info);
fInspectorWidget->setDisabled(false);
fInspectorWidget->setMatrix(fCanvasWidget->getCurrentMatrix());
fInspectorWidget->setClip(fCanvasWidget->getCurrentClip());
fInspectorWidget.setDetailText(info);
fInspectorWidget.setDisabled(false);
fInspectorWidget.setMatrix(fCanvasWidget.getCurrentMatrix());
fInspectorWidget.setClip(fCanvasWidget.getCurrentClip());
}
}
void SkDebuggerGUI::toggleBreakpoint() {
QListWidgetItem* item = fListWidget->currentItem();
QListWidgetItem* item = fListWidget.currentItem();
if (item->checkState() == Qt::Unchecked) {
item->setCheckState(Qt::Checked);
@ -265,16 +291,16 @@ void SkDebuggerGUI::toggleBreakpoint() {
}
void SkDebuggerGUI::toggleDirectory() {
if (fDirectoryWidget->isHidden()) {
fDirectoryWidget->setHidden(false);
if (fDirectoryWidget.isHidden()) {
fDirectoryWidget.setHidden(false);
} else {
fDirectoryWidget->setHidden(true);
fDirectoryWidget.setHidden(true);
}
}
void SkDebuggerGUI::toggleFilter(QString string) {
for (int row = 0; row < fListWidget->count(); row++) {
QListWidgetItem *item = fListWidget->item(row);
for (int row = 0; row < fListWidget.count(); row++) {
QListWidgetItem *item = fListWidget.item(row);
if (item->text() == string) {
item->setHidden(false);
} else {
@ -290,195 +316,144 @@ void SkDebuggerGUI::setupUi(QMainWindow *SkDebuggerGUI) {
SkDebuggerGUI->setObjectName(QString::fromUtf8("SkDebuggerGUI"));
SkDebuggerGUI->resize(1200, 1000);
SkDebuggerGUI->setWindowIcon(windowIcon);
SkDebuggerGUI->setWindowTitle("Skia Debugger");
QIcon open;
open.addFile(QString::fromUtf8(":/images/Icons/package-br32.png"), QSize(),
QIcon::Normal, QIcon::Off);
fActionOpen = new QAction(SkDebuggerGUI);
fActionOpen->setObjectName(QString::fromUtf8("actionOpen"));
fActionOpen->setIcon(open);
QIcon directory;
directory.addFile(QString::fromUtf8(":/images/Icons/drawer-open-icon.png"),
QSize(), QIcon::Normal, QIcon::Off);
fActionDirectory = new QAction(SkDebuggerGUI);
fActionDirectory->setObjectName(QString::fromUtf8("actionDirectory"));
fActionDirectory->setIcon(directory);
fActionDirectory->setText("Toggle Directory");
QIcon rewind;
rewind.addFile(QString::fromUtf8(":/images/Icons/rewind.png"), QSize(),
QIcon::Normal, QIcon::Off);
fActionRewind = new QAction(SkDebuggerGUI);
fActionRewind->setObjectName(QString::fromUtf8("actionRewind"));
fActionRewind->setIcon(rewind);
fActionRewind->setText("Rewind");
QIcon stepBack;
stepBack.addFile(QString::fromUtf8(":/images/Icons/back.png"), QSize(),
QIcon::Normal, QIcon::Off);
fActionStepBack = new QAction(SkDebuggerGUI);
fActionStepBack->setObjectName(QString::fromUtf8("actionStepBack"));
fActionStepBack->setIcon(stepBack);
fActionStepBack->setText("Step Back");
QIcon stepForward;
stepForward.addFile(QString::fromUtf8(":/images/Icons/go-next.png"),
QSize(), QIcon::Normal, QIcon::Off);
fActionStepForward = new QAction(SkDebuggerGUI);
fActionStepForward->setObjectName(QString::fromUtf8("actionStepBack"));
fActionStepForward->setIcon(stepForward);
fActionStepForward->setText("Step Forward");
QIcon play;
play.addFile(QString::fromUtf8(":/images/Icons/play.png"), QSize(),
QIcon::Normal, QIcon::Off);
fActionPlay = new QAction(SkDebuggerGUI);
fActionPlay->setObjectName(QString::fromUtf8("actionPlay"));
fActionPlay->setIcon(play);
fActionPlay->setText("Play");
fActionOpen.setIcon(open);
fActionOpen.setText("Open");
QIcon breakpoint;
breakpoint.addFile(QString::fromUtf8(":/images/Icons/breakpoint.png"),
QSize(), QIcon::Normal, QIcon::Off);
fActionBreakpoint = new QAction(SkDebuggerGUI);
fActionBreakpoint->setObjectName(QString::fromUtf8("actionBreakpoint"));
fActionBreakpoint->setIcon(breakpoint);
fActionBreakpoint->setText("Show Breakpoints");
QIcon inspector;
inspector.addFile(QString::fromUtf8(":/images/Icons/inspector.png"),
QSize(), QIcon::Normal, QIcon::Off);
fActionInspector = new QAction(SkDebuggerGUI);
fActionInspector->setObjectName(QString::fromUtf8("actionInspector"));
fActionInspector->setIcon(inspector);
fActionInspector->setText("Inspector");
QIcon deleteIcon;
deleteIcon.addFile(QString::fromUtf8(":/images/Icons/delete.png"), QSize(),
QIcon::Normal, QIcon::Off);
fActionDelete = new QAction(SkDebuggerGUI);
fActionDelete->setObjectName(QString::fromUtf8("actionDelete"));
fActionDelete->setIcon(deleteIcon);
fActionDelete->setText("Delete Command");
QIcon reload;
reload.addFile(QString::fromUtf8(":/images/Icons/reload.png"), QSize(),
QIcon::Normal, QIcon::Off);
fActionReload = new QAction(SkDebuggerGUI);
fActionReload->setObjectName(QString::fromUtf8("actionReload"));
fActionReload->setIcon(reload);
fActionReload->setText("Reset Picture");
QIcon settings;
settings.addFile(QString::fromUtf8(":/images/Icons/settings.png"), QSize(),
QIcon::Normal, QIcon::Off);
fActionSettings = new QAction(SkDebuggerGUI);
fActionSettings->setObjectName(QString::fromUtf8("actionSettings"));
fActionSettings->setIcon(settings);
fActionSettings->setText("Settings");
fActionBreakpoint.setIcon(breakpoint);
fActionBreakpoint.setText("Show Breakpoints");
QIcon cancel;
cancel.addFile(QString::fromUtf8(":/images/Icons/reset.png"), QSize(),
QIcon::Normal, QIcon::Off);
fActionCancel = new QAction(SkDebuggerGUI);
fActionCancel->setObjectName(QString::fromUtf8("actionCancel"));
fActionCancel->setIcon(cancel);
fActionCancel->setText("Clear Filter");
fActionCancel.setIcon(cancel);
fActionCancel.setText("Clear Filter");
fCentralWidget = new QWidget(SkDebuggerGUI);
fCentralWidget->setObjectName(QString::fromUtf8("centralWidget"));
fActionClose.setText("Exit");
fHorizontalLayout = new QHBoxLayout(fCentralWidget);
fHorizontalLayout->setSpacing(6);
fHorizontalLayout->setContentsMargins(11, 11, 11, 11);
fHorizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout"));
QIcon deleteIcon;
deleteIcon.addFile(QString::fromUtf8(":/images/Icons/delete.png"), QSize(),
QIcon::Normal, QIcon::Off);
fActionDelete.setIcon(deleteIcon);
fActionDelete.setText("Delete Command");
fVerticalLayout = new QVBoxLayout();
fVerticalLayout->setSpacing(6);
fVerticalLayout->setObjectName(QString::fromUtf8("verticalLayout"));
QIcon directory;
directory.addFile(QString::fromUtf8(":/images/Icons/drawer-open-icon.png"),
QSize(), QIcon::Normal, QIcon::Off);
fActionDirectory.setIcon(directory);
fActionDirectory.setText("Toggle Directory");
fVerticalLayout_2 = new QVBoxLayout();
fVerticalLayout_2->setSpacing(6);
fVerticalLayout_2->setObjectName(QString::fromUtf8("verticalLayout_2"));
QIcon inspector;
inspector.addFile(QString::fromUtf8(":/images/Icons/inspector.png"),
QSize(), QIcon::Normal, QIcon::Off);
fActionInspector.setIcon(inspector);
fActionInspector.setText("Toggle Inspector");
fListWidget = new QListWidget(fCentralWidget);
fListWidget->setItemDelegate(new SkListWidget(fListWidget));
fListWidget->setObjectName(QString::fromUtf8("listWidget"));
fListWidget->setMaximumWidth(250);
QIcon play;
play.addFile(QString::fromUtf8(":/images/Icons/play.png"), QSize(),
QIcon::Normal, QIcon::Off);
fActionPlay.setIcon(play);
fActionPlay.setText("Play");
fInspectorWidget = new SkInspectorWidget();
fInspectorWidget->setObjectName(QString::fromUtf8("inspectorWidget"));
fInspectorWidget->setSizePolicy(QSizePolicy::Expanding,
QSizePolicy::Expanding);
fInspectorWidget->setMaximumHeight(300);
QIcon reload;
reload.addFile(QString::fromUtf8(":/images/Icons/reload.png"), QSize(),
QIcon::Normal, QIcon::Off);
fActionReload.setIcon(reload);
fActionReload.setText("Reset Picture");
fFilter = new QComboBox(fCentralWidget);
fFilter->setObjectName(QString::fromUtf8("comboBox"));
fFilter->addItem("--Filter By Available Commands--");
QIcon rewind;
rewind.addFile(QString::fromUtf8(":/images/Icons/rewind.png"), QSize(),
QIcon::Normal, QIcon::Off);
fActionRewind.setIcon(rewind);
fActionRewind.setText("Rewind");
fDirectoryWidget = new QListWidget(fCentralWidget);
fDirectoryWidget->setObjectName(QString::fromUtf8("listWidget_2"));
fDirectoryWidget->setMaximumWidth(250);
fDirectoryWidget->setStyleSheet("QListWidget::Item {padding: 5px;}");
QIcon settings;
settings.addFile(QString::fromUtf8(":/images/Icons/settings.png"), QSize(),
QIcon::Normal, QIcon::Off);
fActionSettings.setIcon(settings);
fActionSettings.setText("Settings");
fVerticalLayout_2->addWidget(fListWidget);
fVerticalLayout_2->addWidget(fDirectoryWidget);
QIcon stepBack;
stepBack.addFile(QString::fromUtf8(":/images/Icons/back.png"), QSize(),
QIcon::Normal, QIcon::Off);
fActionStepBack.setIcon(stepBack);
fActionStepBack.setText("Step Back");
fCanvasWidget = new SkCanvasWidget(fCentralWidget);
fCanvasWidget->setSizePolicy(QSizePolicy::Expanding,
QIcon stepForward;
stepForward.addFile(QString::fromUtf8(":/images/Icons/go-next.png"),
QSize(), QIcon::Normal, QIcon::Off);
fActionStepForward.setIcon(stepForward);
fActionStepForward.setText("Step Forward");
fListWidget.setItemDelegate(new SkListWidget(&fListWidget));
fListWidget.setObjectName(QString::fromUtf8("listWidget"));
fListWidget.setMaximumWidth(250);
fFilter.addItem("--Filter By Available Commands--");
fDirectoryWidget.setMaximumWidth(250);
fDirectoryWidget.setStyleSheet("QListWidget::Item {padding: 5px;}");
fCanvasWidget.setSizePolicy(QSizePolicy::Expanding,
QSizePolicy::Expanding);
fSettingsWidget = new SkSettingsWidget(fCentralWidget);
fSettingsWidget->setSizePolicy(QSizePolicy::Expanding,
fInspectorWidget.setSizePolicy(QSizePolicy::Expanding,
QSizePolicy::Expanding);
fSettingsWidget->setMaximumWidth(250);
fSettingsWidget->setHidden(true);
fInspectorWidget.setMaximumHeight(300);
fHorizontalLayout_2 = new QHBoxLayout();
fHorizontalLayout_2->setSpacing(6);
fSettingsWidget.setSizePolicy(QSizePolicy::Expanding,
QSizePolicy::Expanding);
fSettingsWidget.setMaximumWidth(250);
fSettingsWidget.setHidden(true);
fHorizontalLayout_2->addWidget(fCanvasWidget);
fHorizontalLayout_2->addWidget(fSettingsWidget);
fLeftColumnLayout.setSpacing(6);
fLeftColumnLayout.addWidget(&fListWidget);
fLeftColumnLayout.addWidget(&fDirectoryWidget);
fVerticalLayout->addLayout(fHorizontalLayout_2);
fVerticalLayout->addWidget(fInspectorWidget);
fCanvasAndSettingsLayout.setSpacing(6);
fCanvasAndSettingsLayout.addWidget(&fCanvasWidget);
fCanvasAndSettingsLayout.addWidget(&fSettingsWidget);
fHorizontalLayout->addLayout(fVerticalLayout_2);
fHorizontalLayout->addLayout(fVerticalLayout);
fMainAndRightColumnLayout.setSpacing(6);
fMainAndRightColumnLayout.addLayout(&fCanvasAndSettingsLayout);
fMainAndRightColumnLayout.addWidget(&fInspectorWidget);
SkDebuggerGUI->setCentralWidget(fCentralWidget);
fStatusBar = new QStatusBar(SkDebuggerGUI);
fStatusBar->setObjectName(QString::fromUtf8("statusBar"));
SkDebuggerGUI->setStatusBar(fStatusBar);
fToolBar = new QToolBar(SkDebuggerGUI);
fToolBar->setObjectName(QString::fromUtf8("toolBar"));
fToolBar->setIconSize(QSize(24, 24));
//fToolBar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
SkDebuggerGUI->addToolBar(Qt::TopToolBarArea, fToolBar);
fContainerLayout.setSpacing(6);
fContainerLayout.setContentsMargins(11, 11, 11, 11);
fContainerLayout.addLayout(&fLeftColumnLayout);
fContainerLayout.addLayout(&fMainAndRightColumnLayout);
SkDebuggerGUI->setCentralWidget(&fCentralWidget);
SkDebuggerGUI->setStatusBar(&fStatusBar);
fToolBar.setIconSize(QSize(24, 24));
fToolBar.setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
SkDebuggerGUI->addToolBar(Qt::TopToolBarArea, &fToolBar);
QWidget *spacer = new QWidget();
spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
fToolBar->addAction(fActionOpen);
fToolBar->addSeparator();
fToolBar->addAction(fActionDirectory);
fToolBar->addSeparator();
fToolBar->addAction(fActionRewind);
fToolBar->addAction(fActionStepBack);
fToolBar->addAction(fActionStepForward);
fToolBar->addAction(fActionPlay);
fToolBar->addSeparator();
fToolBar->addAction(fActionBreakpoint);
fToolBar->addAction(fActionInspector);
fToolBar->addSeparator();
fToolBar->addAction(fActionDelete);
fToolBar->addAction(fActionReload);
fToolBar->addSeparator();
fToolBar->addAction(fActionSettings);
fToolBar->addWidget(spacer);
fToolBar->addWidget(fFilter);
fToolBar->addAction(fActionCancel);
fToolBar.addAction(&fActionRewind);
fToolBar.addAction(&fActionStepBack);
fToolBar.addAction(&fActionStepForward);
fToolBar.addAction(&fActionPlay);
fToolBar.addSeparator();
fToolBar.addAction(&fActionBreakpoint);
fToolBar.addSeparator();
fToolBar.addAction(&fActionDelete);
fToolBar.addAction(&fActionReload);
fToolBar.addSeparator();
fToolBar.addAction(&fActionSettings);
fToolBar.addWidget(spacer);
fToolBar.addWidget(&fFilter);
fToolBar.addAction(&fActionCancel);
// TODO(chudy): Remove static call.
fDirectoryWidgetActive = false;
@ -486,95 +461,65 @@ void SkDebuggerGUI::setupUi(QMainWindow *SkDebuggerGUI) {
setupDirectoryWidget();
fDirectoryWidgetActive = true;
fMenuBar = new QMenuBar(SkDebuggerGUI);
// File
fMenuFile = new QMenu(SkDebuggerGUI);
fMenuFile->setTitle("File");
fActionClose = new QAction(SkDebuggerGUI);
fActionClose->setText("Close");
fMenuFile->addAction(fActionOpen);
fMenuFile->addAction(fActionClose);
// Navigate
fMenuNavigate = new QMenu(SkDebuggerGUI);
fMenuNavigate->setTitle("Navigate");
fActionGoToLine = new QAction(SkDebuggerGUI);
fActionGoToLine->setText("Go to Line...");
fActionGoToLine->setDisabled(true);
fMenuNavigate->addAction(fActionGoToLine);
// Menu Bar
fMenuBar->addAction(fMenuFile->menuAction());
fMenuBar->addAction(fMenuNavigate->menuAction());
fMenuFile.setTitle("File");
fMenuFile.addAction(&fActionOpen);
fMenuFile.addAction(&fActionClose);
fMenuNavigate.setTitle("Navigate");
fMenuNavigate.addAction(&fActionGoToLine);
fMenuView.setTitle("View");
fMenuView.addAction(&fActionInspector);
fMenuView.addAction(&fActionDirectory);
fActionGoToLine.setText("Go to Line...");
fActionGoToLine.setDisabled(true);
fMenuBar.addAction(fMenuFile.menuAction());
fMenuBar.addAction(fMenuView.menuAction());
fMenuBar.addAction(fMenuNavigate.menuAction());
fPause = false;
SkDebuggerGUI->setMenuBar(fMenuBar);
retranslateUi(SkDebuggerGUI);
SkDebuggerGUI->setMenuBar(&fMenuBar);
QMetaObject::connectSlotsByName(SkDebuggerGUI);
}
void SkDebuggerGUI::setupDirectoryWidget() {
fDir = new QDir(fPath);
QDir dir(fPath);
QRegExp r(".skp");
fDirectoryWidget->clear();
const QStringList files = fDir->entryList();
fDirectoryWidget.clear();
const QStringList files = dir.entryList();
foreach (QString f, files) {
if (f.contains(r))
fDirectoryWidget->addItem(f);
fDirectoryWidget.addItem(f);
}
}
// TODO(chudy): Is this necessary?
void SkDebuggerGUI::retranslateUi(QMainWindow *SkDebuggerGUI) {
SkDebuggerGUI->setWindowTitle(
QApplication::translate("SkDebuggerGUI", "SkDebuggerGUI", 0,
QApplication::UnicodeUTF8));
fActionOpen->setText(
QApplication::translate("SkDebuggerGUI", "Open", 0,
QApplication::UnicodeUTF8));
fToolBar->setWindowTitle(
QApplication::translate("SkDebuggerGUI", "toolBar", 0,
QApplication::UnicodeUTF8));
}
void SkDebuggerGUI::loadPicture(QString fileName) {
fCanvasWidget->loadPicture(fileName);
std::vector<std::string> *cv = fCanvasWidget->getDrawCommands();
fCanvasWidget.loadPicture(fileName);
std::vector<std::string> *cv = fCanvasWidget.getDrawCommands();
/* fDebugCanvas is reinitialized every load picture. Need it to retain value
* of the visibility filter. */
actionCommandFilter();
fCanvasWidget->toggleCurrentCommandFilter(fSettingsWidget->getVisibilityButton()->isChecked());
fCanvasWidget.toggleCurrentCommandFilter(
fSettingsWidget.getVisibilityButton()->isChecked());
setupListWidget(cv);
setupComboBox(cv);
}
void SkDebuggerGUI::setupListWidget(std::vector<std::string>* cv) {
fListWidget->clear();
fListWidget.clear();
int counter = 0;
for (unsigned int i = 0; i < cv->size(); i++) {
QListWidgetItem *item = new QListWidgetItem();
item->setData(Qt::DisplayRole, (*cv)[i].c_str());
item->setData(Qt::UserRole + 1, counter++);
item->setData(Qt::UserRole + 2, true);
fListWidget->addItem(item);
fListWidget.addItem(item);
}
}
void SkDebuggerGUI::setupComboBox(std::vector<std::string>* cv) {
fFilter->clear();
fFilter->addItem("--Filter By Available Commands--");
fFilter.clear();
fFilter.addItem("--Filter By Available Commands--");
std::map<std::string, int> map;
for (unsigned int i = 0; i < cv->size(); i++) {
@ -590,7 +535,7 @@ void SkDebuggerGUI::setupComboBox(std::vector<std::string>* cv) {
overview.append(QString::number(it->second));
overview.append("<br/>");
counter += it->second;
fFilter->addItem((it->first).c_str());
fFilter.addItem((it->first).c_str());
}
QString total;
total.append("Total Draw Commands: ");
@ -601,18 +546,18 @@ void SkDebuggerGUI::setupComboBox(std::vector<std::string>* cv) {
overview.append("<br/>");
overview.append("SkBitmap Width: ");
// NOTE(chudy): This is where we can pull out the SkPictures width.
overview.append(QString::number(fCanvasWidget->getBitmapWidth()));
overview.append(QString::number(fCanvasWidget.getBitmapWidth()));
overview.append("px<br/>");
overview.append("SkBitmap Height: ");
overview.append(QString::number(fCanvasWidget->getBitmapHeight()));
overview.append(QString::number(fCanvasWidget.getBitmapHeight()));
overview.append("px");
fInspectorWidget->setOverviewText(overview);
fInspectorWidget.setOverviewText(overview);
// NOTE(chudy): Makes first item unselectable.
QStandardItemModel* model = qobject_cast<QStandardItemModel*>(
fFilter->model());
QModelIndex firstIndex = model->index(0, fFilter->modelColumn(),
fFilter->rootModelIndex());
fFilter.model());
QModelIndex firstIndex = model->index(0, fFilter.modelColumn(),
fFilter.rootModelIndex());
QStandardItem* firstItem = model->itemFromIndex(firstIndex);
firstItem->setSelectable(false);
}

View File

@ -134,7 +134,7 @@ private slots:
Toggles whether drawing to a new command requires a double click
or simple focus.
*/
void pauseDrawing(int state);
void pauseDrawing(bool isPaused);
/**
Executes draw commands up to the selected command
@ -158,48 +158,45 @@ private slots:
void toggleFilter(QString string);
private:
QAction* fActionOpen;
QAction* fActionDirectory;
QAction* fActionRewind;
QAction* fActionStepBack;
QAction* fActionStepForward;
QAction* fActionPlay;
QAction* fActionBreakpoint;
QAction* fActionInspector;
QAction* fActionDelete;
QAction* fActionReload;
QAction* fActionClose;
QAction* fActionSettings;
QAction fActionOpen;
QAction fActionBreakpoint;
QAction fActionCancel;
QAction fActionClose;
QAction fActionDelete;
QAction fActionDirectory;
QAction fActionGoToLine;
QAction fActionInspector;
QAction fActionPlay;
QAction fActionReload;
QAction fActionRewind;
QAction fActionSettings;
QAction fActionStepBack;
QAction fActionStepForward;
QWidget fCentralWidget;
QComboBox* fFilter;
QAction* fActionCancel;
QComboBox fFilter;
QWidget* fCentralWidget;
QHBoxLayout* fHorizontalLayout;
QHBoxLayout* fHorizontalLayout_2;
QVBoxLayout* fVerticalLayout;
QVBoxLayout* fVerticalLayout_2;
QListWidget* fListWidget;
QListWidget* fDirectoryWidget;
QListView* fListView;
QStatusBar* fStatusBar;
QToolBar* fToolBar;
QVBoxLayout fLeftColumnLayout;
QVBoxLayout fMainAndRightColumnLayout;
QHBoxLayout fContainerLayout;
QHBoxLayout fCanvasAndSettingsLayout;
SkCanvasWidget* fCanvasWidget;
SkInspectorWidget* fInspectorWidget;
SkSettingsWidget* fSettingsWidget;
QListWidget fListWidget;
QListWidget fDirectoryWidget;
SkCanvasWidget fCanvasWidget;
SkInspectorWidget fInspectorWidget;
SkSettingsWidget fSettingsWidget;
QStatusBar fStatusBar;
QDir* fDir;
QString fPath;
bool fDirectoryWidgetActive;
QMenuBar* fMenuBar;
QMenu* fMenuFile;
QAction* fActionQuit;
QAction* fActionTemp;
QMenu* fMenuNavigate;
QAction *fActionGoToLine;
QMenuBar fMenuBar;
QMenu fMenuFile;
QMenu fMenuNavigate;
QMenu fMenuView;
QToolBar fToolBar;
bool fBreakpointsActivated;
bool fPause;
@ -209,12 +206,6 @@ private:
*/
void setupUi(QMainWindow *SkDebuggerGUI);
/**
Placeholder function for executing new commands on window translate
and resize.
*/
void retranslateUi(QMainWindow *SkDebuggerGUI);
/**
Pipes a QString in with the location of the filename, proceeds to updating
the listwidget, combowidget and inspectorwidget.

View File

@ -1,7 +1,7 @@
/****************************************************************************
** Meta object code from reading C++ file 'SkDebuggerGUI.h'
**
** Created: Mon Jul 9 13:45:07 2012
** Created: Tue Jul 10 09:04:38 2012
** by: The Qt Meta Object Compiler version 62 (Qt 4.6.2)
**
** WARNING! All changes made in this file will be lost!
@ -43,17 +43,17 @@ static const uint qt_meta_data_SkDebuggerGUI[] = {
147, 14, 14, 14, 0x08,
160, 14, 14, 14, 0x08,
175, 14, 14, 14, 0x08,
190, 14, 14, 14, 0x08,
207, 14, 14, 14, 0x08,
224, 14, 14, 14, 0x08,
249, 244, 14, 14, 0x08,
276, 14, 14, 14, 0x08,
287, 244, 14, 14, 0x08,
335, 323, 14, 14, 0x08,
354, 14, 14, 14, 0x08,
373, 14, 14, 14, 0x08,
398, 391, 14, 14, 0x08,
426, 420, 14, 14, 0x08,
202, 190, 14, 14, 0x08,
221, 14, 14, 14, 0x08,
238, 14, 14, 14, 0x08,
255, 14, 14, 14, 0x08,
280, 275, 14, 14, 0x08,
307, 14, 14, 14, 0x08,
327, 318, 14, 14, 0x08,
346, 275, 14, 14, 0x08,
382, 14, 14, 14, 0x08,
401, 14, 14, 14, 0x08,
426, 419, 14, 14, 0x08,
0 // eod
};
@ -64,14 +64,14 @@ static const char qt_meta_stringdata_SkDebuggerGUI[] = {
"actionCommandFilter()\0actionClose()\0"
"actionDelete()\0actionInspector()\0"
"actionPlay()\0actionReload()\0actionRewind()\0"
"scaleFactor\0actionScale(float)\0"
"actionSettings()\0actionStepBack()\0"
"actionStepForward()\0item\0"
"loadFile(QListWidgetItem*)\0openFile()\0"
"isPaused\0pauseDrawing(bool)\0"
"registerListClick(QListWidgetItem*)\0"
"scaleFactor\0actionScale(float)\0"
"toggleBreakpoint()\0toggleDirectory()\0"
"string\0toggleFilter(QString)\0state\0"
"pauseDrawing(int)\0"
"string\0toggleFilter(QString)\0"
};
const QMetaObject SkDebuggerGUI::staticMetaObject = {
@ -113,17 +113,17 @@ int SkDebuggerGUI::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
case 7: actionPlay(); break;
case 8: actionReload(); break;
case 9: actionRewind(); break;
case 10: actionSettings(); break;
case 11: actionStepBack(); break;
case 12: actionStepForward(); break;
case 13: loadFile((*reinterpret_cast< QListWidgetItem*(*)>(_a[1]))); break;
case 14: openFile(); break;
case 15: registerListClick((*reinterpret_cast< QListWidgetItem*(*)>(_a[1]))); break;
case 16: actionScale((*reinterpret_cast< float(*)>(_a[1]))); break;
case 17: toggleBreakpoint(); break;
case 18: toggleDirectory(); break;
case 19: toggleFilter((*reinterpret_cast< QString(*)>(_a[1]))); break;
case 20: pauseDrawing((*reinterpret_cast< int(*)>(_a[1]))); break;
case 10: actionScale((*reinterpret_cast< float(*)>(_a[1]))); break;
case 11: actionSettings(); break;
case 12: actionStepBack(); break;
case 13: actionStepForward(); break;
case 14: loadFile((*reinterpret_cast< QListWidgetItem*(*)>(_a[1]))); break;
case 15: openFile(); break;
case 16: pauseDrawing((*reinterpret_cast< bool(*)>(_a[1]))); break;
case 17: registerListClick((*reinterpret_cast< QListWidgetItem*(*)>(_a[1]))); break;
case 18: toggleBreakpoint(); break;
case 19: toggleDirectory(); break;
case 20: toggleFilter((*reinterpret_cast< QString(*)>(_a[1]))); break;
default: ;
}
_id -= 21;