QT5.8. custom Virtual keyboard including - qt

I'm writing a custom virtual keyboard, which based on QtVirtualKeyboard. For my project I would need to be able to use my version of keyboard.
But the only method, which i found is recompile project and replace original "qtvirtualkeyboardplugin.dll" in "mingw53_32\plugins\platforminputcontexts" on my version of "qtvirtualkeyboardplugin.dll". And use the qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard")); function in main.cpp
After hours of reading the docs and trying various things I'm still cannot find method to use custom keyboard localy, without deleting original "qtvirtualkeyboardplugin.dll".

I'm assuming that you've forked the code, in which case the following modifications seem to be enough to get a differently named plugin to be installed to plugins/platforminputcontexts:
Rename qtvirtualkeyboard/src/virtualkeyboard/qtvirtualkeyboard.json to qtvirtualkeyboard/src/virtualkeyboard/customvirtualkeyboard.json.
In customvirtualkeyboard.json, rename the qtvirtualkeyboard key to customvirtualkeyboard.
In qtvirtualkeyboard/src/virtualkeyboard/plugin.cpp, change the contents of the pluginName string to customvirtualkeyboard.
In qtvirtualkeyboard/src/virtualkeyboard/plugin.h, change the FILE string to customvirtualkeyboard.
In src/virtualkeyboard/virtualkeyboard.pro, change TARGET = qtvirtualkeyboardplugin to TARGET = customvirtualkeyboardplugin. This affects the name of the installed .dll, .lib, etc. that you see in plugins/platforminputcontexts.
Here are the changes as a Git diff:
diff --git a/src/virtualkeyboard/customvirtualkeyboard.json b/src/virtualkeyboard/customvirtualkeyboard.json
new file mode 100644
index 0000000..9ef7a87
--- /dev/null
+++ b/src/virtualkeyboard/customvirtualkeyboard.json
## -0,0 +1,3 ##
+{
+ "Keys": [ "customvirtualkeyboard" ]
+}
diff --git a/src/virtualkeyboard/plugin.cpp b/src/virtualkeyboard/plugin.cpp
index 73ddeab..4abe9a4 100644
--- a/src/virtualkeyboard/plugin.cpp
+++ b/src/virtualkeyboard/plugin.cpp
## -76,7 +76,7 ## using namespace QtVirtualKeyboard;
Q_LOGGING_CATEGORY(qlcVirtualKeyboard, "qt.virtualkeyboard")
-static const char pluginName[] = "qtvirtualkeyboard";
+static const char pluginName[] = "customvirtualkeyboard";
static const char inputMethodEnvVarName[] = "QT_IM_MODULE";
static const char pluginUri[] = "QtQuick.VirtualKeyboard";
static const char pluginSettingsUri[] = "QtQuick.VirtualKeyboard.Settings";
diff --git a/src/virtualkeyboard/plugin.h b/src/virtualkeyboard/plugin.h
index 08074d1..19593a4 100644
--- a/src/virtualkeyboard/plugin.h
+++ b/src/virtualkeyboard/plugin.h
## -38,7 +38,7 ##
class QVirtualKeyboardPlugin : public QPlatformInputContextPlugin
{
Q_OBJECT
- Q_PLUGIN_METADATA(IID QPlatformInputContextFactoryInterface_iid FILE "qtvirtualkeyboard.json")
+ Q_PLUGIN_METADATA(IID QPlatformInputContextFactoryInterface_iid FILE "customvirtualkeyboard.json")
public:
QStringList keys() const;
diff --git a/src/virtualkeyboard/qtvirtualkeyboard.json b/src/virtualkeyboard/qtvirtualkeyboard.json
deleted file mode 100644
index 76d1706..0000000
--- a/src/virtualkeyboard/qtvirtualkeyboard.json
+++ /dev/null
## -1,3 +0,0 ##
-{
- "Keys": [ "qtvirtualkeyboard" ]
-}
diff --git a/src/virtualkeyboard/virtualkeyboard.pro b/src/virtualkeyboard/virtualkeyboard.pro
index 4f3ca69..e9b0ff9 100644
--- a/src/virtualkeyboard/virtualkeyboard.pro
+++ b/src/virtualkeyboard/virtualkeyboard.pro
## -1,4 +1,4 ##
-TARGET = qtvirtualkeyboardplugin
+TARGET = customvirtualkeyboardplugin
DATAPATH = $$[QT_INSTALL_DATA]/qtvirtualkeyboard
QMAKE_DOCS = $$PWD/doc/qtvirtualkeyboard.qdocconf
Remember that if you're using an open source license, you have to make modifications to Qt code available to users of your application.

Related

Qt Plugin Loading fails (specified module could not be found)

For some reason I am unable to load my plugins anymore, although it has worked previously. I have a plugin loader code in my MainWindow, which is supposed to load every .dll found in a specific folder. The MainWindow Code contains the following:
Interface
#ifndef PLUGININTERFACE_H
#define PLUGININTERFACE_H
#include <QtPlugin>
// forward declarations
class MainWindow;
struct P3DData;
class PluginInterface
{
public:
virtual bool createPublisher(MainWindow*, P3DData*) = 0;
};
#define PLUGIN_INTERFACE_iid "PluginInterface"
Q_DECLARE_INTERFACE(PluginInterface, PLUGIN_INTERFACE_iid)
#endif // PLUGININTERFACE_H
loadPlugins()
bool MainWindow::loadPlugins()
{
QDir pluginsDir(qApp->applicationDirPath());
pluginsDir.cd("plugins");
const auto entryList = pluginsDir.entryList(QDir::Files);
for(const QString &fileName : entryList)
{
QString dllPath = pluginsDir.absoluteFilePath(fileName);
QPluginLoader* loader = new QPluginLoader(dllPath);
loaderList.push_back(loader);
QObject *plugin = loader->instance();
if (plugin)
{
pluginList.push_back(qobject_cast<PluginInterface *>(plugin));
pluginList.last()->createPublisher(this, simDataPtr);
pluginCount++;
continue;
}
else
{
qDebug() << "[PluginLoader] '" + fileName + "': " + loader->errorString();
delete loaderList.takeLast();
}
}
}
Besides my MainWindow, there is another subdir in my project, which is the plugin "Position". The plugin is deployed into the correct "plugins" folder, which the loadPlugin() method from the MainWindow iterates through. The plugin uses following code to implement the interface:
#include <QObject>
#include "MainWindow.h"
class PositionPublisher : public QObject, PluginInterface
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "PluginInterface")
Q_INTERFACES(PluginInterface)
public:
PositionPublisher();
~PositionPublisher();
bool createPublisher(MainWindow* _window, P3DData* _simDataPtr) override;
//...
};
When trying to run loadPlugins() now, it checks the correct Position.dll file but the "if(plugin)" part returns false and loader->errorString() is executed giving the following error:
[PluginLoader] 'Position.dll': Cannot load library
F:\DEV\build\simNET\bin\plugins\Position.dll: Cannot find the
specified module.
I have already checked and tried the following:
the Plugins folder actually contains the Position.dll file
both projects (MainWindow and Plugin) are built in release mode
the dependencies of the plugin (two libs) exist and the specified path in the pro file is correct
.pro file of plugin:
QT += widgets
TEMPLATE = lib
CONFIG += c++11
CONFIG += plugin
CONFIG += release
SOURCES += \
Position.cpp \
PositionPubSubTypes.cpp \
PositionPublisher.cpp
HEADERS += \
Position.h \
PositionPubSubTypes.h \
PositionPublisher.h
DISTFILES += \
Position.idl
INCLUDEPATH += ../../application
TARGET = $$qtLibraryTarget(Position)
DESTDIR = ../../bin/plugins
INCLUDEPATH += "F:/DEV/prog/FastRTPSv1.5/include"
DEPENDPATH += "F:/DEV/prog/FastRTPSv1.5/include"
LIBS += -L"F:/DEV/prog/FastRTPSv1.5/lib/x64Win64VS2015" -lfastrtps-1.5
PRE_TARGETDEPS += F:/DEV/prog/FastRTPSv1.5/lib/x64Win64VS2015/fastrtps-1.5.lib
INCLUDEPATH += 'F:/Programme/Prepar3D v4/SDK/inc/SimConnect'
DEPENDPATH += 'F:/Programme/Prepar3D v4/SDK/inc/SimConnect'
LIBS += -L'F:/Programme/Prepar3D v4/SDK/lib/SimConnect' -lSimConnect
PRE_TARGETDEPS += 'F:/Programme/Prepar3D v4/SDK/lib/SimConnect/SimConnect.lib'
Does anyone have an idea why it does not load the plugin??
Qt plugin loader is trying to tell you that a Qt module used in your plugin doesn't exist so first you need to check which Qt modules your plugin depends on then,
If you're trying to run the application from Qt Creator itself, and it gives you this error, then maybe the DLL file got deleted for some reason or you're trying to use the plugin with a Qt version that doesn't have its needed modules. (for example, Qt6 doesn't contain the QtSerialPort module but Qt5 did (at the time of writing this)).
If you're trying to run the application directly outside Qt Creator then you need to copy the required module's dll file into your applications root directory.

