iPhones now supported

This commit is contained in:
Victor Tran 2016-10-17 11:56:22 +11:00
parent 51f69e947a
commit 28a2c5228a
17 changed files with 5 additions and 679 deletions

View file

@ -1,151 +0,0 @@
#include <QtCore>
#if defined(Q_OS_WIN)
inline size_t QtKeyToWin(size_t key) {
// TODO: other maping or full keys list
if (key >= 0x01000030 && key <= 0x01000047) {
return VK_F1 + (key - Qt::Key_F1);
}
return key;
}
#elif defined(Q_OS_LINUX)
#include "ukeysequence.h"
#include "xcb/xcb.h"
#include "xcb/xcb_keysyms.h"
#include "X11/keysym.h"
struct UKeyData {
int key;
int mods;
};
inline UKeyData QtKeyToLinux(const UKeySequence &keySeq)
{
UKeyData data = {0, 0};
auto key = keySeq.GetSimpleKeys();
if (key.size() > 0)
data.key = key[0];
else
throw UException("Invalid hotkey");
// Key conversion
// Qt's F keys need conversion
if (data.key >= Qt::Key_F1 && data.key <= Qt::Key_F35) {
const size_t DIFF = Qt::Key_F1 - XK_F1;
data.key -= DIFF;
} else if (data.key >= Qt::Key_Space && data.key <= Qt::Key_QuoteLeft) {
// conversion is not necessary, if the value in the range Qt::Key_Space - Qt::Key_QuoteLeft
//} else if (data.key == Qt::Key_PowerOff) {
//const size_t DIFF = Qt::Key_PowerDown - ;
} else {
throw UException("Invalid hotkey: key conversion is not defined");
}
// Modifiers conversion
auto mods = keySeq.GetModifiers();
for (auto i : mods) {
if (i == Qt::Key_Shift)
data.mods |= XCB_MOD_MASK_SHIFT;
else if (i == Qt::Key_Control)
data.mods |= XCB_MOD_MASK_CONTROL;
else if (i == Qt::Key_Alt)
data.mods |= XCB_MOD_MASK_1;
else if (i == Qt::Key_Meta)
data.mods |= XCB_MOD_MASK_4; // !
}
return data;
}
#elif defined(Q_OS_MAC)
#include "ukeysequence.h"
#include <Carbon/Carbon.h>
#include <unordered_map>
struct UKeyData {
uint32_t key;
uint32_t mods;
};
static std::unordered_map<uint32_t, uint32_t> KEY_MAP = {
{Qt::Key_A, kVK_ANSI_A},
{Qt::Key_B, kVK_ANSI_B},
{Qt::Key_C, kVK_ANSI_C},
{Qt::Key_D, kVK_ANSI_D},
{Qt::Key_E, kVK_ANSI_E},
{Qt::Key_F, kVK_ANSI_F},
{Qt::Key_G, kVK_ANSI_G},
{Qt::Key_H, kVK_ANSI_H},
{Qt::Key_I, kVK_ANSI_I},
{Qt::Key_J, kVK_ANSI_J},
{Qt::Key_K, kVK_ANSI_K},
{Qt::Key_L, kVK_ANSI_L},
{Qt::Key_M, kVK_ANSI_M},
{Qt::Key_N, kVK_ANSI_N},
{Qt::Key_O, kVK_ANSI_O},
{Qt::Key_P, kVK_ANSI_P},
{Qt::Key_Q, kVK_ANSI_Q},
{Qt::Key_R, kVK_ANSI_R},
{Qt::Key_S, kVK_ANSI_S},
{Qt::Key_T, kVK_ANSI_T},
{Qt::Key_U, kVK_ANSI_U},
{Qt::Key_V, kVK_ANSI_V},
{Qt::Key_W, kVK_ANSI_W},
{Qt::Key_X, kVK_ANSI_X},
{Qt::Key_Y, kVK_ANSI_Y},
{Qt::Key_Z, kVK_ANSI_Z},
{Qt::Key_0, kVK_ANSI_0},
{Qt::Key_1, kVK_ANSI_1},
{Qt::Key_2, kVK_ANSI_2},
{Qt::Key_3, kVK_ANSI_3},
{Qt::Key_4, kVK_ANSI_4},
{Qt::Key_5, kVK_ANSI_5},
{Qt::Key_6, kVK_ANSI_6},
{Qt::Key_7, kVK_ANSI_7},
{Qt::Key_8, kVK_ANSI_8},
{Qt::Key_9, kVK_ANSI_9},
{Qt::Key_F1, kVK_F1},
{Qt::Key_F2, kVK_F2},
{Qt::Key_F3, kVK_F3},
{Qt::Key_F4, kVK_F4},
{Qt::Key_F5, kVK_F5},
{Qt::Key_F6, kVK_F6},
{Qt::Key_F7, kVK_F7},
{Qt::Key_F8, kVK_F8},
{Qt::Key_F9, kVK_F9},
{Qt::Key_F10, kVK_F10},
{Qt::Key_F11, kVK_F11},
{Qt::Key_F12, kVK_F12},
{Qt::Key_F13, kVK_F13},
{Qt::Key_F14, kVK_F14},
};
static std::unordered_map<uint32_t, uint32_t> MOD_MAP = {
{Qt::Key_Shift, shiftKey},
{Qt::Key_Alt, optionKey},
{Qt::Key_Control, controlKey},
{Qt::Key_Option, optionKey},
{Qt::Key_Meta, cmdKey},
};
inline UKeyData QtKeyToMac(const UKeySequence &keySeq) {
UKeyData data = {0, 0};
auto key = keySeq.GetSimpleKeys();
auto mods = keySeq.GetModifiers();
if (key.size() == 1 && KEY_MAP.find(key[0]) != KEY_MAP.end())
data.key = KEY_MAP[key[0]];
else
throw UException("Invalid hotkey");
for (auto&& mod: mods) {
if (MOD_MAP.find(mod) == MOD_MAP.end())
throw UException("Invalid hotkey");
data.mods += MOD_MAP[mod];
}
return data;
}
#endif

