code style

This commit is contained in:
Patrick von Reth 2015-04-18 15:11:04 +02:00
parent 2dcde7b37a
commit 282f51da87
8 changed files with 22 additions and 20 deletions

View File

@ -31,7 +31,8 @@ static int debugLevel = 0;
static std::unique_ptr<QTextStream> logFile = std::unique_ptr<QTextStream>(); static std::unique_ptr<QTextStream> logFile = std::unique_ptr<QTextStream>();
static std::unique_ptr<QFile> file = std::unique_ptr<QFile>(); static std::unique_ptr<QFile> file = std::unique_ptr<QFile>();
static void init(){ static void init()
{
debugLevel = qgetenv("LIBSNORE_DEBUG_LVL").toInt(); debugLevel = qgetenv("LIBSNORE_DEBUG_LVL").toInt();
if (qgetenv("LIBSNORE_LOG_TO_FILE").toInt() == 1) { if (qgetenv("LIBSNORE_LOG_TO_FILE").toInt() == 1) {

View File

@ -32,9 +32,9 @@ using namespace Snore;
SnorePlugin::SnorePlugin(const QString &name) : SnorePlugin::SnorePlugin(const QString &name) :
m_name(name) m_name(name)
{ {
Q_ASSERT_X(thread() != qApp->thread(),Q_FUNC_INFO,"Plugin initialized in wrong thread"); Q_ASSERT_X(thread() != qApp->thread(), Q_FUNC_INFO, "Plugin initialized in wrong thread");
if (thread() != qApp->thread()) { if (thread() != qApp->thread()) {
snoreDebug(SNORE_WARNING) << "Plugin initialized in wrong thread."; snoreDebug(SNORE_WARNING) << "Plugin initialized in wrong thread.";
} }
setDefaultValue("Enabled", false, LOCAL_SETTING); setDefaultValue("Enabled", false, LOCAL_SETTING);
} }

View File

@ -112,5 +112,4 @@ private:
}; };
} }
#endif // SNORECOREPRIVATE_H #endif // SNORECOREPRIVATE_H

View File

@ -59,7 +59,7 @@ void Utils::raiseWindowToFront(qlonglong wid)
// Looks like qt is handling it on linux. // Looks like qt is handling it on linux.
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
int active = attatchToActiveProcess(); int active = attatchToActiveProcess();
SetWindowPos((HWND)wid, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE); SetWindowPos((HWND)wid, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
detatchActiveProcess(active); detatchActiveProcess(active);
#else #else
Q_UNUSED(wid); Q_UNUSED(wid);
@ -75,7 +75,7 @@ int Utils::attatchToActiveProcess()
void Utils::detatchActiveProcess(int idActive) void Utils::detatchActiveProcess(int idActive)
{ {
if (idActive!= -1) { if (idActive != -1) {
AttachThreadInput(GetCurrentThreadId(), idActive, FALSE); AttachThreadInput(GetCurrentThreadId(), idActive, FALSE);
} }
} }

View File

@ -25,8 +25,10 @@
#include <QTextDocument> #include <QTextDocument>
#include <QTextDocumentFragment> #include <QTextDocumentFragment>
namespace Snore { namespace Snore
class SNORE_EXPORT Utils : public QObject { {
class SNORE_EXPORT Utils : public QObject
{
Q_OBJECT Q_OBJECT
public: public:
Utils(QObject *parent = nullptr); Utils(QObject *parent = nullptr);
@ -83,8 +85,8 @@ public:
private: private:
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
static int attatchToActiveProcess(); static int attatchToActiveProcess();
static void detatchActiveProcess(int idActive); static void detatchActiveProcess(int idActive);
#endif #endif
}; };

View File

@ -49,12 +49,12 @@ void NotifyMyAndroid::slotNotify(Notification notification)
// TODO: use toHTML? // TODO: use toHTML?
QString data(QString("apikey=%1&application=%2&event=%3&description=%4&content-type=text/html") QString data(QString("apikey=%1&application=%2&event=%3&description=%4&content-type=text/html")
.arg(key, .arg(key,
notification.application().name(), notification.application().name(),
Utils::toPlainText(notification.title()), Utils::toPlainText(notification.title()),
Utils::toPlainText(notification.text()))); Utils::toPlainText(notification.text())));
QNetworkReply *reply = m_manager.post(request,data.toUtf8().constData()); QNetworkReply *reply = m_manager.post(request, data.toUtf8().constData());
connect(reply, &QNetworkReply::finished, [reply]() { connect(reply, &QNetworkReply::finished, [reply]() {
snoreDebug(SNORE_DEBUG) << reply->error(); snoreDebug(SNORE_DEBUG) << reply->error();
snoreDebug(SNORE_DEBUG) << reply->readAll(); snoreDebug(SNORE_DEBUG) << reply->readAll();

View File

@ -27,7 +27,7 @@ Sound::Sound():
SnoreSecondaryBackend("Sound", false), SnoreSecondaryBackend("Sound", false),
m_player(new QMediaPlayer(this)) m_player(new QMediaPlayer(this))
{ {
setDefaultValue("Volume",50); setDefaultValue("Volume", 50);
m_player->setVolume(value("Volume").toInt()); m_player->setVolume(value("Volume").toInt());
// connect(m_player,QMediaPlayer::positionChanged,[](qint64 pos){ // connect(m_player,QMediaPlayer::positionChanged,[](qint64 pos){
// snoreDebug(SNORE_DEBUG) << "Player: " << pos; // snoreDebug(SNORE_DEBUG) << "Player: " << pos;
@ -65,9 +65,9 @@ void Sound::slotNotify(Snore::Notification notification)
QTimer *timeout = new QTimer(this); QTimer *timeout = new QTimer(this);
timeout->setSingleShot(true); timeout->setSingleShot(true);
timeout->setInterval(notification.timeout() * 1000); timeout->setInterval(notification.timeout() * 1000);
connect(timeout, &QTimer::timeout, [this,timeout]{ connect(timeout, &QTimer::timeout, [this, timeout] {
m_player->stop(); m_player->stop();
timeout->deleteLater(); timeout->deleteLater();
}); });
} }
} }

View File

@ -30,7 +30,7 @@ SoundSettings::SoundSettings(SnorePlugin *snorePlugin, QWidget *parent) :
m_lineEditFileName(new QLineEdit), m_lineEditFileName(new QLineEdit),
m_spinBoxVolume(new QSpinBox) m_spinBoxVolume(new QSpinBox)
{ {
m_spinBoxVolume->setRange(0,100); m_spinBoxVolume->setRange(0, 100);
addRow(tr("Volume:"), m_spinBoxVolume); addRow(tr("Volume:"), m_spinBoxVolume);
addRow(tr("Audio file:"), m_lineEditFileName); addRow(tr("Audio file:"), m_lineEditFileName);