style fixes

This commit is contained in:
Patrick von Reth 2015-07-29 16:16:21 +02:00
parent e555d36e56
commit 5edad0fe6f
5 changed files with 34 additions and 47 deletions

View File

@ -20,8 +20,6 @@ public:
instance.setSettingsValue(QLatin1String("Timeout"), 1, LOCAL_SETTING);
}
QString htmlTestString = QLatin1String("<i>Italic A</i><br>"
"<i>Italic B</i><br>"
"<b>Bold</b><br>"
@ -43,19 +41,19 @@ void SnoreBenchmark::benchmarkUtilsToHtml()
{
QCOMPARE(Utils::normalizeMarkup(htmlTestString, Utils::NO_MARKUP), QLatin1String("Italic A\n"
"Italic B\n"
"Bold\n"
"Underline\n"
"Font\n"
"<&>\n"
"Website\n"));
"Italic B\n"
"Bold\n"
"Underline\n"
"Font\n"
"<&>\n"
"Website\n"));
QCOMPARE(Utils::normalizeMarkup(htmlTestString, Utils::HREF), QLatin1String("Italic A\n"
"Italic B\n"
"Bold\n"
"Underline\n"
"Font\n"
"&lt;&amp;&gt;\n"
"<a href=\"https://github.com/Snorenotify/Snorenotify\">Website</a>\n"));
"Italic B\n"
"Bold\n"
"Underline\n"
"Font\n"
"&lt;&amp;&gt;\n"
"<a href=\"https://github.com/Snorenotify/Snorenotify\">Website</a>\n"));
QCOMPARE(Utils::normalizeMarkup(htmlTestString, Utils::HREF | Utils::BOLD | Utils::BREAK |
Utils::UNDERLINE | Utils::FONT | Utils::ITALIC), htmlTestString);
QBENCHMARK{
@ -83,23 +81,21 @@ void SnoreBenchmark::benchmarkNotifications()
{
SnoreCore &instance = SnoreCore::instance();
int closed = 0;
connect(&instance, SnoreCore::notificationClosed, [&closed](Notification)
{
connect(&instance, SnoreCore::notificationClosed, [&closed](Notification) {
closed++;
});
Application app = SnoreCorePrivate::instance()->defaultApplication();
// QBENCHMARK_ONCE{
for( int i=0; i<100; ++i)
{
QString number = QString::number(i);
Notification n(app, app.defaultAlert(), QLatin1String("Test ") + number, QLatin1String("Message ") + number, app.icon() );
instance.broadcastNotification(n);
}
// }
while(closed < 100){
QTest::qWait(100);
}
// QBENCHMARK_ONCE{
for (int i = 0; i < 100; ++i) {
QString number = QString::number(i);
Notification n(app, app.defaultAlert(), QLatin1String("Test ") + number, QLatin1String("Message ") + number, app.icon());
instance.broadcastNotification(n);
}
// }
while (closed < 100) {
QTest::qWait(100);
}
}

View File

@ -109,8 +109,7 @@ void SnoreCore::loadPlugins(SnorePlugin::PluginTypes types)
void SnoreCore::broadcastNotification(Notification notification)
{
Q_D(SnoreCore);
if(d->m_activeNotifications.size() > d->maxNumberOfActiveNotifications())
{
if (d->m_activeNotifications.size() > d->maxNumberOfActiveNotifications()) {
snoreDebug(SNORE_DEBUG) << "queue size:" << d->m_notificationQue.size() << "active size:" << d->m_activeNotifications.size();
d->m_notificationQue.append(notification);
return;
@ -124,8 +123,7 @@ void SnoreCore::broadcastNotification(Notification notification)
}
notification.data()->setBroadcasted();
notification.addActiveIn(this);
if(!d->m_notificationBackend)
{
if (!d->m_notificationBackend) {
d->startNotificationTimeoutTimer(notification);
}
emit d->notify(notification);

View File

@ -35,8 +35,7 @@ using namespace Snore;
SnoreCorePrivate::SnoreCorePrivate():
m_localSettingsPrefix(qApp->applicationName().isEmpty() ? QLatin1String("SnoreNotify") : qApp->applicationName())
{
if(!qgetenv("LIBSNORE_SETTINGS_FILE").isNull())
{
if (!qgetenv("LIBSNORE_SETTINGS_FILE").isNull()) {
m_settings = new QSettings(QString::fromUtf8(qgetenv("LIBSNORE_SETTINGS_FILE")), QSettings::IniFormat);
} else {
m_settings = new QSettings(QLatin1String("Snorenotify"), QLatin1String("libsnore"), this);
@ -226,12 +225,10 @@ void SnoreCorePrivate::slotNotificationClosed(Notification n)
{
Q_Q(SnoreCore);
emit q->notificationClosed(n);
if(!n.removeActiveIn(q))
{
if (!n.removeActiveIn(q)) {
snoreDebug(SNORE_WARNING) << n << "was already closed";
}
if(!m_notificationQue.isEmpty() && m_activeNotifications.size() < maxNumberOfActiveNotifications())
{
if (!m_notificationQue.isEmpty() && m_activeNotifications.size() < maxNumberOfActiveNotifications()) {
snoreDebug(SNORE_DEBUG) << "Broadcast from queue" << m_notificationQue.size();
q->broadcastNotification(m_notificationQue.takeFirst());
}

View File

@ -59,7 +59,7 @@ void listSettings(SettingsType type, const QString &application)
};
QString prefix = application;
if(application == QLatin1String("global")) {
if (application == QLatin1String("global")) {
prefix = QString();
}
cout << qPrintable(application) << endl;
@ -79,7 +79,6 @@ int main(int argc, char *argv[])
app.setOrganizationName(QLatin1String("SnoreNotify"));
app.setApplicationVersion(Snore::Version::version());
Snore::SnoreCore::instance().loadPlugins(Snore::SnorePlugin::ALL);
Snore::SnoreCorePrivate::instance()->defaultApplication().hints().setValue("use-markup", QVariant::fromValue(true));
@ -103,11 +102,10 @@ int main(int argc, char *argv[])
parser.process(app);
QString appName = parser.value(appNameCommand);
SettingsType type = GLOBAL_SETTING;
if(appName != QLatin1String("global")){
if (appName != QLatin1String("global")) {
type = LOCAL_SETTING;
}

View File

@ -37,7 +37,6 @@
using namespace Snore;
using namespace std;
void bringToFront(QString pid)
{
snoreDebug(SNORE_DEBUG) << pid;
@ -45,7 +44,7 @@ void bringToFront(QString pid)
auto findWindowForPid = [](ulong pid) {
// based on http://stackoverflow.com/a/21767578
pair<ulong, HWND> data = make_pair(pid, (HWND)0);
::EnumWindows((WNDENUMPROC)static_cast<BOOL(*)(HWND,LPARAM)>([](HWND handle, LPARAM lParam) -> BOOL {
::EnumWindows((WNDENUMPROC)static_cast<BOOL(*)(HWND, LPARAM)>([](HWND handle, LPARAM lParam) -> BOOL {
auto isMainWindow = [](HWND handle)
{
return ::GetWindow(handle, GW_OWNER) == (HWND)0 && IsWindowVisible(handle);
@ -124,15 +123,14 @@ int main(int argc, char *argv[])
Alert alert(parser.value(alertName), icon);
application.addAlert(alert);
if(parser.value(markup).toInt() == 1)
{
if (parser.value(markup).toInt() == 1) {
application.hints().setValue("use-markup", true);
}
core.registerApplication(application);
int prio = parser.value(priority).toInt();
if(prio < -2 || prio > 2){
if (prio < -2 || prio > 2) {
parser.showHelp(-1);
}
Notification n(application, alert, parser.value(title), parser.value(message), icon, Notification::defaultTimeout(), static_cast<Notification::Prioritys>(prio));
@ -151,7 +149,7 @@ int main(int argc, char *argv[])
if (parser.isSet(_bringProcessToFront)) {
bringToFront(parser.value(_bringProcessToFront));
} else if (parser.isSet(_bringWindowToFront)) {
Utils::bringWindowToFront((WId)parser.value(_bringWindowToFront).toULongLong(),true);
Utils::bringWindowToFront((WId)parser.value(_bringWindowToFront).toULongLong(), true);
}
}
returnCode = noti.closeReason();