diff --git a/CMakeLists.txt b/CMakeLists.txt
index 712ec17..7b4b205 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -21,9 +21,15 @@
find_package(Fcitx 4.2.3 REQUIRED)
find_package(Libiconv REQUIRED)
find_package(Gettext REQUIRED)
+find_package(Qt4)
configure_file(config.h.in config.h)
+add_subdirectory(unikey)
add_subdirectory(src)
add_subdirectory(data)
-add_subdirectory(po)
\ No newline at end of file
+add_subdirectory(po)
+
+if (QT_FOUND)
+add_subdirectory(macro-editor)
+endif(QT_FOUND)
\ No newline at end of file
diff --git a/README b/README
new file mode 100644
index 0000000..4ba920b
--- /dev/null
+++ b/README
@@ -0,0 +1,9 @@
+Unikey (Vietnamese Input Method) engine support for Fcitx
+
+Released under GPLv3+
+
+Install:
+$ mkdir build && cd build
+$ cmake -DCMAKE_INSTALL_PREFIX=`fcitx4-config --prefix` ..
+$ make
+# make install
diff --git a/data/fcitx-unikey.conf.in b/data/fcitx-unikey.conf.in
index e472285..2bf856d 100644
--- a/data/fcitx-unikey.conf.in
+++ b/data/fcitx-unikey.conf.in
@@ -7,3 +7,4 @@
Library=fcitx-unikey.so
Type=SharedLibrary
IMRegisterMethod=ConfigFile
+SubConfig=Macro:program:fcitx-unikey-macro-editor,fcitx-unikey:domain
\ No newline at end of file
diff --git a/macro-editor/CMakeLists.txt b/macro-editor/CMakeLists.txt
new file mode 100644
index 0000000..35dd300
--- /dev/null
+++ b/macro-editor/CMakeLists.txt
@@ -0,0 +1,39 @@
+include_directories(
+ ${QT_QTCORE_INCLUDE_DIR}
+ ${QT_QTGUI_INCLUDE_DIR}
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${PROJECT_SOURCE_DIR}/unikey
+ )
+
+link_directories(
+${FCITX4_FCITX_UTILS_LIBRARY_DIRS}
+${FCITX4_FCITX_CONFIG_LIBRARY_DIRS}
+)
+
+set(MACRO_EDITOR_SRCS
+ model.cpp
+ main.cpp
+ editor.cpp
+ dialog.cpp
+ )
+set(MACRO_EDITOR_HDRS
+ model.h
+ editor.h
+ dialog.h
+ )
+qt4_wrap_cpp(MACRO_EDITOR_MOCS ${MACRO_EDITOR_HDRS})
+qt4_wrap_ui(MACRO_EDITOR_SRCS editor.ui dialog.ui)
+add_executable(fcitx-unikey-macro-editor ${MACRO_EDITOR_SRCS} ${MACRO_EDITOR_MOCS})
+target_link_libraries(fcitx-unikey-macro-editor
+ debug ${QT_QTCORE_LIBRARY_DEBUG}
+ debug ${QT_QTDBUS_LIBRARY_DEBUG}
+ debug ${QT_QTGUI_LIBRARY_DEBUG}
+ optimized ${QT_QTCORE_LIBRARY_RELEASE}
+ optimized ${QT_QTDBUS_LIBRARY_RELEASE}
+ optimized ${QT_QTGUI_LIBRARY_RELEASE}
+ unikey
+ ${FCITX4_FCITX_UTILS_LIBRARIES}
+ ${FCITX4_FCITX_CONFIG_LIBRARIES}
+ )
+
+install(TARGETS fcitx-unikey-macro-editor DESTINATION ${FCITX4_PREFIX}/bin)
\ No newline at end of file
diff --git a/macro-editor/common.h b/macro-editor/common.h
new file mode 100644
index 0000000..c87ce50
--- /dev/null
+++ b/macro-editor/common.h
@@ -0,0 +1,27 @@
+/***************************************************************************
+ * Copyright (C) 2012~2012 by CSSlayer *
+ * wengxt@gmail.com *
+ * *
+ * 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 . *
+ * *
+ ***************************************************************************/
+
+#ifndef _FCITX_UNIKEY_COMMON_H
+#define _FCITX_UNIKEY_COMMON_H
+
+#include
+
+#define _(x) QString::fromUtf8(gettext(x))
+
+#endif // _FCITX_UNIKEY_COMMON_H
\ No newline at end of file
diff --git a/macro-editor/dialog.cpp b/macro-editor/dialog.cpp
new file mode 100644
index 0000000..73324a4
--- /dev/null
+++ b/macro-editor/dialog.cpp
@@ -0,0 +1,46 @@
+/***************************************************************************
+ * Copyright (C) 2012~2012 by CSSlayer *
+ * wengxt@gmail.com *
+ * *
+ * 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 . *
+ * *
+ ***************************************************************************/
+
+#include "ui_dialog.h"
+#include "dialog.h"
+
+namespace fcitx_unikey {
+MacroDialog::MacroDialog(QWidget* parent): QDialog(parent),
+ m_ui(new Ui::Dialog)
+{
+ m_ui->setupUi(this);
+}
+
+MacroDialog::~MacroDialog()
+{
+ delete m_ui;
+}
+
+QString MacroDialog::macro() const
+{
+ return m_ui->macroLineEdit->text();
+}
+
+QString MacroDialog::word() const
+{
+ return m_ui->wordLineEdit->text();
+}
+
+
+}
\ No newline at end of file
diff --git a/macro-editor/dialog.h b/macro-editor/dialog.h
new file mode 100644
index 0000000..5b2fa4c
--- /dev/null
+++ b/macro-editor/dialog.h
@@ -0,0 +1,39 @@
+/***************************************************************************
+ * Copyright (C) 2012~2012 by CSSlayer *
+ * wengxt@gmail.com *
+ * *
+ * 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 . *
+ * *
+ ***************************************************************************/
+
+#include
+
+class CMacroTable;
+namespace Ui {
+class Dialog;
+}
+
+namespace fcitx_unikey {
+class MacroDialog : public QDialog {
+ Q_OBJECT
+public:
+ explicit MacroDialog(QWidget* parent = 0);
+ virtual ~MacroDialog();
+ QString macro() const;
+ QString word() const;
+
+private:
+ Ui::Dialog* m_ui;
+};
+}
\ No newline at end of file
diff --git a/macro-editor/dialog.ui b/macro-editor/dialog.ui
new file mode 100644
index 0000000..729f6a2
--- /dev/null
+++ b/macro-editor/dialog.ui
@@ -0,0 +1,93 @@
+
+
+ Dialog
+
+
+
+ 0
+ 0
+ 334
+ 91
+
+
+
+ Dialog
+
+
+ -
+
+
-
+
+
+ -
+
+
+ Word:
+
+
+
+ -
+
+
+ Macro:
+
+
+
+ -
+
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+ QDialogButtonBox::Cancel|QDialogButtonBox::Ok
+
+
+
+
+
+
+ macroLineEdit
+ wordLineEdit
+ buttonBox
+
+
+
+
+ buttonBox
+ accepted()
+ Dialog
+ accept()
+
+
+ 248
+ 254
+
+
+ 157
+ 274
+
+
+
+
+ buttonBox
+ rejected()
+ Dialog
+ reject()
+
+
+ 316
+ 260
+
+
+ 286
+ 274
+
+
+
+
+
diff --git a/macro-editor/editor.cpp b/macro-editor/editor.cpp
new file mode 100644
index 0000000..9b394e8
--- /dev/null
+++ b/macro-editor/editor.cpp
@@ -0,0 +1,254 @@
+/***************************************************************************
+ * Copyright (C) 2012~2012 by CSSlayer *
+ * wengxt@gmail.com *
+ * *
+ * 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 . *
+ * *
+ ***************************************************************************/
+
+#include
+#include
+
+#include
+#include
+#include
+#include
+
+#include "editor.h"
+#include "model.h"
+#include "dialog.h"
+#include "mactab.h"
+#include "ui_editor.h"
+#include "common.h"
+
+namespace fcitx_unikey {
+
+MacroEditor::MacroEditor(QWidget* parent): QMainWindow(parent)
+ ,m_ui(new Ui::Editor)
+{
+ m_ui->setupUi(this);
+ m_ui->addButton->setText(_("&Add"));
+ m_ui->deleteButton->setText(_("&Delete"));
+ m_ui->clearButton->setText(_("De&lete All"));
+ m_ui->exitButton->setText(_("&Quit"));
+ m_ui->saveButton->setText(_("&Save"));
+ m_ui->importButton->setText(_("&Import"));
+ m_ui->exportButton->setText(_("&Export"));
+ m_ui->macroTableView->setSelectionMode(QAbstractItemView::SingleSelection);
+ m_ui->macroTableView->setSelectionBehavior(QAbstractItemView::SelectRows);
+ setWindowTitle(_("Unikey Macro Editor"));
+
+ connect(m_ui->addButton, SIGNAL(clicked(bool)), this, SLOT(addWord()));
+ connect(m_ui->deleteButton, SIGNAL(clicked(bool)), this, SLOT(deleteWord()));
+ connect(m_ui->clearButton, SIGNAL(clicked(bool)), this, SLOT(deleteAllWord()));
+ connect(m_ui->importButton, SIGNAL(clicked(bool)), this, SLOT(importMacro()));
+ connect(m_ui->exportButton, SIGNAL(clicked(bool)), this, SLOT(exportMacro()));
+ connect(m_ui->exitButton, SIGNAL(clicked(bool)), this, SLOT(aboutToQuit()));
+ connect(m_ui->saveButton, SIGNAL(clicked(bool)), this, SLOT(saveMacro()));
+
+ load();
+ itemFocusChanged();
+}
+
+MacroEditor::~MacroEditor()
+{
+ delete m_ui;
+}
+
+void MacroEditor::aboutToQuit()
+{
+ if (!m_model->needSave())
+ qApp->quit();
+ else {
+ QMessageBox* dialog = new QMessageBox(this);
+ dialog->setIcon(QMessageBox::Warning);
+ dialog->setWindowTitle(_("Quit Macro Editor"));
+ dialog->setText(_("Macro table still contains unsaved changes. Do you want to save?"));
+ dialog->setStandardButtons(QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
+ dialog->setDefaultButton(QMessageBox::Save);
+ dialog->setAttribute(Qt::WA_DeleteOnClose, true);
+ dialog->open();
+ connect(dialog, SIGNAL(finished(int)), this, SLOT(quitConfirmDone(int)));
+ }
+}
+
+void MacroEditor::quitConfirmDone(int result)
+{
+ switch(result) {
+ case QMessageBox::Save:
+ saveMacro();
+ case QMessageBox::Discard:
+ qApp->quit();
+ break;
+ }
+}
+
+void MacroEditor::closeEvent(QCloseEvent* event)
+{
+ if (m_model->needSave()) {
+ event->ignore();
+
+ QMessageBox* dialog = new QMessageBox(this);
+ dialog->setIcon(QMessageBox::Warning);
+ dialog->setWindowTitle(_("Quit Macro Editor"));
+ dialog->setText(_("Macro table still contains unsaved changes. Do you want to save?"));
+ dialog->setStandardButtons(QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
+ dialog->setDefaultButton(QMessageBox::Save);
+ dialog->setAttribute(Qt::WA_DeleteOnClose, true);
+ dialog->open();
+ connect(dialog, SIGNAL(finished(int)), this, SLOT(quitConfirmDone(int)));
+ }
+ else {
+ event->accept();
+ qApp->quit();
+ }
+}
+
+
+void MacroEditor::itemFocusChanged()
+{
+ m_ui->deleteButton->setEnabled(m_ui->macroTableView->currentIndex().isValid());
+}
+
+void MacroEditor::deleteWord()
+{
+ if (!m_ui->macroTableView->currentIndex().isValid())
+ return;
+ int row = m_ui->macroTableView->currentIndex().row();
+ m_model->deleteItem(row);
+}
+
+void MacroEditor::deleteAllWord()
+{
+ m_model->deleteAllItem();
+}
+
+void MacroEditor::addWord()
+{
+ MacroDialog* dialog = new MacroDialog(this);
+ dialog->setAttribute(Qt::WA_DeleteOnClose, true);
+ dialog->open();
+ connect(dialog, SIGNAL(accepted()), this, SLOT(addWordAccepted()));
+}
+
+QString MacroEditor::getData(CMacroTable* table, int i, bool iskey) {
+
+ char key[MAX_MACRO_KEY_LEN*3];
+ char value[MAX_MACRO_TEXT_LEN*3];
+ do {
+ if (i < table->getCount()) {
+ const StdVnChar* p = NULL;
+ int maxOutLen = 0;
+ const char* result = NULL;
+ if (iskey) {
+ p = table->getKey(i);
+ maxOutLen = sizeof(key);
+ result = key;
+ } else {
+ p = table->getText(i);
+ maxOutLen = sizeof(value);
+ result = value;
+ }
+
+ if (!p)
+ break;
+ int inLen = -1;
+ int ret = VnConvert(CONV_CHARSET_VNSTANDARD, CONV_CHARSET_XUTF8,
+ (UKBYTE*) p, (UKBYTE*)result,
+ &inLen, &maxOutLen);
+ if (ret != 0)
+ break;
+ return QString::fromUtf8(result);
+ }
+ } while(0);
+ return QString();
+}
+
+void MacroEditor::addWordAccepted()
+{
+ const MacroDialog* dialog = qobject_cast< const MacroDialog* >(QObject::sender());
+
+ m_model->addItem(dialog->macro(), dialog->word());
+}
+
+void MacroEditor::load()
+{
+ m_table = new CMacroTable;
+ m_table->init();
+ char* fileName;
+ FcitxXDGGetFileUserWithPrefix("unikey", "macro", NULL, &fileName);
+ m_table->loadFromFile(fileName);
+ free(fileName);
+ m_model = new MacroModel(this);
+ m_model->load(m_table);
+ m_ui->macroTableView->horizontalHeader()->setStretchLastSection(true);
+ m_ui->macroTableView->verticalHeader()->setVisible(false);
+ m_ui->macroTableView->setModel(m_model);
+ connect(m_ui->macroTableView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(itemFocusChanged()));
+ connect(m_model, SIGNAL(needSaveChanged(bool)), this, SLOT(needSaveChanged(bool)));
+
+}
+
+void MacroEditor::needSaveChanged(bool needSave)
+{
+ m_ui->saveButton->setEnabled(needSave);
+}
+
+
+void MacroEditor::saveMacro()
+{
+ m_model->save(m_table);
+ FILE* f = FcitxXDGGetFileUserWithPrefix("unikey", "macro", "w", NULL);
+ m_table->writeToFp(f);
+}
+
+void MacroEditor::importMacro()
+{
+ QFileDialog* dialog = new QFileDialog(this);
+ dialog->setAttribute(Qt::WA_DeleteOnClose, true);
+ dialog->setFileMode(QFileDialog::ExistingFile);
+ dialog->setAcceptMode(QFileDialog::AcceptOpen);
+ dialog->open();
+ connect(dialog, SIGNAL(accepted()), this, SLOT(importFileSelected()));
+}
+
+void MacroEditor::importFileSelected()
+{
+ const QFileDialog* dialog = qobject_cast< const QFileDialog* >(QObject::sender());
+ qDebug() << dialog->selectedFiles();
+}
+
+void MacroEditor::exportMacro()
+{
+ QFileDialog* dialog = new QFileDialog(this);
+ dialog->setAttribute(Qt::WA_DeleteOnClose, true);
+ dialog->setDirectory("macro");
+ dialog->setAcceptMode(QFileDialog::AcceptSave);
+ dialog->open();
+ connect(dialog, SIGNAL(accepted()), this, SLOT(exportFileSelected()));
+}
+
+void MacroEditor::exportFileSelected()
+{
+ const QFileDialog* dialog = qobject_cast< const QFileDialog* >(QObject::sender());
+ if (dialog->selectedFiles().length() <= 0)
+ return;
+ QString file = dialog->selectedFiles()[0];
+ m_table->writeToFile(file.toUtf8().data());
+}
+
+
+
+
+}
\ No newline at end of file
diff --git a/macro-editor/editor.h b/macro-editor/editor.h
new file mode 100644
index 0000000..ce5ae05
--- /dev/null
+++ b/macro-editor/editor.h
@@ -0,0 +1,58 @@
+/***************************************************************************
+ * Copyright (C) 2012~2012 by CSSlayer *
+ * wengxt@gmail.com *
+ * *
+ * 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 . *
+ * *
+ ***************************************************************************/
+
+#include
+
+class CMacroTable;
+namespace Ui {
+class Editor;
+}
+
+namespace fcitx_unikey {
+
+class MacroModel;
+class MacroEditor : public QMainWindow {
+ Q_OBJECT
+public:
+ explicit MacroEditor(QWidget* parent = 0);
+ virtual ~MacroEditor();
+ static QString getData(CMacroTable* table, int i, bool iskey);
+protected:
+ virtual void closeEvent(QCloseEvent* event );
+private slots:
+ void addWord();
+ void deleteWord();
+ void deleteAllWord();
+ void itemFocusChanged();
+ void aboutToQuit();
+ void saveMacro();
+ void load();
+ void addWordAccepted();
+ void importMacro();
+ void exportMacro();
+ void importFileSelected();
+ void exportFileSelected();
+ void needSaveChanged(bool needSave);
+ void quitConfirmDone(int result);
+private:
+ Ui::Editor* m_ui;
+ CMacroTable* m_table;
+ MacroModel* m_model;
+};
+}
\ No newline at end of file
diff --git a/macro-editor/editor.ui b/macro-editor/editor.ui
new file mode 100644
index 0000000..1ea203a
--- /dev/null
+++ b/macro-editor/editor.ui
@@ -0,0 +1,147 @@
+
+
+ Editor
+
+
+
+ 0
+ 0
+ 375
+ 366
+
+
+
+ MainWindow
+
+
+
+
+
+
+ -
+
+
+ -
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ -
+
+
+ false
+
+
+
+
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 40
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/macro-editor/main.cpp b/macro-editor/main.cpp
new file mode 100644
index 0000000..6e3a652
--- /dev/null
+++ b/macro-editor/main.cpp
@@ -0,0 +1,37 @@
+/***************************************************************************
+ * Copyright (C) 2012~2012 by CSSlayer *
+ * wengxt@gmail.com *
+ * *
+ * 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 . *
+ * *
+ ***************************************************************************/
+
+#include
+#include
+#include
+#include "editor.h"
+int main(int argc, char* argv[])
+{
+ setlocale(LC_ALL, "");
+ char* path = fcitx_utils_get_fcitx_path("localedir");
+ bindtextdomain("fcitx-unikey", path);
+ free(path);
+ bind_textdomain_codeset("fcitx-unikey", "UTF-8");
+ textdomain("fcitx-unikey");
+
+ QApplication app(argc, argv);
+ fcitx_unikey::MacroEditor window;
+ window.show();
+ return app.exec();
+}
\ No newline at end of file
diff --git a/macro-editor/model.cpp b/macro-editor/model.cpp
new file mode 100644
index 0000000..380789c
--- /dev/null
+++ b/macro-editor/model.cpp
@@ -0,0 +1,147 @@
+/***************************************************************************
+ * Copyright (C) 2012~2012 by CSSlayer *
+ * wengxt@gmail.com *
+ * *
+ * 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 . *
+ * *
+ ***************************************************************************/
+
+#include
+
+#include "model.h"
+#include "common.h"
+#include "editor.h"
+
+namespace fcitx_unikey {
+
+typedef QPair ItemType;
+
+MacroModel::MacroModel(QObject* parent): QAbstractTableModel(parent)
+ ,m_needSave(false)
+{
+}
+
+MacroModel::~MacroModel()
+{
+
+}
+
+QVariant MacroModel::headerData(int section, Qt::Orientation orientation, int role) const
+{
+ if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
+ if (section == 0)
+ return _("Macro");
+ else if (section == 1)
+ return _("Word");
+ }
+ return QVariant();
+}
+
+int MacroModel::rowCount(const QModelIndex& parent) const
+{
+ return m_list.count();
+}
+
+int MacroModel::columnCount(const QModelIndex& parent) const
+{
+ return 2;
+}
+
+QVariant MacroModel::data(const QModelIndex& index, int role) const
+{
+ do {
+ if (role == Qt::DisplayRole && index.row() < m_list.count()) {
+ if (index.column() == 0) {
+ return m_list[index.row()].first;
+ } else if (index.column() == 1) {
+ return m_list[index.row()].second;
+ }
+ }
+ } while(0);
+ return QVariant();
+}
+
+void MacroModel::addItem(const QString& macro, const QString& word)
+{
+ if (m_keyset.contains(macro))
+ return;
+ beginInsertRows(QModelIndex(), m_list.size(), m_list.size());
+ m_list.append(QPair(macro, word));
+ m_keyset.insert(macro);
+ endInsertRows();
+ setNeedSave(true);
+}
+
+void MacroModel::deleteItem(int row)
+{
+ if (row >= m_list.count())
+ return;
+ QPair item = m_list.at(row);
+ QString key = item.first;
+ beginRemoveRows(QModelIndex(), row, row);
+ m_list.removeAt(row);
+ m_keyset.remove(key);
+ endRemoveRows();
+ setNeedSave(true);
+}
+
+void MacroModel::deleteAllItem()
+{
+ if (m_list.count())
+ setNeedSave(true);
+ beginResetModel();
+ m_list.clear();
+ m_keyset.clear();
+ endResetModel();
+}
+
+void MacroModel::setNeedSave(bool needSave)
+{
+ if (m_needSave != needSave) {
+ m_needSave = needSave;
+ emit needSaveChanged(m_needSave);
+ }
+}
+
+bool MacroModel::needSave()
+{
+ return m_needSave;
+}
+
+
+void MacroModel::load(CMacroTable* table)
+{
+ beginResetModel();
+ m_list.clear();
+ m_keyset.clear();
+ for (int i = 0; i < table->getCount(); i++) {
+ QString key = MacroEditor::getData(table, i, true);
+ QString value = MacroEditor::getData(table, i, false);
+ m_list.append(QPair(key, value));
+ m_keyset.insert(key);
+ }
+ endResetModel();
+}
+
+void MacroModel::save(CMacroTable* m_table)
+{
+ m_table->resetContent();
+ foreach(const ItemType& item, m_list) {
+ m_table->addItem(item.first.toUtf8().data(), item.second.toUtf8().data(), CONV_CHARSET_XUTF8);
+ }
+ setNeedSave(false);
+}
+
+
+}
\ No newline at end of file
diff --git a/macro-editor/model.h b/macro-editor/model.h
new file mode 100644
index 0000000..2ee1bde
--- /dev/null
+++ b/macro-editor/model.h
@@ -0,0 +1,52 @@
+/***************************************************************************
+ * Copyright (C) 2012~2012 by CSSlayer *
+ * wengxt@gmail.com *
+ * *
+ * 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 . *
+ * *
+ ***************************************************************************/
+
+#include
+#include
+#include "mactab.h"
+
+namespace fcitx_unikey {
+class MacroModel : public QAbstractTableModel {
+ Q_OBJECT
+public:
+ explicit MacroModel(QObject* parent = 0);
+ virtual ~MacroModel();
+
+ virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
+ virtual int rowCount(const QModelIndex& parent = QModelIndex()) const;
+ virtual int columnCount(const QModelIndex& parent = QModelIndex()) const;
+ virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
+ void load(CMacroTable* table);
+ void addItem(const QString& macro, const QString& word);
+ void deleteItem(int row);
+ void deleteAllItem();
+ void save(CMacroTable* m_table);
+ bool needSave();
+
+signals:
+ void needSaveChanged(bool m_needSave);
+
+private:
+ void setNeedSave(bool needSave);
+ bool m_needSave;
+ QSet m_keyset;
+ QList >m_list;
+};
+
+}
\ No newline at end of file
diff --git a/po/CMakeLists.txt b/po/CMakeLists.txt
index c45f4e9..a55d30e 100644
--- a/po/CMakeLists.txt
+++ b/po/CMakeLists.txt
@@ -9,10 +9,7 @@
configure_file(POTFILES.in.in ${CMAKE_CURRENT_BINARY_DIR}/POTFILES.in)
extract_fcitx_addon_conf_postring()
-
-add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/desc.po
- COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/getdescpo ${PROJECT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}
- DEPENDS getdescpo)
+extract_fcitx_desc_file_postring()
add_custom_target(
pot
diff --git a/po/POTFILES.in.in b/po/POTFILES.in.in
index 4a7773c..f654768 100644
--- a/po/POTFILES.in.in
+++ b/po/POTFILES.in.in
@@ -6,5 +6,9 @@
@REL_SOURCE_ROOT@/src/unikey-config.h
@REL_SOURCE_ROOT@/src/unikey-im.cpp
@REL_SOURCE_ROOT@/src/unikey-im.h
+@REL_SOURCE_ROOT@/macro-editor/dialog.cpp
+@REL_SOURCE_ROOT@/macro-editor/editor.cpp
+@REL_SOURCE_ROOT@/macro-editor/main.cpp
+@REL_SOURCE_ROOT@/macro-editor/model.cpp
@REL_SOURCE_ROOT@/data/fcitx-unikey.conf.in
@REL_SOURCE_ROOT@/data/unikey.conf.in
diff --git a/po/fcitx-unikey.pot b/po/fcitx-unikey.pot
index c2fb863..d92efc5 100644
--- a/po/fcitx-unikey.pot
+++ b/po/fcitx-unikey.pot
@@ -8,7 +8,7 @@
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2012-05-05 16:38+0800\n"
+"POT-Creation-Date: 2012-10-20 22:29-0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME \n"
"Language-Team: LANGUAGE \n"
@@ -22,7 +22,7 @@
msgstr ""
#: /home/saber/Develop/fcitx-unikey/data/fcitx-unikey.desc:14
-#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-ui.cpp:137
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-ui.cpp:156
msgid "Output Charset"
msgstr ""
@@ -53,7 +53,7 @@
# unknown
#: /home/saber/Develop/fcitx-unikey/build/po/tmp/fcitx-unikey.conf.in.h:1
#: /home/saber/Develop/fcitx-unikey/build/po/tmp/unikey.conf.in.h:1
-#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-im.cpp:131
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-im.cpp:150
msgid "Unikey"
msgstr ""
@@ -103,47 +103,98 @@
#: unknown
msgid "VNI Win"
+msgstr ""
+
+#: unknown
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-ui.cpp:127
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-ui.cpp:187
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//macro-editor/model.cpp:25
+msgid "Macro"
msgstr ""
#: /home/saber/Develop/fcitx-unikey/build/po/tmp/fcitx-unikey.conf.in.h:2
msgid "Unikey Wrapper For Fcitx"
msgstr ""
-#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-ui.cpp:86
-#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-ui.cpp:153
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-ui.cpp:105
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-ui.cpp:172
msgid "Choose input method"
msgstr ""
-#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-ui.cpp:94
-#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-ui.cpp:159
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-ui.cpp:113
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-ui.cpp:178
msgid "Choose output charset"
msgstr ""
-#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-ui.cpp:100
-#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-ui.cpp:163
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-ui.cpp:119
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-ui.cpp:182
msgid "Spell Check"
msgstr ""
-#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-ui.cpp:101
-#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-ui.cpp:164
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-ui.cpp:120
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-ui.cpp:183
msgid "Enable Spell Check"
msgstr ""
-#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-ui.cpp:108
-#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-ui.cpp:168
-msgid "Macro"
-msgstr ""
-
-#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-ui.cpp:109
-#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-ui.cpp:169
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-ui.cpp:128
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-ui.cpp:188
msgid "Enable Macro"
msgstr ""
-#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-ui.cpp:123
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-ui.cpp:142
msgid "Unikey Input Method"
msgstr ""
-#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-ui.cpp:163
-#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-ui.cpp:168
-msgid "N"
-msgstr ""
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-ui.cpp:182
+msgid "No Spell Check"
+msgstr ""
+
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-ui.cpp:187
+msgid "No Macro"
+msgstr ""
+
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//macro-editor/editor.cpp:21
+msgid "&Add"
+msgstr ""
+
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//macro-editor/editor.cpp:22
+msgid "&Delete"
+msgstr ""
+
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//macro-editor/editor.cpp:23
+msgid "De&lete All"
+msgstr ""
+
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//macro-editor/editor.cpp:24
+msgid "&Quit"
+msgstr ""
+
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//macro-editor/editor.cpp:25
+msgid "&Save"
+msgstr ""
+
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//macro-editor/editor.cpp:26
+msgid "&Import"
+msgstr ""
+
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//macro-editor/editor.cpp:27
+msgid "&Export"
+msgstr ""
+
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//macro-editor/editor.cpp:30
+msgid "Unikey Macro Editor"
+msgstr ""
+
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//macro-editor/editor.cpp:56
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//macro-editor/editor.cpp:84
+msgid "Quit Macro Editor"
+msgstr ""
+
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//macro-editor/editor.cpp:57
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//macro-editor/editor.cpp:85
+msgid "Macro table still contains unsaved changes. Do you want to save?"
+msgstr ""
+
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//macro-editor/model.cpp:27
+msgid "Word"
+msgstr ""
diff --git a/po/getdescpo b/po/getdescpo
deleted file mode 100755
index 65289a2..0000000
--- a/po/getdescpo
+++ /dev/null
@@ -1,46 +0,0 @@
-#!/bin/sh
-filename=desc.po
-indir=$1
-outdir=$2
-
-cd "$outdir"
-
-rm -f "$outdir/$filename"; touch "$outdir/$filename"
-
-cat > "$outdir/$filename" <, YEAR.
-#
-#, fuzzy
-msgid ""
-msgstr ""
-"Project-Id-Version: PACKAGE VERSION\n"
-"Report-Msgid-Bugs-To: fcitx-dev@googlegroups.com\n"
-"POT-Creation-Date: 2010-11-17 11:48+0800\n"
-"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
-"Last-Translator: FULL NAME \n"
-"Language-Team: LANGUAGE \n"
-"Language: \n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=UTF-8\n"
-"Content-Transfer-Encoding: 8bit\n"
-EOF
-
-cd $indir
-
-descfiles=`find "$indir" -name ".hg" -prune -or -name "test" -prune -or -iname "*.desc" | grep desc`
-
-# Extract Description
-for f in $descfiles
-do
- awk '/^[\t ]*Description=/ { print "\n#: '$f':" NR"\n" "msgid \"" substr($0, 13)"\"\n" "msgstr \"\""}' "$f" >> "$outdir/$filename"
-done
-
-# Extract Group Name
-grep -nH '^\[' $descfiles | grep -v 'DescriptionFile' | awk ' "^[" { split($0, a, ":"); split(a[3], b, "/"); print substr(b[1], 2); }' | sort | uniq | awk '{ print "# unknown\nmsgid \""$0"\"\nmsgstr \"\"\n"; }' >> "$outdir/$filename"
-
-# Extract Enum Name
-grep -h 'Enum[0-9]' $descfiles | sed -e 's/Enum[0-9]=//g' | sort | uniq | awk '{ print "#: unknown\nmsgid \""$0"\"\nmsgstr \"\"\n"; }' >> "$outdir/$filename"
-
diff --git a/po/vi.po b/po/vi.po
index a3eb0d2..8af11e7 100644
--- a/po/vi.po
+++ b/po/vi.po
@@ -9,8 +9,8 @@
msgstr ""
"Project-Id-Version: ibus-unikey 0.6.1\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2012-05-05 16:38+0800\n"
-"PO-Revision-Date: 2012-05-05 16:39+0800\n"
+"POT-Creation-Date: 2012-10-20 22:29-0400\n"
+"PO-Revision-Date: 2012-10-20 22:33-0400\n"
"Last-Translator: Weng Xuetian \n"
"Language-Team: Chinese Simplified \n"
"Language: zh_CN\n"
@@ -21,7 +21,31 @@
"X-Poedit-Language: Vietnamese\n"
"X-Poedit-Country: VIET NAM\n"
"X-Poedit-SourceCharset: utf-8\n"
-"X-Generator: Lokalize 1.4\n"
+"X-Generator: Lokalize 1.5\n"
+
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//macro-editor/editor.cpp:21
+msgid "&Add"
+msgstr ""
+
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//macro-editor/editor.cpp:22
+msgid "&Delete"
+msgstr "&Xóa"
+
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//macro-editor/editor.cpp:27
+msgid "&Export"
+msgstr "&Xuất"
+
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//macro-editor/editor.cpp:26
+msgid "&Import"
+msgstr "&Nhập"
+
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//macro-editor/editor.cpp:24
+msgid "&Quit"
+msgstr ""
+
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//macro-editor/editor.cpp:25
+msgid "&Save"
+msgstr ""
#: /home/saber/Develop/fcitx-unikey/data/fcitx-unikey.desc:43
msgid "Allow type with more freedom"
@@ -39,23 +63,27 @@
msgid "CString"
msgstr "CString"
-#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-ui.cpp:86
-#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-ui.cpp:153
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-ui.cpp:105
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-ui.cpp:172
msgid "Choose input method"
msgstr "Chọn kiểu gõ"
-#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-ui.cpp:94
-#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-ui.cpp:159
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-ui.cpp:113
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-ui.cpp:178
msgid "Choose output charset"
msgstr "Chọn bảng mã"
-#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-ui.cpp:109
-#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-ui.cpp:169
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//macro-editor/editor.cpp:23
+msgid "De&lete All"
+msgstr "Xóa &hết"
+
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-ui.cpp:128
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-ui.cpp:188
msgid "Enable Macro"
msgstr "Bật gõ tắt"
-#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-ui.cpp:101
-#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-ui.cpp:164
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-ui.cpp:120
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-ui.cpp:183
msgid "Enable Spell Check"
msgstr "Bật kiểm tra chính tả"
@@ -71,15 +99,17 @@
msgid "Input Method"
msgstr "Kiểu gõ"
-#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-ui.cpp:108
-#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-ui.cpp:168
+#: unknown
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-ui.cpp:127
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-ui.cpp:187
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//macro-editor/model.cpp:25
msgid "Macro"
msgstr "gõ tắt"
-#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-ui.cpp:163
-#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-ui.cpp:168
-msgid "N"
-msgstr "N"
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//macro-editor/editor.cpp:57
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//macro-editor/editor.cpp:85
+msgid "Macro table still contains unsaved changes. Do you want to save?"
+msgstr ""
#: unknown
msgid "NCR Decimal"
@@ -89,8 +119,18 @@
msgid "NCR Hex"
msgstr "NCR Hex"
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-ui.cpp:187
+#, fuzzy
+msgid "No Macro"
+msgstr "gõ tắt"
+
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-ui.cpp:182
+#, fuzzy
+msgid "No Spell Check"
+msgstr "kiểm tra chính tả"
+
#: /home/saber/Develop/fcitx-unikey/data/fcitx-unikey.desc:14
-#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-ui.cpp:137
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-ui.cpp:156
msgid "Output Charset"
msgstr "Bảng mã"
@@ -98,6 +138,11 @@
msgid "Process W at word begin"
msgstr "Xử lý phím W ở đầu từ"
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//macro-editor/editor.cpp:56
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//macro-editor/editor.cpp:84
+msgid "Quit Macro Editor"
+msgstr ""
+
#: unknown
msgid "STelex"
msgstr "STelex"
@@ -106,8 +151,8 @@
msgid "STelex2"
msgstr "STelex2"
-#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-ui.cpp:100
-#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-ui.cpp:163
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-ui.cpp:119
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-ui.cpp:182
msgid "Spell Check"
msgstr "kiểm tra chính tả"
@@ -126,13 +171,17 @@
# unknown
#: /home/saber/Develop/fcitx-unikey/build/po/tmp/fcitx-unikey.conf.in.h:1
#: /home/saber/Develop/fcitx-unikey/build/po/tmp/unikey.conf.in.h:1
-#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-im.cpp:131
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-im.cpp:150
msgid "Unikey"
msgstr "Unikey"
-#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-ui.cpp:123
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-ui.cpp:142
msgid "Unikey Input Method"
msgstr "Unikey Kiểu gõ"
+
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//macro-editor/editor.cpp:30
+msgid "Unikey Macro Editor"
+msgstr ""
#: /home/saber/Develop/fcitx-unikey/build/po/tmp/fcitx-unikey.conf.in.h:2
msgid "Unikey Wrapper For Fcitx"
@@ -154,6 +203,10 @@
msgid "Vni"
msgstr "Vni"
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//macro-editor/model.cpp:27
+msgid "Word"
+msgstr "Từ"
+
#~ msgid "(replace text)"
#~ msgstr "(chuỗi thay thế)"
@@ -179,9 +232,6 @@
#~ msgid "Choose file to import"
#~ msgstr "Chọn tập tin để nhập"
-#~ msgid "Delete _all"
-#~ msgstr "Xóa _hết"
-
#~ msgid "Full setup utility for IBus-Unikey"
#~ msgstr "Tiện ích cài đặt đầy đủ cho IBus-Unikey"
@@ -196,6 +246,9 @@
#~ msgid "Macro table definition"
#~ msgstr "Định nghĩa bảng gõ tắt"
+
+#~ msgid "N"
+#~ msgstr "N"
#~ msgid "Options"
#~ msgstr "Tùy chọn"
@@ -241,14 +294,5 @@
#~ " - Dùng + hoặc + để khôi phục phím.\n"
#~ " - Dùng để xác nhận từ (kết thúc từ)."
-#~ msgid "Word"
-#~ msgstr "Từ"
-
#~ msgid "_Edit macro"
#~ msgstr "_Sửa bảng gõ tắt"
-
-#~ msgid "_Export..."
-#~ msgstr "_Xuất..."
-
-#~ msgid "_Import..."
-#~ msgstr "_Nhập..."
diff --git a/po/zh_CN.po b/po/zh_CN.po
new file mode 100644
index 0000000..2fe5735
--- /dev/null
+++ b/po/zh_CN.po
@@ -0,0 +1,205 @@
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+#
+# Translators:
+# Christopher Meng , 2012.
+# Weng Xuetian , 2012.
+msgid ""
+msgstr ""
+"Project-Id-Version: fcitx\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2012-10-20 22:29-0400\n"
+"PO-Revision-Date: 2012-10-20 22:47-0400\n"
+"Last-Translator: Weng Xuetian \n"
+"Language-Team: Chinese Simplified \n"
+"Language: zh_CN\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=1; plural=0\n"
+"X-Generator: Lokalize 1.5\n"
+
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//macro-editor/editor.cpp:21
+msgid "&Add"
+msgstr "添加(&A)"
+
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//macro-editor/editor.cpp:22
+msgid "&Delete"
+msgstr "删除(&D)"
+
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//macro-editor/editor.cpp:27
+msgid "&Export"
+msgstr "导出(&E)"
+
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//macro-editor/editor.cpp:26
+msgid "&Import"
+msgstr "导入(&I)"
+
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//macro-editor/editor.cpp:24
+msgid "&Quit"
+msgstr "退出(&Q)"
+
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//macro-editor/editor.cpp:25
+msgid "&Save"
+msgstr "保存(&S)"
+
+#: /home/saber/Develop/fcitx-unikey/data/fcitx-unikey.desc:43
+msgid "Allow type with more freedom"
+msgstr ""
+
+#: /home/saber/Develop/fcitx-unikey/data/fcitx-unikey.desc:48
+msgid "Auto restore keys with invalid words"
+msgstr ""
+
+#: unknown
+msgid "BK HCM 2"
+msgstr "BK HCM 2"
+
+#: unknown
+msgid "CString"
+msgstr "CString"
+
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-ui.cpp:105
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-ui.cpp:172
+msgid "Choose input method"
+msgstr "选择输入法"
+
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-ui.cpp:113
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-ui.cpp:178
+msgid "Choose output charset"
+msgstr "选择输出字符集"
+
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//macro-editor/editor.cpp:23
+msgid "De&lete All"
+msgstr "全部删除(&L)"
+
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-ui.cpp:128
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-ui.cpp:188
+msgid "Enable Macro"
+msgstr "开启宏"
+
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-ui.cpp:120
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-ui.cpp:183
+msgid "Enable Spell Check"
+msgstr "启用拼写检查"
+
+#: /home/saber/Develop/fcitx-unikey/data/fcitx-unikey.desc:33
+msgid "Enable macro"
+msgstr "开启宏"
+
+#: /home/saber/Develop/fcitx-unikey/data/fcitx-unikey.desc:28
+msgid "Enable spell check"
+msgstr "启用拼写检查"
+
+#: /home/saber/Develop/fcitx-unikey/data/fcitx-unikey.desc:4
+msgid "Input Method"
+msgstr "输入法"
+
+#: unknown
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-ui.cpp:127
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-ui.cpp:187
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//macro-editor/model.cpp:25
+msgid "Macro"
+msgstr "宏"
+
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//macro-editor/editor.cpp:57
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//macro-editor/editor.cpp:85
+msgid "Macro table still contains unsaved changes. Do you want to save?"
+msgstr "宏表上有未保存的修改。您想要保存吗?"
+
+#: unknown
+msgid "NCR Decimal"
+msgstr "NCR Decimal"
+
+#: unknown
+msgid "NCR Hex"
+msgstr "NCR Hex"
+
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-ui.cpp:187
+msgid "No Macro"
+msgstr "禁用宏"
+
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-ui.cpp:182
+msgid "No Spell Check"
+msgstr "禁用拼写检查"
+
+#: /home/saber/Develop/fcitx-unikey/data/fcitx-unikey.desc:14
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-ui.cpp:156
+msgid "Output Charset"
+msgstr "输出字符集"
+
+#: /home/saber/Develop/fcitx-unikey/data/fcitx-unikey.desc:53
+msgid "Process W at word begin"
+msgstr ""
+
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//macro-editor/editor.cpp:56
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//macro-editor/editor.cpp:84
+msgid "Quit Macro Editor"
+msgstr ""
+
+#: unknown
+msgid "STelex"
+msgstr "STelex"
+
+#: unknown
+msgid "STelex2"
+msgstr "STelex2"
+
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-ui.cpp:119
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-ui.cpp:182
+msgid "Spell Check"
+msgstr "拼写检查"
+
+#: unknown
+msgid "TCVN3"
+msgstr "TCVN3"
+
+#: unknown
+msgid "Telex"
+msgstr "Telex"
+
+#: unknown
+msgid "Unicode"
+msgstr "Unicode"
+
+# unknown
+#: /home/saber/Develop/fcitx-unikey/build/po/tmp/fcitx-unikey.conf.in.h:1
+#: /home/saber/Develop/fcitx-unikey/build/po/tmp/unikey.conf.in.h:1
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-im.cpp:150
+msgid "Unikey"
+msgstr "Unikey"
+
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//src/unikey-ui.cpp:142
+msgid "Unikey Input Method"
+msgstr "Unikey 输入法"
+
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//macro-editor/editor.cpp:30
+msgid "Unikey Macro Editor"
+msgstr "Unikey 宏编辑器"
+
+#: /home/saber/Develop/fcitx-unikey/build/po/tmp/fcitx-unikey.conf.in.h:2
+msgid "Unikey Wrapper For Fcitx"
+msgstr "Fcitx 的 Unikey 封装"
+
+#: /home/saber/Develop/fcitx-unikey/data/fcitx-unikey.desc:38
+msgid "Use oà, _uý (instead of òa, úy)"
+msgstr "使用 oà, _uý (替换òa, úy)"
+
+#: unknown
+msgid "VIQR"
+msgstr "VIQR"
+
+#: unknown
+msgid "VNI Win"
+msgstr "VNI Win"
+
+#: unknown
+msgid "Vni"
+msgstr "Vni"
+
+#: /home/saber/Develop/fcitx-unikey/build/po/../..//macro-editor/model.cpp:27
+msgid "Word"
+msgstr "单词"
+
+#~ msgid "N"
+#~ msgstr "N"
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index fb0af74..43e0b3b 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -13,32 +13,7 @@
unikey-ui.cpp
)
-set(UNIKEY_SRCS
- ../unikey/byteio.cpp
- ../unikey/byteio.h
- ../unikey/charset.cpp
- ../unikey/charset.h
- ../unikey/convert.cpp
- ../unikey/data.cpp
- ../unikey/data.h
- ../unikey/error.cpp
- ../unikey/inputproc.cpp
- ../unikey/inputproc.h
- ../unikey/keycons.h
- ../unikey/mactab.cpp
- ../unikey/mactab.h
- ../unikey/pattern.cpp
- ../unikey/pattern.h
- ../unikey/ukengine.cpp
- ../unikey/ukengine.h
- ../unikey/unikey.cpp
- ../unikey/unikey.h
- ../unikey/usrkeymap.cpp
- ../unikey/usrkeymap.h
- ../unikey/vnconv.h
- ../unikey/vnlexi.h
-)
-
add_definitions( -DLOCALEDIR=\"${CMAKE_INSTALL_PREFIX}/share/locale\" )
-fcitx_add_addon(fcitx-unikey ${fcitx_unikey_sources} ${UNIKEY_SRCS} )
+fcitx_add_addon(fcitx-unikey ${fcitx_unikey_sources} )
+target_link_libraries(fcitx-unikey unikey)
diff --git a/src/unikey-im.cpp b/src/unikey-im.cpp
index f8fc4fa..1e25437 100644
--- a/src/unikey-im.cpp
+++ b/src/unikey-im.cpp
@@ -187,6 +187,7 @@
UnikeyResetBuf();
unikey->preeditstr->clear();
+ FcitxUnikeyUpdatePreedit(unikey);
}
void FcitxUnikeyCommit(FcitxUnikey* unikey)
@@ -239,7 +240,9 @@
FcitxUnikeyCommit(unikey);
return IRV_FLAG_FORWARD_KEY;
}
-
+ else if (state & FcitxKeyState_Super) {
+ return IRV_TO_PROCESS;
+ }
else if ((sym >= FcitxKey_Caps_Lock && sym <= FcitxKey_Hyper_R)
|| (!(state & FcitxKeyState_Shift) && (sym == FcitxKey_Shift_L || sym == FcitxKey_Shift_R)) // when press one shift key
)
@@ -267,7 +270,6 @@
else
{
FcitxUnikeyEraseChars(unikey, UnikeyBackspaces);
- FcitxUnikeyUpdatePreedit(unikey);
}
// change tone position after press backspace
@@ -287,8 +289,8 @@
}
unikey->auto_commit = false;
- FcitxUnikeyUpdatePreedit(unikey);
- }
+ }
+ FcitxUnikeyUpdatePreedit(unikey);
}
return IRV_DISPLAY_MESSAGE;
} // end capture BackSpace
@@ -493,6 +495,7 @@
}
FcitxMessagesAddMessageAtLast(clientPreedit, MSG_INPUT, "%s", unikey->preeditstr->c_str());
FcitxInputStateSetClientCursorPos(input, unikey->preeditstr->size());
+ FcitxUIUpdateInputWindow(unikey->owner);
}
CONFIG_DESC_DEFINE(GetUnikeyConfigDesc, "fcitx-unikey.desc")
@@ -530,6 +533,10 @@
UnikeySetInputMethod(unikey->config.im);
UnikeySetOutputCharset(Unikey_OC[unikey->config.oc]);
UnikeySetOptions(&unikey->ukopt);
+ char* userFile = NULL;
+ FcitxXDGGetFileUserWithPrefix("unikey", "macro", NULL, &userFile);
+ UnikeyLoadMacroTable(userFile);
+ free(userFile);
UpdateUnikeyUI(unikey);
}
diff --git a/src/unikey-ui.cpp b/src/unikey-ui.cpp
index 83680cf..a204701 100644
--- a/src/unikey-ui.cpp
+++ b/src/unikey-ui.cpp
@@ -179,11 +179,11 @@
FcitxUISetStatusString(unikey->owner,
"unikey-spell-check",
- unikey->config.spellCheck? _("Spell Check"): _("N"),
+ unikey->config.spellCheck? _("Spell Check"): _("No Spell Check"),
_("Enable Spell Check"));
FcitxUISetStatusString(unikey->owner,
"unikey-macro",
- unikey->config.macro? _("Macro"): _("N"),
+ unikey->config.macro? _("Macro"): _("No Macro"),
_("Enable Macro"));
}
diff --git a/unikey/CMakeLists.txt b/unikey/CMakeLists.txt
new file mode 100644
index 0000000..f7a3d91
--- /dev/null
+++ b/unikey/CMakeLists.txt
@@ -0,0 +1,30 @@
+
+set(UNIKEY_SRCS
+ byteio.cpp
+ byteio.h
+ charset.cpp
+ charset.h
+ convert.cpp
+ data.cpp
+ data.h
+ error.cpp
+ inputproc.cpp
+ inputproc.h
+ keycons.h
+ mactab.cpp
+ mactab.h
+ pattern.cpp
+ pattern.h
+ ukengine.cpp
+ ukengine.h
+ unikey.cpp
+ unikey.h
+ usrkeymap.cpp
+ usrkeymap.h
+ vnconv.h
+ vnlexi.h
+)
+
+
+add_library(unikey STATIC ${UNIKEY_SRCS})
+set_target_properties(unikey PROPERTIES COMPILE_FLAGS "-fPIC")
\ No newline at end of file
diff --git a/unikey/convert.cpp b/unikey/convert.cpp
index d6ee8fc..f22f6b7 100644
--- a/unikey/convert.cpp
+++ b/unikey/convert.cpp
@@ -77,7 +77,7 @@
//----------------------------------------------
//int VnConvert(int inCharset, int outCharset, UKBYTE *input, UKBYTE *output, int & inLen, int & maxOutLen)
-DllExport int VnConvert(int inCharset, int outCharset, UKBYTE *input, UKBYTE *output,
+DllExport int VnConvert(int inCharset, int outCharset, UKBYTE *input, UKBYTE *output,
int * pInLen, int * pMaxOutLen)
{
int inLen, maxOutLen;
@@ -163,7 +163,7 @@
if (outf == NULL) {
fclose(inf);
- ret = VNCONV_ERR_OUTPUT_FILE;
+ ret = VNCONV_ERR_OUTPUT_FILE;
goto end;
}
}
@@ -190,7 +190,7 @@
}
#endif
}
- else
+ else
remove(tmpName);
}
@@ -230,7 +230,7 @@
return genConvert(*pInCharset, *pOutCharset, is, os);
}
-const char *ErrTable[VNCONV_LAST_ERROR] =
+const char *ErrTable[VNCONV_LAST_ERROR] =
{"No error",
"Unknown error",
"Invalid charset",
diff --git a/unikey/mactab.cpp b/unikey/mactab.cpp
index 9abfa57..58d0cf4 100644
--- a/unikey/mactab.cpp
+++ b/unikey/mactab.cpp
@@ -133,8 +133,8 @@
//if BOM is available, skip it
char *p = line;
size_t len = strlen(line);
- if (len >= 3 && (unsigned char)line[0] == 0xEF && (unsigned char)line[1] == 0xBB &&
- (unsigned char)line[2] == 0xBF)
+ if (len >= 3 && (unsigned char)line[0] == 0xEF && (unsigned char)line[1] == 0xBB &&
+ (unsigned char)line[2] == 0xBF)
{
p += 3;
}
@@ -173,7 +173,7 @@
f = fopen(fname, "r");
#endif
- if (f == NULL)
+ if (f == NULL)
return 0;
char line[MAX_MACRO_LINE];
size_t len;
@@ -210,14 +210,19 @@
//---------------------------------------------------------------
int CMacroTable::writeToFile(const char *fname)
{
- int ret;
- int inLen, maxOutLen;
FILE *f;
#if defined(WIN32)
f = _tfopen(fname, _TEXT("wt"));
#else
f = fopen(fname, "w");
#endif
+ return writeToFp(f);
+}
+
+int CMacroTable::writeToFp(FILE* f)
+{
+ int ret;
+ int inLen, maxOutLen;
if (f == NULL)
return 0;
@@ -268,7 +273,7 @@
if (m_count >= MAX_MACRO_ITEMS)
return -1;
-
+
m_table[m_count].keyOffset = offset;
// Convert macro key to VN standard
@@ -276,7 +281,7 @@
maxOutLen = MAX_MACRO_KEY_LEN * sizeof(StdVnChar);
if (maxOutLen + offset > m_memSize)
maxOutLen = m_memSize - offset;
- ret = VnConvert(charset, CONV_CHARSET_VNSTANDARD,
+ ret = VnConvert(charset, CONV_CHARSET_VNSTANDARD,
(UKBYTE *)key, (UKBYTE *)p,
&inLen, &maxOutLen);
if (ret != 0)
@@ -291,7 +296,7 @@
maxOutLen = MAX_MACRO_TEXT_LEN * sizeof(StdVnChar);
if (maxOutLen + offset > m_memSize)
maxOutLen = m_memSize - offset;
- ret = VnConvert(charset, CONV_CHARSET_VNSTANDARD,
+ ret = VnConvert(charset, CONV_CHARSET_VNSTANDARD,
(UKBYTE *)text, (UKBYTE *)p,
&inLen, &maxOutLen);
if (ret != 0)
@@ -309,7 +314,7 @@
int CMacroTable::addItem(const char *item, int charset)
{
char key[MAX_MACRO_KEY_LEN];
-
+
// Parse the input item
char * pos = (char*)strchr(item, ':');
if (pos == NULL)
@@ -330,7 +335,7 @@
}
//---------------------------------------------------------------
-const StdVnChar *CMacroTable::getKey(int idx)
+const StdVnChar *CMacroTable::getKey(int idx) const
{
if (idx < 0 || idx >= m_count)
return 0;
@@ -338,7 +343,7 @@
}
//---------------------------------------------------------------
-const StdVnChar *CMacroTable::getText(int idx)
+const StdVnChar *CMacroTable::getText(int idx) const
{
if (idx < 0 || idx >= m_count)
return 0;
diff --git a/unikey/mactab.h b/unikey/mactab.h
index c38965f..64d4db2 100644
--- a/unikey/mactab.h
+++ b/unikey/mactab.h
@@ -55,11 +55,12 @@
void init();
int loadFromFile(const char *fname);
int writeToFile(const char *fname);
+ int writeToFp(FILE* f);
const StdVnChar *lookup(StdVnChar *key);
- const StdVnChar *getKey(int idx);
- const StdVnChar *getText(int idx);
- int getCount() { return m_count; }
+ const StdVnChar *getKey(int idx) const;
+ const StdVnChar *getText(int idx) const;
+ int getCount() const { return m_count; }
void resetContent();
int addItem(const char *item, int charset);
int addItem(const void *key, const void *text, int charset);
diff --git a/unikey/vnconv.h b/unikey/vnconv.h
index c94a72f..0fcb112 100644
--- a/unikey/vnconv.h
+++ b/unikey/vnconv.h
@@ -75,7 +75,7 @@
#if defined(__cplusplus)
extern "C" {
#endif
-DllInterface int VnConvert(int inCharset, int outCharset, UKBYTE *input, UKBYTE *output,
+DllInterface int VnConvert(int inCharset, int outCharset, UKBYTE *input, UKBYTE *output,
int * pInLen, int * pMaxOutLen);
DllInterface int VnFileConvert(int inCharset, int outCharset, const char *inFile, const char *outFile);