aboutsummaryrefslogtreecommitdiff
path: root/qmidiplayer.src.d/qmpinfowindow.cpp
diff options
context:
space:
mode:
authorGravatar Chris Xiong <chirs241097@gmail.com> 2016-04-06 09:46:52 +0800
committerGravatar Chris Xiong <chirs241097@gmail.com> 2016-04-06 09:46:52 +0800
commitcf7eafca1fbc9aae495d7b7d7e1fb4bc92e6819f (patch)
treed1881d513983a345936a547cbc25b8bd1a1f056e /qmidiplayer.src.d/qmpinfowindow.cpp
parentffd5bf0c99be3e4089886ab4757100474010edb8 (diff)
downloadQMidiPlayer-cf7eafca1fbc9aae495d7b7d7e1fb4bc92e6819f.tar.xz
Sometimes Naïve!
Diffstat (limited to 'qmidiplayer.src.d/qmpinfowindow.cpp')
-rw-r--r--qmidiplayer.src.d/qmpinfowindow.cpp57
1 files changed, 57 insertions, 0 deletions
diff --git a/qmidiplayer.src.d/qmpinfowindow.cpp b/qmidiplayer.src.d/qmpinfowindow.cpp
new file mode 100644
index 0000000..689a756
--- /dev/null
+++ b/qmidiplayer.src.d/qmpinfowindow.cpp
@@ -0,0 +1,57 @@
+#include <QTextCodec>
+#include "qmpinfowindow.hpp"
+#include "ui_qmpinfowindow.h"
+#include "qmpmainwindow.hpp"
+#include "qmpsettingswindow.hpp"
+
+const char* minors="abebbbf c g d a e b f#c#g#d#a#";
+const char* majors="CbGbDbAbEbBbF C G D A E B F#C#";
+const char* standards="? GM GM2GS XG ";
+
+qmpInfoWindow::qmpInfoWindow(QWidget *parent) :
+ QDialog(parent),
+ ui(new Ui::qmpInfoWindow)
+{
+ ui->setupUi(this);
+}
+
+qmpInfoWindow::~qmpInfoWindow()
+{
+ delete ui;
+}
+
+void qmpInfoWindow::updateInfo()
+{
+ char str[256];
+ CMidiPlayer* player=qmpMainWindow::getInstance()->getPlayer();
+ QSettings* settings=qmpSettingsWindow::getSettingsIntf();
+ ui->lbFileName->setText(QString("File name: ")+qmpMainWindow::getInstance()->getFileName());
+ if(player->getTitle())
+ {
+ if(settings->value("Midi/TextEncoding","").toString()!="Unicode")
+ ui->lbTitle->setText(QString("Title: ")+
+ QTextCodec::codecForName(settings->value("Midi/TextEncoding","").toString().toStdString().c_str())->toUnicode(player->getTitle()));
+ else
+ ui->lbTitle->setText(QString("Title: ")+player->getTitle());
+ }
+ else ui->lbTitle->setText(QString("Title: "));
+ if(player->getCopyright())
+ {
+ if(settings->value("Midi/TextEncoding","").toString()!="Unicode")
+ ui->lbCopyright->setText(QString("Copyright: ")+
+ QTextCodec::codecForName(settings->value("Midi/TextEncoding","").toString().toStdString().c_str())->toUnicode(player->getCopyright()));
+ else
+ ui->lbCopyright->setText(QString("Copyright: ")+player->getCopyright());
+ }
+ else ui->lbCopyright->setText(QString("Copyright: "));
+ ui->lbTempo->setText(QString("Tempo: ")+QString::number(player->getTempo(),'g',5));
+ int t,r;player->getCurrentKeySignature(&t);r=(int8_t)((t>>8)&0xFF)+7;
+ strncpy(str,t&0xFF?minors+2*r:majors+2*r,2);str[2]='\0';
+ ui->lbKeySig->setText(QString("Key Sig.: ")+str);
+ player->getCurrentTimeSignature(&t,&r);sprintf(str,"Time Sig.: %d/%d",t,r);
+ ui->lbTimeSig->setText(str);
+ sprintf(str,"Note count: %u",player->getFileNoteCount());
+ ui->lbNoteCount->setText(str);
+ strncpy(str,standards+player->getFileStandard()*3,3);str[3]='\0';
+ ui->lbFileStandard->setText(QString("File standard: ")+str);
+}