Some cleanup

* removed audio utils from blackmiscfreefunctions (we wanna give it up)
* comments
* formatting
This commit is contained in:
Klaus Basan
2015-12-19 03:33:46 +01:00
parent 3ac32fa58e
commit 8aa449bc13
11 changed files with 67 additions and 46 deletions

View File

@@ -277,7 +277,7 @@ namespace BlackCore
if (!liveriesJson.isEmpty()) if (!liveriesJson.isEmpty())
{ {
CLiveryList liveries; CLiveryList liveries;
liveries.convertFromJson(Json::jsonObjectFromString(liveriesJson)); liveries.convertFromJson(liveriesJson);
int c = liveries.size(); int c = liveries.size();
{ {
QWriteLocker l(&m_lockLivery); QWriteLocker l(&m_lockLivery);

View File

@@ -8,6 +8,7 @@
*/ */
#include "blackcore/contextaudio.h" #include "blackcore/contextaudio.h"
#include "blackmisc/audio/audioutils.h"
#include "audiovolumecomponent.h" #include "audiovolumecomponent.h"
#include "ui_audiovolumecomponent.h" #include "ui_audiovolumecomponent.h"

View File

@@ -22,7 +22,6 @@ namespace BlackGui
{ {
namespace Components namespace Components
{ {
//! Audio volume, mixer //! Audio volume, mixer
class BLACKGUI_EXPORT CAudioVolumeComponent : class BLACKGUI_EXPORT CAudioVolumeComponent :
public QFrame, public QFrame,
@@ -62,9 +61,7 @@ namespace BlackGui
private: private:
QScopedPointer<Ui::CAudioVolumeComponent> ui; QScopedPointer<Ui::CAudioVolumeComponent> ui;
}; };
} // namespace } // namespace
} // namespace } // namespace

View File

@@ -14,6 +14,7 @@
#include "blackcore/contextapplication.h" #include "blackcore/contextapplication.h"
#include "blackcore/contextaudio.h" #include "blackcore/contextaudio.h"
#include "blackcore/simulator.h" #include "blackcore/simulator.h"
#include "blackmisc/audio/audioutils.h"
#include "blackmisc/project.h" #include "blackmisc/project.h"
#include "blackmisc/icons.h" #include "blackmisc/icons.h"

View File

@@ -53,11 +53,11 @@ namespace BlackGui
bool m_enabled = true; bool m_enabled = true;
}; };
//! Model filter interface for those who can generate such a filter (e.g. a widget dialog) //! Model filter interface for those who can generate such a filter (e.g. a widget or dialog)
template<class ContainerType> class IModelFilterProvider template<class ContainerType> class IModelFilterProvider
{ {
public: public:
//! Get the filter //! Get the filter, this is the filter itself, not its widget or dialog
virtual std::unique_ptr<IModelFilter<ContainerType>> createModelFilter() const = 0; virtual std::unique_ptr<IModelFilter<ContainerType>> createModelFilter() const = 0;
}; };

View File

@@ -10,6 +10,7 @@
#include "audiodeviceinfo.h" #include "audiodeviceinfo.h"
#include "blackmisc/blackmiscfreefunctions.h" #include "blackmisc/blackmiscfreefunctions.h"
#include <tuple> #include <tuple>
#include <QHostInfo>
namespace BlackMisc namespace BlackMisc
{ {
@@ -18,12 +19,12 @@ namespace BlackMisc
CAudioDeviceInfo::CAudioDeviceInfo() : CAudioDeviceInfo::CAudioDeviceInfo() :
m_type(Unknown), m_deviceIndex(invalidDeviceIndex()), m_type(Unknown), m_deviceIndex(invalidDeviceIndex()),
m_deviceName(""), m_hostName(BlackMisc::localHostName()) m_deviceName(""), m_hostName(QHostInfo::localHostName())
{ } { }
CAudioDeviceInfo::CAudioDeviceInfo(DeviceType type, const int index, const QString &name) : CAudioDeviceInfo::CAudioDeviceInfo(DeviceType type, const int index, const QString &name) :
m_type(type), m_deviceIndex(index), m_type(type), m_deviceIndex(index),
m_deviceName(name), m_hostName(BlackMisc::localHostName()) m_deviceName(name), m_hostName(QHostInfo::localHostName())
{ } { }
QString CAudioDeviceInfo::convertToQString(bool i18n) const QString CAudioDeviceInfo::convertToQString(bool i18n) const

View File

@@ -37,11 +37,9 @@ namespace BlackMisc
Unknown Unknown
}; };
/*! //!
* Default constructor. //! Default constructor.
* If m_deviceIndex is -1, default should be used. However on Windows this doesnt work. Needs //! \note If m_deviceIndex is -1, default should be used. However on Windows this doesnt work. Needs to be checked in Vatlib.
* to be checked in Vatlib.
*/
CAudioDeviceInfo(); CAudioDeviceInfo();
//! Constructor. //! Constructor.
@@ -85,17 +83,11 @@ namespace BlackMisc
private: private:
BLACK_ENABLE_TUPLE_CONVERSION(CAudioDeviceInfo) BLACK_ENABLE_TUPLE_CONVERSION(CAudioDeviceInfo)
//! Device type, @see CAudioDeviceInfo::DeviceType
DeviceType m_type; DeviceType m_type; //!< Device type, @see CAudioDeviceInfo::DeviceType
/*! int m_deviceIndex; //!< deviceIndex is the number is the reference for the VVL. The device is selected by this index. The managing class needs to take care, that indexes are valid.
* deviceIndex is the number is the reference for the VVL. The device is selected by this index. QString m_deviceName; //!< Device name
* The managing class needs to take care, that indexes are valid. QString m_hostName; //!< We use a DBus based system. Hence an audio device can reside on a differen computers, this here is its name
*/
int m_deviceIndex;
//! Device name
QString m_deviceName;
//! We use a DBus based system. Hence an audio device can reside on a differen computers, this here is its name
QString m_hostName;
}; };
} // namespace } // namespace
} // namespace } // namespace

