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
|
||||
SUBDIRS = Devices \
|
||||
Systray \
|
||||
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 "telldus-core.h"
|
||||
#include "tellduscenterapplication.h"
|
||||
//#include "tellduscenterapplication.h"
|
||||
|
||||
#include <QApplication>
|
||||
#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 \
|
||||
tellduscenterapplication.cpp \
|
||||
autoupdater.cpp \
|
||||
systrayicon.cpp \
|
||||
message.cpp
|
||||
HEADERS += mainwindow.h \
|
||||
tellduscenterapplication.h \
|
||||
autoupdater.h \
|
||||
CocoaInitializer.h \
|
||||
systrayicon.h \
|
||||
message.h \
|
||||
tellduscenterplugin.h
|
||||
RESOURCES += resource.qrc
|
||||
TARGET = TelldusCenter
|
||||
macx {
|
||||
# HEADERS += sparkleautoupdater.h
|
||||
# HEADERS += sparkleautoupdater.h
|
||||
LIBS += -framework \
|
||||
TelldusCore
|
||||
# -framework \
|
||||
# Sparkle
|
||||
# OBJECTIVE_SOURCES += SparkleAutoUpdater.mm \
|
||||
# CocoaInitializer.mm
|
||||
|
||||
# -framework \
|
||||
# Sparkle
|
||||
# OBJECTIVE_SOURCES += SparkleAutoUpdater.mm \
|
||||
# CocoaInitializer.mm
|
||||
QMAKE_INFO_PLIST = Info.plist
|
||||
ICON = TelldusCenter.icns
|
||||
}
|
||||
|
|
|
@ -15,15 +15,19 @@ int main(int argc, char *argv[])
|
|||
|
||||
|
||||
TelldusCenterApplication application(argc, argv);
|
||||
QCoreApplication::setLibraryPaths( QStringList( QCoreApplication::applicationDirPath() ) );
|
||||
application.loadPlugins();
|
||||
application.loadScripts();
|
||||
|
||||
application.showMainWindow();
|
||||
|
||||
#ifdef Q_WS_MAC
|
||||
AutoUpdater* updater = 0;
|
||||
/* AutoUpdater* updater = 0;
|
||||
CocoaInitializer initializer;
|
||||
updater = new SparkleAutoUpdater("file:///Users/micke/Documents/dev/appcast.xml");
|
||||
if (updater) {
|
||||
//updater->checkForUpdates();
|
||||
}
|
||||
}*/
|
||||
#endif
|
||||
|
||||
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() );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@ typedef QList<TelldusCenterPlugin *> PluginList;
|
|||
|
||||
class TelldusCenterApplicationPrivate {
|
||||
public:
|
||||
SystrayIcon *systrayIcon;
|
||||
PluginList plugins;
|
||||
QPointer<MainWindow> mainWindow;
|
||||
QScriptEngine scriptEngine;
|
||||
|
@ -26,9 +25,6 @@ TelldusCenterApplication::TelldusCenterApplication(int &argc, char **argv)
|
|||
:QApplication(argc, argv)
|
||||
{
|
||||
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 );
|
||||
|
||||
|
@ -37,8 +33,6 @@ TelldusCenterApplication::TelldusCenterApplication(int &argc, char **argv)
|
|||
tdInit();
|
||||
tdRegisterDeviceEvent( &TelldusCenterApplication::deviceEvent, 0 );
|
||||
|
||||
loadPlugins();
|
||||
loadScripts();
|
||||
}
|
||||
|
||||
TelldusCenterApplication::~TelldusCenterApplication() {
|
||||
|
@ -48,6 +42,9 @@ TelldusCenterApplication::~TelldusCenterApplication() {
|
|||
}
|
||||
|
||||
PluginList TelldusCenterApplication::plugins() const {
|
||||
if (d->plugins.empty()) {
|
||||
return PluginList();
|
||||
}
|
||||
return d->plugins;
|
||||
}
|
||||
|
||||
|
@ -85,7 +82,7 @@ void TelldusCenterApplication::showMessage( const QString &title, const QString
|
|||
if (isMainWindowShown()) {
|
||||
d->mainWindow->showMessage(title, message, detailedMessage);
|
||||
} 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")) {
|
||||
return;
|
||||
}
|
||||
this->addLibraryPath( pluginsDir.absolutePath() );
|
||||
this->setLibraryPaths( QStringList(pluginsDir.absolutePath()) );
|
||||
|
||||
foreach (QString fileName, pluginsDir.entryList(QDir::Files)) {
|
||||
QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
#include <QPointer>
|
||||
//#incldue
|
||||
|
||||
#include "systrayicon.h"
|
||||
#include "mainwindow.h"
|
||||
|
||||
class TelldusCenterPlugin;
|
||||
|
@ -28,6 +27,9 @@ public:
|
|||
void showMainWindow();
|
||||
bool isMainWindowShown();
|
||||
|
||||
void loadPlugins();
|
||||
void loadScripts();
|
||||
|
||||
static TelldusCenterApplication *instance();
|
||||
|
||||
signals:
|
||||
|
@ -42,9 +44,7 @@ private slots:
|
|||
|
||||
private:
|
||||
static void deviceEvent(int deviceId, int method, const char *data, int callbackId, void *context);
|
||||
void loadPlugins();
|
||||
void loadPlugin(QObject *plugin);
|
||||
void loadScripts();
|
||||
|
||||
TelldusCenterApplicationPrivate *d;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue