394
401
d->zoomPlusAction = KStandardAction::zoomIn(this, SLOT(slotIncreaseZoom()), this);
395
402
actionCollection()->addAction("editorwindow_zoomplus", d->zoomPlusAction);
396
d->zoomPlusAction->setShortcut(QKeySequence(Qt::Key_Plus));
403
d->zoomPlusAction->setShortcut(KShortcut(Qt::Key_Plus));
398
405
d->zoomMinusAction = KStandardAction::zoomOut(this, SLOT(slotDecreaseZoom()), this);
399
406
actionCollection()->addAction("editorwindow_zoomminus", d->zoomMinusAction);
400
d->zoomMinusAction->setShortcut(QKeySequence(Qt::Key_Minus));
407
d->zoomMinusAction->setShortcut(KShortcut(Qt::Key_Minus));
402
409
d->zoomTo100percents = new KAction(KIcon("zoom-original"), i18n("Zoom to 100%"), this);
403
d->zoomTo100percents->setShortcut(Qt::ALT+Qt::CTRL+Qt::Key_0); // NOTE: Photoshop 7 use ALT+CTRL+0
410
d->zoomTo100percents->setShortcut(KShortcut(Qt::ALT+Qt::CTRL+Qt::Key_0)); // NOTE: Photoshop 7 use ALT+CTRL+0
404
411
connect(d->zoomTo100percents, SIGNAL(triggered()), this, SLOT(slotZoomTo100Percents()));
405
412
actionCollection()->addAction("editorwindow_zoomto100percents", d->zoomTo100percents);
407
414
d->zoomFitToWindowAction = new KToggleAction(KIcon("zoom-fit-best"), i18n("Fit to &Window"), this);
408
d->zoomFitToWindowAction->setShortcut(Qt::CTRL+Qt::SHIFT+Qt::Key_E); // NOTE: Gimp 2 use CTRL+SHIFT+E.
415
d->zoomFitToWindowAction->setShortcut(KShortcut(Qt::CTRL+Qt::SHIFT+Qt::Key_E)); // NOTE: Gimp 2 use CTRL+SHIFT+E.
409
416
connect(d->zoomFitToWindowAction, SIGNAL(triggered()), this, SLOT(slotToggleFitToWindow()));
410
417
actionCollection()->addAction("editorwindow_zoomfit2window", d->zoomFitToWindowAction);
412
419
d->zoomFitToSelectAction = new KAction(KIcon("zoom-select-fit"), i18n("Fit to &Selection"), this);
413
d->zoomFitToSelectAction->setShortcut(Qt::ALT+Qt::CTRL+Qt::Key_S); // NOTE: Photoshop 7 use ALT+CTRL+0
420
d->zoomFitToSelectAction->setShortcut(KShortcut(Qt::ALT+Qt::CTRL+Qt::Key_S)); // NOTE: Photoshop 7 use ALT+CTRL+0
414
421
connect(d->zoomFitToSelectAction, SIGNAL(triggered()), this, SLOT(slotFitToSelect()));
415
422
actionCollection()->addAction("editorwindow_zoomfit2select", d->zoomFitToSelectAction);
416
423
d->zoomFitToSelectAction->setEnabled(false);
417
424
d->zoomFitToSelectAction->setWhatsThis(i18n("This option can be used to zoom the image to the "
418
425
"current selection area."));
427
// --------------------------------------------------------
420
429
d->zoomCombo = new KComboBox(true);
421
430
d->zoomCombo->setDuplicatesEnabled(false);
422
431
d->zoomCombo->setFocusPolicy(Qt::ClickFocus);
423
432
d->zoomCombo->setInsertPolicy(QComboBox::NoInsert);
424
d->zoomCombo->insertItem(-1, QString("10%"));
425
d->zoomCombo->insertItem(-1, QString("25%"));
426
d->zoomCombo->insertItem(-1, QString("50%"));
427
d->zoomCombo->insertItem(-1, QString("75%"));
428
d->zoomCombo->insertItem(-1, QString("100%"));
429
d->zoomCombo->insertItem(-1, QString("150%"));
430
d->zoomCombo->insertItem(-1, QString("200%"));
431
d->zoomCombo->insertItem(-1, QString("300%"));
432
d->zoomCombo->insertItem(-1, QString("450%"));
433
d->zoomCombo->insertItem(-1, QString("600%"));
434
d->zoomCombo->insertItem(-1, QString("800%"));
435
d->zoomCombo->insertItem(-1, QString("1200%"));
434
QList<double> zoomLevels;
446
zoomLevels << 1200.0;
448
foreach (const double zoom, zoomLevels)
450
d->zoomCombo->addItem(QString("%1%").arg((int)zoom),
437
454
connect(d->zoomCombo, SIGNAL(activated(int)),
438
this, SLOT(slotZoomSelected()) );
455
this, SLOT(slotZoomSelected(int)));
440
457
connect(d->zoomCombo, SIGNAL(returnPressed(const QString&)),
441
this, SLOT(slotZoomTextChanged(const QString &)) );
458
this, SLOT(slotZoomTextChanged(const QString&)));
443
460
d->zoomComboAction = new QWidgetAction(this);
444
461
d->zoomComboAction->setDefaultWidget(d->zoomCombo);
445
462
d->zoomComboAction->setText(i18n("Zoom"));
446
463
actionCollection()->addAction("editorwindow_zoomto", d->zoomComboAction);
465
// --------------------------------------------------------
448
467
m_fullScreenAction = KStandardAction::fullScreen(this, SLOT(slotToggleFullScreen()), this, this);
449
468
actionCollection()->addAction("editorwindow_fullscreen", m_fullScreenAction);
451
470
d->slideShowAction = new KAction(KIcon("view-presentation"), i18n("Slideshow"), this);
452
d->slideShowAction->setShortcut(Qt::Key_F9);
471
d->slideShowAction->setShortcut(KShortcut(Qt::Key_F9));
453
472
connect(d->slideShowAction, SIGNAL(triggered()), this, SLOT(slotToggleSlideShow()));
454
473
actionCollection()->addAction("editorwindow_slideshow", d->slideShowAction);
456
475
d->viewUnderExpoAction = new KToggleAction(KIcon("underexposure"),
457
476
i18n("Under-Exposure Indicator"), this);
458
d->viewUnderExpoAction->setShortcut(Qt::Key_F10);
477
d->viewUnderExpoAction->setShortcut(KShortcut(Qt::Key_F10));
459
478
connect(d->viewUnderExpoAction, SIGNAL(triggered(bool)), this, SLOT(slotSetUnderExposureIndicator(bool)));
460
479
actionCollection()->addAction("editorwindow_underexposure", d->viewUnderExpoAction);
462
481
d->viewOverExpoAction = new KToggleAction(KIcon("overexposure"),
463
482
i18n("Over-Exposure Indicator"), this);
464
d->viewOverExpoAction->setShortcut(Qt::Key_F11);
483
d->viewOverExpoAction->setShortcut(KShortcut(Qt::Key_F11));
465
484
connect(d->viewOverExpoAction, SIGNAL(triggered(bool)), this, SLOT(slotSetOverExposureIndicator(bool)));
466
485
actionCollection()->addAction("editorwindow_overexposure", d->viewOverExpoAction);
468
487
d->viewCMViewAction = new KToggleAction(KIcon("video-display"), i18n("Color-Managed View"), this);
469
d->viewCMViewAction->setShortcut(Qt::Key_F12);
488
d->viewCMViewAction->setShortcut(KShortcut(Qt::Key_F12));
470
489
connect(d->viewCMViewAction, SIGNAL(triggered()), this, SLOT(slotToggleColorManagedView()));
471
490
actionCollection()->addAction("editorwindow_cmview", d->viewCMViewAction);
1159
1193
bool EditorWindow::promptForOverWrite()
1161
QFileInfo fi(m_canvas->currentImageFilePath());
1162
QString warnMsg(i18n("About to overwrite file \"%1\"\nAre you sure?", fi.fileName()));
1163
return (KMessageBox::warningContinueCancel(this,
1166
KGuiItem(i18n("Overwrite")),
1167
KStandardGuiItem::cancel(),
1168
QString("editorWindowSaveOverwrite"))
1169
== KMessageBox::Continue);
1196
KUrl destination = saveDestinationUrl();
1198
if (destination.isLocalFile())
1201
QFileInfo fi(m_canvas->currentImageFilePath());
1202
QString warnMsg(i18n("About to overwrite file \"%1\"\nAre you sure?", fi.fileName()));
1203
return (KMessageBox::warningContinueCancel(this,
1206
KGuiItem(i18n("Overwrite")),
1207
KStandardGuiItem::cancel(),
1208
QString("editorWindowSaveOverwrite"))
1209
== KMessageBox::Continue);
1214
// in this case kio handles the overwrite request
1172
1220
bool EditorWindow::promptUserSave(const KUrl& url, SaveOrSaveAs saveOrSaveAs, bool allowCancel)
1446
kDebug(digiKamAreaCode) << "renaming to " << m_savingContext->destinationURL.toLocalFile();
1450
finishSaving(false);
1454
m_canvas->setUndoHistoryOrigin();
1456
// remove image from cache since it has changed
1457
LoadingCacheInterface::fileChanged(m_savingContext->destinationURL.toLocalFile());
1458
// this won't be in the cache, but does not hurt to do it anyway
1459
LoadingCacheInterface::fileChanged(filename);
1461
// restore state of disabled actions. saveIsComplete can start any other task
1462
// (loading!) which might itself in turn change states
1467
// Take all actions necessary to update information and re-enable sidebar
1470
else if (m_savingContext->savingState == SavingContextContainer::SavingStateSaveAs)
1472
m_savingContext->savingState = SavingContextContainer::SavingStateNone;
1477
if (!m_savingContext->abortingSaving)
1479
KMessageBox::error(this, i18n("Failed to save file\n\"%1\"\nto\n\"%2\".",
1480
m_savingContext->destinationURL.fileName(),
1481
m_savingContext->destinationURL.toLocalFile()));
1483
finishSaving(false);
1487
// Only try to write Exif if both src and destination are JPEG files
1489
kDebug(digiKamAreaCode) << "renaming to " << m_savingContext->destinationURL.toLocalFile();
1493
finishSaving(false);
1497
m_canvas->setUndoHistoryOrigin();
1499
LoadingCacheInterface::fileChanged(m_savingContext->destinationURL.toLocalFile());
1500
LoadingCacheInterface::fileChanged(filename);
1505
// Take all actions necessary to update information and re-enable sidebar
1535
kWarning() << "Why was slotSavingFinished called "
1536
<< "if we did not want to save a file?";
1510
1541
void EditorWindow::finishSaving(bool success)
1569
void EditorWindow::setupTempSaveFile(const KUrl & url)
1572
QString tempDir = url.directory(KUrl::AppendTrailingSlash);
1573
// use magic file extension which tells the digikamalbums ioslave to ignore the file
1574
m_savingContext->saveTempFile = new KTemporaryFile();
1575
// if the destination url is on local file system, try to set the temp file
1576
// location to the destination folder, otherwise use a local default
1577
if (url.isLocalFile())
1579
m_savingContext->saveTempFile->setPrefix(tempDir);
1581
m_savingContext->saveTempFile->setSuffix(".digikamtempfile.tmp");
1582
m_savingContext->saveTempFile->setAutoRemove(false);
1583
m_savingContext->saveTempFile->open();
1585
if (!m_savingContext->saveTempFile->open())
1587
KMessageBox::error(this, i18n("Could not open a temporary file in the folder \"%1\": %2 (%3)",
1588
tempDir, m_savingContext->saveTempFile->errorString(),
1589
m_savingContext->saveTempFile->error()));
1593
m_savingContext->saveTempFileName = m_savingContext->saveTempFile->fileName();
1594
delete m_savingContext->saveTempFile;
1595
m_savingContext->saveTempFile = 0;
1538
1599
void EditorWindow::startingSave(const KUrl& url)
1602
kDebug() << "startSaving url = " << url;
1540
1604
// avoid any reentrancy. Should be impossible anyway since actions will be disabled.
1541
1605
if (m_savingContext->savingState != SavingContextContainer::SavingStateNone)
1570
1617
m_savingContext->format = m_savingContext->originalFormat;
1571
1618
m_savingContext->abortingSaving = false;
1572
1619
m_savingContext->savingState = SavingContextContainer::SavingStateSave;
1620
m_savingContext->executedOperation = SavingContextContainer::SavingStateNone;
1574
1622
m_canvas->saveAs(m_savingContext->saveTempFileName, m_IOFileSettings,
1575
1623
m_setExifOrientationTag && (m_rotatedOrFlipped || m_canvas->exifRotated()));
1578
bool EditorWindow::startingSaveAs(const KUrl& url)
1626
QStringList EditorWindow::getWritingFilters()
1580
if (m_savingContext->savingState != SavingContextContainer::SavingStateNone)
1629
// begin with the filtersa KImageIO supports
1583
1630
QString pattern = KImageIO::pattern(KImageIO::Writing);
1584
1631
QStringList writablePattern = pattern.split(QChar('\n'));
1585
kDebug(digiKamAreaCode) << "KDE Offered pattern: " << writablePattern;
1632
kDebug() << "KImageIO offered pattern: " << writablePattern;
1634
// remove "all images" type
1635
// XXX bad assumption that this is always the first type in the list
1636
writablePattern.removeFirst();
1638
// append custom file types
1586
1639
writablePattern.append(QString("*.jp2|") + i18n("JPEG 2000 image"));
1587
1640
writablePattern.append(QString("*.pgf|") + i18n("Progressive Graphics File"));
1642
return writablePattern;
1646
QString EditorWindow::findFilterByExtension(const QStringList& allFilters, const QString& extension)
1649
kDebug() << "Searching for a filter with extension '" << extension
1650
<< "' in: " << allFilters;
1652
const QString filterExtension = QString("*.%1").arg(extension.toLower());
1654
foreach(const QString& filter, allFilters)
1657
if (filter.contains(filterExtension))
1659
kDebug() << "Found filter '" << filter << "'";
1665
// fall back to "all image types"
1666
if (!allFilters.empty() && allFilters.first().contains(filterExtension))
1668
kDebug() << "using fall back all images filter: " << allFilters.first();
1669
return allFilters.first();
1676
QString EditorWindow::getExtensionFromFilter(const QString& filter)
1679
kDebug () << "Trying to extract format from filter: " << filter;
1681
// find locations of interesting characters in the filter string
1682
const int asteriskLocation = filter.indexOf('*');
1683
if (asteriskLocation < 0)
1685
kDebug() << "Could not find a * in the filter";
1689
const int endLocation = filter.indexOf(QRegExp("[|\\* ]"), asteriskLocation + 1);
1690
if (endLocation < 0)
1692
kDebug() << "Could not find a valid end of the format in the filter";
1696
kDebug() << "astriskLocation = " << asteriskLocation
1697
<< ", endLocation = " << endLocation;
1699
// extract extension with the locations found above
1700
QString formatString = filter;
1701
formatString.remove(0, asteriskLocation + 2);
1702
formatString = formatString.left(endLocation - asteriskLocation - 2);
1703
kDebug() << "Extracted format " << formatString;
1704
return formatString;
1708
bool EditorWindow::selectValidSavingFormat(const QString& filterExtension, const KUrl& targetUrl)
1711
kDebug() << "Trying to find a saving format with filterExtension = "
1712
<< filterExtension << ", targetUrl = " << targetUrl;
1714
// build a list of valid types
1715
QStringList validTypes = KImageIO::types(KImageIO::Writing);
1716
kDebug() << "KDE Offered types: " << validTypes;
1718
validTypes << "TIF";
1719
validTypes << "TIFF";
1720
validTypes << "JPG";
1721
validTypes << "JPEG";
1722
validTypes << "JPE";
1723
validTypes << "J2K";
1724
validTypes << "JP2";
1725
validTypes << "PGF";
1727
kDebug() << "Writable formats: " << validTypes;
1729
// first check if the selected filter extension can be used
1731
if (!filterExtension.isEmpty() &&
1732
validTypes.contains(filterExtension, Qt::CaseInsensitive))
1734
kDebug() << "Using format from filter extension: " << filterExtension;
1735
m_savingContext->format = filterExtension;
1740
// as a second step, try to determine the desired format from the extension
1741
// of the target url
1744
if (targetUrl.isLocalFile())
1746
// for local files QFileInfo can be used
1747
QFileInfo fi(targetUrl.toLocalFile());
1748
suffix = fi.suffix();
1749
kDebug() << "Possible format from local file: " << suffix;
1753
// for remote files string manipulation is needed unfortunately
1754
QString fileName = targetUrl.fileName();
1755
const int periodLocation = fileName.lastIndexOf('.');
1756
if (periodLocation >= 0)
1758
suffix = fileName.right(fileName.size() - periodLocation - 1);
1760
kDebug() << "Possible format from remote file: " << suffix;
1762
if (!suffix.isEmpty() && validTypes.contains(suffix, Qt::CaseInsensitive))
1764
kDebug() << "Using format from target url " << suffix;
1765
m_savingContext->format = suffix;
1770
// another way to determine the format is to use the original file
1772
QString originalFormat(QImageReader::imageFormat(
1773
m_savingContext->srcURL.toLocalFile()));
1774
if (validTypes.contains(originalFormat, Qt::CaseInsensitive))
1776
kDebug() << "Using format from original file: " << originalFormat;
1777
m_savingContext->format = originalFormat;
1782
kDebug() << "No suitable format found";
1788
bool EditorWindow::startingSaveAs(const KUrl& url)
1791
kDebug() << "startSavingAs called";
1793
if (m_savingContext->savingState != SavingContextContainer::SavingStateNone)
1589
1796
m_savingContext->srcURL = url;
1798
// prepare the save dialog
1591
1799
FileSaveOptionsBox *options = new FileSaveOptionsBox();
1592
1800
KFileDialog *imageFileSaveDialog = new KFileDialog(m_savingContext->srcURL.isLocalFile() ?
1593
1801
m_savingContext->srcURL : KUrl(QDir::homePath()),
1612
1820
KSharedConfig::Ptr config = KGlobal::config();
1613
1821
KConfigGroup group = config->group("ImageViewer Settings");
1614
1822
QString ext = group.readEntry("LastSavedImageTypeMime", "png");
1615
QString fileName = info.baseName() + QString(".") + ext;
1823
QString fileName = info.completeBaseName() + QString(".") + ext;
1617
1825
// Determine the default filter from LastSavedImageTypeMime
1618
QString defaultFilter;
1619
foreach(const QString& filter, writablePattern)
1621
if (filter.contains(QString("*.%1").arg(ext.toLower())))
1623
defaultFilter = filter;
1627
imageFileSaveDialog->filterWidget()->setDefaultFilter(defaultFilter);
1826
QStringList writablePattern = getWritingFilters();
1628
1827
imageFileSaveDialog->setFilter(writablePattern.join(QChar('\n')));
1828
QString initialFilter = findFilterByExtension(writablePattern, ext);
1829
if (!initialFilter.isEmpty())
1831
imageFileSaveDialog->filterWidget()->setCurrentFilter(initialFilter);
1835
kWarning() << "Could not find a filter for extension " << ext
1836
<< ". Is this really writable?";
1838
kDebug() << "Using initial filter '" << initialFilter
1839
<< "' out of all possible ones:" << writablePattern;
1629
1840
imageFileSaveDialog->setSelection(fileName);
1631
1842
options->slotImageFileFormatChanged(ext);
1639
1850
applyStandardSettings();
1641
1852
KUrl newURL = imageFileSaveDialog->selectedUrl();
1643
// Check if target image format have been selected from Combo List of SaveAs dialog.
1645
QStringList mimes = KImageIO::typeForMime(imageFileSaveDialog->currentMimeFilter());
1646
if (!mimes.isEmpty())
1648
m_savingContext->format = mimes.first();
1652
// Else, check if target image format have been add to target image file name using extension.
1654
QFileInfo fi(newURL.toLocalFile());
1655
m_savingContext->format = fi.suffix();
1657
if ( m_savingContext->format.isEmpty() )
1659
// If format is empty then file format is same as that of the original file.
1660
m_savingContext->format = QImageReader::imageFormat(m_savingContext->srcURL.toLocalFile());
1664
// Else, check if format from file name extension is include on file mime type list.
1666
QStringList types = KImageIO::types(KImageIO::Writing);
1667
kDebug(digiKamAreaCode) << "KDE Offered types: " << types;
1677
QString imgExtList = types.join(" ");
1679
if ( !imgExtList.toUpper().contains( m_savingContext->format.toUpper() ) )
1681
KMessageBox::error(this, i18n("Target image file format \"%1\" unsupported.", m_savingContext->format));
1682
kWarning(digiKamAreaCode) << "target image file format " << m_savingContext->format << " unsupported!";
1853
kDebug() << "Writing file to " << newURL;
1855
// select the format to save the image with
1856
kDebug() << "filter from save dialog: " << imageFileSaveDialog->currentFilter();
1857
QString dialogExtension = getExtensionFromFilter(imageFileSaveDialog->currentFilter());
1858
kDebug() << "extracted extension from filter: " << dialogExtension;
1859
bool validFormatSet = selectValidSavingFormat(dialogExtension, newURL);
1861
if (!validFormatSet)
1863
KMessageBox::error(this, i18n("Unable to determine the format to save the target image with."));
1688
1867
if (!newURL.isValid())
1690
1869
KMessageBox::error(this, i18n("Failed to save file\n\"%1\"\nto\n\"%2\".",
1692
newURL.toLocalFile().section('/', -2, -2)));
1693
kWarning(digiKamAreaCode) << "target URL is not valid !";
1870
info.completeBaseName(),
1871
newURL.prettyUrl()));
1872
kWarning() << "target URL is not valid !";
1737
1916
// Now do the actual saving -----------------------------------------------------
1739
// use magic file extension which tells the digikamalbums ioslave to ignore the file
1741
QString tempDir = newURL.directory(KUrl::AppendTrailingSlash);
1743
m_savingContext->saveTempFile = new KTemporaryFile();
1744
m_savingContext->saveTempFile->setPrefix(tempDir);
1745
m_savingContext->saveTempFile->setSuffix(".digikamtempfile.tmp");
1746
m_savingContext->saveTempFile->setAutoRemove(false);
1748
if (!m_savingContext->saveTempFile->open())
1750
KMessageBox::error(this, i18n("Could not open a temporary file in the folder \"%1\": %2 (%3)",
1751
tempDir, m_savingContext->saveTempFile->errorString(),
1752
m_savingContext->saveTempFile->error()));
1755
m_savingContext->saveTempFileName = m_savingContext->saveTempFile->fileName();
1756
delete m_savingContext->saveTempFile;
1757
m_savingContext->saveTempFile = 0;
1918
setupTempSaveFile(newURL);
1759
1920
m_savingContext->destinationURL = newURL;
1760
1921
m_savingContext->originalFormat = m_canvas->currentImageFileFormat();
1761
1922
m_savingContext->savingState = SavingContextContainer::SavingStateSaveAs;
1923
m_savingContext->executedOperation = SavingContextContainer::SavingStateNone;
1762
1924
m_savingContext->abortingSaving = false;
1764
1926
m_canvas->saveAs(m_savingContext->saveTempFileName, m_IOFileSettings,
1798
bool EditorWindow::moveFile()
1960
void EditorWindow::moveFile()
1800
QByteArray dstFileName = QFile::encodeName(m_savingContext->destinationURL.toLocalFile());
1963
// how to move a file depends on if the file is on a local system or not.
1964
if (m_savingContext->destinationURL.isLocalFile())
1967
kDebug() << "moving a local file";
1969
QByteArray dstFileName = QFile::encodeName(m_savingContext->destinationURL.toLocalFile());
1802
// Store old permissions:
1803
// Just get the current umask.
1804
mode_t curr_umask = umask(S_IREAD | S_IWRITE);
1805
// Restore the umask.
1808
// For new files respect the umask setting.
1809
mode_t filePermissions = (S_IREAD | S_IWRITE | S_IROTH | S_IWOTH | S_IRGRP | S_IWGRP) & ~curr_umask;
1811
// For existing files, use the mode of the original file.
1812
if (m_savingContext->destinationExisted)
1815
if (::stat(dstFileName, &stbuf) == 0)
1971
// Store old permissions:
1972
// Just get the current umask.
1973
mode_t curr_umask = umask(S_IREAD | S_IWRITE);
1974
// Restore the umask.
1977
// For new files respect the umask setting.
1978
mode_t filePermissions = (S_IREAD | S_IWRITE | S_IROTH | S_IWOTH | S_IRGRP | S_IWGRP) & ~curr_umask;
1980
// For existing files, use the mode of the original file.
1981
if (m_savingContext->destinationExisted)
1817
filePermissions = stbuf.st_mode;
1984
if (::stat(dstFileName, &stbuf) == 0)
1986
filePermissions = stbuf.st_mode;
1821
// rename tmp file to dest
1990
// rename tmp file to dest
1823
1992
#if KDE_IS_VERSION(4,2,85)
1825
// KDE::rename() takes care of QString -> bytestring encoding
1826
ret = KDE::rename(m_savingContext->saveTempFileName,
1827
m_savingContext->destinationURL.toLocalFile());
1994
// KDE::rename() takes care of QString -> bytestring encoding
1995
ret = KDE::rename(m_savingContext->saveTempFileName,
1996
m_savingContext->destinationURL.toLocalFile());
1829
// KDE 4.2.x or 4.1.x
1830
ret = KDE_rename(QFile::encodeName(m_savingContext->saveTempFileName),
1835
KMessageBox::error(this, i18n("Failed to overwrite original file"),
1998
// KDE 4.2.x or 4.1.x
1999
ret = KDE_rename(QFile::encodeName(m_savingContext->saveTempFileName),
2004
KMessageBox::error(this, i18n("Failed to overwrite original file"),
2005
i18n("Error Saving File"));
2006
movingSaveFileFinished(false);
2011
// restore permissions
2012
if (::chmod(dstFileName, filePermissions) != 0)
2014
kWarning() << "Failed to restore file permissions for file " << dstFileName;
2017
movingSaveFileFinished(true);
2024
// for remote destinations use kio to move the temp file over there
2026
kDebug() << "moving a remote file via KIO";
2028
KIO::CopyJob *moveJob = KIO::move(KUrl(
2029
m_savingContext->saveTempFileName),
2030
m_savingContext->destinationURL);
2031
connect(moveJob, SIGNAL(result(KJob*)),
2032
this, SLOT(slotKioMoveFinished(KJob*)));
2038
void EditorWindow::slotKioMoveFinished(KJob *job)
2043
KMessageBox::error(this, i18n("Failed to save file: %1", job->errorString()),
1836
2044
i18n("Error Saving File"));
1841
// restore permissions
1842
if (::chmod(dstFileName, filePermissions) != 0)
1844
kWarning(digiKamAreaCode) << "Failed to restore file permissions for file " << dstFileName;
2047
movingSaveFileFinished(!job->error());
1850
2050
void EditorWindow::slotColorManagementOptionsChanged()