-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3a62426
commit 8d49dfc
Showing
20 changed files
with
1,435 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<keyboard name="Kinesis Freestyle 2" keywidth="18" keyheight="18"> | ||
<group id='left'> | ||
<key id="ESC" x="0" y="0" w='38'/> | ||
<group id='extra' x="0" y="2" relativeTo="ESC" corner='sw'> | ||
<key id='LALT+LEFT'/> | ||
<key id='LALT+RGHT' relativeTo='LALT+LEFT' corner='ne'/> | ||
<key id='LCTL+AB01' relativeTo='LALT+LEFT' corner='sw' y='0.5'/> | ||
<key id='LALT+HOME' relativeTo='LCTL+AB01' corner='ne'/> | ||
<key id='LCTL+AB02' relativeTo='LCTL+AB01' corner='sw' y='0.5'/> | ||
<key id='DEL' relativeTo='LCTL+AB02' corner='ne'/> | ||
<key id='LCTL+AB03' relativeTo='LCTL+AB02' corner='sw' y='0.5'/> | ||
<key id='LCTL+AB04' relativeTo='LCTL+AB03' corner='ne'/> | ||
<key id='FN' relativeTo='LCTL+AB03' corner='sw' y='0.5'/> | ||
<key id='MENU' relativeTo='FN' corner='ne'/> | ||
</group> | ||
<row id="f1_7" x="2" y="0" relativeTo="ESC" corner='ne'> | ||
<key id='FK01'/> | ||
<key id='FK02'/> | ||
<key id='FK03'/> | ||
<key id='FK04'/> | ||
<key id='FK05'/> | ||
<key id='FK06'/> | ||
<key id='FK07'/> | ||
</row> | ||
<row id="L1" x="0" y="2" relativeTo="f1_7" corner='sw'> | ||
<key id='TLDE'/> | ||
<key id='AE01'/> | ||
<key id='AE02'/> | ||
<key id='AE03'/> | ||
<key id='AE04'/> | ||
<key id='AE05'/> | ||
<key id='AE06'/> | ||
</row> | ||
<row id="L2" x="0" y="0" relativeTo="L1" corner='sw'> | ||
<key id='TAB' w='29'/> | ||
<key id='AD01'/> | ||
<key id='AD02'/> | ||
<key id='AD03'/> | ||
<key id='AD04'/> | ||
<key id='AD05'/> | ||
</row> | ||
<row id="L3" x="0" y="0" relativeTo="L2" corner='sw'> | ||
<key id='CAPS' w='26'/> | ||
<key id='AC01' x='7'/> | ||
<key id='AC02'/> | ||
<key id='AC03'/> | ||
<key id='AC04'/> | ||
<key id='AC05'/> | ||
</row> | ||
<row id="L4" x="0" y="0" relativeTo="L3" corner='sw'> | ||
<key id='LFSH' w='20'/> | ||
<key id='LSGT'/> | ||
<key id='AB01'/> | ||
<key id='AB02'/> | ||
<key id='AB03'/> | ||
<key id='AB04'/> | ||
<key id='AB05'/> | ||
</row> | ||
<row id="L5" x="0" y="0" relativeTo="L4" corner='sw'> | ||
<key id='LCTL' w='28'/> | ||
<key id='LWIN' /> | ||
<key id='LALT' w='23'/> | ||
<key id='SPCE' w='64'/> | ||
</row> | ||
</group> | ||
|
||
<group id='right' relativeTo='left' x='5' corner='ne'> | ||
<row id="f8_PAUS" x="5" y="0" > | ||
<key id='FK08'/> | ||
<key id='FK09'/> | ||
<key id='FK10'/> | ||
<key id='FK11'/> | ||
<key id='FK12'/> | ||
<key id='PRSC'/> | ||
<key id='DEL' w='37'/> | ||
<key id='PAUS'/> | ||
</row> | ||
<row id="R1" x="0" y="2" relativeTo="f8_PAUS" corner='sw'> | ||
<key id='AE07'/> | ||
<key id='AE08'/> | ||
<key id='AE09'/> | ||
<key id='AE10'/> | ||
<key id='AE11'/> | ||
<key id='AE12'/> | ||
<key id='BKSP' w='37'/> | ||
<key id='HOME'/> | ||
</row> | ||
<row id="R2" x="-5" y="0" relativeTo="R1" corner='sw'> | ||
<key id='AD06'/> | ||
<key id='AD07'/> | ||
<key id='AD08'/> | ||
<key id='AD09'/> | ||
<key id='AD10'/> | ||
<key id='AD11'/> | ||
<key id='AD12'/> | ||
</row> | ||
<group id='RETURN' x='0.25' relativeTo='R2' corner='ne'> | ||
<key id='RTRN' polygon='0,0 27,0 27,37.5 4,37.5 4,18 0,18' /> | ||
<key id='END'/> | ||
<key id='PGUP' y='0.5' relativeTo='END' corner='sw'/> | ||
</group> | ||
<row id="R3" x="2" y="0" relativeTo="R2" corner='sw'> | ||
<key id='AC06'/> | ||
<key id='AC07'/> | ||
<key id='AC08'/> | ||
<key id='AC09'/> | ||
<key id='AC10'/> | ||
<key id='AC11'/> | ||
<key id='BKSL'/> | ||
</row> | ||
<row id="R4" x="5" y="0" relativeTo="R3" corner='sw'> | ||
<key id='AB06'/> | ||
<key id='AB07'/> | ||
<key id='AB08'/> | ||
<key id='AB09'/> | ||
<key id='AB10'/> | ||
<key id='RTSH' w='26'/> | ||
<key id='UP' x='7'/> | ||
<key id='PGDN'/> | ||
</row> | ||
<row id="R5" x="-7" y="0" relativeTo="R4" corner='sw'> | ||
<key id='SPCE' w='66'/> | ||
<key id='RALT' w='23'/> | ||
<key id='RCTL' w='27'/> | ||
<key id='LEFT' x='5'/> | ||
<key id='DOWN'/> | ||
<key id='RGHT'/> | ||
</row> | ||
</group> | ||
</keyboard> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
/* | ||
* <one line to give the program's name and a brief idea of what it does.> | ||
* Copyright (C) 2016 Arek <[email protected]> | ||
* | ||
* This program 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. | ||
* | ||
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
|
||
#include "keyboardview.h" | ||
#include "qgraphicskeyitem.h" | ||
#include <QContextMenuEvent> | ||
#include <QDebug> | ||
#include <QSvgGenerator> | ||
#include <QProcess> | ||
#include <QMessageBox> | ||
|
||
KeyboardView::KeyboardView(QWidget* parent) | ||
: QGraphicsView(parent) | ||
{ | ||
keyDialog = new KeyDialog(); | ||
stylechooser = keyDialog->getStyleChooser(); | ||
connect(stylechooser, SIGNAL(itemChanged(QListWidgetItem*)), | ||
this, SLOT(setStyle(QListWidgetItem*))); | ||
connect(stylechooser, SIGNAL(itemClicked(QListWidgetItem*)), | ||
this, SLOT(setStyle(QListWidgetItem*))); | ||
} | ||
|
||
void KeyboardView::setStyle(QListWidgetItem* item) | ||
{ | ||
if (currentKey) | ||
currentKey->setStyle(item->data(Qt::DisplayRole).toString(), currentIndex); | ||
} | ||
|
||
void KeyboardView::setModel(KeyItemModel* model) | ||
{ | ||
if (this->model != nullptr) | ||
QObject::disconnect(this->model, 0, stylechooser, 0); | ||
this->model = model; | ||
connect(model, SIGNAL(stylesChanged()), stylechooser, SLOT(updateStyles())); | ||
stylechooser->updateStyles(); | ||
} | ||
|
||
void KeyboardView::contextMenuEvent(QContextMenuEvent* event) | ||
{ | ||
QGraphicsKeyItem *keyitem = nullptr; | ||
foreach(QGraphicsItem *item, items(event->pos())) { | ||
if (item->type() != QGraphicsKeyItem::Type) | ||
continue; | ||
keyitem = (QGraphicsKeyItem*)item; | ||
break; | ||
} | ||
if (keyitem == nullptr) | ||
return; | ||
currentKey = keyitem->getKey(); | ||
currentIndex = keyitem->getPartIndex(mapToScene(event->pos())); | ||
keyDialog->exec(currentKey); | ||
|
||
|
||
} | ||
|
||
void KeyboardView::keyPressEvent(QKeyEvent* event) | ||
{ | ||
/*qDebug("Key( %d ), nativeScanCode( %d ), nativeVirtualKey( %d )", | ||
event->key(), event->nativeScanCode(), event->nativeVirtualKey() | ||
);*/ | ||
currentKey = model->codeToKeyItemMap[event->nativeScanCode()]; | ||
// qDebug() << currentKey->keyId << " : " << event->nativeScanCode(); | ||
keyDialog->exec(currentKey); | ||
|
||
QGraphicsView::keyPressEvent(event); | ||
} | ||
|
||
void KeyboardView::autoMap() | ||
{ | ||
QList<int> codes = model->codeToKeyItemMap.keys(); | ||
QString platform = QGuiApplication::platformName(); | ||
if (platform == "xcb") { | ||
QProcess xmodmap; | ||
xmodmap.setProgram("xmodmap"); | ||
QStringList args; | ||
args.append("-pk"); | ||
xmodmap.setArguments(args); | ||
xmodmap.start(); | ||
if (!xmodmap.waitForFinished()) { | ||
QMessageBox::warning(this, "Meh!", | ||
"xmodmap failed or is not installed"); | ||
return; | ||
} | ||
QString outString = QString(xmodmap.readAllStandardOutput()); | ||
QStringList output = outString.split('\n'); | ||
for(int i = 0; i < output.length(); i++) { | ||
bool ok; | ||
QStringList line = output[i].trimmed().split( | ||
QRegExp("\\s"), QString::SkipEmptyParts); | ||
if (line.length() < 3) | ||
continue; | ||
int code = line[0].toInt(&ok); | ||
if (!ok) | ||
continue; | ||
KeyItem * key = model->codeToKeyItemMap[code]; | ||
if (key == nullptr) | ||
continue; | ||
int value = line[1].toInt(&ok, 16); | ||
QString name = line[2].mid(1, line[2].length()-2); | ||
|
||
if (name.length() > 1 && value < 255) | ||
name = QChar(value); | ||
key->labelTop=name; | ||
key->updateItems(); | ||
} | ||
} | ||
else | ||
QMessageBox::information(this, "Meh!", | ||
"sorry, this function currently only works on X11"); | ||
} | ||
|
||
|
||
void KeyboardView::exportSVG(QString filename) | ||
{ | ||
QSvgGenerator generator; | ||
generator.setFileName(filename); | ||
|
||
QRect rect = scene()->sceneRect().toRect(); | ||
const double_t scale = 3.0; | ||
rect.setRect(rect.x() * scale, rect.y() * scale, | ||
rect.width() * scale, rect.height() * scale); | ||
|
||
|
||
generator.setSize(rect.size()); | ||
generator.setViewBox(rect); | ||
|
||
QPainter painter( &generator ); | ||
scene()->render( &painter ); | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* <one line to give the program's name and a brief idea of what it does.> | ||
* Copyright (C) 2016 Arek <[email protected]> | ||
* | ||
* This program 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. | ||
* | ||
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
|
||
#ifndef KEYBOARDVIEW_H | ||
#define KEYBOARDVIEW_H | ||
|
||
#include <QtWidgets/QGraphicsView> | ||
#include "stylechooser.h" | ||
#include "keyitemmodel.h" | ||
#include "keydialog.h" | ||
|
||
class KeyboardView : public QGraphicsView | ||
{ | ||
Q_OBJECT | ||
public: | ||
KeyboardView(QWidget* parent = 0); | ||
void setModel(KeyItemModel* model); | ||
KeyDialog *keyDialog; | ||
public slots: | ||
void setStyle(QListWidgetItem* item); | ||
void exportSVG(QString filename); | ||
void autoMap(); | ||
//void updateItem(KeyItem* key); | ||
|
||
protected: | ||
KeyItem * currentKey = nullptr; | ||
int currentIndex = 0; | ||
virtual void contextMenuEvent(QContextMenuEvent* event); | ||
StyleChooser *stylechooser; | ||
KeyItemModel *model = nullptr; | ||
virtual void keyPressEvent(QKeyEvent *event); | ||
bool autoMapping = false; | ||
}; | ||
|
||
#endif // KEYBOARDVIEW_H |
Oops, something went wrong.