--Boundary-00=_PNXqDiSl7Fmz48y Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Hello, I just completed a little patch. Because my explanation was very lenghtly and needed a lot of html (because I pasted some code), I link here the webpage where I wrote the explanation. The patch is the attached file, but you can download it also from the webpage: http://principe.homelinux.net/patch/ I hope the patch is fine... Bye ;) Emanuele --Boundary-00=_PNXqDiSl7Fmz48y Content-Type: text/x-diff; charset="us-ascii"; name="konquerorpatch.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="konquerorpatch.diff" Index: konq_mainwindow.h =================================================================== --- konq_mainwindow.h (revisione 487901) +++ konq_mainwindow.h (copia locale) @@ -63,6 +63,7 @@ class KonqFrameContainer; class KToolBarPopupAction; class KonqLogoAction; +class KonqMainWindowPrivate; class KonqViewModeAction; class KonqPart; class KonqViewManager; @@ -104,6 +105,9 @@ KonqMainWindow( const KURL &initialURL = KURL(), bool openInitialURL = true, const char *name = 0, const QString& xmluiFile="konqueror.rc"); ~KonqMainWindow(); + bool autoSaveKonqSettings() const; + void setAutoSaveKonqSettings( const QString & groupName, bool saveWindowSize ); + void resetAutoSaveKonqSettings(); /** * Filters the URL and calls the main openURL method. @@ -325,6 +329,9 @@ void viewRemoved( KonqView *view ); public slots: + void setKonqSettingsDirty(); + void saveAutoSaveKonqSettings(); + void slotCtrlTabPressed(); // for KBookmarkMenu and KBookmarkBar @@ -755,6 +762,8 @@ static time_t s_startupTime; static int s_preloadUsageCount; + KonqMainWindowPrivate *dk; + public: static QFile *s_crashlog_file; Index: konq_mainwindow.cc =================================================================== --- konq_mainwindow.cc (revisione 487901) +++ konq_mainwindow.cc (copia locale) @@ -136,6 +136,15 @@ #include "konq_mainwindow_p.h" +class KonqMainWindowPrivate { +public: + bool autoSaveSettings:1; + bool settingsDirty:1; + bool autoSaveWindowSize:1; + QTimer* settingsTimer; + QString autoSaveGroup; +}; + KonqExtendedBookmarkOwner::KonqExtendedBookmarkOwner(KonqMainWindow *w) { m_pKonqMainWindow = w; @@ -273,8 +282,18 @@ // silent m_bNeedApplyKonqMainWindowSettings = false; + dk = new KonqMainWindowPrivate; + dk->settingsDirty = false; + dk->autoSaveSettings = false; + dk->autoSaveWindowSize = true; // for compatibility + dk->settingsTimer = 0; + + // Dirty hack to get d->autoSaveWindowSize = false + setAutoSaveSettings( "Main Window Settings", false ); + resetAutoSaveSettings(); + // Read basic main-view settings, and set to autosave - setAutoSaveSettings( "KonqMainWindow", false ); + setAutoSaveKonqSettings( "Main Window Settings", false ); if ( !initialGeometrySet() ) resize( 700, 480 ); @@ -291,6 +310,9 @@ KonqMainWindow::~KonqMainWindow() { kdDebug(1202) << "KonqMainWindow::~KonqMainWindow " << this << endl; + + delete dk->settingsTimer; + delete dk; delete m_pViewManager; @@ -336,6 +358,70 @@ kdDebug(1202) << "KonqMainWindow::~KonqMainWindow " << this << " done" << endl; } +bool KonqMainWindow::autoSaveKonqSettings() const +{ + return dk->autoSaveSettings; +} + +void KonqMainWindow::resetAutoSaveKonqSettings() +{ + dk->autoSaveSettings = false; + if ( dk->settingsTimer ) + dk->settingsTimer->stop(); +} + +void KonqMainWindow::setKonqSettingsDirty() +{ + //kdDebug(200) << "KMainWindow::setSettingsDirty" << endl; + dk->settingsDirty = true; + if ( dk->autoSaveSettings ) + { + // Use a timer to save "immediately" user-wise, but not too immediately + // (to compress calls and save only once, in case of multiple changes) + if ( !dk->settingsTimer ) + { + dk->settingsTimer = new QTimer( this ); + connect( dk->settingsTimer, SIGNAL( timeout() ), SLOT( saveAutoSaveKonqSettings() ) ); + } + dk->settingsTimer->start( 500, true ); + } +} + +void KonqMainWindow::setAutoSaveKonqSettings( const QString & groupName, bool saveWindowSize ) +{ + dk->autoSaveSettings = true; + dk->autoSaveGroup = groupName; + dk->autoSaveWindowSize = saveWindowSize; + // Get notified when the user moves a toolbar around + disconnect( this, SIGNAL( dockWindowPositionChanged( QDockWindow * ) ), + this, SLOT( setSettingsDirty() ) ); + connect( this, SIGNAL( dockWindowPositionChanged( QDockWindow * ) ), + this, SLOT( setKonqSettingsDirty() ) ); + + // Now read the previously saved settings + KConfig cfg(locate("data",QString::fromLatin1("konqueror/profiles/")+m_pViewManager->currentProfile())); + applyMainWindowSettings( &cfg, groupName ); +} + +void KonqMainWindow::saveAutoSaveKonqSettings() +{ + Q_ASSERT( dk->autoSaveSettings ); + //kdDebug(200) << "KMainWindow::saveAutoSaveSettings -> saving settings" << endl; + QString profile = m_pViewManager->currentProfile(); + if (!profile.isEmpty()) { + QString path = locateLocal("data",QString::fromLatin1("konqueror/profiles/")+profile); + KConfig cfg( path ); + if (QFile::exists( path )) + saveMainWindowSettings( &cfg, dk->autoSaveGroup ); + else + m_pViewManager->saveViewProfile( profile, m_pViewManager->currentProfileText(), true, false ); + cfg.sync(); + } + dk->settingsDirty = false; + if ( dk->settingsTimer ) + dk->settingsTimer->stop(); +} + QWidget * KonqMainWindow::createContainer( QWidget *parent, int index, const QDomElement &element, int &id ) { static QString nameBookmarkBar = QString::fromLatin1( "bookmarkToolBar" ); @@ -1133,9 +1219,13 @@ return; } - mainWindow = new KonqMainWindow( KURL(), false ); + QString profileName = QString::fromLatin1( url.isLocalFile() ? "konqueror/profiles/filemanagement" : "konqueror/profiles/webbrowsing" ); + KSimpleConfig cfg( locate( "data", profileName ), true ); + cfg.setGroup( "Profile" ); + + mainWindow = new KonqMainWindow( KURL(), false, 0, cfg.readEntry("XMLUIFile") ); mainWindow->setInitialFrameName( args.frameName ); - mainWindow->resetAutoSaveSettings(); // Don't autosave + mainWindow->resetAutoSaveKonqSettings(); // Don't autosave KonqOpenURLRequest req; req.args = args; @@ -1165,10 +1255,6 @@ mainWindow->viewManager()->setActivePart( part, true ); } - QString profileName = QString::fromLatin1( url.isLocalFile() ? "konqueror/profiles/filemanagement" : "konqueror/profiles/webbrowsing" ); - KSimpleConfig cfg( locate( "data", profileName ), true ); - cfg.setGroup( "Profile" ); - if ( windowArgs.x != -1 ) mainWindow->move( windowArgs.x, mainWindow->y() ); if ( windowArgs.y != -1 ) @@ -1205,6 +1291,12 @@ (*it)->hide(); } } + else + { + QString savedGroup = cfg.group(); + mainWindow->applyMainWindowSettings( &cfg, "Main Window Settings" ); + cfg.setGroup( savedGroup ); + } if ( view ) { if ( !windowArgs.scrollBarsVisible ) @@ -1924,8 +2016,11 @@ void KonqMainWindow::slotConfigureToolbars() { - if ( autoSaveSettings() ) - saveMainWindowSettings( KGlobal::config(), "KonqMainWindow" ); + if ( autoSaveKonqSettings() ) + { + KConfig cfg(locate("data",QString::fromLatin1("konqueror/profiles/")+m_pViewManager->currentProfile())); + saveMainWindowSettings( &cfg, "Main Window Settings" ); + } KEditToolbar dlg(factory()); connect(&dlg,SIGNAL(newToolbarConfig()),this,SLOT(slotNewToolbarConfig())); connect(&dlg,SIGNAL(newToolbarConfig()),this,SLOT(initBookmarkBar())); @@ -1941,7 +2036,8 @@ plugViewModeActions(); - applyMainWindowSettings( KGlobal::config(), "KonqMainWindow" ); + KConfig cfg(locate("data",QString::fromLatin1("konqueror/profiles/")+m_pViewManager->currentProfile())); + applyMainWindowSettings( &cfg, "Main Window Settings" ); } void KonqMainWindow::slotUndoAvailable( bool avail ) @@ -3494,10 +3590,12 @@ void KonqMainWindow::slotForceSaveMainWindowSettings() { // kdDebug(1202)<<"slotForceSaveMainWindowSettings()"<sync(); + QString profile = m_pViewManager->currentProfile(); + KConfig cfg(locate("data",QString::fromLatin1("konqueror/profiles/")+profile)); + saveMainWindowSettings( &cfg, "Main Window Settings" ); + cfg.sync(); } } Index: konq_misc.cc =================================================================== --- konq_misc.cc (revisione 487901) +++ konq_misc.cc (copia locale) @@ -126,7 +126,8 @@ if ( forbidUseHTML ) mainWindow->setShowHTML( false ); } - else if( KonqMainWindow::isPreloaded() && KonqMainWindow::preloadedWindow() != NULL ) + else if( KonqMainWindow::isPreloaded() && KonqMainWindow::preloadedWindow() != NULL && + KonqMainWindow::preloadedWindow()->xmlFile() == (new KConfig(path))->readEntry("XMLUIFile") ) { mainWindow = KonqMainWindow::preloadedWindow(); KStartupInfo::setWindowStartupId( mainWindow->winId(), kapp->startupId()); Index: konq_viewmgr.cc =================================================================== --- konq_viewmgr.cc (revisione 487901) +++ konq_viewmgr.cc (copia locale) @@ -25,6 +25,7 @@ #include "konq_profiledlg.h" #include "konq_events.h" #include "konq_settingsxt.h" +#include "konq_misc.h" #include #include @@ -1185,6 +1186,14 @@ bool alwaysTabbedMode = KonqSettings::alwaysTabbedMode(); + if (!m_currentProfile.isEmpty()) { + if ( m_pMainWindow->xmlFile() != cfg.readEntry ("XMLUIFile","konqueror.rc") ) { + KonqMisc::createBrowserWindowFromProfile( locate("data",QString::fromLatin1("konqueror/profiles/")+filename), filename ); + m_pMainWindow->close(); + return; + } + } + m_currentProfile = filename; m_currentProfileText = cfg.readPathEntry("Name",filename); m_profileHomeURL = cfg.readEntry("HomeURL", QString::null); @@ -1294,7 +1303,8 @@ if( resetWindow ) { // force default settings for the GUI - m_pMainWindow->applyMainWindowSettings( KGlobal::config(), "KonqMainWindow", true ); + KConfig cfg(locate("data",QString::fromLatin1("konqueror/profiles/")+currentProfile())); + m_pMainWindow->applyMainWindowSettings( &cfg, "Main Window Settings", true ); } // Apply menu/toolbar settings saved in profile. Read from a separate group --Boundary-00=_PNXqDiSl7Fmz48y--