diff --git a/freestyle2.xml b/freestyle2.xml deleted file mode 100644 index fa2a89a..0000000 --- a/freestyle2.xml +++ /dev/null @@ -1,131 +0,0 @@ -<?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> diff --git a/kbddisplay.cpp b/kbddisplay.cpp index 7d9e982..221038d 100644 --- a/kbddisplay.cpp +++ b/kbddisplay.cpp @@ -49,7 +49,7 @@ KbdDisplay::KbdDisplay() ui->graphicsView->scale(4.0, 4.0); //paintStuff(); - loadKbd(QDir::currentPath() + "/freestyle2.xml"); + loadKbd(QDir::currentPath() + "/keyboards/default.xml"); // set up table model = new KeyItemModel(); @@ -108,7 +108,7 @@ QGraphicsItem* KbdDisplay::drawGroup(QXmlStreamReader &reader, QGraphicsItemGrou if (!reader.isStartElement()) continue; - double_t x = 0.0, y = 0.0; + double_t x = 0.0, y = 0.0, margin = 0.5; attr = reader.attributes(); if (attr.hasAttribute("keywidth")) keywidth = attr.value("keywidth").toDouble(); @@ -141,6 +141,7 @@ QGraphicsItem* KbdDisplay::drawGroup(QXmlStreamReader &reader, QGraphicsItemGrou groups[id] = (QGraphicsItemGroup*) item; groupX = x; groupY = y; + margin = 0.0; } else if (reader.name() == "key") { @@ -161,6 +162,11 @@ QGraphicsItem* KbdDisplay::drawGroup(QXmlStreamReader &reader, QGraphicsItemGrou } item = new QGraphicsKeyItem(polygon); } + else if (attr.hasAttribute("d")) + { + qreal diameter = attr.value("d").toDouble(); + item = new QGraphicsKeyItem(diameter); + } else { double_t w = keywidth, h = keyheight; @@ -207,7 +213,7 @@ QGraphicsItem* KbdDisplay::drawGroup(QXmlStreamReader &reader, QGraphicsItemGrou } - item->moveBy(groupX + x + p.x() + 0.5, groupY + y + p.y() + 0.5); + item->moveBy(groupX + x + p.x() + margin, groupY + y + p.y() + margin); //item->moveBy(groupX + x + p.x() + 1, groupY + y + p.y() + 1); //item->moveBy(groupX + x + p.x() , groupY + y + p.y()); lastItem = item; diff --git a/keydialog.cpp b/keydialog.cpp index 20a3f61..f9a8719 100644 --- a/keydialog.cpp +++ b/keydialog.cpp @@ -57,6 +57,11 @@ void KeyDialog::styleChanged(QListWidgetItem* item) int KeyDialog::exec(KeyItem* key) { + if (key == nullptr) { + qDebug() << "can't open dialog for unknown key!"; + return Rejected; + } + setWindowTitle(tr("Set labels for ") + key->keyId); if (key == nullptr || ui->styleChooser->count() == 0) return QDialog::Rejected; @@ -136,7 +141,7 @@ void KeyDialog::deleteStyle() QString name = ui->styleChooser->currentItem()->text(); if (QMessageBox::question(this, "Really Delete?", "Really delete style " + name) == QMessageBox::Yes) { - // FIXME occasional crash when style is used an some key -> race conditions + // FIXME occasional crash when style is used on some key -> race conditions StyleModel::model->deleteStyle(name); } } diff --git a/keymapping.xml b/keymapping.xml index 93eda51..cecd92d 100644 --- a/keymapping.xml +++ b/keymapping.xml @@ -1,62 +1,13 @@ <?xml version="1.0" encoding="UTF-8"?> <keymapping> - <key lxcode="9" xevdevid="ESC"/> - - <key lxcode="119" xevdevid='DEL'/> <key lxcode="0" xevdevid='FN' /> - <key lxcode="135" xevdevid='MENU'/> - - <key lxcode="67" xevdevid='FK01'/> - <key lxcode="68" xevdevid='FK02'/> - <key lxcode="69" xevdevid='FK03'/> - <key lxcode="70" xevdevid='FK04'/> - <key lxcode="71" xevdevid='FK05'/> - <key lxcode="72" xevdevid='FK06'/> - <key lxcode="73" xevdevid='FK07'/> - - <key lxcode="49" xevdevid='TLDE'/> + <key lxcode="9" xevdevid="ESC"/> <key lxcode="10" xevdevid='AE01'/> <key lxcode="11" xevdevid='AE02'/> <key lxcode="12" xevdevid='AE03'/> <key lxcode="13" xevdevid='AE04'/> <key lxcode="14" xevdevid='AE05'/> <key lxcode="15" xevdevid='AE06'/> - - <key lxcode="23" xevdevid='TAB'/> - <key lxcode="24" xevdevid='AD01'/> - <key lxcode="25" xevdevid='AD02'/> - <key lxcode="26" xevdevid='AD03'/> - <key lxcode="27" xevdevid='AD04'/> - <key lxcode="28" xevdevid='AD05'/> - - <key lxcode="66" xevdevid='CAPS'/> - <key lxcode="38" xevdevid='AC01'/> - <key lxcode="39" xevdevid='AC02'/> - <key lxcode="40" xevdevid='AC03'/> - <key lxcode="41" xevdevid='AC04'/> - <key lxcode="42" xevdevid='AC05'/> - - <key lxcode="50" xevdevid='LFSH'/> - <key lxcode="94" xevdevid='LSGT'/> - <key lxcode="52" xevdevid='AB01'/> - <key lxcode="53" xevdevid='AB02'/> - <key lxcode="54" xevdevid='AB03'/> - <key lxcode="55" xevdevid='AB04'/> - <key lxcode="56" xevdevid='AB05'/> - - <key lxcode="37" xevdevid='LCTL'/> - <key lxcode="133" xevdevid='LWIN'/> - <key lxcode="64" xevdevid='LALT'/> - <key lxcode="65" xevdevid='SPCE'/> - - <key lxcode="74" xevdevid='FK08'/> - <key lxcode="75" xevdevid='FK09'/> - <key lxcode="76" xevdevid='FK10'/> - <key lxcode="95" xevdevid='FK11'/> - <key lxcode="96" xevdevid='FK12'/> - <key lxcode="107" xevdevid='PRSC'/> - <key lxcode="127" xevdevid='PAUS'/> - <key lxcode="16" xevdevid='AE07'/> <key lxcode="17" xevdevid='AE08'/> <key lxcode="18" xevdevid='AE09'/> @@ -64,8 +15,12 @@ <key lxcode="20" xevdevid='AE11'/> <key lxcode="21" xevdevid='AE12'/> <key lxcode="22" xevdevid='BKSP'/> - <key lxcode="110" xevdevid='HOME'/> - + <key lxcode="23" xevdevid='TAB'/> + <key lxcode="24" xevdevid='AD01'/> + <key lxcode="25" xevdevid='AD02'/> + <key lxcode="26" xevdevid='AD03'/> + <key lxcode="27" xevdevid='AD04'/> + <key lxcode="28" xevdevid='AD05'/> <key lxcode="29" xevdevid='AD06'/> <key lxcode="30" xevdevid='AD07'/> <key lxcode="31" xevdevid='AD08'/> @@ -73,31 +28,70 @@ <key lxcode="33" xevdevid='AD10'/> <key lxcode="34" xevdevid='AD11'/> <key lxcode="35" xevdevid='AD12'/> - <key lxcode="36" xevdevid='RTRN'/> - <key lxcode="115" xevdevid='END'/> - <key lxcode="112" xevdevid='PGUP'/> - + <key lxcode="37" xevdevid='LCTL'/> + <key lxcode="38" xevdevid='AC01'/> + <key lxcode="39" xevdevid='AC02'/> + <key lxcode="40" xevdevid='AC03'/> + <key lxcode="41" xevdevid='AC04'/> + <key lxcode="42" xevdevid='AC05'/> <key lxcode="43" xevdevid='AC06'/> <key lxcode="44" xevdevid='AC07'/> <key lxcode="45" xevdevid='AC08'/> <key lxcode="46" xevdevid='AC09'/> <key lxcode="47" xevdevid='AC10'/> <key lxcode="48" xevdevid='AC11'/> + <key lxcode="49" xevdevid='TLDE'/> + <key lxcode="50" xevdevid='LFSH'/> <key lxcode="51" xevdevid='BKSL'/> - + <key lxcode="52" xevdevid='AB01'/> + <key lxcode="53" xevdevid='AB02'/> + <key lxcode="54" xevdevid='AB03'/> + <key lxcode="55" xevdevid='AB04'/> + <key lxcode="56" xevdevid='AB05'/> <key lxcode="57" xevdevid='AB06'/> <key lxcode="58" xevdevid='AB07'/> <key lxcode="59" xevdevid='AB08'/> <key lxcode="60" xevdevid='AB09'/> <key lxcode="61" xevdevid='AB10'/> <key lxcode="62" xevdevid='RTSH'/> - <key lxcode="111" xevdevid='UP'/> - <key lxcode="117" xevdevid='PGDN'/> - - <key lxcode="108" xevdevid='RALT' /> + <key lxcode="64" xevdevid='LALT'/> + <key lxcode="65" xevdevid='SPCE'/> + <key lxcode="66" xevdevid='CAPS'/> + <key lxcode="67" xevdevid='FK01'/> + <key lxcode="68" xevdevid='FK02'/> + <key lxcode="69" xevdevid='FK03'/> + <key lxcode="70" xevdevid='FK04'/> + <key lxcode="71" xevdevid='FK05'/> + <key lxcode="72" xevdevid='FK06'/> + <key lxcode="73" xevdevid='FK07'/> + <key lxcode="74" xevdevid='FK08'/> + <key lxcode="75" xevdevid='FK09'/> + <key lxcode="76" xevdevid='FK10'/> + <key lxcode="78" xevdevid='SCLK'/> + <key lxcode="94" xevdevid='LSGT'/> + <key lxcode="95" xevdevid='FK11'/> + <key lxcode="96" xevdevid='FK12'/> <key lxcode="105" xevdevid='RCTL'/> + <key lxcode="107" xevdevid='PRSC'/> + <key lxcode="108" xevdevid='RALT' /> + <key lxcode="110" xevdevid='HOME'/> + <key lxcode="111" xevdevid='UP'/> + <key lxcode="112" xevdevid='PGUP'/> <key lxcode="113" xevdevid='LEFT'/> - <key lxcode="116" xevdevid='DOWN'/> <key lxcode="114" xevdevid='RGHT'/> + <key lxcode="115" xevdevid='END'/> + <key lxcode="116" xevdevid='DOWN'/> + <key lxcode="117" xevdevid='PGDN'/> + <key lxcode="118" xevdevid='INS'/> + <key lxcode="119" xevdevid='DEL'/> + <key lxcode="121" xevdevid='MUTE'/> + <key lxcode="122" xevdevid='VOL-'/> + <key lxcode="123" xevdevid='VOL+'/> + <key lxcode="127" xevdevid='PAUS'/> + <key lxcode="133" xevdevid='LWIN'/> + <key lxcode="135" xevdevid='MENU'/> + <key lxcode="156" xevdevid='I156'/> + <key lxcode="166" xevdevid='I166'/> + <key lxcode="167" xevdevid='I167'/> </keymapping> diff --git a/qgraphicskeyitem.cpp b/qgraphicskeyitem.cpp index bb28b66..fea1380 100644 --- a/qgraphicskeyitem.cpp +++ b/qgraphicskeyitem.cpp @@ -94,6 +94,23 @@ QGraphicsKeyItem::QGraphicsKeyItem(const QPolygonF& polygon, QGraphicsItem* pare commonInit(); } +QGraphicsKeyItem::QGraphicsKeyItem(qreal diameter, QGraphicsItem* parent): QGraphicsPolygonItem(parent) +{ + QPolygonF mockCircle; + QLineF helper; + helper.setP1(QPointF(diameter/2, diameter/2)); + helper.setP2(QPointF(diameter, diameter/2)); +// mockCircle << helper.p2(); + for (int i = 1; i < 36; i++) { + helper.setAngle(10.0 * i); + mockCircle << helper.p2(); + } + helper.setAngle(0.0); + mockCircle << helper.p2(); + setPolygon(mockCircle); +// qDebug() << "mockCircle: " << mockCircle; + commonInit(); +} void QGraphicsKeyItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) { diff --git a/qgraphicskeyitem.h b/qgraphicskeyitem.h index 94c0678..bdf841e 100644 --- a/qgraphicskeyitem.h +++ b/qgraphicskeyitem.h @@ -36,7 +36,8 @@ class QGraphicsKeyItem : public QGraphicsPolygonItem QGraphicsKeyItem(const QPolygonF& polygon, QGraphicsItem* parent = Q_NULLPTR); QGraphicsKeyItem(const QRectF& polygon, QGraphicsItem* parent = Q_NULLPTR); - QGraphicsKeyItem(qreal x, qreal y, qreal width, qreal height, QGraphicsItem* parent = Q_NULLPTR); + QGraphicsKeyItem(qreal diameter, QGraphicsItem* parent = Q_NULLPTR); + virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget); void setKey(KeyItem * key); virtual int type() const {return Type; };