Moved systray-icon to its own plugin
This commit is contained in:
parent
aed1bfdcf4
commit
2e79d68ee3
11 changed files with 116 additions and 22 deletions
|
@ -1,4 +1,5 @@
|
||||||
TEMPLATE=subdirs
|
TEMPLATE=subdirs
|
||||||
SUBDIRS = Devices \
|
SUBDIRS = Devices \
|
||||||
|
Systray \
|
||||||
TouchInterface
|
TouchInterface
|
||||||
|
|
||||||
|
|
21
telldus-gui/Plugins/Systray/Systray.pro
Normal file
21
telldus-gui/Plugins/Systray/Systray.pro
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
# -------------------------------------------------
|
||||||
|
# Project created by QtCreator 2009-03-10T12:16:44
|
||||||
|
# -------------------------------------------------
|
||||||
|
QT += core \
|
||||||
|
gui
|
||||||
|
TARGET = SystrayIcon
|
||||||
|
TEMPLATE = lib
|
||||||
|
CONFIG += plugin
|
||||||
|
SOURCES += systrayicon.cpp \
|
||||||
|
systrayplugin.cpp
|
||||||
|
HEADERS += systrayplugin.h \
|
||||||
|
systrayicon.h
|
||||||
|
macx {
|
||||||
|
LIBS += -framework TelldusCore
|
||||||
|
DESTDIR = ../../TelldusCenter/TelldusCenter.app/Contents/Plugins
|
||||||
|
}
|
||||||
|
!macx {
|
||||||
|
LIBS += -ltelldus-core
|
||||||
|
DESTDIR = ../../TelldusCenter/Plugins
|
||||||
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include "systrayicon.h"
|
#include "systrayicon.h"
|
||||||
#include "telldus-core.h"
|
#include "telldus-core.h"
|
||||||
#include "tellduscenterapplication.h"
|
//#include "tellduscenterapplication.h"
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
42
telldus-gui/Plugins/Systray/systrayplugin.cpp
Normal file
42
telldus-gui/Plugins/Systray/systrayplugin.cpp
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
#include <QtCore>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QApplication>
|
||||||
|
#include "systrayplugin.h"
|
||||||
|
|
||||||
|
#include "../../TelldusGui/telldusgui.h"
|
||||||
|
#include "systrayicon.h"
|
||||||
|
|
||||||
|
class SystrayPluginPrivate {
|
||||||
|
public:
|
||||||
|
SystrayIcon *icon;
|
||||||
|
};
|
||||||
|
|
||||||
|
SystrayPlugin::SystrayPlugin( )
|
||||||
|
: QObject(),
|
||||||
|
TelldusCenterPlugin()
|
||||||
|
{
|
||||||
|
d = new SystrayPluginPrivate;
|
||||||
|
d->icon = new SystrayIcon(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
SystrayPlugin::~SystrayPlugin() {
|
||||||
|
delete d;
|
||||||
|
}
|
||||||
|
|
||||||
|
QIcon SystrayPlugin::iconForPage( const QString &page ) const {
|
||||||
|
return QIcon(":/images/devices.png");
|
||||||
|
}
|
||||||
|
|
||||||
|
QString SystrayPlugin::pluginName() const {
|
||||||
|
return "Systray icon";
|
||||||
|
}
|
||||||
|
|
||||||
|
QWidget *SystrayPlugin::widget( const QString &page, QWidget *parent ) const {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList SystrayPlugin::widgets() const {
|
||||||
|
return QStringList();
|
||||||
|
}
|
||||||
|
|
||||||
|
Q_EXPORT_PLUGIN2(SystrayInterface, SystrayPlugin)
|
28
telldus-gui/Plugins/Systray/systrayplugin.h
Normal file
28
telldus-gui/Plugins/Systray/systrayplugin.h
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
#ifndef SYSTRAYPLUGIN_H
|
||||||
|
#define SYSTRAYPLUGIN_H
|
||||||
|
|
||||||
|
#include <QtCore/QObject>
|
||||||
|
#include <QIcon>
|
||||||
|
#include "../../TelldusCenter/tellduscenterplugin.h"
|
||||||
|
|
||||||
|
class SystrayPluginPrivate;
|
||||||
|
|
||||||
|
class SystrayPlugin : public QObject, public TelldusCenterPlugin
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_INTERFACES(TelldusCenterPlugin)
|
||||||
|
public:
|
||||||
|
SystrayPlugin( );
|
||||||
|
virtual ~SystrayPlugin();
|
||||||
|
|
||||||
|
virtual QIcon iconForPage( const QString &page ) const;
|
||||||
|
virtual QString pluginName() const;
|
||||||
|
|
||||||
|
virtual QWidget *widget( const QString &page, QWidget *parent ) const;
|
||||||
|
virtual QStringList widgets() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
SystrayPluginPrivate *d;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SYSTRAYPLUGIN_H
|
|
@ -8,25 +8,24 @@ SOURCES += main.cpp \
|
||||||
mainwindow.cpp \
|
mainwindow.cpp \
|
||||||
tellduscenterapplication.cpp \
|
tellduscenterapplication.cpp \
|
||||||
autoupdater.cpp \
|
autoupdater.cpp \
|
||||||
systrayicon.cpp \
|
|
||||||
message.cpp
|
message.cpp
|
||||||
HEADERS += mainwindow.h \
|
HEADERS += mainwindow.h \
|
||||||
tellduscenterapplication.h \
|
tellduscenterapplication.h \
|
||||||
autoupdater.h \
|
autoupdater.h \
|
||||||
CocoaInitializer.h \
|
CocoaInitializer.h \
|
||||||
systrayicon.h \
|
|
||||||
message.h \
|
message.h \
|
||||||
tellduscenterplugin.h
|
tellduscenterplugin.h
|
||||||
RESOURCES += resource.qrc
|
RESOURCES += resource.qrc
|
||||||
TARGET = TelldusCenter
|
TARGET = TelldusCenter
|
||||||
macx {
|
macx {
|
||||||
# HEADERS += sparkleautoupdater.h
|
# HEADERS += sparkleautoupdater.h
|
||||||
LIBS += -framework \
|
LIBS += -framework \
|
||||||
TelldusCore
|
TelldusCore
|
||||||
# -framework \
|
|
||||||
# Sparkle
|
# -framework \
|
||||||
# OBJECTIVE_SOURCES += SparkleAutoUpdater.mm \
|
# Sparkle
|
||||||
# CocoaInitializer.mm
|
# OBJECTIVE_SOURCES += SparkleAutoUpdater.mm \
|
||||||
|
# CocoaInitializer.mm
|
||||||
QMAKE_INFO_PLIST = Info.plist
|
QMAKE_INFO_PLIST = Info.plist
|
||||||
ICON = TelldusCenter.icns
|
ICON = TelldusCenter.icns
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,15 +15,19 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
|
|
||||||
TelldusCenterApplication application(argc, argv);
|
TelldusCenterApplication application(argc, argv);
|
||||||
|
QCoreApplication::setLibraryPaths( QStringList( QCoreApplication::applicationDirPath() ) );
|
||||||
|
application.loadPlugins();
|
||||||
|
application.loadScripts();
|
||||||
|
|
||||||
application.showMainWindow();
|
application.showMainWindow();
|
||||||
|
|
||||||
#ifdef Q_WS_MAC
|
#ifdef Q_WS_MAC
|
||||||
AutoUpdater* updater = 0;
|
/* AutoUpdater* updater = 0;
|
||||||
CocoaInitializer initializer;
|
CocoaInitializer initializer;
|
||||||
updater = new SparkleAutoUpdater("file:///Users/micke/Documents/dev/appcast.xml");
|
updater = new SparkleAutoUpdater("file:///Users/micke/Documents/dev/appcast.xml");
|
||||||
if (updater) {
|
if (updater) {
|
||||||
//updater->checkForUpdates();
|
//updater->checkForUpdates();
|
||||||
}
|
}*/
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return application.exec();
|
return application.exec();
|
||||||
|
|
|
@ -118,7 +118,9 @@ void MainWindow::setupToolBar()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
ag->actions().first()->setChecked( true );
|
if (!ag->actions().empty()) {
|
||||||
|
ag->actions().first()->setChecked( true );
|
||||||
|
}
|
||||||
d->pagesBar->addActions( ag->actions() );
|
d->pagesBar->addActions( ag->actions() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,6 @@ typedef QList<TelldusCenterPlugin *> PluginList;
|
||||||
|
|
||||||
class TelldusCenterApplicationPrivate {
|
class TelldusCenterApplicationPrivate {
|
||||||
public:
|
public:
|
||||||
SystrayIcon *systrayIcon;
|
|
||||||
PluginList plugins;
|
PluginList plugins;
|
||||||
QPointer<MainWindow> mainWindow;
|
QPointer<MainWindow> mainWindow;
|
||||||
QScriptEngine scriptEngine;
|
QScriptEngine scriptEngine;
|
||||||
|
@ -26,9 +25,6 @@ TelldusCenterApplication::TelldusCenterApplication(int &argc, char **argv)
|
||||||
:QApplication(argc, argv)
|
:QApplication(argc, argv)
|
||||||
{
|
{
|
||||||
d = new TelldusCenterApplicationPrivate;
|
d = new TelldusCenterApplicationPrivate;
|
||||||
d->systrayIcon = new SystrayIcon( this );
|
|
||||||
|
|
||||||
connect(d->systrayIcon, SIGNAL(showEventMessage(const QString &, const QString &, const QString &)), this, SLOT(showMessage(QString,QString,QString)));
|
|
||||||
|
|
||||||
setQuitOnLastWindowClosed( false );
|
setQuitOnLastWindowClosed( false );
|
||||||
|
|
||||||
|
@ -37,8 +33,6 @@ TelldusCenterApplication::TelldusCenterApplication(int &argc, char **argv)
|
||||||
tdInit();
|
tdInit();
|
||||||
tdRegisterDeviceEvent( &TelldusCenterApplication::deviceEvent, 0 );
|
tdRegisterDeviceEvent( &TelldusCenterApplication::deviceEvent, 0 );
|
||||||
|
|
||||||
loadPlugins();
|
|
||||||
loadScripts();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TelldusCenterApplication::~TelldusCenterApplication() {
|
TelldusCenterApplication::~TelldusCenterApplication() {
|
||||||
|
@ -48,6 +42,9 @@ TelldusCenterApplication::~TelldusCenterApplication() {
|
||||||
}
|
}
|
||||||
|
|
||||||
PluginList TelldusCenterApplication::plugins() const {
|
PluginList TelldusCenterApplication::plugins() const {
|
||||||
|
if (d->plugins.empty()) {
|
||||||
|
return PluginList();
|
||||||
|
}
|
||||||
return d->plugins;
|
return d->plugins;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,7 +82,7 @@ void TelldusCenterApplication::showMessage( const QString &title, const QString
|
||||||
if (isMainWindowShown()) {
|
if (isMainWindowShown()) {
|
||||||
d->mainWindow->showMessage(title, message, detailedMessage);
|
d->mainWindow->showMessage(title, message, detailedMessage);
|
||||||
} else {
|
} else {
|
||||||
d->systrayIcon->showMessage((title != "" ? title : "Telldus Center"), message, QSystemTrayIcon::Warning);
|
//d->systrayIcon->showMessage((title != "" ? title : "Telldus Center"), message, QSystemTrayIcon::Warning);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,7 +105,7 @@ void TelldusCenterApplication::loadPlugins() {
|
||||||
if (!pluginsDir.cd("plugins")) {
|
if (!pluginsDir.cd("plugins")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this->addLibraryPath( pluginsDir.absolutePath() );
|
this->setLibraryPaths( QStringList(pluginsDir.absolutePath()) );
|
||||||
|
|
||||||
foreach (QString fileName, pluginsDir.entryList(QDir::Files)) {
|
foreach (QString fileName, pluginsDir.entryList(QDir::Files)) {
|
||||||
QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
|
QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
//#incldue
|
//#incldue
|
||||||
|
|
||||||
#include "systrayicon.h"
|
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
|
||||||
class TelldusCenterPlugin;
|
class TelldusCenterPlugin;
|
||||||
|
@ -28,6 +27,9 @@ public:
|
||||||
void showMainWindow();
|
void showMainWindow();
|
||||||
bool isMainWindowShown();
|
bool isMainWindowShown();
|
||||||
|
|
||||||
|
void loadPlugins();
|
||||||
|
void loadScripts();
|
||||||
|
|
||||||
static TelldusCenterApplication *instance();
|
static TelldusCenterApplication *instance();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
@ -42,9 +44,7 @@ private slots:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void deviceEvent(int deviceId, int method, const char *data, int callbackId, void *context);
|
static void deviceEvent(int deviceId, int method, const char *data, int callbackId, void *context);
|
||||||
void loadPlugins();
|
|
||||||
void loadPlugin(QObject *plugin);
|
void loadPlugin(QObject *plugin);
|
||||||
void loadScripts();
|
|
||||||
|
|
||||||
TelldusCenterApplicationPrivate *d;
|
TelldusCenterApplicationPrivate *d;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue