X-Git-Url: http://git.johnwright.org/?p=fmit.git;a=blobdiff_plain;f=src%2Fmodules%2FGLFreqStruct.cpp;fp=src%2Fmodules%2FGLFreqStruct.cpp;h=ac5fc3548832c148adde5a2214974fc5e81b83cc;hp=ca8464f494a2c207cd797fa2d1b2ce7ba812f599;hb=a8fb82288feb6b258f2c04312f0c36ba8d79b494;hpb=adfba0402927438a1869f1e716bcf0e25574ce1e diff --git a/src/modules/GLFreqStruct.cpp b/src/modules/GLFreqStruct.cpp index ca8464f..ac5fc35 100644 --- a/src/modules/GLFreqStruct.cpp +++ b/src/modules/GLFreqStruct.cpp @@ -171,29 +171,45 @@ static const unsigned char g_icon_formants[] = { using namespace std; #include #include +#include +#include #include #include using namespace Music; GLFreqStruct::GLFreqStruct(QWidget* parent) -: QGLWidget(parent, "GLFreqStruct") -, View("Harmonics", this) +: QGLWidget(parent) +, View(tr("Harmonics"), this) , m_components_max(1.0) { // settings - QImage img; + QPixmap img; img.loadFromData(g_icon_formants, sizeof(g_icon_formants), "PNG"); - setting_show->setIconSet(QIconSet(QImage(img))); - setting_show->setOn(false); + setting_show->setIcon(QIcon(img)); + setting_show->setChecked(false); hide(); - m_popup_menu.insertItem(new Title(tr("Number of harmonics"), &m_popup_menu)); - setting_spinNumComponents = new QSpinBox(1, 128, 1, &m_popup_menu); - setting_spinNumComponents->setValue(16); + QHBoxLayout* numComponentsActionLayout = new QHBoxLayout(&m_popup_menu); + + QLabel* numComponentsActionTitle = new QLabel(tr("Number of harmonics"), &m_popup_menu); + numComponentsActionLayout->addWidget(numComponentsActionTitle); + + setting_spinNumComponents = new QSpinBox(&m_popup_menu); + setting_spinNumComponents->setMinimum(1); + setting_spinNumComponents->setMaximum(128); + setting_spinNumComponents->setSingleStep(1); + setting_spinNumComponents->setValue(16); m_components.resize(setting_spinNumComponents->value()); - QToolTip::add(setting_spinNumComponents, tr("Number of harmonics")); + setting_spinNumComponents->setToolTip(tr("Number of harmonics")); connect(setting_spinNumComponents, SIGNAL(valueChanged(int)), this, SLOT(spinNumComponentsChanged(int))); - m_popup_menu.insertItem(setting_spinNumComponents); + numComponentsActionLayout->addWidget(setting_spinNumComponents); + + QWidget* numComponentsActionWidget = new QWidget(&m_popup_menu); + numComponentsActionWidget->setLayout(numComponentsActionLayout); + + QWidgetAction* numComponentsAction = new QWidgetAction(&m_popup_menu); + numComponentsAction->setDefaultWidget(numComponentsActionWidget); + m_popup_menu.addAction(numComponentsAction); for(size_t i=0; iwriteEntry("spinNumComponents", setting_spinNumComponents->value()); + s_settings->setValue("spinNumComponents", setting_spinNumComponents->value()); } void GLFreqStruct::load() { - setting_spinNumComponents->setValue(s_settings->readNumEntry("spinNumComponents", setting_spinNumComponents->value())); + setting_spinNumComponents->setValue(s_settings->value("spinNumComponents", setting_spinNumComponents->value()).toInt()); } void GLFreqStruct::clearSettings() { - s_settings->removeEntry("spinNumComponents"); + s_settings->remove("spinNumComponents"); } void GLFreqStruct::spinNumComponentsChanged(int num) @@ -235,11 +251,11 @@ void GLFreqStruct::paintGL() glClear(GL_COLOR_BUFFER_BIT); // name - string str = tr("Harmonics"); + string str = tr("Harmonics").toStdString(); glColor3f(0.75,0.75,0.75); glRasterPos2i(2, height()-20); for(size_t i = 0; i < str.size(); i++) - glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, str[i]); + glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, (unsigned char)str[i]); int scale_height = 12; @@ -273,10 +289,10 @@ void GLFreqStruct::paintGL() glRasterPos2i(int((i+0.5)*step)-3, 2); // string str = StringAddons::toString(i+1); - string str = QString::number(i+1); + string str = QString::number(i+1).toStdString(); for(size_t i = 0; i < str.size(); i++) - glutBitmapCharacter(GLUT_BITMAP_HELVETICA_10, str[i]); + glutBitmapCharacter(GLUT_BITMAP_HELVETICA_10, (unsigned char)str[i]); } glFlush();