How to set hbase-site.xml in sbt classpath

I am trying to connect HBase from my sbt scala project. I need to set hbase-site.xml in the classpath. How can I do this? HBase is located in virtual machine and sbt scala project is located on my windows machine.
I suggest that you try add the following dependency settings in your build.sbt, assuming your hbase-site.xml resides under /path/to/hbase/conf/:
unmanagedJars in Compile ++= {
val baseDir = baseDirectory.value
val customDirs = ("/path/to/hbase/conf") +++ ("/path/to/hadoop/conf")
val customJars = (baseDir ** "*.jar") +++ (customDirs ** "*.jar")
customJars.classpath
}
More sbt library management info can be found here.
[UPDATE]
In addition to the reported error, custom libs in this case shouldn't be limited to *.jar. See revised settings below:
unmanagedJars in Compile ++= {
val baseDir = baseDirectory.value
val customLibs = (baseDir ** "*.jar") +++ file("/path/to/hbase/conf") +++ file("/path/to/hadoop/conf")
customLibs.classpath
}
Here's an alternative way using map:
unmanagedJars in Compile <++= baseDirectory map { base =>
val baseJars = (base ** "*.jar")
val customLibs = baseJars +++ file("/path/to/hbase/conf") +++ file("/path/to/hadoop/conf")
customLibs.classpath
}

IPython nbconvert output pdf without In[#] words

When I run below command to convert a IPython notebook to pdf, I wish to remove the leading word "In[#]" but only display the cell content.
ipython nbconvert --to=latex --post=pdf input.ipynb
Some useful information at nbconvert-example.
Just copy style_notebook.tplx to local directory and do some minor modify:
diff --git a/latex_cell_style/use_cell_style.tplx b/latex_cell_style/use_cell_style.tplx
index 72b3c24..9114157 100644
--- a/latex_cell_style/use_cell_style.tplx
+++ b/latex_cell_style/use_cell_style.tplx
## -1,5 +1,5 ##
((= This line selects the cell style. =))
-((* set cell_style = 'style_python.tplx' *))
+((* set cell_style = 'style_notebook.tplx' *))
((= This line inherits from the built in template that you want to use. =))
-((* extends 'latex_article.tplx' *))
\ No newline at end of file
+((* extends 'article.tplx' *))
diff --git a/notebook_cell_style/style_notebook.tplx b/notebook_cell_style/style_notebook.tplx
index 504cd52..7bd9f2a 100644
--- a/notebook_cell_style/style_notebook.tplx
+++ b/notebook_cell_style/style_notebook.tplx
## -1,6 +1,6 ##
((= Notebook input/output style =))
-((* extends 'latex_base.tplx' *))
+((* extends 'base.tplx' *))
% Custom packages
((* block packages *))
## -29,7 +29,7 ##
\newlength{\inputpadding}
\setlength{\inputpadding}{0.5em}
\newlength{\cellleftmargin}
- \setlength{\cellleftmargin}{0.15\linewidth}
+ \setlength{\cellleftmargin}{0\linewidth}
\newlength{\borderthickness}
\setlength{\borderthickness}{0.4pt}
\newlength{\smallerfontscale}
## -177,15 +177,5 ##
% Name: draw_prompt
% Purpose: Renders an output/input prompt for notebook style pdfs
((* macro draw_prompt(prompt, number, color, space) -*))
- \begin{minipage}{\cellleftmargin}%
- \hfill%
- {\smaller%
- \tt%
- \color{(((color)))}%
- (((prompt)))[(((number)))]:}%
- \hspace{\inputpadding}%
- \hspace{(((space)))}%
- \hspace{3pt}%
- \end{minipage}%
((*- endmacro *))
Then copy below files to your notebook directory:
style_notebook.tplx
ipython_nbconvert_config.py
use_cell_style.tplx
Run below command to generate pdf output:
ipython nbconvert test.ipynb
Output as below:

Show changes/diffs without a parent commit (first commit) with JGit

when I do a git show commit of the first commit in a repository, I see all the files along with the diffs of the files (i.e all the lines being added)
$ git show cb5d132
commit cb5d13286cf9d14782f0e10445456dfe41072f55
Author: tw2 tw2LastName <tw2>
Date: Thu Oct 23 05:15:09 2014 -0400
Initial Commit
diff --git a/README.txt b/README.txt
new file mode 100644
index 0000000..96d156e
--- /dev/null
+++ b/README.txt
## -0,0 +1 ##
+First Line in README file!
\ No newline at end of file
The jgit show doesn't seem to get similar info, How can I get similar output using JGit API? I could use DiffFormatter, but it seems to require the baseTree and commitTree, wondering how I can get the DiffFormatter to work on the first commit in the repository.
ByteArrayOutputStream os = new ByteArrayOutputStream();
DiffFormatter df = new DiffFormatter( os )
RawTextComparator cmp = RawTextComparator.DEFAULT;
df.setRepository(repository);
df.setDiffComparator(cmp);
df.setDetectRenames(true);
// wondering how to use the API if we do not have baseCommit.
List<DiffEntry> diffEntries = df.scan(??baseCommitTree??, firstCommit.getTree());
for (DiffEntry diffEntry : diffEntries) {
df.format(diffEntry);
}
System.out.println(df.toString());
Use an o.e.jgit.treewalk.EmptyTreeIterator to compare the first commit against:
AbstractTreeIterator oldTreeIter = new EmptyTreeIterator();
ObjectReader reader = repository.newObjectReader();
AbstractTreeIterator newTreeIter = new CanonicalTreeParser(null, reader, firstCommit.getTree());
List<DiffEntry> diffEntries = df.scan(oldTreeIter, newTreeIter);
...

redefine \nomencl_command in LyX

I am trying to redefine the \nomencl_command in LyX, in order to be able to use the glossaries package in stead of the obsolete nomencl.
LyX allows you to specify the Nomenclature command, which by default is set to:
makeindex -s nomencl.ist
For glossaries the command is thus changed to:
makeglossaries
However, the LyX implementation of nomencl uses the more recent .nlo as an input file, and the .nls as an output file. Whereas glossaries uses the 'older' .glo and .gls Unfortunately, the extensions cannot be specified.
I found that the preferences file only says:
\nomencl_command "makeglossaries"
but the log output says:
makeglossaries "[filename].nlo" -o [filename].nls
So my question is where is \nomencl_command defined further?
The relevant code is in src/LaTeX.cpp.
Note below that some diagnostic information is written to the latex debug flag. You can see this info on the terminal if you run LyX with lyx -dbg latex.
The following are excerpts from the file src/LaTeX.cpp from the soon-to-be-released (a matter of days) LyX 2.1.
FileName const nlofile(changeExtension(file.absFileName(), ".nlo"));
// If all nomencl entries are removed, nomencl writes an empty nlo file.
// DepTable::hasChanged() returns false in this case, since it does not
// distinguish empty files from non-existing files. This is why we need
// the extra checks here (to trigger a rerun). Cf. discussions in #8905.
// FIXME: Sort out the real problem in DepTable.
if (head.haschanged(nlofile) || (nlofile.exists() && nlofile.isFileEmpty()))
rerun |= runMakeIndexNomencl(file, ".nlo", ".nls");
FileName const glofile(changeExtension(file.absFileName(), ".glo"));
if (head.haschanged(glofile))
rerun |= runMakeIndexNomencl(file, ".glo", ".gls");
and
bool LaTeX::runMakeIndexNomencl(FileName const & file,
string const & nlo, string const & nls)
{
LYXERR(Debug::LATEX, "Running MakeIndex for nomencl.");
message(_("Running MakeIndex for nomencl."));
string tmp = lyxrc.nomencl_command + ' ';
// onlyFileName() is needed for cygwin
tmp += quoteName(onlyFileName(changeExtension(file.absFileName(), nlo)));
tmp += " -o "
+ onlyFileName(changeExtension(file.toFilesystemEncoding(), nls));
Systemcall one;
one.startscript(Systemcall::Wait, tmp, path);
return true;
}
and
// nomencl file
FileName const nls(changeExtension(file.absFileName(), ".nls"));
nls.removeFile();
// nomencl file (old version of the package)
FileName const gls(changeExtension(file.absFileName(), ".gls"));
gls.removeFile();

Resources