123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145 |
- diff -ur ktigcc/assistant.cpp ktigcc-assistant-qt4/assistant.cpp
- --- ktigcc/assistant.cpp 2007-10-09 21:36:50.000000000 +0200
- +++ ktigcc-assistant-qt4/assistant.cpp 2008-04-30 03:43:31.000000000 +0200
- @@ -32,6 +32,7 @@
- #include <qapplication.h>
- #include <qeventloop.h>
- #include <qtextstream.h>
- +#include <qfile.h>
- #include <unistd.h>
-
- AssistantClient::AssistantClient(QObject *parent, const QString &profile)
- @@ -39,6 +40,12 @@
- assistantProfile(profile)
- {
- if (parent->isWidgetType()) parentWidget=static_cast<QWidget *>(parent);
- + if (QFile::exists("/usr/bin/assistant_adp"))
- + assistantExecutable="assistant_adp";
- + else if (QFile::exists("/usr/bin/assistant-qt4"))
- + assistantExecutable="assistant-qt4";
- + else
- + assistantExecutable="assistant";
- }
-
- AssistantClient::~AssistantClient()
- @@ -89,7 +96,7 @@
- // properly.
- procIO->setComm(static_cast<KProcess::Communication>(
- KProcess::Stdout|KProcess::MergedStderr));
- - (*procIO)<<"assistant"<<"-server";
- + (*procIO)<<assistantExecutable<<"-server";
- if (!assistantProfile.isNull())
- (*procIO)<<"-profile"<<assistantProfile;
- if (!page.isNull())
- @@ -99,7 +106,7 @@
- connect(procIO,SIGNAL(readReady(KProcIO*)),this,SLOT(procIO_readReady()));
- if (!procIO->start()) {
- KMessageBox::error(parentWidget,"Could not run assistant.\n"
- - "This feature requires Qt 3 Assistant.");
- + "This feature requires Qt Assistant.");
- delete procIO;
- procIO=static_cast<KProcIO *>(NULL);
- return;
- diff -ur ktigcc/assistant.h ktigcc-assistant-qt4/assistant.h
- --- ktigcc/assistant.h 2007-10-09 21:36:50.000000000 +0200
- +++ ktigcc-assistant-qt4/assistant.h 2008-04-30 03:33:21.000000000 +0200
- @@ -41,4 +41,5 @@
- KProcIO *procIO;
- KExtendedSocket *socket;
- QString assistantProfile;
- + QString assistantExecutable;
- };
- diff -ur ktigcc/ktigcc.cpp ktigcc-assistant-qt4/ktigcc.cpp
- --- ktigcc/ktigcc.cpp 2007-10-09 03:31:28.000000000 +0200
- +++ ktigcc-assistant-qt4/ktigcc.cpp 2008-06-06 02:56:10.000000000 +0200
- @@ -21,10 +21,12 @@
-
- #include <cstdio>
- #include <cstdlib>
- +#include <cstring>
- #include <unistd.h>
- #include <qstring.h>
- #include <qimage.h>
- #include <qdir.h>
- +#include <qfile.h>
- #include <kapplication.h>
- #include <kcmdlineargs.h>
- #include <kaboutdata.h>
- @@ -37,6 +39,7 @@
- #include <kconfig.h>
- #include <glib.h>
- #include "mainform.h"
- +#include "tpr.h"
-
- // Check for KDE version at compile time to avoid wasting users' time
- #if KDE_VERSION < KDE_MAKE_VERSION(3,5,7)
- @@ -227,7 +230,40 @@
-
- void force_qt_assistant_page(int n)
- {
- - QString fname=QDir::homeDirPath()+"/.qt/qt_assistantrc";
- + bool useQt4=(QFile::exists("/usr/bin/assistant_adp") || QFile::exists("/usr/bin/assistant-qt4"));
- + QString fname=QDir::homeDirPath()+(useQt4?"/.config/Trolltech/Assistant.conf":"/.qt/qt_assistantrc");
- + mkdir_multi(fname);
- + char qtVersion[5]="3.3";
- + size_t verlen=3;
- + if (useQt4) {
- + QStringList entries;
- + QDir libdir("/usr/lib64");
- + if (libdir.exists()) {
- + entries=libdir.entryList("libQtCore.so.4.?");
- + if (entries.empty()) entries=libdir.entryList("libQtCore.so.4.??");
- + }
- + if (entries.empty()) {
- + libdir.cd("/usr/lib");
- + if (libdir.exists()) {
- + entries=libdir.entryList("libQtCore.so.4.?");
- + if (entries.empty()) entries=libdir.entryList("libQtCore.so.4.??");
- + }
- + }
- + if (entries.empty()) {
- + qWarning("Failed to determine Qt 4 version");
- + return;
- + }
- + QString soname=entries.first();
- + unsigned l=soname.length();
- + *qtVersion='4';
- + if (soname[l-2]=='.')
- + qtVersion[2]=soname[l-1].latin1();
- + else {
- + qtVersion[2]=soname[l-2].latin1();
- + qtVersion[3]=soname[l-1].latin1();
- + verlen++;
- + }
- + }
- FILE *f=fopen(fname,"r+b");
- if (!f) f=fopen(fname,"w+b");
- if (!f) exit(1);
- @@ -237,13 +273,21 @@
- char buffer[flen+1];
- memset(buffer,0,flen+1);
- if (fread(buffer,1,flen,f)<flen) exit(1);
- - char *p=strstr(buffer,"SideBarPage=");
- - if (p) {
- - fseek(f,p-buffer+12,SEEK_SET);
- - fputc('0'+n,f);
- - } else {
- + char *p=strtok(buffer,"\n");
- + bool wantedSection=false, found=false;
- + while (p) {
- + if (*p=='[')
- + wantedSection=(!strncmp(p+1,qtVersion,verlen) && p[verlen+1]==']' && !p[verlen+2]);
- + else if (wantedSection && !strncmp(p,"SideBarPage=",12)) {
- + fseek(f,p-buffer+12,SEEK_SET);
- + fputc('0'+n,f);
- + found=true;
- + }
- + p=strtok(NULL,"\n");
- + }
- + if (!found) {
- fseek(f,0,SEEK_END);
- - fprintf(f,"\n\n[3.3]\nSideBarPage=%d\n",n);
- + fprintf(f,"\n\n[%s]\nSideBarPage=%d\n",qtVersion,n);
- }
- fclose(f);
- }
|