summaryrefslogtreecommitdiffstats
path: root/tqt3integration
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-10-19 18:56:47 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-10-19 18:56:47 +0000
commit337f18fe5d032a59084a5d6516bcb0ff070128b6 (patch)
treeb8e5fa7014c3aa5672f15c86ddba5e53462d6f6f /tqt3integration
parent1944004a4c57c4c87efc66084579b595da720af8 (diff)
downloadtdebase-337f18fe5d032a59084a5d6516bcb0ff070128b6.tar.gz
tdebase-337f18fe5d032a59084a5d6516bcb0ff070128b6.zip
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
Diffstat (limited to 'tqt3integration')
-rw-r--r--tqt3integration/CMakeLists.txt14
-rw-r--r--tqt3integration/Makefile.am1
-rw-r--r--tqt3integration/README36
-rw-r--r--tqt3integration/configure.in.in5
-rw-r--r--tqt3integration/libqtkde/CMakeLists.txt33
-rw-r--r--tqt3integration/libqtkde/Makefile.am15
-rw-r--r--tqt3integration/libqtkde/qtkde.cpp147
-rw-r--r--tqt3integration/libqtkde/qtkde.h34
-rw-r--r--tqt3integration/module/CMakeLists.txt42
-rw-r--r--tqt3integration/module/Makefile.am21
-rw-r--r--tqt3integration/module/kdeintegration.desktop13
-rw-r--r--tqt3integration/module/module.cpp378
-rw-r--r--tqt3integration/module/module.h154
-rw-r--r--tqt3integration/utils/CMakeLists.txt44
-rw-r--r--tqt3integration/utils/Makefile.am19
-rw-r--r--tqt3integration/utils/gen.cpp970
-rw-r--r--tqt3integration/utils/gen.txt546
-rw-r--r--tqt3integration/utils/qt/CMakeLists.txt12
-rw-r--r--tqt3integration/utils/qt/Makefile.am1
-rw-r--r--tqt3integration/utils/qt/in/CMakeLists.txt12
-rw-r--r--tqt3integration/utils/qt/in/qt.patch270
-rw-r--r--tqt3integration/utils/qt/in/qtkdeintegration_x11_0.cpp.cmake1
-rw-r--r--tqt3integration/utils/qt/in/qtkdeintegration_x11_1.cpp73
-rw-r--r--tqt3integration/utils/qt/in/qtkdeintegration_x11_2.cpp81
-rw-r--r--tqt3integration/utils/qt/in/qtkdeintegration_x11_p_1.h35
-rw-r--r--tqt3integration/utils/qt/in/qtkdeintegration_x11_p_2.h28
26 files changed, 2985 insertions, 0 deletions
diff --git a/tqt3integration/CMakeLists.txt b/tqt3integration/CMakeLists.txt
new file mode 100644
index 00000000..01ce8a76
--- /dev/null
+++ b/tqt3integration/CMakeLists.txt
@@ -0,0 +1,14 @@
+#################################################
+#
+# (C) 2011 Timothy Pearson
+# kb9vqf (AT) pearsoncomputing.net
+#
+# Improvements and feedback are welcome
+#
+# This file is released under GPL >= 2
+#
+#################################################
+
+add_subdirectory( libqtkde )
+add_subdirectory( module )
+add_subdirectory( utils ) \ No newline at end of file
diff --git a/tqt3integration/Makefile.am b/tqt3integration/Makefile.am
new file mode 100644
index 00000000..dc0a666a
--- /dev/null
+++ b/tqt3integration/Makefile.am
@@ -0,0 +1 @@
+SUBDIRS = libqtkde module utils
diff --git a/tqt3integration/README b/tqt3integration/README
new file mode 100644
index 00000000..989d59d5
--- /dev/null
+++ b/tqt3integration/README
@@ -0,0 +1,36 @@
+Qt/KDE UI integration. Makes Qt-only apps use several KDE dialogs without any modifications
+to these applications. Can be turned off by setting $QT_NO_KDE_INTEGRATION.
+
+Installation:
+Just plain make && make install.
+Additionally 'make generate' needs to be done in utils/, and Qt needs to be patched using the sources
+generated in utils/qt . Patch should be applied, the .cpp/.h files belong to src/kernel/ ,
+the .h file additionally should go to include/private .
+
+
+<l.lunak@suse.cz>
+
+
+=====
+
+- nastavovat WM_CLASS i vsem poddialogum tech, ktere se zobrazuji?
+
+v kded nesmi byt nic, co znovu vstupuje do event loop
+ - udelat na to test
+ - spravit kwallet
+
+blokovat uzivatelsky vstup, jako to dela kapp pro dcop
+
+obcas se dela demand-attention v taskbaru
+- navic je problem s focus stealing prevention, kdyz aplikace nejdriv zobrazi jen samotny dialog
+ - delat updateUserTimestamp?
+
+filedialogs
+ - pamatovat si working directory pro kazdou dcop konexi, a pouzit, kdyz neni dano?
+ - vraceni selectedFilter uplne nefunguje, protoze KFileDialog nevraci cely filter (*.cpp|C++ File), alen jen *.cpp
+
+getColor()
+ - KColorDialog neumi alpha channel - ale to mac taky ne
+
+getFont()
+ - zmenil jsem QFont* def na const QFont& def, tj. vzdy je k dispozici, neexistence se da null hodnotou
diff --git a/tqt3integration/configure.in.in b/tqt3integration/configure.in.in
new file mode 100644
index 00000000..8e36cc20
--- /dev/null
+++ b/tqt3integration/configure.in.in
@@ -0,0 +1,5 @@
+qtkdelibdir="\${kde_moduledir}/plugins/integration"
+KDE_EXPAND_MAKEVAR(ac_qtkdelibdir,qtkdelibdir)
+AC_SUBST(qtkdelibdir)
+AC_SUBST(ac_qtkdelibdir)
+dnl AC_OUTPUT(qtkdeintegration/utils/qt/in/qtkdeintegration_x11_0.cpp)
diff --git a/tqt3integration/libqtkde/CMakeLists.txt b/tqt3integration/libqtkde/CMakeLists.txt
new file mode 100644
index 00000000..a4220ac2
--- /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 00000000..8675e19d
--- /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 00000000..4e737a9a
--- /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 <assert.h>
+#include <dcopclient.h>
+#include <dcoptypes.h>
+#include <qapplication.h>
+#include <qregexp.h>
+#include <qstringlist.h>
+#include <qwidget.h>
+#include <unistd.h>
+
+#include <X11/Xlib.h>
+
+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 00000000..c485537d
--- /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 <qobject.h>
+
+class qtkde_EventLoop
+ : public QObject
+ {
+ Q_OBJECT
+ public slots:
+ void block( bool );
+ };
+
+#endif
diff --git a/tqt3integration/module/CMakeLists.txt b/tqt3integration/module/CMakeLists.txt
new file mode 100644
index 00000000..282c4a6a
--- /dev/null
+++ b/tqt3integration/module/CMakeLists.txt
@@ -0,0 +1,42 @@
+#################################################
+#
+# (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}
+)
+
+##### service desktop file(s) ##########################
+
+install( FILES kdeintegration.desktop DESTINATION ${SERVICES_INSTALL_DIR}/kded )
+
+##### kded_kdeintegration (module) #####################
+
+set( target kded_kdeintegration )
+
+set( ${target}_SRCS
+ module.cpp
+)
+
+tde_add_kpart( ${target} AUTOMOC
+ SOURCES ${${target}_SRCS}
+ LINK kdeinit_kded-shared
+ DEPENDENCIES generate_tqt3_bindings
+ DESTINATION ${PLUGIN_INSTALL_DIR}
+) \ No newline at end of file
diff --git a/tqt3integration/module/Makefile.am b/tqt3integration/module/Makefile.am
new file mode 100644
index 00000000..d730db97
--- /dev/null
+++ b/tqt3integration/module/Makefile.am
@@ -0,0 +1,21 @@
+INCLUDES= $(all_includes)
+
+kde_module_LTLIBRARIES = kded_kdeintegration.la
+
+kded_kdeintegration_la_SOURCES = module.cpp
+kded_kdeintegration_la_METASOURCES = AUTO
+kded_kdeintegration_la_LDFLAGS = $(all_libraries) -module -avoid-version
+kded_kdeintegration_la_LIBADD = $(LIB_KIO)
+
+CLEANFILES = module_functions.cpp module_functions.h
+
+servicesdir = $(kde_servicesdir)/kded
+services_DATA = kdeintegration.desktop
+
+module.lo : module_functions.cpp module_functions.h
+
+module_functions.cpp : ../utils/module_functions.cpp
+ cp -f ../utils/module_functions.cpp . || exit 1
+
+module_functions.h : ../utils/module_functions.h
+ cp -f ../utils/module_functions.h . || exit 1
diff --git a/tqt3integration/module/kdeintegration.desktop b/tqt3integration/module/kdeintegration.desktop
new file mode 100644
index 00000000..0f41e5e9
--- /dev/null
+++ b/tqt3integration/module/kdeintegration.desktop
@@ -0,0 +1,13 @@
+[Desktop Entry]
+Encoding=UTF-8
+Type=Service
+
+ServiceTypes=KDEDModule
+X-KDE-ModuleType=Library
+X-KDE-Library=kdeintegration
+X-KDE-Factory=kdeintegration
+X-KDE-Kded-autoload=false
+X-KDE-Kded-load-on-demand=true
+
+Name=KDE Integration Module
+Comment=Module for integrating UI of non-KDE applications
diff --git a/tqt3integration/module/module.cpp b/tqt3integration/module/module.cpp
new file mode 100644
index 00000000..f76f2003
--- /dev/null
+++ b/tqt3integration/module/module.cpp
@@ -0,0 +1,378 @@
+ /*
+ * 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 "module.h"
+
+#include <assert.h>
+#include <dcopclient.h>
+#include <kapplication.h>
+#include <kdebug.h>
+#include <kfiledialog.h>
+#include <kglobalsettings.h>
+#include <klocale.h>
+#include <krecentdocument.h>
+#include <kwin.h>
+#include <qtimer.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <kmessagebox.h>
+
+#include <X11/Xutil.h>
+
+extern "C"
+{
+ KDE_EXPORT KDEDModule *create_kdeintegration( const QCString& obj )
+ {
+ return new KDEIntegration::Module( obj );
+ }
+};
+
+namespace KDEIntegration
+{
+
+static void prepareDialog( QWidget* w, long parent, const QCString& wmclass1, const QCString& wmclass2 )
+ {
+ XClassHint hints;
+ hints.res_name = ( char* ) ( const char* ) wmclass1;
+ hints.res_class = ( char* ) ( const char* ) wmclass2;
+ XSetClassHint( qt_xdisplay(), w->winId(), &hints );
+ KWin::setMainWindow( w, parent );
+ KWin::setState( w->winId(), NET::Modal );
+ KWin::WindowInfo info = KWin::windowInfo( parent, (unsigned long)NET::WMGeometry );
+ if( info.valid())
+ w->move( info.geometry().x() + ( info.geometry().width() - w->width())/2,
+ info.geometry().y() + ( info.geometry().height()- w->height())/2 );
+ }
+
+// duped in qtkde
+static QString getHostname()
+ {
+ char hostname[ 256 ];
+ if( gethostname( hostname, 255 ) == 0 )
+ {
+ hostname[ 255 ] = '\0';
+ return hostname;
+ }
+ return "";
+ }
+
+bool Module::initializeIntegration( const QString& hostname )
+ {
+ if( hostname != getHostname())
+ return false;
+ // multihead support in KDE is just a hack, it wouldn't work very well anyway
+ if( KGlobalSettings::isMultiHead())
+ return false;
+ return true;
+ }
+
+void* Module::getOpenFileNames( const QString& filter, QString workingDirectory, long parent,
+ const QCString& name, const QString& caption, QString /*selectedFilter*/, bool multiple,
+ const QCString& wmclass1, const QCString& wmclass2 )
+ {
+ KFileDialog* dlg = new KFileDialog( workingDirectory, filter, 0, name.isEmpty() ? "filedialog" : name, false);
+ prepareDialog( dlg, parent, wmclass1, wmclass2 );
+ dlg->setOperationMode( KFileDialog::Opening );
+ dlg->setMode(( multiple ? KFile::Files : KFile::File ) | KFile::LocalOnly );
+ dlg->setPlainCaption( caption.isNull() ? i18n("Open") : caption );
+// TODO dlg->ops->clearHistory();
+ connect( dlg, SIGNAL( dialogDone( int )), SLOT( dialogDone( int )));
+ dlg->show();
+ return dlg;
+ }
+
+void* Module::getSaveFileName( const QString& initialSelection, const QString& filter,
+ QString workingDirectory, long parent, const QCString& name, const QString& caption, QString /*selectedFilter*/,
+ const QCString& wmclass1, const QCString& wmclass2 )
+ {
+ QString initial = workingDirectory;
+ if( !initialSelection.isEmpty())
+ {
+ if( initial.right( 1 ) != QChar( '/' ))
+ initial += '/';
+ initial += initialSelection;
+ }
+ bool specialDir = initial.at(0) == ':';
+ KFileDialog* dlg = new KFileDialog( specialDir ? initial : QString::null, filter, 0,
+ name.isEmpty() ? "filedialog" : name, false);
+ if ( !specialDir )
+ dlg->setSelection( initial ); // may also be a filename
+ prepareDialog( dlg, parent, wmclass1, wmclass2 );
+ dlg->setOperationMode( KFileDialog::Saving );
+ dlg->setPlainCaption( caption.isNull() ? i18n("Save As") : caption );
+ connect( dlg, SIGNAL( dialogDone( int )), SLOT( dialogDone( int )));
+ dlg->show();
+ return dlg;
+ }
+
+
+void* Module::getExistingDirectory( const QString& initialDirectory, long parent,
+ const QCString& name, const QString& caption, const QCString& wmclass1, const QCString& wmclass2 )
+ {
+ KDirSelectDialog* dlg = new KDirSelectDialog( initialDirectory, true, 0,
+ name.isEmpty() ? name : "kdirselect dialog", false );
+ prepareDialog( dlg, parent, wmclass1, wmclass2 );
+ dlg->setPlainCaption( caption.isNull() ? i18n( "Select Folder" ) : caption );
+ connect( dlg, SIGNAL( dialogDone( int )), SLOT( dialogDone( int )));
+ dlg->show();
+ return dlg;
+ }
+
+void* Module::getColor( const QColor& color, long parent, const QCString& name,
+ const QCString& wmclass1, const QCString& wmclass2 )
+ {
+ KColorDialog* dlg = new KColorDialog( NULL, name.isEmpty() ? name : "colordialog", true );
+ dlg->setModal( false ); // KColorDialog creates its buttons depending on modality :(
+ if( color.isValid())
+ dlg->setColor( color );
+ prepareDialog( dlg, parent, wmclass1, wmclass2 );
+ dlg->setPlainCaption( i18n( "Select Color" ));
+ connect( dlg, SIGNAL( dialogDone( int )), SLOT( dialogDone( int )));
+ dlg->show();
+ return dlg;
+ }
+
+void* Module::getFont( bool /*ok*/, const QFont& def, long parent, const QCString& name,
+ const QCString& wmclass1, const QCString& wmclass2 )
+ {
+ KFontDialog* dlg = new KFontDialog( NULL, name.isEmpty() ? name : "Font Selector", false, false );
+ dlg->setFont( def, false );
+ prepareDialog( dlg, parent, wmclass1, wmclass2 );
+ dlg->setPlainCaption( i18n( "Select Font" ));
+ connect( dlg, SIGNAL( dialogDone( int )), SLOT( dialogDone( int )));
+ dlg->show();
+ return dlg;
+ }
+
+namespace
+{
+struct btns
+ {
+ int buttons[ 3 ];
+ };
+}
+static QMap< KDialogBase*, btns > msgbox1_buttons;
+
+void* Module::messageBox1( int type, long parent, const QString& caption, const QString& text,
+ int button0, int button1, int button2, const QCString& wmclass1, const QCString& wmclass2 )
+ {
+ static const char* const caps[ 4 ]
+ = { I18N_NOOP( "Information" ), I18N_NOOP( "Question" ), I18N_NOOP( "Warning" ), I18N_NOOP( "Error" )};
+ int buttons[ 3 ] = { button0 & QMessageBox::ButtonMask,
+ button1 & QMessageBox::ButtonMask, button2 & QMessageBox::ButtonMask };
+ KGuiItem buttonItems[ 3 ];
+ for( int i = 0;
+ i < 3;
+ ++i )
+ switch( buttons[ i ] )
+ {
+ case QMessageBox::Ok:
+ buttonItems[ i ] = KStdGuiItem::ok();
+ break;
+ case QMessageBox::Cancel:
+ buttonItems[ i ] = KStdGuiItem::cancel();
+ break;
+ case QMessageBox::Yes:
+ buttonItems[ i ] = KStdGuiItem::yes();
+ break;
+ case QMessageBox::No:
+ buttonItems[ i ] = KStdGuiItem::no();
+ break;
+ case QMessageBox::Abort:
+ buttonItems[ i ] = KGuiItem( i18n( "&Abort" ));
+ break;
+ case QMessageBox::Retry:
+ buttonItems[ i ] = KGuiItem( "&Retry" );
+ break;
+ case QMessageBox::Ignore:
+ buttonItems[ i ] = KGuiItem( "&Ignore" );
+ break;
+ case QMessageBox::YesAll:
+ buttonItems[ i ] = KStdGuiItem::yes();
+ buttonItems[ i ].setText( i18n( "Yes to &All" ));
+ break;
+ case QMessageBox::NoAll:
+ buttonItems[ i ] = KStdGuiItem::no();
+ buttonItems[ i ].setText( i18n( "N&o to All" ));
+ break;
+ default:
+ break;
+ };
+ KDialogBase::ButtonCode defaultButton = KDialogBase::NoDefault;
+ if( button0 & QMessageBox::Default )
+ defaultButton = KDialogBase::Yes;
+ else if( button1 & QMessageBox::Default )
+ defaultButton = KDialogBase::No;
+ else if( button2 & QMessageBox::Default )
+ defaultButton = KDialogBase::Cancel;
+ else // TODO KDialogBase's handling of NoDefault has strange focus effects
+ defaultButton = KDialogBase::Yes;
+ KDialogBase::ButtonCode escapeButton = KDialogBase::Cancel;
+ if( button0 & QMessageBox::Escape )
+ escapeButton = KDialogBase::Yes;
+ else if( button1 & QMessageBox::Escape )
+ escapeButton = KDialogBase::No;
+ else if( button2 & QMessageBox::Escape )
+ escapeButton = KDialogBase::Cancel;
+ KDialogBase *dialog= new KDialogBase(
+ caption.isEmpty() ? i18n( caps[ type ] ) : caption,
+ KDialogBase::Yes
+ | ( buttons[ 1 ] == QMessageBox::NoButton ? 0 : int( KDialogBase::No ))
+ | ( buttons[ 2 ] == QMessageBox::NoButton ? 0 : int( KDialogBase::Cancel )),
+ defaultButton, escapeButton,
+ NULL, "messageBox2", true, true,
+ buttonItems[ 0 ], buttonItems[ 1 ],buttonItems[ 2 ] );
+ bool checkboxResult = false;
+ KMessageBox::createKMessageBox(dialog, static_cast< QMessageBox::Icon >( type ), text, QStringList(),
+ QString::null,
+ &checkboxResult, KMessageBox::Notify | KMessageBox::NoExec);
+ prepareDialog( dialog, parent, wmclass1, wmclass2 );
+ dialog->setPlainCaption( caption );
+ connect( dialog, SIGNAL( dialogDone( int )), SLOT( dialogDone( int )));
+ btns b;
+ b.buttons[ 0 ] = buttons[ 0 ];
+ b.buttons[ 1 ] = buttons[ 1 ];
+ b.buttons[ 2 ] = buttons[ 2 ];
+ msgbox1_buttons[ dialog ] = b;
+ dialog->show();
+ return dialog;
+ }
+
+void* Module::messageBox2( int type, long parent, const QString& caption, const QString& text, const QString& button0Text,
+ const QString& button1Text, const QString& button2Text, int defaultButton, int escapeButton,
+ const QCString& wmclass1, const QCString& wmclass2 )
+ {
+ static KDialogBase::ButtonCode map[ 4 ]
+ = { KDialogBase::NoDefault, KDialogBase::Yes, KDialogBase::No, KDialogBase::Cancel };
+ static const char* const caps[ 4 ]
+ = { I18N_NOOP( "Information" ), I18N_NOOP( "Question" ), I18N_NOOP( "Warning" ), I18N_NOOP( "Error" )};
+ KDialogBase *dialog= new KDialogBase(
+ caption.isEmpty() ? i18n( caps[ type ] ) : caption,
+ KDialogBase::Yes
+ | ( button1Text.isEmpty() ? 0 : int( KDialogBase::No ))
+ | ( button2Text.isEmpty() ? 0 : int( KDialogBase::Cancel )),
+ map[ defaultButton + 1 ], map[ escapeButton + 1 ],
+ NULL, "messageBox2", true, true,
+ button0Text.isEmpty() ? KStdGuiItem::ok() : KGuiItem( button0Text ), button1Text,button2Text);
+ bool checkboxResult = false;
+ KMessageBox::createKMessageBox(dialog, static_cast< QMessageBox::Icon >( type ), text, QStringList(),
+ QString::null,
+ &checkboxResult, KMessageBox::Notify | KMessageBox::NoExec);
+ prepareDialog( dialog, parent, wmclass1, wmclass2 );
+ dialog->setPlainCaption( caption );
+ connect( dialog, SIGNAL( dialogDone( int )), SLOT( dialogDone( int )));
+ dialog->show();
+ return dialog;
+ }
+
+void Module::dialogDone( int result )
+ {
+ void* handle = (void*)sender(); // TODO?
+ JobData job = jobs[ handle ];
+ switch( job.type )
+ {
+ case JobData::GetOpenFileNames:
+ {
+ KFileDialog* dlg = static_cast< KFileDialog* >( handle );
+ post_getOpenFileNames( dlg, result == QDialog::Accepted ? dlg->selectedFiles() : QStringList(),
+ dlg->baseURL().path(), dlg->currentFilter());
+ dlg->deleteLater();
+ break;
+ }
+ case JobData::GetSaveFileName:
+ {
+ KFileDialog* dlg = static_cast< KFileDialog* >( handle );
+ QString filename = result == QDialog::Accepted ? dlg->selectedFile() : QString();
+ if (!filename.isEmpty())
+ KRecentDocument::add(filename);
+ post_getSaveFileName( dlg, filename, dlg->baseURL().path(), dlg->currentFilter());
+ dlg->deleteLater();
+ break;
+ }
+ case JobData::GetExistingDirectory:
+ {
+ KDirSelectDialog* dlg = static_cast< KDirSelectDialog* >( handle );
+ post_getExistingDirectory( dlg, result == QDialog::Accepted ? dlg->url().path() : QString());
+ dlg->deleteLater();
+ break;
+ }
+ case JobData::GetColor:
+ {
+ KColorDialog* dlg = static_cast< KColorDialog* >( handle );
+ post_getColor( dlg, result == QDialog::Accepted ? dlg->color() : QColor());
+ dlg->deleteLater();
+ break;
+ }
+ case JobData::GetFont:
+ {
+ KFontDialog* dlg = static_cast< KFontDialog* >( handle );
+ post_getFont( dlg, result == QDialog::Accepted ? dlg->font() : QFont(), result == QDialog::Accepted );
+ dlg->deleteLater();
+ break;
+ }
+ case JobData::MessageBox1:
+ {
+ KDialogBase* dlg = static_cast< KDialogBase* >( handle );
+ btns b = msgbox1_buttons[ dlg ];
+ int res;
+ if( result == KDialogBase::Cancel )
+ res = b.buttons[ 2 ];
+ else if( result == KDialogBase::Yes )
+ res = b.buttons[ 0 ];
+ else
+ res = b.buttons[ 1 ];
+ msgbox1_buttons.remove( dlg );
+ post_messageBox1( dlg, res );
+// if (checkboxResult)
+// saveDontShowAgainYesNo(dontAskAgainName, res);
+ dlg->deleteLater();
+ break;
+ }
+ case JobData::MessageBox2:
+ {
+ KDialogBase* dlg = static_cast< KDialogBase* >( handle );
+ int res;
+ if( result == KDialogBase::Cancel )
+ res = 2;
+ else if( result == KDialogBase::Yes )
+ res = 0;
+ else if( result == KDialogBase::No )
+ res = 1;
+ else
+ res = -1;
+ post_messageBox2( dlg, res );
+// if (checkboxResult)
+// saveDontShowAgainYesNo(dontAskAgainName, res);
+ dlg->deleteLater();
+ break;
+ }
+ }
+ }
+
+Module::Module( const QCString& obj )
+ : KDEDModule( obj )
+ {
+ }
+
+#include "module_functions.cpp"
+
+} // namespace
+
+#include "module.moc"
diff --git a/tqt3integration/module/module.h b/tqt3integration/module/module.h
new file mode 100644
index 00000000..80bc4a34
--- /dev/null
+++ b/tqt3integration/module/module.h
@@ -0,0 +1,154 @@
+ /*
+ * 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 _INTEGRATION_MODULE_H_
+#define _INTEGRATION_MODULE_H_
+
+#include <kcolordialog.h>
+#include <kdedmodule.h>
+#include <kdirselectdialog.h>
+#include <kfiledialog.h>
+#include <kfontdialog.h>
+#include <kdialogbase.h>
+
+class DCOPClientTransaction;
+
+namespace KDEIntegration
+{
+
+class Module
+ : public KDEDModule
+ {
+ Q_OBJECT
+ public:
+ Module( const QCString& obj );
+ // DCOP
+ virtual bool process(const QCString &fun, const QByteArray &data,
+ QCString &replyType, QByteArray &replyData);
+ virtual QCStringList functions();
+ virtual QCStringList interfaces();
+ private slots:
+ void dialogDone( int result );
+ private:
+ struct JobData
+ {
+ DCOPClientTransaction* transaction;
+ enum
+ {
+ GetOpenFileNames,
+ GetSaveFileName,
+ GetExistingDirectory,
+ GetColor,
+ GetFont,
+ MessageBox1,
+ MessageBox2
+ } type;
+ };
+ QMap< void*, JobData > jobs;
+#include "module_functions.h"
+ };
+
+class KFileDialog
+ : public ::KFileDialog
+ {
+ Q_OBJECT
+ public:
+ KFileDialog(const QString& startDir, const QString& filter,
+ QWidget *parent, const char *name, bool modal)
+ : ::KFileDialog( startDir, filter, parent, name, modal )
+ {}
+ signals:
+ void dialogDone( int result );
+ protected:
+ virtual void done( int r ) { ::KFileDialog::done( r ); emit dialogDone( r ); }
+ };
+
+
+class KDirSelectDialog
+ : public ::KDirSelectDialog
+ {
+ Q_OBJECT
+ public:
+ KDirSelectDialog(const QString& startDir, bool localOnly,
+ QWidget *parent, const char *name, bool modal)
+ : ::KDirSelectDialog( startDir, localOnly, parent, name, modal )
+ {}
+ signals:
+ void dialogDone( int result );
+ protected:
+ virtual void done( int r ) { ::KDirSelectDialog::done( r ); emit dialogDone( r ); }
+ };
+
+
+class KColorDialog
+ : public ::KColorDialog
+ {
+ Q_OBJECT
+ public:
+ KColorDialog( QWidget *parent, const char *name, bool modal )
+ : ::KColorDialog( parent, name, modal )
+ {}
+ signals:
+ void dialogDone( int result );
+ protected:
+ virtual void done( int r ) { ::KColorDialog::done( r ); emit dialogDone( r ); } // hmm?
+ };
+
+class KFontDialog
+ : public ::KFontDialog
+ {
+ Q_OBJECT
+ public:
+ KFontDialog( QWidget *parent, const char *name, bool onlyFixed, bool modal,
+ const QStringList &fontlist = QStringList(), bool makeFrame = true,
+ bool diff = false, QButton::ToggleState *sizeIsRelativeState = 0L )
+ : ::KFontDialog( parent, name, onlyFixed, modal, fontlist, makeFrame, diff, sizeIsRelativeState )
+ {}
+ signals:
+ void dialogDone( int result );
+ protected:
+ virtual void done( int r ) { ::KFontDialog::done( r ); emit dialogDone( r ); }
+ };
+
+class KDialogBase
+ : public ::KDialogBase
+ {
+ Q_OBJECT
+ public:
+ KDialogBase( const QString &caption, int buttonMask=Yes|No|Cancel,
+ ButtonCode defaultButton=Yes, ButtonCode escapeButton=Cancel,
+ QWidget *parent=0, const char *name=0,
+ bool modal=true, bool separator=false,
+ const KGuiItem &yes = KStdGuiItem::yes(), // i18n("&Yes")
+ const KGuiItem &no = KStdGuiItem::no(), // i18n("&No"),
+ const KGuiItem &cancel = KStdGuiItem::cancel()) // i18n("&Cancel")
+ : ::KDialogBase( caption, buttonMask, defaultButton, escapeButton, parent, name, modal, separator,
+ yes, no, cancel )
+ {}
+ signals:
+ void dialogDone( int result );
+ protected:
+ virtual void done( int r ) { ::KDialogBase::done( r ); emit dialogDone( r ); }
+ };
+
+
+} // namespace
+
+#endif
diff --git a/tqt3integration/utils/CMakeLists.txt b/tqt3integration/utils/CMakeLists.txt
new file mode 100644
index 00000000..8386a95f
--- /dev/null
+++ b/tqt3integration/utils/CMakeLists.txt
@@ -0,0 +1,44 @@
+#################################################
+#
+# (C) 2011 Timothy Pearson
+# kb9vqf (AT) pearsoncomputing.net
+#
+# Improvements and feedback are welcome
+#
+# This file is released under GPL >= 2
+#
+#################################################
+
+add_subdirectory( qt )
+
+include_directories(
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${CMAKE_CURRENT_SOURCE_DIR}
+ ${CMAKE_BINARY_DIR}
+ ${TDE_INCLUDE_DIR}
+ ${TQT_INCLUDE_DIRS}
+)
+
+link_directories(
+ ${TQT_LIBRARY_DIRS}
+)
+
+##### gen (internal executable) ########################
+
+tde_add_executable( gen AUTOMOC
+ SOURCES
+ gen.cpp
+ LINK kdecore-shared
+)
+
+ADD_CUSTOM_COMMAND(
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/qtkde_functions.cpp ${CMAKE_CURRENT_BINARY_DIR}/module_functions.cpp ${CMAKE_CURRENT_BINARY_DIR}/module_functions.h
+ COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/qt
+ COMMAND ${CMAKE_CURRENT_BINARY_DIR}/gen ${CMAKE_CURRENT_SOURCE_DIR}/gen.txt
+ COMMAND cat ${CMAKE_CURRENT_BINARY_DIR}/qt/in/qtkdeintegration_x11_0.cpp ${CMAKE_CURRENT_SOURCE_DIR}/qt/in/qtkdeintegration_x11_1.cpp ${CMAKE_CURRENT_BINARY_DIR}/qtkdeintegration_x11.cpp.gen ${CMAKE_CURRENT_SOURCE_DIR}/qt/in/qtkdeintegration_x11_2.cpp > ${CMAKE_CURRENT_BINARY_DIR}/qt/qtkdeintegration_x11.cpp
+ COMMAND cat ${CMAKE_CURRENT_SOURCE_DIR}/qt/in/qtkdeintegration_x11_p_1.h ${CMAKE_CURRENT_BINARY_DIR}/qtkdeintegration_x11_p.h.gen ${CMAKE_CURRENT_SOURCE_DIR}/qt/in/qtkdeintegration_x11_p_2.h > ${CMAKE_CURRENT_BINARY_DIR}/qt/qtkdeintegration_x11_p.h
+ COMMAND rm -f ${CMAKE_CURRENT_BINARY_DIR}/qtkdeintegration_x11.cpp.gen ${CMAKE_CURRENT_BINARY_DIR}/qtkdeintegration_x11_p.h.gen
+# COMMAND cp -f ${CMAKE_CURRENT_SOURCE_DIR}/qt/in/qt.patch ${CMAKE_CURRENT_BINARY_DIR}/qt/
+ DEPENDS gen
+)
+ADD_CUSTOM_TARGET(generate_tqt3_bindings DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/qtkde_functions.cpp) \ No newline at end of file
diff --git a/tqt3integration/utils/Makefile.am b/tqt3integration/utils/Makefile.am
new file mode 100644
index 00000000..f4f22e3b
--- /dev/null
+++ b/tqt3integration/utils/Makefile.am
@@ -0,0 +1,19 @@
+noinst_PROGRAMS = gen
+gen_SOURCES = gen.cpp
+gen_LDADD = $(LIB_KDECORE)
+gen_LDFLAGS = $(all_libraries)
+INCLUDES = $(all_includes)
+CLEANFILES = qtkde_functions.cpp module_functions.cpp module_functions.h generated
+SUBDIRS = qt
+
+generate: generated
+
+generated: gen gen.txt
+ ./gen || exit 1
+ cat qt/in/qtkdeintegration_x11_0.cpp qt/in/qtkdeintegration_x11_1.cpp qtkdeintegration_x11.cpp.gen qt/in/qtkdeintegration_x11_2.cpp >qt/qtkdeintegration_x11.cpp
+ cat qt/in/qtkdeintegration_x11_p_1.h qtkdeintegration_x11_p.h.gen qt/in/qtkdeintegration_x11_p_2.h >qt/qtkdeintegration_x11_p.h
+ rm -f qtkdeintegration_x11.cpp.gen qtkdeintegration_x11_p.h.gen
+ cp -f qt/in/qt.patch qt/
+ touch generated
+
+qtkde_functions.cpp module_functions.cpp module_functions.h : generated
diff --git a/tqt3integration/utils/gen.cpp b/tqt3integration/utils/gen.cpp
new file mode 100644
index 00000000..178d67a3
--- /dev/null
+++ b/tqt3integration/utils/gen.cpp
@@ -0,0 +1,970 @@
+ /*
+ * 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 <qfile.h>
+#include <qstring.h>
+#include <qvaluelist.h>
+#include <stdlib.h>
+
+// TODO includes, forwards
+
+
+/*
+
+FUNCTION <name>
+ RETURN_TYPE <type>
+ DELAYED_RETURN - use DCOP transaction in kded module, function will take some time to finish
+ SKIP_QT - don't generate in qt file
+ ONLY_QT - generate only in qt file
+ ADD_APPINFO - generate wmclass arguments
+ ARG <name>
+ TYPE <type>
+ ORIG_TYPE <type> - for example when the function accepts QWidget*, but WId is really used
+ ORIG_CONVERSION <conversion>
+ IGNORE
+ NEEDS_DEREF
+ CONST_REF
+ OUT_ARGUMENT
+ CONVERSION <function>
+ BACK_CONVERSION <function> - for out arguments
+ CREATE <function> - doesn't exist in Qt, create in qtkde using function
+ PARENT - the argument is a parent window to be used for windows
+ ENDARG
+ENDFUNCTION
+
+*/
+
+struct Arg
+ {
+ Arg() : ignore( false ), needs_deref( false ), const_ref( false ), out_argument( false ), parent( false ) {}
+ QString name;
+ QString type;
+ QString orig_type;
+ QString orig_conversion;
+ bool ignore;
+ bool needs_deref;
+ bool const_ref;
+ bool out_argument;
+ QString conversion;
+ QString back_conversion;
+ QString create;
+ bool parent;
+ };
+
+struct Function
+ {
+ Function() : delayed_return( false ), skip_qt( false ), only_qt( false ), add_appinfo( false ) {}
+ QString name;
+ QString return_type;
+ bool delayed_return;
+ bool skip_qt;
+ bool only_qt;
+ bool add_appinfo;
+ QValueList< Arg > args;
+ void stripNonOutArguments();
+ void stripCreatedArguments();
+ };
+
+void Function::stripNonOutArguments()
+ {
+ QValueList< Arg > new_args;
+ for( QValueList< Arg >::ConstIterator it = args.begin();
+ it != args.end();
+ ++it )
+ {
+ const Arg& arg = (*it);
+ if( arg.out_argument )
+ new_args.append( arg );
+ }
+ args = new_args;
+ }
+
+void Function::stripCreatedArguments()
+ {
+ QValueList< Arg > new_args;
+ for( QValueList< Arg >::ConstIterator it = args.begin();
+ it != args.end();
+ ++it )
+ {
+ const Arg& arg = (*it);
+ if( arg.create.isEmpty())
+ new_args.append( arg );
+ }
+ args = new_args;
+ }
+
+QValueList< Function > functions;
+
+QFile* input_file = NULL;
+QTextStream* input_stream = NULL;
+static QString last_line;
+int last_lineno = 0;
+
+#define check( arg ) my_check( __FILE__, __LINE__, arg )
+#define error() my_error( __FILE__, __LINE__ )
+
+void my_error( const char* file, int line )
+ {
+ fprintf( stderr, "Error: %s: %d\n", file, line );
+ fprintf( stderr, "Line %d: %s\n", last_lineno, last_line.utf8().data());
+ abort();
+ }
+
+void my_check( const char* file, int line, bool arg )
+ {
+ if( !arg )
+ my_error( file, line );
+ }
+
+void openInputFile( const QString& filename )
+ {
+ check( input_file == NULL );
+ input_file = new QFile( filename );
+ printf("[INFO] Reading bindings definitions from file %s\n\r", filename.ascii());
+ if( !input_file->open( IO_ReadOnly ))
+ error();
+ input_stream = new QTextStream( input_file );
+ last_lineno = 0;
+ }
+
+QString getInputLine()
+ {
+ while( !input_stream->atEnd())
+ {
+ QString line = input_stream->readLine().stripWhiteSpace();
+ ++last_lineno;
+ last_line = line;
+ if( line.isEmpty() || line[ 0 ] == '#' )
+ continue;
+ return line;
+ }
+ return QString::null;
+ }
+
+void closeInputFile()
+ {
+ delete input_stream;
+ delete input_file;
+ input_stream = NULL;
+ input_file = NULL;
+ }
+
+void parseArg( Function& function, const QString& details )
+ {
+ Arg arg;
+ arg.name = details;
+ QString line = getInputLine();
+ while( !line.isNull() )
+ {
+ if( line.startsWith( "ENDARG" ))
+ {
+ check( !arg.type.isEmpty());
+ function.args.append( arg );
+ return;
+ }
+ else if( line.startsWith( "TYPE" ))
+ {
+ check( arg.type.isEmpty());
+ arg.type = line.mid( strlen( "TYPE" )).stripWhiteSpace();
+ }
+ else if( line.startsWith( "ORIG_TYPE" ))
+ {
+ check( arg.orig_type.isEmpty());
+ arg.orig_type = line.mid( strlen( "ORIG_TYPE" )).stripWhiteSpace();
+ }
+ else if( line.startsWith( "ORIG_CONVERSION" ))
+ {
+ check( arg.orig_conversion.isEmpty());
+ arg.orig_conversion = line.mid( strlen( "ORIG_CONVERSION" )).stripWhiteSpace();
+ }
+ else if( line.startsWith( "IGNORE" ))
+ {
+ check( !arg.out_argument );
+ arg.ignore = true;
+ }
+ else if( line.startsWith( "NEEDS_DEREF" ))
+ {
+ check( !arg.const_ref );
+ arg.needs_deref = true;
+ }
+ else if( line.startsWith( "CONST_REF" ))
+ {
+ check( !arg.needs_deref );
+ check( !arg.out_argument );
+ arg.const_ref = true;
+ }
+ else if( line.startsWith( "OUT_ARGUMENT" ))
+ {
+ check( !arg.ignore );
+ check( !arg.const_ref );
+ arg.out_argument = true;
+ }
+ else if( line.startsWith( "CONVERSION" ))
+ {
+ check( arg.conversion.isEmpty());
+ arg.conversion = line.mid( strlen( "CONVERSION" )).stripWhiteSpace();
+ }
+ else if( line.startsWith( "BACK_CONVERSION" ))
+ {
+ check( arg.back_conversion.isEmpty());
+ arg.back_conversion = line.mid( strlen( "BACK_CONVERSION" )).stripWhiteSpace();
+ }
+ else if( line.startsWith( "CREATE" ))
+ {
+ check( arg.create.isEmpty());
+ arg.create = line.mid( strlen( "CREATE" )).stripWhiteSpace();
+ }
+ else if( line.startsWith( "PARENT" ))
+ {
+ arg.parent = true;
+ }
+ else
+ error();
+ line = getInputLine();
+ }
+ error();
+ }
+
+void parseFunction( const QString& details )
+ {
+ Function function;
+ function.name = details;
+ QString line = getInputLine();
+ while( !line.isNull() )
+ {
+ if( line.startsWith( "ENDFUNCTION" ))
+ {
+ if( function.add_appinfo )
+ {
+ Arg arg;
+ arg.name = "wmclass1";
+ arg.type = "QCString";
+ arg.const_ref = true;
+ arg.create = "qAppName";
+ function.args.append( arg );
+ arg.name = "wmclass2";
+ arg.create = "qAppClass";
+ function.args.append( arg );
+ }
+ check( !function.return_type.isEmpty());
+ functions.append( function );
+ return;
+ }
+ else if( line.startsWith( "RETURN_TYPE" ))
+ {
+ check( function.return_type.isEmpty());
+ function.return_type = line.mid( strlen( "RETURN_TYPE" )).stripWhiteSpace();
+ }
+ else if( line.startsWith( "DELAYED_RETURN" ))
+ function.delayed_return = true;
+ else if( line.startsWith( "SKIP_QT" ))
+ function.skip_qt = true;
+ else if( line.startsWith( "ONLY_QT" ))
+ function.only_qt = true;
+ else if( line.startsWith( "ADD_APPINFO" ))
+ function.add_appinfo = true;
+ else if( line.startsWith( "ARG" ))
+ {
+ parseArg( function, line.mid( strlen( "ARG" )).stripWhiteSpace());
+ }
+ else
+ error();
+ line = getInputLine();
+ }
+ error();
+ }
+
+void parse(TQString filename)
+ {
+ openInputFile( filename );
+ QString line = getInputLine();
+ while( !line.isNull() )
+ {
+ if( line.startsWith( "FUNCTION" ))
+ {
+ parseFunction( line.mid( strlen( "FUNCTION" )).stripWhiteSpace());
+ }
+ else
+ error();
+ line = getInputLine();
+ }
+ closeInputFile();
+ }
+
+QString makeIndent( int indent )
+ {
+ return indent > 0 ? QString().fill( ' ', indent ) : "";
+ }
+
+void generateFunction( QTextStream& stream, const Function& function, const QString name,
+ int indent, bool staticf, bool orig_type, bool ignore_deref, int ignore_level )
+ {
+ QString line;
+ line += makeIndent( indent );
+ if( staticf )
+ line += "static ";
+ line += function.return_type + " " + name + "(";
+ bool need_comma = false;
+ for( QValueList< Arg >::ConstIterator it = function.args.begin();
+ it != function.args.end();
+ ++it )
+ {
+ const Arg& arg = (*it);
+ if( ignore_level >= 2 && arg.ignore )
+ continue;
+ if( need_comma )
+ {
+ line += ",";
+ if( line.length() > 80 )
+ {
+ stream << line << "\n";
+ line = makeIndent( indent + 4 );
+ }
+ else
+ line += " ";
+ }
+ else
+ line += " ";
+ need_comma = true;
+ if( orig_type && !arg.orig_type.isEmpty())
+ line += arg.orig_type;
+ else
+ {
+ if( arg.const_ref )
+ line += "const ";
+ line += arg.type;
+ if( !ignore_deref && arg.needs_deref )
+ line += "*";
+ if( arg.const_ref )
+ line += "&";
+ }
+ if( ignore_level >= 1 && arg.ignore )
+ line += " /*" + arg.name + "*/";
+ else
+ line += " " + arg.name;
+ }
+ line += " )";
+ stream << line;
+ }
+
+void generateQtH()
+ {
+ QFile file( "qtkdeintegration_x11_p.h.gen" );
+ if( !file.open( IO_WriteOnly ))
+ error();
+ QTextStream stream( &file );
+ for( QValueList< Function >::ConstIterator it = functions.begin();
+ it != functions.end();
+ ++it )
+ {
+ Function f = *it;
+ if( f.skip_qt )
+ continue;
+ f.stripCreatedArguments();
+ generateFunction( stream, f, f.name, 8,
+ true /*static*/, true /*orig type*/, false /*ignore deref*/, 0 /*ignore level*/ );
+ stream << ";\n";
+ }
+ }
+
+void generateQtCpp()
+ {
+ QFile file( "qtkdeintegration_x11.cpp.gen" );
+ if( !file.open( IO_WriteOnly ))
+ error();
+ QTextStream stream( &file );
+ for( QValueList< Function >::ConstIterator it = functions.begin();
+ it != functions.end();
+ ++it )
+ {
+ Function f = *it;
+ if( f.only_qt )
+ continue;
+ f.stripCreatedArguments();
+ generateFunction( stream, f, "(*qtkde_" + f.name + ")", 0,
+ true /*static*/, false /*orig type*/, false /*ignore deref*/, 0 /*ignore level*/ );
+ stream << ";\n";
+ }
+ stream <<
+"\n"
+"void QKDEIntegration::initLibrary()\n"
+" {\n"
+" if( !inited )\n"
+" {\n"
+" enable = false;\n"
+" inited = true;\n"
+" QString libpath = findLibrary();\n"
+" if( libpath.isEmpty())\n"
+" return;\n"
+" QLibrary lib( libpath );\n"
+" if( !QFile::exists( lib.library())) // avoid stupid Qt warning\n"
+" return;\n"
+" lib.setAutoUnload( false );\n";
+ for( QValueList< Function >::ConstIterator it = functions.begin();
+ it != functions.end();
+ ++it )
+ {
+ Function function = *it;
+ if( function.only_qt )
+ continue;
+ stream << makeIndent( 8 ) + "qtkde_" + function.name + " = (\n";
+ function.stripCreatedArguments();
+ generateFunction( stream, function, "(*)", 12,
+ false /*static*/, false /*orig type*/, false /*ignore deref*/, 0 /*ignore level*/ );
+ stream << "\n" + makeIndent( 12 ) + ")\n";
+ stream << makeIndent( 12 ) + "lib.resolve(\"" + (*it).name + "\");\n";
+ stream << makeIndent( 8 ) + "if( qtkde_" + (*it).name + " == NULL )\n";
+ stream << makeIndent( 12 ) + "return;\n";
+ }
+ stream <<
+" enable = qtkde_initializeIntegration();\n"
+" }\n"
+" }\n"
+"\n";
+ for( QValueList< Function >::ConstIterator it1 = functions.begin();
+ it1 != functions.end();
+ ++it1 )
+ {
+ Function function = *it1;
+ if( function.skip_qt || function.only_qt )
+ continue;
+ function.stripCreatedArguments();
+ generateFunction( stream, function, "QKDEIntegration::" + function.name, 0,
+ false /*static*/, true /*orig type*/, false /*ignore deref*/, 0 /*ignore level*/ );
+ stream << "\n";
+ stream << makeIndent( 4 ) + "{\n";
+ stream << makeIndent( 4 ) + "return qtkde_" + function.name + "(\n";
+ stream << makeIndent( 8 );
+ bool need_comma = false;
+ for( QValueList< Arg >::ConstIterator it2 = function.args.begin();
+ it2 != function.args.end();
+ ++it2 )
+ {
+ const Arg& arg = (*it2);
+ if( need_comma )
+ stream << ", ";
+ need_comma = true;
+ if( !arg.orig_conversion.isEmpty())
+ {
+ stream << arg.orig_conversion + "( " + arg.name + " )";
+ }
+ else
+ stream << arg.name;
+ }
+ stream << " );\n";
+ stream << makeIndent( 4 ) + "}\n";
+ }
+ }
+
+void generateQt()
+ {
+ generateQtH();
+ generateQtCpp();
+ }
+
+void generateQtKde()
+ {
+ QFile file( "qtkde_functions.cpp" );
+ if( !file.open( IO_WriteOnly ))
+ error();
+ QTextStream stream( &file );
+ for( QValueList< Function >::ConstIterator it1 = functions.begin();
+ it1 != functions.end();
+ ++it1 )
+ {
+ const Function& function = *it1;
+ if( function.only_qt )
+ continue;
+ Function stripped_function = function;
+ stripped_function.stripCreatedArguments();
+ stream << "extern \"C\"\n";
+ generateFunction( stream, stripped_function, stripped_function.name, 0,
+ false /*static*/, false /*orig type*/, false /*ignore deref*/, 1 /*ignore level*/ );
+ stream << "\n";
+ stream <<
+" {\n"
+" if( qt_xdisplay() != NULL )\n"
+" XSync( qt_xdisplay(), False );\n";
+ QString parent_arg;
+ for( QValueList< Arg >::ConstIterator it2 = function.args.begin();
+ it2 != function.args.end();
+ ++it2 )
+ {
+ const Arg& arg = (*it2);
+ if( arg.ignore )
+ continue;
+ if( arg.parent )
+ {
+ parent_arg = arg.name;
+ break;
+ }
+ }
+ if( !parent_arg.isEmpty())
+ {
+ stream << " if( " << parent_arg << " == 0 )\n";
+ stream << " DCOPRef( \"kded\", \"MainApplication-Interface\" ).call( \"updateUserTimestamp\", qt_x_time );\n";
+ }
+ stream <<
+" QByteArray data, replyData;\n"
+" QCString replyType;\n";
+ if( !function.args.isEmpty())
+ {
+ stream << " QDataStream datastream( data, IO_WriteOnly );\n";
+ stream << " datastream";
+ for( QValueList< Arg >::ConstIterator it2 = function.args.begin();
+ it2 != function.args.end();
+ ++it2 )
+ {
+ const Arg& arg = (*it2);
+ if( arg.ignore )
+ continue;
+ stream << " << ";
+ if( !(arg.conversion).isNull() )
+ stream << arg.conversion + "( ";
+ if( !arg.create.isEmpty())
+ stream << arg.create + "()";
+ else
+ {
+ if( arg.needs_deref )
+ stream << "( " << arg.name << " != NULL ? *" << arg.name << " : " << arg.type << "())";
+ else
+ stream << arg.name;
+ }
+ if( !(arg.conversion).isNull() )
+ stream << " )";
+ }
+ stream << ";\n";
+ }
+ stream << " if( !dcopClient()->call( \"kded\", \"kdeintegration\",\"" + function.name + "(";
+ bool need_comma = false;
+ for( QValueList< Arg >::ConstIterator it2 = function.args.begin();
+ it2 != function.args.end();
+ ++it2 )
+ {
+ const Arg& arg = (*it2);
+ if( arg.ignore )
+ continue;
+ if( need_comma )
+ stream << ",";
+ need_comma = true;
+ stream << arg.type;
+ }
+ stream << ")\", data, replyType, replyData, true ))\n";
+ stream << " {\n";
+ if( function.return_type != "void" )
+ {
+ stream << " " + function.return_type << " ret;\n";
+ stream << " dcopTypeInit( ret ); // set to false/0/whatever\n";
+ stream << " return ret;\n";
+ }
+ else
+ stream << " return;\n";
+ stream << " }\n";
+ bool return_data = false;
+ for( QValueList< Arg >::ConstIterator it2 = function.args.begin();
+ !return_data && it2 != function.args.end();
+ ++it2 )
+ {
+ if( (*it2).out_argument )
+ return_data = true;
+ }
+ if( return_data || function.return_type != "void" )
+ stream << " QDataStream replystream( replyData, IO_ReadOnly );\n";
+ if( function.return_type != "void" )
+ {
+ stream << " " + function.return_type << " ret;\n";
+ stream << " replystream >> ret;\n";
+ }
+ if( return_data )
+ {
+ for( QValueList< Arg >::ConstIterator it2 = function.args.begin();
+ it2 != function.args.end();
+ ++it2 )
+ {
+ const Arg& arg = (*it2);
+ if( arg.out_argument && arg.needs_deref )
+ stream << " " << arg.type << " " << arg.name + "_dummy;\n";
+ }
+ stream << " replystream";
+ for( QValueList< Arg >::ConstIterator it2 = function.args.begin();
+ it2 != function.args.end();
+ ++it2 )
+ {
+ const Arg& arg = (*it2);
+ if( arg.out_argument )
+ {
+ stream << " >> ";
+ if( !(arg.back_conversion).isNull() )
+ stream << arg.name + "_dummy";
+ else
+ {
+ if( arg.needs_deref )
+ stream << "( " << arg.name << " != NULL ? *" << arg.name << " : " << arg.name << "_dummy )";
+ else
+ stream << arg.name;
+ }
+ }
+ }
+ stream << ";\n";
+ for( QValueList< Arg >::ConstIterator it2 = function.args.begin();
+ it2 != function.args.end();
+ ++it2 )
+ {
+ const Arg& arg = (*it2);
+ if( arg.out_argument && (!(arg.back_conversion).isNull()) )
+ stream << " if( " << arg.name << " != NULL )\n"
+ << makeIndent( 8 ) << "*" << arg.name << " = " << arg.back_conversion << "( " << arg.name + "_dummy );\n";
+ }
+ }
+ if( function.return_type != "void" )
+ stream << " return ret;\n";
+ stream << " }\n";
+ stream << "\n";
+ }
+ }
+
+void generateKdeDcop( QTextStream& stream )
+ {
+ stream <<
+"bool Module::process(const QCString &fun, const QByteArray &data,\n"
+" QCString &replyType, QByteArray &replyData)\n"
+" {\n";
+ for( QValueList< Function >::ConstIterator it1 = functions.begin();
+ it1 != functions.end();
+ ++it1 )
+ {
+ const Function& function = *it1;
+ if( function.only_qt )
+ continue;
+ stream << " if( fun == \"" + function.name + "(";
+ bool need_comma = false;
+ for( QValueList< Arg >::ConstIterator it2 = function.args.begin();
+ it2 != function.args.end();
+ ++it2 )
+ {
+ const Arg& arg = (*it2);
+ if( arg.ignore )
+ continue;
+ if( need_comma )
+ stream << ",";
+ need_comma = true;
+ stream << arg.type;
+ }
+ stream << ")\" )\n";
+ stream << " {\n";
+ if( function.delayed_return )
+ stream << " pre_" + function.name + "( data );\n";
+ else
+ {
+ stream << " pre_" + function.name + "( data, replyData );\n";
+ stream << " replyType = \"" << function.return_type << "\";\n";
+ }
+ stream << " return true;\n";
+ stream << " }\n";
+ }
+ stream <<
+" return KDEDModule::process( fun, data, replyType, replyData );\n"
+" }\n"
+"\n";
+ stream <<
+"QCStringList Module::functions()\n"
+" {\n"
+" QCStringList funcs = KDEDModule::functions();\n";
+ for( QValueList< Function >::ConstIterator it1 = functions.begin();
+ it1 != functions.end();
+ ++it1 )
+ {
+ const Function& function = *it1;
+ if( function.only_qt )
+ continue;
+ stream << " funcs << \"" + function.name + "(";
+ bool need_comma = false;
+ for( QValueList< Arg >::ConstIterator it2 = function.args.begin();
+ it2 != function.args.end();
+ ++it2 )
+ {
+ const Arg& arg = (*it2);
+ if( arg.ignore )
+ continue;
+ if( need_comma )
+ stream << ",";
+ need_comma = true;
+ stream << arg.type;
+ }
+ stream << ")\";\n";
+ }
+ stream <<
+" return funcs;\n"
+" }\n"
+"\n"
+"QCStringList Module::interfaces()\n"
+" {\n"
+" QCStringList ifaces = KDEDModule::interfaces();\n"
+" ifaces << \"KDEIntegration\";\n"
+" return ifaces;\n"
+" }\n"
+"\n";
+ }
+
+void generateKdePreStub( QTextStream& stream )
+ {
+ for( QValueList< Function >::ConstIterator it1 = functions.begin();
+ it1 != functions.end();
+ ++it1 )
+ {
+ const Function& function = *it1;
+ if( function.only_qt )
+ continue;
+ stream << "void Module::pre_" + function.name + "( const QByteArray& "
+ + ( function.args.isEmpty() ? "" : "data" )
+ + ( function.delayed_return ? "" : ", QByteArray& replyData" )
+ + " )\n";
+ stream << " {\n";
+ if( function.delayed_return )
+ {
+ stream << " JobData job;\n";
+ stream << " job.transaction = kapp->dcopClient()->beginTransaction();\n";
+ stream << " job.type = JobData::" + QString( function.name[ 0 ].upper()) + function.name.mid( 1 ) + ";\n";
+ }
+ for( QValueList< Arg >::ConstIterator it2 = function.args.begin();
+ it2 != function.args.end();
+ ++it2 )
+ {
+ const Arg& arg = (*it2);
+ if( arg.ignore )
+ continue;
+ stream << " " + arg.type + " " + arg.name + ";\n";
+ }
+ if( !function.args.isEmpty())
+ {
+ stream << " QDataStream datastream( data, IO_ReadOnly );\n";
+ stream << " datastream";
+ for( QValueList< Arg >::ConstIterator it2 = function.args.begin();
+ it2 != function.args.end();
+ ++it2 )
+ {
+ const Arg& arg = (*it2);
+ if( arg.ignore )
+ continue;
+ stream << " >> " + arg.name;
+ }
+ stream << ";\n";
+ }
+ if( function.delayed_return )
+ stream << " void* handle = " + function.name + "( ";
+ else
+ stream << " post_" + function.name + "( " + function.name + "( ";
+ bool need_comma = false;
+ for( QValueList< Arg >::ConstIterator it2 = function.args.begin();
+ it2 != function.args.end();
+ ++it2 )
+ {
+ const Arg& arg = (*it2);
+ if( arg.ignore )
+ continue;
+ if( need_comma )
+ stream << ", ";
+ need_comma = true;
+ stream << arg.name;
+ }
+ if( function.delayed_return )
+ {
+ stream << " );\n";
+ stream << " jobs[ handle ] = job;\n";
+ }
+ else
+ stream << " ), replyData );\n";
+ stream << " }\n";
+ stream << "\n";
+ }
+ }
+
+void generateKdePostStub( QTextStream& stream )
+ {
+ for( QValueList< Function >::ConstIterator it1 = functions.begin();
+ it1 != functions.end();
+ ++it1 )
+ {
+ const Function& function = *it1;
+ if( function.only_qt )
+ continue;
+ stream << "void Module::post_" + function.name + "( ";
+ bool needs_comma = false;
+ if( function.delayed_return )
+ {
+ stream << "void* handle";
+ needs_comma = true;
+ }
+ if( function.return_type != "void" )
+ {
+ if( needs_comma )
+ stream << ", ";
+ needs_comma = true;
+ stream << function.return_type + " ret";
+ }
+ for( QValueList< Arg >::ConstIterator it2 = function.args.begin();
+ it2 != function.args.end();
+ ++it2 )
+ {
+ const Arg& arg = (*it2);
+ if( arg.out_argument )
+ {
+ if( needs_comma )
+ stream << ", ";
+ needs_comma = true;
+ stream << arg.type + " " + arg.name;
+ }
+ }
+ if( !function.delayed_return )
+ stream << ( needs_comma ? "," : "" ) << " QByteArray& replyData";
+ stream << " )\n";
+ stream << " {\n";
+ if( function.delayed_return )
+ {
+ stream << " assert( jobs.contains( handle ));\n";
+ stream << " JobData job = jobs[ handle ];\n";
+ stream << " jobs.remove( handle );\n";
+ stream << " QByteArray replyData;\n";
+ stream << " QCString replyType = \"qtkde\";\n";
+ }
+ bool return_data = false;
+ for( QValueList< Arg >::ConstIterator it2 = function.args.begin();
+ !return_data && it2 != function.args.end();
+ ++it2 )
+ {
+ if( (*it2).out_argument )
+ return_data = true;
+ }
+ if( function.return_type != "void" || return_data )
+ stream << " QDataStream replystream( replyData, IO_WriteOnly );\n";
+ if( function.return_type != "void" )
+ stream << " replystream << ret;\n";
+ if( return_data )
+ {
+ stream << " replystream";
+ for( QValueList< Arg >::ConstIterator it2 = function.args.begin();
+ it2 != function.args.end();
+ ++it2 )
+ {
+ const Arg& arg = (*it2);
+ if( arg.out_argument )
+ stream << " << " + arg.name;
+ }
+ stream << ";\n";
+ }
+ if( function.delayed_return )
+ stream << " kapp->dcopClient()->endTransaction( job.transaction, replyType, replyData );\n";
+ stream << " }\n";
+ stream << "\n";
+ }
+ }
+
+void generateKdeStubs( QTextStream& stream )
+ {
+ generateKdePreStub( stream );
+ generateKdePostStub( stream );
+// TODO udelat i predbezne deklarace pro skutecne funkce?
+ }
+
+void generateKdeCpp()
+ {
+ QFile file( "module_functions.cpp" );
+ if( !file.open( IO_WriteOnly ))
+ error();
+ QTextStream stream( &file );
+ generateKdeDcop( stream );
+ generateKdeStubs( stream );
+ }
+
+void generateKdeH()
+ {
+ QFile file( "module_functions.h" );
+ if( !file.open( IO_WriteOnly ))
+ error();
+ QTextStream stream( &file );
+ for( QValueList< Function >::ConstIterator it1 = functions.begin();
+ it1 != functions.end();
+ ++it1 )
+ {
+ const Function& function = *it1;
+ if( function.only_qt )
+ continue;
+ Function real_function = function;
+ if( function.delayed_return )
+ real_function.return_type = "void*";
+ generateFunction( stream, real_function, real_function.name, 8,
+ false /*static*/, false /*orig type*/, true /*ignore deref*/, 2 /*ignore level*/ );
+ stream << ";\n";
+ stream << makeIndent( 8 ) + "void pre_" + function.name + "( const QByteArray& data"
+ + ( function.delayed_return ? "" : ", QByteArray& replyData" ) + " );\n";
+ Function post_function = function;
+ post_function.stripNonOutArguments();
+ if( function.return_type != "void" )
+ {
+ Arg return_arg;
+ return_arg.name = "ret";
+ return_arg.type = function.return_type;
+ post_function.args.prepend( return_arg );
+ }
+ if( function.delayed_return )
+ {
+ Arg handle_arg;
+ handle_arg.name = "handle";
+ handle_arg.type = "void*";
+ post_function.args.prepend( handle_arg );
+ }
+ else
+ {
+ Arg handle_arg;
+ handle_arg.name = "replyData";
+ handle_arg.type = "QByteArray&";
+ post_function.args.append( handle_arg );
+ }
+ post_function.return_type = "void";
+ generateFunction( stream, post_function, "post_" + post_function.name, 8,
+ false /*static*/, false /*orig type*/, true /*ignore deref*/, 2 /*ignore level*/ );
+ stream << ";\n";
+ }
+ }
+
+void generateKde()
+ {
+ generateKdeCpp();
+ generateKdeH();
+ }
+
+void generate()
+ {
+ generateQt();
+ generateQtKde();
+ generateKde();
+ }
+
+int main (int argc, char *argv[])
+ {
+ if (argc > 1) {
+ parse(TQString(argv[1]));
+ }
+ else {
+ parse(TQString("gen.txt"));
+ }
+ generate();
+ return 0;
+ }
diff --git a/tqt3integration/utils/gen.txt b/tqt3integration/utils/gen.txt
new file mode 100644
index 00000000..2bd4b1b3
--- /dev/null
+++ b/tqt3integration/utils/gen.txt
@@ -0,0 +1,546 @@
+# bool initializeIntegration()
+#
+FUNCTION initializeIntegration
+ RETURN_TYPE bool
+ ARG hostname
+ TYPE QString
+ CONST_REF
+ CREATE getHostname
+ ENDARG
+ENDFUNCTION
+# QStringList getOpenFileNames( const QString &filter,
+# QString* workingDirectory, QWidget *parent, const char* name,
+# const QString& caption, QString* selectedFilter, bool multiple );
+#
+FUNCTION getOpenFileNames
+ RETURN_TYPE QStringList
+ DELAYED_RETURN
+ ADD_APPINFO
+ ARG filter
+ TYPE QString
+ CONST_REF
+ CONVERSION convertFileFilter
+ ENDARG
+ ARG workingDirectory
+ TYPE QString
+ NEEDS_DEREF
+ OUT_ARGUMENT
+ ENDARG
+ ARG parent
+ TYPE long
+ ORIG_TYPE QWidget*
+ ORIG_CONVERSION parentToWinId
+ PARENT
+ ENDARG
+ ARG name
+ TYPE QCString
+ CONST_REF
+ ORIG_TYPE const char*
+ ENDARG
+ ARG caption
+ TYPE QString
+ CONST_REF
+ ENDARG
+ ARG selectedFilter
+ TYPE QString
+ NEEDS_DEREF
+ OUT_ARGUMENT
+ CONVERSION convertFileFilter
+ BACK_CONVERSION convertBackFileFilter
+ ENDARG
+ ARG multiple
+ TYPE bool
+ ENDARG
+ENDFUNCTION
+
+# QString getSaveFileName( const QString &initialSelection,
+# const QString &filter, QString* workingDirectory, QWidget *parent,
+# const char* name, const QString& caption, QString* selectedFilter );
+#
+FUNCTION getSaveFileName
+ RETURN_TYPE QString
+ DELAYED_RETURN
+ ADD_APPINFO
+ ARG initialSelection
+ TYPE QString
+ CONST_REF
+ ENDARG
+ ARG filter
+ TYPE QString
+ CONST_REF
+ CONVERSION convertFileFilter
+ ENDARG
+ ARG workingDirectory
+ TYPE QString
+ NEEDS_DEREF
+ OUT_ARGUMENT
+ ENDARG
+ ARG parent
+ TYPE long
+ ORIG_TYPE QWidget*
+ ORIG_CONVERSION parentToWinId
+ PARENT
+ ENDARG
+ ARG name
+ TYPE QCString
+ CONST_REF
+ ORIG_TYPE const char*
+ ENDARG
+ ARG caption
+ TYPE QString
+ CONST_REF
+ ENDARG
+ ARG selectedFilter
+ TYPE QString
+ NEEDS_DEREF
+ OUT_ARGUMENT
+ CONVERSION convertFileFilter
+ BACK_CONVERSION convertBackFileFilter
+ ENDARG
+ENDFUNCTION
+
+# QString getExistingDirectory( const QString &initialDirectory,
+# QWidget* parent, const char* name, const QString& caption );
+#
+FUNCTION getExistingDirectory
+ RETURN_TYPE QString
+ DELAYED_RETURN
+ ADD_APPINFO
+ ARG initialDirectory
+ TYPE QString
+ CONST_REF
+ ENDARG
+ ARG parent
+ TYPE long
+ ORIG_TYPE QWidget*
+ ORIG_CONVERSION parentToWinId
+ PARENT
+ ENDARG
+ ARG name
+ TYPE QCString
+ CONST_REF
+ ORIG_TYPE const char*
+ ENDARG
+ ARG caption
+ TYPE QString
+ CONST_REF
+ ENDARG
+ENDFUNCTION
+
+# QColor getColor( const QColor& color, QWidget* parent, const char* name );
+#
+FUNCTION getColor
+ RETURN_TYPE QColor
+ DELAYED_RETURN
+ ADD_APPINFO
+ ARG color
+ TYPE QColor
+ CONST_REF
+ ENDARG
+ ARG parent
+ TYPE long
+ ORIG_TYPE QWidget*
+ ORIG_CONVERSION parentToWinId
+ PARENT
+ ENDARG
+ ARG name
+ TYPE QCString
+ CONST_REF
+ ORIG_TYPE const char*
+ ENDARG
+ENDFUNCTION
+
+# QFont getFont( bool* ok, const QFont* def, QWidget *parent, const char* name);
+FUNCTION getFont
+ RETURN_TYPE QFont
+ DELAYED_RETURN
+ ADD_APPINFO
+ ARG ok
+ TYPE bool
+ NEEDS_DEREF
+ OUT_ARGUMENT
+ ENDARG
+ ARG def
+ TYPE QFont
+ ORIG_TYPE const QFont*
+ ORIG_CONVERSION fontPtrToFontRef
+ CONST_REF
+ ENDARG
+ ARG parent
+ TYPE long
+ ORIG_TYPE QWidget*
+ ORIG_CONVERSION parentToWinId
+ PARENT
+ ENDARG
+ ARG name
+ TYPE QCString
+ CONST_REF
+ ORIG_TYPE const char*
+ ENDARG
+ENDFUNCTION
+
+# int messageBox1( int type, QWidget *parent, const QString& caption, const QString& text,
+# int button0, int button1, int button2 );
+FUNCTION messageBox1
+ RETURN_TYPE int
+ DELAYED_RETURN
+ ADD_APPINFO
+ ARG type
+ TYPE int
+ ENDARG
+ ARG parent
+ TYPE long
+ ORIG_TYPE QWidget*
+ ORIG_CONVERSION parentToWinId
+ PARENT
+ ENDARG
+ ARG caption
+ TYPE QString
+ CONST_REF
+ ENDARG
+ ARG text
+ TYPE QString
+ CONST_REF
+ ENDARG
+ ARG button0
+ TYPE int
+ ENDARG
+ ARG button1
+ TYPE int
+ ENDARG
+ ARG button2
+ TYPE int
+ ENDARG
+ENDFUNCTION
+
+# int information( QWidget *parent, const QString& caption, const QString& text,
+# int button0, int button1, int button2 );
+FUNCTION information
+ RETURN_TYPE int
+ DELAYED_RETURN
+ ONLY_QT
+ ARG parent
+ TYPE long
+ ORIG_TYPE QWidget*
+ ORIG_CONVERSION parentToWinId
+ PARENT
+ ENDARG
+ ARG caption
+ TYPE QString
+ CONST_REF
+ ENDARG
+ ARG text
+ TYPE QString
+ CONST_REF
+ ENDARG
+ ARG button0
+ TYPE int
+ ENDARG
+ ARG button1
+ TYPE int
+ ENDARG
+ ARG button2
+ TYPE int
+ ENDARG
+ENDFUNCTION
+
+# int question( QWidget *parent, const QString& caption, const QString& text,
+# int button0, int button1, int button2 );
+FUNCTION question
+ RETURN_TYPE int
+ DELAYED_RETURN
+ ONLY_QT
+ ARG parent
+ TYPE long
+ ORIG_TYPE QWidget*
+ ORIG_CONVERSION parentToWinId
+ PARENT
+ ENDARG
+ ARG caption
+ TYPE QString
+ CONST_REF
+ ENDARG
+ ARG text
+ TYPE QString
+ CONST_REF
+ ENDARG
+ ARG button0
+ TYPE int
+ ENDARG
+ ARG button1
+ TYPE int
+ ENDARG
+ ARG button2
+ TYPE int
+ ENDARG
+ENDFUNCTION
+
+# int warning( QWidget *parent, const QString& caption, const QString& text,
+# int button0, int button1, int button2 );
+FUNCTION warning
+ RETURN_TYPE int
+ DELAYED_RETURN
+ ONLY_QT
+ ARG parent
+ TYPE long
+ ORIG_TYPE QWidget*
+ ORIG_CONVERSION parentToWinId
+ PARENT
+ ENDARG
+ ARG caption
+ TYPE QString
+ CONST_REF
+ ENDARG
+ ARG text
+ TYPE QString
+ CONST_REF
+ ENDARG
+ ARG button0
+ TYPE int
+ ENDARG
+ ARG button1
+ TYPE int
+ ENDARG
+ ARG button2
+ TYPE int
+ ENDARG
+ENDFUNCTION
+
+# int critical( QWidget *parent, const QString& caption, const QString& text,
+# int button0, int button1, int button2 );
+FUNCTION critical
+ RETURN_TYPE int
+ DELAYED_RETURN
+ ONLY_QT
+ ARG parent
+ TYPE long
+ ORIG_TYPE QWidget*
+ ORIG_CONVERSION parentToWinId
+ PARENT
+ ENDARG
+ ARG caption
+ TYPE QString
+ CONST_REF
+ ENDARG
+ ARG text
+ TYPE QString
+ CONST_REF
+ ENDARG
+ ARG button0
+ TYPE int
+ ENDARG
+ ARG button1
+ TYPE int
+ ENDARG
+ ARG button2
+ TYPE int
+ ENDARG
+ENDFUNCTION
+
+# int messageBox2( int type, QWidget* parent, const QString& caption, const QString& text,
+# const QString& button0Text, const QString& button1Text, const QString& button2Text,
+# int defaultButton, int escapeButton );
+FUNCTION messageBox2
+ RETURN_TYPE int
+ DELAYED_RETURN
+ ADD_APPINFO
+ ARG type
+ TYPE int
+ ENDARG
+ ARG parent
+ TYPE long
+ ORIG_TYPE QWidget*
+ ORIG_CONVERSION parentToWinId
+ PARENT
+ ENDARG
+ ARG caption
+ TYPE QString
+ CONST_REF
+ ENDARG
+ ARG text
+ TYPE QString
+ CONST_REF
+ ENDARG
+ ARG button0Text
+ TYPE QString
+ CONST_REF
+ ENDARG
+ ARG button1Text
+ TYPE QString
+ CONST_REF
+ ENDARG
+ ARG button2Text
+ TYPE QString
+ CONST_REF
+ ENDARG
+ ARG defaultButton
+ TYPE int
+ ENDARG
+ ARG escapeButton
+ TYPE int
+ ENDARG
+ENDFUNCTION
+
+# int information( QWidget* parent, const QString& caption, const QString& text,
+# const QString& button0Text, const QString& button1Text, const QString& button2Text,
+# int defaultButton, int escapeButton );
+FUNCTION information
+ RETURN_TYPE int
+ DELAYED_RETURN
+ ONLY_QT
+ ARG parent
+ TYPE long
+ ORIG_TYPE QWidget*
+ ORIG_CONVERSION parentToWinId
+ PARENT
+ ENDARG
+ ARG caption
+ TYPE QString
+ CONST_REF
+ ENDARG
+ ARG text
+ TYPE QString
+ CONST_REF
+ ENDARG
+ ARG button0Text
+ TYPE QString
+ CONST_REF
+ ENDARG
+ ARG button1Text
+ TYPE QString
+ CONST_REF
+ ENDARG
+ ARG button2Text
+ TYPE QString
+ CONST_REF
+ ENDARG
+ ARG defaultButton
+ TYPE int
+ ENDARG
+ ARG escapeButton
+ TYPE int
+ ENDARG
+ENDFUNCTION
+
+# int question( QWidget* parent, const QString& caption, const QString& text,
+# const QString& button0Text, const QString& button1Text, const QString& button2Text,
+# int defaultButton, int escapeButton );
+FUNCTION question
+ RETURN_TYPE int
+ DELAYED_RETURN
+ ONLY_QT
+ ARG parent
+ TYPE long
+ ORIG_TYPE QWidget*
+ ORIG_CONVERSION parentToWinId
+ PARENT
+ ENDARG
+ ARG caption
+ TYPE QString
+ CONST_REF
+ ENDARG
+ ARG text
+ TYPE QString
+ CONST_REF
+ ENDARG
+ ARG button0Text
+ TYPE QString
+ CONST_REF
+ ENDARG
+ ARG button1Text
+ TYPE QString
+ CONST_REF
+ ENDARG
+ ARG button2Text
+ TYPE QString
+ CONST_REF
+ ENDARG
+ ARG defaultButton
+ TYPE int
+ ENDARG
+ ARG escapeButton
+ TYPE int
+ ENDARG
+ENDFUNCTION
+
+# int warning( QWidget* parent, const QString& caption, const QString& text,
+# const QString& button0Text, const QString& button1Text, const QString& button2Text,
+# int defaultButton, int escapeButton );
+FUNCTION warning
+ RETURN_TYPE int
+ DELAYED_RETURN
+ ONLY_QT
+ ARG parent
+ TYPE long
+ ORIG_TYPE QWidget*
+ ORIG_CONVERSION parentToWinId
+ PARENT
+ ENDARG
+ ARG caption
+ TYPE QString
+ CONST_REF
+ ENDARG
+ ARG text
+ TYPE QString
+ CONST_REF
+ ENDARG
+ ARG button0Text
+ TYPE QString
+ CONST_REF
+ ENDARG
+ ARG button1Text
+ TYPE QString
+ CONST_REF
+ ENDARG
+ ARG button2Text
+ TYPE QString
+ CONST_REF
+ ENDARG
+ ARG defaultButton
+ TYPE int
+ ENDARG
+ ARG escapeButton
+ TYPE int
+ ENDARG
+ENDFUNCTION
+
+# int critical( QWidget* parent, const QString& caption, const QString& text,
+# const QString& button0Text, const QString& button1Text, const QString& button2Text,
+# int defaultButton, int escapeButton );
+FUNCTION critical
+ RETURN_TYPE int
+ DELAYED_RETURN
+ ONLY_QT
+ ARG parent
+ TYPE long
+ ORIG_TYPE QWidget*
+ ORIG_CONVERSION parentToWinId
+ PARENT
+ ENDARG
+ ARG caption
+ TYPE QString
+ CONST_REF
+ ENDARG
+ ARG text
+ TYPE QString
+ CONST_REF
+ ENDARG
+ ARG button0Text
+ TYPE QString
+ CONST_REF
+ ENDARG
+ ARG button1Text
+ TYPE QString
+ CONST_REF
+ ENDARG
+ ARG button2Text
+ TYPE QString
+ CONST_REF
+ ENDARG
+ ARG defaultButton
+ TYPE int
+ ENDARG
+ ARG escapeButton
+ TYPE int
+ ENDARG
+ENDFUNCTION
diff --git a/tqt3integration/utils/qt/CMakeLists.txt b/tqt3integration/utils/qt/CMakeLists.txt
new file mode 100644
index 00000000..de5ffb4e
--- /dev/null
+++ b/tqt3integration/utils/qt/CMakeLists.txt
@@ -0,0 +1,12 @@
+#################################################
+#
+# (C) 2011 Timothy Pearson
+# kb9vqf (AT) pearsoncomputing.net
+#
+# Improvements and feedback are welcome
+#
+# This file is released under GPL >= 2
+#
+#################################################
+
+add_subdirectory( in ) \ No newline at end of file
diff --git a/tqt3integration/utils/qt/Makefile.am b/tqt3integration/utils/qt/Makefile.am
new file mode 100644
index 00000000..c4667d0b
--- /dev/null
+++ b/tqt3integration/utils/qt/Makefile.am
@@ -0,0 +1 @@
+CLEANFILES = qt.patch qtkdeintegration_x11.cpp qtkdeintegration_x11_p.h
diff --git a/tqt3integration/utils/qt/in/CMakeLists.txt b/tqt3integration/utils/qt/in/CMakeLists.txt
new file mode 100644
index 00000000..e6fa392d
--- /dev/null
+++ b/tqt3integration/utils/qt/in/CMakeLists.txt
@@ -0,0 +1,12 @@
+#################################################
+#
+# (C) 2011 Timothy Pearson
+# kb9vqf (AT) pearsoncomputing.net
+#
+# Improvements and feedback are welcome
+#
+# This file is released under GPL >= 2
+#
+#################################################
+
+configure_file( qtkdeintegration_x11_0.cpp.cmake qtkdeintegration_x11_0.cpp @ONLY ) \ No newline at end of file
diff --git a/tqt3integration/utils/qt/in/qt.patch b/tqt3integration/utils/qt/in/qt.patch
new file mode 100644
index 00000000..57838844
--- /dev/null
+++ b/tqt3integration/utils/qt/in/qt.patch
@@ -0,0 +1,270 @@
+--- src/dialogs/qfiledialog.cpp.sav 2004-12-08 15:39:41.000000000 +0100
++++ src/dialogs/qfiledialog.cpp 2004-12-13 16:53:40.000000000 +0100
+@@ -92,6 +92,10 @@
+ #include "qvbox.h"
+ #include "qwidgetstack.h"
+
++#ifdef Q_WS_X11
++#include "private/qtkdeintegration_x11_p.h"
++#endif
++
+ #ifdef Q_WS_WIN
+ #ifdef QT_THREAD_SUPPORT
+ # include <private/qmutexpool_p.h>
+@@ -3428,7 +3432,11 @@ QString QFileDialog::getOpenFileName( co
+ if ( workingDirectory->isNull() )
+ *workingDirectory = QDir::currentDirPath();
+
+-#if defined(Q_WS_WIN)
++#if defined(Q_WS_X11)
++ if ( qt_use_native_dialogs && QKDEIntegration::enabled())
++ return QKDEIntegration::getOpenFileNames( filter, workingDirectory, parent, name,
++ caption, selectedFilter, false ).first();
++#elif defined(Q_WS_WIN)
+ if ( qt_use_native_dialogs && qApp->style().styleHint( QStyle::SH_GUIStyle ) == WindowsStyle )
+ return winGetOpenFileName( initialSelection, filter, workingDirectory,
+ parent, name, caption, selectedFilter );
+@@ -3546,7 +3554,11 @@ QString QFileDialog::getSaveFileName( co
+ if ( workingDirectory->isNull() )
+ *workingDirectory = QDir::currentDirPath();
+
+-#if defined(Q_WS_WIN)
++#if defined(Q_WS_X11)
++ if ( qt_use_native_dialogs && QKDEIntegration::enabled())
++ return QKDEIntegration::getSaveFileName( initialSelection, filter, workingDirectory,
++ parent, name, caption, selectedFilter );
++#elif defined(Q_WS_WIN)
+ if ( qt_use_native_dialogs && qApp->style().styleHint( QStyle::SH_GUIStyle ) == WindowsStyle )
+ return winGetSaveFileName( initialSelection, filter, workingDirectory,
+ parent, name, caption, selectedFilter );
+@@ -4433,7 +4445,17 @@ QString QFileDialog::getExistingDirector
+ if ( workingDirectory )
+ wd = *workingDirectory;
+
+-#if defined(Q_WS_WIN)
++#if defined(Q_WS_X11)
++ QString initialDir;
++ if ( !dir.isEmpty() ) {
++ QUrlOperator u( dir );
++ if ( QFileInfo( u.path() ).isDir() )
++ initialDir = dir;
++ } else
++ initialDir = QString::null;
++ if ( qt_use_native_dialogs && QKDEIntegration::enabled())
++ return QKDEIntegration::getExistingDirectory( initialDir, parent, name, caption );
++#elif defined(Q_WS_WIN)
+ QString initialDir;
+ if ( !dir.isEmpty() ) {
+ QUrlOperator u( dir );
+@@ -5586,7 +5608,10 @@ QStringList QFileDialog::getOpenFileName
+ }
+ }
+
+-#if defined(Q_WS_WIN)
++#if defined(Q_WS_X11)
++ if ( qt_use_native_dialogs && QKDEIntegration::enabled())
++ return QKDEIntegration::getOpenFileNames( filter, workingDirectory, parent, name, caption, selectedFilter, true );
++#elif defined(Q_WS_WIN)
+ if ( qt_use_native_dialogs && qApp->style().styleHint( QStyle::SH_GUIStyle ) == WindowsStyle )
+ return winGetOpenFileNames( filter, workingDirectory, parent, name, caption, selectedFilter );
+ #elif defined(Q_WS_MAC)
+--- src/dialogs/qmessagebox.cpp.sav 2003-12-22 12:24:32.000000000 +0100
++++ src/dialogs/qmessagebox.cpp 2005-01-05 18:05:29.638723917 +0100
+@@ -54,6 +54,12 @@
+ #endif
+
+
++#ifdef Q_WS_X11
++#include "private/qtkdeintegration_x11_p.h"
++#endif
++
++extern bool qt_use_native_dialogs;
++
+ // Internal class - don't touch
+
+ class QMessageBoxLabel : public QLabel
+@@ -1104,6 +1110,10 @@ int QMessageBox::information( QWidget *p
+ const QString& caption, const QString& text,
+ int button0, int button1, int button2 )
+ {
++#if defined(Q_WS_X11)
++ if ( qt_use_native_dialogs && QKDEIntegration::enabled())
++ return QKDEIntegration::information( parent, caption, text, button0, button1, button2 );
++#endif
+ QMessageBox *mb = new QMessageBox( caption, text, Information,
+ button0, button1, button2,
+ parent, "qt_msgbox_information", TRUE,
+@@ -1151,6 +1161,10 @@ int QMessageBox::question( QWidget *pare
+ const QString& caption, const QString& text,
+ int button0, int button1, int button2 )
+ {
++#if defined(Q_WS_X11)
++ if ( qt_use_native_dialogs && QKDEIntegration::enabled())
++ return QKDEIntegration::question( parent, caption, text, button0, button1, button2 );
++#endif
+ QMessageBox *mb = new QMessageBox( caption, text, Question,
+ button0, button1, button2,
+ parent, "qt_msgbox_information", TRUE,
+@@ -1199,6 +1213,10 @@ int QMessageBox::warning( QWidget *paren
+ const QString& caption, const QString& text,
+ int button0, int button1, int button2 )
+ {
++#if defined(Q_WS_X11)
++ if ( qt_use_native_dialogs && QKDEIntegration::enabled())
++ return QKDEIntegration::warning( parent, caption, text, button0, button1, button2 );
++#endif
+ QMessageBox *mb = new QMessageBox( caption, text, Warning,
+ button0, button1, button2,
+ parent, "qt_msgbox_warning", TRUE,
+@@ -1247,6 +1265,10 @@ int QMessageBox::critical( QWidget *pare
+ const QString& caption, const QString& text,
+ int button0, int button1, int button2 )
+ {
++#if defined(Q_WS_X11)
++ if ( qt_use_native_dialogs && QKDEIntegration::enabled())
++ return QKDEIntegration::critical( parent, caption, text, button0, button1, button2 );
++#endif
+ QMessageBox *mb = new QMessageBox( caption, text, Critical,
+ button0, button1, button2,
+ parent, "qt_msgbox_critical", TRUE,
+@@ -1394,6 +1416,11 @@ int QMessageBox::information( QWidget *p
+ int defaultButtonNumber,
+ int escapeButtonNumber )
+ {
++#if defined(Q_WS_X11)
++ if ( qt_use_native_dialogs && QKDEIntegration::enabled())
++ return QKDEIntegration::information( parent, caption, text,
++ button0Text, button1Text, button2Text, defaultButtonNumber, escapeButtonNumber );
++#endif
+ return textBox( parent, Information, caption, text,
+ button0Text, button1Text, button2Text,
+ defaultButtonNumber, escapeButtonNumber );
+@@ -1436,6 +1463,11 @@ int QMessageBox::question( QWidget *pare
+ int defaultButtonNumber,
+ int escapeButtonNumber )
+ {
++#if defined(Q_WS_X11)
++ if ( qt_use_native_dialogs && QKDEIntegration::enabled())
++ return QKDEIntegration::question( parent, caption, text,
++ button0Text, button1Text, button2Text, defaultButtonNumber, escapeButtonNumber );
++#endif
+ return textBox( parent, Question, caption, text,
+ button0Text, button1Text, button2Text,
+ defaultButtonNumber, escapeButtonNumber );
+@@ -1480,6 +1512,11 @@ int QMessageBox::warning( QWidget *paren
+ int defaultButtonNumber,
+ int escapeButtonNumber )
+ {
++#if defined(Q_WS_X11)
++ if ( qt_use_native_dialogs && QKDEIntegration::enabled())
++ return QKDEIntegration::warning( parent, caption, text,
++ button0Text, button1Text, button2Text, defaultButtonNumber, escapeButtonNumber );
++#endif
+ return textBox( parent, Warning, caption, text,
+ button0Text, button1Text, button2Text,
+ defaultButtonNumber, escapeButtonNumber );
+@@ -1520,6 +1557,11 @@ int QMessageBox::critical( QWidget *pare
+ int defaultButtonNumber,
+ int escapeButtonNumber )
+ {
++#if defined(Q_WS_X11)
++ if ( qt_use_native_dialogs && QKDEIntegration::enabled())
++ return QKDEIntegration::critical( parent, caption, text,
++ button0Text, button1Text, button2Text, defaultButtonNumber, escapeButtonNumber );
++#endif
+ return textBox( parent, Critical, caption, text,
+ button0Text, button1Text, button2Text,
+ defaultButtonNumber, escapeButtonNumber );
+--- src/dialogs/qfontdialog.cpp.sav 2004-08-12 14:32:06.000000000 +0200
++++ src/dialogs/qfontdialog.cpp 2004-12-13 19:02:31.000000000 +0100
+@@ -56,6 +56,10 @@
+ #include <private/qfontdata_p.h>
+ #include <qvalidator.h>
+
++#ifdef Q_WS_X11
++#include "private/qtkdeintegration_x11_p.h"
++#endif
++
+ /*!
+ \class QFontDialog qfontdialog.h
+ \ingroup dialogs
+@@ -384,9 +388,15 @@ QFont QFontDialog::getFont( bool *ok, QW
+ return getFont( ok, 0, parent, name );
+ }
+
++extern bool qt_use_native_dialogs;
++
+ QFont QFontDialog::getFont( bool *ok, const QFont *def,
+ QWidget *parent, const char* name)
+ {
++#if defined(Q_WS_X11)
++ if ( qt_use_native_dialogs && QKDEIntegration::enabled())
++ return QKDEIntegration::getFont( ok, def, parent, name );
++#endif
+ QFont result;
+ if ( def )
+ result = *def;
+--- src/dialogs/qcolordialog.cpp.sav 2004-04-30 12:00:05.000000000 +0200
++++ src/dialogs/qcolordialog.cpp 2004-12-13 16:53:40.000000000 +0100
+@@ -60,6 +60,10 @@ QRgb macGetRgba( QRgb initial, bool *ok,
+ QColor macGetColor( const QColor& initial, QWidget *parent, const char *name );
+ #endif
+
++#ifdef Q_WS_X11
++#include "private/qtkdeintegration_x11_p.h"
++#endif
++
+ //////////// QWellArray BEGIN
+
+ struct QWellArrayData;
+@@ -1478,7 +1482,10 @@ QColorDialog::QColorDialog(QWidget* pare
+ QColor QColorDialog::getColor( const QColor& initial, QWidget *parent,
+ const char *name )
+ {
+-#if defined(Q_WS_MAC)
++#if defined(Q_WS_X11)
++ if( QKDEIntegration::enabled())
++ return QKDEIntegration::getColor( initial, parent, name );
++#elif defined(Q_WS_MAC)
+ return macGetColor(initial, parent, name);
+ #endif
+
+@@ -1516,6 +1523,13 @@ QRgb QColorDialog::getRgba( QRgb initial
+ QWidget *parent, const char* name )
+ {
+ #if defined(Q_WS_MAC)
++ if( QKDEIntegration::enabled()) {
++ QColor color = QKDEIntegration::getColor( QColor( initial ), parent, name );
++ if( ok )
++ *ok = color.isValid();
++ return color.rgba();
++ }
++#elif defined(Q_WS_MAC)
+ return macGetRgba(initial, ok, parent, name);
+ #endif
+
+--- src/kernel/qt_x11.pri.sav 2004-11-15 17:51:45.000000000 +0100
++++ src/kernel/qt_x11.pri 2004-12-13 16:53:40.000000000 +0100
+@@ -10,6 +10,9 @@ unix {
+
+ SOURCES += $$KERNEL_CPP/qtaddons_x11.cpp
+ PRECOMPILED_HEADER = kernel/qt_pch.h
++
++ SOURCES += $$KERNEL_CPP/qtkdeintegration_x11.cpp
++ HEADERS += $$KERNEL_H/qtkdeintegration_x11_p.h
+ }
+
+ nas {
+--- src/kernel/qt.h.sav 2004-02-16 15:05:19.000000000 +0100
++++ src/kernel/qt.h 2004-12-13 16:53:40.000000000 +0100
+@@ -313,6 +313,10 @@
+ #endif // Private headers
+
+
++#ifdef Q_WS_X11
++#include "private/qtkdeintegration_x11_p.h"
++#endif
++
+ #ifdef Q_WS_MAC
+ #include <qaquastyle.h>
+ #include <qmacstyle_mac.h>
diff --git a/tqt3integration/utils/qt/in/qtkdeintegration_x11_0.cpp.cmake b/tqt3integration/utils/qt/in/qtkdeintegration_x11_0.cpp.cmake
new file mode 100644
index 00000000..37b84a77
--- /dev/null
+++ b/tqt3integration/utils/qt/in/qtkdeintegration_x11_0.cpp.cmake
@@ -0,0 +1 @@
+#define QTKDELIBDIR @PLUGIN_INSTALL_DIR@/plugins/integration
diff --git a/tqt3integration/utils/qt/in/qtkdeintegration_x11_1.cpp b/tqt3integration/utils/qt/in/qtkdeintegration_x11_1.cpp
new file mode 100644
index 00000000..0fe1b3ba
--- /dev/null
+++ b/tqt3integration/utils/qt/in/qtkdeintegration_x11_1.cpp
@@ -0,0 +1,73 @@
+ /*
+ * 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 "qtkdeintegration_x11_p.h"
+
+#include <qcolordialog.h>
+#include <qfiledialog.h>
+#include <qfontdialog.h>
+#include <qlibrary.h>
+#include <qregexp.h>
+#include <qmessagebox.h>
+#include <qapplication.h>
+#include <stdlib.h>
+
+bool QKDEIntegration::inited = false;
+bool QKDEIntegration::enable = false;
+
+bool QKDEIntegration::enabled()
+ {
+ if( !inited )
+ initLibrary();
+ return enable;
+ }
+
+static QCString findLibrary()
+ {
+ if( getenv( "KDE_FULL_SESSION" ) == NULL )
+ return "";
+ if( getenv( "KDE_FULL_SESSION" )[ 0 ] != 't' && getenv( "KDE_FULL_SESSION" )[ 0 ] != '1' )
+ return "";
+ if( getenv( "QT_NO_KDE_INTEGRATION" ) == NULL
+ || getenv( "QT_NO_KDE_INTEGRATION" )[ 0 ] == '0' )
+ {
+ return QCString( QTKDELIBDIR ) + "/libqtkde";
+ }
+ return "";
+ }
+
+static long parentToWinId( const QWidget* w )
+ {
+ if( w != NULL )
+ return w->topLevelWidget()->winId();
+ // try to find some usable parent
+ if( qApp->activeWindow() && w != qApp->activeWindow())
+ return qApp->activeWindow()->winId();
+ if( qApp->mainWidget() && w != qApp->mainWidget())
+ return qApp->mainWidget()->winId();
+ return 0;
+ }
+
+inline static QFont fontPtrToFontRef( const QFont* f )
+ {
+ return f != NULL ? *f : QFont();
+ }
+
+// ---
diff --git a/tqt3integration/utils/qt/in/qtkdeintegration_x11_2.cpp b/tqt3integration/utils/qt/in/qtkdeintegration_x11_2.cpp
new file mode 100644
index 00000000..d22f5e9a
--- /dev/null
+++ b/tqt3integration/utils/qt/in/qtkdeintegration_x11_2.cpp
@@ -0,0 +1,81 @@
+ /*
+ * 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.
+ */
+
+// ---
+
+int QKDEIntegration::information( QWidget* parent, const QString& caption,
+ const QString& text, int button0, int button1, int button2 )
+ {
+ return qtkde_messageBox1(
+ QMessageBox::Information, parentToWinId( parent ), caption, text, button0, button1, button2 );
+ }
+
+int QKDEIntegration::question( QWidget* parent, const QString& caption,
+ const QString& text, int button0, int button1, int button2 )
+ {
+ return qtkde_messageBox1(
+ QMessageBox::Question, parentToWinId( parent ), caption, text, button0, button1, button2 );
+ }
+
+int QKDEIntegration::warning( QWidget* parent, const QString& caption,
+ const QString& text, int button0, int button1, int button2 )
+ {
+ return qtkde_messageBox1(
+ QMessageBox::Warning, parentToWinId( parent ), caption, text, button0, button1, button2 );
+ }
+
+int QKDEIntegration::critical( QWidget* parent, const QString& caption,
+ const QString& text, int button0, int button1, int button2 )
+ {
+ return qtkde_messageBox1(
+ QMessageBox::Critical, parentToWinId( parent ), caption, text, button0, button1, button2 );
+ }
+
+int QKDEIntegration::information( QWidget* parent, const QString& caption,
+ const QString& text, const QString& button0Text, const QString& button1Text, const QString& button2Text,
+ int defaultButton, int escapeButton )
+ {
+ return qtkde_messageBox2(
+ QMessageBox::Information, parentToWinId( parent ), caption, text, button0Text, button1Text, button2Text, defaultButton, escapeButton );
+ }
+
+int QKDEIntegration::question( QWidget* parent, const QString& caption,
+ const QString& text, const QString& button0Text, const QString& button1Text, const QString& button2Text,
+ int defaultButton, int escapeButton )
+ {
+ return qtkde_messageBox2(
+ QMessageBox::Question, parentToWinId( parent ), caption, text, button0Text, button1Text, button2Text, defaultButton, escapeButton );
+ }
+
+int QKDEIntegration::warning( QWidget* parent, const QString& caption,
+ const QString& text, const QString& button0Text, const QString& button1Text, const QString& button2Text,
+ int defaultButton, int escapeButton )
+ {
+ return qtkde_messageBox2(
+ QMessageBox::Warning, parentToWinId( parent ), caption, text, button0Text, button1Text, button2Text, defaultButton, escapeButton );
+ }
+
+int QKDEIntegration::critical( QWidget* parent, const QString& caption,
+ const QString& text, const QString& button0Text, const QString& button1Text, const QString& button2Text,
+ int defaultButton, int escapeButton )
+ {
+ return qtkde_messageBox2(
+ QMessageBox::Critical, parentToWinId( parent ), caption, text, button0Text, button1Text, button2Text, defaultButton, escapeButton );
+ }
diff --git a/tqt3integration/utils/qt/in/qtkdeintegration_x11_p_1.h b/tqt3integration/utils/qt/in/qtkdeintegration_x11_p_1.h
new file mode 100644
index 00000000..118e861e
--- /dev/null
+++ b/tqt3integration/utils/qt/in/qtkdeintegration_x11_p_1.h
@@ -0,0 +1,35 @@
+ /*
+ * 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 QKDEINTEGRATION_H
+#define QKDEINTEGRATION_H
+
+#include <qstringlist.h>
+
+class QLibrary;
+class QWidget;
+class QColor;
+class QFont;
+
+class QKDEIntegration
+ {
+ public:
+ static bool enabled();
+// ---
diff --git a/tqt3integration/utils/qt/in/qtkdeintegration_x11_p_2.h b/tqt3integration/utils/qt/in/qtkdeintegration_x11_p_2.h
new file mode 100644
index 00000000..4ce56ff9
--- /dev/null
+++ b/tqt3integration/utils/qt/in/qtkdeintegration_x11_p_2.h
@@ -0,0 +1,28 @@
+ /*
+ * 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.
+ */
+
+// ---
+ private:
+ static void initLibrary();
+ static bool inited;
+ static bool enable;
+ };
+
+#endif