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)
preferencesAboutTextFull
Craig Watson 9 years ago
parent 435c559b86
commit 5b7cf175e9
  1. 44
      src/board/UBBoardController.cpp
  2. 3
      src/frameworks/UBPlatformUtils.h
  3. 7
      src/frameworks/UBPlatformUtils_linux.cpp
  4. 20
      src/frameworks/UBPlatformUtils_mac.mm
  5. 6
      src/frameworks/UBPlatformUtils_win.cpp

@ -89,15 +89,6 @@
#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)
: UBDocumentContainer(mainWindow->centralWidget())
, mMainWindow(mainWindow)
@ -172,12 +163,6 @@ void UBBoardController::init()
UBBoardController::~UBBoardController()
{
#ifdef Q_OS_LINUX
if(!onboardIsAlreadyRunning){
QProcess newProcess;
newProcess.startDetached("killall onboard");
}
#endif
delete mDisplayView;
}
@ -836,36 +821,11 @@ void UBBoardController::showKeyboard(bool show)
if(show)
UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector);
#ifdef Q_OS_LINUX
static bool isFirstTime = true;
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");
}
if(UBSettings::settings()->useSystemOnScreenKeybard->get().toBool())
UBPlatformUtils::showOSK(show);
else
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 @@
#include <QtCore>
#include <QIcon>
#include <QProcess>
class QMainWindow;
@ -205,10 +206,10 @@ public:
static QStringList availableTranslations();
static void setFrontProcess();
static void showFullScreen(QWidget * pWidget);
static void showOSK(bool show);
#ifdef Q_OS_OSX
static void SetMacLocaleByIdentifier(const QString& id);
static void showOSK();
#endif
};

@ -440,3 +440,10 @@ void UBPlatformUtils::showFullScreen(QWidget *pWidget)
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)
}
void UBPlatformUtils::showOSK()
void UBPlatformUtils::showOSK(bool show)
{
[[NSAutoreleasePool alloc] init];
// TODO: enable hiding OSK
CFDictionaryRef properties =
(CFDictionaryRef)[NSDictionary
dictionaryWithObject: @"com.apple.KeyboardViewer"
forKey: (NSString *)kTISPropertyInputSourceID];
NSArray *sources = (NSArray *)TISCreateInputSourceList(properties, false);
if (show) {
[[NSAutoreleasePool alloc] init];
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)
{
pWidget->showFullScreen();
}
void UBPlatformUtils::showOSK(bool show)
{
Q_UNUSED(show);
// No system OSK support yet
}

Loading…
Cancel
Save