Commit 5b7cf175 authored by Craig Watson's avatar Craig Watson

Clean-up of on-screen keyboard code

- Moved all platform-specific code to UBPlatformUtils
- For now, removed support (on Linux) for checking whether onboard is 
running when OpenBoard is started (it wasn't working anyway, but it needs a
cleaner solution for all 3 platforms)
parent 435c559b
...@@ -89,15 +89,6 @@ ...@@ -89,15 +89,6 @@
#include "core/memcheck.h" #include "core/memcheck.h"
#ifdef Q_OS_LINUX
#include <QProcess>
bool onboardIsAlreadyRunning = true;
#endif
#ifdef Q_OS_OSX
#include <QProcess>
#endif
UBBoardController::UBBoardController(UBMainWindow* mainWindow) UBBoardController::UBBoardController(UBMainWindow* mainWindow)
: UBDocumentContainer(mainWindow->centralWidget()) : UBDocumentContainer(mainWindow->centralWidget())
, mMainWindow(mainWindow) , mMainWindow(mainWindow)
...@@ -172,12 +163,6 @@ void UBBoardController::init() ...@@ -172,12 +163,6 @@ void UBBoardController::init()
UBBoardController::~UBBoardController() UBBoardController::~UBBoardController()
{ {
#ifdef Q_OS_LINUX
if(!onboardIsAlreadyRunning){
QProcess newProcess;
newProcess.startDetached("killall onboard");
}
#endif
delete mDisplayView; delete mDisplayView;
} }
...@@ -836,36 +821,11 @@ void UBBoardController::showKeyboard(bool show) ...@@ -836,36 +821,11 @@ void UBBoardController::showKeyboard(bool show)
if(show) if(show)
UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector); UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector);
#ifdef Q_OS_LINUX if(UBSettings::settings()->useSystemOnScreenKeybard->get().toBool())
static bool isFirstTime = true; UBPlatformUtils::showOSK(show);
if(isFirstTime){
QProcess isAlreadyRunningProcess;
QString psAuxGrepC = "ps aux";
isAlreadyRunningProcess.start(psAuxGrepC);
isAlreadyRunningProcess.waitForFinished();
QString output(isAlreadyRunningProcess.readAll());
if(output.count("onboard") != 0)
onboardIsAlreadyRunning = true;
else
onboardIsAlreadyRunning = false;
isFirstTime = false;
}
if(UBSettings::settings()->useSystemOnScreenKeybard->get().toBool()){
QProcess newProcess;
newProcess.startDetached("/usr/bin/onboard");
}
else else
mPaletteManager->showVirtualKeyboard(show); mPaletteManager->showVirtualKeyboard(show);
#elif defined(Q_OS_OSX)
if(UBSettings::settings()->useSystemOnScreenKeybard->get().toBool())
UBPlatformUtils::showOSK();
#else
mPaletteManager->showVirtualKeyboard(show);
#endif
} }
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include <QtCore> #include <QtCore>
#include <QIcon> #include <QIcon>
#include <QProcess>
class QMainWindow; class QMainWindow;
...@@ -205,10 +206,10 @@ public: ...@@ -205,10 +206,10 @@ public:
static QStringList availableTranslations(); static QStringList availableTranslations();
static void setFrontProcess(); static void setFrontProcess();
static void showFullScreen(QWidget * pWidget); static void showFullScreen(QWidget * pWidget);
static void showOSK(bool show);
#ifdef Q_OS_OSX #ifdef Q_OS_OSX
static void SetMacLocaleByIdentifier(const QString& id); static void SetMacLocaleByIdentifier(const QString& id);
static void showOSK();
#endif #endif
}; };
......
...@@ -440,3 +440,10 @@ void UBPlatformUtils::showFullScreen(QWidget *pWidget) ...@@ -440,3 +440,10 @@ void UBPlatformUtils::showFullScreen(QWidget *pWidget)
pWidget->showFullScreen(); pWidget->showFullScreen();
} }
void UBPlatformUtils::showOSK(bool show)
{
if (show) {
QProcess newProcess;
newProcess.startDetached("/usr/bin/env onboard");
}
}
...@@ -610,15 +610,19 @@ void UBPlatformUtils::showFullScreen(QWidget *pWidget) ...@@ -610,15 +610,19 @@ void UBPlatformUtils::showFullScreen(QWidget *pWidget)
} }
void UBPlatformUtils::showOSK() void UBPlatformUtils::showOSK(bool show)
{ {
[[NSAutoreleasePool alloc] init]; // TODO: enable hiding OSK
CFDictionaryRef properties = if (show) {
(CFDictionaryRef)[NSDictionary [[NSAutoreleasePool alloc] init];
dictionaryWithObject: @"com.apple.KeyboardViewer"
forKey: (NSString *)kTISPropertyInputSourceID];
NSArray *sources = (NSArray *)TISCreateInputSourceList(properties, false);
TISSelectInputSource((TISInputSourceRef)[sources objectAtIndex: 0]); CFDictionaryRef properties =
(CFDictionaryRef)[NSDictionary
dictionaryWithObject: @"com.apple.KeyboardViewer"
forKey: (NSString *)kTISPropertyInputSourceID];
NSArray *sources = (NSArray *)TISCreateInputSourceList(properties, false);
TISSelectInputSource((TISInputSourceRef)[sources objectAtIndex: 0]);
}
} }
...@@ -436,3 +436,9 @@ void UBPlatformUtils::showFullScreen(QWidget *pWidget) ...@@ -436,3 +436,9 @@ void UBPlatformUtils::showFullScreen(QWidget *pWidget)
{ {
pWidget->showFullScreen(); pWidget->showFullScreen();
} }
void UBPlatformUtils::showOSK(bool show)
{
Q_UNUSED(show);
// No system OSK support yet
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment