2012-06-29 14:21:22 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2012 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
#include "SkDebuggerGUI.h"
|
|
|
|
#include <QListWidgetItem>
|
|
|
|
|
|
|
|
SkDebuggerGUI::SkDebuggerGUI(QWidget *parent) :
|
2012-07-10 13:19:25 +00:00
|
|
|
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)
|
|
|
|
{
|
2012-06-29 14:21:22 +00:00
|
|
|
setupUi(this);
|
2012-07-10 13:19:25 +00:00
|
|
|
connect(&fListWidget, SIGNAL(currentItemChanged(QListWidgetItem*,
|
2012-07-09 20:26:53 +00:00
|
|
|
QListWidgetItem*)), this,
|
|
|
|
SLOT(registerListClick(QListWidgetItem *)));
|
2012-07-10 13:19:25 +00:00
|
|
|
connect(&fActionOpen, SIGNAL(triggered()), this, SLOT(openFile()));
|
|
|
|
connect(&fActionDirectory, SIGNAL(triggered()), this,
|
2012-07-09 20:26:53 +00:00
|
|
|
SLOT(toggleDirectory()));
|
2012-07-10 13:19:25 +00:00
|
|
|
connect(&fDirectoryWidget, SIGNAL(currentItemChanged(QListWidgetItem*,
|
2012-07-09 20:26:53 +00:00
|
|
|
QListWidgetItem*)), this,
|
|
|
|
SLOT(loadFile(QListWidgetItem *)));
|
2012-07-10 13:19:25 +00:00
|
|
|
connect(&fActionDelete, SIGNAL(triggered()), this, SLOT(actionDelete()));
|
|
|
|
connect(&fActionReload, SIGNAL(triggered()), this, SLOT(actionReload()));
|
|
|
|
connect(&fListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this,
|
2012-07-09 20:26:53 +00:00
|
|
|
SLOT(toggleBreakpoint()));
|
2012-07-10 13:19:25 +00:00
|
|
|
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,
|
2012-07-09 20:26:53 +00:00
|
|
|
SLOT(actionStepForward()));
|
2012-07-10 13:19:25 +00:00
|
|
|
connect(&fActionBreakpoint, SIGNAL(triggered()), this,
|
2012-07-09 20:26:53 +00:00
|
|
|
SLOT(actionBreakpoints()));
|
2012-07-10 13:19:25 +00:00
|
|
|
connect(&fActionInspector, SIGNAL(triggered()), this,
|
2012-07-09 20:26:53 +00:00
|
|
|
SLOT(actionInspector()));
|
2012-07-10 13:19:25 +00:00
|
|
|
connect(&fFilter, SIGNAL(activated(QString)), this,
|
2012-07-09 20:26:53 +00:00
|
|
|
SLOT(toggleFilter(QString)));
|
2012-07-10 13:19:25 +00:00
|
|
|
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,
|
2012-07-09 20:26:53 +00:00
|
|
|
SLOT(actionCommandFilter()));
|
2012-07-10 13:19:25 +00:00
|
|
|
connect(&fCanvasWidget, SIGNAL(scaleFactorChanged(float)), this,
|
2012-07-09 20:26:53 +00:00
|
|
|
SLOT(actionScale(float)));
|
2012-07-12 14:31:25 +00:00
|
|
|
connect(fSettingsWidget.getCommandCheckBox(), SIGNAL(toggled(bool)),
|
2012-07-10 14:36:14 +00:00
|
|
|
this, SLOT(pauseDrawing(bool)));
|
2012-07-10 13:19:25 +00:00
|
|
|
connect(&fCanvasWidget, SIGNAL(commandChanged(int)), &fSettingsWidget,
|
2012-07-09 20:26:53 +00:00
|
|
|
SLOT(updateCommand(int)));
|
2012-07-12 14:31:25 +00:00
|
|
|
connect(&fCanvasWidget, SIGNAL(hitChanged(int)), &fSettingsWidget,
|
|
|
|
SLOT(updateHit(int)));
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SkDebuggerGUI::~SkDebuggerGUI() {
|
|
|
|
}
|
|
|
|
|
|
|
|
void SkDebuggerGUI::actionBreakpoints() {
|
2012-07-09 20:26:53 +00:00
|
|
|
if (!fBreakpointsActivated) {
|
2012-06-29 14:21:22 +00:00
|
|
|
fBreakpointsActivated = true;
|
|
|
|
} else {
|
|
|
|
fBreakpointsActivated = false;
|
|
|
|
}
|
|
|
|
|
2012-07-10 13:19:25 +00:00
|
|
|
for (int row = 0; row < fListWidget.count(); row++) {
|
|
|
|
QListWidgetItem *item = fListWidget.item(row);
|
2012-06-29 14:21:22 +00:00
|
|
|
|
|
|
|
if (item->checkState() == Qt::Unchecked && fBreakpointsActivated) {
|
|
|
|
item->setHidden(true);
|
|
|
|
} else {
|
|
|
|
item->setHidden(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SkDebuggerGUI::actionCancel() {
|
2012-07-10 13:19:25 +00:00
|
|
|
for (int row = 0; row < fListWidget.count(); row++) {
|
|
|
|
fListWidget.item(row)->setHidden(false);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SkDebuggerGUI::actionCommandFilter() {
|
2012-07-10 13:19:25 +00:00
|
|
|
fCanvasWidget.toggleCurrentCommandFilter(
|
|
|
|
fSettingsWidget.getVisibilityButton()->isChecked());
|
|
|
|
fCanvasWidget.drawTo(fListWidget.currentRow());
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SkDebuggerGUI::actionClose() {
|
|
|
|
this->close();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SkDebuggerGUI::actionDelete() {
|
2012-07-10 13:19:25 +00:00
|
|
|
QListWidgetItem* item = fListWidget.currentItem();
|
2012-07-09 20:26:53 +00:00
|
|
|
if (item->data(Qt::UserRole + 2) == true) {
|
2012-06-29 14:21:22 +00:00
|
|
|
item->setData(Qt::UserRole + 2, false);
|
2012-07-12 14:15:54 +00:00
|
|
|
item->setData(Qt::UserRole + 3, QPixmap(":/images/Icons/delete.png"));
|
2012-06-29 14:21:22 +00:00
|
|
|
} else {
|
|
|
|
item->setData(Qt::UserRole + 2, true);
|
2012-07-12 14:15:54 +00:00
|
|
|
item->setData(Qt::UserRole + 3, QPixmap(":/images/Icons/blank.png"));
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
2012-07-10 13:19:25 +00:00
|
|
|
int currentRow = fListWidget.currentRow();
|
2012-06-29 14:21:22 +00:00
|
|
|
// NOTE(chudy): Forces a redraw up to current selected command.
|
2012-07-10 13:19:25 +00:00
|
|
|
fCanvasWidget.toggleCommand(currentRow);
|
2012-07-12 14:38:49 +00:00
|
|
|
fCanvasWidget.drawTo(fPausedRow);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SkDebuggerGUI::actionInspector() {
|
2012-07-10 13:19:25 +00:00
|
|
|
if (fInspectorWidget.isHidden()) {
|
|
|
|
fInspectorWidget.setHidden(false);
|
2012-06-29 14:21:22 +00:00
|
|
|
} else {
|
2012-07-10 13:19:25 +00:00
|
|
|
fInspectorWidget.setHidden(true);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SkDebuggerGUI::actionPlay() {
|
2012-07-10 13:19:25 +00:00
|
|
|
for (int row = fListWidget.currentRow() + 1; row < fListWidget.count();
|
2012-07-09 20:26:53 +00:00
|
|
|
row++) {
|
2012-07-10 13:19:25 +00:00
|
|
|
QListWidgetItem *item = fListWidget.item(row);
|
2012-06-29 14:21:22 +00:00
|
|
|
if (item->checkState() == Qt::Checked) {
|
2012-07-10 13:19:25 +00:00
|
|
|
fListWidget.setCurrentItem(item);
|
2012-06-29 14:21:22 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2012-07-10 13:19:25 +00:00
|
|
|
fListWidget.setCurrentRow(fListWidget.count() - 1);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SkDebuggerGUI::actionReload() {
|
2012-07-10 13:19:25 +00:00
|
|
|
for (int row = 0; row < fListWidget.count(); row++) {
|
|
|
|
QListWidgetItem* item = fListWidget.item(row);
|
2012-06-29 14:21:22 +00:00
|
|
|
item->setData(Qt::UserRole + 2, true);
|
2012-07-09 20:26:53 +00:00
|
|
|
item->setData(Qt::DecorationRole, QPixmap(":/images/Icons/blank.png"));
|
2012-07-10 13:19:25 +00:00
|
|
|
fCanvasWidget.toggleCommand(row, true);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
2012-07-10 13:19:25 +00:00
|
|
|
fCanvasWidget.drawTo(fListWidget.currentRow());
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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. */
|
2012-07-10 13:19:25 +00:00
|
|
|
fListWidget.setCurrentRow(2);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2012-07-09 20:26:53 +00:00
|
|
|
void SkDebuggerGUI::actionScale(float scaleFactor) {
|
2012-07-10 13:19:25 +00:00
|
|
|
fSettingsWidget.setZoomText(scaleFactor);
|
2012-07-09 20:26:53 +00:00
|
|
|
}
|
|
|
|
|
2012-06-29 14:21:22 +00:00
|
|
|
void SkDebuggerGUI::actionSettings() {
|
2012-07-10 13:19:25 +00:00
|
|
|
if (fSettingsWidget.isHidden()) {
|
|
|
|
fSettingsWidget.setHidden(false);
|
2012-06-29 14:21:22 +00:00
|
|
|
} else {
|
2012-07-10 13:19:25 +00:00
|
|
|
fSettingsWidget.setHidden(true);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SkDebuggerGUI::actionStepBack() {
|
2012-07-10 13:19:25 +00:00
|
|
|
int currentRow = fListWidget.currentRow();
|
2012-06-29 14:21:22 +00:00
|
|
|
if (currentRow != 0) {
|
2012-07-10 13:19:25 +00:00
|
|
|
fListWidget.setCurrentRow(currentRow - 1);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SkDebuggerGUI::actionStepForward() {
|
2012-07-10 13:19:25 +00:00
|
|
|
int currentRow = fListWidget.currentRow();
|
2012-06-29 14:21:22 +00:00
|
|
|
QString curRow = QString::number(currentRow);
|
2012-07-10 13:19:25 +00:00
|
|
|
QString curCount = QString::number(fListWidget.count());
|
|
|
|
if (currentRow < fListWidget.count() - 1) {
|
|
|
|
fListWidget.setCurrentRow(currentRow + 1);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SkDebuggerGUI::loadFile(QListWidgetItem *item) {
|
|
|
|
if (fDirectoryWidgetActive) {
|
|
|
|
QString fileName;
|
|
|
|
fileName.append(fPath);
|
|
|
|
fileName.append("/");
|
|
|
|
fileName.append(item->text());
|
|
|
|
loadPicture(fileName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SkDebuggerGUI::openFile() {
|
2012-07-09 20:26:53 +00:00
|
|
|
QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"), "",
|
|
|
|
tr("Files (*.*)"));
|
2012-06-29 14:21:22 +00:00
|
|
|
fDirectoryWidgetActive = false;
|
|
|
|
if (!fileName.isNull()) {
|
|
|
|
QFileInfo pathInfo(fileName);
|
|
|
|
fPath = pathInfo.path();
|
|
|
|
loadPicture(fileName);
|
|
|
|
setupDirectoryWidget();
|
|
|
|
}
|
|
|
|
fDirectoryWidgetActive = true;
|
|
|
|
}
|
|
|
|
|
2012-07-10 13:19:25 +00:00
|
|
|
void SkDebuggerGUI::pauseDrawing(bool isPaused) {
|
2012-07-09 20:26:53 +00:00
|
|
|
// Qt uses 0 for unchecked, 1 for partially enabled and 2 for checked.
|
2012-07-10 13:19:25 +00:00
|
|
|
if (isPaused) {
|
2012-07-09 20:26:53 +00:00
|
|
|
fPause = true;
|
2012-07-12 14:38:49 +00:00
|
|
|
fPausedRow = fListWidget.currentRow();
|
2012-07-09 20:26:53 +00:00
|
|
|
} else {
|
|
|
|
fPause = false;
|
2012-07-10 13:19:25 +00:00
|
|
|
fCanvasWidget.drawTo(fListWidget.currentRow());
|
2012-07-09 20:26:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-29 14:21:22 +00:00
|
|
|
void SkDebuggerGUI::registerListClick(QListWidgetItem *item) {
|
2012-07-10 13:19:25 +00:00
|
|
|
int currentRow = fListWidget.currentRow();
|
2012-07-09 20:26:53 +00:00
|
|
|
if (!fPause) {
|
2012-07-10 13:19:25 +00:00
|
|
|
fCanvasWidget.drawTo(currentRow);
|
2012-07-09 20:26:53 +00:00
|
|
|
}
|
2012-07-10 13:19:25 +00:00
|
|
|
std::vector<std::string> *v = fCanvasWidget.getCurrentCommandInfo(
|
2012-07-09 20:26:53 +00:00
|
|
|
currentRow);
|
|
|
|
|
|
|
|
/* TODO(chudy): Add command type before parameters. Rename v
|
|
|
|
* to something more informative. */
|
|
|
|
if (v) {
|
|
|
|
std::vector<std::string>::iterator it;
|
|
|
|
|
|
|
|
QString info;
|
|
|
|
info.append("<b>Parameters: </b><br/>");
|
|
|
|
for (it = v->begin(); it != v->end(); ++it) {
|
|
|
|
info.append(QString((*it).c_str()));
|
|
|
|
info.append("<br/>");
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
2012-07-10 13:19:25 +00:00
|
|
|
fInspectorWidget.setDetailText(info);
|
|
|
|
fInspectorWidget.setDisabled(false);
|
|
|
|
fInspectorWidget.setMatrix(fCanvasWidget.getCurrentMatrix());
|
|
|
|
fInspectorWidget.setClip(fCanvasWidget.getCurrentClip());
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SkDebuggerGUI::toggleBreakpoint() {
|
2012-07-10 13:19:25 +00:00
|
|
|
QListWidgetItem* item = fListWidget.currentItem();
|
2012-06-29 14:21:22 +00:00
|
|
|
if (item->checkState() == Qt::Unchecked) {
|
|
|
|
item->setCheckState(Qt::Checked);
|
2012-07-12 14:15:54 +00:00
|
|
|
item->setData(Qt::DecorationRole,
|
|
|
|
QPixmap(":/images/Icons/breakpoint_16x16.png"));
|
2012-06-29 14:21:22 +00:00
|
|
|
} else {
|
|
|
|
item->setCheckState(Qt::Unchecked);
|
2012-07-12 14:15:54 +00:00
|
|
|
item->setData(Qt::DecorationRole,
|
|
|
|
QPixmap(":/images/Icons/blank.png"));
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SkDebuggerGUI::toggleDirectory() {
|
2012-07-10 13:19:25 +00:00
|
|
|
if (fDirectoryWidget.isHidden()) {
|
|
|
|
fDirectoryWidget.setHidden(false);
|
2012-06-29 14:21:22 +00:00
|
|
|
} else {
|
2012-07-10 13:19:25 +00:00
|
|
|
fDirectoryWidget.setHidden(true);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SkDebuggerGUI::toggleFilter(QString string) {
|
2012-07-10 13:19:25 +00:00
|
|
|
for (int row = 0; row < fListWidget.count(); row++) {
|
|
|
|
QListWidgetItem *item = fListWidget.item(row);
|
2012-06-29 14:21:22 +00:00
|
|
|
if (item->text() == string) {
|
|
|
|
item->setHidden(false);
|
|
|
|
} else {
|
|
|
|
item->setHidden(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SkDebuggerGUI::setupUi(QMainWindow *SkDebuggerGUI) {
|
|
|
|
QIcon windowIcon;
|
2012-07-09 20:26:53 +00:00
|
|
|
windowIcon.addFile(QString::fromUtf8(":/images/Icons/skia.png"), QSize(),
|
|
|
|
QIcon::Normal, QIcon::Off);
|
2012-06-29 14:21:22 +00:00
|
|
|
SkDebuggerGUI->setObjectName(QString::fromUtf8("SkDebuggerGUI"));
|
|
|
|
SkDebuggerGUI->resize(1200, 1000);
|
|
|
|
SkDebuggerGUI->setWindowIcon(windowIcon);
|
2012-07-10 13:19:25 +00:00
|
|
|
SkDebuggerGUI->setWindowTitle("Skia Debugger");
|
2012-06-29 14:21:22 +00:00
|
|
|
|
|
|
|
QIcon open;
|
2012-07-09 20:26:53 +00:00
|
|
|
open.addFile(QString::fromUtf8(":/images/Icons/package-br32.png"), QSize(),
|
|
|
|
QIcon::Normal, QIcon::Off);
|
2012-07-10 13:19:25 +00:00
|
|
|
fActionOpen.setIcon(open);
|
|
|
|
fActionOpen.setText("Open");
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2012-07-10 13:19:25 +00:00
|
|
|
QIcon breakpoint;
|
|
|
|
breakpoint.addFile(QString::fromUtf8(":/images/Icons/breakpoint.png"),
|
2012-07-09 20:26:53 +00:00
|
|
|
QSize(), QIcon::Normal, QIcon::Off);
|
2012-07-10 13:19:25 +00:00
|
|
|
fActionBreakpoint.setIcon(breakpoint);
|
|
|
|
fActionBreakpoint.setText("Show Breakpoints");
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2012-07-10 13:19:25 +00:00
|
|
|
QIcon cancel;
|
|
|
|
cancel.addFile(QString::fromUtf8(":/images/Icons/reset.png"), QSize(),
|
2012-07-09 20:26:53 +00:00
|
|
|
QIcon::Normal, QIcon::Off);
|
2012-07-10 13:19:25 +00:00
|
|
|
fActionCancel.setIcon(cancel);
|
|
|
|
fActionCancel.setText("Clear Filter");
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2012-07-10 13:19:25 +00:00
|
|
|
fActionClose.setText("Exit");
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2012-07-10 13:19:25 +00:00
|
|
|
QIcon deleteIcon;
|
|
|
|
deleteIcon.addFile(QString::fromUtf8(":/images/Icons/delete.png"), QSize(),
|
2012-07-09 20:26:53 +00:00
|
|
|
QIcon::Normal, QIcon::Off);
|
2012-07-10 13:19:25 +00:00
|
|
|
fActionDelete.setIcon(deleteIcon);
|
|
|
|
fActionDelete.setText("Delete Command");
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2012-07-10 13:19:25 +00:00
|
|
|
QIcon directory;
|
|
|
|
directory.addFile(QString::fromUtf8(":/images/Icons/drawer-open-icon.png"),
|
2012-07-09 20:26:53 +00:00
|
|
|
QSize(), QIcon::Normal, QIcon::Off);
|
2012-07-10 13:19:25 +00:00
|
|
|
fActionDirectory.setIcon(directory);
|
|
|
|
fActionDirectory.setText("Toggle Directory");
|
2012-06-29 14:21:22 +00:00
|
|
|
|
|
|
|
QIcon inspector;
|
2012-07-09 20:26:53 +00:00
|
|
|
inspector.addFile(QString::fromUtf8(":/images/Icons/inspector.png"),
|
|
|
|
QSize(), QIcon::Normal, QIcon::Off);
|
2012-07-10 13:19:25 +00:00
|
|
|
fActionInspector.setIcon(inspector);
|
|
|
|
fActionInspector.setText("Toggle Inspector");
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2012-07-10 13:19:25 +00:00
|
|
|
QIcon play;
|
|
|
|
play.addFile(QString::fromUtf8(":/images/Icons/play.png"), QSize(),
|
2012-07-09 20:26:53 +00:00
|
|
|
QIcon::Normal, QIcon::Off);
|
2012-07-10 13:19:25 +00:00
|
|
|
fActionPlay.setIcon(play);
|
|
|
|
fActionPlay.setText("Play");
|
2012-06-29 14:21:22 +00:00
|
|
|
|
|
|
|
QIcon reload;
|
2012-07-09 20:26:53 +00:00
|
|
|
reload.addFile(QString::fromUtf8(":/images/Icons/reload.png"), QSize(),
|
|
|
|
QIcon::Normal, QIcon::Off);
|
2012-07-10 13:19:25 +00:00
|
|
|
fActionReload.setIcon(reload);
|
|
|
|
fActionReload.setText("Reset Picture");
|
|
|
|
|
|
|
|
QIcon rewind;
|
|
|
|
rewind.addFile(QString::fromUtf8(":/images/Icons/rewind.png"), QSize(),
|
|
|
|
QIcon::Normal, QIcon::Off);
|
|
|
|
fActionRewind.setIcon(rewind);
|
|
|
|
fActionRewind.setText("Rewind");
|
2012-06-29 14:21:22 +00:00
|
|
|
|
|
|
|
QIcon settings;
|
2012-07-09 20:26:53 +00:00
|
|
|
settings.addFile(QString::fromUtf8(":/images/Icons/settings.png"), QSize(),
|
|
|
|
QIcon::Normal, QIcon::Off);
|
2012-07-10 13:19:25 +00:00
|
|
|
fActionSettings.setIcon(settings);
|
|
|
|
fActionSettings.setText("Settings");
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2012-07-10 13:19:25 +00:00
|
|
|
QIcon stepBack;
|
|
|
|
stepBack.addFile(QString::fromUtf8(":/images/Icons/back.png"), QSize(),
|
2012-07-09 20:26:53 +00:00
|
|
|
QIcon::Normal, QIcon::Off);
|
2012-07-10 13:19:25 +00:00
|
|
|
fActionStepBack.setIcon(stepBack);
|
|
|
|
fActionStepBack.setText("Step Back");
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2012-07-10 13:19:25 +00:00
|
|
|
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);
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2012-07-10 13:19:25 +00:00
|
|
|
fFilter.addItem("--Filter By Available Commands--");
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2012-07-10 13:19:25 +00:00
|
|
|
fDirectoryWidget.setMaximumWidth(250);
|
|
|
|
fDirectoryWidget.setStyleSheet("QListWidget::Item {padding: 5px;}");
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2012-07-10 13:19:25 +00:00
|
|
|
fCanvasWidget.setSizePolicy(QSizePolicy::Expanding,
|
2012-07-09 20:26:53 +00:00
|
|
|
QSizePolicy::Expanding);
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2012-07-10 13:19:25 +00:00
|
|
|
fInspectorWidget.setSizePolicy(QSizePolicy::Expanding,
|
2012-07-09 20:26:53 +00:00
|
|
|
QSizePolicy::Expanding);
|
2012-07-10 13:19:25 +00:00
|
|
|
fInspectorWidget.setMaximumHeight(300);
|
|
|
|
|
|
|
|
fSettingsWidget.setSizePolicy(QSizePolicy::Expanding,
|
|
|
|
QSizePolicy::Expanding);
|
|
|
|
fSettingsWidget.setMaximumWidth(250);
|
|
|
|
fSettingsWidget.setHidden(true);
|
|
|
|
|
|
|
|
fLeftColumnLayout.setSpacing(6);
|
|
|
|
fLeftColumnLayout.addWidget(&fListWidget);
|
|
|
|
fLeftColumnLayout.addWidget(&fDirectoryWidget);
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2012-07-10 13:19:25 +00:00
|
|
|
fCanvasAndSettingsLayout.setSpacing(6);
|
|
|
|
fCanvasAndSettingsLayout.addWidget(&fCanvasWidget);
|
|
|
|
fCanvasAndSettingsLayout.addWidget(&fSettingsWidget);
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2012-07-10 13:19:25 +00:00
|
|
|
fMainAndRightColumnLayout.setSpacing(6);
|
|
|
|
fMainAndRightColumnLayout.addLayout(&fCanvasAndSettingsLayout);
|
|
|
|
fMainAndRightColumnLayout.addWidget(&fInspectorWidget);
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2012-07-10 13:19:25 +00:00
|
|
|
fContainerLayout.setSpacing(6);
|
|
|
|
fContainerLayout.setContentsMargins(11, 11, 11, 11);
|
|
|
|
fContainerLayout.addLayout(&fLeftColumnLayout);
|
|
|
|
fContainerLayout.addLayout(&fMainAndRightColumnLayout);
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2012-07-10 13:19:25 +00:00
|
|
|
SkDebuggerGUI->setCentralWidget(&fCentralWidget);
|
|
|
|
SkDebuggerGUI->setStatusBar(&fStatusBar);
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2012-07-10 13:19:25 +00:00
|
|
|
fToolBar.setIconSize(QSize(24, 24));
|
|
|
|
fToolBar.setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
|
|
|
|
SkDebuggerGUI->addToolBar(Qt::TopToolBarArea, &fToolBar);
|
2012-06-29 14:21:22 +00:00
|
|
|
|
|
|
|
QWidget *spacer = new QWidget();
|
|
|
|
spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
|
|
|
|
2012-07-10 13:19:25 +00:00
|
|
|
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);
|
2012-06-29 14:21:22 +00:00
|
|
|
|
|
|
|
// TODO(chudy): Remove static call.
|
|
|
|
fDirectoryWidgetActive = false;
|
2012-07-09 20:26:53 +00:00
|
|
|
fPath = "/usr/local/google/home/chudy/trunk-linux/debugger/skp";
|
2012-06-29 14:21:22 +00:00
|
|
|
setupDirectoryWidget();
|
|
|
|
fDirectoryWidgetActive = true;
|
|
|
|
|
|
|
|
// Menu Bar
|
2012-07-10 13:19:25 +00:00
|
|
|
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());
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2012-07-09 20:26:53 +00:00
|
|
|
fPause = false;
|
|
|
|
|
2012-07-10 13:19:25 +00:00
|
|
|
SkDebuggerGUI->setMenuBar(&fMenuBar);
|
2012-06-29 14:21:22 +00:00
|
|
|
QMetaObject::connectSlotsByName(SkDebuggerGUI);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SkDebuggerGUI::setupDirectoryWidget() {
|
2012-07-10 13:19:25 +00:00
|
|
|
QDir dir(fPath);
|
2012-06-29 14:21:22 +00:00
|
|
|
QRegExp r(".skp");
|
2012-07-10 13:19:25 +00:00
|
|
|
fDirectoryWidget.clear();
|
|
|
|
const QStringList files = dir.entryList();
|
2012-06-29 14:21:22 +00:00
|
|
|
foreach (QString f, files) {
|
2012-07-09 20:26:53 +00:00
|
|
|
if (f.contains(r))
|
2012-07-10 13:19:25 +00:00
|
|
|
fDirectoryWidget.addItem(f);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SkDebuggerGUI::loadPicture(QString fileName) {
|
2012-07-10 13:19:25 +00:00
|
|
|
fCanvasWidget.loadPicture(fileName);
|
|
|
|
std::vector<std::string> *cv = fCanvasWidget.getDrawCommands();
|
2012-07-09 20:26:53 +00:00
|
|
|
/* fDebugCanvas is reinitialized every load picture. Need it to retain value
|
|
|
|
* of the visibility filter. */
|
2012-07-10 13:19:25 +00:00
|
|
|
fCanvasWidget.toggleCurrentCommandFilter(
|
|
|
|
fSettingsWidget.getVisibilityButton()->isChecked());
|
2012-06-29 14:21:22 +00:00
|
|
|
setupListWidget(cv);
|
|
|
|
setupComboBox(cv);
|
2012-07-12 14:31:25 +00:00
|
|
|
fSettingsWidget.setDisabled(false);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SkDebuggerGUI::setupListWidget(std::vector<std::string>* cv) {
|
2012-07-10 13:19:25 +00:00
|
|
|
fListWidget.clear();
|
2012-06-29 14:21:22 +00:00
|
|
|
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);
|
2012-07-10 13:19:25 +00:00
|
|
|
fListWidget.addItem(item);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SkDebuggerGUI::setupComboBox(std::vector<std::string>* cv) {
|
2012-07-10 13:19:25 +00:00
|
|
|
fFilter.clear();
|
|
|
|
fFilter.addItem("--Filter By Available Commands--");
|
2012-06-29 14:21:22 +00:00
|
|
|
|
|
|
|
std::map<std::string, int> map;
|
|
|
|
for (unsigned int i = 0; i < cv->size(); i++) {
|
|
|
|
map[(*cv)[i]]++;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString overview;
|
|
|
|
int counter;
|
2012-07-09 20:26:53 +00:00
|
|
|
for (std::map<std::string, int>::iterator it = map.begin(); it != map.end();
|
|
|
|
++it) {
|
2012-06-29 14:21:22 +00:00
|
|
|
overview.append((it->first).c_str());
|
|
|
|
overview.append(": ");
|
|
|
|
overview.append(QString::number(it->second));
|
|
|
|
overview.append("<br/>");
|
2012-07-09 20:26:53 +00:00
|
|
|
counter += it->second;
|
2012-07-10 13:19:25 +00:00
|
|
|
fFilter.addItem((it->first).c_str());
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
QString total;
|
|
|
|
total.append("Total Draw Commands: ");
|
|
|
|
total.append(QString::number(counter));
|
|
|
|
total.append("<br/>");
|
|
|
|
overview.insert(0, total);
|
|
|
|
|
|
|
|
overview.append("<br/>");
|
|
|
|
overview.append("SkBitmap Width: ");
|
|
|
|
// NOTE(chudy): This is where we can pull out the SkPictures width.
|
2012-07-10 13:19:25 +00:00
|
|
|
overview.append(QString::number(fCanvasWidget.getBitmapWidth()));
|
2012-06-29 14:21:22 +00:00
|
|
|
overview.append("px<br/>");
|
|
|
|
overview.append("SkBitmap Height: ");
|
2012-07-10 13:19:25 +00:00
|
|
|
overview.append(QString::number(fCanvasWidget.getBitmapHeight()));
|
2012-06-29 14:21:22 +00:00
|
|
|
overview.append("px");
|
2012-07-10 13:19:25 +00:00
|
|
|
fInspectorWidget.setOverviewText(overview);
|
2012-06-29 14:21:22 +00:00
|
|
|
|
|
|
|
// NOTE(chudy): Makes first item unselectable.
|
2012-07-09 20:26:53 +00:00
|
|
|
QStandardItemModel* model = qobject_cast<QStandardItemModel*>(
|
2012-07-10 13:19:25 +00:00
|
|
|
fFilter.model());
|
|
|
|
QModelIndex firstIndex = model->index(0, fFilter.modelColumn(),
|
|
|
|
fFilter.rootModelIndex());
|
2012-06-29 14:21:22 +00:00
|
|
|
QStandardItem* firstItem = model->itemFromIndex(firstIndex);
|
|
|
|
firstItem->setSelectable(false);
|
|
|
|
}
|