|
|
|
@ -43,6 +43,7 @@
|
|
|
|
|
|
|
|
|
|
// KDE
|
|
|
|
|
#include <KLocalizedString>
|
|
|
|
|
#include <KMessageBox>
|
|
|
|
|
#include <KIO/OpenFileManagerWindowJob>
|
|
|
|
|
|
|
|
|
|
// Plasma
|
|
|
|
@ -198,6 +199,17 @@ void ExportTemplateHandler::chooseFileDialog()
|
|
|
|
|
|
|
|
|
|
void ExportTemplateHandler::onExport()
|
|
|
|
|
{
|
|
|
|
|
QString curbasename = QFileInfo(c_filepath).baseName();
|
|
|
|
|
QString curfilename = QFileInfo(c_filepath).fileName();
|
|
|
|
|
|
|
|
|
|
//! Confirm Overwrite if that is the case
|
|
|
|
|
if (QFile(c_filepath).exists()) {
|
|
|
|
|
if (!overwriteConfirmation(curfilename)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//! Proceed with export
|
|
|
|
|
auto showExportTemplateError = [this](const QString &templateName) {
|
|
|
|
|
showInlineMessage(i18nc("settings:template export fail","Template <b>%0</b> export <b>failed</b>...").arg(templateName),
|
|
|
|
|
KMessageWidget::Error,
|
|
|
|
@ -208,12 +220,12 @@ void ExportTemplateHandler::onExport()
|
|
|
|
|
|
|
|
|
|
if (!m_originLayoutFilePath.isEmpty()) {
|
|
|
|
|
result = m_dialog->corona()->templatesManager()->exportTemplate(m_originLayoutFilePath,
|
|
|
|
|
c_filepath,
|
|
|
|
|
m_appletsModel->selectedApplets());
|
|
|
|
|
c_filepath,
|
|
|
|
|
m_appletsModel->selectedApplets());
|
|
|
|
|
} else if (m_originView){
|
|
|
|
|
result = m_dialog->corona()->templatesManager()->exportTemplate(m_originView,
|
|
|
|
|
c_filepath,
|
|
|
|
|
m_appletsModel->selectedApplets());
|
|
|
|
|
c_filepath,
|
|
|
|
|
m_appletsModel->selectedApplets());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (result) {
|
|
|
|
@ -230,7 +242,7 @@ void ExportTemplateHandler::onExport()
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
showInlineMessage(i18nc("settings:template export success","Template <b>%0</b> export succeeded...").arg(QFileInfo(c_filepath).baseName()),
|
|
|
|
|
showInlineMessage(i18nc("settings:template export success","Template <b>%0</b> export succeeded...").arg(curbasename),
|
|
|
|
|
KMessageWidget::Information,
|
|
|
|
|
false,
|
|
|
|
|
actions);
|
|
|
|
@ -289,6 +301,15 @@ void ExportTemplateHandler::save()
|
|
|
|
|
//do nothing
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool ExportTemplateHandler::overwriteConfirmation(const QString &fileName)
|
|
|
|
|
{
|
|
|
|
|
return (KMessageBox::warningYesNo(m_dialog,
|
|
|
|
|
i18n("The file \"%0\" already exists. Do you wish to overwrite it?").arg(fileName),
|
|
|
|
|
i18n("Overwrite File?"),
|
|
|
|
|
KStandardGuiItem::overwrite(),
|
|
|
|
|
KStandardGuiItem::cancel()) == KMessageBox::Yes);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|