View File

@@ -0,0 +1,25 @@
/* Copyright (C) 2013
* swift project Community / Contributors
*
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
* including this file, may be copied, modified, propagated, or distributed except according to the terms
* contained in the LICENSE file.
*/
#include "audioutils.h"
#include "blackmisc/project.h"
#include <QProcess>
namespace BlackMisc
{
namespace Audio
{
bool startWindowsMixer()
{
if (!CProject::isRunningOnWindowsNtPlatform()) { return false; }
QStringList parameterlist;
return QProcess::startDetached("SndVol.exe", parameterlist);
}
} // ns
} // ns

View File

@@ -0,0 +1,26 @@
/* Copyright (C) 2015
* swift project Community / Contributors
*
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
* including this file, may be copied, modified, propagated, or distributed except according to the terms
* contained in the LICENSE file.
*/
//! \file
#ifndef BLACKMISC_AUDIO_UTILS_H
#define BLACKMISC_AUDIO_UTILS_H
#include "blackmisc/blackmiscexport.h"
namespace BlackMisc
{
namespace Audio
{
//! Start the Windows mixer
BLACKMISC_EXPORT bool startWindowsMixer();
}
}
#endif // guard

View File

@@ -60,7 +60,6 @@ uint BlackMisc::calculateHash(const QList<int> &values, const char *className)
uint s = 0; uint s = 0;
foreach(int i, values) foreach(int i, values)
{ {
if (i >= 0) if (i >= 0)
{ {
list.append(static_cast<uint>(i)); list.append(static_cast<uint>(i));
@@ -74,20 +73,8 @@ uint BlackMisc::calculateHash(const QList<int> &values, const char *className)
return calculateHash(list, className); return calculateHash(list, className);
} }
const QString &BlackMisc::localHostName()
{
static const QString hostName = QHostInfo::localHostName();
return hostName;
}
const QString &BlackMisc::localHostNameEnvVariable() const QString &BlackMisc::localHostNameEnvVariable()
{ {
static const QString hostName = QProcessEnvironment::systemEnvironment().value("COMPUTERNAME", QProcessEnvironment::systemEnvironment().value("HOSTNAME")); static const QString hostName = QProcessEnvironment::systemEnvironment().value("COMPUTERNAME", QProcessEnvironment::systemEnvironment().value("HOSTNAME"));
return hostName; return hostName;
} }
bool BlackMisc::Audio::startWindowsMixer()
{
QStringList parameterlist;
return QProcess::startDetached("SndVol.exe", parameterlist);
}

View File

@@ -35,12 +35,6 @@ inline void initBlackMiscResources()
//! Free functions in BlackMisc //! Free functions in BlackMisc
namespace BlackMisc namespace BlackMisc
{ {
namespace Audio
{
//! Start the Windows mixer
BLACKMISC_EXPORT bool startWindowsMixer();
}
//! Init resources //! Init resources
BLACKMISC_EXPORT void initResources(); BLACKMISC_EXPORT void initResources();
@@ -157,9 +151,6 @@ namespace BlackMisc
//! Hash value, but with int list //! Hash value, but with int list
BLACKMISC_EXPORT uint calculateHash(const QList<int> &values, const char *className); BLACKMISC_EXPORT uint calculateHash(const QList<int> &values, const char *className);
//! Get local host name
BLACKMISC_EXPORT const QString &localHostName();
//! Get local host name env.variable //! Get local host name env.variable
BLACKMISC_EXPORT const QString &localHostNameEnvVariable(); BLACKMISC_EXPORT const QString &localHostNameEnvVariable();