From: Zack Rusin Date: Sat, 24 Sep 2011 23:39:59 +0000 (-0400) Subject: Add an option to indent the glsl code in the shader viewer. X-Git-Url: https://git.cworth.org/git?a=commitdiff_plain;h=ab347b0a2d3d70a4524494cf14130cf3ed10947e;p=apitrace Add an option to indent the glsl code in the shader viewer. Requires 'astyle' but works very well and makes reading wonky shaders a /lot/ easier. --- diff --git a/gui/glsledit.cpp b/gui/glsledit.cpp index 5c77882..f0e4613 100644 --- a/gui/glsledit.cpp +++ b/gui/glsledit.cpp @@ -961,4 +961,44 @@ void GLSLEdit::mark(const QString &str, Qt::CaseSensitivity sens) d_ptr->highlighter->mark(str, sens); } +void GLSLEdit::indent() +{ + QTemporaryFile file(QLatin1String("shader.glsl")); + if (!file.open()) { + qDebug()<<"Couldn't create temporary file "<addAction(tr("Indent Code"), this, SLOT(indent())); + + menu->exec(e->globalPos()); + delete menu; +} + #include "glsledit.moc" diff --git a/gui/glsledit.h b/gui/glsledit.h index e4412a2..1fc452a 100644 --- a/gui/glsledit.h +++ b/gui/glsledit.h @@ -89,10 +89,13 @@ public slots: void fold(int line); void unfold(int line); void toggleFold(int line); + void indent(); protected: - void resizeEvent(QResizeEvent *e); - void wheelEvent(QWheelEvent *e); + virtual void resizeEvent(QResizeEvent *e); + virtual void wheelEvent(QWheelEvent *e); + virtual void contextMenuEvent(QContextMenuEvent *e); + private slots: void updateCursor();