Skip to content

Commit

Permalink
[fix]修复保存音量失败的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
itisyang committed Jun 24, 2018
1 parent 8a3f614 commit 2825703
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
10 changes: 6 additions & 4 deletions playerdemo/globalhelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

#include "globalhelper.h"

const QString PLAYER_CONFIG_BASEDIR = QDir::tempPath();

const QString PLAYER_CONFIG = "player_config.ini";

GlobalHelper::GlobalHelper()
Expand Down Expand Up @@ -42,7 +44,7 @@ void GlobalHelper::SetIcon(QPushButton* btn, int iconSize, QChar icon)
void GlobalHelper::SavePlaylist(QStringList& playList)
{
//QString strPlayerConfigFileName = QCoreApplication::applicationDirPath() + QDir::separator() + PLAYER_CONFIG;
QString strPlayerConfigFileName = QDir::tempPath() + QDir::separator() + PLAYER_CONFIG;
QString strPlayerConfigFileName = PLAYER_CONFIG_BASEDIR + QDir::separator() + PLAYER_CONFIG;
QSettings settings(strPlayerConfigFileName, QSettings::IniFormat);
settings.beginWriteArray("playlist");
for (int i = 0; i < playList.size(); ++i)
Expand All @@ -56,7 +58,7 @@ void GlobalHelper::SavePlaylist(QStringList& playList)
void GlobalHelper::GetPlaylist(QStringList& playList)
{
//QString strPlayerConfigFileName = QCoreApplication::applicationDirPath() + QDir::separator() + PLAYER_CONFIG;
QString strPlayerConfigFileName = QDir::tempPath() + QDir::separator() + PLAYER_CONFIG;
QString strPlayerConfigFileName = PLAYER_CONFIG_BASEDIR + QDir::separator() + PLAYER_CONFIG;
QSettings settings(strPlayerConfigFileName, QSettings::IniFormat);

int size = settings.beginReadArray("playlist");
Expand All @@ -70,14 +72,14 @@ void GlobalHelper::GetPlaylist(QStringList& playList)

void GlobalHelper::SavePlayVolume(double& nVolume)
{
QString strPlayerConfigFileName = QCoreApplication::applicationDirPath() + QDir::separator() + PLAYER_CONFIG;
QString strPlayerConfigFileName = PLAYER_CONFIG_BASEDIR + QDir::separator() + PLAYER_CONFIG;
QSettings settings(strPlayerConfigFileName, QSettings::IniFormat);
settings.setValue("volume/size", nVolume);
}

void GlobalHelper::GetPlayVolume(double& nVolume)
{
QString strPlayerConfigFileName = QCoreApplication::applicationDirPath() + QDir::separator() + PLAYER_CONFIG;
QString strPlayerConfigFileName = PLAYER_CONFIG_BASEDIR + QDir::separator() + PLAYER_CONFIG;
QSettings settings(strPlayerConfigFileName, QSettings::IniFormat);
QString str = settings.value("volume/size").toString();
nVolume = settings.value("volume/size", nVolume).toDouble();
Expand Down
13 changes: 8 additions & 5 deletions playerdemo/mainwid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@ MainWid::~MainWid()

bool MainWid::Init()
{

//连接自定义信号与槽
if (ConnectSignalSlots() == false)
{
return false;
}

if (ui->CtrlBarWid->Init() == false ||
ui->PlaylistWid->Init() == false ||
ui->ShowWid->Init() == false ||
Expand All @@ -92,11 +99,7 @@ bool MainWid::Init()
return false;
}

//连接自定义信号与槽
if (ConnectSignalSlots() == false)
{
return false;
}


return true;
}
Expand Down

0 comments on commit 2825703

Please sign in to comment.