View file

@ -1,13 +0,0 @@
#include "uexception.h"
UException::UException(const QString& message) throw()
: Message(message.toLocal8Bit())
{
}
UException::~UException() throw () {
}
const char* UException::what() const throw () {
return Message.data();
}

View file

@ -1,16 +0,0 @@
#pragma once
#include <exception>
#include <QString>
#include <QByteArray>
#include "uglobal.h"
class UGLOBALHOTKEY_EXPORT UException : public std::exception
{
public:
UException(const QString& message) throw();
const char* what() const throw();
~UException() throw ();
private:
QByteArray Message;
};

View file

@ -1,14 +0,0 @@
#ifndef UGLOBAL_H
#define UGLOBAL_H
#include <QtCore/QtGlobal>
#if defined(UGLOBALHOTKEY_LIBRARY)
# define UGLOBALHOTKEY_EXPORT Q_DECL_EXPORT
#elif defined(UGLOBALHOTKEY_NOEXPORT)
# define UGLOBALHOTKEY_EXPORT
#else
# define UGLOBALHOTKEY_EXPORT Q_DECL_IMPORT
#endif
#endif // UGLOBAL_H

View file

@ -1,213 +0,0 @@
#include <QtCore>
#if defined(Q_OS_WIN)
#include <windows.h>
#elif defined(Q_OS_LINUX)
#include <QWindow>
#include <QtGui/qpa/qplatformnativeinterface.h>
#include <QApplication>
#endif
#include "hotkeymap.h"
#include "uglobalhotkeys.h"
UGlobalHotkeys::UGlobalHotkeys(QWidget *parent)
: QWidget(parent)
{
#if defined(Q_OS_LINUX)
qApp->installNativeEventFilter(this);
QWindow wndw;
void* v = qApp->platformNativeInterface()->nativeResourceForWindow("connection", &wndw);
X11Connection = (xcb_connection_t*)v;
X11Wid = xcb_setup_roots_iterator(xcb_get_setup(X11Connection)).data->root;
X11KeySymbs = xcb_key_symbols_alloc(X11Connection);
#endif
}
void UGlobalHotkeys::registerHotkey(const QString& keySeq, size_t id) {
registerHotkey(UKeySequence(keySeq), id);
}
#if defined(Q_OS_MAC)
OSStatus macHotkeyHandler(EventHandlerCallRef nextHandler, EventRef theEvent, void* userData) {
Q_UNUSED(nextHandler);
EventHotKeyID hkCom;
GetEventParameter(theEvent,kEventParamDirectObject,typeEventHotKeyID,NULL,
sizeof(hkCom),NULL,&hkCom);
size_t id = hkCom.id;
UGlobalHotkeys* caller = (UGlobalHotkeys*)userData;
caller->onHotkeyPressed(id);
return noErr;
}
#endif
void UGlobalHotkeys::registerHotkey(const UKeySequence& keySeq, size_t id) {
if (keySeq.Size() == 0) {
throw UException("Empty hotkeys");
}
#if defined(Q_OS_WIN) || defined(Q_OS_LINUX)
if (Registered.find(id) != Registered.end()) {
unregisterHotkey(id);
}
#endif
#if defined(Q_OS_WIN)
size_t winMod = 0;
size_t key = VK_F2;
for (size_t i = 0; i != keySeq.Size(); i++) {
if (keySeq[i] == Qt::Key_Control) {
winMod |= MOD_CONTROL;
} else if (keySeq[i] == Qt::Key_Alt) {
winMod |= MOD_ALT;
} else if (keySeq[i] == Qt::Key_Shift) {
winMod |= MOD_SHIFT;
} else if (keySeq[i] == Qt::Key_Meta) {
winMod |= MOD_WIN;
} else {
key = QtKeyToWin(keySeq[i]);
}
}
if (!RegisterHotKey((HWND)winId(), id, winMod, key)) {
qDebug() << "Error activating hotkey!";
} else {
Registered.insert(id);
}
#elif defined(Q_OS_LINUX)
regLinuxHotkey(keySeq, id);
#endif
#if defined(Q_OS_MAC)
unregisterHotkey(id);
EventHotKeyRef gMyHotKeyRef;
EventHotKeyID gMyHotKeyID;
EventTypeSpec eventType;
eventType.eventClass=kEventClassKeyboard;
eventType.eventKind=kEventHotKeyPressed;
InstallApplicationEventHandler(&macHotkeyHandler, 1, &eventType, this, NULL);
gMyHotKeyID.signature = uint32_t(id);
gMyHotKeyID.id=uint32_t(id);
UKeyData macKey = QtKeyToMac(keySeq);
RegisterEventHotKey(macKey.key, macKey.mods, gMyHotKeyID,
GetApplicationEventTarget(), 0, &gMyHotKeyRef);
HotkeyRefs[id] = gMyHotKeyRef;
#endif
}
void UGlobalHotkeys::unregisterHotkey(size_t id) {
#if defined(Q_OS_WIN) || defined(Q_OS_LINUX)
Q_ASSERT(Registered.find(id) != Registered.end() && "Unregistered hotkey");
#endif
#if defined(Q_OS_WIN)
UnregisterHotKey((HWND)winId(), id);
#elif defined(Q_OS_LINUX)
unregLinuxHotkey(id);
#endif
#if defined(Q_OS_WIN) || defined(Q_OS_LINUX)
Registered.remove(id);
#endif
#if defined(Q_OS_MAC)
if (HotkeyRefs.find(id) != HotkeyRefs.end()) {
UnregisterEventHotKey(HotkeyRefs[id]);
}
#endif
}
void UGlobalHotkeys::unregisterAllHotkeys()
{
#ifdef Q_OS_WIN
for (size_t id : Registered)
this->unregisterHotkey(id);
#elif defined(Q_OS_LINUX)
for (size_t id :Registered.keys())
this->unregisterHotkey(id);
#endif
}
UGlobalHotkeys::~UGlobalHotkeys() {
#if defined(Q_OS_WIN)
for (QSet<size_t>::iterator i = Registered.begin(); i != Registered.end(); i++) {
UnregisterHotKey((HWND)winId(), *i);
}
#elif defined(Q_OS_LINUX)
xcb_key_symbols_free(X11KeySymbs);
#endif
}
#if defined(Q_OS_MAC)
void UGlobalHotkeys::onHotkeyPressed(size_t id) {
emit activated(id);
}
#endif
#if defined(Q_OS_WIN)
bool UGlobalHotkeys::winEvent(MSG * message, long * result) {
Q_UNUSED(result);
if (message->message == WM_HOTKEY) {
size_t id = message->wParam;
Q_ASSERT(Registered.find(id) != Registered.end() && "Unregistered hotkey");
emit activated(id);
}
return false;
}
bool UGlobalHotkeys::nativeEvent(const QByteArray &eventType,
void *message, long *result)
{
Q_UNUSED(eventType);
return winEvent((MSG*)message, result);
}
#elif defined(Q_OS_LINUX)
bool UGlobalHotkeys::nativeEventFilter(const QByteArray &eventType, void *message, long *result) {
Q_UNUSED(eventType);
Q_UNUSED(result);
return linuxEvent(static_cast<xcb_generic_event_t*>(message));
}
bool UGlobalHotkeys::linuxEvent(xcb_generic_event_t *message)
{
if ( (message->response_type & ~0x80) == XCB_KEY_PRESS ) {
xcb_key_press_event_t *ev = (xcb_key_press_event_t*)message;
auto ind = Registered.key( {ev->detail, (ev->state & ~XCB_MOD_MASK_2)} );
if (ind == 0) // this is not hotkeys
return false;
emit activated(ind);
return true;
}
return false;
}
void UGlobalHotkeys::regLinuxHotkey(const UKeySequence &keySeq, size_t id)
{
UHotkeyData data;
UKeyData keyData = QtKeyToLinux(keySeq);
xcb_keycode_t *keyC = xcb_key_symbols_get_keycode(X11KeySymbs, keyData.key);
data.keyCode = *keyC;
data.mods = keyData.mods;
xcb_grab_key(X11Connection, 1, X11Wid, data.mods, data.keyCode, XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC);
// NumLk
xcb_grab_key(X11Connection, 1, X11Wid, data.mods | XCB_MOD_MASK_2, data.keyCode,XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC);
Registered.insert(id, data);
}
void UGlobalHotkeys::unregLinuxHotkey(size_t id)
{
UHotkeyData data = Registered.take(id);
xcb_ungrab_key(X11Connection, data.keyCode, X11Wid, data.mods);
xcb_ungrab_key(X11Connection, data.keyCode, X11Wid, data.mods | XCB_MOD_MASK_2);
}
#endif

