Skip to content

Commit

Permalink
Sailfish: Crazy shit
Browse files Browse the repository at this point in the history
  • Loading branch information
celeron55 committed Jan 4, 2014
1 parent ba748ed commit 37ef0c4
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 4 deletions.
8 changes: 7 additions & 1 deletion src/CMakeLists.txt
Expand Up @@ -179,7 +179,7 @@ else()
set(CLIENT_PLATFORM_LIBS ${CLIENT_PLATFORM_LIBS} -lGLESv1_CM -lEGL -lwayland-client -lwayland-egl -lSDL2)

include_directories("/usr/include/qt5")
set(CLIENT_PLATFORM_LIBS ${CLIENT_PLATFORM_LIBS} -lQt5Core -lQt5DBus)
set(CLIENT_PLATFORM_LIBS ${CLIENT_PLATFORM_LIBS} -lQt5Core -lQt5DBus -lQt5Widgets)
endif()
endif()

Expand Down Expand Up @@ -435,6 +435,12 @@ endif(USE_CURL)
set(EXECUTABLE_OUTPUT_PATH "${CMAKE_SOURCE_DIR}/bin")

if(BUILD_CLIENT)
if(TARGET_SAILFISH)
set(minetest_SRCS ${minetest_SRCS} moc_sailfish_inputwindow.cpp)
add_custom_command(OUTPUT moc_sailfish_inputwindow.cpp
COMMAND moc -DSAILFISH ${CMAKE_SOURCE_DIR}/src/sailfish_inputwindow.h -o ${PROJECT_BINARY_DIR}/moc_sailfish_inputwindow.cpp
DEPENDS ${CMAKE_SOURCE_DIR}/src/sailfish_inputwindow.h COMMENT "moc")
endif()
add_executable(${PROJECT_NAME} ${minetest_SRCS})
add_dependencies(${PROJECT_NAME} GenerateVersion)
target_link_libraries(
Expand Down
16 changes: 16 additions & 0 deletions src/guiFormSpecMenu.cpp
Expand Up @@ -68,6 +68,10 @@ extern android_app *app_global;
extern JNIEnv *jnienv;
#endif

#ifdef SAILFISH
#include "sailfish_inputwindow.h"
#endif

/*
GUIFormSpecMenu
*/
Expand Down Expand Up @@ -2301,6 +2305,18 @@ bool GUIFormSpecMenu::preprocessEvent(const SEvent& event)
}
#endif

#ifdef SAILFISH
// display software keyboard when clicking edit boxes
if (event.EventType == EET_MOUSE_INPUT_EVENT
&& event.MouseInput.Event == EMIE_LMOUSE_PRESSED_DOWN) {
gui::IGUIElement *hovered =
Environment->getRootGUIElement()->getElementFromPoint(
core::position2d<s32>(event.MouseInput.X, event.MouseInput.Y));
if (hovered->getType() == irr::gui::EGUIET_EDIT_BOX)
sailfish_inputwindow_show("foo");
}
#endif

return false;
}

Expand Down
19 changes: 16 additions & 3 deletions src/main.cpp
Expand Up @@ -97,8 +97,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,

// TODO: Move elsewhere
#ifdef SAILFISH
#include <qt5/QtDBus/QtDBus>
#include <qt5/QtCore/QDebug>
#include <QtDBus/QtDBus>
#include <QtCore/QDebug>
void launch_keyboard()
{
dstream<<"launch_keyboard()"<<std::endl;
Expand Down Expand Up @@ -137,7 +137,10 @@ void launch_keyboard()
qDebug() << "showInputMethod reply: " << reply;
}
}
#endif
#include <QtWidgets/QApplication>
#include <QtWidgets/QMainWindow>
QApplication *qt_app = NULL;
#endif // SAILFISH

/*
Settings.
Expand Down Expand Up @@ -821,9 +824,11 @@ JNIEnv *jnienv;

int main(int argc, char *argv[])
{
#ifdef ANDROID
// well android lags anyway so no one will notice anything
// (this is actually needed to give GDB time to attach before everything crashes)
sleep(5);
#endif
int retval = 0;

/*
Expand Down Expand Up @@ -1524,6 +1529,13 @@ int main(int argc, char *argv[])
if (device == 0)
return 1; // could not create selected driver.

#ifdef SAILFISH
qt_app = new QApplication(argc, argv);
setlocale(LC_NUMERIC, "C");
//qt_app->exec();
qt_app->processEvents();
#endif

/*
Continue initialization
*/
Expand Down Expand Up @@ -1756,6 +1768,7 @@ int main(int argc, char *argv[])
video::SColor(255,128,128,128));
guienv->drawAll();
driver->endScene();
qt_app->processEvents();
// On some computers framerate doesn't seem to be
// automatically limited
sleep_ms(25);
Expand Down
79 changes: 79 additions & 0 deletions src/sailfish_inputwindow.h
@@ -0,0 +1,79 @@
/*
Minetest
Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/


#ifndef SAILFISH_INPUTWINDOW_HEADER
#define SAILFISH_INPUTWINDOW_HEADER

#include <QtWidgets/QApplication>
extern QApplication *qt_app;
#include <QtWidgets/QMainWindow>
#include <QtWidgets/QBoxLayout>
#include <QtWidgets/QPushButton>
#include <QtWidgets/QLineEdit>
//#include <QtWidgets/QPlainTextEdit>
#include <QtGui/QPalette>
#include <QtWidgets/QSpacerItem>
#include <QtCore/QTimer>
#include <QtCore/QProcess>

class InputWindow: public QMainWindow
{
Q_OBJECT
public:
};

inline std::string sailfish_inputwindow_show(const std::string &orig)
{
QProcess p;
p.start("jolla-fileman", QStringList());
if(!p.waitForStarted())
return orig;
p.write(orig.c_str());
p.closeWriteChannel();
if(!p.waitForFinished())
return orig;
QByteArray result = p.readAll();
return result.data();
#if 0
InputWindow *window = new InputWindow();
QBoxLayout *bl = new QBoxLayout(QBoxLayout::TopToBottom, window);
QWidget *central = new QWidget();
central->setLayout(bl);
window->setCentralWidget(central);
window->setStyleSheet("background-color: #333333; color: #ffffff");
window->show();
bl->addWidget(new QPushButton("Done"));
QLineEdit *input = new QLineEdit();
bl->addWidget(input);
bl->addSpacerItem(new QSpacerItem(500,500));
QTimer::singleShot(0, input, SLOT(setFocus()));
/*QObject::connect(input, SIGNAL(returnPressed()),
qt_app, SLOT(quit()));*/
//bl->addWidget(new QPlainTextEdit);
for(;;){
qt_app->processEvents();
usleep(1000000/60);
}
//qt_app->exec();
return "foo";
#endif
}

#endif

0 comments on commit 37ef0c4

Please sign in to comment.