Skip to content

Commit

Permalink
fixed group margin
Browse files Browse the repository at this point in the history
  • Loading branch information
kermitfrog committed Jul 11, 2016
1 parent def27c1 commit a1897ac
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 198 deletions.
131 changes: 0 additions & 131 deletions freestyle2.xml

This file was deleted.

12 changes: 9 additions & 3 deletions kbddisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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")
{
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
7 changes: 6 additions & 1 deletion keydialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}
Expand Down
118 changes: 56 additions & 62 deletions keymapping.xml
Original file line number Diff line number Diff line change
@@ -1,103 +1,97 @@
<?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'/>
<key lxcode="19" xevdevid='AE10'/>
<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'/>
<key lxcode="32" xevdevid='AD09'/>
<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>
17 changes: 17 additions & 0 deletions qgraphicskeyitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
3 changes: 2 additions & 1 deletion qgraphicskeyitem.h
Original file line number Diff line number Diff line change
Expand Up @@ -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; };
Expand Down

0 comments on commit a1897ac

Please sign in to comment.