summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2008-12-05 01:34:44 +0100
committerAndrea Diamantini <adjam7@gmail.com>2008-12-05 01:34:44 +0100
commitd3ae019349f53901a93f42fbad5d65b6f9b40fe6 (patch)
tree95b382870e9ada528abe1a07d51b4c2c47d45307 /src
parentQUrl --> KUrl! (diff)
downloadrekonq-d3ae019349f53901a93f42fbad5d65b6f9b40fe6.tar.xz
QSettings --> KConfig
Diffstat (limited to 'src')
-rw-r--r--src/browserapplication.cpp106
-rw-r--r--src/browserapplication.h1
-rw-r--r--src/browsermainwindow.cpp47
-rw-r--r--src/browsermainwindow.h5
4 files changed, 61 insertions, 98 deletions
diff --git a/src/browserapplication.cpp b/src/browserapplication.cpp
index a79f28b2..a35bab6f 100644
--- a/src/browserapplication.cpp
+++ b/src/browserapplication.cpp
@@ -41,7 +41,6 @@
#include <QLibraryInfo>
#include <QSettings>
#include <QTextStream>
-#include <QTranslator>
#include <QDesktopServices>
#include <QFileOpenEvent>
#include <QLocalServer>
@@ -94,19 +93,14 @@ BrowserApplication::BrowserApplication(KCmdLineArgs *args, const QString &server
QDesktopServices::setUrlHandler(QLatin1String("http"), this, "openUrl");
QString localSysName = QLocale::system().name();
- installTranslator(QLatin1String("qt_") + localSysName);
-
- QSettings settings;
- settings.beginGroup(QLatin1String("sessions"));
- m_lastSession = settings.value(QLatin1String("lastSession")).toByteArray();
- settings.endGroup();
+ KConfig config("rekonqrc");
+ KConfigGroup group = config.group("sessions");
+ m_lastSession = group.readEntry( QString("lastSession"), QByteArray() );
QTimer::singleShot(0, this, SLOT( postLaunch() ) );
}
-
-
BrowserApplication::~BrowserApplication()
{
delete s_downloadManager;
@@ -115,27 +109,12 @@ BrowserApplication::~BrowserApplication()
}
-
-// #if defined(Q_WS_MAC)
-// void BrowserApplication::lastWindowClosed()
-// {
-// clean();
-// BrowserMainWindow *mw = new BrowserMainWindow;
-// mw->slotHome();
-// m_mainWindows.prepend(mw);
-// }
-// #endif
-
-
-
BrowserApplication *BrowserApplication::instance()
{
return (static_cast<BrowserApplication *>(QCoreApplication::instance()));
}
-
-
/*!
Any actions that can be delayed until the window is visible
*/
@@ -168,31 +147,28 @@ void BrowserApplication::postLaunch()
void BrowserApplication::loadSettings()
{
- QSettings settings;
- settings.beginGroup(QLatin1String("websettings"));
-
+ KConfig config("rekonqrc");
+ KConfigGroup group = config.group("Appearance Settings");
+
QWebSettings *defaultSettings = QWebSettings::globalSettings();
QString standardFontFamily = defaultSettings->fontFamily(QWebSettings::StandardFont);
int standardFontSize = defaultSettings->fontSize(QWebSettings::DefaultFontSize);
QFont standardFont = QFont(standardFontFamily, standardFontSize);
- standardFont = qVariantValue<QFont>(settings.value(QLatin1String("standardFont"), standardFont));
+ standardFont = qVariantValue<QFont>( group.readEntry( QString("standardFont"), standardFont ) );
+
defaultSettings->setFontFamily(QWebSettings::StandardFont, standardFont.family());
defaultSettings->setFontSize(QWebSettings::DefaultFontSize, standardFont.pointSize());
QString fixedFontFamily = defaultSettings->fontFamily(QWebSettings::FixedFont);
int fixedFontSize = defaultSettings->fontSize(QWebSettings::DefaultFixedFontSize);
QFont fixedFont = QFont(fixedFontFamily, fixedFontSize);
- fixedFont = qVariantValue<QFont>(settings.value(QLatin1String("fixedFont"), fixedFont));
+ fixedFont = qVariantValue<QFont>(group.readEntry( QString("fixedFont"), fixedFont ) );
+
defaultSettings->setFontFamily(QWebSettings::FixedFont, fixedFont.family());
defaultSettings->setFontSize(QWebSettings::DefaultFixedFontSize, fixedFont.pointSize());
- defaultSettings->setAttribute(QWebSettings::JavascriptEnabled, settings.value(QLatin1String("enableJavascript"), true).toBool());
- defaultSettings->setAttribute(QWebSettings::PluginsEnabled, settings.value(QLatin1String("enablePlugins"), true).toBool());
-
- QUrl url = settings.value(QLatin1String("userStyleSheet")).toUrl();
- defaultSettings->setUserStyleSheetUrl(url);
-
- settings.endGroup();
+ defaultSettings->setAttribute(QWebSettings::JavascriptEnabled, group.readEntry( QString("enableJavascript"), true ) );
+ defaultSettings->setAttribute(QWebSettings::PluginsEnabled, group.readEntry( QString("enablePlugins"), true ) );
}
@@ -203,7 +179,9 @@ QList<BrowserMainWindow*> BrowserApplication::mainWindows()
clean();
QList<BrowserMainWindow*> list;
for (int i = 0; i < m_mainWindows.count(); ++i)
+ {
list.append(m_mainWindows.at(i));
+ }
return list;
}
@@ -214,13 +192,15 @@ void BrowserApplication::clean()
{
// cleanup any deleted main windows first
for (int i = m_mainWindows.count() - 1; i >= 0; --i)
+ {
if (m_mainWindows.at(i).isNull())
+ {
m_mainWindows.removeAt(i);
+ }
+ }
}
-
-
void BrowserApplication::saveSession()
{
QWebSettings *globalSettings = QWebSettings::globalSettings();
@@ -229,9 +209,8 @@ void BrowserApplication::saveSession()
clean();
- QSettings settings;
- settings.beginGroup(QLatin1String("sessions"));
-
+ KConfig config("rekonqrc");
+ KConfigGroup group = config.group("sessions");
QByteArray data;
QBuffer buffer(&data);
QDataStream stream(&buffer);
@@ -239,22 +218,20 @@ void BrowserApplication::saveSession()
stream << m_mainWindows.count();
for (int i = 0; i < m_mainWindows.count(); ++i)
+ {
stream << m_mainWindows.at(i)->saveState();
- settings.setValue(QLatin1String("lastSession"), data);
- settings.endGroup();
+ }
+
+ group.writeEntry( QString("lastSession"), data );
}
-
-
bool BrowserApplication::canRestoreSession() const
{
return !m_lastSession.isEmpty();
}
-
-
void BrowserApplication::restoreLastSession()
{
QList<QByteArray> windows;
@@ -294,16 +271,6 @@ bool BrowserApplication::isTheOnlyBrowser() const
}
-
-void BrowserApplication::installTranslator(const QString &name)
-{
- QTranslator *translator = new QTranslator(this);
- translator->load(name, QLibraryInfo::location(QLibraryInfo::TranslationsPath));
- KApplication::installTranslator(translator);
-}
-
-
-
void BrowserApplication::openUrl(const KUrl &url)
{
mainWindow()->loadPage( url.url() );
@@ -338,15 +305,19 @@ void BrowserApplication::newLocalSocketConnection()
QTextStream stream(socket);
QString url;
stream >> url;
- if (!url.isEmpty()) {
- QSettings settings;
- settings.beginGroup(QLatin1String("general"));
- int openLinksIn = settings.value(QLatin1String("openLinksIn"), 0).toInt();
- settings.endGroup();
+ if (!url.isEmpty())
+ {
+ KConfig config("rekonqrc");
+ KConfigGroup group = config.group("Global Settings");
+ int openLinksIn = group.readEntry( QString("openLinksIn"), QString().toInt() );
if (openLinksIn == 1)
+ {
newMainWindow();
+ }
else
+ {
mainWindow()->tabWidget()->newTab();
+ }
openUrl(url);
}
delete socket;
@@ -362,11 +333,10 @@ CookieJar *BrowserApplication::cookieJar()
}
-
-
DownloadManager *BrowserApplication::downloadManager()
{
- if (!s_downloadManager) {
+ if (!s_downloadManager)
+ {
s_downloadManager = new DownloadManager();
}
return s_downloadManager;
@@ -376,7 +346,8 @@ DownloadManager *BrowserApplication::downloadManager()
NetworkAccessManager *BrowserApplication::networkAccessManager()
{
- if (!s_networkAccessManager) {
+ if (!s_networkAccessManager)
+ {
s_networkAccessManager = new NetworkAccessManager();
s_networkAccessManager->setCookieJar(new CookieJar);
}
@@ -387,7 +358,8 @@ NetworkAccessManager *BrowserApplication::networkAccessManager()
HistoryManager *BrowserApplication::historyManager()
{
- if (!s_historyManager) {
+ if (!s_historyManager)
+ {
s_historyManager = new HistoryManager();
QWebHistoryInterface::setDefaultInterface(s_historyManager);
}
diff --git a/src/browserapplication.h b/src/browserapplication.h
index cee28895..eb6962ef 100644
--- a/src/browserapplication.h
+++ b/src/browserapplication.h
@@ -75,7 +75,6 @@ private slots:
private:
void clean();
- void installTranslator(const QString &name);
static HistoryManager *s_historyManager;
static DownloadManager *s_downloadManager;
diff --git a/src/browsermainwindow.cpp b/src/browsermainwindow.cpp
index ada00b5c..9abdb3ef 100644
--- a/src/browsermainwindow.cpp
+++ b/src/browsermainwindow.cpp
@@ -44,7 +44,6 @@
#include <KBookmarkOwner>
// Qt Includes
-#include <QSettings>
#include <QDesktopWidget>
#include <QFileDialog>
#include <QPlainTextEdit>
@@ -119,11 +118,10 @@ BrowserMainWindow::~BrowserMainWindow()
void BrowserMainWindow::loadDefaultState()
{
- QSettings settings;
- settings.beginGroup(QLatin1String("BrowserMainWindow"));
- QByteArray data = settings.value(QLatin1String("defaultState")).toByteArray();
-// restoreState(data); // FIXME re-enable me!
- settings.endGroup();
+ KConfig config("rekonqrc");
+ KConfigGroup group1 = config.group("BrowserMainWindow");
+ QByteArray data = group1.readEntry(QString("defaultState"), QByteArray() );
+ restoreState(data);
}
@@ -141,11 +139,10 @@ void BrowserMainWindow::save()
{
BrowserApplication::instance()->saveSession();
- QSettings settings;
- settings.beginGroup(QLatin1String("BrowserMainWindow"));
+ KConfig config("rekonqrc");
+ KConfigGroup group1 = config.group("BrowserMainWindow");
QByteArray data = saveState(false);
- settings.setValue(QLatin1String("defaultState"), data);
- settings.endGroup();
+ group1.writeEntry( QString("defaultState"), data );
}
@@ -164,8 +161,7 @@ QByteArray BrowserMainWindow::saveState(bool withTabs) const
stream << qint32(version);
stream << size();
- stream << !m_navigationBar->isHidden();
-// stream << !statusBar()->isHidden(); // FIXME strange error ????
+// stream << !( statusBar()->isHidden() ); FIXME
if (withTabs)
stream << tabWidget()->saveState();
else
@@ -180,36 +176,36 @@ bool BrowserMainWindow::restoreState(const QByteArray &state)
int version = 2;
QByteArray sd = state;
QDataStream stream(&sd, QIODevice::ReadOnly);
- if (stream.atEnd())
+ if ( stream.atEnd() )
+ {
return false;
+ }
qint32 marker;
qint32 v;
stream >> marker;
stream >> v;
if (marker != BrowserMainWindowMagic || v != version)
+ {
return false;
+ }
QSize size;
- bool showToolbar;
- bool showStatusbar;
+ bool showStatusbar = true;
QByteArray tabState;
stream >> size;
- stream >> showToolbar;
- stream >> showStatusbar;
+// stream >> showStatusbar; FIXME see 30 lines over..
stream >> tabState;
resize(size);
-
- m_navigationBar->setVisible(showToolbar);
-
statusBar()->setVisible(showStatusbar);
updateStatusbarActionText(showStatusbar);
- if (!tabWidget()->restoreState(tabState))
+ if ( !tabWidget()->restoreState(tabState) )
+ {
return false;
-
+ }
return true;
}
@@ -785,9 +781,9 @@ void BrowserMainWindow::slotViewPageSource()
void BrowserMainWindow::slotHome()
{
- QSettings settings;
- settings.beginGroup(QLatin1String("MainWindow"));
- QString home = settings.value(QLatin1String("home"), QLatin1String("http://www.kde.org/")).toString();
+ KConfig config("rekonqrc");
+ KConfigGroup group = config.group("Global Settings");
+ QString home = group.readEntry( QString("home"), QString("http://www.kde.org/") );
loadPage(home);
}
@@ -858,7 +854,6 @@ WebView *BrowserMainWindow::currentTab() const
}
-
void BrowserMainWindow::slotLoadProgress(int progress)
{
if (progress < 100 && progress > 0)
diff --git a/src/browsermainwindow.h b/src/browsermainwindow.h
index 237f872d..e952eec2 100644
--- a/src/browsermainwindow.h
+++ b/src/browsermainwindow.h
@@ -34,9 +34,6 @@
#include <KAction>
#include <KMenu>
-// // Qt Includes
-// #include <QUrl>
-
class AutoSaver;
class QWebFrame;
@@ -47,7 +44,7 @@ class WebView;
The MainWindow of the Browser Application.
Handles the tab widget and all the actions
- */
+*/
class BrowserMainWindow : public KMainWindow
{
Q_OBJECT