View file

@ -1,68 +0,0 @@
#pragma once
#include <QWidget>
#include <QAbstractNativeEventFilter>
#include <QSet>
#if defined(Q_OS_LINUX)
#include "xcb/xcb.h"
#include "xcb/xcb_keysyms.h"
#elif defined(Q_OS_MAC)
#include <Carbon/Carbon.h>
#endif
#include "ukeysequence.h"
#include "uexception.h"
#include "uglobal.h"
#if defined(Q_OS_LINUX)
struct UHotkeyData {
xcb_keycode_t keyCode;
int mods;
bool operator ==(const UHotkeyData& data) const {
return data.keyCode == this->keyCode && data.mods == this->mods;
}
};
#endif
class UGLOBALHOTKEY_EXPORT UGlobalHotkeys : public QWidget
#if defined(Q_OS_LINUX)
, public QAbstractNativeEventFilter
#endif
{
Q_OBJECT
public:
explicit UGlobalHotkeys(QWidget *parent = 0);
void registerHotkey(const QString& keySeq, size_t id = 1);
void registerHotkey(const UKeySequence& keySeq, size_t id = 1);
void unregisterHotkey(size_t id = 1);
void unregisterAllHotkeys();
~UGlobalHotkeys();
protected:
#if defined(Q_OS_WIN)
bool winEvent (MSG * message, long * result);
bool nativeEvent(const QByteArray &eventType, void *message, long *result);
#elif defined(Q_OS_LINUX)
bool nativeEventFilter(const QByteArray &eventType, void *message, long *result);
bool linuxEvent(xcb_generic_event_t *message);
void regLinuxHotkey(const UKeySequence& keySeq, size_t id);
void unregLinuxHotkey(size_t id);
#endif
public:
#if defined (Q_OS_MAC)
void onHotkeyPressed(size_t id);
#endif
signals:
void activated(size_t id);
private:
#if defined(Q_OS_WIN)
QSet<size_t> Registered;
#elif defined(Q_OS_LINUX)
QHash<size_t, UHotkeyData> Registered;
xcb_connection_t* X11Connection;
xcb_window_t X11Wid;
xcb_key_symbols_t* X11KeySymbs;
#elif defined(Q_OS_MAC)
QHash<size_t, EventHotKeyRef> HotkeyRefs;
#endif
};

View file

@ -1,144 +0,0 @@
#include "ukeysequence.h"
#include <QDebug>
UKeySequence::UKeySequence(QObject *parent)
: QObject(parent)
{
}
UKeySequence::UKeySequence(const QString& str, QObject *parent)
: QObject(parent)
{
FromString(str);
}
bool IsModifier(int key) {
return (key == Qt::Key_Shift ||
key == Qt::Key_Control ||
key == Qt::Key_Alt ||
key == Qt::Key_Meta);
}
static QString KeyToStr(int key) {
if (key == Qt::Key_Shift) {
return "Shift";
}
if (key == Qt::Key_Control) {
return "Ctrl";
}
if (key == Qt::Key_Alt) {
return "Alt";
}
if (key == Qt::Key_Meta) {
return "Meta";
}
QKeySequence seq(key);
return seq.toString();
}
void UKeySequence::FromString(const QString& str) {
QStringList keys = str.split('+');
for (int i = 0; i < keys.size(); i++) {
AddKey(keys[i]);
}
}
QString UKeySequence::ToString() {
QVector<int> simpleKeys = GetSimpleKeys();
QVector<int> modifiers = GetModifiers();
QStringList result;
for (int i = 0; i < modifiers.size(); i++) {
result.push_back(KeyToStr(modifiers[i]));
}
for (int i = 0; i < simpleKeys.size(); i++) {
result.push_back(KeyToStr(simpleKeys[i]));
}
return result.join('+');
}
QVector<int> UKeySequence::GetSimpleKeys() const {
QVector<int> result;
for (int i = 0; i < Keys.size(); i++) {
if (!IsModifier(Keys[i])) {
result.push_back(Keys[i]);
}
}
return result;
}
QVector<int> UKeySequence::GetModifiers() const {
QVector<int> result;
for (int i = 0; i < Keys.size(); i++) {
if (IsModifier(Keys[i])) {
result.push_back(Keys[i]);
}
}
return result;
}
void UKeySequence::AddModifiers(Qt::KeyboardModifiers mod) {
if (mod == Qt::NoModifier) {
return;
}
if (mod & Qt::ShiftModifier) {
AddKey(Qt::Key_Shift);
}
if (mod & Qt::ControlModifier) {
AddKey(Qt::Key_Control);
}
if (mod & Qt::AltModifier) {
AddKey(Qt::Key_Alt);
}
if (mod & Qt::MetaModifier) {
AddKey(Qt::Key_Meta);
}
}
void UKeySequence::AddKey(const QString& key) {
if (key.contains("+") || key.contains(",")) {
throw UException("Wrong key");
}
QString mod = key.toLower();
qDebug() << "mod: " << mod;
if (mod == "alt") {
AddKey(Qt::Key_Alt);
return;
}
if (mod == "shift" || mod == "shft") {
AddKey(Qt::Key_Shift);
return;
}
if (mod == "control" || mod == "ctrl") {
AddKey(Qt::Key_Control);
return;
}
if (mod == "win" || mod == "meta") {
AddKey(Qt::Key_Meta);
return;
}
QKeySequence seq(key);
if (seq.count() != 1) {
throw UException("Wrong key");
}
AddKey(seq[0]);
}
void UKeySequence::AddKey(int key) {
if (key <= 0) {
return;
}
for (int i = 0; i < Keys.size(); i++) {
if (Keys[i] == key) {
return;
}
}
qDebug() << "Key added: " << key;
Keys.push_back(key);
}
void UKeySequence::AddKey(const QKeyEvent* event) {
AddKey(event->key());
AddModifiers(event->modifiers());
}

View file

@ -1,38 +0,0 @@
#pragma once
#include <QObject>
#include <QString>
#include <QVector>
#include <QStringList>
#include <QKeyEvent>
#include "uexception.h"
#include "uglobal.h"
class UGLOBALHOTKEY_EXPORT UKeySequence : public QObject
{
Q_OBJECT
public:
explicit UKeySequence(QObject *parent = 0);
explicit UKeySequence(const QString& str, QObject *parent = 0);
void FromString(const QString& str);
QString ToString();
void AddKey(int key);
void AddKey(const QString& key);
void AddModifiers(Qt::KeyboardModifiers mod);
void AddKey(const QKeyEvent* event);
inline size_t Size() const {
return Keys.size();
}
inline int operator [] (size_t n) const {
if ((int)n > Keys.size()) {
throw UException("Out of bounds");
}
return Keys[n];
}
QVector<int> GetSimpleKeys() const;
QVector<int> GetModifiers() const;
private:
QVector<int> Keys;
};

View file

@ -128,10 +128,6 @@ InfoPaneDropdown::InfoPaneDropdown(NotificationDBus* notificationEngine, UPowerD
connect(eventTimer, SIGNAL(timeout()), this, SLOT(processTimer()));
eventTimer->start();
UGlobalHotkeys* exitKey = new UGlobalHotkeys(this);
exitKey->registerHotkey("Alt+F7");
connect(exitKey, SIGNAL(activated(size_t)), this, SLOT(on_pushButton_clicked()));
QObjectList allObjects;
allObjects.append(this);

View file

@ -19,7 +19,6 @@
#include "notificationdbus.h"
#include "upowerdbus.h"
#include "endsessionwait.h"
#include "UGlobalHotkey-master/uglobalhotkeys.h"
#include <sys/sysinfo.h>
class UPowerDBus;

View file

@ -59,10 +59,6 @@ MainWindow::MainWindow(QWidget *parent) :
ui->batteryFrame->setVisible(false);
}
UGlobalHotkeys* infoKey = new UGlobalHotkeys(this);
infoKey->registerHotkey("Alt+F6");
connect(infoKey, SIGNAL(activated(size_t)), this, SLOT(pullDownGesture()));
infoPane = new InfoPaneDropdown(ndbus, updbus);
infoPane->setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
connect(infoPane, SIGNAL(networkLabelChanged(QString)), this, SLOT(internetLabelChanged(QString)));

View file

@ -19,7 +19,6 @@
#include "menu.h"
#include "notificationdbus.h"
#include "upowerdbus.h"
#include "UGlobalHotkey-master/uglobalhotkeys.h"
#include "infopanedropdown.h"
#include "touchkeyboard.h"
#include "systrayicons.h"

View file

@ -38,6 +38,7 @@ void MouseScrollWidget::mouseMoveEvent(QMouseEvent *event) {
void MouseScrollWidget::wheelEvent(QWheelEvent *event) {
//this->scroll(event->delta(), 0);
if (event->orientation() == Qt::Vertical) {
//It's more natural to scroll downwards to go to the right, so subtract delta rather than add.
this->horizontalScrollBar()->setValue(this->horizontalScrollBar()->value() - event->delta());
}
}

View file

@ -140,7 +140,7 @@ void SniIcon::ReloadIcon() {
this->setToolTip(interface->property("Title").toString());
}
void SniIcon::mousePressEvent(QMouseEvent *event) {
void SniIcon::mouseReleaseEvent(QMouseEvent *event) {
QPoint pos = this->mapToGlobal(event->pos());
if (event->button() == Qt::LeftButton) {
interface->call("Activate", pos.x(), pos.y());

View file

@ -55,7 +55,7 @@ private:
QString service;
QDBusInterface* interface;
void mousePressEvent(QMouseEvent* event);
void mouseReleaseEvent(QMouseEvent* event);
void wheelEvent(QWheelEvent* event);
};

View file

@ -30,9 +30,6 @@ SOURCES += main.cpp\
background.cpp \
notificationdbus.cpp \
notificationdialog.cpp \
UGlobalHotkey-master/uexception.cpp \
UGlobalHotkey-master/uglobalhotkeys.cpp \
UGlobalHotkey-master/ukeysequence.cpp \
upowerdbus.cpp \
infopanedropdown.cpp \
clickablelabel.cpp \
@ -64,11 +61,6 @@ HEADERS += mainwindow.h \
notificationdbus.h \
notifications_adaptor.h \
notificationdialog.h \
UGlobalHotkey-master/hotkeymap.h \
UGlobalHotkey-master/uexception.h \
UGlobalHotkey-master/uglobal.h \
UGlobalHotkey-master/uglobalhotkeys.h \
UGlobalHotkey-master/ukeysequence.h \
upowerdbus.h \
infopanedropdown.h \
clickablelabel.h \

View file

@ -31,7 +31,7 @@ void UPowerDBus::devicesChanged() {
if (reply.isValid()) { //Check if the reply is ok
for (QDBusObjectPath device : reply.value()) {
if (device.path().contains("battery") || device.path().contains("media_player") || device.path().contains("computer")) { //This is a battery or media player or tablet computer
if (device.path().contains("battery") || device.path().contains("media_player") || device.path().contains("computer") || device.path().contains("phone")) { //This is a battery or media player or tablet computer
QDBusConnection::systemBus().connect("org.freedesktop.UPower", device.path(),
"org.freedesktop.DBus.Properties", "PropertiesChanged", this,
SLOT(DeviceChanged()));
@ -185,7 +185,7 @@ void UPowerDBus::DeviceChanged() {
} else {
displayOutput.append("No Battery Inserted");
}
} else if (i->path().contains("media_player") || i->path().contains("computer")) {
} else if (i->path().contains("media_player") || i->path().contains("computer") || i->path().contains("phone")) {
//This is an external media player (or tablet)
//Get the model of this media player
QString model = i->property("Model").toString();