diff options
author | Andrea Diamantini <adjam7@gmail.com> | 2010-05-18 02:22:57 +0200 |
---|---|---|
committer | Andrea Diamantini <adjam7@gmail.com> | 2010-05-18 02:24:13 +0200 |
commit | 5163336b8e9f5e34a5d07ba38b59aa0dad72fb1b (patch) | |
tree | 06f3ea0af37992b1b14e07de580ba31beda74074 /src/mainwindow.cpp | |
parent | Moved setEncoding action to be a local page settings as it seems (diff) | |
download | rekonq-5163336b8e9f5e34a5d07ba38b59aa0dad72fb1b.tar.xz |
This commit let encoding handling being a bit easier.
It is anyway a bit tricky :)
Hope no-one blame about..
BUG:237518
Diffstat (limited to 'src/mainwindow.cpp')
-rw-r--r-- | src/mainwindow.cpp | 36 |
1 files changed, 30 insertions, 6 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 527e5020..1aa4374a 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1292,11 +1292,12 @@ void MainWindow::setEncoding(QAction *qa) void MainWindow::populateEncodingMenu() { - QList<QByteArray> byteCodecs = QTextCodec::availableCodecs(); QStringList codecs; - Q_FOREACH(const QByteArray &b, byteCodecs) + QList<int> mibs = QTextCodec::availableMibs(); + Q_FOREACH (const int &mib, mibs) { - codecs << QString(b); + QString codec = QLatin1String(QTextCodec::codecForMib(mib)->name()); + codecs.append(codec); } codecs.sort(); @@ -1304,13 +1305,36 @@ void MainWindow::populateEncodingMenu() kDebug() << "Current Codec: " << currentCodec; m_encodingMenu->clear(); + KMenu *isoMenu = new KMenu( QL1S("ISO"), m_encodingMenu); + KMenu *winMenu = new KMenu( QL1S("windows"), m_encodingMenu); + KMenu *isciiMenu = new KMenu( QL1S("Iscii"), m_encodingMenu); + KMenu *uniMenu = new KMenu( QL1S("UNICODE"), m_encodingMenu); + KMenu *otherMenu = new KMenu( QL1S("Other"), m_encodingMenu); + + QAction *a; Q_FOREACH(const QString &codec, codecs) { - QAction *action = m_encodingMenu->addAction(codec); - action->setCheckable(true); + + if( codec.startsWith( QL1S("ISO"), Qt::CaseInsensitive ) ) + a = isoMenu->addAction(codec); + else if( codec.startsWith( QL1S("win") ) ) + a = winMenu->addAction(codec); + else if( codec.startsWith( QL1S("Iscii") ) ) + a = isciiMenu->addAction(codec); + else if( codec.startsWith( QL1S("UT") ) ) + a = uniMenu->addAction(codec); + else + a = otherMenu->addAction(codec); + + a->setCheckable(true); if (currentCodec == codec) - action->setChecked(true); + a->setChecked(true); } + m_encodingMenu->addMenu( isoMenu ); + m_encodingMenu->addMenu( winMenu ); + m_encodingMenu->addMenu( isciiMenu ); + m_encodingMenu->addMenu( uniMenu ); + m_encodingMenu->addMenu( otherMenu ); } |