aboutsummaryrefslogtreecommitdiffhomepage
path: root/debugger
diff options
context:
space:
mode:
authorGravatar chudy@google.com <chudy@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-08-14 19:34:13 +0000
committerGravatar chudy@google.com <chudy@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-08-14 19:34:13 +0000
commit6bd109a39370d21bfd4b48f5a28df8bcfc7f5ba2 (patch)
tree2ea29b12bb111e831dad3f687f19aaf5e3c0365b /debugger
parent40fbb1810a1bbd53b56afaad8bb5ceee825a337d (diff)
Refactored inspector widget such that creating custom tabs for information is straightforward for future developers.
Review URL: https://codereview.appspot.com/6463046 git-svn-id: http://skia.googlecode.com/svn/trunk@5093 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'debugger')
-rw-r--r--debugger/QT/SkDebuggerGUI.cpp4
-rw-r--r--debugger/QT/SkInspectorWidget.cpp42
-rw-r--r--debugger/QT/SkInspectorWidget.h41
3 files changed, 44 insertions, 43 deletions
diff --git a/debugger/QT/SkDebuggerGUI.cpp b/debugger/QT/SkDebuggerGUI.cpp
index 6075df0430..f5c78d6ead 100644
--- a/debugger/QT/SkDebuggerGUI.cpp
+++ b/debugger/QT/SkDebuggerGUI.cpp
@@ -310,7 +310,7 @@ void SkDebuggerGUI::registerListClick(QListWidgetItem *item) {
info.append(QString((*currInfo)[i]->c_str()));
info.append("<br/>");
}
- fInspectorWidget.setDetailText(info);
+ fInspectorWidget.setText(info, SkInspectorWidget::kDetail_TabType);
fInspectorWidget.setDisabled(false);
}
}
@@ -649,7 +649,7 @@ void SkDebuggerGUI::setupComboBox(SkTDArray<SkString*>* command) {
overview.append("SkPicture Height: ");
overview.append(QString::number(fDebugger.pictureHeight()));
overview.append("px");
- fInspectorWidget.setOverviewText(overview);
+ fInspectorWidget.setText(overview, SkInspectorWidget::kOverview_TabType);
// NOTE(chudy): Makes first item unselectable.
QStandardItemModel* model = qobject_cast<QStandardItemModel*>(
diff --git a/debugger/QT/SkInspectorWidget.cpp b/debugger/QT/SkInspectorWidget.cpp
index e09c25bb8d..6cf121241a 100644
--- a/debugger/QT/SkInspectorWidget.cpp
+++ b/debugger/QT/SkInspectorWidget.cpp
@@ -12,10 +12,6 @@
SkInspectorWidget::SkInspectorWidget() : QWidget()
, fHorizontalLayout(this)
- , fOverviewTab()
- , fOverviewLayout(&fOverviewTab)
- , fDetailTab()
- , fDetailLayout(&fDetailTab)
, fMatrixAndClipWidget(this)
, fVerticalLayout(&fMatrixAndClipWidget)
, fMatrixLabel(this)
@@ -24,20 +20,18 @@ SkInspectorWidget::SkInspectorWidget() : QWidget()
fHorizontalLayout.setSpacing(6);
fHorizontalLayout.setContentsMargins(11, 11, 11, 11);
- fOverviewLayout.setSpacing(6);
- fOverviewLayout.setContentsMargins(11, 11, 11, 11);
-
- fOverviewText.setReadOnly(true);
- fOverviewLayout.addWidget(&fOverviewText);
-
- fDetailLayout.setSpacing(6);
- fDetailLayout.setContentsMargins(11,11,11,11);
-
- fDetailText.setReadOnly(true);
- fDetailLayout.addWidget(&fDetailText);
-
- fTabWidget.addTab(&fOverviewTab, QString("Overview"));
- fTabWidget.addTab(&fDetailTab, QString("Details"));
+ QString tabNames[kTotalTabCount];
+ tabNames[kOverview_TabType] = "Overview";
+ tabNames[kDetail_TabType] = "Details";
+
+ for (int i = 0; i < kTotalTabCount; i++) {
+ fTabTexts[i].setReadOnly(true);
+ fTabLayouts[i].setSpacing(6);
+ fTabLayouts[i].setContentsMargins(11, 11, 11, 11);
+ fTabLayouts[i].addWidget(&fTabTexts[i]);
+ fTabs[i].setLayout(&fTabLayouts[i]);
+ fTabWidget.addTab(&fTabs[i], tabNames[i]);
+ }
fHorizontalLayout.setAlignment(Qt::AlignTop);
fHorizontalLayout.addWidget(&fTabWidget);
@@ -46,9 +40,7 @@ SkInspectorWidget::SkInspectorWidget() : QWidget()
* by adding them to horizontal layouts.
*
* We will have 1 big vertical layout, 3 horizontal layouts and then 3
- * line edits in each horizontal layout.
- */
-
+ * line edits in each horizontal layout. */
fMatrixAndClipWidget.setFixedSize(260,300);
fMatrixAndClipWidget.setDisabled(true);
@@ -58,12 +50,8 @@ SkInspectorWidget::SkInspectorWidget() : QWidget()
fHorizontalLayout.addWidget(&fMatrixAndClipWidget);
}
-void SkInspectorWidget::setDetailText(QString text) {
- fDetailText.setHtml(text);
-}
-
-void SkInspectorWidget::setOverviewText(QString text) {
- fOverviewText.setHtml(text);
+void SkInspectorWidget::setText(QString text, TabType type) {
+ fTabTexts[type].setHtml(text);
}
void SkInspectorWidget::setMatrix(const SkMatrix& matrix) {
diff --git a/debugger/QT/SkInspectorWidget.h b/debugger/QT/SkInspectorWidget.h
index 78a834406b..1b962356f7 100644
--- a/debugger/QT/SkInspectorWidget.h
+++ b/debugger/QT/SkInspectorWidget.h
@@ -28,6 +28,12 @@ class SkInspectorWidget : public QWidget {
Q_OBJECT
public:
+ enum TabType {
+ kOverview_TabType,
+ kDetail_TabType,
+ kTotalTabCount,
+ };
+
/**
Constructs a widget with the specified parent for layout purposes.
@param parent The parent container of this widget
@@ -37,17 +43,12 @@ public:
void setDisabled(bool isDisabled) {
fMatrixAndClipWidget.setDisabled(isDisabled);
}
- /**
- Sets the text in the detail tab.
- @param text
- */
- void setDetailText(QString text);
/**
- Sets the text in the overview tab.
+ Sets the text in tab at the specified index.
@param text
*/
- void setOverviewText(QString text);
+ void setText(QString text, TabType type);
/**
Sets the text in the current matrix.
@@ -61,17 +62,29 @@ public:
*/
void setClip(const SkIRect& clip);
+ class Tab : public QWidget {
+ QWidget fTab;
+ QHBoxLayout fTabLayout;
+ QTextEdit fTabText;
+ QString fName;
+
+ Tab(const char* name) {
+ fTabText.setReadOnly(true);
+ fTabLayout.setSpacing(6);
+ fTabLayout.setContentsMargins(11, 11, 11, 11);
+ fTabLayout.addWidget(&fTabText);
+ fTab.setLayout(&fTabLayout);
+ fName = QString(name);
+ }
+ };
+
private:
QHBoxLayout fHorizontalLayout;
QTabWidget fTabWidget;
- QWidget fOverviewTab;
- QHBoxLayout fOverviewLayout;
- QTextEdit fOverviewText;
-
- QWidget fDetailTab;
- QHBoxLayout fDetailLayout;
- QTextEdit fDetailText;
+ QWidget fTabs[kTotalTabCount];
+ QHBoxLayout fTabLayouts[kTotalTabCount];
+ QTextEdit fTabTexts[kTotalTabCount];
QWidget fMatrixAndClipWidget;
QVBoxLayout fVerticalLayout;