Commit 753365bb authored by Luigi Toscano's avatar Luigi Toscano

Port away from KStandardDirs, KCmdLine*, K4AboutData

... and from KApplication and KGlobal as a side effect.
parent bc6e9fed
......@@ -33,6 +33,7 @@
#include <QPrinter>
#include <QPrintDialog>
#include <QStandardPaths>
#include <KLocalizedString>
#include <KActionCollection>
......@@ -44,9 +45,6 @@
#include <libkdegamesprivate/kgamethemeselector.h>
#include <KShortcut>
#include <KUrl>
#include <KCmdLineArgs>
#include <K4AboutData>
#include <KGlobal>
#include <kmessagebox.h>
#include <KLocalizedString>
#include <qstatusbar.h>
......@@ -65,10 +63,10 @@
#include "puzzleprinter.h"
#include <ktar.h>
#include <kstandarddirs.h>
#include <kio/job.h>
#include <kstandardgameaction.h>
#include <QDir>
#include <KSharedConfig>
#include "gamevariants.h"
#include "welcomescreen.h"
......@@ -160,9 +158,6 @@ KSudoku::KSudoku()
showWelcomeScreen();
// Register the gamevariants resource
KGlobal::dirs()->addResourceType ("gamevariant", "data", KCmdLineArgs::aboutData()->appName());
updateShapesList();
// QTimer *timer = new QTimer( this );
......@@ -191,7 +186,17 @@ void KSudoku::updateShapesList()
variant->setIcon("ksudoku-roxdoku_3x3x3");
#endif
QStringList filepaths = KGlobal::dirs()->findAllResources("gamevariant", "*.desktop", KStandardDirs::NoDuplicates); // Find files.
QStringList gamevariantdirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, "ksudoku", QStandardPaths::LocateDirectory);
QStringList filepaths;
Q_FOREACH (const QString& gamevariantdir, gamevariantdirs) {
const QStringList fileNames = QDir(gamevariantdir).entryList(QStringList() << QStringLiteral("*.desktop"));
Q_FOREACH (const QString &file, fileNames) {
if (!filepaths.contains(gamevariantdir + '/' + file)) {
filepaths.append(gamevariantdir + '/' + file);
}
}
}
QString variantName;
QString variantDescr;
......@@ -867,8 +872,7 @@ void KSudoku::loadCustomShapeFromPath()
return;
}
KStandardDirs myStdDir;
const QString destDir = myStdDir.saveLocation( "data", /*kapp->instanceName() + TODO PORT */"ksudoku/", true );
const QString destDir = QStandardPaths::writableLocation( QStandardPaths::GenericDataLocation ) + QStringLiteral("/ksudoku/");
QDir().mkpath( destDir );
KTar archive( tmpFile );
......@@ -896,7 +900,7 @@ void KSudoku::enableMessages()
i18n("Enable all messages"));
if (result == KMessageBox::Yes) {
KMessageBox::enableAllMessages();
KGlobal::config()->sync(); // Save the changes to disk.
KSharedConfig::openConfig()->sync(); // Save the changes to disk.
}
}
......@@ -914,8 +918,7 @@ bool KSudokuNewStuff::install( const QString &fileName )
return false;
const KArchiveDirectory *archiveDir = archive.directory();
KStandardDirs myStdDir;
const QString destDir = myStdDir.saveLocation("data", /*kapp->instanceName() + TODO PORT*/"ksudoku/", true);
const QString destDir = QStandardPaths::writableLocation( QStandardPaths::GenericDataLocation ) + QStringLiteral("/ksudoku/");
QDir().mkpath(destDir);
archiveDir->copyTo(destDir);
......
......@@ -18,14 +18,17 @@
***************************************************************************/
#include <kapplication.h>
#include <dcopclient.h>
#include <qdatastream.h>
#include <qstring.h>
#include <QApplication>
#include <KAboutData>
#include <KLocalizedString>
int main(int argc, char **argv)
{
KApplication app(argc, argv, "ksudoku_client", false);
QApplication app(argc, argv);
// get our DCOP client and attach so that we may use it
DCOPClient *client = app.dcopClient();
......
......@@ -33,7 +33,7 @@
#include <kio/netaccess.h>
#include <qfile.h>
#include <KLocalizedString>
#include <kstandarddirs.h>
#include "ksudoku.h"
#include "symbols.h"
......
......@@ -21,7 +21,7 @@
#include "renderer.h"
#include <QSvgRenderer>
#include <KStandardDirs>
#include <kpixmapcache.h>
#include <KDebug>
#define USE_UNSTABLE_LIBKDEGAMESPRIVATE_API
......
......@@ -21,15 +21,20 @@
***************************************************************************/
#include "ksudoku.h"
#include <kapplication.h>
//#include <dcopclient.h>
#include <K4AboutData>
#include <KAboutData>
#include <KCrash>
#include <kcmdlineargs.h>
#include <KLocalizedString>
#include <kconfigdialogmanager.h>
#include <KUrl>
#include <QApplication>
#include <QCommandLineParser>
#include <QCommandLineOption>
#include <QDir>
#include <cstdlib>
#include <ctime>
......@@ -43,28 +48,35 @@ static const char version[] = "1.3";
int main(int argc, char **argv)
{
qsrand(std::time(nullptr));
QApplication app(argc, argv);
KLocalizedString::setApplicationDomain("ksudoku");
K4AboutData about("ksudoku", 0,
ki18n("KSudoku"),
KAboutData about("ksudoku",
i18n("KSudoku"),
version,
ki18n("KSudoku - Sudoku games and more"),
K4AboutData::License_GPL_V2,
ki18n("(c) 2005-2007 The KSudoku Authors"),
KLocalizedString(), "http://ksudoku.sourceforge.net/");
about.addAuthor( ki18n("Francesco Rossi"), ki18n("KSudoku Author"), "redsh@email.it" );
about.addAuthor( ki18n("Johannes Bergmeier"), ki18n("Maintainer"), "Johannes.Bergmeier@gmx.net" );
about.addAuthor( ki18n("Ian Wadham"), ki18n("New puzzle generator and solver"), "iandw.au@gmail.com" );
about.addAuthor( ki18n("Mick Kappenburg"), ki18n("Printing and export of 0.4"), "ksudoku@kappendburg.net");
about.addAuthor( ki18n("Thanks to NeHe for OpenGL tutorials"), KLocalizedString(), "nehe.gamedev.net");
about.addCredit( ki18n("David Bau"), ki18n("Algorithms for new puzzle generator and solver at davidbau.com/archives/2006/09/04/sudoku_generator.html"), "");
KCmdLineArgs::init(argc, argv, &about);
KCmdLineOptions options;
options.add("+[URL]", ki18n( "Document to open" ));
KCmdLineArgs::addCmdLineOptions(options);
KApplication app;
i18n(description),
KAboutLicense::GPL_V2,
i18n("(c) 2005-2007 The KSudoku Authors"),
QString(), "https://games.kde.org/game.php?game=ksudoku");
about.addAuthor( i18n("Francesco Rossi"), i18n("KSudoku Author"), "redsh@email.it" );
about.addAuthor( i18n("Johannes Bergmeier"), i18n("Maintainer"), "Johannes.Bergmeier@gmx.net" );
about.addAuthor( i18n("Ian Wadham"), i18n("New puzzle generator and solver"), "iandw.au@gmail.com" );
about.addAuthor( i18n("Mick Kappenburg"), i18n("Printing and export of 0.4"), "ksudoku@kappendburg.net");
about.addAuthor( i18n("Thanks to NeHe for OpenGL tutorials"), QString(), "nehe.gamedev.net");
about.addCredit( i18n("David Bau"), i18n("Algorithms for new puzzle generator and solver at davidbau.com/archives/2006/09/04/sudoku_generator.html"), "");
KAboutData::setApplicationData(about);
app.setOrganizationDomain(QStringLiteral("kde.org"));
app.setWindowIcon(QIcon::fromTheme(QStringLiteral("ksudoku")));
KLocalizedString::setApplicationDomain("ksudoku");
QCommandLineParser parser;
about.setupCommandLine(&parser);
parser.addVersionOption();
parser.addHelpOption();
parser.addPositionalArgument(QLatin1String("[URL]"), i18n( "Document to open" ));
parser.process(app);
about.processCommandLine(&parser);
KCrash::initialize();
......@@ -84,18 +96,15 @@ int main(int argc, char **argv)
widget->show();
// no session.. just start up normally
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
if (args->count() != 0)
if (parser.positionalArguments().count() != 0)
{
for (int i = 0; i < args->count(); ++i)
for (int i = 0; i < parser.positionalArguments().count(); ++i)
{
widget->loadGame(args->url(i));
widget->loadGame(QUrl::fromUserInput(parser.positionalArguments().at(i), QDir::currentPath()));
}
}
args->clear();
//} //TODO PORT
app.setWindowIcon(QIcon::fromTheme(QStringLiteral("ksudoku")));
//} //TODO PORT
return app.exec();
}
Markdown is supported
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