summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/application.cpp4
-rw-r--r--src/mainwindow.cpp49
-rw-r--r--src/mainwindow.h7
-rw-r--r--src/rekonq.kcfg3
-rw-r--r--src/settings/settings_general.ui14
5 files changed, 66 insertions, 11 deletions
diff --git a/src/application.cpp b/src/application.cpp
index b28055f7..d2754ec1 100644
--- a/src/application.cpp
+++ b/src/application.cpp
@@ -411,9 +411,11 @@ void Application::updateConfiguration()
else
view->tabBar()->setSelectionBehaviorOnRemove(QTabBar::SelectRightTab);
- // =========== Fonts ==============
+ // =========== Encodings & Fonts ==============
QWebSettings *defaultSettings = QWebSettings::globalSettings();
+ defaultSettings->setDefaultTextEncoding( ReKonfig::defaultEncoding() );
+
int fnSize = ReKonfig::fontSize();
int minFnSize = ReKonfig::minFontSize();
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 03a6194a..6355e6d8 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -104,6 +104,7 @@ MainWindow::MainWindow()
, m_bookmarksPanel(0)
, m_webInspectorPanel(0)
, m_historyBackMenu(0)
+ , m_encodingMenu( new KMenu(this) )
, m_mainBar( new KToolBar( QString("MainToolBar"), this, Qt::TopToolBarArea, true, true, true) )
, m_bmBar( new KToolBar( QString("BookmarkToolBar"), this, Qt::TopToolBarArea, true, false, true) )
, m_popup( new KPassivePopup(this) )
@@ -161,6 +162,7 @@ MainWindow::~MainWindow()
Application::bookmarkProvider()->removeToolBar(m_bmBar);
Application::instance()->removeMainWindow(this);
delete m_popup;
+ delete m_encodingMenu;
}
@@ -396,6 +398,7 @@ void MainWindow::setupActions()
actionCollection()->addAction( QLatin1String("detach_tab"), a);
connect(a, SIGNAL(triggered(bool)), m_view->tabBar(), SLOT(detachTab()) );
+
// ----------------------- Bookmarks ToolBar Action --------------------------------------
QAction *qa;
@@ -414,6 +417,14 @@ void MainWindow::setupActions()
bmMenu->setIcon(KIcon("bookmarks"));
bmMenu->setDelayed(false);
actionCollection()->addAction(QLatin1String("bookmarksActionMenu"), bmMenu);
+
+
+ // ---------------- Encodings -----------------------------------
+ a = new KAction( KIcon("character-set"), i18n("Set Encoding"), this);
+ actionCollection()->addAction( QLatin1String("encodings"), a);
+ a->setMenu(m_encodingMenu);
+ connect(m_encodingMenu, SIGNAL(aboutToShow()), this, SLOT( populateEncodingMenu() ) );
+ connect(m_encodingMenu, SIGNAL(triggered(QAction *)), this, SLOT( setEncoding(QAction *) ));
}
@@ -482,6 +493,8 @@ void MainWindow::setupTools()
toolsMenu->addSeparator();
+ toolsMenu->addAction(actionByName(QLatin1String("encodings")));
+
helpMenu()->setIcon(KIcon("help-browser"));
toolsMenu->addAction(helpMenu()->menuAction());
toolsMenu->addAction(actionByName(KStandardAction::name(KStandardAction::Preferences)));
@@ -1174,8 +1187,6 @@ void MainWindow::aboutToShowBackMenu()
if(pivot >= 8)
offset = pivot - 8;
-
-
for(int i = listCount - 1; i>=0; --i)
{
QWebHistoryItem item = historyList.at(i);
@@ -1202,3 +1213,37 @@ void MainWindow::openActionUrl(QAction *action)
history->goToItem( history->itemAt(index) );
}
+
+
+void MainWindow::setEncoding(QAction *qa)
+{
+ QString currentCodec = qa->text().toLatin1();
+ currentCodec = currentCodec.remove('&');
+ kDebug() << currentCodec;
+ QWebSettings::globalSettings()->setDefaultTextEncoding( currentCodec );
+ ReKonfig::setDefaultEncoding(currentCodec);
+}
+
+
+void MainWindow::populateEncodingMenu()
+{
+ QList<QByteArray> byteCodecs = QTextCodec::availableCodecs();
+ QStringList codecs;
+ Q_FOREACH(const QByteArray &b, byteCodecs)
+ {
+ codecs << QString(b);
+ }
+ codecs.sort();
+
+ QString currentCodec = ReKonfig::defaultEncoding();
+ kDebug() << "Current Codec: " << currentCodec;
+
+ m_encodingMenu->clear();
+ Q_FOREACH(const QString &codec, codecs)
+ {
+ QAction *action = m_encodingMenu->addAction(codec);
+ action->setCheckable(true);
+ if (currentCodec == codec)
+ action->setChecked(true);
+ }
+} \ No newline at end of file
diff --git a/src/mainwindow.h b/src/mainwindow.h
index 5c525e26..7129de80 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -157,6 +157,10 @@ private slots:
void aboutToShowBackMenu();
void openActionUrl(QAction *action);
+ // encodings
+ void setEncoding(QAction *);
+ void populateEncodingMenu();
+
private:
MainView *m_view;
FindBar *m_findBar;
@@ -167,7 +171,8 @@ private:
KAction *m_stopReloadAction;
KMenu *m_historyBackMenu;
-
+ KMenu *m_encodingMenu;
+
KToolBar *m_mainBar;
KToolBar *m_bmBar;
diff --git a/src/rekonq.kcfg b/src/rekonq.kcfg
index dd46624f..3658b324 100644
--- a/src/rekonq.kcfg
+++ b/src/rekonq.kcfg
@@ -29,6 +29,9 @@
<entry name="recoverOnCrash" type="Int">
<default>0</default>
</entry>
+ <entry name="defaultEncoding" type="String">
+ <default>UTF-8</default>
+ </entry>
</group>
<!-- New Tab Page Settings -->
diff --git a/src/settings/settings_general.ui b/src/settings/settings_general.ui
index 00277133..eaa91859 100644
--- a/src/settings/settings_general.ui
+++ b/src/settings/settings_general.ui
@@ -226,19 +226,19 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
- <widget class="QCheckBox" name="kcfg_kgetList">
- <property name="whatsThis">
- <string>If enabled, rekonq will display an additional context menu entry, which, when selected, lists all available links of the current website in KGet.</string>
- </property>
+ <widget class="QCheckBox" name="kcfg_kgetDownload">
<property name="text">
- <string>List links with KGet</string>
+ <string>Use KGet for downloading files</string>
</property>
</widget>
</item>
<item>
- <widget class="QCheckBox" name="kcfg_kgetDownload">
+ <widget class="QCheckBox" name="kcfg_kgetList">
+ <property name="whatsThis">
+ <string>If enabled, rekonq will display an additional context menu entry, which, when selected, lists all available links of the current website in KGet.</string>
+ </property>
<property name="text">
- <string>Use KGet for downloading files</string>
+ <string>List links with KGet</string>
</property>
</widget>
</item>