Deleted Qt4/KDE4 portions of kgtk-qt3

git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/kgtk-qt3@1230840 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
v3.5.13-sru
tpearson 13 years ago
parent f4b5a1545d
commit 3868959444

@ -16,26 +16,10 @@ set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
include(CheckFunctionExists)
check_function_exists(getpeereid HAVE_GETPEEREID)
# Cant compile Qt3/KDE3 at the same time as Qt4/KDE4...
if ("${KGTK_KDE4}" MATCHES "true" OR "${KGTK_QT4}" MATCHES "true")
if (NOT "${KGTK_KDE3}" MATCHES "false" OR NOT "${KGTK_QT3}" MATCHES "false")
set(KGTK_KDE3 "false")
set(KGTK_QT3 "false")
message("** INFORMATION: Compiling Qt4/KDE4, Qt3/KDE3 disabled")
endif (NOT "${KGTK_KDE3}" MATCHES "false" OR NOT "${KGTK_QT3}" MATCHES "false")
endif ("${KGTK_KDE4}" MATCHES "true" OR "${KGTK_QT4}" MATCHES "true")
if (NOT "${KGTK_KDE3}" MATCHES "false")
add_subdirectory(kdialogd3)
endif (NOT "${KGTK_KDE3}" MATCHES "false")
if ("${KGTK_KDE4}" MATCHES "true")
add_subdirectory(kdialogd4)
# For some reason kdialogd4 does not install unless you cd into the kdialogd4 folder?
# ...hacky fix for this...
install(PROGRAMS ${CMAKE_BINARY_DIR}/kdialogd4/kdialogd4 DESTINATION bin)
endif ("${KGTK_KDE4}" MATCHES "true")
if (NOT "${KGTK_GTK2}" MATCHES "false")
# Check if we have dlvsym...
find_library(LIBDLVSYM_LIBRARY
@ -70,11 +54,6 @@ if (NOT "${KGTK_QT3}" MATCHES "false")
add_subdirectory(qt3)
endif (NOT "${KGTK_QT3}" MATCHES "false")
if ("${KGTK_QT4}" MATCHES "true")
add_subdirectory(qt4)
endif ("${KGTK_QT4}" MATCHES "true")
install(PROGRAMS ${CMAKE_SOURCE_DIR}/kdialogd-wrapper DESTINATION bin)
install(PROGRAMS ${CMAKE_SOURCE_DIR}/kgtk-wrapper DESTINATION bin)

@ -1,16 +0,0 @@
find_package(KDE4)
find_package(Qt4)
if (KDE4_FOUND)
message("** INFORMATION: KDialogD for KDE4 will be built.")
include (KDE4Defaults)
include_directories (${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR}/common ${CMAKE_BINARY_DIR} ${KDE4_INCLUDE_DIR} ${QT_INCLUDE_DIR})
set(kdialogd4_bin_SRCS kdialogd.cpp)
kde4_add_executable(kdialogd4_bin ${kdialogd4_bin_SRCS})
set_target_properties(kdialogd4_bin PROPERTIES OUTPUT_NAME kdialogd4)
target_link_libraries(kdialogd4_bin ${KDE4_KDEUI_LIBS} ${KDE4_KIO_LIBS} ${KDE4_KIO_LIBS} ${KDE4_KDECORE_LIBRARY} kfile )
install(TARGETS kdialogd4_bin ${INSTALL_TARGETS_DEFAULT_ARGS} )
add_subdirectory(po)
else (KDE4_FOUND)
message("** ERROR : Could not locate Qt4/KDE4 headers, KDialogD for KDE4 will not be built.")
endif (KDE4_FOUND)

@ -1,759 +0,0 @@
#define USE_KWIN
#include "kdialogd.h"
#include <iostream>
#include <kdiroperator.h>
#include <kuniqueapplication.h>
#include <QtCore/QSocketNotifier>
#include <QtGui/QX11Info>
#include <kio/netaccess.h>
#include <kmessagebox.h>
#include <klocale.h>
#include <kconfig.h>
#include <kurlcombobox.h>
#ifdef USE_KWIN
#include <kwindowsystem.h>
#else
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include <fixx11h.h>
#endif
#include <sys/un.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/errno.h>
#include <kdebug.h>
#include <kdeversion.h>
#ifdef KDIALOGD_APP
#include <QtCore/QTimer>
#include <kcmdlineargs.h>
#include <kaboutdata.h>
#endif
#include <kabstractfilewidget.h>
#include <fstream>
KConfig *KDialogD::theirConfig=NULL;
#define CFG_KEY_DIALOG_SIZE "KDialogDSize"
#define CFG_TIMEOUT_GROUP "General"
#ifdef KDIALOGD_APP
#define CFG_TIMEOUT_KEY "Timeout"
#define DEFAULT_TIMEOUT 30
#endif
static QString groupName(const QString &app, bool fileDialog=true)
{
return QString(fileDialog ? "KFileDialog " : "KDirSelectDialog ")+app;
}
// from kdebase/kdesu
typedef unsigned ksocklen_t;
static int createSocket()
{
int socketFd;
ksocklen_t addrlen;
struct stat s;
const char *sock=getSockName();
int stat_err=lstat(sock, &s);
if(!stat_err && S_ISLNK(s.st_mode))
{
kWarning() << "Someone is running a symlink attack on you" ;
if(unlink(sock))
{
kWarning() << "Could not delete symlink" ;
return -1;
}
}
if (!access(sock, R_OK|W_OK))
{
kWarning() << "stale socket exists" ;
if (unlink(sock))
{
kWarning() << "Could not delete stale socket" ;
return -1;
}
}
socketFd = socket(PF_UNIX, SOCK_STREAM, 0);
if (socketFd < 0)
{
kError() << "socket(): " << strerror(errno);
return -1;
}
struct sockaddr_un addr;
addr.sun_family = AF_UNIX;
strncpy(addr.sun_path, sock, sizeof(addr.sun_path)-1);
addr.sun_path[sizeof(addr.sun_path)-1] = '\000';
addrlen = SUN_LEN(&addr);
if (bind(socketFd, (struct sockaddr *)&addr, addrlen) < 0)
{
kError() << "bind(): " << strerror(errno);
return -1;
}
struct linger lin;
lin.l_onoff = lin.l_linger = 0;
if (setsockopt(socketFd, SOL_SOCKET, SO_LINGER, (char *) &lin,
sizeof(linger)) < 0)
{
kError() << "setsockopt(SO_LINGER): " << strerror(errno);
return -1;
}
int opt = 1;
if (setsockopt(socketFd, SOL_SOCKET, SO_REUSEADDR, (char *) &opt,
sizeof(opt)) < 0)
{
kError() << "setsockopt(SO_REUSEADDR): " << strerror(errno);
return -1;
}
opt = 1;
if (setsockopt(socketFd, SOL_SOCKET, SO_KEEPALIVE, (char *) &opt,
sizeof(opt)) < 0)
{
kError() << "setsockopt(SO_KEEPALIVE): " << strerror(errno);
return -1;
}
chmod(sock, 0600);
if (listen(socketFd, 1) < 0)
{
kError() << "listen(): " << strerror(errno);
return -1;
}
return socketFd;
}
static void urls2Local(KUrl::List &urls, QStringList &items, QWidget *parent)
{
KUrl::List::Iterator it(urls.begin()),
end(urls.end());
for(; it!=end; ++it)
{
kDebug() << "URL:" << *it << " local? " << (*it).isLocalFile();
if((*it).isLocalFile())
items.append((*it).path());
else
{
KUrl url(KIO::NetAccess::mostLocalUrl(*it, parent));
kDebug() << "mostLocal:" << url << " local? " << url.isLocalFile();
if(url.isLocalFile())
items.append(url.path());
else
break;
}
}
}
KDialogD::KDialogD(QObject *parent)
: QObject(parent),
#ifdef KDIALOGD_APP
itsTimer(NULL),
itsTimeoutVal(DEFAULT_TIMEOUT),
#endif
itsFd(::createSocket()),
itsNumConnections(0)
{
if(itsFd<0)
{
kError() << "KDialogD could not create socket";
#ifdef KDIALOGD_APP
kapp->exit();
#endif
}
else
{
std::ofstream f(getPidFileName());
if(f)
{
f << getpid();
f.close();
}
if(!theirConfig)
theirConfig=new KConfig("kdialogd4rc"); // , KConfig::OnlyLocal);
connect(new QSocketNotifier(itsFd, QSocketNotifier::Read, this),
SIGNAL(activated(int)), this, SLOT(newConnection()));
#ifdef KDIALOGD_APP
if(theirConfig->hasGroup(CFG_TIMEOUT_GROUP))
{
itsTimeoutVal=KConfigGroup(theirConfig, CFG_TIMEOUT_GROUP).readEntry(CFG_TIMEOUT_KEY, DEFAULT_TIMEOUT);
if(itsTimeoutVal<0)
itsTimeoutVal=DEFAULT_TIMEOUT;
}
kDebug() << "Timeout:" << itsTimeoutVal;
if(itsTimeoutVal)
{
connect(itsTimer=new QTimer(this), SIGNAL(timeout()), this, SLOT(timeout()));
itsTimer->setSingleShot(true);
}
#endif
}
}
KDialogD::~KDialogD()
{
if(-1!=itsFd)
close(itsFd);
if(theirConfig)
delete theirConfig;
theirConfig=NULL;
}
void KDialogD::newConnection()
{
kDebug() << "New connection";
ksocklen_t addrlen = 64;
struct sockaddr_un clientname;
int connectedFD;
if((connectedFD=::accept(itsFd, (struct sockaddr *) &clientname, &addrlen))>=0)
{
int appNameLen;
if(readBlock(connectedFD, (char *)&appNameLen, 4))
{
bool ok=true;
QByteArray appName;
if(0==appNameLen)
appName="Generic";
else
{
appName.resize(appNameLen);
ok=readBlock(connectedFD, appName.data(), appNameLen);
}
if(ok)
{
itsNumConnections++;
#ifdef KDIALOGD_APP
if(itsTimer)
itsTimer->stop();
#endif
connect(new KDialogDClient(connectedFD, appName, this),
SIGNAL(error(KDialogDClient *)),
this, SLOT(deleteConnection(KDialogDClient *)));
}
}
}
}
void KDialogD::deleteConnection(KDialogDClient *client)
{
kDebug() << "Delete client";
delete client;
#ifdef KDIALOGD_APP
if(0==--itsNumConnections)
if(itsTimeoutVal)
itsTimer->start(itsTimeoutVal*1000); // Only single shot...
else
timeout();
#endif
}
void KDialogD::timeout()
{
#ifdef KDIALOGD_APP
if(0==itsNumConnections)
if(grabLock(0)>0) // 0=> no wait...
{
kDebug() << "Timeout occured, and no connections, so exit";
kapp->exit();
}
else //...unlock lock file...
{
kDebug() << "Timeout occured, but unable to grab lock file - app must be connecting";
releaseLock();
}
#endif
}
KDialogDClient::KDialogDClient(int sock, const QString &an, QObject *parent)
: QObject(parent),
itsFd(sock),
itsDlg(NULL),
itsXid(0),
itsAccepted(false),
itsAppName(an)
{
kDebug() << "new client..." << itsAppName << " (" << itsFd << ")";
connect(new QSocketNotifier(itsFd, QSocketNotifier::Read, this), SIGNAL(activated(int)), this, SLOT(read()));
connect(new QSocketNotifier(itsFd, QSocketNotifier::Exception, this), SIGNAL(activated(int)), this, SLOT(close()));
}
KDialogDClient::~KDialogDClient()
{
kDebug() << "Deleted client";
if(-1!=itsFd)
::close(itsFd);
itsDlg=NULL;
if(KDialogD::config())
KDialogD::config()->sync();
}
void KDialogDClient::close()
{
kDebug() << "close" << itsFd;
::close(itsFd);
itsFd=-1;
if(itsDlg)
{
itsDlg->close();
itsDlg->delayedDestruct();
itsDlg=NULL;
itsXid=0;
}
emit error(this);
}
void KDialogDClient::read()
{
kDebug() << "read" << itsFd;
if(-1==itsFd)
return;
char request;
QString caption;
if(!itsDlg && readData(&request, 1) && request>=(char)OP_FILE_OPEN && request<=(char)OP_FOLDER &&
readData((char *)&itsXid, 4) && readString(caption))
{
if("."==caption)
switch((Operation)request)
{
case OP_FILE_OPEN:
case OP_FILE_OPEN_MULTIPLE:
caption=i18n("Open");
break;
case OP_FILE_SAVE:
caption=i18n("Save As");
break;
case OP_FOLDER:
caption=i18n("Select Folder");
break;
default:
break;
}
if(OP_FOLDER==(Operation)request)
{
QString intialFolder;
if(readString(intialFolder))
{
initDialog(caption, new KDialogDDirSelectDialog(itsAppName, intialFolder, true, NULL, false));
return;
}
}
else
{
QString intialFolder,
filter;
char overW=0;
if(readString(intialFolder) && readString(filter) &&
(OP_FILE_SAVE!=(Operation)request || readData(&overW, 1)))
{
initDialog(caption, new KDialogDFileDialog(itsAppName, (Operation)request, intialFolder,
filter, overW ? true : false));
return;
}
}
}
kDebug() << "Comms error, closing connection..." << itsFd;
// If we get here something was wrong, close connection...
close();
}
void KDialogDClient::finished()
{
if(-1==itsFd)
return;
//
// * finished is emitted when a dialog is ok'ed/cancel'ed/closed
// * if the user just closes the dialog - neither ok nor cancel are emitted
// * the dir select dialog doesnt seem to set the QDialog result parameter
// when it is accepted - so for this reason if ok is clicked we store an
// 'accepted' value there, and check for that after the dialog is finished.
kDebug() << "finished " << (void *)itsDlg << itsAccepted << (itsDlg ? QDialog::Accepted==itsDlg->result() : false);
if(itsDlg && !(itsAccepted || QDialog::Accepted==itsDlg->result()))
cancel();
}
void KDialogDClient::ok(const QStringList &items)
{
kDebug() << "ok";
int num=items.count();
QStringList::ConstIterator it(items.begin()),
end(items.end());
bool error=!writeData((char *)&num, 4);
for(; !error && it!=end; ++it)
{
kDebug() << "writeString " << *it;
error=!writeString(*it);
}
if(error)
close();
else
itsAccepted=true;
if(itsDlg)
itsDlg->delayedDestruct();
itsDlg=NULL;
}
void KDialogDClient::cancel()
{
kDebug() << "cancel";
if(itsDlg)
{
kDebug() << "send cancel";
int rv=0;
if(!writeData((char *)&rv, 4))
{
kDebug() << "failed to write data!";
close();
}
if(itsDlg)
itsDlg->delayedDestruct();
itsDlg=NULL;
}
}
bool KDialogDClient::readData(QByteArray &buffer, int size)
{
kDebug() << "readData" << itsFd;
buffer.resize(size);
return ::readBlock(itsFd, buffer.data(), size);
}
bool KDialogDClient::readString(QString &str)
{
kDebug() << "readString" << itsFd;
int size;
if(!readData((char *)&size, 4))
return false;
QByteArray buffer;
buffer.resize(size);
if(!readData(buffer.data(), size))
return false;
str=QString::fromUtf8(buffer.data());
return true;
}
bool KDialogDClient::writeString(const QString &str)
{
kDebug() << "writeString" << itsFd;
QByteArray utf8(str.toUtf8());
int size=utf8.length()+1;
return writeData((char *)&size, 4) && writeData(utf8.data(), size);
}
void KDialogDClient::initDialog(const QString &caption, KDialog *d)
{
kDebug() << "initDialog" << itsFd;
itsAccepted=false;
itsDlg=d;
if(!caption.isEmpty())
itsDlg->setPlainCaption(caption);
if(itsXid)
itsDlg->installEventFilter(this);
connect(itsDlg, SIGNAL(okClicked()), itsDlg, SLOT(slotOk()));
connect(itsDlg, SIGNAL(ok(const QStringList &)), this, SLOT(ok(const QStringList &)));
connect(itsDlg, SIGNAL(finished()), this, SLOT(finished()));
itsDlg->show();
}
bool KDialogDClient::eventFilter(QObject *object, QEvent *event)
{
if(object==itsDlg && QEvent::ShowToParent==event->type())
{
#ifdef USE_KWIN
KWindowSystem::setMainWindow(itsDlg, itsXid);
KWindowSystem::setState(itsDlg->winId(), NET::Modal|NET::SkipTaskbar|NET::SkipPager);
#if 0
KWindowInfo wi(KWindowSystem::windowInfo(itsXid, NET::WMGeometry, NET::WM2UserTime));
QRect geom(wi.geometry());
int rx=geom.x(),
ry=geom.y();
rx=(rx+(geom.width()/2))-(itsDlg->width()/2);
if(rx<0)
rx=0;
ry=(ry+(geom.height()/2))-(itsDlg->height()/2);
if(ry<0)
ry=0;
itsDlg->move(rx, ry);
#endif
QPixmap icon=KWindowSystem::icon(itsXid, 16, 16, true, KWindowSystem::NETWM | KWindowSystem::WMHints);
if(!icon.isNull())
itsDlg->setWindowIcon(QIcon(icon));
#else
XSetTransientForHint(QX11Info::display(), itsDlg->winId(), itsXid);
#if 0
XWindowAttributes attr;
int rx, ry;
Window junkwin;
if(XGetWindowAttributes(QX11Info::display(), itsXid, &attr))
{
XTranslateCoordinates(QX11Info::display(), itsXid, attr.root,
-attr.border_width, -16,
&rx, &ry, &junkwin);
rx=(rx+(attr.width/2))-(itsDlg->width()/2);
if(rx<0)
rx=0;
ry=(ry+(attr.height/2))-(itsDlg->height()/2);
if(ry<0)
ry=0;
itsDlg->move(rx, ry);
}
#endif
// unsigned long num;
// unsigned long *data = NULL;
// Atom prop = XInternAtom(QX11Info::display(), "_NET_WM_ICON", False);
// Atom typeRet;
// int formatRet;
// unsigned long afterRet;
// if(XGetWindowProperty(QX11Info::display(), itsXid, prop, 0, 0x7FFFFFFF, False, XA_CARDINAL,
// &typeRet, &formatRet, &num, &afterRet, (unsigned char **)&data))
// {
// kDebug() << "GOT ICON!!!";
// }
// else
// kDebug() << "FAILED TO GET ICON!!!";
#endif
itsDlg->removeEventFilter(this);
}
return false;
}
KDialogDFileDialog::KDialogDFileDialog(QString &an, Operation op, const QString &startDir,
const QString &filter, bool confirmOw)
: KFileDialog(KUrl(startDir.isEmpty() || "~"==startDir ? QDir::homePath() : startDir),
filter, NULL),
itsConfirmOw(confirmOw),
itsDone(false),
itsAppName(an)
{
setModal(false);
setSelection(startDir);
kDebug() << "startDir:" << startDir;
switch(op)
{
case OP_FILE_OPEN:
setOperationMode(KFileDialog::Opening);
setMode(KFile::File|KFile::ExistingOnly);
break;
case OP_FILE_OPEN_MULTIPLE:
setOperationMode(KFileDialog::Opening);
setMode(KFile::Files|KFile::ExistingOnly);
break;
case OP_FILE_SAVE:
setOperationMode(KFileDialog::Saving);
setMode(KFile::File);
break;
default:
break;
}
if(KDialogD::config())
{
KConfigGroup cfg(KDialogD::config(), groupName(itsAppName));
//TODO !!! readConfig(KDialogD::config(), grp);
resize(cfg.readEntry(CFG_KEY_DIALOG_SIZE, QSize(600, 400)));
}
//TODO !!! ops->clearHistory();
}
void KDialogDFileDialog::accept()
{
fileWidget()->accept();
kDebug() << "KDialogDFileDialog::slotOk" << selectedUrls().count() << ' ' << mode() << ' ' << selectedUrl().prettyUrl();
KUrl::List urls(selectedUrls());
QStringList items;
bool good=true;
if(urls.count())
{
urls2Local(urls, items, this);
if(urls.count()!=items.count())
{
KMessageBox::sorry(this, i18n("You can only select local files."),
i18n("Remote Files Not Accepted"));
good=false;
}
else if(itsConfirmOw && KFileDialog::Saving==operationMode())
good=!KIO::NetAccess::exists(urls.first(), KIO::NetAccess::DestinationSide, this) ||
KMessageBox::Continue==KMessageBox::warningContinueCancel(this,
i18n("File %1 exits.\nDo you want to replace it?")
.arg(urls.first().prettyUrl()),
i18n("File Exists"),
KGuiItem(i18n("Replace"), "filesaveas"), KStandardGuiItem::cancel(), QString(),
KMessageBox::Notify|KMessageBox::PlainCaption);
if(good)
{
QString filter(currentFilter());
if(!filter.isEmpty())
items.append(filter);
emit ok(items);
hide();
//KFileDialog::accept();
}
else
setResult(QDialog::Rejected);
}
}
KDialogDFileDialog::~KDialogDFileDialog()
{
kDebug() << "~KDialogDFileDialog";
if(KDialogD::config())
{
KConfigGroup cfg(KDialogD::config(), groupName(itsAppName));
//TODO !!! writeConfig(KDialogD::config(), grp);
cfg.writeEntry(CFG_KEY_DIALOG_SIZE, size());
}
}
KDialogDDirSelectDialog::KDialogDDirSelectDialog(QString &an, const QString &startDir, bool localOnly,
QWidget *parent, bool modal)
: KDirSelectDialog(KUrl(startDir.isEmpty() || "~"==startDir
? QDir::homePath() : startDir),
localOnly, parent),
itsAppName(an)
{
kDebug() << "startDir:" << startDir;
setModal(false);
if(KDialogD::config())
{
KConfigGroup cfg(KDialogD::config(), groupName(itsAppName, false));
//TODO !!! readConfig(KDialogD::config(), grp);
resize(cfg.readEntry(CFG_KEY_DIALOG_SIZE, QSize(600, 400)));
}
}
KDialogDDirSelectDialog::~KDialogDDirSelectDialog()
{
kDebug() << "~KDialogDDirSelectDialog";
if(KDialogD::config())
{
KConfigGroup cfg(KDialogD::config(), groupName(itsAppName, false));
//TODO !!! writeConfig(KDialogD::config(), grp);
cfg.writeEntry(CFG_KEY_DIALOG_SIZE, size());
}
}
void KDialogDDirSelectDialog::slotOk()
{
kDebug() << "KDialogDDirSelectDialog::slotOk";
KUrl::List urls;
QStringList items;
urls.append(url());
urls2Local(urls, items, this);
if(urls.count()!=items.count())
KMessageBox::sorry(this, i18n("You can only select local folders."),
i18n("Remote Folders Not Accepted"));
else
{
emit ok(items);
hide();
}
}
#ifdef KDIALOGD_APP
static KAboutData aboutData("kdialogd4", "kdialogd4", ki18n("KDialog Daemon"), VERSION,
ki18n("Use KDE dialogs from non-KDE apps."),
KAboutData::License_GPL,
ki18n("(c) Craig Drummond, 2006-2007"));
int main(int argc, char **argv)
{
KCmdLineArgs::init(argc, argv, &aboutData);
KUniqueApplication *app=new KUniqueApplication;
KDialogD kdialogd;
QApplication::setQuitOnLastWindowClosed(false);
int rv=app->exec();
delete app;
unlink(getSockName());
releaseLock();
return rv;
}
#else
extern "C"
{
KDE_EXPORT KDEDModule *create_kdialogd()
{
return new KDialogDKDED();
}
};
KDialogDKDED::KDialogDKDED()
: KDEDModule()
{
new KDialogD(this);
}
#endif
#include "kdialogd.moc"

@ -1,146 +0,0 @@
#ifndef __KDIALOGD_H__
#define __KDIALOGD_H__
#include <kfile.h>
#include <kfiledialog.h>
#include <kfiledialog.h>
#include <kdirselectdialog.h>
#include "common.h"
#include "config.h"
#ifdef KDIALOGD_APP
class QTimer;
#else
#include <kdedmodule.h>
#endif
class KDialog;
class KConfig;
class KDialogDFileDialog : public KFileDialog
{
Q_OBJECT
public:
KDialogDFileDialog(QString &an, Operation op, const QString& startDir, const QString& filter,
bool confirmOw);
virtual ~KDialogDFileDialog();
public slots:
void accept();
signals:
void ok(const QStringList &items);
private:
bool itsConfirmOw,
itsDone;
QString &itsAppName;
};
class KDialogDDirSelectDialog : public KDirSelectDialog
{
Q_OBJECT
public:
KDialogDDirSelectDialog(QString &an, const QString &startDir = QString(),
bool localOnly = false, QWidget *parent = 0L,
bool modal = false);
virtual ~KDialogDDirSelectDialog();
public slots:
void slotOk();
signals:
void ok(const QStringList &items);
private:
QString &itsAppName;
};
class KDialogDClient : public QObject
{
Q_OBJECT
public:
KDialogDClient(int sock, const QString &an, QObject *parent);
virtual ~KDialogDClient();
public slots:
void read();
void close();
void ok(const QStringList &items);
void finished();
signals:
void error(KDialogDClient *);
private:
void cancel();
bool readData(QByteArray &buffer, int size);
bool readData(char *buffer, int size) { return readBlock(itsFd, buffer, size); }
bool writeData(const char *buffer, int size) { return writeBlock(itsFd, buffer, size); }
bool readString(QString &str);
bool writeString(const QString &str);
void initDialog(const QString &caption, KDialog *d);
bool eventFilter(QObject *object, QEvent *event);
private:
int itsFd;
KDialog *itsDlg;
unsigned int itsXid;
bool itsAccepted;
QString itsAppName;
};
class KDialogD : public QObject
{
Q_OBJECT
public:
KDialogD(QObject *parent=0L);
virtual ~KDialogD();
public slots:
void newConnection();
void deleteConnection(KDialogDClient *client);
void timeout();
static KConfig * config() { return theirConfig; }
private:
#ifdef KDIALOGD_APP
QTimer *itsTimer;
int itsTimeoutVal;
#endif
int itsFd,
itsNumConnections;
static KConfig *theirConfig;
};
#ifndef KDIALOGD_APP
class KDialogDKDED : public KDEDModule
{
public:
KDialogDKDED();
};
#endif
#endif

@ -1,41 +0,0 @@
find_package(Msgfmt REQUIRED)
# .po to .gmo stuff
file(GLOB _pofiles *.po)
foreach(_file ${_pofiles})
get_filename_component(_file_we ${_file} NAME_WE)
set(_out "${CMAKE_CURRENT_BINARY_DIR}/${_file_we}.gmo")
set(_in "${_file_we}.po")
add_custom_command(OUTPUT ${_out} COMMAND ${MSGFMT_EXECUTABLE} -o ${_out} ${_file} DEPENDS ${_file})
install(FILES ${_out} DESTINATION share/locale/${_file_we}/LC_MESSAGES/ RENAME kdialogd4.mo)
set(_outputs ${_outputs} ${_out})
endforeach(_file)
add_custom_target(pofiles ALL DEPENDS ${_outputs})
# Stuff to generate the .pot
set(POT_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/../kdialogd.cpp)
set(POT_OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/kdialogd4.pot)
# Find xgettext
find_program(XGETTEXT_PATH NAMES "xgettext" PATHS "/usr/bin" "/usr/local/bin")
if(${XGETTEXT_PATH} STREQUAL "XGETTEXT_PATH-NOTFOUND")
message(STATUS "xgettext not found. You will not be able to run 'make extract_messages' in the 'po' directory.")
else(${XGETTEXT_PATH} STREQUAL "XGETTEXT_PATH-NOTFOUND")
message(STATUS "Found xgettext: ${XGETTEXT_PATH}")
endif(${XGETTEXT_PATH} STREQUAL "XGETTEXT_PATH-NOTFOUND")
if(EXISTS ${KDE4_INCLUDE_DIR}/kde.pot)
add_custom_command(
OUTPUT ${POT_OUTPUT}
COMMAND ${XGETTEXT_PATH} --foreign-user -C -ci18n -ki18n -ktr2i18n -kI18N_NOOP -kI18N_NOOP2 -kaliasLocale -x "${KDE4_INCLUDE_DIR}/kde.pot" -o ${POT_OUTPUT} ${POT_SOURCES}
)
else (EXISTS ${KDE4_INCLUDE_DIR}/kde.pot)
add_custom_command(
OUTPUT ${POT_OUTPUT}
COMMAND ${XGETTEXT_PATH} --foreign-user -C -ci18n -ki18n -ktr2i18n -kI18N_NOOP -kI18N_NOOP2 -kaliasLocale -o ${POT_OUTPUT} ${POT_SOURCES}
)
endif (EXISTS ${KDE4_INCLUDE_DIR}/kde.pot)
add_custom_target(extract_messages DEPENDS ${POT_OUTPUT})

@ -1,61 +0,0 @@
# translation of cs.po to Česky
# This file is put in the public domain.
#
# Marián Kyral <mkyral@email.cz>, 2007.
msgid ""
msgstr ""
"Project-Id-Version: cs\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2007-09-21 15:08+0100\n"
"PO-Revision-Date: 2007-10-16 05:41+0200\n"
"Last-Translator: Marián Kyral <mkyral@email.cz>\n"
"Language-Team: Česky <cs@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: KBabel 1.11.4\n"
"Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;\n"
#: kdialogd.cpp:331
msgid "Open"
msgstr "Otevřít"
#: kdialogd.cpp:334
msgid "Save As"
msgstr "Uložit jako"
#: kdialogd.cpp:337
msgid "Select Folder"
msgstr "Vyberte složku"
#: kdialogd.cpp:627
msgid "You can only select local files."
msgstr "Můžete vybrat pouze místní soubory."
#: kdialogd.cpp:628
msgid "Remote Files Not Accepted"
msgstr "Vzdálené soubory nejsou akceptovány."
#: kdialogd.cpp:634
msgid ""
"File %1 exits.\n"
"Do you want to replace it?"
msgstr ""
"Soubor %1 existuje.\n"
"Chcete jej přepsat?"
#: kdialogd.cpp:636
msgid "File Exists"
msgstr "Soubor existuje."
#: kdialogd.cpp:637
msgid "Replace"
msgstr "Přepiš"
#: kdialogd.cpp:712
msgid "You can only select local folders."
msgstr "Můžete vybrat pouze místní složky."
#: kdialogd.cpp:713
msgid "Remote Folders Not Accepted"
msgstr "Vzdálené složky nejsou akceptovány."

@ -1,62 +0,0 @@
# translation of kdialogd4.po to Deutsch
# This file is put in the public domain.
#
# Jannick Kuhr <opensource@kuhr.org>, 2007.
msgid ""
msgstr ""
"Project-Id-Version: kdialogd4\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2007-09-21 15:08+0100\n"
"PO-Revision-Date: 2007-10-11 13:28+0200\n"
"Last-Translator: Jannick Kuhr <opensource@kuhr.org>\n"
"Language-Team: Deutsch <kde-i18n-de@kde.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: KBabel 1.11.4\n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
#:kdialogd.cpp:331
msgid "Open"
msgstr "Öffnen"
#:kdialogd.cpp:334
msgid "Save As"
msgstr "Speichern unter"
#:kdialogd.cpp:337
msgid "Select Folder"
msgstr "Ordner wählen"
#:kdialogd.cpp:627
msgid "You can only select local files."
msgstr "Sie können nur lokale Dateien auswählen."
#:kdialogd.cpp:628
msgid "Remote Files Not Accepted"
msgstr "Dateien von Fremdrechnern werden nicht akzeptiert."
#:kdialogd.cpp:634
msgid ""
"File %1 exits.\n"
"Do you want to replace it?"
msgstr ""
"Die Datei %1 exisitiert bereits.\n"
"Wollen Sie sie ersetzen?"
#:kdialogd.cpp:636
msgid "File Exists"
msgstr "Datei existiert bereits"
#:kdialogd.cpp:637
msgid "Replace"
msgstr "Ersetzen"
#:kdialogd.cpp:712
msgid "You can only select local folders."
msgstr "Sie können nur lokale Ordner auswählen."
#:kdialogd.cpp:713
msgid "Remote Folders Not Accepted"
msgstr "Ordner von Fremdrechnern werden nicht akzeptiert."

@ -1,60 +0,0 @@
# translation of kdialogd4.po to British English
# Copyright (C) 2007 Craig Drummond <Craig.Drummond@lycos.co.uk>
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: kdialogd4\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2007-09-21 14:40+0100\n"
"PO-Revision-Date: 2007-10-05 22:35+0200\n"
"Last-Translator: Craig Drummond <Craig.Drummond@lycos.co.uk>\n"
"Language-Team: Craig Drummond <Craig.Drummond@lycos.co.uk>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=iso-8859-1\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=1; plural=0;\n"
#: kdialogd.cpp:328
msgid "Select Folder"
msgstr "Select Folder"
#: kdialogd.cpp:573
msgid "You can only select local files."
msgstr "You can only select local files."
#: kdialogd.cpp:574
msgid "Remote Files Not Accepted"
msgstr "Remote Files Not Accepted"
#: kdialogd.cpp:580
msgid ""
"File %1 exits.\n"
"Do you want to replace it?"
msgstr ""
"File %1 exits.\n"
"Do you want to replace it?"
#: kdialogd.cpp:582
msgid "File Exists"
msgstr "File Exists"
#: kdialogd.cpp:667
msgid "You can only select local folders."
msgstr "You can only select local folders."
#: kdialogd.cpp:668
msgid "Remote Folders Not Accepted"
msgstr "Remote Folders Not Accepted"
#: kdialogd.cpp:677
msgid "KDialog Daemon"
msgstr "KDialog Daemon"
#: kdialogd.cpp:678
msgid "Use KDE dialogs from non-KDE apps."
msgstr "Use KDE dialogs from non-KDE apps."
#: kdialogd.cpp:680
msgid "(c) Craig Drummond, 2006-2007"
msgstr "(c) Craig Drummond, 2006-2007"

@ -1,56 +0,0 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2007-09-21 15:08+0100\n"
"PO-Revision-Date: 2007-10-19 18:06+0200\n"
"Last-Translator: Marco Antonio Blanco <mablanco@activasistemas.com>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Pootle 0.10.1\n"
#: kdialogd.cpp:331
msgid "Open"
msgstr "Abrir"
#: kdialogd.cpp:334
msgid "Save As"
msgstr "Guardar como"
#: kdialogd.cpp:337
msgid "Select Folder"
msgstr "Seleccione carpeta"
#: kdialogd.cpp:627
msgid "You can only select local files."
msgstr "Sólo se pueden seleccionar ficheros locales."
#: kdialogd.cpp:628
msgid "Remote Files Not Accepted"
msgstr "No se aceptan ficheros remotos"
#: kdialogd.cpp:634
msgid ""
"File %1 exits.\n"
"Do you want to replace it?"
msgstr ""
"El fichero %1 existe.\n"
"¿Quiere sustituirlo?"
#: kdialogd.cpp:636
msgid "File Exists"
msgstr "El fichero existe"
#: kdialogd.cpp:637
msgid "Replace"
msgstr "Sustituir"
#: kdialogd.cpp:712
msgid "You can only select local folders."
msgstr "Sólo se pueden seleccionar carpetas locales."
#: kdialogd.cpp:713
msgid "Remote Folders Not Accepted"
msgstr "No se aceptan carpetas remotas"

@ -1,60 +0,0 @@
# translation of kdialogd4.po to French
# Copyright (C) 2007 aul Thomas <pw1517@gmail.com>
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: kdialogd4\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2007-09-21 14:40+0100\n"
"PO-Revision-Date: 2007-10-06 17:54+0200\n"
"Last-Translator: Paul Thomas <pw1517@gmail.com>\n"
"Language-Team: Paul Thomas <pw1517@gmail.com>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=1; plural=0;\n"
#: kdialogd.cpp:328
msgid "Select Folder"
msgstr "Sélectionnez le dossier"
#: kdialogd.cpp:573
msgid "You can only select local files."
msgstr "Vous ne pouvez sélectionner que des fichiers locaux."
#: kdialogd.cpp:574
msgid "Remote Files Not Accepted"
msgstr "Les fichiers distants ne sont pas acceptés"
#: kdialogd.cpp:580
msgid ""
"File %1 exits.\n"
"Do you want to replace it?"
msgstr ""
"Le fichier %1 exite déjà.\n"
"Voulez-vous le remplacer"
#: kdialogd.cpp:582
msgid "File Exists"
msgstr "Le Fichier existe déjà"
#: kdialogd.cpp:667
msgid "You can only select local folders."
msgstr "Vous ne pouvez sélectionner que des dossiers locaux."
#: kdialogd.cpp:668
msgid "Remote Folders Not Accepted"
msgstr "Les dossiers distants ne sont pas acceptés"
#: kdialogd.cpp:677
msgid "KDialog Daemon"
msgstr "KDialog Daemon"
#: kdialogd.cpp:678
msgid "Use KDE dialogs from non-KDE apps."
msgstr "Utilisez les dialogues KDE à partir d'applications non-KDE."
#: kdialogd.cpp:680
msgid "(c) Craig Drummond, 2006-2007"
msgstr "(c) Craig Drummond, 2006-2007"

@ -1,58 +0,0 @@
# SOME DESCRIPTIVE TITLE.
# This file is put in the public domain.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2007-09-21 15:08+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
#: kdialogd.cpp:331
msgid "Open"
msgstr ""
#: kdialogd.cpp:334
msgid "Save As"
msgstr ""
#: kdialogd.cpp:337
msgid "Select Folder"
msgstr ""
#: kdialogd.cpp:627
msgid "You can only select local files."
msgstr ""
#: kdialogd.cpp:628
msgid "Remote Files Not Accepted"
msgstr ""
#: kdialogd.cpp:634
msgid ""
"File %1 exits.\n"
"Do you want to replace it?"
msgstr ""
#: kdialogd.cpp:636
msgid "File Exists"
msgstr ""
#: kdialogd.cpp:637
msgid "Replace"
msgstr ""
#: kdialogd.cpp:712
msgid "You can only select local folders."
msgstr ""
#: kdialogd.cpp:713
msgid "Remote Folders Not Accepted"
msgstr ""

@ -1,60 +0,0 @@
# translation of kdialogd4.po to Brazillian Portuguese
# This file is put in the public domain.
#
# Márcio Moraes <marcio.moraes@redlinks.com.br>, 2007.
msgid ""
msgstr ""
"Project-Id-Version: kdialogd4\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2007-09-21 15:08+0100\n"
"PO-Revision-Date: 2008-02-26 11:47-0300\n"
"Last-Translator: Márcio Moraes <marcio.moraes@redlinks.com.br>\n"
"Language-Team: Márcio Moraes <marcio.moraes@redlinks.com.br>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=iso-8859-1\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=1; plural=0;\n"
#: kdialogd.cpp:331
msgid "Open"
msgstr "Abrir"
#: kdialogd.cpp:334
msgid "Save As"
msgstr "Salvar Como"
#: kdialogd.cpp:337
msgid "Select Folder"
msgstr "Selecionar Pasta"
#: kdialogd.cpp:627
msgid "You can only select local files."
msgstr "Selecione apenas arquivos locais."
#: kdialogd.cpp:628
msgid "Remote Files Not Accepted"
msgstr "Arquivos remotos não são aceitos"
#: kdialogd.cpp:634
msgid ""
"File %1 exits.\n"
"Do you want to replace it?"
msgstr ""
"Arquivo %1 exite.\n"
"Você realmente deseja sobrescrever?"
#: kdialogd.cpp:636
msgid "File Exists"
msgstr "Arquivo Existe"
#: kdialogd.cpp:637
msgid "Replace"
msgstr "Sobrescrever"
#: kdialogd.cpp:712
msgid "You can only select local folders."
msgstr "Selecione apenas pastas locais."
#: kdialogd.cpp:713
msgid "Remote Folders Not Accepted"
msgstr "Pastas remotas não são aceitas"

@ -1,62 +0,0 @@
# translation of ru.po to
# This file is put in the public domain.
#
# Yarodin <yarodin@gmail.com>, 2008.
msgid ""
msgstr ""
"Project-Id-Version: kdialogd3\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2007-09-21 14:40+0100\n"
"PO-Revision-Date: 2008-05-01 19:31+0600\n"
"Last-Translator: Yarodin <yarodin@gmail.com>\n"
"Language-Team: Russian <kde-i18n-ru@kde.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: KBabel 1.11.4\n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
#: kdialogd.cpp:328
msgid "Select Folder"
msgstr "Выбор папки"
#: kdialogd.cpp:573
msgid "You can only select local files."
msgstr "Вы можете выбрать только локальные файлы."
#: kdialogd.cpp:574
msgid "Remote Files Not Accepted"
msgstr "Файлы на удаленной машине недоступны"
#: kdialogd.cpp:580
msgid ""
"File %1 exits.\n"
"Do you want to replace it?"
msgstr ""
"Файл %1 уже существует.\n"
"Хотите его перезаписать?"
#: kdialogd.cpp:582
msgid "File Exists"
msgstr "Файл существует"
#: kdialogd.cpp:667
msgid "You can only select local folders."
msgstr "Вы можете выбрать только локальные папки."
#: kdialogd.cpp:668
msgid "Remote Folders Not Accepted"
msgstr "Сетевые папки недоступны."
#: kdialogd.cpp:677
msgid "KDialog Daemon"
msgstr "KDialog-Демон"
#: kdialogd.cpp:678
msgid "Use KDE dialogs from non-KDE apps."
msgstr "Использование KDE диалогов в Не-KDE приложениях."
#: kdialogd.cpp:680
msgid "(c) Craig Drummond, 2006-2007"
msgstr "(c) Craig Drummond, 2006-2007"

@ -1,60 +0,0 @@
# translation of kdialogd4.po to Chinese Simplified
# Copyright (C) 2007 Free Software Foundation, Inc.
#
# Liang Qi <cavendish.qi@gmail.com>, 2007.
msgid ""
msgstr ""
"Project-Id-Version: kdialogd4\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2007-09-21 14:40+0100\n"
"PO-Revision-Date: 2007-10-05 13:20+0200\n"
"Last-Translator: Liang Qi <cavendish.qi@gmail.com>\n"
"Language-Team: zh_CN <kde-china@kde.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=1; plural=0;\n"
#: kdialogd.cpp:328
msgid "Select Folder"
msgstr "选择文件夹"
#: kdialogd.cpp:573
msgid "You can only select local files."
msgstr "仅允许选择本地文件。"
#: kdialogd.cpp:574
msgid "Remote Files Not Accepted"
msgstr "无法接受远程文件"
#: kdialogd.cpp:580
msgid ""
"File %1 exits.\n"
"Do you want to replace it?"
msgstr ""
"文件 %1 已经存在。\n"
"您想替换它么?"
#: kdialogd.cpp:582
msgid "File Exists"
msgstr "文件已存在"
#: kdialogd.cpp:667
msgid "You can only select local folders."
msgstr "仅允许选择本地文件夹。"
#: kdialogd.cpp:668
msgid "Remote Folders Not Accepted"
msgstr "无法接受远程文件夹"
#: kdialogd.cpp:677
msgid "KDialog Daemon"
msgstr "KDialog 守护进程"
#: kdialogd.cpp:678
msgid "Use KDE dialogs from non-KDE apps."
msgstr "在非 KDE 程序中使用 KDE 对话框。"
#: kdialogd.cpp:680
msgid "(c) Craig Drummond, 2006-2007"
msgstr "(c) Craig Drummond, 2006-2007"

@ -1,22 +0,0 @@
find_package(Qt4)
if (QT4_FOUND)
message("** INFORMATION: Qt4 LD_PRELOAD library will be built.")
# set(LIB_SUFFIX "" CACHE STRING "Define suffix of directory name (32/64)" )
set(LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}" CACHE PATH "The subdirectory relative to the install prefix where libraries will be installed (default is /lib${LIB_SUFFIX})" FORCE)
ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/mangled.h
COMMAND ${CMAKE_SOURCE_DIR}/mangled.sh ${CMAKE_CXX_COMPILER} ${CMAKE_CURRENT_BINARY_DIR}/mangled.h)
include_directories (${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR}/common ${CMAKE_BINARY_DIR} ${QT_INCLUDE_DIR})
set(kqt4_SRCS kqt4.cpp mangled.h)
add_definitions(${QT_DEFINITIONS} -DQT_CLEAN_NAMESPACE -DQT_THREAD_SUPPORT)
add_library(kqt4 SHARED ${kqt4_SRCS})
target_link_libraries(kqt4 ${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY} -lc -ldl)
install(TARGETS kqt4 LIBRARY DESTINATION ${LIB_INSTALL_DIR}/kgtk)
configure_file (kqt4-wrapper.cmake ${CMAKE_CURRENT_BINARY_DIR}/kqt4-wrapper @ONLY)
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/kqt4-wrapper DESTINATION bin)
else (QT4_FOUND)
message("** ERROR : Could not locate Qt4 headers, Qt4 LD_PRELOAD library will not be built.")
endif (QT4_FOUND)

