Commit 1dee8fe1 authored by Halla Rempt's avatar Halla Rempt

Fix import resources after KoFileDialog api changes.

parent 6c266016
......@@ -137,65 +137,57 @@ void ResourceManager::slotImport()
KoFileDialog dlg(m_view, KoFileDialog::OpenFiles, "krita_resources");
dlg.setCaption(i18n("Add Resources"));
QStringList nameFilters;
nameFilters << i18n("GIMP Brushes (*.gbr)")
<< i18n("Imagepipe Brushes (*.gih)")
<< i18n("Photoshop Brushes (*.abr)")
<< i18n("PNG Brushes (*.png)")
<< i18n("SVG Brushes (*.svg)")
<< i18n("Brush Presets (*.kpp)")
<< i18n("GIMP Gradients (*.ggr)")
<< i18n("SVG Gradients (*.svg)")
<< i18n("Karbon Gradients (*.kgr)")
<< i18n("Resource Bundles (*.bundle)")
<< i18n("GIMP Patterns (*.pat)")
<< i18n("Jpeg Patterns (*.jpg)")
<< i18n("Gif Patterns (*.gif)")
<< i18n("PNG Patterns (*.png)")
<< i18n("Tiff Patterns (*.tif)")
<< i18n("XPM Patterns (*.xpm)")
<< i18n("BMP Patterns (*.bmp)")
<< i18n("Palettes (*.gpl *.pal *.act *.aco *.colors)")
<< i18n("Workspaces (*.kts)");
QMap<QString, QString> filterToTypeMap;
filterToTypeMap[i18n("Krita Brush Presets (*.kpp)")] = "presets";
filterToTypeMap[i18n("GIMP Brushes (*.gbr)")] = "brushes";
filterToTypeMap[i18n("Imagepipe Brushes (*.gih)")] = "brushes";
filterToTypeMap[i18n("Photoshop Brushes (*.abr)")] = "brushes";
filterToTypeMap[i18n("PNG Brushes (*.png)")] = "brushes";
filterToTypeMap[i18n("SVG Brushes (*.svg)")] = "brushes";
filterToTypeMap[i18n("Brush Presets (*.kpp)")] = "brushes";
filterToTypeMap[i18n("GIMP Gradients (*.ggr)")] = "gradients";
filterToTypeMap[i18n("SVG Gradients (*.svg)")] = "gradients";
filterToTypeMap[i18n("Karbon Gradients (*.kgr)")] = "gradients";
filterToTypeMap[i18n("Resource Bundles (*.bundle)")] = "bundles";
filterToTypeMap[i18n("GIMP Patterns (*.pat)")] = "patterns";
filterToTypeMap[i18n("JPEG Patterns (*.jpg)")] = "patterns";
filterToTypeMap[i18n("GIF Patterns (*.gif)")] = "patterns";
filterToTypeMap[i18n("PNG Patterns (*.png)")] = "patterns";
filterToTypeMap[i18n("TIFF Patterns (*.tif)")] = "patterns";
filterToTypeMap[i18n("XPM Patterns (*.xpm)")] = "patterns";
filterToTypeMap[i18n("BMP Patterns (*.bmp)")] = "patterns";
filterToTypeMap[i18n("Palettes (*.gpl *.pal *.act *.aco *.colors)")] = "palettes";
filterToTypeMap[i18n("Workspaces (*.kts)")] = "workspaces";
QStringList nameFilters = filterToTypeMap.keys();
dlg.setNameFilters(nameFilters, nameFilters.first());
QStringList resources = dlg.urls();
QString resourceType = dlg.selectedNameFilter();
resourceType = resourceType.left(resourceType.indexOf(" ("));
int i = -1;
foreach(const QString &nf, nameFilters) {
i++;
if (nf.startsWith(resourceType)) {
break;
}
if (!filterToTypeMap.contains(resourceType)) {
QMessageBox::warning(0, i18n("Importing Resources"), i18n("The selected resource type is unknown."));
return;
}
switch(i) {
case 0:
{
resourceType = filterToTypeMap[resourceType];
if (resourceType == "brushes") {
foreach(const QString &res, resources) {
d->brushServer->importResourceFile(res);
}
break;
}
case 1:
{
else if (resourceType == "presets") {
foreach(const QString &res, resources) {
d->paintopServer->importResourceFile(res);
}
break;
}
case 2:
{
else if (resourceType == "gradients") {
foreach(const QString &res, resources) {
d->gradientServer->importResourceFile(res);
}
break;
}
case 3:
{
else if (resourceType == "bundles") {
foreach(const QString &res, resources) {
d->bundleServer->importResourceFile(res);
ResourceBundle *bundle = d->bundleServer->resourceByFilename(QFileInfo(res).fileName());
......@@ -203,32 +195,26 @@ void ResourceManager::slotImport()
bundle->install();
}
}
break;
}
case 4:
{
else if (resourceType == "patterns") {
foreach(const QString &res, resources) {
d->patternServer->importResourceFile(res);
}
break;
}
case 5:
{
else if (resourceType == "palettes") {
foreach(const QString &res, resources) {
d->paletteServer->importResourceFile(res);
}
break;
}
case 6:
{
else if (resourceType == "workspaces") {
foreach(const QString &res, resources) {
d->workspaceServer->importResourceFile(res);
}
break;
}
default:
else {
qWarning() << "Trying to add a resource of an undefined type";
}
}
void ResourceManager::slotCreateBundle()
......
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