Git commit df82229be2d8124640bfe1ab8ea4ebce47681de3 by Giorgos Tsiapaliwkas. Committed on 24/05/2012 at 12:42. Pushed by tsiapaliwkas into branch 'master'. fix publisher's combobox and doCMake slot M +105 -12 publisher/publisher.cpp M +5 -3 publisher/publisher.h M +3 -2 templates/cmakelists http://commits.kde.org/plasmate/df82229be2d8124640bfe1ab8ea4ebce47681de3 diff --git a/publisher/publisher.cpp b/publisher/publisher.cpp index 3fcd268..11ddf36 100644 --- a/publisher/publisher.cpp +++ b/publisher/publisher.cpp @@ -14,9 +14,11 @@ #include #include = +#include +#include +#include #include #include -#include #include #include #include @@ -57,8 +59,8 @@ Publisher::Publisher(QWidget *parent, const KUrl &path, c= onst QString& type) = connect(m_exporterUrl, SIGNAL(urlSelected(const KUrl&)), this, SLOT(ad= dSuffix())); connect(m_exporterButton, SIGNAL(clicked()), this, SLOT(doExport())); - connect(m_installerButton, SIGNAL(currentIndexChanged(int)), this, SLO= T(doPlasmaPkg())); - connect(m_installerButton, SIGNAL(currentIndexChanged(int)), this, SLO= T(doCMake())); + connect(m_installerButton, SIGNAL(currentIndexChanged(int)), this, SLO= T(doPlasmaPkg(int))); + connect(m_installerButton, SIGNAL(currentIndexChanged(int)), this, SLO= T(doCMake(int))); connect(m_publisherButton, SIGNAL(clicked()), this, SLOT(doPublish())); = // Publish only works right for Plasmoid now afaik. Disabling for othe= r project types. @@ -126,7 +128,7 @@ void Publisher::doExport() } bool ok =3D exportToFile(m_exporterUrl->url()); = - // If signign is enabled, lets do that! + // If signing is enabled, lets do that! if (m_signingWidget->signingEnabled()) { ok =3D ok && m_signingWidget->sign(m_exporterUrl->url()); } @@ -139,16 +141,21 @@ void Publisher::doExport() } = // Plasmoid specific, for now -void Publisher::doCMake() +void Publisher::doCMake(int index) { + //check if this the index that we want + if (index !=3D 2) { + return; + } + if (m_projectType !=3D "Plasma/Applet") { qDebug() << "chaos"; return; } = - qDebug() << "aei gamis"; - const KUrl tempPackage(tempPackagePath()); + //this is the CMakeLists.txt from the templates directory QFile cmakeListsSourceFile(KStandardDirs::locate("appdata", "templates= /") + "cmakelists"); + QFile cmakeListsDestinationFile(m_projectPath.pathOrUrl() + "CMakeList= s.txt"); = cmakeListsSourceFile.open(QIODevice::ReadOnly); @@ -164,21 +171,107 @@ void Publisher::doCMake() = cmakeListsDestinationFile.close(); cmakeListsSourceFile.close(); - QStringList argv("cmake"); - argv.append("-DCMAKE_INSTALL_PREFIX=3D$HOME"); - argv.append(tempPackagePath()); - if(KProcess::execute(argv) >=3D 0 ? true: false) { + + //we need the last loaded package which also is the current package. + KConfigGroup cg(KGlobal::config(), "PackageModel::package"); + QString packagePath(cg.readEntry("lastLoadedPackage", QString())); + + //create a temporary build dir + QDir dir(packagePath); + dir.mkdir("build/"); + + //cd build/ + dir.cd("build/"); + + //initilize the processes + KProcess cmake; + KProcess makeInstall; + + //KProcess isn't aware of the QDir::cd, so we need to + //change current directory + cmake.setWorkingDirectory(dir.path()); + makeInstall.setWorkingDirectory(dir.path()); + + //the cmake's arguments + QStringList cmakeArgv; + // cmakeArgv.append("-DCMAKE_INSTALL_PREFIX=3D`kde4-config --prefix`"); + cmakeArgv.append("-DCMAKE_INSTALL_PREFIX=3D" + QString(qgetenv("KDEDIR= S"))); + cmakeArgv.append(".."); + + //the make install arguments + QStringList makeInstallArgv("install"); + + cmake.setProgram("cmake", cmakeArgv); + makeInstall.setProgram("make", makeInstallArgv); + + //start the processes + cmake.start(); + + //cmake must finish before make install + cmake.waitForFinished(); + makeInstall.start(); + + //make install must finish before the KMessageBox + makeInstall.waitForFinished(); + + bool processStatus =3D false; + processStatus =3D cmakeProcessStatus(cmake.error()); + processStatus =3D cmakeProcessStatus(makeInstall.error()); + + if(processStatus) { QDBusInterface dbi("org.kde.kded", "/kbuildsycoca", "org.kde.kbuil= dsycoca"); dbi.call(QDBus::NoBlock, "recreate"); + KMessageBox::information(this, i18n("Project has been installed")); } else { KMessageBox::error(this, i18n("Project has not been installed")); return; } + + //now delete the temporary build directory. We don't need it anymore + KIO::del(packagePath + "build", KIO::HideProgressInfo); } = +//we need this method in order to avoid duplication of code. +bool Publisher::cmakeProcessStatus(QProcess::ProcessError error) +{ + switch (error) { + case QProcess::FailedToStart: { + return true; + break; + } + case QProcess::Crashed: { + return true; + break; + } + case QProcess::Timedout: { + return true; + break; + } + case QProcess::WriteError: { + return true; + break; + } + case QProcess::ReadError: { + return true; + break; + } + case QProcess::UnknownError: { + return true; + } + } + + return false; +} + + // Plasmoid specific, for now -void Publisher::doPlasmaPkg() +void Publisher::doPlasmaPkg(int index) { + //check if this the index that we want + if (index !=3D 1) { + return; + } + const KUrl tempPackage(tempPackagePath()); qDebug() << "tempPackagePath" << tempPackage.pathOrUrl(); qDebug() << "m_projectPath" << m_projectPath.pathOrUrl(); diff --git a/publisher/publisher.h b/publisher/publisher.h index 6eba693..ee57cf3 100644 --- a/publisher/publisher.h +++ b/publisher/publisher.h @@ -12,9 +12,10 @@ = #include #include +#include = class KUrlRequester; -class QPushButton; +class KPushButton; class QCheckBox; class SigningWidget; class QComboBox; @@ -35,10 +36,11 @@ private slots: void doExport(); void addSuffix(); void doPublish(); - void doPlasmaPkg(); - void doCMake(); + void doPlasmaPkg(int index); + void doCMake(int index); = private: + bool cmakeProcessStatus(QProcess::ProcessError error); bool exportToFile(const KUrl& url); const QString tempPackagePath(); = diff --git a/templates/cmakelists b/templates/cmakelists index c3e2ce9..5cb4dae 100644 --- a/templates/cmakelists +++ b/templates/cmakelists @@ -12,5 +12,6 @@ include_directories( ${KDE4_INCLUDES} ) = -install(DIRECTORY ${projectPlasmate}/ DESTINATION ${DATA_INSTALL_DIR}/plas= ma/plasmoids/${projectPlasmate}) -install(FILES ${projectPlasmate}/metadata.desktop DESTINATION ${SERVICES_I= NSTALL_DIR} RENAME plasma-applet-${projectPlasmate}.desktop) \ No newline at end of file +install(DIRECTORY contents/ DESTINATION ${DATA_INSTALL_DIR}/plasma/plasmoi= ds/${projectPlasmate}) +install(FILES metadata.desktop DESTINATION ${DATA_INSTALL_DIR}/plasma/plas= moids/${projectPlasmate}) +install(FILES metadata.desktop DESTINATION ${SERVICES_INSTALL_DIR} RENAME = plasma-applet-${projectPlasmate}.desktop) \ No newline at end of file