summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2008-12-18 02:51:24 +0100
committerAndrea Diamantini <adjam7@gmail.com>2008-12-18 02:51:24 +0100
commit0dc1272340d4deda7f9b07c5278fac9e04383b18 (patch)
tree041c3e575f9b45ae5d9d97a6fd3cf750b6fb87a5
parentAdjusted download directory requester (diff)
downloadrekonq-0dc1272340d4deda7f9b07c5278fac9e04383b18.tar.xz
Lots of improvements in save/restore state functions.
- saving toolbar lock - removing unuseful save/restore tabWidget functions - saving navigation toolbar settings
-rw-r--r--src/browsermainwindow.cpp80
-rw-r--r--src/browsermainwindow.h9
-rw-r--r--src/main.cpp9
-rw-r--r--src/tabwidget.cpp4
-rw-r--r--src/tabwidget.h4
5 files changed, 63 insertions, 43 deletions
diff --git a/src/browsermainwindow.cpp b/src/browsermainwindow.cpp
index 8a936774..32dd13a3 100644
--- a/src/browsermainwindow.cpp
+++ b/src/browsermainwindow.cpp
@@ -126,15 +126,18 @@ void BrowserMainWindow::save()
KConfig config("rekonqrc");
KConfigGroup group1 = config.group("BrowserMainWindow");
- QByteArray data = saveState(false);
+ QByteArray data = saveState();
group1.writeEntry( QString("defaultState"), data );
+
+ KConfigGroup group2 = config.group("navigation toobar");
+ m_navigationBar->saveSettings( group2 );
}
static const qint32 BrowserMainWindowMagic = 0xba;
-QByteArray BrowserMainWindow::saveState(bool withTabs) const
+QByteArray BrowserMainWindow::saveState() const
{
int version = 2;
QByteArray data;
@@ -144,25 +147,28 @@ QByteArray BrowserMainWindow::saveState(bool withTabs) const
stream << qint32(version);
stream << size();
-// stream << !( statusBar()->isHidden() ); FIXME
- if (withTabs)
-// stream << tabWidget()->saveState();
- ;
- else
+
+ stream << KToolBar::toolBarsLocked();
+ bool b = true; // statusBar()->isVisible() ; FIXME
+ stream << b;
+// if (withTabs)
+// // stream << tabWidget()->saveState();
+// ;
+// else
stream << QByteArray();
return data;
}
-bool BrowserMainWindow::restoreState(const QByteArray &state)
+void BrowserMainWindow::restoreState(const QByteArray &state)
{
int version = 2;
QByteArray sd = state;
QDataStream stream(&sd, QIODevice::ReadOnly);
if ( stream.atEnd() )
{
- return false;
+ return;
}
qint32 marker;
@@ -171,26 +177,29 @@ bool BrowserMainWindow::restoreState(const QByteArray &state)
stream >> v;
if (marker != BrowserMainWindowMagic || v != version)
{
- return false;
+ return;
}
QSize size;
- bool showStatusbar = true;
+ bool showStatusbar;
+ bool toolbarsLocked;
QByteArray tabState;
stream >> size;
-// stream >> showStatusbar; FIXME see 30 lines over..
- stream >> tabState;
+ stream >> toolbarsLocked;
+ stream >> showStatusbar;
+// stream >> tabState;
resize(size);
statusBar()->setVisible(showStatusbar);
updateStatusbarActionText(showStatusbar);
- if ( !tabWidget()->restoreState(tabState) )
- {
- return false;
- }
- return true;
+ KToolBar::setToolBarsLocked ( toolbarsLocked );
+// if ( !tabWidget()->restoreState(tabState) )
+// {
+// return false;
+// }
+ return;
}
@@ -302,23 +311,19 @@ void BrowserMainWindow::setupMenu()
m_historyBack = new KAction( i18n("Back"), this);
m_historyBack->setShortcut( KShortcut( QKeySequence::Back ) );
- m_tabWidget->addWebAction(m_historyBack, QWebPage::Back);
+ m_tabWidget->addWebAction( m_historyBack, QWebPage::Back );
m_historyBack->setIconVisibleInMenu(false);
m_historyForward = new KAction( i18n("Forward"), this);
m_historyForward->setShortcut( KShortcut( QKeySequence::Forward ) );
- m_tabWidget->addWebAction(m_historyForward, QWebPage::Forward);
+ m_tabWidget->addWebAction( m_historyForward, QWebPage::Forward );
m_historyForward->setIconVisibleInMenu(false);
- m_restoreLastSession = new KAction( i18n("Restore Last Session"), this);
- connect(m_restoreLastSession, SIGNAL(triggered()), BrowserApplication::instance(), SLOT(restoreLastSession()));
- m_restoreLastSession->setEnabled(BrowserApplication::instance()->canRestoreSession());
-
- historyActions.append(m_historyBack);
- historyActions.append(m_historyForward);
+ historyActions.append( m_historyBack );
+ historyActions.append( m_historyForward );
historyActions.append( KStandardAction::home(this, SLOT( slotHome() ) , this ) );
- historyActions.append(m_tabWidget->recentlyClosedTabsAction());
- historyActions.append(m_restoreLastSession);
+ historyActions.append( m_tabWidget->recentlyClosedTabsAction() );
+
historyMenu->setInitialActions(historyActions);
@@ -380,10 +385,16 @@ void BrowserMainWindow::setupToolBar()
// UI settings
setContextMenuPolicy( Qt::PreventContextMenu );
- m_navigationBar->setIconDimensions(22);
- KToolBar::setToolBarsEditable( false );
- KToolBar::setToolBarsLocked( true );
+// m_navigationBar->setIconDimensions(22);
+// m_navigationBar->setToolButtonStyle( Qt::ToolButtonIconOnly );
+// KToolBar::setToolBarsEditable( false );
+// KToolBar::setToolBarsLocked( true );
+
+ KConfig config("rekonqrc");
+ KConfigGroup group = config.group("navigation toobar");
+ m_navigationBar->applySettings( group );
+
}
@@ -504,9 +515,12 @@ void BrowserMainWindow::slotUpdateStatusbar(const QString &string)
void BrowserMainWindow::slotUpdateWindowTitle(const QString &title)
{
- if (title.isEmpty()) {
+ if (title.isEmpty())
+ {
setWindowTitle("rekonq");
- } else {
+ }
+ else
+ {
setWindowTitle(title + " - rekonq");
}
}
diff --git a/src/browsermainwindow.h b/src/browsermainwindow.h
index d50abcc4..3bd80168 100644
--- a/src/browsermainwindow.h
+++ b/src/browsermainwindow.h
@@ -41,9 +41,8 @@ class QWebFrame;
class TabWidget;
class WebView;
-/*!
+/**
The MainWindow of the Browser Application.
-
Handles the tab widget and all the actions
*/
class BrowserMainWindow : public KMainWindow
@@ -57,8 +56,10 @@ public:
static KUrl guessUrlFromString(const QString &url);
TabWidget *tabWidget() const;
WebView *currentTab() const;
- QByteArray saveState(bool withTabs = true) const;
- bool restoreState(const QByteArray &state);
+
+
+ QByteArray saveState() const;
+ void restoreState(const QByteArray &state);
public slots:
void loadPage(const QString &url);
diff --git a/src/main.cpp b/src/main.cpp
index e2f74b4d..7963405d 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -41,13 +41,18 @@ int main(int argc, char **argv)
"adjam7@gmail.com" // bug report mail
);
- aboutData.addAuthor(ki18n("Andrea Diamantini"), ki18n("rekonq author"), "adjam7@gmail.com");
+ aboutData.addAuthor(
+ ki18n("Andrea Diamantini"),
+ ki18n("rekonq author"),
+ "adjam7@gmail.com"
+ );
+
aboutData.setProgramIconName("applications-internet");
KCmdLineArgs::init( argc, argv, &aboutData );
KCmdLineOptions options;
- options.add("+URL", ki18n("Location to open"));
+ options.add( "+URL" , ki18n("Location to open") );
KCmdLineArgs::addCmdLineOptions( options );
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
diff --git a/src/tabwidget.cpp b/src/tabwidget.cpp
index 24aacfff..7d0fb788 100644
--- a/src/tabwidget.cpp
+++ b/src/tabwidget.cpp
@@ -774,7 +774,7 @@ void TabWidget::previousTab()
setCurrentIndex(next);
}
-
+/*
static const qint32 TabWidgetMagic = 0xaa;
@@ -835,7 +835,7 @@ bool TabWidget::restoreState(const QByteArray &state)
setCurrentIndex(currentTab);
return true;
-}
+}*/
// ----------------------------------------------------------------------------------------------------------------------------
diff --git a/src/tabwidget.h b/src/tabwidget.h
index 1a46371c..d99ff156 100644
--- a/src/tabwidget.h
+++ b/src/tabwidget.h
@@ -168,8 +168,8 @@ public:
QLineEdit *lineEdit(int index) const;
int webViewIndex(WebView *webView) const;
- QByteArray saveState() const;
- bool restoreState(const QByteArray &state);
+// QByteArray saveState() const;
+// bool restoreState(const QByteArray &state);
protected:
void mouseDoubleClickEvent(QMouseEvent *event);