From 337f18fe5d032a59084a5d6516bcb0ff070128b6 Mon Sep 17 00:00:00 2001 From: tpearson Date: Wed, 19 Oct 2011 18:56:47 +0000 Subject: Add tqt3integration These files were originally taken from the GPLed OpenSUSE kdebase builds git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebase@1259731 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- tqt3integration/libqtkde/CMakeLists.txt | 33 +++++++ tqt3integration/libqtkde/Makefile.am | 15 ++++ tqt3integration/libqtkde/qtkde.cpp | 147 ++++++++++++++++++++++++++++++++ tqt3integration/libqtkde/qtkde.h | 34 ++++++++ 4 files changed, 229 insertions(+) create mode 100644 tqt3integration/libqtkde/CMakeLists.txt create mode 100644 tqt3integration/libqtkde/Makefile.am create mode 100644 tqt3integration/libqtkde/qtkde.cpp create mode 100644 tqt3integration/libqtkde/qtkde.h (limited to 'tqt3integration/libqtkde') diff --git a/tqt3integration/libqtkde/CMakeLists.txt b/tqt3integration/libqtkde/CMakeLists.txt new file mode 100644 index 000000000..a4220ac26 --- /dev/null +++ b/tqt3integration/libqtkde/CMakeLists.txt @@ -0,0 +1,33 @@ +################################################# +# +# (C) 2011 Timothy Pearson +# kb9vqf (AT) pearsoncomputing.net +# +# Improvements and feedback are welcome +# +# This file is released under GPL >= 2 +# +################################################# + +include_directories( + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_BINARY_DIR} + ${CMAKE_BINARY_DIR}/tqt3integration/utils/ + ${TDE_INCLUDE_DIR} + ${TQT_INCLUDE_DIRS} +) + +link_directories( + ${TQT_LIBRARY_DIRS} +) + +##### libqtkde (shared) #################### + +tde_add_library( qtkde SHARED AUTOMOC + SOURCES qtkde.cpp + VERSION 0.0.0 + LINK kdeui-shared + DEPENDENCIES generate_tqt3_bindings + DESTINATION "${PLUGIN_INSTALL_DIR}/plugins/integration/" +) \ No newline at end of file diff --git a/tqt3integration/libqtkde/Makefile.am b/tqt3integration/libqtkde/Makefile.am new file mode 100644 index 000000000..8675e19dd --- /dev/null +++ b/tqt3integration/libqtkde/Makefile.am @@ -0,0 +1,15 @@ +qtkdelib_LTLIBRARIES = libqtkde.la + +libqtkde_la_SOURCES = qtkde.cpp +libqtkde_la_LIBADD = -lDCOP +libqtkde_la_LDFLAGS = $(all_libraries) -module -no-undefined -avoid-version + +CLEANFILES = qtkde_functions.cpp + +INCLUDES = $(all_includes) +METASOURCES = AUTO + +qtkde.lo : qtkde_functions.cpp + +qtkde_functions.cpp : ../utils/qtkde_functions.cpp + cp -f ../utils/qtkde_functions.cpp . || exit 1 diff --git a/tqt3integration/libqtkde/qtkde.cpp b/tqt3integration/libqtkde/qtkde.cpp new file mode 100644 index 000000000..4e737a9a2 --- /dev/null +++ b/tqt3integration/libqtkde/qtkde.cpp @@ -0,0 +1,147 @@ + /* + * This file is part of the Trinity Desktop Environment + * + * Original file taken from the OpenSUSE kdebase builds + * + * This program 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; either version 2 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 General Public License for more details. + * + * You should have received a copy of the GNU 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. + */ + +#include "qtkde.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +extern Time qt_x_time; + +static QString convertFileFilter( const QString& filter ) + { + if( filter.isEmpty()) + return filter; + QString f2 = filter; + f2.replace( '\n', ";;" ); // Qt says separator is ";;", but it also silently accepts newline + f2.replace( '/', "\\/" ); // escape /'s for KFileDialog + QStringList items = QStringList::split( ";;", f2 ); + QRegExp reg( "\\((.*)\\)" ); + for( QStringList::Iterator it = items.begin(); + it != items.end(); + ++it ) + { + if( reg.search( *it )) + *it = reg.cap( 1 ) + '|' + *it; + } + return items.join( "\n" ); + } + +static QString convertBackFileFilter( const QString& filter ) + { + if( filter.isEmpty()) + return filter; + QStringList items = QStringList::split( "\n", filter ); + for( QStringList::Iterator it = items.begin(); + it != items.end(); + ++it ) + { + int pos = (*it).find( '|' ); + if( pos >= 0 ) + (*it) = (*it).mid( pos + 1 ); + } + return items.join( ";;" ); + } + +static DCOPClient* dcopClient() + { + DCOPClient* dcop = DCOPClient::mainClient(); + if( dcop == NULL ) + { + static DCOPClient* dcop_private; + if( dcop_private == NULL ) + { + dcop_private = new DCOPClient; + dcop_private->attach(); + } + dcop = dcop_private; + } + static bool prepared = false; + if( !prepared ) + { + assert( qApp != NULL ); // TODO + prepared = true; + dcop->bindToApp(); + if( !qApp->inherits( "KApplication" )) // KApp takes care of input blocking + { + static qtkde_EventLoop* loop = new qtkde_EventLoop; + QObject::connect( dcop, SIGNAL( blockUserInput( bool )), loop, SLOT( block( bool ))); + } + } + return dcop; + } + +// defined in qapplication_x11.cpp +typedef int (*QX11EventFilter) (XEvent*); +extern QX11EventFilter qt_set_x11_event_filter (QX11EventFilter filter); + +static QX11EventFilter old_filter; + +static int input_filter( XEvent* e ) + { + switch( e->type ) + { + case ButtonPress: + case ButtonRelease: + case KeyPress: + case KeyRelease: + case MotionNotify: + case EnterNotify: + case LeaveNotify: + return true; + default: + break; + } + if( old_filter != NULL ) + return old_filter( e ); + return false; + } + +void qtkde_EventLoop::block( bool b ) + { + if( b ) + old_filter = qt_set_x11_event_filter( input_filter ); + else + qt_set_x11_event_filter( old_filter ); + } + +// duped in kded module +static QString getHostname() + { + char hostname[ 256 ]; + if( gethostname( hostname, 255 ) == 0 ) + { + hostname[ 255 ] = '\0'; + return hostname; + } + return ""; + } + +#include "qtkde_functions.cpp" + +#include "qtkde.moc" diff --git a/tqt3integration/libqtkde/qtkde.h b/tqt3integration/libqtkde/qtkde.h new file mode 100644 index 000000000..c485537d8 --- /dev/null +++ b/tqt3integration/libqtkde/qtkde.h @@ -0,0 +1,34 @@ + /* + * This file is part of the Trinity Desktop Environment + * + * Original file taken from the OpenSUSE kdebase builds + * + * This program 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; either version 2 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 General Public License for more details. + * + * You should have received a copy of the GNU 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 _QTKDE_H +#define _QTKDE_H + +#include + +class qtkde_EventLoop + : public QObject + { + Q_OBJECT + public slots: + void block( bool ); + }; + +#endif -- cgit v1.2.3