blob: 88ed1b6c137207180dce0108ae9a362b63acfc78 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
#include "shaderssourcewidget.h"
#include "glsledit.h"
ShadersSourceWidget::ShadersSourceWidget(QWidget *parent)
: QWidget(parent)
{
m_ui.setupUi(this);
m_edit = new GLSLEdit(this);
m_edit->setReadOnly(true);
m_ui.verticalLayout->addWidget(m_edit);
connect(m_ui.shadersCB, SIGNAL(currentIndexChanged(const QString &)),
SLOT(changeShader(const QString &)));
}
void ShadersSourceWidget::setShaders(const QMap<QString, QString> &sources)
{
m_sources = sources;
m_ui.shadersCB->clear();
m_edit->clear();
if (m_sources.isEmpty()) {
m_ui.shadersCB->setDisabled(true);
m_edit->setPlainText(tr("No bound shaders."));
m_edit->setDisabled(true);
return;
}
m_ui.shadersCB->setEnabled(true);
m_edit->setEnabled(true);
QMap<QString, QString>::const_iterator itr;
for (itr = m_sources.constBegin(); itr != m_sources.constEnd(); ++itr) {
m_ui.shadersCB->addItem(itr.key());
}
m_ui.shadersCB->setCurrentIndex(0);
}
void ShadersSourceWidget::changeShader(const QString &key)
{
m_edit->setPlainText(m_sources.value(key));
}
#include "shaderssourcewidget.moc"
|