Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Software/Lightpack.pro
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,18 @@
# Project created by QtCreator 2010-04-28T19:08:13
# -------------------------------------------------


CONFIG-=create_cmake

#linux-g++:QMAKE_TARGET.arch = $$QMAKE_HOST.arch
#linux-g++-32:QMAKE_TARGET.arch = x86
#linux-g++-64:QMAKE_TARGET.arch = x86_64

#contains(QMAKE_TARGET.arch, x86_64):{
# unix:QMAKE_CXXFLAGS+=-m32
# unix:QMAKE_LFLAGS+=-m32 -L/usr/lib32 -L/usr/lib/i386-linux-gnu
# }

TEMPLATE = subdirs
CONFIG += ordered

Expand Down
2 changes: 2 additions & 0 deletions Software/qtserialport/qtserialport.pro
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
CONFIG-=create_cmake

lessThan(QT_MAJOR_VERSION, 5) {
TEMPLATE = subdirs
SUBDIRS = src
Expand Down
2 changes: 2 additions & 0 deletions Software/qtserialport/src/serialport/serialport.pro
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
QT = core

CONFIG-=create_cmake

QMAKE_DOCS = $$PWD/doc/qtserialport.qdocconf
include($$PWD/serialport-lib.pri)

Expand Down
1 change: 1 addition & 0 deletions Software/qtserialport/src/src.pro
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
TEMPLATE = subdirs

SUBDIRS = serialport
CONFIG-=create_cmake
4 changes: 4 additions & 0 deletions Software/res/LightpackResources.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,9 @@
<file>icons/Prismatik.png</file>
<file>icons/Prismatik-pixmap.png</file>
<file>text/cast.html</file>
<file>icons/error16.png</file>
<file>icons/lock16.png</file>
<file>icons/off16.png</file>
<file>icons/on16.png</file>
</qresource>
</RCC>
Binary file added Software/res/icons/error16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Software/res/icons/lock16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Software/res/icons/off16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Software/res/icons/on16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions Software/src/SettingsWindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>608</width>
<height>600</height>
<width>654</width>
<height>599</height>
</rect>
</property>
<property name="sizePolicy">
Expand Down Expand Up @@ -243,7 +243,7 @@
<enum>QTabWidget::Rounded</enum>
</property>
<property name="currentIndex">
<number>5</number>
<number>0</number>
</property>
<widget class="QWidget" name="tabSoftwareOptions">
<property name="enabled">
Expand Down
1 change: 1 addition & 0 deletions Software/src/qtsingleapplication/src/qtlocalpeer.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#include <QLocalServer>
#include <QLocalSocket>
#include <QDir>
#include <QDataStream>

#include "qtlockedfile.h"

Expand Down
2 changes: 2 additions & 0 deletions Software/src/src.pro
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ CONFIG(msvc) {
DESTDIR = bin
TEMPLATE = app
QT += network widgets
QT += gui-private
win32 {
QT += serialport
}
Expand Down Expand Up @@ -65,6 +66,7 @@ unix:!macx{
DESKTOP = $$(XDG_CURRENT_DESKTOP)

equals(DESKTOP, "Unity") {
message(Unity DESKTOP)
DEFINES += UNITY_DESKTOP
PKGCONFIG += gtk+-2.0 appindicator-0.1 libnotify
}
Expand Down
14 changes: 14 additions & 0 deletions Software/src/systrayicon/SysTrayIcon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,20 @@ void SysTrayIcon::checkUpdate()
d->checkUpdate();
}

void SysTrayIcon::switchBacklight(const bool &power)
{
if (power)
emit backlightOn();
else
emit backlightOff();
}

void SysTrayIcon::nextProfile()
{
using namespace SettingsScope;
QStringList profiles = Settings::findAllProfiles();
}

void SysTrayIcon::setStatus(const Status status, const QString *arg)
{
Q_D(SysTrayIcon);
Expand Down
4 changes: 4 additions & 0 deletions Software/src/systrayicon/SysTrayIcon.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ class SysTrayIcon : public QObject
public slots:
void retranslateUi();
void checkUpdate();
void nextProfile();

private slots:
void switchBacklight(const bool &power);

private:
SysTrayIconPrivate * const d_ptr;
Expand Down
114 changes: 90 additions & 24 deletions Software/src/systrayicon/SysTrayIcon_qt_p.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,10 @@ class SysTrayIconPrivate : public QObject, public SysTrayIconPrivateData

fillProfilesFromSettings();

trayIconMenu->addAction(_switchOnBacklightAction);
trayIconMenu->addAction(_switchOffBacklightAction);
trayIconMenu->addAction(_switchBacklightAction);
trayIconMenu->addAction(_nextProfile);
// trayIconMenu->addAction(_switchOnBacklightAction);
// trayIconMenu->addAction(_switchOffBacklightAction);
trayIconMenu->addSeparator();
trayIconMenu->addMenu(_profilesMenu);
trayIconMenu->addAction(_settingsAction);
Expand Down Expand Up @@ -83,10 +85,11 @@ class SysTrayIconPrivate : public QObject, public SysTrayIconPrivateData

connect(&_updatesProcessor, SIGNAL(readyRead()), this, SLOT(onCheckUpdate_Finished()));

_pixmapCache.insert("lock16", new QPixmap(QPixmap(":/icons/lock.png").scaledToWidth(16, Qt::SmoothTransformation)) );
_pixmapCache.insert("on16", new QPixmap(QPixmap(":/icons/on.png").scaledToWidth(16, Qt::SmoothTransformation)) );
_pixmapCache.insert("off16", new QPixmap(QPixmap(":/icons/off.png").scaledToWidth(16, Qt::SmoothTransformation)) );
_pixmapCache.insert("error16", new QPixmap(QPixmap(":/icons/error.png").scaledToWidth(16, Qt::SmoothTransformation)) );
const int icon_size = 16;
_pixmapCache.insert("on16", new QPixmap(QPixmap(":/icons/on.png").scaledToWidth(icon_size, Qt::SmoothTransformation)) );
_pixmapCache.insert("lock16", new QPixmap(QPixmap(":/icons/lock.png").scaledToWidth(icon_size, Qt::SmoothTransformation)) );
_pixmapCache.insert("off16", new QPixmap(QPixmap(":/icons/off.png").scaledToWidth(icon_size, Qt::SmoothTransformation)) );
_pixmapCache.insert("error16", new QPixmap(QPixmap(":/icons/error.png").scaledToWidth(icon_size, Qt::SmoothTransformation)) );

setStatus(SysTrayIcon::StatusOn);
_qsystray->show();
Expand Down Expand Up @@ -138,8 +141,10 @@ class SysTrayIconPrivate : public QObject, public SysTrayIconPrivateData
void retranslateUi()
{
DEBUG_LOW_LEVEL << Q_FUNC_INFO;
_switchOnBacklightAction->setText(tr("&Turn on"));
_switchOffBacklightAction->setText(tr("&Turn off"));
_switchBacklightAction->setText(tr("&Switch on/off"));
// _nextProfile->setText(tr("&Next profile"));
// _switchOnBacklightAction->setText(tr("&Turn on"));
// _switchOffBacklightAction->setText(tr("&Turn off"));
_settingsAction->setText(tr("&Settings"));
_quitAction->setText(tr("&Quit"));
_profilesMenu->setTitle(tr("&Profiles"));
Expand Down Expand Up @@ -173,17 +178,18 @@ class SysTrayIconPrivate : public QObject, public SysTrayIconPrivateData
switch (status)
{
case SysTrayIcon::StatusOn:
_switchOnBacklightAction->setEnabled(false);
_switchOffBacklightAction->setEnabled(true);
// _switchOnBacklightAction->setEnabled(false);
// _switchOffBacklightAction->setEnabled(true);
// /mnt/workspace/source/Lightpack/Software/res/icons
_qsystray->setIcon(QIcon(*_pixmapCache["on16"]));

if(SettingsScope::Settings::isProfileLoaded())
_qsystray->setToolTip(tr("Enabled profile: %1").arg(SettingsScope::Settings::getCurrentProfileName()));
break;

case SysTrayIcon::StatusLockedByApi:
_switchOnBacklightAction->setEnabled(false);
_switchOffBacklightAction->setEnabled(true);
// _switchOnBacklightAction->setEnabled(false);
// _switchOffBacklightAction->setEnabled(true);
_qsystray->setIcon(QIcon(*_pixmapCache["lock16"]));
_qsystray->setToolTip(tr("Device locked via API"));
break;
Expand All @@ -193,15 +199,15 @@ class SysTrayIconPrivate : public QObject, public SysTrayIconPrivateData
break;

case SysTrayIcon::StatusOff:
_switchOnBacklightAction->setEnabled(true);
_switchOffBacklightAction->setEnabled(false);
// _switchOnBacklightAction->setEnabled(true);
// _switchOffBacklightAction->setEnabled(false);
_qsystray->setIcon(QIcon(*_pixmapCache["off16"]));
_qsystray->setToolTip(tr("Disabled"));
break;

case SysTrayIcon::StatusError:
_switchOnBacklightAction->setEnabled(false);
_switchOffBacklightAction->setEnabled(true);
// _switchOnBacklightAction->setEnabled(false);
// _switchOffBacklightAction->setEnabled(true);
_qsystray->setIcon(QIcon(*_pixmapCache["error16"]));
_qsystray->setToolTip(tr("Error with connection device, verbose in logs"));
break;
Expand All @@ -226,6 +232,54 @@ class SysTrayIconPrivate : public QObject, public SysTrayIconPrivateData

private slots:

void nextProfile()
{
using namespace SettingsScope;
QStringList profiles = Settings::findAllProfiles();
const QString curProfile = Settings::getCurrentProfileName();
int index = 0;
for (int i=0; i<profiles.count(); i++) {
if (profiles.at(i) == curProfile) {
index = i;
break;
}
}

index++;
if (index>=profiles.count())
index = 0;
const QString next = profiles.at(index);

Settings::loadOrCreateProfile(next);
}

void updateProfileNextText(const QString)
{
using namespace SettingsScope;
QStringList profiles = Settings::findAllProfiles();
const QString curProfile = Settings::getCurrentProfileName();
int index = 0;
for (int i=0; i<profiles.count(); i++) {
if (profiles.at(i) == curProfile) {
index = i;
break;
}
}

index++;
if (index>=profiles.count())
index = 0;
const QString next = profiles.at(index);

index++;
if (index>=profiles.count())
index = 0;
const QString nextAfterNext = profiles.at(index);

_nextProfile->setText(QString("%1 -> %2").arg(next).arg(nextAfterNext));
qDebug() << _nextProfile->text();
}

void onCheckUpdate_Finished()
{
using namespace SettingsScope;
Expand Down Expand Up @@ -329,15 +383,25 @@ private slots:
{
Q_Q(SysTrayIcon);
DEBUG_LOW_LEVEL << Q_FUNC_INFO;
using namespace SettingsScope;

// _switchOnBacklightAction = new QAction(QIcon(":/icons/on.png"), tr("&Turn on"), this);
// _switchOnBacklightAction->setIconVisibleInMenu(true);
// connect(_switchOnBacklightAction, SIGNAL(triggered()), q, SIGNAL(backlightOn()));

_switchOnBacklightAction = new QAction(QIcon(":/icons/on.png"), tr("&Turn on"), this);
_switchOnBacklightAction->setIconVisibleInMenu(true);
connect(_switchOnBacklightAction, SIGNAL(triggered()), q, SIGNAL(backlightOn()));
_switchBacklightAction = new QAction(QIcon(":/icons/on.png"), tr("&Switch on/off"), this);
_switchBacklightAction->setIconVisibleInMenu(true);
_switchBacklightAction->setCheckable(true);
connect(_switchBacklightAction, SIGNAL(triggered(bool)), q, SLOT(switchBacklight(bool)));

_switchOffBacklightAction = new QAction(QIcon(":/icons/off.png"), tr("&Turn off"), this);
_switchOffBacklightAction->setIconVisibleInMenu(true);
connect(_switchOffBacklightAction, SIGNAL(triggered()), q, SIGNAL(backlightOff()));
// _switchOffBacklightAction = new QAction(QIcon(":/icons/off.png"), tr("&Turn off"), this);
// _switchOffBacklightAction->setIconVisibleInMenu(true);
// connect(_switchOffBacklightAction, SIGNAL(triggered()), q, SIGNAL(backlightOff()));

_nextProfile = new QAction(QIcon(":/icons/profiles.png"), ("&Next profile"), this);
_nextProfile->setIconVisibleInMenu(true);
connect(_nextProfile, SIGNAL(triggered()), this, SLOT(nextProfile()));
connect(SettingsScope::Settings::settingsSingleton(), SIGNAL(currentProfileInited(QString)), this, SLOT(updateProfileNextText(QString)));

_profilesMenu = new QMenu(tr("&Profiles"));
_profilesMenu->setIcon(QIcon(":/icons/profiles.png"));
Expand Down Expand Up @@ -373,8 +437,10 @@ private slots:

private:
QSystemTrayIcon * _qsystray;
QAction * _switchOnBacklightAction;
QAction * _switchOffBacklightAction;
QAction * _switchBacklightAction;
QAction * _nextProfile;
// QAction * _switchOnBacklightAction;
// QAction * _switchOffBacklightAction;
QAction * _settingsAction;
QAction * _quitAction;
QMenu * _profilesMenu;
Expand Down