aboutsummaryrefslogtreecommitdiff
path: root/qmidiplayer-desktop
diff options
context:
space:
mode:
authorGravatar Chris Xiong <chirs241097@gmail.com> 2016-05-12 23:33:51 +0800
committerGravatar Chris Xiong <chirs241097@gmail.com> 2016-05-12 23:33:51 +0800
commita84ae874f0334172900d611fc098de8433f54e4c (patch)
tree4f2b185dfa734ad5cf2ede916a07573efe8a310a /qmidiplayer-desktop
parent59304aa1b2c6d278e76f72509183fee96bbb8cae (diff)
downloadQMidiPlayer-a84ae874f0334172900d611fc098de8433f54e4c.tar.xz
Now channel labels are displayed correctly.
Add an option to change the tint of the chequer board. Show unsigned integer options in hexadecimal format. Fixed a crash caused by attemting seeking when no file is being played.
Diffstat (limited to 'qmidiplayer-desktop')
-rw-r--r--qmidiplayer-desktop/qmpmainwindow.cpp1
-rw-r--r--qmidiplayer-desktop/qmpsettingswindow.cpp16
-rw-r--r--qmidiplayer-desktop/qmpsettingswindow.hpp36
3 files changed, 48 insertions, 5 deletions
diff --git a/qmidiplayer-desktop/qmpmainwindow.cpp b/qmidiplayer-desktop/qmpmainwindow.cpp
index c377010..762da0f 100644
--- a/qmidiplayer-desktop/qmpmainwindow.cpp
+++ b/qmidiplayer-desktop/qmpmainwindow.cpp
@@ -409,6 +409,7 @@ void qmpMainWindow::on_hsTimer_sliderReleased()
}
else
{
+ if(stopped){ui->hsTimer->setValue(0);}return;
player->setTCeptr(player->getStamp(ui->hsTimer->value()),ui->hsTimer->value());
offset=ui->hsTimer->value()/100.*player->getFtime();
char ts[100];
diff --git a/qmidiplayer-desktop/qmpsettingswindow.cpp b/qmidiplayer-desktop/qmpsettingswindow.cpp
index 81ac364..2d6912c 100644
--- a/qmidiplayer-desktop/qmpsettingswindow.cpp
+++ b/qmidiplayer-desktop/qmpsettingswindow.cpp
@@ -328,12 +328,19 @@ void qmpSettingsWindow::updateCustomOptions()
for(auto i=customOptions.begin();i!=customOptions.end();++i)
switch(i->second.type)
{
- case 0:case 1:
+ case 0:
{
QSpinBox* sb=(QSpinBox*)i->second.widget;if(!i->second.widget)break;
settings->setValue(QString(i->first.c_str()),sb->value());
break;
}
+ case 1:
+ {
+ QHexSpinBox* sb=(QHexSpinBox*)i->second.widget;if(!i->second.widget)break;
+ int v=sb->value();
+ settings->setValue(QString(i->first.c_str()),*reinterpret_cast<unsigned int*>(&v));
+ break;
+ }
case 2:
{
if(!i->second.widget)break;
@@ -418,7 +425,7 @@ void qmpSettingsWindow::registerOptionUint(std::string tab,std::string desc,std:
ui->tabWidget->addTab(w,QString(tab.c_str()));
customOptPages[tab]=page;
}
- QSpinBox* sb=new QSpinBox(page->parentWidget());
+ QHexSpinBox* sb=new QHexSpinBox(page->parentWidget());
QLabel* lb=new QLabel(desc.c_str(),page->parentWidget());
customOptions[key].widget=sb;
sb->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Fixed);
@@ -426,8 +433,7 @@ void qmpSettingsWindow::registerOptionUint(std::string tab,std::string desc,std:
int row=page->rowCount();
page->addWidget(lb,row,0);
page->addWidget(sb,row,1);
- sb->setMaximum(max);
- sb->setMinimum(min);
+ //sb->setMaximum(i(max));sb->setMinimum(i(min));
sb->setValue(settings->value(QString(key.c_str()),defaultval).toUInt());
}
}
@@ -439,7 +445,7 @@ void qmpSettingsWindow::setOptionUint(std::string key,unsigned val)
{
settings->setValue(QString(key.c_str()),val);
if(customOptions[key].widget)
- ((QSpinBox*)customOptions[key].widget)->setValue(val);
+ ((QHexSpinBox*)customOptions[key].widget)->setValue(val);
}
void qmpSettingsWindow::registerOptionBool(std::string tab,std::string desc,std::string key,bool defaultval)
diff --git a/qmidiplayer-desktop/qmpsettingswindow.hpp b/qmidiplayer-desktop/qmpsettingswindow.hpp
index efa69d5..3820279 100644
--- a/qmidiplayer-desktop/qmpsettingswindow.hpp
+++ b/qmidiplayer-desktop/qmpsettingswindow.hpp
@@ -7,6 +7,7 @@
#include <QSettings>
#include <QListWidget>
#include <QComboBox>
+#include <QSpinBox>
#include <QFormLayout>
#include "qmpplugin.hpp"
@@ -21,6 +22,41 @@ struct qmpCustomOption
QVariant defaultval,minv,maxv;
};
+class QHexSpinBox:public QSpinBox
+{
+ public:
+ QHexSpinBox(QWidget *parent=0):QSpinBox(parent)
+ {
+ setPrefix("0x");
+ setDisplayIntegerBase(16);
+ setRange(-0x80000000,0x7FFFFFFF);
+ }
+ protected:
+ QString textFromValue(int value)const
+ {
+ return QString::number(u(value),16).toUpper();
+ }
+ int valueFromText(const QString &text)const
+ {
+ return i(text.toUInt(0,16));
+ }
+ QValidator::State validate(QString &input,int &pos)const
+ {
+ QString t=input;
+ if(t.startsWith("0x"))t.remove(0,2);
+ pos-=t.size()-t.trimmed().size();t=t.trimmed();
+ if(t.isEmpty())return QValidator::Intermediate;
+ input=QString("0x")+t.toUpper();
+ bool okay;t.toUInt(&okay,16);
+ if(!okay)return QValidator::Invalid;
+ return QValidator::Acceptable;
+ }
+ inline unsigned int u(int i)const
+ {return *reinterpret_cast<unsigned int*>(&i);}
+ inline int i(unsigned int u)const
+ {return *reinterpret_cast<int*>(&u);}
+};
+
class qmpSettingsWindow:public QDialog
{
Q_OBJECT