diff --git a/CMakeLists.txt b/CMakeLists.txt index 2947f50a3..8359f2706 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -341,6 +341,7 @@ set(APP_SOURCES src/gui/dialogs/formdatabasecleanup.cpp src/gui/dialogs/formbackupdatabasesettings.cpp src/gui/dialogs/formrestoredatabasesettings.cpp + src/gui/notifications/notification.cpp src/gui/systemtrayicon.cpp src/gui/baselineedit.cpp src/gui/locationlineedit.cpp @@ -454,6 +455,7 @@ set(APP_HEADERS src/gui/dialogs/formrestoredatabasesettings.h src/gui/dialogs/formdatabasecleanup.h src/gui/dialogs/formupdate.h + src/gui/notifications/notification.h src/gui/systemtrayicon.h src/gui/baselineedit.h src/gui/locationlineedit.h @@ -700,6 +702,7 @@ include_directories ( ${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}/src/gui ${CMAKE_SOURCE_DIR}/src/gui/dialogs + ${CMAKE_SOURCE_DIR}/src/gui/notifications ${CMAKE_SOURCE_DIR}/src/network-web ${CMAKE_SOURCE_DIR}/src/network-web/adblock ${CMAKE_SOURCE_DIR}/src/dynamic-shortcuts diff --git a/src/gui/notifications/notification.cpp b/src/gui/notifications/notification.cpp new file mode 100644 index 000000000..9f0825727 --- /dev/null +++ b/src/gui/notifications/notification.cpp @@ -0,0 +1,68 @@ +// This file is part of RSS Guard. +// +// Copyright (C) 2011-2015 by Martin Rotter +// +// RSS Guard is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// RSS Guard is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with RSS Guard. If not, see . + +#include "gui/notifications/notification.h" + +#if defined(Q_OS_MAC) +#include +#endif + + +Notification::Notification() : QWidget(0) { + setupWidget(); +} + +Notification::~Notification() { +} + +void Notification::setupWidget() { + // Set window flags. + Qt::WindowFlags window_flags = Qt::FramelessWindowHint | Qt::WindowSystemMenuHint | + Qt::WindowStaysOnTopHint | Qt::X11BypassWindowManagerHint | + Qt::WindowDoesNotAcceptFocus; + +#if defined (Q_OS_MAC) + window_flags |= Qt::SubWindow; +#else + window_flags |= Qt::Tool; +#endif + + setWindowFlags(window_flags); + + // Set widget attributes. + setAttribute(Qt::WA_TranslucentBackground); + setAttribute(Qt::WA_X11DoNotAcceptFocus); + setAttribute(Qt::WA_ShowWithoutActivating); + +#if defined (Q_OS_MAC) + winId(); + + int setAttr[] = {kHIWindowBitDoesNotHide, kHIWindowBitDoesNotCycle, kHIWindowBitNoShadow, 0}; + int clearAttr[] = {0}; + HIWindowChangeAttributes(qt_mac_window_for(this), setAttr, clearAttr); +#endif + + // Window will be meant to be on top, but should not steal focus. + setFocusPolicy(Qt::NoFocus); + + // TODO: pokracovat + // https://github.com/binaryking/QNotify/blob/master/QNotify.cpp + // http://stackoverflow.com/questions/5823700/notification-window-in-mac-with-or-without-qt + // quiterss + // a odkazy z issue + // promyslet esli tam dat jen ciste label a ikonu, nebo i seznam nejnovesich zprav atp. +} diff --git a/src/gui/notifications/notification.h b/src/gui/notifications/notification.h new file mode 100644 index 000000000..9b4e70f49 --- /dev/null +++ b/src/gui/notifications/notification.h @@ -0,0 +1,40 @@ +// This file is part of RSS Guard. +// +// Copyright (C) 2011-2015 by Martin Rotter +// +// RSS Guard is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// RSS Guard is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with RSS Guard. If not, see . + +#ifndef NOTIFICATION_H +#define NOTIFICATION_H + +#include + + +class Notification : public QWidget { + Q_OBJECT + + public: + explicit Notification(); + virtual ~Notification(); + + signals: + + public slots: + + private: + void setupWidget(); + +}; + +#endif // NOTIFICATION_H