diff --git a/include/grabber/V4L2Grabber.h b/include/grabber/V4L2Grabber.h index 36c2f8a9..3a877eed 100644 --- a/include/grabber/V4L2Grabber.h +++ b/include/grabber/V4L2Grabber.h @@ -147,8 +147,8 @@ private: double _y_frac_min; double _x_frac_max; double _y_frac_max; + int _currentFrame; - int _currentFrame; QSocketNotifier * _streamNotifier; ImageResampler _imageResampler; diff --git a/include/utils/Image.h b/include/utils/Image.h index e8c82e48..f4c5183e 100644 --- a/include/utils/Image.h +++ b/include/utils/Image.h @@ -5,6 +5,7 @@ #include #include #include +#include #include diff --git a/include/webconfig/WebConfig.h b/include/webconfig/WebConfig.h index b29c89cb..c9b58bfe 100644 --- a/include/webconfig/WebConfig.h +++ b/include/webconfig/WebConfig.h @@ -18,6 +18,8 @@ public: void start(); void stop(); + quint16 getPort() { return _port; }; + private: Hyperion* _hyperion; QString _baseUrl; diff --git a/libsrc/grabber/v4l2/V4L2Grabber.cpp b/libsrc/grabber/v4l2/V4L2Grabber.cpp index d5234530..4bd98509 100644 --- a/libsrc/grabber/v4l2/V4L2Grabber.cpp +++ b/libsrc/grabber/v4l2/V4L2Grabber.cpp @@ -49,12 +49,12 @@ V4L2Grabber::V4L2Grabber(const QString & device , _noSignalThresholdColor(ColorRgb{0,0,0}) , _signalDetectionEnabled(true) , _noSignalDetected(false) + , _noSignalCounter(0) , _x_frac_min(0.25) , _y_frac_min(0.25) , _x_frac_max(0.75) , _y_frac_max(0.75) , _currentFrame(0) - , _noSignalCounter(0) , _streamNotifier(nullptr) , _imageResampler() , _log(Logger::getInstance("V4L2:"+device)) diff --git a/libsrc/hyperion/hyperion-icon_32px.png b/libsrc/hyperion/hyperion-icon_32px.png new file mode 100644 index 00000000..12196277 Binary files /dev/null and b/libsrc/hyperion/hyperion-icon_32px.png differ diff --git a/libsrc/hyperion/resource.qrc b/libsrc/hyperion/resource.qrc index 8bb420c2..7f0b7528 100644 --- a/libsrc/hyperion/resource.qrc +++ b/libsrc/hyperion/resource.qrc @@ -1,5 +1,6 @@ + hyperion-icon_32px.png hyperion.schema.json ../../config/hyperion.config.json.default schema/schema-general.json diff --git a/src/hyperiond/CMakeLists.txt b/src/hyperiond/CMakeLists.txt index 2bf5b991..d99ed863 100644 --- a/src/hyperiond/CMakeLists.txt +++ b/src/hyperiond/CMakeLists.txt @@ -1,7 +1,9 @@ add_executable(hyperiond hyperiond.h + systray.h hyperiond.cpp + systray.cpp main.cpp ) @@ -42,6 +44,8 @@ if (ENABLE_X11) target_link_libraries(hyperiond x11-grabber ) endif () +qt5_use_modules(hyperiond Core Gui Network Widgets) + install ( TARGETS hyperiond DESTINATION "share/hyperion/bin/" COMPONENT "${PLATFORM}" ) install ( DIRECTORY ${CMAKE_SOURCE_DIR}/bin/service DESTINATION "share/hyperion/" COMPONENT "${PLATFORM}" ) install ( FILES ${CMAKE_SOURCE_DIR}/effects/readme.txt DESTINATION "share/hyperion/effects" COMPONENT "${PLATFORM}" ) diff --git a/src/hyperiond/hyperiond.cpp b/src/hyperiond/hyperiond.cpp index 25f200de..ff73e813 100644 --- a/src/hyperiond/hyperiond.cpp +++ b/src/hyperiond/hyperiond.cpp @@ -137,7 +137,7 @@ void HyperionDaemon::run() void HyperionDaemon::loadConfig(const QString & configFile) { - Info(_log, "Selected configuration file: %s", configFile.toUtf8().constData()); + Info(_log, "Selected configuration file: %s", QSTRING_CSTR(configFile)); // make sure the resources are loaded (they may be left out after static linking) Q_INIT_RESOURCE(resource); @@ -224,7 +224,7 @@ void HyperionDaemon::startInitialEffect() else { int result = hyperion->setEffect(fgEffectConfig, FG_PRIORITY, fg_duration_ms); - Info(_log,"Inital foreground effect '%s' %s", fgEffectConfig.toUtf8().constData(), ((result == 0) ? "started" : "failed")); + Info(_log,"Inital foreground effect '%s' %s", QSTRING_CSTR(fgEffectConfig), ((result == 0) ? "started" : "failed")); } } // initial background effect/color @@ -246,7 +246,7 @@ void HyperionDaemon::startInitialEffect() else { int result = hyperion->setEffect(bgEffectConfig, BG_PRIORITY, DURATION_INFINITY); - Info(_log,"Inital background effect '%s' %s", bgEffectConfig.toUtf8().constData(), ((result == 0) ? "started" : "failed")); + Info(_log,"Inital background effect '%s' %s", QSTRING_CSTR(bgEffectConfig), ((result == 0) ? "started" : "failed")); } } @@ -435,7 +435,7 @@ void HyperionDaemon::createSystemFrameGrabber() { type = "framebuffer"; } - Info( _log, "set screen capture device to '%s'", type.toUtf8().constData()); + Info( _log, "set screen capture device to '%s'", QSTRING_CSTR(type)); } bool grabberCompState = grabberConfig["enable"].toBool(true); @@ -445,7 +445,7 @@ void HyperionDaemon::createSystemFrameGrabber() else if (type == "amlogic") { createGrabberAmlogic(); createGrabberFramebuffer(grabberConfig); } else if (type == "osx") createGrabberOsx(grabberConfig); else if (type == "x11") createGrabberX11(grabberConfig); - else { Warning( _log, "unknown framegrabber type '%s'", type.toUtf8().constData()); grabberCompState = false; } + else { Warning( _log, "unknown framegrabber type '%s'", QSTRING_CSTR(type)); grabberCompState = false; } // _hyperion->getComponentRegister().componentStateChanged(hyperion::COMP_GRABBER, grabberCompState); _hyperion->setComponentState(hyperion::COMP_GRABBER, grabberCompState ); diff --git a/src/hyperiond/hyperiond.h b/src/hyperiond/hyperiond.h index 2e69fb98..f774ea9f 100644 --- a/src/hyperiond/hyperiond.h +++ b/src/hyperiond/hyperiond.h @@ -48,9 +48,14 @@ #include #include +class SysTray; + class HyperionDaemon : public QObject { Q_OBJECT + + friend SysTray; + public: HyperionDaemon(QString configFile, QObject *parent=nullptr); ~HyperionDaemon(); diff --git a/src/hyperiond/main.cpp b/src/hyperiond/main.cpp index df8a1c37..cee1858c 100644 --- a/src/hyperiond/main.cpp +++ b/src/hyperiond/main.cpp @@ -11,12 +11,14 @@ #include #include +#include #include #include #include #include #include #include +#include #include "HyperionConfig.h" @@ -26,7 +28,12 @@ #include #include +#ifdef ENABLE_X11 +#include +#endif + #include "hyperiond.h" +#include "systray.h" using namespace commandline; @@ -58,6 +65,54 @@ void startNewHyperion(int parentPid, std::string hyperionFile, std::string confi } } +QCoreApplication* createApplication(int &argc, char *argv[]) +{ + bool isGuiApp = false; + bool forceNoGui = false; + // command line + for (int i = 1; i < argc; ++i) + { + if (qstrcmp(argv[i], "--desktop") == 0) + { + isGuiApp = true; + } + else if (qstrcmp(argv[i], "--service") == 0) + { + isGuiApp = false; + forceNoGui = true; + } + } + + // on osx/windows gui always available +#if defined(__APPLE__) || defined(__WIN32__) + isGuiApp = true && ! forceNoGui; +#else + if (!forceNoGui) + { + // if x11, then test if xserver is available + #ifdef ENABLE_X11 + Display* dpy = XOpenDisplay(NULL); + if (dpy != NULL) + { + XCloseDisplay(dpy); + isGuiApp = true; + } + } + #endif +#endif + + if (isGuiApp) + { + QApplication* app = new QApplication(argc, argv); + app->setApplicationDisplayName("Hyperion"); + return app; + } + + QCoreApplication* app = new QCoreApplication(argc, argv); + app->setApplicationName("Hyperion"); + app->setApplicationVersion(HYPERION_VERSION); + return app; +} int main(int argc, char** argv) { @@ -68,7 +123,8 @@ int main(int argc, char** argv) Logger::setLogLevel(Logger::WARNING); // Initialising QCoreApplication - QCoreApplication app(argc, argv); + QScopedPointer app(createApplication(argc, argv)); + bool isGuiApp = (qobject_cast(app.data()) != 0 && QSystemTrayIcon::isSystemTrayAvailable()); signal(SIGINT, signal_handler); signal(SIGTERM, signal_handler); @@ -88,14 +144,16 @@ int main(int argc, char** argv) BooleanOption & silentOption = parser.add('s', "silent", "do not print any outputs"); BooleanOption & verboseOption = parser.add('v', "verbose", "Increase verbosity"); BooleanOption & debugOption = parser.add('d', "debug", "Show debug messages"); + parser.add(0x0, "desktop", "show systray on desktop"); + parser.add(0x0, "service", "force hyperion to start as console service"); Option & exportConfigOption = parser.add