You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
241 lines
9.8 KiB
241 lines
9.8 KiB
13 years ago
|
/* This file is licensed under the terms of the GPL v2 or v3, as it has been publicly released by
|
||
|
OpenSUSE as part of their GPLed TQt library disribution */
|
||
|
|
||
6 years ago
|
#include "tqttdeintegration_x11_p.h"
|
||
13 years ago
|
|
||
13 years ago
|
#include <ntqcolordialog.h>
|
||
|
#include <ntqfiledialog.h>
|
||
|
#include <ntqfontdialog.h>
|
||
|
#include <ntqlibrary.h>
|
||
|
#include <ntqregexp.h>
|
||
|
#include <ntqmessagebox.h>
|
||
13 years ago
|
#include <stdlib.h>
|
||
|
|
||
6 years ago
|
bool TQTDEIntegration::inited = false;
|
||
|
bool TQTDEIntegration::enable = false;
|
||
13 years ago
|
|
||
6 years ago
|
bool TQTDEIntegration::enabled()
|
||
13 years ago
|
{
|
||
|
if( !inited )
|
||
|
initLibrary();
|
||
|
return enable;
|
||
|
}
|
||
|
|
||
|
static TQCString findLibrary()
|
||
|
{
|
||
6 years ago
|
if( getenv( "TQT_NO_TDE_INTEGRATION" ) == NULL
|
||
|
|| getenv( "TQT_NO_TDE_INTEGRATION" )[ 0 ] == '0' )
|
||
13 years ago
|
{
|
||
6 years ago
|
return TQCString() + tqInstallPathPlugins() + "/integration/libtqttde";
|
||
13 years ago
|
}
|
||
|
return "";
|
||
|
}
|
||
|
|
||
|
inline static long widgetToWinId( const TQWidget* w )
|
||
|
{
|
||
|
return w != NULL ? w->winId() : 0;
|
||
|
}
|
||
|
|
||
|
inline static TQFont fontPtrToFontRef( const TQFont* f )
|
||
|
{
|
||
|
return f != NULL ? *f : TQFont();
|
||
|
}
|
||
|
|
||
|
// ---
|
||
6 years ago
|
static bool (*tqttde_initializeIntegration)( );
|
||
|
static TQStringList (*tqttde_getOpenFileNames)( const TQString& filter, TQString* workingDirectory,
|
||
13 years ago
|
long parent, const TQCString& name, const TQString& caption, TQString* selectedFilter,
|
||
|
bool multiple );
|
||
6 years ago
|
static TQString (*tqttde_getSaveFileName)( const TQString& initialSelection, const TQString& filter,
|
||
13 years ago
|
TQString* workingDirectory, long parent, const TQCString& name, const TQString& caption,
|
||
|
TQString* selectedFilter );
|
||
6 years ago
|
static TQString (*tqttde_getExistingDirectory)( const TQString& initialDirectory, long parent,
|
||
13 years ago
|
const TQCString& name, const TQString& caption );
|
||
6 years ago
|
static TQColor (*tqttde_getColor)( const TQColor& color, long parent, const TQCString& name );
|
||
|
static TQFont (*tqttde_getFont)( bool* ok, const TQFont& def, long parent, const TQCString& name );
|
||
|
static int (*tqttde_messageBox1)( int type, long parent, const TQString& caption, const TQString& text,
|
||
13 years ago
|
int button0, int button1, int button2 );
|
||
6 years ago
|
static int (*tqttde_messageBox2)( int type, long parent, const TQString& caption, const TQString& text,
|
||
13 years ago
|
const TQString& button0Text, const TQString& button1Text, const TQString& button2Text,
|
||
|
int defaultButton, int escapeButton );
|
||
|
|
||
6 years ago
|
void TQTDEIntegration::initLibrary()
|
||
13 years ago
|
{
|
||
|
if( !inited )
|
||
|
{
|
||
|
enable = false;
|
||
|
inited = true;
|
||
|
TQString libpath = findLibrary();
|
||
|
if( libpath.isEmpty())
|
||
|
return;
|
||
|
TQLibrary lib( libpath );
|
||
|
lib.setAutoUnload( false );
|
||
6 years ago
|
tqttde_initializeIntegration = (
|
||
13 years ago
|
bool (*)( )
|
||
|
)
|
||
|
lib.resolve("initializeIntegration");
|
||
6 years ago
|
if( tqttde_initializeIntegration == NULL )
|
||
13 years ago
|
return;
|
||
6 years ago
|
tqttde_getOpenFileNames = (
|
||
13 years ago
|
TQStringList (*)( const TQString& filter, TQString* workingDirectory, long parent,
|
||
|
const TQCString& name, const TQString& caption, TQString* selectedFilter,
|
||
|
bool multiple )
|
||
|
)
|
||
|
lib.resolve("getOpenFileNames");
|
||
6 years ago
|
if( tqttde_getOpenFileNames == NULL )
|
||
13 years ago
|
return;
|
||
6 years ago
|
tqttde_getSaveFileName = (
|
||
13 years ago
|
TQString (*)( const TQString& initialSelection, const TQString& filter, TQString* workingDirectory,
|
||
|
long parent, const TQCString& name, const TQString& caption, TQString* selectedFilter )
|
||
|
)
|
||
|
lib.resolve("getSaveFileName");
|
||
6 years ago
|
if( tqttde_getSaveFileName == NULL )
|
||
13 years ago
|
return;
|
||
6 years ago
|
tqttde_getExistingDirectory = (
|
||
13 years ago
|
TQString (*)( const TQString& initialDirectory, long parent, const TQCString& name,
|
||
|
const TQString& caption )
|
||
|
)
|
||
|
lib.resolve("getExistingDirectory");
|
||
6 years ago
|
if( tqttde_getExistingDirectory == NULL )
|
||
13 years ago
|
return;
|
||
6 years ago
|
tqttde_getColor = (
|
||
13 years ago
|
TQColor (*)( const TQColor& color, long parent, const TQCString& name )
|
||
|
)
|
||
|
lib.resolve("getColor");
|
||
6 years ago
|
if( tqttde_getColor == NULL )
|
||
13 years ago
|
return;
|
||
6 years ago
|
tqttde_getFont = (
|
||
13 years ago
|
TQFont (*)( bool* ok, const TQFont& def, long parent, const TQCString& name )
|
||
|
)
|
||
|
lib.resolve("getFont");
|
||
6 years ago
|
if( tqttde_getFont == NULL )
|
||
13 years ago
|
return;
|
||
6 years ago
|
tqttde_messageBox1 = (
|
||
13 years ago
|
int (*)( int type, long parent, const TQString& caption, const TQString& text,
|
||
|
int button0, int button1, int button2 )
|
||
|
)
|
||
|
lib.resolve("messageBox1");
|
||
6 years ago
|
if( tqttde_messageBox1 == NULL )
|
||
13 years ago
|
return;
|
||
6 years ago
|
tqttde_messageBox2 = (
|
||
13 years ago
|
int (*)( int type, long parent, const TQString& caption, const TQString& text,
|
||
|
const TQString& button0Text, const TQString& button1Text, const TQString& button2Text,
|
||
|
int defaultButton, int escapeButton )
|
||
|
)
|
||
|
lib.resolve("messageBox2");
|
||
6 years ago
|
if( tqttde_messageBox2 == NULL )
|
||
13 years ago
|
return;
|
||
6 years ago
|
enable = tqttde_initializeIntegration();
|
||
13 years ago
|
}
|
||
|
}
|
||
|
|
||
6 years ago
|
bool TQTDEIntegration::initializeIntegration( )
|
||
13 years ago
|
{
|
||
6 years ago
|
return tqttde_initializeIntegration(
|
||
13 years ago
|
);
|
||
|
}
|
||
6 years ago
|
TQStringList TQTDEIntegration::getOpenFileNames( const TQString& filter, TQString* workingDirectory,
|
||
13 years ago
|
TQWidget* parent, const char* name, const TQString& caption, TQString* selectedFilter,
|
||
|
bool multiple )
|
||
|
{
|
||
6 years ago
|
return tqttde_getOpenFileNames(
|
||
13 years ago
|
filter, workingDirectory, widgetToWinId( parent ), name, caption, selectedFilter, multiple );
|
||
|
}
|
||
6 years ago
|
TQString TQTDEIntegration::getSaveFileName( const TQString& initialSelection, const TQString& filter,
|
||
13 years ago
|
TQString* workingDirectory, TQWidget* parent, const char* name, const TQString& caption,
|
||
|
TQString* selectedFilter )
|
||
|
{
|
||
6 years ago
|
return tqttde_getSaveFileName(
|
||
13 years ago
|
initialSelection, filter, workingDirectory, widgetToWinId( parent ), name, caption, selectedFilter );
|
||
|
}
|
||
6 years ago
|
TQString TQTDEIntegration::getExistingDirectory( const TQString& initialDirectory, TQWidget* parent,
|
||
13 years ago
|
const char* name, const TQString& caption )
|
||
|
{
|
||
6 years ago
|
return tqttde_getExistingDirectory(
|
||
13 years ago
|
initialDirectory, widgetToWinId( parent ), name, caption );
|
||
|
}
|
||
6 years ago
|
TQColor TQTDEIntegration::getColor( const TQColor& color, TQWidget* parent, const char* name )
|
||
13 years ago
|
{
|
||
6 years ago
|
return tqttde_getColor(
|
||
13 years ago
|
color, widgetToWinId( parent ), name );
|
||
|
}
|
||
6 years ago
|
TQFont TQTDEIntegration::getFont( bool* ok, const TQFont* def, TQWidget* parent, const char* name )
|
||
13 years ago
|
{
|
||
6 years ago
|
return tqttde_getFont(
|
||
13 years ago
|
ok, fontPtrToFontRef( def ), widgetToWinId( parent ), name );
|
||
|
}
|
||
6 years ago
|
int TQTDEIntegration::messageBox1( int type, TQWidget* parent, const TQString& caption,
|
||
13 years ago
|
const TQString& text, int button0, int button1, int button2 )
|
||
|
{
|
||
6 years ago
|
return tqttde_messageBox1(
|
||
13 years ago
|
type, widgetToWinId( parent ), caption, text, button0, button1, button2 );
|
||
|
}
|
||
6 years ago
|
int TQTDEIntegration::messageBox2( int type, TQWidget* parent, const TQString& caption,
|
||
13 years ago
|
const TQString& text, const TQString& button0Text, const TQString& button1Text, const TQString& button2Text,
|
||
|
int defaultButton, int escapeButton )
|
||
|
{
|
||
6 years ago
|
return tqttde_messageBox2(
|
||
13 years ago
|
type, widgetToWinId( parent ), caption, text, button0Text, button1Text, button2Text, defaultButton, escapeButton );
|
||
|
}
|
||
|
// ---
|
||
|
|
||
6 years ago
|
int TQTDEIntegration::information( TQWidget* parent, const TQString& caption,
|
||
13 years ago
|
const TQString& text, int button0, int button1, int button2 )
|
||
|
{
|
||
6 years ago
|
return tqttde_messageBox1(
|
||
13 years ago
|
TQMessageBox::Information, widgetToWinId( parent ), caption, text, button0, button1, button2 );
|
||
|
}
|
||
|
|
||
6 years ago
|
int TQTDEIntegration::question( TQWidget* parent, const TQString& caption,
|
||
13 years ago
|
const TQString& text, int button0, int button1, int button2 )
|
||
|
{
|
||
6 years ago
|
return tqttde_messageBox1(
|
||
13 years ago
|
TQMessageBox::Question, widgetToWinId( parent ), caption, text, button0, button1, button2 );
|
||
|
}
|
||
|
|
||
6 years ago
|
int TQTDEIntegration::warning( TQWidget* parent, const TQString& caption,
|
||
13 years ago
|
const TQString& text, int button0, int button1, int button2 )
|
||
|
{
|
||
6 years ago
|
return tqttde_messageBox1(
|
||
13 years ago
|
TQMessageBox::Warning, widgetToWinId( parent ), caption, text, button0, button1, button2 );
|
||
|
}
|
||
|
|
||
6 years ago
|
int TQTDEIntegration::critical( TQWidget* parent, const TQString& caption,
|
||
13 years ago
|
const TQString& text, int button0, int button1, int button2 )
|
||
|
{
|
||
6 years ago
|
return tqttde_messageBox1(
|
||
13 years ago
|
TQMessageBox::Critical, widgetToWinId( parent ), caption, text, button0, button1, button2 );
|
||
|
}
|
||
|
|
||
6 years ago
|
int TQTDEIntegration::information( TQWidget* parent, const TQString& caption,
|
||
13 years ago
|
const TQString& text, const TQString& button0Text, const TQString& button1Text, const TQString& button2Text,
|
||
|
int defaultButton, int escapeButton )
|
||
|
{
|
||
6 years ago
|
return tqttde_messageBox2(
|
||
13 years ago
|
TQMessageBox::Information, widgetToWinId( parent ), caption, text, button0Text, button1Text, button2Text, defaultButton, escapeButton );
|
||
|
}
|
||
|
|
||
6 years ago
|
int TQTDEIntegration::question( TQWidget* parent, const TQString& caption,
|
||
13 years ago
|
const TQString& text, const TQString& button0Text, const TQString& button1Text, const TQString& button2Text,
|
||
|
int defaultButton, int escapeButton )
|
||
|
{
|
||
6 years ago
|
return tqttde_messageBox2(
|
||
13 years ago
|
TQMessageBox::Question, widgetToWinId( parent ), caption, text, button0Text, button1Text, button2Text, defaultButton, escapeButton );
|
||
|
}
|
||
|
|
||
6 years ago
|
int TQTDEIntegration::warning( TQWidget* parent, const TQString& caption,
|
||
13 years ago
|
const TQString& text, const TQString& button0Text, const TQString& button1Text, const TQString& button2Text,
|
||
|
int defaultButton, int escapeButton )
|
||
|
{
|
||
6 years ago
|
return tqttde_messageBox2(
|
||
13 years ago
|
TQMessageBox::Warning, widgetToWinId( parent ), caption, text, button0Text, button1Text, button2Text, defaultButton, escapeButton );
|
||
|
}
|
||
|
|
||
6 years ago
|
int TQTDEIntegration::critical( TQWidget* parent, const TQString& caption,
|
||
13 years ago
|
const TQString& text, const TQString& button0Text, const TQString& button1Text, const TQString& button2Text,
|
||
|
int defaultButton, int escapeButton )
|
||
|
{
|
||
6 years ago
|
return tqttde_messageBox2(
|
||
13 years ago
|
TQMessageBox::Critical, widgetToWinId( parent ), caption, text, button0Text, button1Text, button2Text, defaultButton, escapeButton );
|
||
|
}
|