r22820 by jghali - Refactor (slightly) ScribusMainWindow::slotGetContent()
scribus-commit
scribus-commit at lists.scribus.net
Wed Jan 23 21:55:07 UTC 2019
Author: jghali
Date: Wed Jan 23 21:55:06 2019
New Revision: 22820
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=22820
Log:
Refactor (slightly) ScribusMainWindow::slotGetContent()
Modified:
trunk/Scribus/scribus/scribus.cpp
Modified: trunk/Scribus/scribus/scribus.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22820&path=/trunk/Scribus/scribus/scribus.cpp
==============================================================================
--- trunk/Scribus/scribus/scribus.cpp (original)
+++ trunk/Scribus/scribus/scribus.cpp Wed Jan 23 21:55:06 2019
@@ -3891,80 +3891,80 @@
// do with file->open for a LONG time. It's used for get text / get picture.
void ScribusMainWindow::slotGetContent()
{
- if (!doc->m_Selection->isEmpty())
- {
- PageItem *currItem = doc->m_Selection->itemAt(0);
- if (currItem->itemType() == PageItem::ImageFrame)
- {
- QString formatD(FormatsManager::instance()->fileDialogFormatList(FormatsManager::IMAGESIMGFRAME));
-
- QString docDir = ".";
- QString prefsDocDir=m_prefsManager->documentDir();
- if (!prefsDocDir.isEmpty())
- docDir = m_prefsManager->prefsFile->getContext("dirs")->get("images", prefsDocDir);
- else
- docDir = m_prefsManager->prefsFile->getContext("dirs")->get("images", ".");
-
- QStringList fileNames;
- fileNames.clear();
- CustomFDialog *dia = new CustomFDialog(qApp->activeWindow(), docDir, tr("Open"), formatD, fdShowPreview | fdExistingFilesI | fdDisableOk);
- if (dia->exec() == QDialog::Accepted)
- fileNames = dia->fileDialog->selectedFiles();
- delete dia;
- //QStringList fileNames = CFileDialog( docDir, tr("Open"), formatD, "", fdShowPreview | fdExistingFiles);
- if (!fileNames.isEmpty())
+ if (doc->m_Selection->isEmpty())
+ return;
+
+ PageItem *currItem = doc->m_Selection->itemAt(0);
+ if (currItem->itemType() == PageItem::ImageFrame)
+ {
+ QString formatD(FormatsManager::instance()->fileDialogFormatList(FormatsManager::IMAGESIMGFRAME));
+
+ QString docDir = ".";
+ QString prefsDocDir=m_prefsManager->documentDir();
+ if (!prefsDocDir.isEmpty())
+ docDir = m_prefsManager->prefsFile->getContext("dirs")->get("images", prefsDocDir);
+ else
+ docDir = m_prefsManager->prefsFile->getContext("dirs")->get("images", ".");
+
+ QStringList fileNames;
+ fileNames.clear();
+ CustomFDialog *dia = new CustomFDialog(qApp->activeWindow(), docDir, tr("Open"), formatD, fdShowPreview | fdExistingFilesI | fdDisableOk);
+ if (dia->exec() == QDialog::Accepted)
+ fileNames = dia->fileDialog->selectedFiles();
+ delete dia;
+ //QStringList fileNames = CFileDialog( docDir, tr("Open"), formatD, "", fdShowPreview | fdExistingFiles);
+ if (!fileNames.isEmpty())
+ {
+ m_prefsManager->prefsFile->getContext("dirs")->set("images", fileNames[0].left(fileNames[0].lastIndexOf("/")));
+ view->requestMode(modeImportImage);
+ CanvasMode_ImageImport* cii=dynamic_cast<CanvasMode_ImageImport*>(view->canvasMode());
+ if (cii)
+ cii->setImageList(fileNames);
+ }
+ }
+ else if (currItem->asTextFrame())
+ {
+ gtGetText* gt = new gtGetText(doc);
+ ImportSetup impsetup=gt->run();
+ if (impsetup.runDialog)
+ {
+ if (currItem->itemText.length() != 0)
{
- m_prefsManager->prefsFile->getContext("dirs")->set("images", fileNames[0].left(fileNames[0].lastIndexOf("/")));
- view->requestMode(modeImportImage);
- CanvasMode_ImageImport* cii=dynamic_cast<CanvasMode_ImageImport*>(view->canvasMode());
- if (cii)
- cii->setImageList(fileNames);
+ int t = ScMessageBox::warning(this, CommonStrings::trWarning, tr("Do you really want to clear all your text?"),
+ QMessageBox::Yes | QMessageBox::No,
+ QMessageBox::No, // GUI default
+ QMessageBox::Yes); // batch default
+ if (t == QMessageBox::No)
+ {
+ delete gt;
+ return;
+ }
}
- }
- else if (currItem->asTextFrame())
- {
- gtGetText* gt = new gtGetText(doc);
- ImportSetup impsetup=gt->run();
- if (impsetup.runDialog)
- {
- if (currItem->itemText.length() != 0)
- {
- int t = ScMessageBox::warning(this, CommonStrings::trWarning, tr("Do you really want to clear all your text?"),
- QMessageBox::Yes | QMessageBox::No,
- QMessageBox::No, // GUI default
- QMessageBox::Yes); // batch default
- if (t == QMessageBox::No)
- {
- delete gt;
- return;
- }
- }
- gt->launchImporter(impsetup.importer, impsetup.filename, impsetup.textOnly, impsetup.encoding, false, impsetup.prefixNames);
- }
- delete gt;
- if (doc->docHyphenator->AutoCheck)
- doc->docHyphenator->slotHyphenate(currItem);
- for (int a = 0; a < doc->Items->count(); ++a)
- {
- if (doc->Items->at(a)->isBookmark)
- bookmarkPalette->BView->changeText(doc->Items->at(a));
- }
- if (!impsetup.textOnly)
- doc->flag_NumUpdateRequest = true;
- view->DrawNew();
- slotDocCh();
- m_styleManager->setDoc(doc);
- marksManager->setDoc(doc);
- nsEditor->setDoc(doc);
- inlinePalette->unsetDoc();
- inlinePalette->setDoc(doc);
- if (outlinePalette->isVisible())
- outlinePalette->BuildTree();
- propertiesPalette->updateColorList();
- textPalette->updateColorList();
- emit UpdateRequest(reqArrowStylesUpdate | reqLineStylesUpdate | reqStyleComboDocUpdate | reqInlinePalUpdate);
- symbolPalette->updateSymbolList();
- }
+ gt->launchImporter(impsetup.importer, impsetup.filename, impsetup.textOnly, impsetup.encoding, false, impsetup.prefixNames);
+ }
+ delete gt;
+ if (doc->docHyphenator->AutoCheck)
+ doc->docHyphenator->slotHyphenate(currItem);
+ for (int a = 0; a < doc->Items->count(); ++a)
+ {
+ if (doc->Items->at(a)->isBookmark)
+ bookmarkPalette->BView->changeText(doc->Items->at(a));
+ }
+ if (!impsetup.textOnly)
+ doc->flag_NumUpdateRequest = true;
+ view->DrawNew();
+ slotDocCh();
+ m_styleManager->setDoc(doc);
+ marksManager->setDoc(doc);
+ nsEditor->setDoc(doc);
+ inlinePalette->unsetDoc();
+ inlinePalette->setDoc(doc);
+ if (outlinePalette->isVisible())
+ outlinePalette->BuildTree();
+ propertiesPalette->updateColorList();
+ textPalette->updateColorList();
+ emit UpdateRequest(reqArrowStylesUpdate | reqLineStylesUpdate | reqStyleComboDocUpdate | reqInlinePalUpdate);
+ symbolPalette->updateSymbolList();
}
}
More information about the scribus-commit
mailing list