Commit e9ae1d99 authored by Lukáš Tinkl's avatar Lukáš Tinkl
Browse files

port away from KLocale

parent fd6a3548
......@@ -24,7 +24,6 @@
#include <KAboutData>
#include <KCmdLineArgs>
#include <KDebug>
#include <KDE/KLocale>
#include <KConfigGroup>
#include "kdeclarativemainwindow.h"
......
......@@ -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");
}
......@@ -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
......
......@@ -58,7 +58,6 @@ struct GeneratorInfo
Okular::Generator * generator;
KComponentData data;
QString catalogName;
Okular::ConfigInterface * config;
Okular::SaveInterface * save;
bool configChecked : 1;
......
......@@ -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;
......
......@@ -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 );
......
......@@ -13,7 +13,7 @@
#include <QXmlStreamReader>
#include <KFilterDev>
#include <KLocale>
#include <KLocalizedString>
#include <KMessageBox>
using namespace OOO;
......
......@@ -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" ) );
}
......
......@@ -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;
......
......@@ -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() );
}
}
......
......@@ -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") {
......
......@@ -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 );
......
......@@ -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 );
......
......@@ -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 )
......
......@@ -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" );
}
......
......@@ -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 );
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment