Commit 2b61f4e6 authored by Lukas Appelhans's avatar Lukas Appelhans

FINALLY proper input handling... fuck shit QCoreApplication

parent 07e6a2e1
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
*/ */
#include <kcmdlineargs.h> #include <kcmdlineargs.h>
#include <klocalizedstring.h> #include <klocalizedstring.h>
#include <kuniqueapplication.h> #include <qcoreapplication.h>
#include <kaboutdata.h> #include <kaboutdata.h>
#include <kdebug.h> #include <kdebug.h>
#include "apm.h" #include "apm.h"
...@@ -79,14 +79,14 @@ int main(int argc, char** argv) ...@@ -79,14 +79,14 @@ int main(int argc, char** argv)
KCmdLineArgs::addCmdLineOptions(options); KCmdLineArgs::addCmdLineOptions(options);
// Add options from other components // Add options from other components
KUniqueApplication::addCmdLineOptions(); //KUniqueApplication::addCmdLineOptions();
if (!KUniqueApplication::start()) { //if (!KUniqueApplication::start()) {
fprintf(stderr, "Akabei is already running!\n"); // fprintf(stderr, "Akabei is already running!\n");
return 0; // return 0;
} //}
KUniqueApplication app; QCoreApplication app(argc, argv);
KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
...@@ -191,7 +191,7 @@ int main(int argc, char** argv) ...@@ -191,7 +191,7 @@ int main(int argc, char** argv)
for (int i = 0; i < args->count(); i++) { for (int i = 0; i < args->count(); i++) {
rest << args->arg(i); rest << args->arg(i);
} }
args->clear(); // Free up some memory args->clear(); // Free up some memory
APM apm(type, list, opts, rest); APM apm(type, list, opts, rest);
......
...@@ -183,20 +183,20 @@ void SyncOperation::install(QUuid , QList< Akabei::Package* > packages) ...@@ -183,20 +183,20 @@ void SyncOperation::install(QUuid , QList< Akabei::Package* > packages)
out << ","; out << ",";
} }
out << "." << endl; out << "." << endl;
out << i18n("Do you want to reinstall them?[y/n]"); out << i18n("Do you want to reinstall them?[Y/n]");
} else { } else {
out << i18n("The package %1 (%2) is already installed.", local.values().first()->name(), local.values().first()->version().toByteArray().data()) << endl; out << i18n("The package %1 (%2) is already installed.", local.values().first()->name(), local.values().first()->version().toByteArray().data()) << endl;
out << i18n("Do you want to reinstall it?[y/n]"); out << i18n("Do you want to reinstall it?[Y/n]");
} }
out.flush(); out.flush();
std::string input; std::string input;
getline(std::cin, input); getline(std::cin, input);
out << QLatin1String(input.c_str()) << endl; if (!input.empty() && input != i18n("y").toStdString()) {
if (input != i18n("y").toStdString()) QCoreApplication::instance()->quit();
return; return;
}
} }
kDebug() << "Let's do this";
foreach (Akabei::Package * pkg, toBeInstalled.values()) { foreach (Akabei::Package * pkg, toBeInstalled.values()) {
AkabeiClient::Backend::instance()->queue()->addPackage(pkg, AkabeiClient::Install); AkabeiClient::Backend::instance()->queue()->addPackage(pkg, AkabeiClient::Install);
...@@ -250,13 +250,14 @@ void SyncOperation::validationFinished(bool valid) ...@@ -250,13 +250,14 @@ void SyncOperation::validationFinished(bool valid)
out << i18n("Installed size: %1", KIO::convertSize(installSize)) << endl; out << i18n("Installed size: %1", KIO::convertSize(installSize)) << endl;
out.flush(); out.flush();
out << i18n("Continue with installation?[y/n]"); out << i18n("Continue with installation?[Y/n]");
out.flush(); out.flush();
//std::string input; std::string input;
//getline(std::cin, input); getline(std::cin, input);
//if (input != "y") if (!input.empty() && input != i18n("y").toStdString()) {
// return; QCoreApplication::instance()->quit();
kDebug() << "Let's install"; return;
}
connect(AkabeiClient::Backend::instance()->transactionHandler(), SIGNAL(progressChanged(int)), SLOT(showProgress(int))); connect(AkabeiClient::Backend::instance()->transactionHandler(), SIGNAL(progressChanged(int)), SLOT(showProgress(int)));
connect(AkabeiClient::Backend::instance()->transactionHandler(), SIGNAL(finished()), SLOT(finished())); connect(AkabeiClient::Backend::instance()->transactionHandler(), SIGNAL(finished()), SLOT(finished()));
AkabeiClient::Backend::instance()->transactionHandler()->process(); AkabeiClient::Backend::instance()->transactionHandler()->process();
......
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