From: Thomas Pietrzak Date: Wed, 14 Mar 2012 09:04:34 +0000 (+0000) Subject: Widget keyboard initial import X-Git-Url: https://git.thomaspietrzak.com/?a=commitdiff_plain;h=0d36b76b3960f1e26132404e72233d24b48beb5f;p=Widgetkeyboard.git Widget keyboard initial import git-svn-id: svn+ssh://thomaspietrzak.com/var/svn/rep@60 47cf9a05-e0a8-4ed5-9e9b-101a649bc004 --- 0d36b76b3960f1e26132404e72233d24b48beb5f diff --git a/KeyboardDebug/KeyboardDebug.sln b/KeyboardDebug/KeyboardDebug.sln new file mode 100644 index 0000000..8f43f7d --- /dev/null +++ b/KeyboardDebug/KeyboardDebug.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "KeyboardDebug", "KeyboardDebug\KeyboardDebug.vcxproj", "{CB081BF4-9013-44A0-901D-E9B91F0DF953}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {CB081BF4-9013-44A0-901D-E9B91F0DF953}.Debug|Win32.ActiveCfg = Debug|Win32 + {CB081BF4-9013-44A0-901D-E9B91F0DF953}.Debug|Win32.Build.0 = Debug|Win32 + {CB081BF4-9013-44A0-901D-E9B91F0DF953}.Release|Win32.ActiveCfg = Release|Win32 + {CB081BF4-9013-44A0-901D-E9B91F0DF953}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/KeyboardDebug/KeyboardDebug.suo b/KeyboardDebug/KeyboardDebug.suo new file mode 100644 index 0000000..def15fb Binary files /dev/null and b/KeyboardDebug/KeyboardDebug.suo differ diff --git a/KeyboardDebug/KeyboardDebug/KeyboardDebug.vcxproj b/KeyboardDebug/KeyboardDebug/KeyboardDebug.vcxproj new file mode 100644 index 0000000..65ac718 --- /dev/null +++ b/KeyboardDebug/KeyboardDebug/KeyboardDebug.vcxproj @@ -0,0 +1,144 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {CB081BF4-9013-44A0-901D-E9B91F0DF953} + Qt4VSv1.0 + + + + Application + + + Application + + + + + + + + + + + + + <_ProjectFileVersion>10.0.40219.1 + AllRules.ruleset + + + AllRules.ruleset + + + $(SolutionDir)$(ConfigurationName) + $(SolutionDir)$(ConfigurationName) + + + + UNICODE;WIN32;QT_LARGEFILE_SUPPORT;QT_CORE_LIB;QT_GUI_LIB;%(PreprocessorDefinitions) + .\GeneratedFiles;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName);$(QTDIR)\include\qtmain;$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;.\;%(AdditionalIncludeDirectories) + Disabled + ProgramDatabase + MultiThreadedDebugDLL + false + + + Windows + $(OutDir)\$(ProjectName).exe + $(QTDIR)\lib;%(AdditionalLibraryDirectories) + true + DynamicKeyboardLibrary.lib;qtmaind.lib;QtCored4.lib;QtGuid4.lib;%(AdditionalDependencies) + + + + + UNICODE;WIN32;QT_LARGEFILE_SUPPORT;QT_NO_DEBUG;NDEBUG;QT_CORE_LIB;QT_GUI_LIB;%(PreprocessorDefinitions) + .\GeneratedFiles;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName);$(QTDIR)\include\qtmain;$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;.\;%(AdditionalIncludeDirectories) + + + MultiThreadedDLL + false + + + Windows + $(OutDir)\$(ProjectName).exe + $(QTDIR)\lib;%(AdditionalLibraryDirectories) + false + DynamicKeyboardLibrary.lib;qtmain.lib;QtCore4.lib;QtGui4.lib;%(AdditionalDependencies) + + + + + true + + + + + + + + + true + + + + + + + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing %(Identity)... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_CORE_LIB -DQT_GUI_LIB "-I." "-I.\GeneratedFiles" "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I$(QTDIR)\include\qtmain" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtGui" "-I." "-I." "-I." "-I." "keyboarddebug.h" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing %(Identity)... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DQT_GUI_LIB "-I." "-I.\GeneratedFiles" "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I$(QTDIR)\include\qtmain" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtGui" "-I." "-I." "-I." "-I." "keyboarddebug.h" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" + + + + + Document + $(QTDIR)\bin\uic.exe;%(AdditionalInputs) + Uic%27ing %(Identity)... + .\GeneratedFiles\ui_%(Filename).h;%(Outputs) + "$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)" + $(QTDIR)\bin\uic.exe;%(AdditionalInputs) + Uic%27ing %(Identity)... + .\GeneratedFiles\ui_%(Filename).h;%(Outputs) + "$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)" + + + + + + + + Document + %(FullPath);%(AdditionalInputs) + Rcc%27ing %(Identity)... + .\GeneratedFiles\qrc_%(Filename).cpp;%(Outputs) + "$(QTDIR)\bin\rcc.exe" -name "%(Filename)" -no-compress "%(FullPath)" -o .\GeneratedFiles\qrc_%(Filename).cpp + %(FullPath);%(AdditionalInputs) + Rcc%27ing %(Identity)... + .\GeneratedFiles\qrc_%(Filename).cpp;%(Outputs) + "$(QTDIR)\bin\rcc.exe" -name "%(Filename)" -no-compress "%(FullPath)" -o .\GeneratedFiles\qrc_%(Filename).cpp + + + + + + + + + + + \ No newline at end of file diff --git a/KeyboardDebug/KeyboardDebug/KeyboardDebug.vcxproj.filters b/KeyboardDebug/KeyboardDebug/KeyboardDebug.vcxproj.filters new file mode 100644 index 0000000..5e0432e --- /dev/null +++ b/KeyboardDebug/KeyboardDebug/KeyboardDebug.vcxproj.filters @@ -0,0 +1,70 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;cxx;c;def + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h + + + {99349809-55BA-4b9d-BF79-8FDBB0286EB3} + ui + + + {D9D6E242-F8AF-46E4-B9FD-80ECBC20BA3E} + qrc;* + false + + + {71ED8ED8-ACB9-4CE9-BBE1-E00B30144E11} + moc;h;cpp + False + + + {447a3b5f-957b-4b68-a79d-a07b726434e0} + cpp;moc + False + + + {e5b2149f-c711-4349-a902-c1554c9309a8} + cpp;moc + False + + + + + Source Files + + + Source Files + + + Generated Files\Debug + + + Generated Files\Release + + + Generated Files + + + + + Header Files + + + Form Files + + + Resource Files + + + + + Generated Files + + + \ No newline at end of file diff --git a/KeyboardDebug/KeyboardDebug/keyboarddebug.cpp b/KeyboardDebug/KeyboardDebug/keyboarddebug.cpp new file mode 100644 index 0000000..274757b --- /dev/null +++ b/KeyboardDebug/KeyboardDebug/keyboarddebug.cpp @@ -0,0 +1,110 @@ +#include "keyboarddebug.h" + +#include + +KeyboardDebug::KeyboardDebug(QWidget *parent, Qt::WFlags flags) + : QMainWindow(parent, flags) +{ + ui.setupUi(this); + try + { + _keyboardController = new DynamicKeyboardController("COM5", 115200); + getState(); + } + catch (...) + { + qDebug() << "Could not locate the Arduino board" << endl; + _keyboardController = NULL; + } + + + QObject::connect(ui.pushButton, SIGNAL(clicked()), this, SLOT(setConfiguration())); + QObject::connect(ui.getState, SIGNAL(clicked()), this, SLOT(getState())); + + QObject::connect(ui.minDutyCycle, SIGNAL(valueChanged(int)), this, SLOT(setMinDutyCycle(int))); + QObject::connect(ui.maxDutyCycle, SIGNAL(valueChanged(int)), this, SLOT(setMaxDutyCycle(int))); + QObject::connect(ui.boostDuration, SIGNAL(valueChanged(int)), this, SLOT(setBoostDuration(int))); + + QObject::connect(ui.s1, SIGNAL(stateChanged(int)), this, SLOT(setConfiguration(int))); + QObject::connect(ui.s2, SIGNAL(stateChanged(int)), this, SLOT(setConfiguration(int))); + QObject::connect(ui.s3, SIGNAL(stateChanged(int)), this, SLOT(setConfiguration(int))); + QObject::connect(ui.s4, SIGNAL(stateChanged(int)), this, SLOT(setConfiguration(int))); + QObject::connect(ui.s5, SIGNAL(stateChanged(int)), this, SLOT(setConfiguration(int))); + QObject::connect(ui.s6, SIGNAL(stateChanged(int)), this, SLOT(setConfiguration(int))); + QObject::connect(ui.s7, SIGNAL(stateChanged(int)), this, SLOT(setConfiguration(int))); + QObject::connect(ui.s8, SIGNAL(stateChanged(int)), this, SLOT(setConfiguration(int))); +} + +KeyboardDebug::~KeyboardDebug() +{ + +} + +inline bool isChecked(QCheckBox *c) +{ + bool a = c->checkState() > 0; + return c->checkState() > 0; +} + +void KeyboardDebug::setConfiguration() +{ + if (!_keyboardController) + return; + + UINT16 config = + UINT16(isChecked(ui.s1)) << 15 + | UINT16(isChecked(ui.s2)) << 14 + | UINT16(isChecked(ui.s3)) << 13 + | UINT16(isChecked(ui.s4)) << 12 + | UINT16(isChecked(ui.s5)) << 11 + | UINT16(isChecked(ui.s6)) << 10 + | UINT16(isChecked(ui.s7)) << 9 + | UINT16(isChecked(ui.s8)) << 8; + + qDebug() << hex << config << endl; + _keyboardController->setConfiguration(config); +} + +void KeyboardDebug::setConfiguration(int) +{ + setConfiguration(); +} + +void KeyboardDebug::setMinDutyCycle(int a) +{ + if (_keyboardController) + _keyboardController->setMinimumDutyCycle(UINT8(a)); +} + +void KeyboardDebug::setMaxDutyCycle(int a) +{ + if (_keyboardController) + _keyboardController->setMaximumDutyCycle(UINT8(a)); +} + +void KeyboardDebug::setBoostDuration(int a) +{ + if (_keyboardController) + _keyboardController->setBoostDuration(UINT16(a)); +} + +void KeyboardDebug::getState() +{ + UINT16 solenoids, duration; + UINT8 min, max; + if (_keyboardController) + _keyboardController->getState(solenoids, min, max, duration); + + ui.s1->setChecked(solenoids & 0x8000); + ui.s2->setChecked(solenoids & 0x4000); + ui.s3->setChecked(solenoids & 0x2000); + ui.s4->setChecked(solenoids & 0x1000); + ui.s5->setChecked(solenoids & 0x0800); + ui.s6->setChecked(solenoids & 0x0400); + ui.s7->setChecked(solenoids & 0x0200); + ui.s8->setChecked(solenoids & 0x0100); + + ui.minDutyCycle->setValue(min); + ui.maxDutyCycle->setValue(max); + ui.boostDuration->setValue(duration); +} diff --git a/KeyboardDebug/KeyboardDebug/keyboarddebug.h b/KeyboardDebug/KeyboardDebug/keyboarddebug.h new file mode 100644 index 0000000..59869e4 --- /dev/null +++ b/KeyboardDebug/KeyboardDebug/keyboarddebug.h @@ -0,0 +1,29 @@ +#ifndef KEYBOARDDEBUG_H +#define KEYBOARDDEBUG_H + +#include +#include "ui_keyboarddebug.h" + +#include + +class KeyboardDebug : public QMainWindow +{ + Q_OBJECT + +public: + KeyboardDebug(QWidget *parent = 0, Qt::WFlags flags = 0); + ~KeyboardDebug(); + + public slots: + void setConfiguration(); + void setConfiguration(int); + void setMinDutyCycle(int); + void setMaxDutyCycle(int); + void setBoostDuration(int); + void getState(); +private: + Ui::KeyboardDebugClass ui; + DynamicKeyboardController *_keyboardController; +}; + +#endif // KEYBOARDDEBUG_H diff --git a/KeyboardDebug/KeyboardDebug/keyboarddebug.qrc b/KeyboardDebug/KeyboardDebug/keyboarddebug.qrc new file mode 100644 index 0000000..cd1413f --- /dev/null +++ b/KeyboardDebug/KeyboardDebug/keyboarddebug.qrc @@ -0,0 +1,4 @@ + + + + diff --git a/KeyboardDebug/KeyboardDebug/keyboarddebug.ui b/KeyboardDebug/KeyboardDebug/keyboarddebug.ui new file mode 100644 index 0000000..678cec6 --- /dev/null +++ b/KeyboardDebug/KeyboardDebug/keyboarddebug.ui @@ -0,0 +1,160 @@ + + + KeyboardDebugClass + + + + 0 + 0 + 576 + 391 + + + + KeyboardDebug + + + + + + 110 + 50 + 421 + 311 + + + + + + + Solenoid 1 + + + + + + + Solenoid 2 + + + + + + + Solenoid 3 + + + + + + + Solenoid 4 + + + + + + + Solenoid 5 + + + + + + + Solenoid 6 + + + + + + + Solenoid 7 + + + + + + + Solenoid 8 + + + + + + + Test + + + + + + + 255 + + + 80 + + + + + + + 255 + + + 255 + + + + + + + 10000 + + + 10 + + + 200 + + + + + + + Min duty cycle + + + + + + + Max duty cycle + + + + + + + Boost Duration + + + + + + + Get state + + + + + + + + + + + + + diff --git a/KeyboardDebug/KeyboardDebug/main.cpp b/KeyboardDebug/KeyboardDebug/main.cpp new file mode 100644 index 0000000..4749db5 --- /dev/null +++ b/KeyboardDebug/KeyboardDebug/main.cpp @@ -0,0 +1,10 @@ +#include "keyboarddebug.h" +#include + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + KeyboardDebug w; + w.show(); + return a.exec(); +} diff --git a/WidgetKeyboard.sln b/WidgetKeyboard.sln new file mode 100644 index 0000000..86e6073 --- /dev/null +++ b/WidgetKeyboard.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WidgetKeyboard", "WidgetKeyboard\WidgetKeyboard.vcxproj", "{2B394A83-C563-419A-BECF-A6EE41EB5BE5}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {2B394A83-C563-419A-BECF-A6EE41EB5BE5}.Debug|Win32.ActiveCfg = Debug|Win32 + {2B394A83-C563-419A-BECF-A6EE41EB5BE5}.Debug|Win32.Build.0 = Debug|Win32 + {2B394A83-C563-419A-BECF-A6EE41EB5BE5}.Release|Win32.ActiveCfg = Release|Win32 + {2B394A83-C563-419A-BECF-A6EE41EB5BE5}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/WidgetKeyboard.suo b/WidgetKeyboard.suo new file mode 100644 index 0000000..85b165c Binary files /dev/null and b/WidgetKeyboard.suo differ diff --git a/WidgetKeyboard/WidgetKeyboard.pro b/WidgetKeyboard/WidgetKeyboard.pro new file mode 100644 index 0000000..09702bd --- /dev/null +++ b/WidgetKeyboard/WidgetKeyboard.pro @@ -0,0 +1,5 @@ +TEMPLATE=subdirs +CONFIG += ordered +include(common.pri) +WidgetKeyboard-uselib:SUBDIRS=buildlib +SUBDIRS+=example diff --git a/WidgetKeyboard/WidgetKeyboard.suo b/WidgetKeyboard/WidgetKeyboard.suo new file mode 100644 index 0000000..1b727b9 Binary files /dev/null and b/WidgetKeyboard/WidgetKeyboard.suo differ diff --git a/WidgetKeyboard/WidgetKeyboard.vcxproj b/WidgetKeyboard/WidgetKeyboard.vcxproj new file mode 100644 index 0000000..c16b8f9 --- /dev/null +++ b/WidgetKeyboard/WidgetKeyboard.vcxproj @@ -0,0 +1,248 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + + + + + + true + + + true + + + true + + + true + + + + + + + + + + + + + + + true + + + true + + + true + + + true + + + + + + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing %(Identity)... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_CORE_LIB -DQT_GUI_LIB "-I." "-I.\example" "-I.\src" "-I.\GeneratedFiles" "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I$(QTDIR)\include\qtmain" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtGui" "-I." "-I." "-I." "-I." "src\WidgetKeyboard.h" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing %(Identity)... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DQT_GUI_LIB "-I." "-I.\example" "-I.\src" "-I.\GeneratedFiles" "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I$(QTDIR)\include\qtmain" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtGui" "-I." "-I." "-I." "-I." "src\WidgetKeyboard.h" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" + + + + + Document + %(FullPath);.\src\res\down.JPG;.\src\res\left.JPG;.\src\res\right.JPG;.\src\res\up.JPG;%(AdditionalInputs) + Rcc%27ing %(Identity)... + .\GeneratedFiles\qrc_%(Filename).cpp;%(Outputs) + "$(QTDIR)\bin\rcc.exe" -name "%(Filename)" -no-compress "%(FullPath)" -o .\GeneratedFiles\qrc_%(Filename).cpp + %(FullPath);.\src\res\down.JPG;.\src\res\left.JPG;.\src\res\right.JPG;.\src\res\up.JPG;%(AdditionalInputs) + Rcc%27ing %(Identity)... + .\GeneratedFiles\qrc_%(Filename).cpp;%(Outputs) + "$(QTDIR)\bin\rcc.exe" -name "%(Filename)" -no-compress "%(FullPath)" -o .\GeneratedFiles\qrc_%(Filename).cpp + + + + + Document + $(QTDIR)\bin\uic.exe;%(AdditionalInputs) + Uic%27ing %(Identity)... + .\GeneratedFiles\ui_%(Filename).h;%(Outputs) + "$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)" + $(QTDIR)\bin\uic.exe;%(AdditionalInputs) + Uic%27ing %(Identity)... + .\GeneratedFiles\ui_%(Filename).h;%(Outputs) + "$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)" + + + true + true + + + true + true + + + Document + %(FullPath);.\grey.png;.\blue.png;%(AdditionalInputs) + Rcc%27ing %(Identity)... + .\GeneratedFiles\qrc_%(Filename).cpp;%(Outputs) + "$(QTDIR)\bin\rcc.exe" -name "%(Filename)" -no-compress "%(FullPath)" -o .\GeneratedFiles\qrc_%(Filename).cpp + %(FullPath);.\grey.png;.\blue.png;%(AdditionalInputs) + Rcc%27ing %(Identity)... + .\GeneratedFiles\qrc_%(Filename).cpp;%(Outputs) + "$(QTDIR)\bin\rcc.exe" -name "%(Filename)" -no-compress "%(FullPath)" -o .\GeneratedFiles\qrc_%(Filename).cpp + + + true + true + + + true + true + + + true + true + + + true + true + + + Document + $(QTDIR)\bin\uic.exe;%(AdditionalInputs) + Uic%27ing %(Identity)... + .\GeneratedFiles\ui_%(Filename).h;%(Outputs) + "$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)" + $(QTDIR)\bin\uic.exe;%(AdditionalInputs) + Uic%27ing %(Identity)... + .\GeneratedFiles\ui_%(Filename).h;%(Outputs) + "$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)" + + + + + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing %(Identity)... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_CORE_LIB -DQT_GUI_LIB "-I." "-I.\example" "-I.\src" "-I.\GeneratedFiles" "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I$(QTDIR)\include\qtmain" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtGui" "-I." "-I." "-I." "-I." "example\UseKeyBoardDialog.h" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing %(Identity)... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DQT_GUI_LIB "-I." "-I.\example" "-I.\src" "-I.\GeneratedFiles" "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I$(QTDIR)\include\qtmain" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtGui" "-I." "-I." "-I." "-I." "example\UseKeyBoardDialog.h" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" + + + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing %(Identity)... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_CORE_LIB -DQT_GUI_LIB "-I." "-I.\example" "-I.\src" "-I.\GeneratedFiles" "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I$(QTDIR)\include\qtmain" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtGui" "-I." "-I." "-I." "-I." "example\Sheet.h" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing %(Identity)... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DQT_GUI_LIB "-I." "-I.\example" "-I.\src" "-I.\GeneratedFiles" "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I$(QTDIR)\include\qtmain" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtGui" "-I." "-I." "-I." "-I." "example\Sheet.h" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" + + + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing %(Identity)... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_CORE_LIB -DQT_GUI_LIB "-I." "-I.\example" "-I.\src" "-I.\GeneratedFiles" "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I$(QTDIR)\include\qtmain" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtGui" "-I." "-I." "-I." "-I." "example\DynaKeyboard.h" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing %(Identity)... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DQT_GUI_LIB "-I." "-I.\example" "-I.\src" "-I.\GeneratedFiles" "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I$(QTDIR)\include\qtmain" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtGui" "-I." "-I." "-I." "-I." "example\DynaKeyboard.h" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" + + + + + + {2B394A83-C563-419A-BECF-A6EE41EB5BE5} + Qt4VSv1.0 + + + + Application + + + Application + + + + + + + + + + + + + <_ProjectFileVersion>10.0.40219.1 + AllRules.ruleset + + + AllRules.ruleset + + + $(SolutionDir)$(ConfigurationName) + $(SolutionDir)$(ConfigurationName) + + + + UNICODE;WIN32;QT_LARGEFILE_SUPPORT;QT_CORE_LIB;QT_GUI_LIB;%(PreprocessorDefinitions) + .\example;.\src;.\GeneratedFiles;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName);$(QTDIR)\include\qtmain;$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;.\;%(AdditionalIncludeDirectories) + Disabled + ProgramDatabase + MultiThreadedDebugDLL + false + + + Windows + $(OutDir)\$(ProjectName).exe + $(QTDIR)\lib;%(AdditionalLibraryDirectories) + true + qtmaind.lib;QtCored4.lib;QtGuid4.lib;%(AdditionalDependencies) + + + + + UNICODE;WIN32;QT_LARGEFILE_SUPPORT;QT_NO_DEBUG;NDEBUG;QT_CORE_LIB;QT_GUI_LIB;%(PreprocessorDefinitions) + .\example;.\src;.\GeneratedFiles;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName);$(QTDIR)\include\qtmain;$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;.\;%(AdditionalIncludeDirectories) + + + MultiThreadedDLL + false + + + Windows + $(OutDir)\$(ProjectName).exe + $(QTDIR)\lib;%(AdditionalLibraryDirectories) + false + qtmain.lib;QtCore4.lib;QtGui4.lib;%(AdditionalDependencies) + + + + + + + + + + + \ No newline at end of file diff --git a/WidgetKeyboard/WidgetKeyboard.vcxproj.filters b/WidgetKeyboard/WidgetKeyboard.vcxproj.filters new file mode 100644 index 0000000..0a66024 --- /dev/null +++ b/WidgetKeyboard/WidgetKeyboard.vcxproj.filters @@ -0,0 +1,138 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;cxx;c;def + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h + + + {99349809-55BA-4b9d-BF79-8FDBB0286EB3} + ui + + + {D9D6E242-F8AF-46E4-B9FD-80ECBC20BA3E} + qrc;* + false + + + {71ED8ED8-ACB9-4CE9-BBE1-E00B30144E11} + moc;h;cpp + False + + + {f57afe67-495f-4895-b08f-60d56773d279} + cpp;moc + False + + + {9a02c7f2-76dc-4701-a6df-c48fdbb338e6} + cpp;moc + False + + + + + Source Files + + + Generated Files\Debug + + + Generated Files\Release + + + Generated Files + + + Generated Files\Debug + + + Generated Files\Release + + + Generated Files\Debug + + + Generated Files\Release + + + Generated Files\Debug + + + Generated Files\Release + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Generated Files + + + + + Header Files + + + Resource Files + + + Form Files + + + Form Files + + + Header Files + + + Header Files + + + Header Files + + + Resource Files + + + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + + + Generated Files + + + Generated Files + + + \ No newline at end of file diff --git a/WidgetKeyboard/WidgetKeyboard.vcxproj.user b/WidgetKeyboard/WidgetKeyboard.vcxproj.user new file mode 100644 index 0000000..ca1c7bf --- /dev/null +++ b/WidgetKeyboard/WidgetKeyboard.vcxproj.user @@ -0,0 +1,10 @@ + + + + C:\Qt\4.7.3 + PATH=$(QTDIR)\bin%3b$(PATH) + PATH=$(QTDIR)\bin%3b$(PATH) + $(ProjectDir) + WindowsLocalDebugger + + \ No newline at end of file diff --git a/WidgetKeyboard/blue.png b/WidgetKeyboard/blue.png new file mode 100644 index 0000000..17abc81 Binary files /dev/null and b/WidgetKeyboard/blue.png differ diff --git a/WidgetKeyboard/common.pri b/WidgetKeyboard/common.pri new file mode 100644 index 0000000..453de63 --- /dev/null +++ b/WidgetKeyboard/common.pri @@ -0,0 +1,9 @@ +infile(config.pri, SOLUTIONS_LIBRARY, yes): CONFIG += WidgetKeyboard-uselib +TEMPLATE += fakelib +WIDGETKEYBOARD_LIBNAME = $$qtLibraryTarget(WidgetKeyboard-1.0) +TEMPLATE -= fakelib +WIDGETKEYBOARD_LIBDIR = $$PWD/lib +unix:WidgetKeyboard-uselib:!WidgetKeyboard-buildlib:QMAKE_RPATHDIR += $$WIDGETKEYBOARD_LIBDIR + +RESOURCES += \ + ../ressource.qrc diff --git a/WidgetKeyboard/example/DynaKeyboard.cpp b/WidgetKeyboard/example/DynaKeyboard.cpp new file mode 100644 index 0000000..5dac04d --- /dev/null +++ b/WidgetKeyboard/example/DynaKeyboard.cpp @@ -0,0 +1,73 @@ +#include "DynaKeyboard.h" + +DynaKeyboard::DynaKeyboard() +{ + visual = new DynaKeyboardVisual(0); + haptic = new DynaKeyboardHaptic(this); +} + + +void DynaKeyboard::raiseKeys(QVector keys, bool ctrl, bool shift, bool alt){ + + QVector res = filterRaisedKeys(keys, ctrl, shift, alt); + haptic->raiseKeys(res); + this->keysRaised(res); + + +} + +QVector DynaKeyboard::filterRaisedKeys(QVector keys, bool Ctrl, bool Shift, bool Alt) +{ + QVector res; + return keys; + + if(Ctrl & Shift & Alt) // ctrl shift alt + { + res = ctrlShiftAlt(keys); + }else if (Ctrl & Shift & !Alt) //ctrl shift + { + res = ctrlShift(keys); + }else if (Ctrl & !Shift & Alt) //ctrl alt + { + res = ctrlAlt(keys); + }else if (Ctrl & !Shift & !Alt) + { + res = ctrl(keys); + }else if (!Ctrl &!Shift & Alt) + { + res = alt(keys); + } + + return res; +} + + +QVector DynaKeyboard::ctrl(QVector keys ){ + QVector res; + return res; +} +QVector DynaKeyboard::ctrlShift(QVector keys){ + QVector res; + return res; +} +QVector DynaKeyboard::ctrlShiftAlt(QVector keys){ + QVector res; + return res; +} +QVector DynaKeyboard::ctrlAlt(QVector keys){ + QVector res; + return res; +} + +QVector DynaKeyboard::alt(QVector keys){ + QVector res; + return res; +} + + + +//called from thomas +void DynaKeyboard::keysRaised(QVector keys) +{ + visual->raiseKeys(keys); +} diff --git a/WidgetKeyboard/example/DynaKeyboard.h b/WidgetKeyboard/example/DynaKeyboard.h new file mode 100644 index 0000000..b164de2 --- /dev/null +++ b/WidgetKeyboard/example/DynaKeyboard.h @@ -0,0 +1,33 @@ +#ifndef DYNAKEYBOARD_H +#define DYNAKEYBOARD_H + +#include "DynaKeyboardVisual.h" +#include "DynaKeyboardHaptic.h" + +class DynaKeyboard +{ +public: + DynaKeyboard(); + void init(); + + DynaKeyboardVisual *visual; + DynaKeyboardHaptic *haptic; + + void raiseKeys(QVector keys, bool ctrl, bool shift, bool alt); //called by the application + + //While the application can have several hotkeys + //we just want to raise the most frequent ones, or not rising two neighboor keys + QVector filterRaisedKeys(QVector keys, bool ctrl, bool shift, bool alt); + + void keysRaised(QVector); //called by thomas with the list of keys + +protected: + QVector ctrl(QVector keys ); + QVector ctrlShift(QVector keys); + QVector ctrlShiftAlt(QVector keys); + QVector ctrlAlt(QVector keys); + QVector alt(QVector keys); + +}; + +#endif // DYNAKEYBOARD_H diff --git a/WidgetKeyboard/example/DynaKeyboardHaptic.cpp b/WidgetKeyboard/example/DynaKeyboardHaptic.cpp new file mode 100644 index 0000000..0041d76 --- /dev/null +++ b/WidgetKeyboard/example/DynaKeyboardHaptic.cpp @@ -0,0 +1,21 @@ +#include "DynaKeyboardHaptic.h" +#include "DynaKeyboard.h" + + +DynaKeyboardHaptic::DynaKeyboardHaptic(DynaKeyboard *dyna){ + dynaKeyboard = dyna; +} + +void DynaKeyboardHaptic::raiseKeys(QVector keys) +{ + //you have more keys than solenoids here. +} + +void DynaKeyboardHaptic::initSolenoidKeyMapping() +{ + +} + +void DynaKeyboardHaptic::raiseSolenoids(){} + +void DynaKeyboardHaptic::lowerSolenoids(){} diff --git a/WidgetKeyboard/example/DynaKeyboardHaptic.h b/WidgetKeyboard/example/DynaKeyboardHaptic.h new file mode 100644 index 0000000..803e931 --- /dev/null +++ b/WidgetKeyboard/example/DynaKeyboardHaptic.h @@ -0,0 +1,22 @@ +#ifndef DYNAKEYBOARDHAPTIC_H +#define DYNAKEYBOARDHAPTIC_H + +#include +#include + +class DynaKeyboard; + +class DynaKeyboardHaptic +{ +public: + DynaKeyboardHaptic(DynaKeyboard* dyna); + void initSolenoidKeyMapping(); + void raiseKeys(QVector keys); + void raiseSolenoids(); + void lowerSolenoids(); + + DynaKeyboard *dynaKeyboard; + +}; + +#endif // DYNAKEYBOARDHAPTIC_H diff --git a/WidgetKeyboard/example/DynaKeyboardVisual.cpp b/WidgetKeyboard/example/DynaKeyboardVisual.cpp new file mode 100644 index 0000000..3c20b11 --- /dev/null +++ b/WidgetKeyboard/example/DynaKeyboardVisual.cpp @@ -0,0 +1,101 @@ +#include "DynaKeyboardVisual.h" +#include +#include +//---------------------- +DynaKeyboardVisual::DynaKeyboardVisual(QObject *parent) : + QObject(parent) +{ + debug =0; + // initSolenoidKeyMapping(); + reset(); +} + +//void DynaKeyboardVisual::initSolenoidKeyMapping(){ +// hotkeys.append("C"); +// hotkeys.append("Z"); +// hotkeys.append("B"); +// hotkeys.append("F"); +// hotkeys.append("P"); +// hotkeys.append("N"); +// hotkeys.append("S"); +// hotkeys.append("W"); + + +// for(int i=0;i i(keyState); + while (i.hasNext()) { + i.next(); + //if(solenoid.contains(i.key())) + //{ + keyState.insert(i.key(), b); + } + //std::cout << i.key() << ": " << i.value() << endl; + //} + + //thomas call your method + //for all your solenoid.... + + updateOutput(); +} + +void DynaKeyboardVisual::updateKey(int key, bool raised){ + + //if(solenoid.contains(key)){ + keyState.insert(key, raised); + //int idSolenoid = solenoid.value(key); + //thomas call your method + + updateOutput(); + //} + +} + +void DynaKeyboardVisual::updateOutput() +{ + if(!debug) return; + debug->raiseKeys(keyState); + +} + +void DynaKeyboardVisual::lowerAll(){ + updateAll(0); +} + +void DynaKeyboardVisual::raisAll(){ + updateAll(1); +} + + +void DynaKeyboardVisual::raiseKeys(QVector keys){ + reset(); + for(int i=0; i +#include +#include "WidgetKeyboard.h" +class DynaKeyboardVisual : public QObject +{ + Q_OBJECT +public: + explicit DynaKeyboardVisual(QObject *parent = 0); + void printRaisedKey(); + void setOutput(WidgetKeyboard *_debug){ debug = _debug; } + +signals: + void reportException(QString); + +public slots: + void lowerAll(); + void raisAll(); + void reset(){ lowerAll(); } + void raiseKey(int); + void lowerKey(int); + void raiseKey(QString c); + void lowerKey(QString c); + void raiseKeys(QVector keys); + +protected: + void updateAll(bool); + void updateKey(int, bool raised); + void updateOutput(); + void getSolenoidFromKey(); + void initSolenoidKeyMapping(); + QMap keyState; + // QMap solenoid; + // QVector hotkeys; + WidgetKeyboard *debug; + +}; + +#endif // DynaKeyboardVisual_H diff --git a/WidgetKeyboard/example/Main.cpp b/WidgetKeyboard/example/Main.cpp new file mode 100644 index 0000000..93a9a81 --- /dev/null +++ b/WidgetKeyboard/example/Main.cpp @@ -0,0 +1,43 @@ +/* + * Copyright 2009 EMBITEL (http://www.embitel.com) + * + * This file is part of Virtual Keyboard Project. + * + * Virtual Keyboard 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 + * + * Virtual Keyboard 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 Virtual Keyboard. If not, see . + */ + +#include +#include "UseKeyBoardDialog.h" + +#ifdef Q_WS_MAC +extern void qt_set_sequence_auto_mnemonic(bool b); +#endif + + +#include "Sheet.h" +int main(int argc, char *argv[]) +{ +#ifdef Q_WS_MAC + qt_set_sequence_auto_mnemonic(true); +#endif + + QApplication a(argc, argv); + //UseKeyBoardDialog w; + + Sheet *sheet = new Sheet(); + + + + //w.show(); + return a.exec(); +} diff --git a/WidgetKeyboard/example/MenuBar.cpp b/WidgetKeyboard/example/MenuBar.cpp new file mode 100644 index 0000000..8cdc843 --- /dev/null +++ b/WidgetKeyboard/example/MenuBar.cpp @@ -0,0 +1,10 @@ +#include "MenuBar.h" + +MenuBar::MenuBar() +{ + this->menubar = new QMenuBar() +} + +void buildMenuBar(){ + +} diff --git a/WidgetKeyboard/example/Sheet.cpp b/WidgetKeyboard/example/Sheet.cpp new file mode 100644 index 0000000..59fd406 --- /dev/null +++ b/WidgetKeyboard/example/Sheet.cpp @@ -0,0 +1,301 @@ +#include "Sheet.h" +#include +#include +#include +#include +#include +#include +//extern void qt_set_sequence_auto_mnemonic(true); + +Sheet::Sheet(QWidget *parent) : + QWidget(parent) +{ + window = new QMainWindow(); + + this->resize(800,600); + + window->setCentralWidget(this); + //this->showFullScreen(); + this->createMenuBar(); + window->showFullScreen(); + ctrl = false; + shift = false; + alt = false; + getCtrlHotkeys(); + init(); + this->setFocus(); + QApplication::setStyle(new QPlastiqueStyle); + +} + +void Sheet::init() +{ + dynaKeyboard = new DynaKeyboard(); + WidgetKeyboard *output = new WidgetKeyboard(this); + output->show(); + dynaKeyboard->visual->setOutput(output); + dynaKeyboard->raiseKeys(getCtrlHotkeys(), 0, 0, 0); +} + +void Sheet::createMenuBar() +{ + + menubar = window->menuBar(); + menubar->setNativeMenuBar(false); + QFont font = menubar->font(); + font.setPointSize(16); + menubar->setFont(font); + + QMenu *menu = menubar->addMenu("&File"); + actionMenuList.append(menu->menuAction()); + menu->installEventFilter(this); + menu->setFont(font); + actionList.append( menu->addAction("&New",this, SLOT(newDoc()),QKeySequence(Qt::CTRL + Qt::Key_N))); + actionList.append(menu->addAction("Open",this, SLOT(open()),QKeySequence(Qt::CTRL + Qt::Key_O))); + menu->addSeparator(); + actionList.append(menu->addAction("&Save", this, SLOT(save()), QKeySequence(Qt::CTRL + Qt::Key_S))); + actionList.append(menu->addAction("Save &As", this, SLOT(saveAs()), QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_S))); + actionList.append(menu->addAction("Save H&tml", this, SLOT(saveHtml()),QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::ALT + Qt::Key_S))); + menu->addSeparator(); + actionList.append(menu->addAction("Export", this, SLOT(exportDoc()))); + actionList.append(menu->addAction("&Print", this, SLOT(print()), QKeySequence(Qt::CTRL + Qt::Key_P) )); + menu->addSeparator(); + actionList.append(menu->addAction("&Close",this, SLOT(close()),QKeySequence(Qt::CTRL + Qt::Key_W))); + actionList.append(menu->addAction("Close All",this, SLOT(closeAll()),QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_W))); + + QMenu *edit = menubar->addMenu("&Edit"); + actionMenuList.append(edit->menuAction()); + edit->setFont(font); + actionList.append(edit->addAction("Undo",this, SLOT(undo()),QKeySequence(Qt::CTRL + Qt::Key_Z))); + actionList.append(edit->addAction("Redo",this, SLOT(redo()),QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_Z))); + edit->addSeparator(); + actionList.append(edit->addAction("Cu&t", this, SLOT(cut()), QKeySequence(Qt::CTRL + Qt::Key_X))); + actionList.append(edit->addAction("&Copy", this, SLOT(copy()), QKeySequence(Qt::CTRL + Qt::Key_C))); + actionList.append(edit->addAction("&Paste", this, SLOT(paste()), QKeySequence(Qt::CTRL + Qt::Key_V))); + edit->addSeparator(); + actionList.append(edit->addAction("Select All", this, SLOT(selectAll()),QKeySequence(Qt::CTRL + Qt::Key_A))); + edit->addMenu("Advanced"); + edit->addSeparator(); + actionList.append(edit->addAction("Find",this, SLOT(find()),QKeySequence(Qt::CTRL + Qt::Key_F))); + actionList.append(edit->addAction("Find Next",this, SLOT(findNext()),QKeySequence(Qt::CTRL + + Qt::SHIFT + Qt::Key_F))); + + QMenu *tool = menubar->addMenu("&Tool"); + actionMenuList.append(tool->menuAction()); + actionList.append(tool->addAction("&Small Tool",this, SLOT(tool()),QKeySequence(Qt::CTRL + Qt::Key_T))); + actionList.append(tool->addAction("Medium Tool",this, SLOT(tool()),QKeySequence(Qt::CTRL + + Qt::SHIFT + Qt::Key_T))); + actionList.append(tool->addAction("Large Tool",this, SLOT(tool()),QKeySequence(Qt::CTRL + + Qt::SHIFT + Qt::ALT + Qt::Key_T))); + actionList.append(tool->addAction("&Altenrative Tool",this, SLOT(tool()),QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_T))); + actionList.append(tool->addAction("Drawing",this, SLOT(tool()),QKeySequence(Qt::Key_D))); + + QList sequences = actionList.at(actionList.size()-1)->shortcuts(); + for(int i=0;itext()); + } + QMenu *window = menubar->addMenu("&Window"); + actionMenuList.append(window->menuAction()); + QMenu *help = menubar->addMenu("Hel&p"); + actionMenuList.append(help->menuAction()); + +} + +QVector Sheet::getCtrlHotkeys(){ + QVector hotkeys; + bool ctrl2 = false; + bool shift2 =false; + bool alt2 =false; + bool valid = false; + for(int i=0; i< actionList.size();i++) + { + QKeySequence seq = actionList.at(i)->shortcut(); + QString str = seq.toString(); + //qDebug()<< "keysequence: "<< str; + ctrl2 = str.contains("Ctrl"); + shift2 = str.contains("Shift"); + alt2 = str.contains("Alt"); + valid = seq.count(); + if(ctrl2 == ctrl && shift2 == shift && alt2 == alt && valid){ + hotkeys.append(QString(str[str.length()-1])); + + } + + } + + qDebug()<< hotkeys; + return hotkeys; + +} + +QVector Sheet::getAltHotkeys(){ + QVector hotkeys; + if (window->menuBar()->activeAction()) + return hotkeys; + + bool alt2 =false; + for(int i=0; i< actionMenuList.size();i++) + { + QKeySequence seq = actionMenuList.at(i)->shortcut(); + QString str = seq.mnemonic(actionMenuList.at(i)->text()).toString(); + //qDebug()<< "alt keysequence: "<< str; + alt2 = str.contains("Alt"); + + if(alt2 == alt){ + hotkeys.append(QString(str[str.length()-1])); + + } + + } + + return hotkeys; + +} + +QVector Sheet::getImplicitAndAltHotkeys(){ + QVector hotkeys; + + QAction *action = window->menuBar()->activeAction(); + if(!action) + { + hotkeys = getCtrlHotkeys(); + }else{ + QMenu* menu = action->menu(); + for(int i=0; i< actionList.size();i++) + { + if(action->parentWidget() ==menu) + { + QKeySequence seq = actionList.at(i)->shortcut(); + QString str = seq.mnemonic(actionList.at(i)->text()).toString(); + if(str.contains("Alt")) + hotkeys.append(QString(str[str.length()-1])); + } + } + } + + + return hotkeys; +} + + +void Sheet::raiseCtrl(){ + +} +void Sheet::raiseCtrlShift(){} +void Sheet::raiseCtrlShiftAlt(){} +void Sheet::raiseCtrlAlt(){} + +bool Sheet::eventFilter(QObject *obj, QEvent *event) +{ + if (event->type() == QEvent::KeyPress) { + QKeyEvent *ke = static_cast(event); + //qDebug()<<"keypressEvent"; + ctrl = ke->modifiers() & Qt::ControlModifier; + shift = ke->modifiers() & Qt::ShiftModifier; + alt = ke->modifiers() & Qt::AltModifier; + if(ctrl) // ctrl shift alt + { + this->dynaKeyboard->raiseKeys(getCtrlHotkeys(), ctrl, shift, alt); + + }else if (!ctrl & !shift & alt) //ctrl shift + { + this->dynaKeyboard->raiseKeys(getAltHotkeys(), ctrl, shift, alt); + }else if( !ctrl & !shift & !alt) + { + this->dynaKeyboard->raiseKeys( getImplicitAndAltHotkeys(), ctrl, shift, alt); + } + + } else if (event->type() == QEvent::KeyRelease) { + QKeyEvent *ke = static_cast(event); + //qDebug()<<"keypressEvent"; + ctrl = ke->modifiers() & Qt::ControlModifier; + shift = ke->modifiers() & Qt::ShiftModifier; + alt = ke->modifiers() & Qt::AltModifier; + if(ctrl) // ctrl shift alt + { + this->dynaKeyboard->raiseKeys(getCtrlHotkeys(), ctrl, shift, alt); + + }else if (!ctrl & !shift & alt) //ctrl shift + { + this->dynaKeyboard->raiseKeys(getAltHotkeys(), ctrl, shift, alt); + }else if( !ctrl & !shift & !alt) + { + this->dynaKeyboard->raiseKeys( getImplicitAndAltHotkeys(), ctrl, shift, alt); + } + } + return false; +} + +bool Sheet::event(QEvent *event) +{ + + if (event->type() == QEvent::KeyPress) { + QKeyEvent *ke = static_cast(event); + //qDebug()<<"keypressEvent"; + ctrl = ke->modifiers() & Qt::ControlModifier; + shift = ke->modifiers() & Qt::ShiftModifier; + alt = ke->modifiers() & Qt::AltModifier; + if(ctrl) // ctrl shift alt + { + this->dynaKeyboard->raiseKeys(getCtrlHotkeys(), ctrl, shift, alt); + + }else if (!ctrl & !shift & alt) //ctrl shift + { + this->dynaKeyboard->raiseKeys(getAltHotkeys(), ctrl, shift, alt); + }else if( !ctrl & !shift & !alt) + { + this->dynaKeyboard->raiseKeys( getImplicitAndAltHotkeys(), ctrl, shift, alt); + } + + } else if (event->type() == QEvent::KeyRelease) { + QKeyEvent *ke = static_cast(event); + //qDebug()<<"keypressEvent"; + ctrl = ke->modifiers() & Qt::ControlModifier; + shift = ke->modifiers() & Qt::ShiftModifier; + alt = ke->modifiers() & Qt::AltModifier; + if(ctrl) // ctrl shift alt + { + this->dynaKeyboard->raiseKeys(getCtrlHotkeys(), ctrl, shift, alt); + + }else if (!ctrl & !shift & alt) //ctrl shift + { + this->dynaKeyboard->raiseKeys(getAltHotkeys(), ctrl, shift, alt); + }else if( !ctrl & !shift & !alt) + { + this->dynaKeyboard->raiseKeys( getImplicitAndAltHotkeys(), ctrl, shift, alt); + } + } + + return QWidget::event(event); +} + +void Sheet::keyPressEvent(QKeyEvent *ke) +{ + +} + +void Sheet::keyReleaseEvent(QKeyEvent *ke) +{ + + +} + +void Sheet::newDoc(){ this->setFocus();} +void Sheet::open(){this->setFocus();} +void Sheet::save(){this->setFocus();} +void Sheet::saveAs(){this->setFocus();} +void Sheet::saveHtml(){this->setFocus();} +void Sheet::close(){ this->setFocus(); } +void Sheet::closeAll(){ exit(0); } +void Sheet::exportDoc(){this->setFocus();} +void Sheet::print(){this->setFocus();} +void Sheet::undo(){this->setFocus();} +void Sheet::redo(){this->setFocus();} +void Sheet::cut(){this->setFocus();} +void Sheet::copy(){this->setFocus();} +void Sheet::paste(){this->setFocus();} +void Sheet::selectAll(){this->setFocus();} +void Sheet::find(){this->setFocus();} +void Sheet::findNext(){this->setFocus();} +void Sheet::tool(){this->setFocus();} + + + + diff --git a/WidgetKeyboard/example/Sheet.h b/WidgetKeyboard/example/Sheet.h new file mode 100644 index 0000000..257ae9a --- /dev/null +++ b/WidgetKeyboard/example/Sheet.h @@ -0,0 +1,73 @@ +#ifndef SHEET_H +#define SHEET_H + +#include +#include +#include +#include +#include +#include "DynaKeyboard.h" +#include "WidgetKeyboard.h" +#include +#include +#include +class Sheet : public QWidget +{ + Q_OBJECT +public: + explicit Sheet(QWidget *parent = 0); + void createMenuBar(); + void init(); + + void keyPressEvent(QKeyEvent *); + void keyReleaseEvent(QKeyEvent *); + bool event(QEvent *event); + bool eventFilter(QObject *, QEvent *e); + + void raiseCtrl(); + void raiseCtrlShift(); + void raiseCtrlShiftAlt(); + void raiseCtrlAlt(); + + QVector getCtrlHotkeys(); + QVector getAltHotkeys(); + QVector getImplicitAndAltHotkeys(); + + +public slots: + void newDoc(); + void open(); + void save(); + void saveAs(); + void saveHtml(); + void close(); + void closeAll(); + void exportDoc(); + void print(); + void undo(); + void redo(); + void cut(); + void copy(); + void paste(); + void selectAll(); + void find(); + void findNext(); + void tool(); + + +signals: + +public slots: +public: + QMenuBar* menubar; + QMainWindow *window; + DynaKeyboard *dynaKeyboard; + QVector< QAction *> actionList; + QVector< QAction*> actionMenuList; + + bool ctrl; + bool shift; + bool alt; +}; + +#endif // SHEET_H diff --git a/WidgetKeyboard/example/UseKeyBoardDialog.cpp b/WidgetKeyboard/example/UseKeyBoardDialog.cpp new file mode 100644 index 0000000..06617c0 --- /dev/null +++ b/WidgetKeyboard/example/UseKeyBoardDialog.cpp @@ -0,0 +1,43 @@ +/* + * Copyright 2009 EMBITEL (http://www.embitel.com) + * + * This file is part of Virtual Keyboard Project. + * + * Virtual Keyboard 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 + * + * Virtual Keyboard 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 Virtual Keyboard. If not, see . + * The supplied test sound file is properitery of Windows XP Balloon.wav © 2009 Microsoft Corporation. All rights reserved. + */ + +#include "UseKeyBoardDialog.h" +#include "WidgetKeyboard.h" + +UseKeyBoardDialog::UseKeyBoardDialog(QWidget *parent) : QDialog(parent) +{ + setupUi(this); + virtualKeyBoard = new WidgetKeyboard(this); + virtualKeyBoard->setSoundEnabled("Windows XP Balloon.wav"); +} + +UseKeyBoardDialog::~UseKeyBoardDialog() +{} + +void UseKeyBoardDialog::on_btnShow_clicked() +{ + virtualKeyBoard->show(); + this->lineEdit_2->setFocus(); +} + +void UseKeyBoardDialog::on_btnHide_clicked() +{ + virtualKeyBoard->hide(); + virtualKeyBoard->setSoundDisabled(); +} diff --git a/WidgetKeyboard/example/UseKeyBoardDialog.h b/WidgetKeyboard/example/UseKeyBoardDialog.h new file mode 100644 index 0000000..d2f5917 --- /dev/null +++ b/WidgetKeyboard/example/UseKeyBoardDialog.h @@ -0,0 +1,41 @@ +/* + * Copyright 2009 EMBITEL (http://www.embitel.com) + * + * This file is part of Virtual Keyboard Project. + * + * Virtual Keyboard 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 + * + * Virtual Keyboard 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 Virtual Keyboard. If not, see . + */ + +#ifndef __USEKEYBOARDDIALOG_H_ +#define __USEKEYBOARDDIALOG_H_ + +#include +#include "ui_UseKeyBoardDialog.h" +class WidgetKeyboard; + +class UseKeyBoardDialog : public QDialog , public Ui::UseKeyBoardDialog +{ + Q_OBJECT + + public: + UseKeyBoardDialog(QWidget *parent = 0); + ~UseKeyBoardDialog(); + + private: + WidgetKeyboard *virtualKeyBoard; + + private slots: + void on_btnShow_clicked(); + void on_btnHide_clicked(); +}; +#endif /*__USEKEYBOARDDIALOG_H_*/ diff --git a/WidgetKeyboard/example/UseKeyBoardDialog.ui b/WidgetKeyboard/example/UseKeyBoardDialog.ui new file mode 100644 index 0000000..6bb797a --- /dev/null +++ b/WidgetKeyboard/example/UseKeyBoardDialog.ui @@ -0,0 +1,87 @@ + + + UseKeyBoardDialog + + + + 0 + 0 + 417 + 269 + + + + Using Virtual Keyboard + + + + + + + + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Open VK + + + + + + + Hide VK + + + + + + + + + + + + + diff --git a/WidgetKeyboard/example/example.pro b/WidgetKeyboard/example/example.pro new file mode 100644 index 0000000..818408c --- /dev/null +++ b/WidgetKeyboard/example/example.pro @@ -0,0 +1,21 @@ +TEMPLATE = app +INCLUDEPATH += . + +include(../src/WidgetKeyboard.pri) + +# Input + +TARGET = UseKeyBoardDialog +HEADERS += UseKeyBoardDialog.h \ + DynaKeyboardVisual.h \ + Sheet.h \ + DynaKeyboard.h \ + DynaKeyboardHaptic.h + +FORMS += UseKeyBoardDialog.ui +SOURCES += Main.cpp \ + UseKeyBoardDialog.cpp \ + DynaKeyboardVisual.cpp \ + Sheet.cpp \ + DynaKeyboard.cpp \ + DynaKeyboardHaptic.cpp diff --git a/WidgetKeyboard/grey.png b/WidgetKeyboard/grey.png new file mode 100644 index 0000000..b99402d Binary files /dev/null and b/WidgetKeyboard/grey.png differ diff --git a/WidgetKeyboard/ressource.qrc b/WidgetKeyboard/ressource.qrc new file mode 100644 index 0000000..920c48c --- /dev/null +++ b/WidgetKeyboard/ressource.qrc @@ -0,0 +1,6 @@ + + + grey.png + blue.png + + diff --git a/WidgetKeyboard/src/WidgetKeyboard.cpp b/WidgetKeyboard/src/WidgetKeyboard.cpp new file mode 100644 index 0000000..93ccdae --- /dev/null +++ b/WidgetKeyboard/src/WidgetKeyboard.cpp @@ -0,0 +1,413 @@ +/* + * Copyright 2009 EMBITEL (http://www.embitel.com) + * + * This file is part of Virtual Keyboard Project. + * + * Virtual Keyboard 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 + * + * Virtual Keyboard 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 Virtual Keyboard. If not, see . + */ + +#include "WidgetKeyboard.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +WidgetKeyboard::WidgetKeyboard(QWidget *parent) : QWidget(0) +{ + setupUi(this); + resize(0,0); + this->setWindowFlags(Qt::Tool); + m_pParent = parent; + isCaps = false; + isShift = false; + isCtrl = false; + isAlt = false; + isIns = false; + changeTextCaps(false); + signalMapper = new QSignalMapper(this); + sliderOpacity->setRange(20,100); + allButtons = findChildren(); + for (int i=0;isetMapping(allButtons.at(i), i); + } + connect(signalMapper, SIGNAL(mapped(int)), this, SLOT(on_btn_clicked(int))); +} + +WidgetKeyboard::~WidgetKeyboard() +{ + delete signalMapper; +} + +void WidgetKeyboard::raiseKeys(const QMap &keyState) +{ + for(int i=0; iaccessibleName(); + bool isOk; + int keyId = strKeyId.toInt(&isOk, 16); + bool find = keyState.contains(keyId); + + bool raised = keyState.value(keyId); + //if(find) qDebug()<<" strKeyId=" << strKeyId << " keyId="<setIcon(icon); + button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); + }else{ + //QIcon icon(":grey.png"); + //button->setIcon(icon); + button->setToolButtonStyle(Qt::ToolButtonTextOnly); + } + //button->setVisible(raised); + //button->setDisabled(!raised); + + } + +} + +void WidgetKeyboard::on_btn_clicked(int btn) +{ + if(! soundFilePath.isEmpty()) + QSound::play(soundFilePath); + QString strKeyId; + strKeyId = allButtons.at(btn)->accessibleName(); + bool isOk; + int keyId = strKeyId.toInt(&isOk, 16); + if (strKeyId.isEmpty() || !isOk) { + QMessageBox::information(0,0,"Key Not Found"); + return; + } + + //Keys to be handled separately + if (keyId==Qt::Key_Shift + || keyId==Qt::Key_Control + || keyId==Qt::Key_Alt + || keyId==Qt::Key_Print + ) + return; + + int involvedKeys = 1; + Qt::KeyboardModifiers Modifier = Qt::NoModifier; + if (isCtrl) { + Modifier = Modifier | Qt::ControlModifier; + involvedKeys++; + } + if (isShift) { + Modifier = Modifier | Qt::ShiftModifier; + involvedKeys++; + } + if (isAlt) { + Modifier = Modifier | Qt::AltModifier; + involvedKeys++; + } + + bool isTextKey = false; + + if(keyId==Qt::Key_Insert && !isShift) + return; + + + QString ch = allButtons.at(btn)->text().trimmed(); + if (ch=="&&") + ch="&"; + else if (keyId==Qt::Key_Space) + ch = " "; + else if (checkNotTextKey(keyId)) + ch = QString(); + else + isTextKey = true; + + + if(isIns && isTextKey) { + QKeyEvent keyEventIns(QEvent::KeyPress, Qt::Key_Delete, Qt::NoModifier); + QApplication::sendEvent(m_pParent->focusWidget(), &keyEventIns); + } + + QKeyEvent keyEvent(QEvent::KeyPress, keyId, Modifier, ch, false, involvedKeys); + if(m_pParent) + QApplication::sendEvent(m_pParent->focusWidget(), &keyEvent); + + + btnShiftLeft->setChecked(false); + btnShiftRight->setChecked(false); + btnCtrlLeft->setChecked(false); + btnAltLeft->setChecked(false); +} + +void WidgetKeyboard::on_btnCaps_toggled(bool checked) +{ + changeTextCaps(checked); + isCaps = checked; +} + +void WidgetKeyboard::on_btnShiftLeft_toggled(bool checked) +{ + isShift = checked; + if (isCaps) { + changeTextShift(checked); + } + else { + changeTextShift(checked); + changeTextCaps(checked); + } +} + +void WidgetKeyboard::on_btnShiftRight_toggled(bool checked) +{ + on_btnShiftLeft_toggled(checked); +} + +void WidgetKeyboard::on_btnCtrlLeft_toggled(bool checked) +{ + isCtrl = checked; +} + +void WidgetKeyboard::on_btnAltLeft_toggled(bool checked) +{ + isAlt = checked; +} + +void WidgetKeyboard::on_btnIns_clicked() +{ + isIns = !isIns; +} + +void WidgetKeyboard::on_btnPrint_clicked() +{ + QPixmap screen = QPixmap::grabWindow(QApplication::desktop()->winId()); + QClipboard *cb = QApplication::clipboard(); + cb->setPixmap(screen, QClipboard::Clipboard); +} + +void WidgetKeyboard::on_sliderOpacity_valueChanged(int val) +{ + opacity = 120.0 - val; + opacity /= 100.0; + setWindowOpacity(opacity); +} + +void WidgetKeyboard::changeTextShift(bool isShift) +{ + changeTextCaps(!isShift); + if (isShift) { + btnTilt->setText(QChar('~')); + btn1->setText(QChar('!')); + btn2->setText(QChar('@')); + btn3->setText(QChar('#')); + btn4->setText(QChar('$')); + btn5->setText(QChar('%')); + btn6->setText(QChar('^')); + btn7->setText("&&"); + btn8->setText(QChar('*')); + btn9->setText(QChar('(')); + btn0->setText(QChar(')')); + btnHiphen->setText(QChar('_')); + btnAssign->setText(QChar('+')); + + btnStartSquare->setText(QChar('{')); + btnCloseSquare->setText(QChar('}')); + btnFwdSlash->setText(QChar('|')); + + btnSemiColon->setText(QChar(':')); + btnSp->setText(QChar('"')); + + btnComma->setText(QChar('<')); + btnPeriod->setText(QChar('>')); + btnBcwdSlash->setText(QChar('?')); + } + else { + btnTilt->setText(QChar('`')); + btn1->setText(QChar('1')); + btn2->setText(QChar('2')); + btn3->setText(QChar('3')); + btn4->setText(QChar('4')); + btn5->setText(QChar('5')); + btn6->setText(QChar('6')); + btn7->setText(QChar('7')); + btn8->setText(QChar('8')); + btn9->setText(QChar('9')); + btn0->setText(QChar('0')); + btnHiphen->setText(QChar('-')); + btnAssign->setText(QChar('=')); + + btnStartSquare->setText(QChar('[')); + btnCloseSquare->setText(QChar(']')); + btnFwdSlash->setText(QChar('\\')); + + btnSemiColon->setText(QChar(';')); + btnSp->setText(QChar('\'')); + + btnComma->setText(QChar(',')); + btnPeriod->setText(QChar('.')); + btnBcwdSlash->setText(QChar('/')); + } +} + +void WidgetKeyboard::changeTextCaps(bool isCaps) +{ + if (isCaps) { + btnQ->setText(QChar('Q')); + btnW->setText(QChar('W')); + btnE->setText(QChar('E')); + btnR->setText(QChar('R')); + btnT->setText(QChar('T')); + btnY->setText(QChar('Y')); + btnU->setText(QChar('U')); + btnI->setText(QChar('I')); + btnO->setText(QChar('O')); + btnP->setText(QChar('P')); + + btnA->setText(QChar('A')); + btnS->setText(QChar('S')); + btnD->setText(QChar('D')); + btnF->setText(QChar('F')); + btnG->setText(QChar('G')); + btnH->setText(QChar('H')); + btnJ->setText(QChar('J')); + btnK->setText(QChar('K')); + btnL->setText(QChar('L')); + + btnZ->setText(QChar('Z')); + btnX->setText(QChar('X')); + btnC->setText(QChar('C')); + btnV->setText(QChar('V')); + btnB->setText(QChar('B')); + btnN->setText(QChar('N')); + btnM->setText(QChar('M')); + } + else { + btnQ->setText(QChar('q')); + btnW->setText(QChar('w')); + btnE->setText(QChar('e')); + btnR->setText(QChar('r')); + btnT->setText(QChar('t')); + btnY->setText(QChar('y')); + btnU->setText(QChar('u')); + btnI->setText(QChar('i')); + btnO->setText(QChar('o')); + btnP->setText(QChar('p')); + + btnA->setText(QChar('a')); + btnS->setText(QChar('s')); + btnD->setText(QChar('d')); + btnF->setText(QChar('f')); + btnG->setText(QChar('g')); + btnH->setText(QChar('h')); + btnJ->setText(QChar('j')); + btnK->setText(QChar('k')); + btnL->setText(QChar('l')); + + btnZ->setText(QChar('z')); + btnX->setText(QChar('x')); + btnC->setText(QChar('c')); + btnV->setText(QChar('v')); + btnB->setText(QChar('b')); + btnN->setText(QChar('n')); + btnM->setText(QChar('m')); + } +} + +bool WidgetKeyboard::checkNotTextKey(int keyId) +{ + if (keyId==Qt::Key_Shift + || keyId==Qt::Key_Control + || keyId==Qt::Key_Tab + || keyId==Qt::Key_Escape + || keyId==Qt::Key_Return + || keyId==Qt::Key_Insert + || keyId==Qt::Key_NumLock + || keyId==Qt::Key_F1 + || keyId==Qt::Key_F2 + || keyId==Qt::Key_F3 + || keyId==Qt::Key_F4 + || keyId==Qt::Key_F5 + || keyId==Qt::Key_F6 + || keyId==Qt::Key_F7 + || keyId==Qt::Key_F8 + || keyId==Qt::Key_F9 + || keyId==Qt::Key_F10 + || keyId==Qt::Key_F11 + || keyId==Qt::Key_F12 + || keyId==Qt::Key_Print + || keyId==Qt::Key_Pause + || keyId==Qt::Key_ScrollLock + || keyId==Qt::Key_Enter + || keyId==Qt::Key_Home + || keyId==Qt::Key_End + || keyId==Qt::Key_CapsLock + || keyId==Qt::Key_Insert + || keyId==Qt::Key_Delete + || keyId==Qt::Key_PageUp + || keyId==Qt::Key_PageDown + || keyId==Qt::Key_Down + || keyId==Qt::Key_Up + || keyId==Qt::Key_Left + || keyId==Qt::Key_Right + || keyId==Qt::Key_Alt) { + return true; + } + else + return false; +} + +void WidgetKeyboard::setOpacity(int opacity) +{ + sliderOpacity->setValue(opacity); +} + +int WidgetKeyboard::getOpacity() +{ + return sliderOpacity->value(); +} + +void WidgetKeyboard::setSoundDisabled() +{ + soundFilePath = ""; +} + +/* +Microsoft Windows : The underlying multimedia system is used; only WAVE format sound files are supported. +X11 : The Network Audio System is used if available, otherwise all operations work silently. NAS supports WAVE and AU files. +Mac OS X : NSSound is used. All formats that NSSound supports, including QuickTime formats, are supported by Qt for Mac OS X. +Qt for Embedded Linux : A built-in mixing sound server is used, accessing /dev/dsp directly. Only the WAVE format is supported. +*/ + +void WidgetKeyboard::setSoundEnabled(QString soundPath) +{ + soundFilePath = soundPath; +} + +void WidgetKeyboard::on_checkBoxShowNumPad_stateChanged(int state) +{ + QList children = frameNumPad->findChildren(); + if(state==Qt::Checked) + { + frameNumPad->show(); + /*for each(QWidget *child in children) + child->show();*/ + } + else + { + frameNumPad->hide(); + /*for each(QWidget *child in children) + child->hide();*/ + } + update(); +} diff --git a/WidgetKeyboard/src/WidgetKeyboard.h b/WidgetKeyboard/src/WidgetKeyboard.h new file mode 100644 index 0000000..02c3611 --- /dev/null +++ b/WidgetKeyboard/src/WidgetKeyboard.h @@ -0,0 +1,69 @@ +/* + * Copyright 2009 EMBITEL (http://www.embitel.com) + * + * This file is part of Virtual Keyboard Project. + * + * Virtual Keyboard 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 + * + * Virtual Keyboard 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 Virtual Keyboard. If not, see . + */ + +#ifndef __WIDGETKEYBOARD_H_ +#define __WIDGETKEYBOARD_H_ + +#include +#include "ui_WidgetKeyboard.h" +class QSignalMapper; + +class WidgetKeyboard : public QWidget, public Ui::WidgetKeyboard +{ + Q_OBJECT + + private: + QWidget *m_pParent; + qreal opacity; + bool isCaps; + bool isShift; + bool isCtrl; + bool isAlt; + bool isIns; + QSignalMapper *signalMapper; + QList allButtons; + QString soundFilePath; + + private slots: + void on_btn_clicked(int btn); + void on_btnCaps_toggled(bool checked); + void on_btnShiftLeft_toggled(bool checked); + void on_btnShiftRight_toggled(bool checked); + void on_btnCtrlLeft_toggled(bool checked); + void on_btnAltLeft_toggled(bool checked); + void on_btnIns_clicked(); + void on_btnPrint_clicked(); + void on_sliderOpacity_valueChanged(int); + void changeTextShift(bool isShift); + void changeTextCaps(bool isCaps); + bool checkNotTextKey(int keyId); + void on_checkBoxShowNumPad_stateChanged(int state); + + public slots: + void raiseKeys(const QMap &keyState); + + + public: + WidgetKeyboard(QWidget *parent = NULL); + ~WidgetKeyboard(); + void setOpacity(int); + int getOpacity(); + void setSoundDisabled(); + void setSoundEnabled(QString soundPath); +}; +#endif /*__WIDGETKEYBOARD_H_*/ diff --git a/WidgetKeyboard/src/WidgetKeyboard.pri b/WidgetKeyboard/src/WidgetKeyboard.pri new file mode 100644 index 0000000..de6cb19 --- /dev/null +++ b/WidgetKeyboard/src/WidgetKeyboard.pri @@ -0,0 +1,18 @@ +include(../common.pri) +INCLUDEPATH += $$PWD +DEPENDPATH += $$PWD + +WidgetKeyboard-uselib:!WidgetKeyboard-buildlib { + LIBS += -L$$WIDGETKEYBOARD_LIBDIR -l$$WIDGETKEYBOARD_LIBNAME +} else { + SOURCES += $$PWD/WidgetKeyboard.cpp + HEADERS += $$PWD/WidgetKeyboard.h + FORMS += $$PWD/WidgetKeyboard.ui + RESOURCES += $$PWD/WidgetKeyboard.qrc +} + +win32 { + contains(TEMPLATE, lib):contains(CONFIG, shared):DEFINES += WIDGETKEYBOARD_EXPORT + else:WidgetKeyboard-uselib:DEFINES += WIDGETKEYBOARD_IMPORT +} + diff --git a/WidgetKeyboard/src/WidgetKeyboard.qrc b/WidgetKeyboard/src/WidgetKeyboard.qrc new file mode 100644 index 0000000..0e66fd3 --- /dev/null +++ b/WidgetKeyboard/src/WidgetKeyboard.qrc @@ -0,0 +1,8 @@ + + + res/down.JPG + res/left.JPG + res/right.JPG + res/up.JPG + + diff --git a/WidgetKeyboard/src/WidgetKeyboard.ui b/WidgetKeyboard/src/WidgetKeyboard.ui new file mode 100644 index 0000000..c9311dd --- /dev/null +++ b/WidgetKeyboard/src/WidgetKeyboard.ui @@ -0,0 +1,2654 @@ + + + WidgetKeyboard + + + + 0 + 0 + 780 + 197 + + + + Virtual Keyboard + + + + 2 + + + 2 + + + + + + + 2 + + + + + + 0 + 0 + + + + + 12 + + + + 0x01000000 + + + + + + Esc + + + true + + + + + + + Qt::Horizontal + + + + 50 + 22 + + + + + + + + 2 + + + + + + 0 + 0 + + + + + 12 + + + + 0x01000030 + + + F1 + + + true + + + + + + + + 0 + 0 + + + + + 12 + + + + 0x01000031 + + + F2 + + + true + + + + + + + + 0 + 0 + + + + + 12 + + + + 0x01000032 + + + F3 + + + true + + + + + + + + 0 + 0 + + + + + 12 + + + + 0x01000033 + + + F4 + + + true + + + + + + + + + Qt::Horizontal + + + + 50 + 16 + + + + + + + + 2 + + + + + + 0 + 0 + + + + + 12 + + + + 0x01000034 + + + F5 + + + true + + + + + + + + 0 + 0 + + + + + 12 + + + + 0x01000035 + + + F6 + + + true + + + + + + + + 0 + 0 + + + + + 12 + + + + 0x01000036 + + + F7 + + + true + + + + + + + + 0 + 0 + + + + + 8 + + + + 0x01000037 + + + F8 + + + true + + + + + + + + + Qt::Horizontal + + + + 50 + 17 + + + + + + + + 2 + + + + + + 0 + 0 + + + + + 12 + + + + 0x01000038 + + + F9 + + + true + + + + + + + + 0 + 0 + + + + + 12 + + + + 0x01000039 + + + F10 + + + true + + + + + + + + 0 + 0 + + + + + 12 + + + + 0x0100003a + + + F11 + + + true + + + + + + + + 0 + 0 + + + + + 12 + + + + 0x0100003b + + + F12 + + + true + + + + + + + + + + + 3 + + + + + true + + + + 0 + 0 + + + + + 12 + + + + 0x01000009 + + + Print +Screen + + + true + + + + + + + false + + + + 0 + 0 + + + + + 12 + + + + 0x01000026 + + + Scroll +Lock + + + true + + + + + + + false + + + + 0 + 0 + + + + + 12 + + + + 0x01000008 + + + Pause +Break + + + true + + + + + + + + + + + 3 + + + 0 + + + + + + 0 + 0 + + + + + 12 + + + + 0x01000006 + + + Insert + + + false + + + true + + + + + + + + 0 + 0 + + + + + 12 + + + + 0x01000010 + + + Home + + + true + + + + + + + + 0 + 0 + + + + + 12 + + + + 0x01000016 + + + PgUP + + + true + + + + + + + + 0 + 0 + + + + + 12 + + + + 0x01000007 + + + Delete + + + true + + + + + + + + 0 + 0 + + + + + 12 + + + + 0x01000011 + + + End + + + true + + + + + + + + 0 + 0 + + + + + 12 + + + + 0x01000017 + + + PgDn + + + true + + + + + + + + + Show Numeric Keypad + + + true + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + 0 + 0 + + + + + 8 + + + + 0x01000013 + + + + + + + :/myresources/upIcon:/myresources/upIcon + + + true + + + + + + + + 0 + 0 + + + + + 8 + + + + 0x01000012 + + + + + + + :/myresources/leftIcon:/myresources/leftIcon + + + true + + + + + + + + 0 + 0 + + + + + 8 + + + + 0x01000015 + + + + + + + :/myresources/downIcon:/myresources/downIcon + + + true + + + + + + + + 0 + 0 + + + + + 8 + + + + 0x01000014 + + + + + + + :/myresources/rightIcon:/myresources/rightIcon + + + true + + + + + + + + + + + 3 + + + + + 0 + + + + + + 0 + 0 + + + + + 12 + + + + 0x60 + + + ` + + + true + + + + + + + + 0 + 0 + + + + + 12 + + + + 0x31 + + + 1 + + + true + + + + + + + + 0 + 0 + + + + + 12 + + + + 0x32 + + + 2 + + + true + + + + + + + + 0 + 0 + + + + + 12 + + + + 0x33 + + + 3 + + + true + + + + + + + + 0 + 0 + + + + + 12 + + + + 0x34 + + + 4 + + + true + + + + + + + + 0 + 0 + + + + + 12 + + + + 0x35 + + + 5 + + + true + + + + + + + + 0 + 0 + + + + + 12 + + + + 0x36 + + + 6 + + + true + + + + + + + + 0 + 0 + + + + + 12 + + + + 0x37 + + + 7 + + + true + + + + + + + + 0 + 0 + + + + + 12 + + + + 0x38 + + + 8 + + + true + + + + + + + + 0 + 0 + + + + + 12 + + + + 0x39 + + + 9 + + + true + + + + + + + + 0 + 0 + + + + + 12 + + + + 0x30 + + + 0 + + + true + + + + + + + + 0 + 0 + + + + + 12 + + + + 0x2d + + + - + + + true + + + + + + + + 0 + 0 + + + + + 12 + + + + 13 + + + = + + + true + + + + + + + + 0 + 0 + + + + + 12 + + + + 0x01000003 + + + Backspace + + + true + + + + + + + + + 0 + + + + + + 0 + 0 + + + + + 12 + + + + 0x01000024 + + + Caps + + + true + + + true + + + + + + + + 0 + 0 + + + + + 12 + + + + 0x41 + + + A + + + true + + + + + + + + 0 + 0 + + + + + 12 + + + + 0x53 + + + S + + + true + + + + + + + + 0 + 0 + + + + + 12 + + + + 0x44 + + + D + + + true + + + + + + + + 0 + 0 + + + + + 12 + + + + 0x46 + + + F + + + true + + + + + + + + 0 + 0 + + + + + 12 + + + + 0x47 + + + G + + + true + + + + + + + + 0 + 0 + + + + + 12 + + + + 0x48 + + + H + + + true + + + + + + + + 0 + 0 + + + + + 12 + + + + 0x4a + + + J + + + true + + + + + + + + 0 + 0 + + + + + 12 + + + + 0x4b + + + K + + + true + + + + + + + + 0 + 0 + + + + + 12 + + + + 0x4c + + + L + + + true + + + + + + + + 0 + 0 + + + + + 12 + + + + 0x3b + + + ; + + + true + + + + + + + + 0 + 0 + + + + + 12 + + + + 0x27 + + + ' + + + true + + + + + + + + 0 + 0 + + + + + 12 + + + + 0x01000004 + + + Return + + + true + + + + + + + + + 0 + + + + + + 0 + 0 + + + + + 12 + + + + 0x01000020 + + + Shift + + + true + + + true + + + + + + + + 0 + 0 + + + + + 12 + + + + 0x5a + + + Z + + + true + + + + + + + + 0 + 0 + + + + + 12 + + + + 0x58 + + + X + + + true + + + + + + + + 0 + 0 + + + + + 12 + + + + 0x43 + + + C + + + true + + + + + + + + 0 + 0 + + + + + 12 + + + + 0x56 + + + V + + + true + + + + + + + + 0 + 0 + + + + + 12 + + + + 0x42 + + + B + + + true + + + + + + + + 0 + 0 + + + + + 12 + + + + 0x4e + + + N + + + true + + + + + + + + 0 + 0 + + + + + 12 + + + + 0x4d + + + M + + + true + + + + + + + + 0 + 0 + + + + + 12 + + + + 0x2c + + + , + + + true + + + + + + + + 0 + 0 + + + + + 12 + + + + 0x2e + + + . + + + true + + + + + + + + 0 + 0 + + + + + 12 + + + + 0x2f + + + / + + + true + + + + + + + + 0 + 0 + + + + + 12 + + + + 0x01000020 + + + Shift + + + true + + + true + + + + + + + + + 0 + + + + + + 0 + 0 + + + + + 12 + + + + 0x01000021 + + + Ctrl + + + true + + + true + + + + + + + + 0 + 0 + + + + + 12 + + + + 0x01000023 + + + Alt + + + true + + + true + + + + + + + + 0 + 0 + + + + + 8 + + + + 0x20 + + + + + + true + + + + + + + + 0 + 0 + + + + Transparency + + + Qt::Horizontal + + + + + + + + + 0 + + + + + + 0 + 0 + + + + + 12 + + + + 0x01000001 + + + Tab + + + true + + + + + + + + 0 + 0 + + + + + 12 + + + + 0x51 + + + Q + + + true + + + + + + + + 0 + 0 + + + + + 12 + + + + 0x57 + + + W + + + true + + + + + + + + 0 + 0 + + + + + 12 + + + + 0x45 + + + E + + + true + + + + + + + + 0 + 0 + + + + + 12 + + + + 0x52 + + + R + + + true + + + + + + + + 0 + 0 + + + + + 12 + + + + 0x54 + + + T + + + true + + + + + + + + 0 + 0 + + + + + 12 + + + + 0x59 + + + Y + + + true + + + + + + + + 0 + 0 + + + + + 12 + + + + 0x55 + + + U + + + true + + + + + + + + 0 + 0 + + + + + 12 + + + + 0x49 + + + I + + + true + + + + + + + + 0 + 0 + + + + + 12 + + + + 0x4f + + + O + + + true + + + + + + + + 0 + 0 + + + + + 12 + + + + 0x50 + + + P + + + true + + + + + + + + 0 + 0 + + + + + 12 + + + + 0x5b + + + [ + + + true + + + + + + + + 0 + 0 + + + + + 12 + + + + 0x5d + + + ] + + + true + + + + + + + + 0 + 0 + + + + + 12 + + + + 0x5c + + + \ + + + true + + + + + + + + + + + QFrame::NoFrame + + + 1 + + + + 3 + + + 0 + + + + + + 0 + 0 + + + + + 12 + + + + 0x2f + + + / + + + true + + + + + + + + 0 + 0 + + + + + 12 + + + + 0x2a + + + * + + + true + + + + + + + + 0 + 0 + + + + + 12 + + + + 0x2d + + + - + + + true + + + + + + + + 0 + 0 + + + + + 12 + + + + 0x37 + + + 7 + + + true + + + + + + + + 0 + 0 + + + + + 12 + + + + 0x38 + + + 8 + + + true + + + + + + + + 0 + 0 + + + + + 12 + + + + 0x39 + + + 9 + + + true + + + + + + + + 0 + 0 + + + + + 12 + + + + 0x34 + + + 4 + + + true + + + + + + + + 0 + 0 + + + + + 12 + + + + 0x35 + + + 5 + + + true + + + + + + + + 0 + 0 + + + + + 12 + + + + 0x36 + + + 6 + + + true + + + + + + + + 0 + 0 + + + + + 12 + + + + 0x2b + + + + + + + true + + + + + + + + 0 + 0 + + + + + 12 + + + + 0x31 + + + 1 + + + true + + + + + + + + 0 + 0 + + + + + 12 + + + + 0x32 + + + 2 + + + true + + + + + + + + 0 + 0 + + + + + 12 + + + + 0x33 + + + 3 + + + true + + + + + + + + 0 + 0 + + + + + 12 + + + + 0x30 + + + 0 + + + true + + + + + + + + 0 + 0 + + + + + 12 + + + + 0x2e + + + . + + + true + + + + + + + + 0 + 0 + + + + + 12 + + + + 0x01000005 + + + Enter + + + true + + + + + + + false + + + + 0 + 0 + + + + + 12 + + + + 0x01000025 + + + Num +Lock + + + true + + + + + + + + + + + + + + + + diff --git a/WidgetKeyboard/src/res/down.JPG b/WidgetKeyboard/src/res/down.JPG new file mode 100644 index 0000000..33812e7 Binary files /dev/null and b/WidgetKeyboard/src/res/down.JPG differ diff --git a/WidgetKeyboard/src/res/left.JPG b/WidgetKeyboard/src/res/left.JPG new file mode 100644 index 0000000..261591e Binary files /dev/null and b/WidgetKeyboard/src/res/left.JPG differ diff --git a/WidgetKeyboard/src/res/right.JPG b/WidgetKeyboard/src/res/right.JPG new file mode 100644 index 0000000..92e1214 Binary files /dev/null and b/WidgetKeyboard/src/res/right.JPG differ diff --git a/WidgetKeyboard/src/res/up.JPG b/WidgetKeyboard/src/res/up.JPG new file mode 100644 index 0000000..cba102a Binary files /dev/null and b/WidgetKeyboard/src/res/up.JPG differ