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