summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-07-05 08:15:56 (UTC)
committer zautrix <zautrix>2004-07-05 08:15:56 (UTC)
commit9f0d4ee43ce6f8c61abbd546376ef4f262261a1e (patch) (side-by-side diff)
tree4484ee12251cc858c3130271e5a798f4302be888
parent25671b4735f2604e13f4d6801b96f016ac8b9834 (diff)
downloadkdepimpi-9f0d4ee43ce6f8c61abbd546376ef4f262261a1e.zip
kdepimpi-9f0d4ee43ce6f8c61abbd546376ef4f262261a1e.tar.gz
kdepimpi-9f0d4ee43ce6f8c61abbd546376ef4f262261a1e.tar.bz2
Found and fixed problem of fastload of KAPI
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--kaddressbook/mainembedded.cpp6
-rw-r--r--microkde/kdeui/kmainwindow.cpp2
2 files changed, 3 insertions, 5 deletions
diff --git a/kaddressbook/mainembedded.cpp b/kaddressbook/mainembedded.cpp
index c127601..dce6a88 100644
--- a/kaddressbook/mainembedded.cpp
+++ b/kaddressbook/mainembedded.cpp
@@ -1,191 +1,189 @@
#ifndef DESKTOP_VERSION
#include <qpe/qpeapplication.h>
#include <stdlib.h>
#else
#include <qapplication.h>
#include <qwindowsstyle.h>
#include <qplatinumstyle.h>
#include <qmainwindow.h>
#endif
#include <kstandarddirs.h>
#include <kglobal.h>
#include <stdio.h>
#include <qdir.h>
#include "kaddressbookmain.h"
int main( int argc, char **argv )
{
#ifndef DESKTOP_VERSION
QPEApplication a( argc, argv );
a.setKeepRunning ();
#else
QApplication a( argc, argv );
QApplication::setStyle( new QPlatinumStyle ());
#endif
bool exitHelp = false;
if ( argc > 1 ) {
QString command = argv[1];
if ( command == "-help" ){
printf("KA/E command line commands:\n");
printf(" no command: Start KA/E in usual way\n");
printf(" -help: This output\n");
printf(" KA/E is exiting now. Bye!\n");
exitHelp = true;
}
}
if ( ! exitHelp ) {
KGlobal::setAppName( "kaddressbook" );
#ifndef DESKTOP_VERSION
if ( QApplication::desktop()->width() > 320 )
KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons22/");
else
KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons16/");
#else
QString fileName ;
fileName = qApp->applicationDirPath () + "/kdepim/kaddressbook/";
KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName));
#endif
KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "kaddressbook")));
- KAddressBookMain* m = new KAddressBookMain();
+ KAddressBookMain m ;
//US MainWindow m;
//US QObject::connect( &a, SIGNAL (appMessage ( const QCString &, const QByteArray & )),&m, SLOT(recieve( const QCString&, const QByteArray& )));
#ifndef DESKTOP_VERSION
- a.showMainWidget(m );
- m->showMaximized();
+ a.showMainWidget( &m );
#else
a.setMainWidget(m );
m->show();
- //m->resize( 640, 480 );
#endif
a.exec();
}
qDebug("KA: Bye! ");
}
/*
#include <stdlib.h>
#include <qstring.h>
#include <kabc/stdaddressbook.h>
#include <kaboutdata.h>
#include <kcmdlineargs.h>
#include <kcrash.h>
#include <kdebug.h>
#include <klocale.h>
#include <kstartupinfo.h>
#include <kuniqueapplication.h>
#include <kwin.h>
#include "kaddressbookmain.h"
#include "kabcore.h"
extern "C" {
void crashHandler( int )
{
KABC::StdAddressBook::handleCrash();
::exit( 0 );
}
}
class KAddressBookApp : public KUniqueApplication {
public:
KAddressBookApp() : mMainWin( 0 ) {}
~KAddressBookApp() {}
int newInstance();
private:
KAddressBookMain *mMainWin;
};
int KAddressBookApp::newInstance()
{
if ( isRestored() ) {
// There can only be one main window
if ( KMainWindow::canBeRestored( 1 ) ) {
mMainWin = new KAddressBookMain;
mMainWin->show();
mMainWin->restore( 1 );
}
} else {
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
QCString addrStr = args->getOption( "addr" );
QCString uidStr = args->getOption( "uid" );
QString addr;
QString uid;
if ( !addrStr.isEmpty() )
addr = QString::fromLocal8Bit( addrStr );
if ( !uidStr.isEmpty() )
uid = QString::fromLocal8Bit( uidStr );
if ( args->isSet( "editor-only" ) ) {
if ( !mMainWin )
mMainWin = new KAddressBookMain;
KStartupInfo::appStarted();
mMainWin->hide();
} else {
if ( mMainWin ) {
mMainWin->show();
KWin::setActiveWindow( mMainWin->winId() );
} else {
mMainWin = new KAddressBookMain;
mMainWin->show();
}
}
// Can not see why anyone would pass both a uid and an email address, so I'll leave it that two contact editors will show if they do
if ( !addr.isEmpty() )
mMainWin->addEmail( addr );
if ( !uid.isEmpty() )
mMainWin->showContactEditor( uid );
if ( args->isSet( "new-contact" ) ) {
mMainWin->newContact();
}
}
KCrash::setEmergencySaveFunction( crashHandler );
return 0;
}
// the dummy argument is required, because KMail apparently sends an empty
// argument.
static KCmdLineOptions kmoptions[] =
{
{ "a", 0 , 0 },
{ "addr <email>", I18N_NOOP( "Shows contact editor with given email address" ), 0 },
{ "uid <uid>", I18N_NOOP( "Shows contact editor with given uid" ), 0 },
{ "editor-only", I18N_NOOP( "Launches in editor only mode" ), 0 },
{ "new-contact", I18N_NOOP( "Launches editor for the new contact" ), 0 },
{ "+[argument]", I18N_NOOP( "dummy argument" ), 0},
{ 0, 0, 0}
};
int main( int argc, char *argv[] )
{
KLocale::setMainCatalogue( "kaddressbook" );
KCmdLineArgs::init( argc, argv, KABCore::createAboutData() );
KCmdLineArgs::addCmdLineOptions( kmoptions );
KUniqueApplication::addCmdLineOptions();
if ( !KAddressBookApp::start() )
exit( 0 );
KAddressBookApp app;
KGlobal::locale()->insertCatalogue( "libkdepim" );
return app.exec();
}
*/
diff --git a/microkde/kdeui/kmainwindow.cpp b/microkde/kdeui/kmainwindow.cpp
index 3a2a4d0..bd5a2cc 100644
--- a/microkde/kdeui/kmainwindow.cpp
+++ b/microkde/kdeui/kmainwindow.cpp
@@ -1,441 +1,441 @@
/* This file is part of the KDE libraries
Copyright
(C) 2000 Reginald Stadlbauer (reggie@kde.org)
(C) 1997 Stephan Kulow (coolo@kde.org)
(C) 1997-2000 Sven Radej (radej@kde.org)
(C) 1997-2000 Matthias Ettrich (ettrich@kde.org)
(C) 1999 Chris Schlaeger (cs@kde.org)
(C) 2002 Joseph Wenninger (jowenn@kde.org)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 as published by the Free Software Foundation.
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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include <qobjectlist.h>
#include <qstringlist.h>
#include <qtimer.h>
#include <qmenubar.h>
#include <qstatusbar.h>
#include <qapplication.h>
#include "kdebug.h"
#include "kmainwindow.h"
#include "kglobalsettings.h"
#include "kactioncollection.h"
class KMainWindowPrivate {
public:
//US bool showHelpMenu:1;
bool autoSaveSettings:1;
bool settingsDirty:1;
bool autoSaveWindowSize:1;
bool care_about_geometry:1;
QString autoSaveGroup;
//US KAccel * kaccel;
//US KMainWindowInterface *m_interface;
KDEPrivate::ToolBarHandler *toolBarHandler;
QTimer* settingsTimer;
KToggleAction *showStatusBarAction;
QRect defaultWindowSize;
};
static bool no_query_exit = false;
KMainWindow::KMainWindow( QWidget* parent, const char *name, WFlags f )
- : QMainWindow( parent, name, f )/*US, KXMLGUIBuilder( this ), helpMenu2( 0 ), factory_( 0 )*/
+ : QMainWindow( parent, name ) /*LR, f ) with the default widget flag we cannot have fastload */ /*US, KXMLGUIBuilder( this ), helpMenu2( 0 ), factory_( 0 )*/
{
mQToolBar = 0;
initKMainWindow(name);
}
void KMainWindow::parseGeometry(bool parsewidth)
{
//US the following code is not getting used in the embedded version !! So disable it for now
/*US
assert ( !kapp->geometryArgument().isNull() );
assert ( d->care_about_geometry );
#ifndef Q_WS_QWS
// FIXME: (E) Implement something similar for Qt Embedded (or decide we don't need it)
int x, y;
int w, h;
int m = XParseGeometry( kapp->geometryArgument().latin1(), &x, &y, (unsigned int*)&w, (unsigned int*)&h);
if (parsewidth) {
QSize minSize = minimumSize();
QSize maxSize = maximumSize();
if ( (m & WidthValue) == 0 )
w = width();
if ( (m & HeightValue) == 0 )
h = height();
w = QMIN(w,maxSize.width());
h = QMIN(h,maxSize.height());
w = QMAX(w,minSize.width());
h = QMAX(h,minSize.height());
resize(w, h);
} else {
if ( parsewidth && (m & XValue) == 0 )
x = geometry().x();
if ( parsewidth && (m & YValue) == 0 )
y = geometry().y();
if ( (m & XNegative) )
x = KApplication::desktop()->width() + x - w;
if ( (m & YNegative) )
y = KApplication::desktop()->height() + y - h;
move(x, y);
}
#endif
*/
}
KMainWindow::~KMainWindow()
{
delete d->settingsTimer;
QMenuBar* mb = internalMenuBar();
delete mb;
//US delete d->m_interface;
delete d;
//US memberList->remove( this );
}
void KMainWindow::initKMainWindow(const char *name)
{
setDockMenuEnabled( FALSE );
//US mHelpMenu = 0;
//US kapp->setTopWidget( this );
actionCollection()->setWidget( this );
//US connect(kapp, SIGNAL(shutDown()), this, SLOT(shuttingDown()));
//US if( !memberList )
//US memberList = new QPtrList<KMainWindow>;
/*US
if ( !ksm )
ksm = ksmd.setObject(new KMWSessionManaged());
// set a unique object name. Required by session management.
QCString objname;
QCString s;
int unusedNumber;
if ( !name )
{ // no name given
objname = kapp->instanceName() + "-mainwindow#";
s = objname + '1'; // start adding number immediately
unusedNumber = 1;
}
else if( name[ strlen( name ) - 1 ] == '#' )
{ // trailing # - always add a number
objname = name;
s = objname + '1'; // start adding number immediately
unusedNumber = 1;
}
else
{
objname = name;
s = objname;
unusedNumber = 0; // add numbers only when needed
}
for(;;) {
QWidgetList* list = kapp->topLevelWidgets();
QWidgetListIt it( *list );
bool found = false;
for( QWidget* w = it.current();
w != NULL;
++it, w = it.current())
if( w != this && w->name() == s )
{
found = true;
break;
}
delete list;
if( !found )
break;
s.setNum( ++unusedNumber );
s = objname + s;
}
setName( s );
memberList->append( this );
*/
d = new KMainWindowPrivate;
//US d->showHelpMenu = true;
d->settingsDirty = false;
d->autoSaveSettings = false;
d->autoSaveWindowSize = true; // for compatibility
//US d->kaccel = actionCollection()->kaccel();
d->toolBarHandler = 0;
d->settingsTimer = 0;
d->showStatusBarAction = NULL;
/*US
if ((d->care_about_geometry == beeing_first)) {
beeing_first = false;
if ( kapp->geometryArgument().isNull() ) // if there is no geometry, it doesn't mater
d->care_about_geometry = false;
else
parseGeometry(false);
}
*/
d->care_about_geometry = false;
//US setCaption( kapp->caption() );
// attach dcop interface
//US d->m_interface = new KMainWindowInterface(this);
//US if (!kapp->authorize("movable_toolbars"))
//US setDockWindowsMovable(false);
}
KAction *KMainWindow::toolBarMenuAction()
{
if ( !d->toolBarHandler )
return 0;
return d->toolBarHandler->toolBarMenuAction();
}
bool KMainWindow::canBeRestored( int number )
{
/*US we do not have and want to save sessioninformation. Use info from the default
application config.
*/
//US if ( !kapp->isRestored() )
//US return FALSE;
//US KConfig *config = kapp->sessionConfig();
KConfig *config = KGlobal::config();
if ( !config )
return FALSE;
config->setGroup( QString::fromLatin1("Number") );
int n = config->readNumEntry( QString::fromLatin1("NumberOfWindows") , 1 );
return number >= 1 && number <= n;
}
const QString KMainWindow::classNameOfToplevel( int number )
{
/*US we do not have and want to save sessioninformation. Use info from the default
application config.
*/
//US if ( !kapp->isRestored() )
//US return QString::null;
//US KConfig *config = kapp->sessionConfig();
KConfig *config = KGlobal::config();
if ( !config )
return QString::null;
QString s;
s.setNum( number );
s.prepend( QString::fromLatin1("WindowProperties") );
config->setGroup( s );
if ( !config->hasKey( QString::fromLatin1("ClassName") ) )
return QString::null;
else
return config->readEntry( QString::fromLatin1("ClassName") );
}
bool KMainWindow::restore( int number, bool show )
{
/*US we do not have and want to save sessioninformation. Use info from the default
application config.
*/
if ( !canBeRestored( number ) )
return FALSE;
//US KConfig *config = kapp->sessionConfig();
KConfig *config = KGlobal::config();
if ( readPropertiesInternal( config, number ) ){
if ( show )
KMainWindow::show();
return FALSE;
}
return FALSE;
}
void KMainWindow::setCaption( const QString &caption )
{
//US setPlainCaption( kapp->makeStdCaption(caption) );
setPlainCaption( caption );
}
void KMainWindow::setCaption( const QString &caption, bool modified )
{
//US setPlainCaption( kapp->makeStdCaption(caption, true, modified) );
setPlainCaption( caption + "modified:" );
}
void KMainWindow::setPlainCaption( const QString &caption )
{
QMainWindow::setCaption( caption );
#ifndef Q_WS_QWS
//US the following is disabled for the embedded version
//US NETWinInfo info( qt_xdisplay(), winId(), qt_xrootwin(), 0 );
//US info.setName( caption.utf8().data() );
#endif
}
void KMainWindow::slotStateChanged(const QString &newstate)
{
stateChanged(newstate, KXMLGUIClient::StateNoReverse);
}
/*
* Get rid of this for KDE 4.0
*/
void KMainWindow::slotStateChanged(const QString &newstate,
KXMLGUIClient::ReverseStateChange reverse)
{
stateChanged(newstate, reverse);
}
void KMainWindow::closeEvent ( QCloseEvent *e )
{
// Save settings if auto-save is enabled, and settings have changed
if (d->settingsDirty && d->autoSaveSettings)
saveAutoSaveSettings();
if (queryClose()) {
e->accept();
int not_withdrawn = 0;
/*US
QPtrListIterator<KMainWindow> it(*KMainWindow::memberList);
for (it.toFirst(); it.current(); ++it){
if ( !it.current()->isHidden() && it.current()->isTopLevel() && it.current() != this )
not_withdrawn++;
}
*/
if ( !no_query_exit && not_withdrawn <= 0 ) { // last window close accepted?
/*US
if ( queryExit() && !kapp->sessionSaving()) { // Yes, Quit app?
// don't call queryExit() twice
disconnect(kapp, SIGNAL(shutDown()), this, SLOT(shuttingDown()));
kapp->deref(); // ...and quit aplication.
} else {
// cancel closing, it's stupid to end up with no windows at all....
e->ignore();
}
*/
//US we have no sessionmanagement. Simply close app.
if ( queryExit() ) { // Yes, Quit app?
qDebug("KMainWindow::closeEvent: Exit application ???");
// don't call queryExit() twice
//US disconnect(kapp, SIGNAL(shutDown()), this, SLOT(shuttingDown()));
}
}
}
}
bool KMainWindow::queryExit()
{
return TRUE;
}
bool KMainWindow::queryClose()
{
return TRUE;
}
void KMainWindow::saveGlobalProperties( KConfig* )
{
}
void KMainWindow::readGlobalProperties( KConfig* )
{
}
void KMainWindow::savePropertiesInternal( KConfig *config, int number )
{
bool oldASWS = d->autoSaveWindowSize;
d->autoSaveWindowSize = true; // make saveMainWindowSettings save the window size
QString s;
s.setNum(number);
s.prepend(QString::fromLatin1("WindowProperties"));
config->setGroup(s);
// store objectName, className, Width and Height for later restoring
// (Only useful for session management)
config->writeEntry(QString::fromLatin1("ObjectName"), name());
config->writeEntry(QString::fromLatin1("ClassName"), className());
saveMainWindowSettings(config); // Menubar, statusbar and Toolbar settings.
s.setNum(number);
config->setGroup(s);
saveProperties(config);
d->autoSaveWindowSize = oldASWS;
}
void KMainWindow::setStandardToolBarMenuEnabled( bool enable )
{
if ( enable )
{
if ( d->toolBarHandler )
return;
d->toolBarHandler = new KDEPrivate::ToolBarHandler( this );
/*US if ( factory() )
factory()->addClient( d->toolBarHandler );
*/
}
else
{
if ( !d->toolBarHandler )
return;
/*US
if ( factory() )
factory()->removeClient( d->toolBarHandler );
*/
delete d->toolBarHandler;
d->toolBarHandler = 0;
}
}
bool KMainWindow::isStandardToolBarMenuEnabled() const
{
return ( d->toolBarHandler != 0 );
}
void KMainWindow::createStandardStatusBarAction(){
if(!d->showStatusBarAction){
d->showStatusBarAction = KStdAction::showStatusbar(this, SLOT(setSettingsDirty()), actionCollection());
connect(d->showStatusBarAction, SIGNAL(toggled(bool)), statusBar(), SLOT(setShown(bool)));
if(internalStatusBar())
d->showStatusBarAction->setChecked(!internalStatusBar()->isHidden());
}
}
QToolBar *KMainWindow::tBar( )
{
if ( ! mQToolBar )
mQToolBar = new QToolBar( this );
return mQToolBar;
}
KToolBar *KMainWindow::toolBar( const char * name )
{
if (!name)
name = "mainToolBar";
KToolBar *tb = (KToolBar*)child( name, "KToolBar" );
if ( tb )
return tb;
bool honor_mode = (name == "mainToolBar");
/*US
if ( builderClient() )