Skip to content

Commit

Permalink
Added support to show alarm progress in Logitech Gaming RGB keyboards.
Browse files Browse the repository at this point in the history
  • Loading branch information
FelixdelasPozas committed Nov 22, 2018
1 parent 2e448c2 commit 879f34b
Show file tree
Hide file tree
Showing 13 changed files with 688 additions and 41 deletions.
2 changes: 1 addition & 1 deletion AboutDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
// Project
#include "AboutDialog.h"

const QString AboutDialog::VERSION = QString("version 1.0.1");
const QString AboutDialog::VERSION = QString("version 1.1.0");

//-----------------------------------------------------------------
AboutDialog::AboutDialog(QWidget *parent, Qt::WindowFlags flags)
Expand Down
82 changes: 76 additions & 6 deletions AboutDialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@
<rect>
<x>0</x>
<y>0</y>
<width>397</width>
<height>232</height>
<width>532</width>
<height>283</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>397</width>
<height>232</height>
<width>532</width>
<height>283</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>397</width>
<height>232</height>
<width>532</width>
<height>283</height>
</size>
</property>
<property name="windowTitle">
Expand Down Expand Up @@ -265,6 +265,76 @@ Qt Framework</string>
</item>
</layout>
</item>
<item>
<widget class="Line" name="line_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_8">
<property name="maximumSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="rsc/resources.qrc">:/MultiAlarm/logitech.svg</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<widget class="QLabel" name="label_9">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Logitech Gaming LED SDK</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_10">
<property name="text">
<string>version 9.0</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="label_6">
<property name="text">
<string>&lt;a href=&quot;https://www.logitechg.com/es-es/developers&quot;&gt;https://www.logitechg.com/es-es/developers&lt;/a&gt;</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
Expand Down
31 changes: 30 additions & 1 deletion AlarmWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "DesktopWidget.h"
#include "MultiAlarm.h"
#include "NewAlarmDialog.h"
#include "LogiLED.h"

// Qt
#include <QTime>
Expand Down Expand Up @@ -54,6 +55,7 @@ AlarmWidget::AlarmWidget(MultiAlarm *parent, Qt::WindowFlags flags)
, m_alarm {nullptr}
, m_icon {nullptr}
, m_widget {nullptr}
, m_logiled {nullptr}
, m_sound {nullptr}
, m_soundFile {nullptr}
, m_parent {parent}
Expand Down Expand Up @@ -128,6 +130,11 @@ void AlarmWidget::start()
m_widget->show();
}

if(m_logiled)
{
m_logiled->registerItem(name(), m_alarm->progress(), QColor{color()}, QColor{m_contrastColor});
}

m_alarm->start();
m_started = true;
}
Expand Down Expand Up @@ -168,6 +175,11 @@ void AlarmWidget::stop()
m_widget->hide();
}

if(m_logiled)
{
m_logiled->unregisterItem(name());
}

setTime(m_alarm->remainingTime());
}

Expand Down Expand Up @@ -295,6 +307,11 @@ void AlarmWidget::onAlarmTic()
{
m_widget->setProgress(m_alarm->precisionProgress());
}

if(m_logiled)
{
m_logiled->updateItem(name(), m_alarm->progress());
}
}

//-----------------------------------------------------------------
Expand Down Expand Up @@ -374,6 +391,7 @@ void AlarmWidget::onSettingsPressed()
dialog.setSoundVolume(m_configuration.soundVolume);
dialog.setShowInTray(m_configuration.useTray);
dialog.setShowInDesktop(m_configuration.useDesktopWidget);
dialog.setShowInKeyboard(m_configuration.useLogiled);
dialog.setDesktopWidgetPosition(m_configuration.widgetPosition);
dialog.setWidgetOpacity(m_configuration.widgetOpacity);

Expand Down Expand Up @@ -401,6 +419,7 @@ void AlarmWidget::onSettingsPressed()
conf.soundVolume = dialog.soundVolume();
conf.useTray = dialog.showInTray();
conf.useDesktopWidget = dialog.showInDesktop();
conf.useLogiled = dialog.showInKeyboard();
conf.widgetPosition = dialog.desktopWidgetPosition();
conf.widgetOpacity = dialog.widgetOpacity();

Expand Down Expand Up @@ -431,6 +450,11 @@ void AlarmWidget::setConfiguration(const AlarmConfiguration &conf)
m_widget = nullptr;
}

if(m_logiled)
{
m_logiled = nullptr;
}

