summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukáš Tinkl <lukas@kde.org>2015-01-29 20:48:47 (GMT)
committerLukáš Tinkl <lukas@kde.org>2015-01-29 20:48:47 (GMT)
commite9ae1d99afc16d62faa27a2b5dbcdb4eed58548e (patch)
tree437d4d4c0e058b84c7f1770a913851cd4dd86805
parentfd6a35486e60f5f727fb70e05403b650fc13163c (diff)
port away from KLocale
-rw-r--r--active/app/src/main.cpp1
-rw-r--r--active/components/okularplugin.cpp5
-rw-r--r--core/document.cpp33
-rw-r--r--core/document_p.h1
-rw-r--r--generators/dvi/pageSize.cpp6
-rw-r--r--generators/fictionbook/converter.cpp2
-rw-r--r--generators/ooo/manifest.cpp2
-rw-r--r--generators/ooo/styleparser.cpp4
-rw-r--r--generators/poppler/generator_pdf.cpp4
-rw-r--r--generators/tiff/generator_tiff.cpp2
-rw-r--r--generators/xps/generator_xps.cpp4
-rw-r--r--ui/annotationpropertiesdialog.cpp8
-rw-r--r--ui/annotationwidgets.cpp7
-rw-r--r--ui/annotwindow.cpp2
-rw-r--r--ui/embeddedfilesdialog.cpp5
-rw-r--r--ui/pageview.cpp10
16 files changed, 34 insertions, 62 deletions
diff --git a/active/app/src/main.cpp b/active/app/src/main.cpp
index 004f12c..416ab76 100644
--- a/active/app/src/main.cpp
+++ b/active/app/src/main.cpp
@@ -24,7 +24,6 @@
#include <KAboutData>
#include <KCmdLineArgs>
#include <KDebug>
-#include <KDE/KLocale>
#include <KConfigGroup>
#include "kdeclarativemainwindow.h"
diff --git a/active/components/okularplugin.cpp b/active/components/okularplugin.cpp
index 0ad8449..a6092d8 100644
--- a/active/components/okularplugin.cpp
+++ b/active/components/okularplugin.cpp
@@ -26,16 +26,11 @@
#include <QtQml/QQmlEngine>
#include <KGlobalSettings>
-#include <KLocale>
void OkularPlugin::registerTypes(const char *uri)
{
Q_ASSERT(uri == QLatin1String("org.kde.okular"));
- //KF5 port: remove this line and define TRANSLATION_DOMAIN in CMakeLists.txt instead
-//KLocale::global()->insertCatalog("org.kde.okular");
qmlRegisterType<DocumentItem>(uri, 2, 0, "DocumentItem");
qmlRegisterType<PageItem>(uri, 2, 0, "PageItem");
qmlRegisterType<ThumbnailItem>(uri, 2, 0, "ThumbnailItem");
}
-
-
diff --git a/core/document.cpp b/core/document.cpp
index 30ad087..c96760e 100644
--- a/core/document.cpp
+++ b/core/document.cpp
@@ -38,13 +38,14 @@
#include <QStack>
#include <QUndoCommand>
#include <QMimeDatabase>
+#include <QDesktopServices>
#include <k4aboutdata.h>
#include <kauthorized.h>
#include <kconfigdialog.h>
#include <QtCore/QLoggingCategory>
#include <klibloader.h>
-#include <klocale.h>
+#include <KLocalizedString>
#include <kmacroexpander.h>
#include <kmessagebox.h>
#include <kmimetypetrader.h>
@@ -52,7 +53,6 @@
#include <krun.h>
#include <kshell.h>
-#include <ktoolinvocation.h>
#include <kzip.h>
#include <KIO/Global>
@@ -283,7 +283,7 @@ QString DocumentPrivate::localizedSize(const QSizeF &size) const
case Generator::None:
break;
}
- if (KLocale::global()->measureSystem() == KLocale::Imperial)
+ if (QLocale::system().measurementSystem() == QLocale::ImperialSystem)
{
return i18nc("%1 is width, %2 is height, %3 is paper size name", "%1 x %2 in (%3)", inchesWidth, inchesHeight, namePaperSize(inchesWidth, inchesHeight));
}
@@ -834,9 +834,6 @@ Generator * DocumentPrivate::loadGeneratorLibrary( const KService::Ptr &service
KComponentData data = KComponentData::mainComponent();
GeneratorInfo info( data );
info.generator = generator;
- if ( info.data.isValid() && info.data.aboutData() )
- info.catalogName = info.data.aboutData()->catalogName();
- qDebug() << "JACK" << service->name();
m_loadedGenerators.insert( service->name(), info );
return generator;
}
@@ -918,11 +915,9 @@ Document::OpenResult DocumentPrivate::openDocumentInternal( const KService::Ptr&
{
QString propName = offer->name();
QHash< QString, GeneratorInfo >::const_iterator genIt = m_loadedGenerators.constFind( propName );
- QString catalogName;
if ( genIt != m_loadedGenerators.constEnd() )
{
m_generator = genIt.value().generator;
- catalogName = genIt.value().catalogName;
}
else
{
@@ -931,14 +926,9 @@ Document::OpenResult DocumentPrivate::openDocumentInternal( const KService::Ptr&
return Document::OpenError;
genIt = m_loadedGenerators.constFind( propName );
Q_ASSERT( genIt != m_loadedGenerators.constEnd() );
- catalogName = genIt.value().catalogName;
}
Q_ASSERT_X( m_generator, "Document::load()", "null generator?!" );
- if ( !catalogName.isEmpty() )
- //KF5 port: remove this line and define TRANSLATION_DOMAIN in CMakeLists.txt instead
-//KLocale::global()->insertCatalog( catalogName );
-
m_generator->d_func()->m_document = this;
// connect error reporting signals
@@ -984,10 +974,6 @@ Document::OpenResult DocumentPrivate::openDocumentInternal( const KService::Ptr&
QApplication::restoreOverrideCursor();
if ( openResult != Document::OpenSuccess || m_pagesVector.size() <= 0 )
{
-#pragma message("KF5: FIXME load translations")
-// if ( !catalogName.isEmpty() )
-// KLocale::global()->removeCatalog( catalogName );
-
m_generator->d_func()->m_document = 0;
QObject::disconnect( m_generator, 0, m_parent, 0 );
m_generator = 0;
@@ -2572,9 +2558,6 @@ void Document::closeDocument()
QHash< QString, GeneratorInfo >::const_iterator genIt = d->m_loadedGenerators.constFind( d->m_generatorName );
Q_ASSERT( genIt != d->m_loadedGenerators.constEnd() );
-#pragma message("KF5: FIXME load translations")
-// if ( !genIt.value().catalogName.isEmpty() && !genIt.value().config )
-// KLocale::global()->removeCatalog( genIt.value().catalogName );
}
d->m_generator = 0;
d->m_generatorName = QString();
@@ -3900,7 +3883,7 @@ void Document::processAction( const Action * action )
{
QList<QUrl> lst;
lst.append( QUrl::fromLocalFile(fileName) );
- KRun::run( *ptr, lst, 0 );
+ KRun::runService( *ptr, lst, 0 );
}
else
KMessageBox::information( d->m_widget, i18n( "No application found for opening file of mimetype %1.", mime.name() ) );
@@ -3957,7 +3940,7 @@ void Document::processAction( const Action * action )
int lilyRow = 0, lilyCol = 0;
// if the url is a mailto one, invoke mailer
if ( browse->url().scheme().compare("mailto") )
- KToolInvocation::invokeMailer( browse->url() );
+ QDesktopServices::openUrl( browse->url() );
else if ( extractLilyPondSourceReference( browse->url(), &lilySource, &lilyRow, &lilyCol ) )
{
const SourceReference ref( lilySource, lilyRow, lilyCol );
@@ -4209,10 +4192,6 @@ void Document::fillConfigDialog( KConfigDialog * dialog )
{
iface->addPages( dialog );
pagesAdded = true;
- if ( !it.value().catalogName.isEmpty() ) {
- //KF5 port: remove this line and define TRANSLATION_DOMAIN in CMakeLists.txt instead
- //KLocale::global()->insertCatalog( it.value().catalogName );
- }
}
}
if ( pagesAdded )
@@ -4478,7 +4457,7 @@ bool Document::saveDocumentArchive( const QString &fileName )
const KUser user;
#ifndef Q_OS_WIN
- const KUserGroup userGroup( user.gid() );
+ const KUserGroup userGroup( user.groupId() );
#else
const KUserGroup userGroup( QString( "" ) );
#endif
diff --git a/core/document_p.h b/core/document_p.h
index b1cb518..6bbe3c4 100644
--- a/core/document_p.h
+++ b/core/document_p.h
@@ -58,7 +58,6 @@ struct GeneratorInfo
Okular::Generator * generator;
KComponentData data;
- QString catalogName;
Okular::ConfigInterface * config;
Okular::SaveInterface * save;
bool configChecked : 1;
diff --git a/generators/dvi/pageSize.cpp b/generators/dvi/pageSize.cpp
index 4b18bfa..a9328f5 100644
--- a/generators/dvi/pageSize.cpp
+++ b/generators/dvi/pageSize.cpp
@@ -209,7 +209,7 @@ QString pageSize::preferredUnit() const
return staticList[currentSize].preferredUnit;
// User-defined size. Give a preferred unit depening on the locale.
- if (KLocale::global()-> measureSystem() == KLocale::Metric)
+ if (QLocale::system().measurementSystem() == QLocale::MetricSystem)
return "mm";
else
return "in";
@@ -314,7 +314,7 @@ QString pageSize::description() const
QString size = " ";
if (formatNumber() == -1) {
- if (KLocale::global()-> measureSystem() == KLocale::Metric)
+ if (QLocale::system().measurementSystem() == QLocale::MetricSystem)
size += QString("%1x%2 mm").arg(width().getLength_in_mm(), 0, 'f', 0).arg(height().getLength_in_mm(), 0, 'f', 0);
else
size += QString("%1x%2 in").arg(width().getLength_in_inch(), 0, 'g', 2).arg(height().getLength_in_inch(), 0, 'g', 2);
@@ -354,7 +354,7 @@ int pageSize::defaultPageSize()
// FIXME: static_cast<QPrinter::PageSize>(KLocale::global()->pageSize())
// is the proper solution here. Then you can determine the values
// without using your hardcoded table too!
- if (KLocale::global()-> measureSystem() == KLocale::Metric)
+ if (QLocale::system().measurementSystem() == QLocale::MetricSystem)
return defaultMetricPaperSize;
else
return defaultImperialPaperSize;
diff --git a/generators/fictionbook/converter.cpp b/generators/fictionbook/converter.cpp
index a492222..7f8023d 100644
--- a/generators/fictionbook/converter.cpp
+++ b/generators/fictionbook/converter.cpp
@@ -189,7 +189,7 @@ QTextDocument* Converter::convert( const QString &fileName )
if ( mDocumentInfo->mDate.isValid() )
emit addMetaData( Okular::DocumentInfo::CreationDate,
- KLocale::global()->formatDate( mDocumentInfo->mDate, KLocale::ShortDate ) );
+ QLocale().toString( mDocumentInfo->mDate, QLocale::ShortFormat ) );
}
QMapIterator<QString, QPair<int, int> > it( mLocalLinks );
diff --git a/generators/ooo/manifest.cpp b/generators/ooo/manifest.cpp
index d64d9c2..e166879 100644
--- a/generators/ooo/manifest.cpp
+++ b/generators/ooo/manifest.cpp
@@ -13,7 +13,7 @@
#include <QXmlStreamReader>
#include <KFilterDev>
-#include <KLocale>
+#include <KLocalizedString>
#include <KMessageBox>
using namespace OOO;
diff --git a/generators/ooo/styleparser.cpp b/generators/ooo/styleparser.cpp
index fe5a43b..d4a38e8 100644
--- a/generators/ooo/styleparser.cpp
+++ b/generators/ooo/styleparser.cpp
@@ -136,7 +136,7 @@ bool StyleParser::parseMetaFile()
mStyleInformation->addMetaInformation( "producer", child.text(), i18n( "Producer" ) );
} else if ( child.tagName() == QLatin1String( "creation-date" ) ) {
const QDateTime dateTime = QDateTime::fromString( child.text(), Qt::ISODate );
- mStyleInformation->addMetaInformation( "creationDate", KLocale::global()->formatDateTime( dateTime, KLocale::LongDate, true ),
+ mStyleInformation->addMetaInformation( "creationDate", QLocale().toString( dateTime, QLocale::LongFormat ),
i18n( "Created" ) );
} else if ( child.tagName() == QLatin1String( "initial-creator" ) ) {
mStyleInformation->addMetaInformation( "creator", child.text(), i18n( "Creator" ) );
@@ -144,7 +144,7 @@ bool StyleParser::parseMetaFile()
mStyleInformation->addMetaInformation( "author", child.text(), i18n( "Author" ) );
} else if ( child.tagName() == QLatin1String( "date" ) ) {
const QDateTime dateTime = QDateTime::fromString( child.text(), Qt::ISODate );
- mStyleInformation->addMetaInformation( "modificationDate", KLocale::global()->formatDateTime( dateTime, KLocale::LongDate, true ),
+ mStyleInformation->addMetaInformation( "modificationDate", QLocale().toString( dateTime, QLocale::LongFormat ),
i18n( "Modified" ) );
}
diff --git a/generators/poppler/generator_pdf.cpp b/generators/poppler/generator_pdf.cpp
index a8b76f6..ae8599b 100644
--- a/generators/poppler/generator_pdf.cpp
+++ b/generators/poppler/generator_pdf.cpp
@@ -604,9 +604,9 @@ Okular::DocumentInfo PDFGenerator::generateDocumentInfo( const QSet<Okular::Docu
if ( keys.contains( Okular::DocumentInfo::Producer ) )
docInfo.set( Okular::DocumentInfo::Producer, pdfdoc->info("Producer") );
if ( keys.contains( Okular::DocumentInfo::CreationDate ) )
- docInfo.set( Okular::DocumentInfo::CreationDate, KLocale::global()->formatDateTime( pdfdoc->date("CreationDate"), KLocale::LongDate, true ) );
+ docInfo.set( Okular::DocumentInfo::CreationDate, QLocale().toString( pdfdoc->date("CreationDate"), QLocale::LongFormat ) );
if ( keys.contains( Okular::DocumentInfo::ModificationDate ) )
- docInfo.set( Okular::DocumentInfo::ModificationDate, KLocale::global()->formatDateTime( pdfdoc->date("ModDate"), KLocale::LongDate, true ) );
+ docInfo.set( Okular::DocumentInfo::ModificationDate, QLocale().toString( pdfdoc->date("ModDate"), QLocale::LongFormat ) );
if ( keys.contains( Okular::DocumentInfo::CustomKeys ) )
{
int major, minor;
diff --git a/generators/tiff/generator_tiff.cpp b/generators/tiff/generator_tiff.cpp
index 7213de6..dbf1811 100644
--- a/generators/tiff/generator_tiff.cpp
+++ b/generators/tiff/generator_tiff.cpp
@@ -341,7 +341,7 @@ Okular::DocumentInfo TIFFGenerator::generateDocumentInfo( const QSet<Okular::Doc
char* buffer = 0;
TIFFGetField( d->tiff, TIFFTAG_DATETIME, &buffer );
QDateTime date = convertTIFFDateTime( buffer );
- docInfo.set( Okular::DocumentInfo::CreationDate, date.isValid() ? KLocale::global()->formatDateTime( date, KLocale::LongDate, true ) : QString() );
+ docInfo.set( Okular::DocumentInfo::CreationDate, date.isValid() ? QLocale().toString( date, QLocale::LongFormat ) : QString() );
}
}
diff --git a/generators/xps/generator_xps.cpp b/generators/xps/generator_xps.cpp
index 2f8fe5d..47fdc63 100644
--- a/generators/xps/generator_xps.cpp
+++ b/generators/xps/generator_xps.cpp
@@ -2020,10 +2020,10 @@ Okular::DocumentInfo XpsFile::generateDocumentInfo() const
docInfo.set( Okular::DocumentInfo::Category, xml.readElementText() );
} else if (xml.name() == "created") {
QDateTime createdDate = QDateTime::fromString( xml.readElementText(), "yyyy-MM-ddThh:mm:ssZ" );
- docInfo.set( Okular::DocumentInfo::CreationDate, KLocale::global()->formatDateTime( createdDate, KLocale::LongDate, true ) );
+ docInfo.set( Okular::DocumentInfo::CreationDate, QLocale().toString( createdDate, QLocale::LongFormat ) );
} else if (xml.name() == "modified") {
QDateTime modifiedDate = QDateTime::fromString( xml.readElementText(), "yyyy-MM-ddThh:mm:ssZ" );
- docInfo.set( Okular::DocumentInfo::ModificationDate, KLocale::global()->formatDateTime( modifiedDate, KLocale::LongDate, true ) );
+ docInfo.set( Okular::DocumentInfo::ModificationDate, QLocale().toString( modifiedDate, QLocale::LongFormat ) );
} else if (xml.name() == "keywords") {
docInfo.set( Okular::DocumentInfo::Keywords, xml.readElementText() );
} else if (xml.name() == "revision") {
diff --git a/ui/annotationpropertiesdialog.cpp b/ui/annotationpropertiesdialog.cpp
index aca6347..a7e0214 100644
--- a/ui/annotationpropertiesdialog.cpp
+++ b/ui/annotationpropertiesdialog.cpp
@@ -18,7 +18,7 @@
#include <qtextedit.h>
#include <QIcon>
#include <klineedit.h>
-#include <klocale.h>
+#include <KLocalizedString>
#include <kglobal.h>
// local includes
@@ -71,12 +71,12 @@ AnnotsPropertiesDialog::AnnotsPropertiesDialog( QWidget *parent, Okular::Documen
gridlayout->addWidget( AuthorEdit, 0, 1 );
tmplabel = new QLabel( page );
- tmplabel->setText( i18n( "Created: %1", KLocale::global()->formatDateTime( ann->creationDate(), KLocale::LongDate, true ) ) );
+ tmplabel->setText( i18n( "Created: %1", QLocale().toString( ann->creationDate(), QLocale::LongFormat ) ) );
tmplabel->setTextInteractionFlags( Qt::TextSelectableByMouse );
gridlayout->addWidget( tmplabel, 1, 0, 1, 2 );
m_modifyDateLabel = new QLabel( page );
- m_modifyDateLabel->setText( i18n( "Modified: %1", KLocale::global()->formatDateTime( ann->modificationDate(), KLocale::LongDate, true ) ) );
+ m_modifyDateLabel->setText( i18n( "Modified: %1", QLocale().toString( ann->modificationDate(), QLocale::LongFormat ) ) );
m_modifyDateLabel->setTextInteractionFlags( Qt::TextSelectableByMouse );
gridlayout->addWidget( m_modifyDateLabel, 2, 0, 1, 2 );
@@ -176,7 +176,7 @@ void AnnotsPropertiesDialog::slotapply()
m_document->modifyPageAnnotationProperties( m_page, m_annot );
- m_modifyDateLabel->setText( i18n( "Modified: %1", KLocale::global()->formatDateTime( m_annot->modificationDate(), KLocale::LongDate, true ) ) );
+ m_modifyDateLabel->setText( i18n( "Modified: %1", QLocale().toString( m_annot->modificationDate(), QLocale::LongFormat ) ) );
modified = false;
button( QDialogButtonBox::Apply )->setEnabled( false );
diff --git a/ui/annotationwidgets.cpp b/ui/annotationwidgets.cpp
index df20203..6b30845 100644
--- a/ui/annotationwidgets.cpp
+++ b/ui/annotationwidgets.cpp
@@ -21,9 +21,10 @@
#include <kfontrequester.h>
#include <QIcon>
#include <kiconloader.h>
-#include <klocale.h>
-#include <QtCore/QDebug>
+#include <KLocalizedString>
+#include <QDebug>
#include <QMimeDatabase>
+#include <KFormat>
#include "core/document.h"
#include "guiutils.h"
@@ -659,7 +660,7 @@ QWidget * FileAttachmentAnnotationWidget::createExtraWidget()
Okular::EmbeddedFile *ef = m_attachAnn->embeddedFile();
const int size = ef->size();
- const QString sizeString = size <= 0 ? i18nc( "Not available size", "N/A" ) : KLocale::global()->formatByteSize( size );
+ const QString sizeString = size <= 0 ? i18nc( "Not available size", "N/A" ) : KFormat::formatByteSize( size );
const QString descString = ef->description().isEmpty() ? i18n( "No description available." ) : ef->description();
QGridLayout * lay = new QGridLayout( widget );
diff --git a/ui/annotwindow.cpp b/ui/annotwindow.cpp
index 2dbf876..403ae7c 100644
--- a/ui/annotwindow.cpp
+++ b/ui/annotwindow.cpp
@@ -155,7 +155,7 @@ public:
void setDate( const QDateTime& dt )
{
- dateLabel->setText( KLocale::global()->formatDateTime( dt, KLocale::ShortDate, true ) + ' ' );
+ dateLabel->setText( QLocale().toString( dt, QLocale::ShortFormat ) + ' ' );
}
void setAuthor( const QString& author )
diff --git a/ui/embeddedfilesdialog.cpp b/ui/embeddedfilesdialog.cpp
index 899e1fa..5a7da8e 100644
--- a/ui/embeddedfilesdialog.cpp
+++ b/ui/embeddedfilesdialog.cpp
@@ -17,7 +17,7 @@
#include <kglobal.h>
#include <QIcon>
-#include <klocale.h>
+#include <KLocalizedString>
#include <QMimeType>
#include <QMimeDatabase>
#include <kstandardguiitem.h>
@@ -25,7 +25,6 @@
#include <KConfigGroup>
#include <QDialogButtonBox>
#include <QPushButton>
-#include <KGuiItem>
#include <QVBoxLayout>
#include "core/document.h"
@@ -38,7 +37,7 @@ static const int EmbeddedFileRole = Qt::UserRole + 100;
static QString dateToString( const QDateTime & date )
{
return date.isValid()
- ? KLocale::global()->formatDateTime( date, KLocale::LongDate, true )
+ ? QLocale().toString( date, QLocale::LongFormat )
: i18nc( "Unknown date", "Unknown" );
}
diff --git a/ui/pageview.cpp b/ui/pageview.cpp
index ae25a77..f1886d3 100644
--- a/ui/pageview.cpp
+++ b/ui/pageview.cpp
@@ -40,7 +40,7 @@
#include <kactionmenu.h>
#include <kstandardaction.h>
#include <kactioncollection.h>
-#include <klocale.h>
+#include <KLocalizedString>
#include <kfiledialog.h>
#include <kglobal.h>
#include <kselectaction.h>
@@ -3668,7 +3668,7 @@ void PageView::updateZoom( ZoomMode newZoomMode )
// kdelibs4 sometimes adds accelerators to actions' text directly :(
z.remove ('&');
z.remove ('%');
- newFactor = KLocale::global()->readNumber( z ) / 100.0;
+ newFactor = QLocale().toDouble( z ) / 100.0;
}break;
case ZoomIn:
case ZoomOut:{
@@ -3790,10 +3790,10 @@ void PageView::updateZoomText()
if ( !inserted )
selIdx++;
// we do not need to display 2-digit precision
- QString localValue( KLocale::global()->formatNumber( value * 100.0, 1 ) );
- localValue.remove( KLocale::global()->decimalSymbol() + single_oh );
+ QString localValue( QLocale().toString( value * 100.0, 'g', 1 ) );
+ localValue.remove( QLocale().decimalPoint() + single_oh );
// remove a trailing zero in numbers like 66.70
- if ( localValue.right( 1 ) == QLatin1String( "0" ) && localValue.indexOf( KLocale::global()->decimalSymbol() ) > -1 )
+ if ( localValue.right( 1 ) == QLatin1String( "0" ) && localValue.indexOf( QLocale().decimalPoint() ) > -1 )
localValue.chop( 1 );
translated << QString( "%1%" ).arg( localValue );
}