Commit f71e7498 authored by Boudewijn Rempt's avatar Boudewijn Rempt

Copy bundles to the local bundle folder from args

If Krita is started with a bundle file as an argument, do not open
it, but copy it to the bundle folder. You can also drop a bundle
on the mainwindow but it won't be loaded in that case.

BUG:394485
(cherry picked from commit 8fff40a2)
parent 877cb51d
......@@ -232,7 +232,7 @@ void KisApplication::initializeGlobals(const KisApplicationArguments &args)
void KisApplication::addResourceTypes()
{
// qDebug() << "addResourceTypes();";
// qDebug() << "addResourceTypes();";
// All Krita's resource types
KoResourcePaths::addResourceType("kis_pics", "data", "/pics/");
KoResourcePaths::addResourceType("kis_images", "data", "/images/");
......@@ -299,7 +299,7 @@ void KisApplication::addResourceTypes()
void KisApplication::loadResources()
{
// qDebug() << "loadResources();";
// qDebug() << "loadResources();";
setSplashScreenLoadingText(i18n("Loading Resources..."));
processEvents();
......@@ -320,7 +320,7 @@ void KisApplication::loadResources()
void KisApplication::loadResourceTags()
{
// qDebug() << "loadResourceTags()";
// qDebug() << "loadResourceTags()";
KoResourceServerProvider::instance()->patternServer()->loadTags();
KoResourceServerProvider::instance()->gradientServer()->loadTags();
......@@ -337,7 +337,7 @@ void KisApplication::loadResourceTags()
void KisApplication::loadPlugins()
{
// qDebug() << "loadPlugins();";
// qDebug() << "loadPlugins();";
KoShapeRegistry* r = KoShapeRegistry::instance();
r->add(new KisShapeSelectionFactory());
......@@ -351,11 +351,11 @@ void KisApplication::loadPlugins()
void KisApplication::loadGuiPlugins()
{
// qDebug() << "loadGuiPlugins();";
// qDebug() << "loadGuiPlugins();";
// Load the krita-specific tools
setSplashScreenLoadingText(i18n("Loading Plugins for Krita/Tool..."));
processEvents();
// qDebug() << "loading tools";
// qDebug() << "loading tools";
KoPluginLoader::instance()->load(QString::fromLatin1("Krita/Tool"),
QString::fromLatin1("[X-Krita-Version] == 28"));
......@@ -363,14 +363,14 @@ void KisApplication::loadGuiPlugins()
// Load dockers
setSplashScreenLoadingText(i18n("Loading Plugins for Krita/Dock..."));
processEvents();
// qDebug() << "loading dockers";
// qDebug() << "loading dockers";
KoPluginLoader::instance()->load(QString::fromLatin1("Krita/Dock"),
QString::fromLatin1("[X-Krita-Version] == 28"));
// XXX_EXIV: make the exiv io backends real plugins
setSplashScreenLoadingText(i18n("Loading Plugins Exiv/IO..."));
processEvents();
// qDebug() << "loading exiv2";
// qDebug() << "loading exiv2";
KisExiv2::initialize();
}
......@@ -571,13 +571,16 @@ bool KisApplication::start(const KisApplicationArguments &args)
QTimer::singleShot(0, this, SLOT(quit()));
}
else if (d->mainWindow) {
KisMainWindow::OpenFlags flags = d->batchRun ? KisMainWindow::BatchMode : KisMainWindow::None;
if (d->mainWindow->openDocument(QUrl::fromLocalFile(fileName), flags)) {
// Normal case, success
numberOfOpenDocuments++;
} else {
// .... if failed
// delete doc; done by openDocument
if (fileName.endsWith(".bundle")) {
d->mainWindow->installBundle(fileName);
}
else {
KisMainWindow::OpenFlags flags = d->batchRun ? KisMainWindow::BatchMode : KisMainWindow::None;
if (d->mainWindow->openDocument(QUrl::fromLocalFile(fileName), flags)) {
// Normal case, success
numberOfOpenDocuments++;
}
}
}
}
......@@ -608,7 +611,7 @@ void KisApplication::setSplashScreen(QWidget *splashScreen)
void KisApplication::setSplashScreenLoadingText(QString textToLoad)
{
if (d->splashScreen) {
//d->splashScreen->loadingLabel->setText(textToLoad);
//d->splashScreen->loadingLabel->setText(textToLoad);
d->splashScreen->setLoadingText(textToLoad);
d->splashScreen->repaint();
}
......
......@@ -954,6 +954,17 @@ bool KisMainWindow::hackIsSaving() const
return !l.owns_lock();
}
bool KisMainWindow::installBundle(const QString &fileName) const
{
QFileInfo from(fileName);
QFileInfo to(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + "/bundles/" + from.fileName());
qDebug() << "from" << from << "to" << to;
if (to.exists()) {
QFile::remove(to.canonicalFilePath());
}
return QFile::copy(fileName, QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + "/bundles/" + from.fileName());
}
bool KisMainWindow::saveDocument(KisDocument *document, bool saveas, bool isExporting)
{
if (!document) {
......@@ -1314,7 +1325,13 @@ void KisMainWindow::dropEvent(QDropEvent *event)
{
if (event->mimeData()->hasUrls() && event->mimeData()->urls().size() > 0) {
Q_FOREACH (const QUrl &url, event->mimeData()->urls()) {
openDocument(url, None);
if (url.toLocalFile().endsWith(".bundle")) {
bool r = installBundle(url.toLocalFile());
qDebug() << "\t" << r;
}
else {
openDocument(url, None);
}
}
}
}
......
......@@ -176,6 +176,9 @@ public:
*/
bool hackIsSaving() const;
/// Copy the given file into the bundle directory.
bool installBundle(const QString &fileName) const;
Q_SIGNALS:
/**
......
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