@ -1,29 +0,0 @@
#!/bin/bash
#
# This script is part of the KGtk package.
#
# (C) Craig Drummond, 2007
#
# Craig.Drummond@lycos.co.uk
#
# --
# Released under the GPL v2 or later
# --
#
app=`basename $0`
if [ "$app" = "kqt4-wrapper" ] ; then
LD_PRELOAD=@CMAKE_INSTALL_PREFIX@/lib/kgtk/libkqt4.so:$LD_PRELOAD "$@"
else
dir=`dirname $0`
oldPath=$PATH
PATH=`echo $PATH | sed s:$dir::g`
real=`which $app`
PATH=$oldPath
if [ "$real" != "" ] && [ "`dirname $real`" != "$dir" ] ; then
LD_PRELOAD=@CMAKE_INSTALL_PREFIX@/lib@LIB_SUFFIX@/kgtk/libkqt4.so:$LD_PRELOAD $real "$@"
fi
fi

@ -1,599 +0,0 @@
/************************************************************************
*
* All dialogs opened are created and used modal.
*
************************************************************************
* (C) Craig Drummond, 2006
************************************************************************
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
************************************************************************/
#define KQT_OVERLOAD_NON_STATIC_FILEDIALOGS
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include <dlfcn.h>
#include <fcntl.h>
#include <string.h>
#include <errno.h>
#include <signal.h>
#include <sys/wait.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <pwd.h>
#include <errno.h>
#include <string.h>
#include <sys/types.h>
#include <QtCore/QString>
#include <QtCore/QStringList>
#include <QtGui/QWidget>
#include <QtGui/QApplication>
#include <QtCore/QTextStream>
#include <QtGui/QCloseEvent>
#include <QtGui/QFileDialog>
#include <QtCore/QThread>
#include <QtCore/Qt>
#include <QtCore/QEventLoop>
#include "connect.h"
#include "config.h"
#include "mangled.h"
static bool useKde=false;
#define MAX_LINE_LEN 1024
#define MAX_APP_NAME_LEN 32
static char * getAppNameFromPid(int pid)
{
static char appName[MAX_APP_NAME_LEN+1]="\0";
int procFile=-1;
char cmdline[MAX_LINE_LEN+1];
sprintf(cmdline, "/proc/%d/cmdline",pid);
if(-1!=(procFile=open(cmdline, O_RDONLY)))
{
if(read(procFile, cmdline, MAX_LINE_LEN)>7)
{
int len=strlen(cmdline),
pos=0;
for(pos=len-1; pos>0 && cmdline[pos] && cmdline[pos]!='/'; --pos)
;
if(pos>=0 && pos<len)
{
strncpy(appName, &cmdline[pos ? pos+1 : 0], MAX_APP_NAME_LEN);
appName[MAX_APP_NAME_LEN]='\0';
}
}
close(procFile);
}
return appName;
}
static const char * getAppName(bool useQt=true)
{
static const char *appName=NULL;
if(!appName)
{
const char *a=useQt && QCoreApplication::arguments().count()
? QCoreApplication::arguments()[0].toLatin1().constData() : getAppNameFromPid(getpid());
char *slash;
// Was the cmdline app java? if so, try to use its parent name - just in case
// its run from a shell script, etc. - e.g. as eclipse does
if(a && 0==strcmp(a, "java"))
a=getAppNameFromPid(getppid());
if(a && a[0]=='\0')
a=NULL;
appName=a && (slash=strrchr(a, '/')) && '\0'!=slash[1]
? &(slash[1])
: a ? a : "Qt4App";
}
return appName;
}
int QApplication::exec()
{
static bool init=false;
if(!init)
{
connectToKDialogD(getAppName(false));
init=true;
}
static int (*realFunction)(void);
if(!realFunction)
realFunction = (int (*)(void)) dlsym(RTLD_NEXT, KQT_QAPPLICATION_EXEC);
return (int)realFunction();
};
static QString qt2KdeFilter(const QString &f)
{
QString filter;
QTextStream str(&filter, QIODevice::WriteOnly);
QStringList list(f.split(";;"));
QStringList::Iterator it(list.begin()),
end(list.end());
bool first=true;
for(; it!=end; ++it)
{
int ob=(*it).lastIndexOf('('),
cb=(*it).lastIndexOf(')');
if(-1!=cb && ob<cb)
{
if(first)
first=false;
else
str << '\n';
str << (*it).mid(ob+1, (cb-ob)-1) << '|' << (*it).mid(0, ob);
}
}
return filter;
}
static void kde2QtFilter(const QString &orig, QString *sel)
{
if(sel)
{
QStringList list(orig.split(";;"));
QStringList::Iterator it(list.begin()),
end(list.end());
int pos;
for(; it!=end; ++it)
if(-1!=(pos=(*it).indexOf(*sel)) && pos>0 &&
('('==(*it)[pos-1] || ' '==(*it)[pos-1]) &&
(*it).length()>=sel->length()+pos &&
(')'==(*it)[pos+sel->length()] || ' '==(*it)[pos+sel->length()]))
{
*sel=*it;
return;
}
}
}
#ifdef KQT_OVERLOAD_NON_STATIC_FILEDIALOGS
static const QString getFilters(QFileDialog *dlg, bool scribusSave=false)
{
QString filter;
if(dlg)
{
QStringList filters(dlg->filters());
QStringList::ConstIterator it(filters.begin()),
end(filters.end());
bool first(true);
QTextStream str(&filter, QIODevice::WriteOnly);
for(; it!=end; ++it)
{
if(!first)
str << ";;";
if(scribusSave && -1!=(*it).indexOf("(*.sla *.sla.gz *.scd *scd.gz)"))
str << "Compressed Documents (*.sla.gz *scd.gz);;Documents (*.sla *.scd)";
else
str << (*it);
first=false;
}
}
return filter;
}
static QString getDir(const QString &f)
{
QString d(f);
int slashPos=d.lastIndexOf('/');
if(slashPos!=-1)
d.remove(slashPos+1, d.length());
return d;
}
#endif
static bool writeString(int fd, const QString &str)
{
QByteArray utf8(str.toUtf8());
int size=utf8.length()+1;
return writeBlock(fd, (char *)&size, 4) && writeBlock(fd, utf8.data(), size);
}
static bool writeBool(int fd, bool b)
{
char bv=b ? 1 : 0;
return writeBlock(fd, (char *)&bv, 1);
}
class KQtDialog : public QDialog
{
public:
KQtDialog(QWidget *parent) : QDialog(parent, Qt::FramelessWindowHint|Qt::X11BypassWindowManagerHint)
{
setModal(true);
resize(1, 1);
setWindowOpacity(0);
setWindowState(Qt::WindowMinimized);
move(32768, 32768);
}
/* void r() { QDialog::reject(); }*/
};
class KQtThread : public QThread
{
public:
KQtThread(QStringList &l, QString &s, int f, KQtDialog *dlg) : dialog(dlg), kdialogdError(false), res(l), selFilter(s), fd(f)
{ }
bool readData(QByteArray &buffer, int size)
{
buffer.resize(size);
return ::readBlock(fd, buffer.data(), size);
}
bool readString(QString &str, int size)
{
QByteArray buffer;
buffer.resize(size);
if(!readBlock(fd, buffer.data(), size))
return false;
str=QString::fromUtf8(buffer.data());
return true;
}
void run()
{
QString buffer;
int num=0;
if(readBlock(fd, (char *)&num, 4))
{
int n;
for(n=0; n<num && !kdialogdError; ++n)
{
int size=0;
if(readBlock(fd, (char *)&size, 4))
{
if(size>0)
{
if(readString(buffer, size))
{
//buffer[size-1]='\0';
if('/'==buffer[0])
res.append(buffer);
else
selFilter=buffer;
}
else
kdialogdError=true;
}
}
else
kdialogdError=true;
}
}
else
kdialogdError=true;
QCoreApplication::postEvent(dialog, new QCloseEvent);
}
KQtDialog *dialog;
bool kdialogdError;
QStringList &res;
QString &selFilter;
int fd;
};
static bool sendMessage(QWidget *parent, Operation op, QStringList &res, QString &selFilter,
const QString &title, const QString &p1, const QString *p2, bool ow)
{
if(connectToKDialogD(getAppName()))
{
char o=(char)op;
int xid=parent ? parent->topLevelWidget()->winId() : qApp->activeWindow()->winId();
if(writeBlock(kdialogdSocket, &o, 1) &&
writeBlock(kdialogdSocket, (char *)&xid, 4) &&
writeString(kdialogdSocket, title) &&
writeString(kdialogdSocket, p1) &&
(p2? writeString(kdialogdSocket, *p2) : true) &&
(OP_FILE_SAVE==op ? writeBool(kdialogdSocket, ow) : true))
{
KQtDialog dlg(parent);
KQtThread thread(res, selFilter, kdialogdSocket, &dlg);
thread.start();
dlg.exec();
thread.wait();
if(thread.kdialogdError)
{
closeConnection();
return false;
}
return true;
}
}
return false;
}
static QString getTitle(const QString &title, Operation op)
{
if(!title.isEmpty())
return title;
return ".";
}
static bool openKdeDialog(QWidget *widget, const QString &title, const QString &p1, const QString *p2,
Operation op, QStringList &res, QString *selFilter, bool ow=false)
{
QString filter;
bool rv=sendMessage(widget, op, res, filter, getTitle(title, op), p1, p2, ow);
// If we failed to talk to, or start kdialogd, then dont keep trying - just fall back to Qt
if(!rv)
/*useKde=false*/;
else if(selFilter)
*selFilter=filter;
return rv;
}
static void kqtExit()
{
if(useKde)
closeConnection();
}
static bool kqtInit()
{
static bool initialised=false;
if(!initialised)
{
initialised=true;
useKde=NULL!=getenv("KDE_FULL_SESSION") && connectToKDialogD(getAppName());
if(useKde)
atexit(&kqtExit);
}
return useKde;
}
static QString lastDir;
static void storeLastDir(const QString &f)
{
lastDir=f;
int slashPos(lastDir.lastIndexOf('/'));
if(slashPos!=-1)
lastDir.remove(slashPos+1, lastDir.length());
}
static const QString & startDir(const QString &d)
{
return d.isEmpty() ? lastDir : d;
}
QString QFileDialog::getOpenFileName(QWidget *parent, const QString &caption,
const QString &dir, const QString &filter,
QString *selectedFilter, Options options)
{
QStringList res;
QString f(qt2KdeFilter(filter));
kqtInit();
if(openKdeDialog(parent, caption, startDir(dir), &f, OP_FILE_OPEN, res, selectedFilter) && res.count())
{
kde2QtFilter(filter, selectedFilter);
QString fn(res.first());
storeLastDir(fn);
return fn;
}
return QString();
}
QString QFileDialog::getSaveFileName(QWidget *parent, const QString &caption,
const QString &dir, const QString &filter,
QString *selectedFilter, Options options)
{
QStringList res;
QString f(qt2KdeFilter(filter));
kqtInit();
if (openKdeDialog(parent, caption, startDir(dir), &f, OP_FILE_SAVE, res, selectedFilter) && res.count())
{
kde2QtFilter(filter, selectedFilter);
QString fn(res.first());
storeLastDir(fn);
return fn;
}
return QString();
}
QString QFileDialog::getExistingDirectory(QWidget *parent, const QString &caption,
const QString &dir, Options options)
{
QStringList res;
QString dummy;
kqtInit();
return openKdeDialog(parent, caption, dir, NULL, OP_FOLDER, res, &dummy) && res.count()
? res.first()
: QString();
}
QStringList QFileDialog::getOpenFileNames(QWidget *parent, const QString &caption,
const QString &dir, const QString &filter,
QString *selectedFilter, Options options)
{
QStringList res;
QString f(qt2KdeFilter(filter));
kqtInit();
openKdeDialog(parent, caption, startDir(dir), &f, OP_FILE_OPEN_MULTIPLE, res, selectedFilter);
if(res.count())
{
kde2QtFilter(filter, selectedFilter);
storeLastDir(res.first());
}
return res;
}
#ifdef KQT_OVERLOAD_NON_STATIC_FILEDIALOGS
static QString getFile(const QString &f)
{
QString d(f);
int slashPos=d.lastIndexOf('/');
if(slashPos!=-1)
d.remove(0, slashPos+1);
return d;
}
int QDialog::exec()
{
int res=QDialog::Rejected;
if(inherits("QFileDialog"))
{
QFileDialog *that=(QFileDialog *)this;
QDir directory(that->directory());
QString dir,
selectedFilter,
file;
QStringList files;
QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents, 1);
switch(that->fileMode())
{
case QFileDialog::Directory:
case QFileDialog::DirectoryOnly:
dir=QFileDialog::getExistingDirectory(parentWidget(), windowTitle(), directory.absolutePath(), 0);
if(!dir.isEmpty())
res=QDialog::Accepted;
break;
case QFileDialog::AnyFile:
{
QString app(getFile(qApp->argv()[0])),
initial(directory.absolutePath());
/*
TODO!!!
initialFile(getCurrentFileName(that));
if(!initialFile.isEmpty())
initial=initial+QLatin1Char('/')+initialFile;
*/
file=QFileDialog::getSaveFileName(parentWidget(), windowTitle(), initial,
getFilters(that, "scribus"==app ||
"scribus-ng"==app), &selectedFilter, 0);
if(!file.isEmpty())
res=QDialog::Accepted;
break;
}
case QFileDialog::ExistingFile:
file=QFileDialog::getOpenFileName(parentWidget(), windowTitle(), directory.absolutePath(),
getFilters(that), &selectedFilter, 0);
if(!file.isEmpty())
res=QDialog::Accepted;
break;
case QFileDialog::ExistingFiles:
files=QFileDialog::getOpenFileNames(parentWidget(), windowTitle(), directory.absolutePath(),
getFilters(that), &selectedFilter, 0);
if(files.count())
res=QDialog::Accepted;
break;
}
if(QDialog::Accepted==res)
{
if(file.isEmpty() && files.count())
file=files.first();
if(dir.isEmpty() && !file.isEmpty())
dir=getDir(file);
if(!dir.isEmpty())
that->setDirectory(dir);
if(!selectedFilter.isEmpty())
that->selectFilter(selectedFilter);
if(!file.isEmpty())
that->selectFile(getFile(file));
if(files.count())
{
QStringList::ConstIterator it(files.begin()),
end(files.end());
for(; it!=end; ++it)
that->selectFile(getFile(*it));
}
}
QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents, 1);
}
else
{
static int (*realFunction)(void *);
if(!realFunction)
realFunction = (int (*)(void *)) dlsym(RTLD_NEXT, KQT_QDIALOG_EXEC);
return (int)realFunction(this);
}
return res;
}
#endif
Loading…
Cancel
Save