if(m_alarm)
{
delete m_alarm;
Expand Down Expand Up @@ -497,7 +521,7 @@ void AlarmWidget::setConfiguration(const AlarmConfiguration &conf)

setAlarm(alarm);

if (conf.useTray && QSystemTrayIcon::isSystemTrayAvailable())
if(conf.useTray && QSystemTrayIcon::isSystemTrayAvailable())
{
m_icon = new QSystemTrayIcon(this);
m_icon->setToolTip(QString("%1\nRemaining time: %2").arg(m_configuration.name).arg(alarm->remainingTimeText()));
Expand Down Expand Up @@ -539,6 +563,11 @@ void AlarmWidget::setConfiguration(const AlarmConfiguration &conf)
m_widget->setOpacity(m_configuration.widgetOpacity);
}

if(conf.useLogiled && LogiLED::isAvailable())
{
m_logiled = &LogiLED::getInstance();
}

if(!conf.isTimer)
{
start();
Expand Down
29 changes: 16 additions & 13 deletions AlarmWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,25 +34,27 @@ class QTemporaryFile;

class DesktopWidget;
class MultiAlarm;
class LogiLED;

/** \struct AlarmConfiguration
* \brief Holds all the relevant information about an alarm and it's notifications.
*/
struct AlarmConfiguration
{
QString name; /** name of the alarm. */
QString message; /** message of the alarm to show on completion. */
QString color; /** name of the color of the alarm. */
bool isTimer; /** true if the alarm is a timer. */
QTime timerTime; /** duration of the timer alarm. */
bool timerLoops; /** true if the timer loops. */
QDateTime clockDateTime; /** date and timer of the clock alarm. */
int sound; /** sound used for the finished alarm notification. */
int soundVolume; /** volume for the sound in [0 (silence) - 100 (loudest) ] */
bool useTray; /** true if the alarm uses the tray for notifications. */
bool useDesktopWidget; /** true if the alarm uses a desktop widget for notifications. */
QPoint widgetPosition; /** position of the desktop widget. */
int widgetOpacity; /** opacity of the desktop widget in [0-100] */
QString name; /** name of the alarm. */
QString message; /** message of the alarm to show on completion. */
QString color; /** name of the color of the alarm. */
bool isTimer; /** true if the alarm is a timer. */
QTime timerTime; /** duration of the timer alarm. */
bool timerLoops; /** true if the timer loops. */
QDateTime clockDateTime; /** date and timer of the clock alarm. */
int sound; /** sound used for the finished alarm notification. */
int soundVolume; /** volume for the sound in [0 (silence) - 100 (loudest) ] */
bool useTray; /** true if the alarm uses the tray for notifications. */
bool useDesktopWidget; /** true if the alarm uses a desktop widget for notifications. */
bool useLogiled; /** true if the alarm uses the keyboard lights for notifications. */
QPoint widgetPosition; /** position of the desktop widget. */
int widgetOpacity; /** opacity of the desktop widget in [0-100] */
};

/** \class AlarmWidget
Expand Down Expand Up @@ -187,6 +189,7 @@ class AlarmWidget
AlarmConfiguration m_configuration; /** alarm configuration. */
QSystemTrayIcon *m_icon; /** system tray icon. */
DesktopWidget *m_widget; /** desktop widget. */
LogiLED *m_logiled; /** LogiLED instance. */
QSoundEffect *m_sound; /** alarm sound. */
QTemporaryFile *m_soundFile; /** local sound file in termporary directory. */

Expand Down
11 changes: 9 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ cmake_policy(SET CMP0020 OLD)

# Version Number
set (MULTIALARM_VERSION_MAJOR 1)
set (MULTIALARM_VERSION_MINOR 0)
set (MULTIALARM_VERSION_PATCH 1)
set (MULTIALARM_VERSION_MINOR 1)
set (MULTIALARM_VERSION_PATCH 0)

# Find includes in corresponding build directories
set(CMAKE_INCLUDE_CURRENT_DIR ON)
Expand All @@ -21,6 +21,10 @@ set(CMAKE_AUTOMOC ON)
# Find the QtWidgets library
find_package(Qt5 COMPONENTS Widgets Multimedia)

# Fixed, need to be changed to your own installation of Logitech Gaming LED SKD files.
set(LOGITECH_INCLUDE "D:/Desarrollo/Code/LogitechG810/include/")
set(LOGITECH_LIBRARY "D:/Desarrollo/Code/LogitechG810/include/LogitechLedEnginesWrapper.a")

# We need add -DQT_WIDGETS_LIB when using QtWidgets in Qt 5.
#add_definitions(${Qt5Widgets_DEFINITIONS})
#add_definitions(${Qt5Multimedia_DEFINITIONS})
Expand Down Expand Up @@ -48,6 +52,7 @@ include_directories(
${CMAKE_CURRENT_BINARY_DIR} # For wrap/ui files
${Qt5Widgets_INCLUDE_DIRS}
${Qt5Multimedia_INCLUDE_DIRS}
${LOGITECH_INCLUDE}
)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-deprecated -std=c++11 -mwindows")
Expand Down Expand Up @@ -78,9 +83,11 @@ set (CORE_SOURCES
AlarmWidget.cpp
Alarm.cpp
DesktopWidget.cpp
LogiLED.cpp
)

set(CORE_EXTERNAL_LIBS
${LOGITECH_LIBRARY}
Qt5::Widgets
Qt5::Multimedia
)
Expand Down
Loading

0 comments on commit 879f34b

Please sign in to comment.