From 4ff25e9e071625c8cae97a4d52f39716caa24a79 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 18 Jun 2010 10:57:40 +0200 Subject: Adding a "default" encoding option.. --- src/mainwindow.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/mainwindow.cpp') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 2d0ed7dd..2aa67868 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1292,6 +1292,14 @@ void MainWindow::setEncoding(QAction *qa) QString currentCodec = qa->text().toLatin1(); currentCodec = currentCodec.remove('&'); kDebug() << "Setting codec: " << currentCodec; + if(currentCodec == QL1S("Default") ) + { + kDebug() << "QWebSettings::globalSettings()->defaultTextEncoding() = " << QWebSettings::globalSettings()->defaultTextEncoding(); + currentTab()->view()->settings()->setDefaultTextEncoding( QWebSettings::globalSettings()->defaultTextEncoding() ); + currentTab()->view()->reload(); + return; + } + currentTab()->view()->settings()->setDefaultTextEncoding(currentCodec); currentTab()->view()->reload(); } @@ -1318,6 +1326,8 @@ void MainWindow::populateEncodingMenu() KMenu *otherMenu = new KMenu( QL1S("Other"), m_encodingMenu); QAction *a; + bool isDefaultCodecUsed = true; + Q_FOREACH(const QString &codec, codecs) { @@ -1334,8 +1344,17 @@ void MainWindow::populateEncodingMenu() a->setCheckable(true); if (currentCodec == codec) + { a->setChecked(true); + isDefaultCodecUsed = false; + } } + + a = new QAction( QL1S("Default"), this); + a->setCheckable(true); + a->setChecked(isDefaultCodecUsed); + + m_encodingMenu->addAction( a ); m_encodingMenu->addMenu( isoMenu ); m_encodingMenu->addMenu( winMenu ); m_encodingMenu->addMenu( isciiMenu ); -- cgit v1.2.1