r21537 by craig - #8753: Rewrite image editor starting <william>, plus change some OS dependent start code

scribus-commit scribus-commit at lists.scribus.net
Thu Nov 24 21:41:10 UTC 2016


Author: craig
Date: Thu Nov 24 21:41:09 2016
New Revision: 21537

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=21537
Log:
#8753: Rewrite image editor starting <william>, plus change some OS dependent start code

Modified:
    trunk/Scribus/scribus/prefsfile.cpp
    trunk/Scribus/scribus/prefsmanager.cpp
    trunk/Scribus/scribus/scribus.cpp
    trunk/Scribus/scribus/scribus.h

Modified: trunk/Scribus/scribus/prefsfile.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21537&path=/trunk/Scribus/scribus/prefsfile.cpp
==============================================================================
--- trunk/Scribus/scribus/prefsfile.cpp	(original)
+++ trunk/Scribus/scribus/prefsfile.cpp	Thu Nov 24 21:41:09 2016
@@ -88,6 +88,7 @@
 {
 	if ((!m_ioEnabled) || ((m_contexts.size() == 0) && (m_pluginContexts.size() == 0)))
 		return; // No prefs file path set -> can't write or no prefs to write
+	qDebug()<<"write"<<m_prefsFilePath;
 	QFile* prefsXML = new QFile(m_prefsFilePath);
 	if (prefsXML->open(QIODevice::WriteOnly))
 	{

Modified: trunk/Scribus/scribus/prefsmanager.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21537&path=/trunk/Scribus/scribus/prefsmanager.cpp
==============================================================================
--- trunk/Scribus/scribus/prefsmanager.cpp	(original)
+++ trunk/Scribus/scribus/prefsmanager.cpp	Thu Nov 24 21:41:09 2016
@@ -868,7 +868,7 @@
 {
 	// Import 1.2 font search path prefs
 	QFile fontPrefsFile12(QDir::toNativeSeparators(m_prefsLocation+"/scribusfont.rc"));
-	if (fontPrefsFile12.open(QIODevice::ReadOnly))
+	if (fontPrefsFile12.exists() && fontPrefsFile12.open(QIODevice::ReadOnly))
 	{
 		PrefsContext *pc = prefsFile->getContext("Fonts");
 		PrefsTable *fontPrefs = pc->getTable("ExtraFontDirs");
@@ -922,9 +922,7 @@
 		appPrefs.verifierPrefs.curCheckProfile = CommonStrings::PostScript;
 	}
 	if (!appPrefs.uiPrefs.mainWinState.isEmpty())
-	{
 		mw->restoreState(appPrefs.uiPrefs.mainWinState);
-	}
 }
 
 void PrefsManager::ReadPrefsXML()
@@ -935,7 +933,7 @@
 		if (userprefsContext)
 		{
 			appPrefs.uiPrefs.language = userprefsContext->get("gui_language","");
-			appPrefs.uiPrefs.mainWinState = QByteArray::fromBase64(userprefsContext->get("mainwinstate","").toLatin1());
+			appPrefs.uiPrefs.mainWinState = QByteArray::fromHex(userprefsContext->get("mainwinstate","").toLatin1());
 			appPrefs.uiPrefs.tabbedPalettes.clear();
 			PrefsTable *tabsTable = userprefsContext->getTable("tabbedPalettes");
 			PrefsTable *actTabsTable = userprefsContext->getTable("activeTabs");
@@ -1005,7 +1003,7 @@
 		if (userprefsContext)
 		{
 			userprefsContext->set("gui_language", appPrefs.uiPrefs.language);
-			userprefsContext->set("mainwinstate", QString::fromLatin1(appPrefs.uiPrefs.mainWinState.toBase64()));
+			userprefsContext->set("mainwinstate", QString::fromLatin1(appPrefs.uiPrefs.mainWinState.toHex()));
 			if (!appPrefs.uiPrefs.tabbedPalettes.isEmpty())
 			{
 				int maxCols = 0;

Modified: trunk/Scribus/scribus/scribus.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21537&path=/trunk/Scribus/scribus/scribus.cpp
==============================================================================
--- trunk/Scribus/scribus/scribus.cpp	(original)
+++ trunk/Scribus/scribus/scribus.cpp	Thu Nov 24 21:41:09 2016
@@ -299,7 +299,6 @@
 	resourceManager=0;
 	UrlLauncher::instance();
 	m_mainWindowStatusLabel=0;
-	ExternalApp=0;
 	m_ScriptRunning = 0;
 #ifdef Q_OS_MAC
 	//commenting this out until this is resolved :https://bugreports.qt.io/browse/QTBUG-44565
@@ -8383,15 +8382,6 @@
 	slotSelect();
 }
 
-void ScribusMainWindow::imageEditorExited(int /*exitCode*/, QProcess::ExitStatus /*exitStatus*/)
-{
-	if ( ExternalApp != 0 )
-	{
-		delete ExternalApp;
-		ExternalApp = 0;
-	}
-}
-
 /* call gimp and wait upon completion */
 void ScribusMainWindow::callImageEditor()
 {
@@ -8419,52 +8409,27 @@
 	}
 #endif
 	QString imageEditorExecutable=m_prefsManager->imageEditorExecutable();
-	if (ExternalApp != 0)
-	{
-		QString ieExe = QDir::toNativeSeparators(imageEditorExecutable);
-		ScMessageBox::information(this, tr("Information"), "<qt>" + tr("The program %1 is already running!").arg(ieExe) + "</qt>");
-		return;
-	}
 	if (currItem->imageIsAvailable)
 	{
-		int index;
-		QString imEditor;
-		ExternalApp = new QProcess(NULL);
-		QStringList cmd;
-	#if defined(_WIN32)
-		index = imageEditorExecutable.indexOf( ".exe" );
-		if ( index >= 0 )
-			imEditor = imageEditorExecutable.left( index + 4 );
-		imEditor.replace( "\\", "/" );
-		if ( imEditor.length() < imageEditorExecutable.length() )
-		{
-			int diffLength = imageEditorExecutable.length() - imEditor.length();
-			QString cmdStr = imageEditorExecutable.right( diffLength );
-			QStringList cmd1 = cmdStr.split( " ", QString::SkipEmptyParts);
-			cmd += cmd1;
-		}
+		bool startFailed=false;
+	#ifdef Q_OS_OSX
+		QString osxcmd(imageEditorExecutable);
+		if (osxcmd.endsWith(".app"))
+			osxcmd.prepend("open -a \"");
+		else
+			osxcmd.prepend("\"");
+		osxcmd.append("\" \"");
+		osxcmd.append(QDir::toNativeSeparators(currItem->Pfile));
+		osxcmd.append("\"");
+		if (!QProcess::startDetached(osxcmd))
+			startFailed=true;
 	#else
-		cmd = imageEditorExecutable.split(" ", QString::SkipEmptyParts);
-		if ( cmd.count() > 0 )
-			imEditor = cmd[0];
-		cmd.clear();
+		QStringList cmd(QDir::toNativeSeparators(currItem->Pfile));
+		if (!QProcess::startDetached(QDir::fromNativeSeparators(imageEditorExecutable), cmd))
+			startFailed=true;
 	#endif
-		index = imEditor.lastIndexOf( "/" );
-		if (index > -1 )
-		{
-			QString imEditorDir = imEditor.left( index + 1 );
-			ExternalApp->setWorkingDirectory( imEditorDir );
-		}
-		cmd.append(QDir::toNativeSeparators(currItem->Pfile));
-		ExternalApp->start(imEditor, cmd);
-		if (!ExternalApp->waitForStarted())
-		{
-			delete ExternalApp;
-			ExternalApp = 0;
-			ScMessageBox::critical(this, CommonStrings::trWarning, "<qt>" + tr("The program %1 is missing!").arg(imageEditorExecutable) + "</qt>");
-			return;
-		}
-		connect(ExternalApp, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(imageEditorExited(int, QProcess::ExitStatus)));
+		if (startFailed)
+			ScMessageBox::critical(this, CommonStrings::trWarning, "<qt>" + tr("The program %1 is missing or failed to open").arg(imageEditorExecutable) + "</qt>");
 	}
 }
 

Modified: trunk/Scribus/scribus/scribus.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21537&path=/trunk/Scribus/scribus/scribus.h
==============================================================================
--- trunk/Scribus/scribus/scribus.h	(original)
+++ trunk/Scribus/scribus/scribus.h	Thu Nov 24 21:41:09 2016
@@ -253,8 +253,6 @@
 	QClipboard *ClipB;
 	QString LoadEnc;
 	AppModeHelper *appModeHelper;
-
-	QProcess *ExternalApp;
 
 	QMap<QString, QPointer<ScrAction> > scrActions;
 	QMap<QString, QPointer<ScrAction> > scrRecentFileActions;
@@ -517,7 +515,6 @@
 	void SetSnapElements(bool b);
 	void EditTabs();
 	void SearchText();
-	void imageEditorExited(int, QProcess::ExitStatus);
 	/*! \brief call gimp and wait upon completion */
 	void callImageEditor();
 	void docCheckToggle(bool visible);




More information about the scribus-commit mailing list