code style
This commit is contained in:
parent
1a9b29a2ca
commit
51131cf2bd
|
@ -41,8 +41,8 @@ TrayIcon::TrayIcon():
|
||||||
void TrayIcon::initConextMenu()
|
void TrayIcon::initConextMenu()
|
||||||
{
|
{
|
||||||
m_settings = new SettingsDialog();
|
m_settings = new SettingsDialog();
|
||||||
QDialogButtonBox *box = new QDialogButtonBox(QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok|QDialogButtonBox::Reset, m_settings);
|
QDialogButtonBox *box = new QDialogButtonBox(QDialogButtonBox::Apply | QDialogButtonBox::Cancel | QDialogButtonBox::Ok | QDialogButtonBox::Reset, m_settings);
|
||||||
connect(box, &QDialogButtonBox::clicked,[&,box](QAbstractButton *button){
|
connect(box, &QDialogButtonBox::clicked, [ &, box](QAbstractButton * button) {
|
||||||
switch (box->buttonRole(button)) {
|
switch (box->buttonRole(button)) {
|
||||||
case QDialogButtonBox::AcceptRole:
|
case QDialogButtonBox::AcceptRole:
|
||||||
m_settings->accept();
|
m_settings->accept();
|
||||||
|
@ -63,7 +63,6 @@ void TrayIcon::initConextMenu()
|
||||||
});
|
});
|
||||||
m_settings->layout()->addWidget(box);
|
m_settings->layout()->addWidget(box);
|
||||||
|
|
||||||
|
|
||||||
// connect(m_settings, &SettingsDialog::finished, m_settings, &SettingsDialog::hide);
|
// connect(m_settings, &SettingsDialog::finished, m_settings, &SettingsDialog::hide);
|
||||||
|
|
||||||
m_trayIcon->setVisible(true);
|
m_trayIcon->setVisible(true);
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
|
|
||||||
using namespace Snore;
|
using namespace Snore;
|
||||||
|
|
||||||
|
|
||||||
Notification::Notification() :
|
Notification::Notification() :
|
||||||
d(NULL)
|
d(NULL)
|
||||||
{
|
{
|
||||||
|
|
|
@ -87,7 +87,7 @@ bool PluginContainer::isLoaded() const
|
||||||
void PluginContainer::updatePluginCache()
|
void PluginContainer::updatePluginCache()
|
||||||
{
|
{
|
||||||
snoreDebug(SNORE_DEBUG) << "Updating plugin cache";
|
snoreDebug(SNORE_DEBUG) << "Updating plugin cache";
|
||||||
for(auto list : s_pluginCache) {
|
for (auto list : s_pluginCache) {
|
||||||
foreach(PluginContainer * p, list.values()) {
|
foreach(PluginContainer * p, list.values()) {
|
||||||
delete p;
|
delete p;
|
||||||
}
|
}
|
||||||
|
|
|
@ -140,7 +140,6 @@ const QList<SnorePlugin::PluginTypes> &SnorePlugin::types()
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QDebug operator<<(QDebug debug, const Snore::SnorePlugin::PluginTypes &flags)
|
QDebug operator<<(QDebug debug, const Snore::SnorePlugin::PluginTypes &flags)
|
||||||
{
|
{
|
||||||
QMetaEnum e = SnorePlugin::staticMetaObject.enumerator(SnorePlugin::staticMetaObject.indexOfEnumerator("PluginType"));
|
QMetaEnum e = SnorePlugin::staticMetaObject.enumerator(SnorePlugin::staticMetaObject.indexOfEnumerator("PluginType"));
|
||||||
|
@ -164,7 +163,6 @@ QDebug operator<<(QDebug debug, const Snore::SnorePlugin::PluginTypes &flags)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QDataStream &operator<<(QDataStream &out, const Snore::SnorePlugin::PluginTypes &type)
|
QDataStream &operator<<(QDataStream &out, const Snore::SnorePlugin::PluginTypes &type)
|
||||||
{
|
{
|
||||||
out << static_cast<int>(type);
|
out << static_cast<int>(type);
|
||||||
|
|
|
@ -47,7 +47,6 @@ public:
|
||||||
static QString typeToString(const PluginTypes t);
|
static QString typeToString(const PluginTypes t);
|
||||||
static const QList<PluginTypes> &types();
|
static const QList<PluginTypes> &types();
|
||||||
|
|
||||||
|
|
||||||
SnorePlugin(const QString &name);
|
SnorePlugin(const QString &name);
|
||||||
virtual ~SnorePlugin();
|
virtual ~SnorePlugin();
|
||||||
virtual bool initialize();
|
virtual bool initialize();
|
||||||
|
@ -90,5 +89,4 @@ SNORE_EXPORT QDebug operator<<(QDebug, const Snore::SnorePlugin::PluginTypes &);
|
||||||
SNORE_EXPORT QDataStream &operator<<(QDataStream &out, const Snore::SnorePlugin::PluginTypes &type);
|
SNORE_EXPORT QDataStream &operator<<(QDataStream &out, const Snore::SnorePlugin::PluginTypes &type);
|
||||||
SNORE_EXPORT QDataStream &operator>>(QDataStream &in, Snore::SnorePlugin::PluginTypes &type);
|
SNORE_EXPORT QDataStream &operator>>(QDataStream &in, Snore::SnorePlugin::PluginTypes &type);
|
||||||
|
|
||||||
|
|
||||||
#endif//SNORE_PLUGINS_H
|
#endif//SNORE_PLUGINS_H
|
||||||
|
|
|
@ -43,11 +43,10 @@ SettingsDialog::~SettingsDialog()
|
||||||
void SettingsDialog::initTabs()
|
void SettingsDialog::initTabs()
|
||||||
{
|
{
|
||||||
SnorePlugin::PluginTypes types = SnoreCore::instance().value("PluginTypes", LOCAL_SETTING).value<SnorePlugin::PluginTypes>();
|
SnorePlugin::PluginTypes types = SnoreCore::instance().value("PluginTypes", LOCAL_SETTING).value<SnorePlugin::PluginTypes>();
|
||||||
if(types == SnorePlugin::NONE)
|
if (types == SnorePlugin::NONE) {
|
||||||
{
|
|
||||||
types = SnorePlugin::ALL;
|
types = SnorePlugin::ALL;
|
||||||
}
|
}
|
||||||
auto addWidgets = [&](QTabWidget *target, QWidget *container, SnorePlugin::PluginTypes type){
|
auto addWidgets = [&](QTabWidget * target, QWidget * container, SnorePlugin::PluginTypes type) {
|
||||||
bool enabled = false;
|
bool enabled = false;
|
||||||
target->clear();
|
target->clear();
|
||||||
if (types & type) {
|
if (types & type) {
|
||||||
|
@ -59,7 +58,7 @@ void SettingsDialog::initTabs()
|
||||||
}
|
}
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
if (ui->tabWidget->indexOf(container) == -1) {
|
if (ui->tabWidget->indexOf(container) == -1) {
|
||||||
ui->tabWidget->addTab(container,container->property("TAB_NAME").toString());
|
ui->tabWidget->addTab(container, container->property("TAB_NAME").toString());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
int index = ui->tabWidget->indexOf(container);
|
int index = ui->tabWidget->indexOf(container);
|
||||||
|
@ -76,9 +75,9 @@ void SettingsDialog::initTabs()
|
||||||
void Snore::SettingsDialog::on_pushButton_clicked()
|
void Snore::SettingsDialog::on_pushButton_clicked()
|
||||||
{
|
{
|
||||||
Application app = SnoreCorePrivate::instance()->defaultApplication();
|
Application app = SnoreCorePrivate::instance()->defaultApplication();
|
||||||
Notification noti(app, app.defaultAlert(),tr("Hello World"),
|
Notification noti(app, app.defaultAlert(), tr("Hello World"),
|
||||||
QString("<i>%1</i><br>"
|
QString("<i>%1</i><br>"
|
||||||
"<a href=\"https://github.com/Snorenotify/Snorenotify\">%2</a><br>").arg(tr("This is Snore"), tr("Project Website") ),
|
"<a href=\"https://github.com/Snorenotify/Snorenotify\">%2</a><br>").arg(tr("This is Snore"), tr("Project Website")),
|
||||||
app.icon());
|
app.icon());
|
||||||
noti.addAction(Action(1, tr("Test Action")));
|
noti.addAction(Action(1, tr("Test Action")));
|
||||||
SnoreCore::instance().broadcastNotification(noti);
|
SnoreCore::instance().broadcastNotification(noti);
|
||||||
|
|
|
@ -51,7 +51,6 @@ public:
|
||||||
//TODO: move to private header
|
//TODO: move to private header
|
||||||
void initTabs();
|
void initTabs();
|
||||||
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setVisible(bool b) override;
|
void setVisible(bool b) override;
|
||||||
void accept();
|
void accept();
|
||||||
|
|
|
@ -36,7 +36,7 @@ using namespace Snore;
|
||||||
SnoreCore::SnoreCore(QObject *parent):
|
SnoreCore::SnoreCore(QObject *parent):
|
||||||
QObject(parent)
|
QObject(parent)
|
||||||
{
|
{
|
||||||
if (QThread::currentThread() != parent->thread() ) {
|
if (QThread::currentThread() != parent->thread()) {
|
||||||
moveToThread(parent->thread());
|
moveToThread(parent->thread());
|
||||||
}
|
}
|
||||||
d_ptr = new SnoreCorePrivate();
|
d_ptr = new SnoreCorePrivate();
|
||||||
|
@ -48,7 +48,7 @@ SnoreCore::SnoreCore(QObject *parent):
|
||||||
SnoreCore &SnoreCore::instance()
|
SnoreCore &SnoreCore::instance()
|
||||||
{
|
{
|
||||||
static SnoreCore *instance = nullptr;
|
static SnoreCore *instance = nullptr;
|
||||||
if(!instance) {
|
if (!instance) {
|
||||||
SnoreCorePrivate::loadTranslator();
|
SnoreCorePrivate::loadTranslator();
|
||||||
SnoreCorePrivate::registerMetaTypes();
|
SnoreCorePrivate::registerMetaTypes();
|
||||||
instance = new SnoreCore(qApp);
|
instance = new SnoreCore(qApp);
|
||||||
|
@ -64,7 +64,7 @@ SnoreCore::~SnoreCore()
|
||||||
|
|
||||||
void SnoreCore::loadPlugins(SnorePlugin::PluginTypes types)
|
void SnoreCore::loadPlugins(SnorePlugin::PluginTypes types)
|
||||||
{
|
{
|
||||||
if (QThread::currentThread() != thread() ) {
|
if (QThread::currentThread() != thread()) {
|
||||||
snoreDebug(SNORE_DEBUG) << "Delayed Plugin loading." << QThread::currentThread() << thread();
|
snoreDebug(SNORE_DEBUG) << "Delayed Plugin loading." << QThread::currentThread() << thread();
|
||||||
QMetaObject::invokeMethod(this, "loadPlugins", Qt::BlockingQueuedConnection, Q_ARG(Snore::SnorePlugin::PluginTypes, types));
|
QMetaObject::invokeMethod(this, "loadPlugins", Qt::BlockingQueuedConnection, Q_ARG(Snore::SnorePlugin::PluginTypes, types));
|
||||||
return;
|
return;
|
||||||
|
@ -213,8 +213,8 @@ QList<PluginSettingsWidget *> SnoreCore::settingWidgets(SnorePlugin::PluginTypes
|
||||||
list.append(widget);
|
list.append(widget);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
qSort(list.begin(),list.end(),[](PluginSettingsWidget *a,PluginSettingsWidget *b){
|
qSort(list.begin(), list.end(), [](PluginSettingsWidget * a, PluginSettingsWidget * b) {
|
||||||
return a->name() < b->name();
|
return a->name() < b->name();
|
||||||
});
|
});
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
|
@ -173,7 +173,8 @@ void SnoreCorePrivate::syncSettings()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList SnoreCorePrivate::knownClients(){
|
QStringList SnoreCorePrivate::knownClients()
|
||||||
|
{
|
||||||
QStringList out;
|
QStringList out;
|
||||||
m_settings->beginGroup(versionSchema());
|
m_settings->beginGroup(versionSchema());
|
||||||
m_settings->beginGroup("LocalSettings");
|
m_settings->beginGroup("LocalSettings");
|
||||||
|
@ -234,22 +235,19 @@ void SnoreCorePrivate::slotAboutToQuit()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SnoreCorePrivate::loadTranslator(){
|
void SnoreCorePrivate::loadTranslator()
|
||||||
auto installTranslator = [](const QString &locale)
|
{
|
||||||
{
|
auto installTranslator = [](const QString & locale) {
|
||||||
snoreDebug(SNORE_DEBUG) << locale;
|
snoreDebug(SNORE_DEBUG) << locale;
|
||||||
if(locale != "C") {
|
if (locale != "C") {
|
||||||
QTranslator* translator = new QTranslator( qApp->instance() );
|
QTranslator *translator = new QTranslator(qApp->instance());
|
||||||
if ( translator->load(locale, ":/lang/libsnore/") )
|
if (translator->load(locale, ":/lang/libsnore/")) {
|
||||||
{
|
|
||||||
snoreDebug(SNORE_INFO) << "Using system locale:" << locale;
|
snoreDebug(SNORE_INFO) << "Using system locale:" << locale;
|
||||||
snoreDebug(SNORE_INFO) << qApp->installTranslator( translator );
|
snoreDebug(SNORE_INFO) << qApp->installTranslator(translator);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
translator->deleteLater();
|
translator->deleteLater();
|
||||||
QString fileName = QString(":/lang/libsnore/%1.qm").arg(locale);
|
QString fileName = QString(":/lang/libsnore/%1.qm").arg(locale);
|
||||||
snoreDebug(SNORE_WARNING)<< "Failed to load translations for:" << locale << fileName << QFile::exists(fileName) ;
|
snoreDebug(SNORE_WARNING) << "Failed to load translations for:" << locale << fileName << QFile::exists(fileName) ;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,7 +77,7 @@ public:
|
||||||
QString normalizeKey(const QString &key, SettingsType type) const
|
QString normalizeKey(const QString &key, SettingsType type) const
|
||||||
{
|
{
|
||||||
if (type == LOCAL_SETTING) {
|
if (type == LOCAL_SETTING) {
|
||||||
return QString("%1/LocalSettings/%2/%3").arg(versionSchema(),m_localSettingsPrefix, key);
|
return QString("%1/LocalSettings/%2/%3").arg(versionSchema(), m_localSettingsPrefix, key);
|
||||||
} else {
|
} else {
|
||||||
return QString("%1/%2").arg(versionSchema(), key);
|
return QString("%1/%2").arg(versionSchema(), key);
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ SnoreNotifier::SnoreNotifier():
|
||||||
|
|
||||||
SnoreNotifier::~SnoreNotifier()
|
SnoreNotifier::~SnoreNotifier()
|
||||||
{
|
{
|
||||||
for(auto w : m_widgets) {
|
for (auto w : m_widgets) {
|
||||||
w->deleteLater();
|
w->deleteLater();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ private slots:
|
||||||
private:
|
private:
|
||||||
|
|
||||||
QList<Snore::Notification> m_queue;
|
QList<Snore::Notification> m_queue;
|
||||||
QVector<NotifyWidget*> m_widgets;
|
QVector<NotifyWidget *> m_widgets;
|
||||||
QTimer *m_timer;
|
QTimer *m_timer;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
|
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui
|
||||||
|
{
|
||||||
class SettingsWindow;
|
class SettingsWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue