aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/core/lumina-desktop-unified/src-events
diff options
context:
space:
mode:
authorKen Moore <ken@ixsystems.com>2017-07-08 09:59:59 -0400
committerKen Moore <ken@ixsystems.com>2017-07-08 09:59:59 -0400
commitac3fa9168954faabc3acd37dde82479340b78283 (patch)
treed47f14a0b3a2c90e867abe6927978eeb50e21a70 /src-qt5/core/lumina-desktop-unified/src-events
parentA few more updates in the X11->Qt button mapping (diff)
downloadlumina-ac3fa9168954faabc3acd37dde82479340b78283.tar.gz
lumina-ac3fa9168954faabc3acd37dde82479340b78283.tar.bz2
lumina-ac3fa9168954faabc3acd37dde82479340b78283.zip
Clean up the LShortcutEvents class so it uses Qt::Key values now instead of raw keycodes.
Diffstat (limited to 'src-qt5/core/lumina-desktop-unified/src-events')
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-events/LShortcutEvents.cpp46
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-events/LShortcutEvents.h7
2 files changed, 41 insertions, 12 deletions
diff --git a/src-qt5/core/lumina-desktop-unified/src-events/LShortcutEvents.cpp b/src-qt5/core/lumina-desktop-unified/src-events/LShortcutEvents.cpp
index f8bb20d3..1b78da21 100644
--- a/src-qt5/core/lumina-desktop-unified/src-events/LShortcutEvents.cpp
+++ b/src-qt5/core/lumina-desktop-unified/src-events/LShortcutEvents.cpp
@@ -106,15 +106,34 @@ void LShortcutEvents::CheckMouseSequence(WId win, NativeWindowSystem::MouseButto
}
QString LShortcutEvents::keylistToString(){
+ if(keylist.isEmpty()){ return ""; }
QString shortcut;
+ QList<int> keys; int ckey = 0;
for(int i=0; i<keylist.length(); i++){
- if(i>0){ shortcut.append("+"); }
- shortcut.append( QString::number(keylist[i]) );
+ if(i == keylist.length()-1){ ckey+=keylist[i]; } //always treat the last key as a non-modifier
+ else if(keylist[i] == Qt::Key_Control){ ckey+=Qt::CTRL; } //use the modifier form of the key
+ else if(keylist[i] == Qt::Key_Alt){ ckey += Qt::ALT; }
+ else if(keylist[i] == Qt::Key_Shift){ ckey += Qt::SHIFT; }
+ else if(keylist[i] == Qt::Key_Meta){ ckey += Qt::META; }
+ else{ ckey+= keylist[i]; keys << ckey; ckey = 0; } //non-modifier - need to finish current mod+key combo and start a new one
+ }
+ if(ckey!=0){ keys << ckey; } //add in the last one as well
+ if(keys.length() < 1){ return ""; }
+ QKeySequence seq;
+ switch(keys.length()){
+ case 1:
+ seq = QKeySequence(keys[0]); break;
+ case 2:
+ seq = QKeySequence(keys[0], keys[1]); break;
+ case 3:
+ seq = QKeySequence(keys[0], keys[1], keys[2]); break;
+ default:
+ seq = QKeySequence(keys[0],keys[1], keys[2], keys[3]); break;
}
/*qDebug() << "KeyList to String:";
- qDebug() << " keys:" << keylist;
- qDebug() << " string:" << shortcut;*/
- return shortcut;
+ qDebug() << " keys:" << seq;
+ qDebug() << " string:" << seq.toString();*/
+ return seq.toString();
}
void LShortcutEvents::evaluateShortcutAction(QString action){
@@ -123,6 +142,8 @@ void LShortcutEvents::evaluateShortcutAction(QString action){
if(action.startsWith("Exec=")){
emit LaunchApplication(action.section("=",1,-1));
return;
+ }else if(action.startsWith("Launch=")){
+ emit LaunchStandardApplication(action.section("=",1,-1));
}
//Specific Internal actions
action = action.toLower();
@@ -135,9 +156,9 @@ void LShortcutEvents::evaluateShortcutAction(QString action){
}
// === PUBLIC SLOTS ===
-void LShortcutEvents::KeyPress(WId window, int key){
+void LShortcutEvents::KeyPress(WId window, Qt::Key key){
if(window!=WIN){ keylist.clear(); WIN = window; }
- if(!keylist.contains(key)){
+ /*if(!keylist.contains(key)){
//Put it in the list in ascending order
bool found = false;
for(int i=0; i<keylist.length() && !found; i++){
@@ -145,15 +166,22 @@ void LShortcutEvents::KeyPress(WId window, int key){
}
if(!found){ keylist << key; }
evaluated = false;
+ }*/
+ if(!keylist.isEmpty()){
+ if( keylist.last()!=key ){ keylist << key; }
+ }else{
+ keylist << key;
}
//Evaluate the key sequence only when the first one is released
clearTimer->start(); //will "restart" if already running
}
-void LShortcutEvents::KeyRelease(WId window, int key){
+void LShortcutEvents::KeyRelease(WId window, Qt::Key key){
if(window!=WIN){ keylist.clear(); return; }
if(!evaluated){ CheckKeySequence(WIN); } //run this "before" removing the key from the list
- keylist.removeAll(key);
+ for(int i=keylist.length()-1; i>=0; i--){
+ if(keylist[i] == key){ keylist.removeAt(i); break; }
+ }
clearTimer->start(); //will "restart" if already running
}
diff --git a/src-qt5/core/lumina-desktop-unified/src-events/LShortcutEvents.h b/src-qt5/core/lumina-desktop-unified/src-events/LShortcutEvents.h
index a8ab4b38..4560cb1f 100644
--- a/src-qt5/core/lumina-desktop-unified/src-events/LShortcutEvents.h
+++ b/src-qt5/core/lumina-desktop-unified/src-events/LShortcutEvents.h
@@ -22,7 +22,7 @@ public:
void stop();
private:
- QList<int> keylist; //keys currently held down (NOTE: QKeySequence has a max of 4 keys for combinations)
+ QList< Qt::Key > keylist; //keys currently held down
WId WIN; //current window being acted on by the keys
QTimer *clearTimer; //used to clear the internal keylist every once in a while if no events come in.
bool evaluated;
@@ -34,8 +34,8 @@ private:
void evaluateShortcutAction(QString action);
public slots:
- void KeyPress(WId window, int key);
- void KeyRelease(WId window, int key);
+ void KeyPress(WId window, Qt::Key key);
+ void KeyRelease(WId window, Qt::Key key);
void MousePress(WId window, NativeWindowSystem::MouseButton);
void MouseRelease(WId window, NativeWindowSystem::MouseButton);
void clearKeys();
@@ -66,6 +66,7 @@ signals:
//General Utility Launch
void LaunchApplication(QString exec);
+ void LaunchStandardApplication(QString app); //standard app like "terminal", "browser", "email", "settings", etc..
};
bgstack15