diff --git a/nagisa/src/keybutton.cpp b/nagisa/src/keybutton.cpp
index ee53a05..f9cdc6b 100644
--- a/nagisa/src/keybutton.cpp
+++ b/nagisa/src/keybutton.cpp
@@ -48,6 +48,9 @@
}
+int KeyButton::buttonSize = 20;
+
+
KeyButton::KeyButton(QWidget *parent,
unsigned int pos_x,unsigned int pos_y,
unsigned int width, unsigned int height,const QColor &keycolor,
@@ -67,8 +70,8 @@
// QToolTip::add(this,l.replace('\n',' ') + "\n[" + event + "]");
setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
- setFixedHeight(h * 20);
- setFixedWidth(w * 20);
+ setFixedHeight(h * buttonSize);
+ setFixedWidth(w * buttonSize);
setPaletteBackgroundColor(color);
if (isToggleButton()) {
@@ -92,8 +95,8 @@
{
QFont f = font();
int s = (w > h ? h : w);
- if (current.label.length() > 1) f.setPixelSize(6 * s);
- else f.setPixelSize(12 * s);
+ if (current.label.length() > 1) f.setPixelSize(((buttonSize * 6) / 20) * s);
+ else f.setPixelSize(((buttonSize * 6) / 10) * s);
setFont(f);
setText(current.label);
update();
@@ -239,3 +242,5 @@
setPaletteBackgroundColor(QColor("red"));
}
}
+
+
diff --git a/nagisa/src/keybutton.h b/nagisa/src/keybutton.h
index 23dd518..1692dcd 100644
--- a/nagisa/src/keybutton.h
+++ b/nagisa/src/keybutton.h
@@ -72,6 +72,9 @@
void updateLabel();
void changeGroup(const QString &name);
+public:
+ static int buttonSize;
+
protected:
QTimer *timer;
KeyGroupList list;
diff --git a/nagisa/src/nagisa.cpp b/nagisa/src/nagisa.cpp
index e7c65b2..546cd94 100644
--- a/nagisa/src/nagisa.cpp
+++ b/nagisa/src/nagisa.cpp
@@ -45,8 +45,8 @@
// : QWidget( 0, "nagisa",Qt::WStyle_Customize | Qt::WStyle_DialogBorder | Qt::WStyle_StaysOnTop)
: QWidget( 0, "nagisa", Qt::WStyle_Customize | Qt::WX11BypassWM | Qt::WStyle_StaysOnTop)
{
- QString file = xml;
- if (file == "") file = "jp109.xml";
+ keytable = xml;
+ if (keytable == "") keytable = "jp109.xml";
id = -1;
mousePress = false;
@@ -60,21 +60,17 @@
menu = new QPopupMenu(scaleButton);
menu_scale = menu->insertItem(tr("hide"),this,SLOT(scale()));
menu_connect = menu->insertItem(tr("connect"),this,SLOT(connectToScim()));
+ QPopupMenu *resizeMenu = new QPopupMenu(menu);
+ resizeMenu->insertItem(tr("enlarge"),this,SLOT(enlarge()));
+ resizeMenu->insertItem(tr("shrink"),this,SLOT(shrink()));
+ menu->insertItem(tr("size"),resizeMenu);
menu_exit = menu->insertItem(tr("exit"),this,SLOT(close()));
scaleButton->setPopup(menu);
connect(scaleButton,SIGNAL(clicked()),this,SLOT(scale()));
- NagisaKeyboard *b = new NagisaKeyboard(file,this);
- contents = b;
- b->show();
- status = new QLabel(this);
-
+ createKeyboaed(keytable);
show();
- connect(b,SIGNAL(pressed(const QString& )),this,SLOT(sendKeyPressEvent(const QString& )));
- connect(b,SIGNAL(released(const QString& )),this,SLOT(sendKeyReleaseEvent(const QString& )));
- connect(b,SIGNAL(status(const QString& )),this,SLOT(updateStatus(const QString& )));
-
connectToScim();
}
@@ -84,6 +80,21 @@
}
+/*!
+ \fn nagisa::createKeyboaed(const QString &xml)
+ */
+void nagisa::createKeyboaed(const QString &xml)
+{
+ NagisaKeyboard *b = new NagisaKeyboard(xml,this);
+ contents = b;
+ connect(b,SIGNAL(pressed(const QString& )),this,SLOT(sendKeyPressEvent(const QString& )));
+ connect(b,SIGNAL(released(const QString& )),this,SLOT(sendKeyReleaseEvent(const QString& )));
+ connect(b,SIGNAL(status(const QString& )),this,SLOT(updateStatus(const QString& )));
+ b->show();
+ status = new QLabel(this);
+ status->show();
+}
+
/*!
@@ -197,3 +208,34 @@
{
status->setText(s);
}
+
+
+
+
+/*!
+ \fn nagisa::enlarge()
+ */
+void nagisa::enlarge()
+{
+ delete(contents);
+ delete(status);
+ KeyButton::buttonSize += 5;
+ createKeyboaed(keytable);
+ adjustSize();
+}
+
+
+/*!
+ \fn nagisa::shrink()
+ */
+void nagisa::shrink()
+{
+ if ((KeyButton::buttonSize - 5) <= 0) return;
+ size -= 5;
+ delete(contents);
+ delete(status);
+ KeyButton::buttonSize -= 5;
+ createKeyboaed(keytable);
+ adjustSize();
+}
+
diff --git a/nagisa/src/nagisa.h b/nagisa/src/nagisa.h
index 40f04d4..c37b243 100644
--- a/nagisa/src/nagisa.h
+++ b/nagisa/src/nagisa.h
@@ -34,6 +34,7 @@
public:
nagisa(const QString &xml = 0);
~nagisa();
+ void createKeyboaed(const QString &xml);
public slots:
void sendKeyPressEvent(const QString &e);
@@ -54,11 +55,15 @@
int menu_connect;
int menu_exit;
int id;
+ int size;
+ QString keytable;
protected slots:
void scale();
void connectToScim();
void updateStatus(const QString &s);
+ void enlarge();
+ void shrink();
};
diff --git a/nagisa/src/nagisa_ja_JP.qm b/nagisa/src/nagisa_ja_JP.qm
index a7db524..e153bc0 100644
--- a/nagisa/src/nagisa_ja_JP.qm
+++ b/nagisa/src/nagisa_ja_JP.qm
Binary files differ
diff --git a/nagisa/src/nagisa_ja_JP.ts b/nagisa/src/nagisa_ja_JP.ts
index cf0de5e..9360a36 100644
--- a/nagisa/src/nagisa_ja_JP.ts
+++ b/nagisa/src/nagisa_ja_JP.ts
@@ -33,5 +33,17 @@
なぎさたんキーボード
+
+
+ でかく
+
+
+
+ ちっさく
+
+
+
+ サイズ
+
diff --git a/nagisa/src/nagisakeyboard.cpp b/nagisa/src/nagisakeyboard.cpp
index 17f2703..6cfa257 100644
--- a/nagisa/src/nagisakeyboard.cpp
+++ b/nagisa/src/nagisakeyboard.cpp
@@ -35,7 +35,7 @@
void NagisaKeyboard::init()
{
- grid = new QGridLayout(this,1,1,0,20);
+ grid = new QGridLayout(this,1,1,0,KeyButton::buttonSize);
}
@@ -52,6 +52,7 @@
void NagisaKeyboard::layout()
{
for(unsigned int i = 0;i < keys.count();i ++) {
+ grid->remove(keys[i]);
grid->addMultiCellWidget(keys[i],
keys[i]->getY(),keys[i]->getY() + keys[i]->getH(),
keys[i]->getX(),keys[i]->getX() + keys[i]->getW());
@@ -181,3 +182,4 @@
}
return res;
}
+
diff --git a/nagisa/src/nagisakeyboard.h b/nagisa/src/nagisakeyboard.h
index b59fcef..4e8f9e7 100644
--- a/nagisa/src/nagisakeyboard.h
+++ b/nagisa/src/nagisakeyboard.h
@@ -37,7 +37,6 @@
NagisaKeyboard(const QString &xml, QWidget *parent = 0, const char *name = 0);
~NagisaKeyboard();
static const QStringList uniq(const QStringList &list);
-
protected:
QGridLayout *grid;
QValueList keys;
diff --git a/nagisa/src/src.pro b/nagisa/src/src.pro
index a29e24d..ef2cbca 100644
--- a/nagisa/src/src.pro
+++ b/nagisa/src/src.pro
@@ -2,12 +2,14 @@
# -------------------------------------------
# Subdir relative project main directory: ./src
# Target is ????????: ../bin/nagisa
-PREFIX = /usr/local
+isEmpty(PREFIX) {
+ PREFIX = /usr/local
+}
+
TRANSLATIONS += nagisa_ja_JP.ts
HEADERS += nagisa.h \
nagisakeyboard.h \
- keybutton.h \
- nagisakeytable.h
+ keybutton.h
SOURCES += nagisa.cpp \
main.cpp \
nagisakeyboard.cpp \