mainwindow.cpp
changeset 608 6cdc2e7b1937
parent 600 a9fe976e01a6
child 611 a1ae877b438d
     1.1 --- a/mainwindow.cpp	Mon Oct 22 09:50:03 2007 +0000
     1.2 +++ b/mainwindow.cpp	Mon Oct 22 09:50:08 2007 +0000
     1.3 @@ -20,6 +20,19 @@
     1.4  #include "texteditor.h"
     1.5  #include "warningdialog.h"
     1.6  
     1.7 +#if defined(Q_OS_WIN32)
     1.8 +// Define only this structure as opposed to
     1.9 +// including full 'windows.h'. FindWindow
    1.10 +// clashes with the one in Win32 API.
    1.11 +typedef struct _PROCESS_INFORMATION
    1.12 +{
    1.13 +  long hProcess;
    1.14 +  long hThread;
    1.15 +  long dwProcessId;
    1.16 +  long dwThreadId;
    1.17 +} PROCESS_INFORMATION, *LPPROCESS_INFORMATION;
    1.18 +#endif
    1.19 +
    1.20  extern TextEditor *textEditor;
    1.21  extern Main *mainWindow;
    1.22  extern QString tmpVymDir;
    1.23 @@ -77,7 +90,7 @@
    1.24  
    1.25  	// Create unique temporary directory
    1.26  	bool ok;
    1.27 -	tmpVymDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
    1.28 +	tmpVymDir=makeTmpDir (ok,"vym");
    1.29  	if (!ok)
    1.30  	{
    1.31  		qWarning ("Mainwindow: Could not create temporary directory, failed to start vym");
    1.32 @@ -135,12 +148,20 @@
    1.33  		// application to open URLs
    1.34  		p="/mainwindow/readerURL";
    1.35  		#if defined(Q_OS_LINUX)
    1.36 -			s=settings.value (p,"konqueror").toString();
    1.37 +			s=settings.value (p,"xdg-open").toString();
    1.38  		#else
    1.39  			#if defined(Q_OS_MACX)
    1.40  				s=settings.value (p,"/usr/bin/open").toString();
    1.41 -			#else
    1.42 -				s=settings.value (p,"mozilla");
    1.43 +
    1.44 +            #else
    1.45 +                #if defined(Q_OS_WIN32)
    1.46 +                    // Assume that system has been set up so that
    1.47 +                    // Explorer automagically opens up the URL
    1.48 +                    // in the user's preferred browser.
    1.49 +                    s=settings.value (p,"explorer").toString();
    1.50 +                #else
    1.51 +					s=settings.value (p,"mozilla").toString();
    1.52 +				#endif
    1.53  			#endif
    1.54  		#endif
    1.55  		settings.setValue( p,s);
    1.56 @@ -148,7 +169,7 @@
    1.57  		// application to open PDFs
    1.58  		p="/mainwindow/readerPDF";
    1.59  		#if defined(Q_OS_LINUX)
    1.60 -			s=settings.value (p,"acroread").toString();
    1.61 +			s=settings.value (p,"xdg-open").toString();
    1.62  		#else
    1.63  			#if defined(Q_OS_MACX)
    1.64  				s=settings.value (p,"/usr/bin/open").toString();
    1.65 @@ -582,6 +603,11 @@
    1.66  	editMenu->addAction (a);
    1.67  	actionEditMoveDown=a;
    1.68  	
    1.69 +	a = new QAction( QPixmap(iconPath+"editsort.png" ), tr( "Sort children","Edit menu" ), this );
    1.70 +	connect( a, SIGNAL( activated() ), this, SLOT( editSortChildren() ) );
    1.71 +	a->setEnabled (true);
    1.72 +	a->addTo( tb );
    1.73 +	actionEditSortChildren=a;
    1.74  
    1.75  	a = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ),this);
    1.76  	a->setShortcut ( Qt::Key_ScrollLock );
    1.77 @@ -1784,7 +1810,7 @@
    1.78  
    1.79  		// Create temporary directory for packing
    1.80  		bool ok;
    1.81 -		QString tmpMapDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
    1.82 +		QString tmpMapDir=makeTmpDir (ok,"vym-pack");
    1.83  		if (!ok)
    1.84  		{
    1.85  			QMessageBox::critical( 0, tr( "Critical Load Error" ),
    1.86 @@ -1863,7 +1889,7 @@
    1.87  			{
    1.88  				me->setFilePath (fn);
    1.89  				tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
    1.90 -				if (fn.left(9)!="/tmp/vym-")
    1.91 +				if (!isInTmpDir (fn))
    1.92  				{
    1.93  					// Only append to lastMaps if not loaded from a tmpDir
    1.94  					// e.g. imported bookmarks are in a tmpDir
    1.95 @@ -2008,7 +2034,7 @@
    1.96  			{
    1.97  				// Create temporary directory for packing
    1.98  				bool ok;
    1.99 -				QString tmpMapDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
   1.100 +				QString tmpMapDir=makeTmpDir (ok,"vym-zip");
   1.101  				if (!ok)
   1.102  				{
   1.103  					QMessageBox::critical( 0, tr( "Critical Load Error" ),
   1.104 @@ -2536,7 +2562,12 @@
   1.105  					tr("Please use Settings->")+tr("Set application to open an URL"));
   1.106  				return;
   1.107  			}
   1.108 +#if defined(Q_OS_WIN32)
   1.109 +            // There's no sleep in VCEE, replace it with Qt's QThread::wait().
   1.110 +            this->thread()->wait(3000);
   1.111 +#else
   1.112  			sleep (3);
   1.113 +#endif
   1.114  		}
   1.115  		if (browser.contains("konqueror"))
   1.116  		{
   1.117 @@ -2546,11 +2577,21 @@
   1.118  				// Try to open new tab in existing konqueror started previously by vym
   1.119  				p=new QProcess (this);
   1.120  				args.clear();
   1.121 -				args<< QString("konqueror-%1").arg(procBrowser->pid())<< 
   1.122 -					"konqueror-mainwindow#1"<< 
   1.123 -					"newTab" << 
   1.124 +#if defined(Q_OS_WIN32)
   1.125 +                // In Win32, pid is not a longlong, but a pointer to a _PROCESS_INFORMATION structure.
   1.126 +                // Redundant change in Win32, as there's no konqueror, but I wanted to follow the original logic.
   1.127 +				args<< QString("konqueror-%1").arg(procBrowser->pid()->dwProcessId)<<
   1.128 +					"konqueror-mainwindow#1"<<
   1.129 +					"newTab" <<
   1.130  					urls.at(i);
   1.131 +#else
   1.132 +				args<< QString("konqueror-%1").arg(procBrowser->pid())<<
   1.133 +					"konqueror-mainwindow#1"<<
   1.134 +					"newTab" <<
   1.135 +					urls.at(i);
   1.136 +#endif
   1.137  				p->start ("dcop",args);
   1.138 +				cout << args.join(" ").ascii()<<endl;
   1.139  				if ( !p->waitForStarted() ) success=false;
   1.140  			}
   1.141  			if (!success)
   1.142 @@ -2819,6 +2860,12 @@
   1.143  		currentMapEditor()->moveBranchDown();
   1.144  }
   1.145  
   1.146 +void Main::editSortChildren()
   1.147 +{
   1.148 +	if (currentMapEditor())
   1.149 +		currentMapEditor()->sortChildren();
   1.150 +}
   1.151 +
   1.152  void Main::editToggleScroll()
   1.153  {
   1.154  	if (currentMapEditor())
   1.155 @@ -3631,6 +3678,9 @@
   1.156  	#if defined(Q_OS_MACX)
   1.157  		searchList << "./vym.app/Contents/Resources/doc";
   1.158  	#else
   1.159 +		#if defined(VYM_DOCDIR)
   1.160 +			searchList << VYM_DOCDIR;
   1.161 +		#endif
   1.162  		// default path in SUSE LINUX
   1.163  		searchList <<"/usr/share/doc/packages/vym";
   1.164  	#endif
   1.165 @@ -3757,3 +3807,31 @@
   1.166  	}	
   1.167  }
   1.168  
   1.169 +
   1.170 +
   1.171 +//////////////////////////////////
   1.172 +/*
   1.173 +@@ -2544,18 +2576,27 @@
   1.174 + 				// Try to open new tab in existing konqueror started previously by vym
   1.175 + 				p=new QProcess (this);
   1.176 + 				args.clear();
   1.177 +-				args<< QString("konqueror-%1").arg(procBrowser->pid())<< 
   1.178 +-					"konqueror-mainwindow#1"<< 
   1.179 +-					"newTab" << 
   1.180 ++#if defined(Q_OS_WIN32)
   1.181 ++                // In Win32, pid is not a longlong, but a pointer to a _PROCESS_INFORMATION structure.
   1.182 ++                // Redundant change in Win32, as there's no konqueror, but I wanted to follow the original logic.
   1.183 ++				args<< QString("konqueror-%1").arg(procBrowser->pid()->dwProcessId)<<
   1.184 ++					"konqueror-mainwindow#1"<<
   1.185 ++					"newTab" <<
   1.186 + 					urls.at(i);
   1.187 ++#else
   1.188 ++				args<< QString("konqueror-%1").arg(procBrowser->pid())<<
   1.189 ++					"konqueror-mainwindow#1"<<
   1.190 ++					"newTab" <<
   1.191 ++					urls.at(i);
   1.192 ++#endif
   1.193 + 				p->start ("dcop",args);
   1.194 + 				if ( !p->waitForStarted() ) success=false;
   1.195 + 			}
   1.196 +*/