diff -r 53c66cb9f5bd -r 6cdc2e7b1937 mainwindow.cpp --- a/mainwindow.cpp Mon Oct 22 09:50:03 2007 +0000 +++ b/mainwindow.cpp Mon Oct 22 09:50:08 2007 +0000 @@ -20,6 +20,19 @@ #include "texteditor.h" #include "warningdialog.h" +#if defined(Q_OS_WIN32) +// Define only this structure as opposed to +// including full 'windows.h'. FindWindow +// clashes with the one in Win32 API. +typedef struct _PROCESS_INFORMATION +{ + long hProcess; + long hThread; + long dwProcessId; + long dwThreadId; +} PROCESS_INFORMATION, *LPPROCESS_INFORMATION; +#endif + extern TextEditor *textEditor; extern Main *mainWindow; extern QString tmpVymDir; @@ -77,7 +90,7 @@ // Create unique temporary directory bool ok; - tmpVymDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX"); + tmpVymDir=makeTmpDir (ok,"vym"); if (!ok) { qWarning ("Mainwindow: Could not create temporary directory, failed to start vym"); @@ -135,12 +148,20 @@ // application to open URLs p="/mainwindow/readerURL"; #if defined(Q_OS_LINUX) - s=settings.value (p,"konqueror").toString(); + s=settings.value (p,"xdg-open").toString(); #else #if defined(Q_OS_MACX) s=settings.value (p,"/usr/bin/open").toString(); - #else - s=settings.value (p,"mozilla"); + + #else + #if defined(Q_OS_WIN32) + // Assume that system has been set up so that + // Explorer automagically opens up the URL + // in the user's preferred browser. + s=settings.value (p,"explorer").toString(); + #else + s=settings.value (p,"mozilla").toString(); + #endif #endif #endif settings.setValue( p,s); @@ -148,7 +169,7 @@ // application to open PDFs p="/mainwindow/readerPDF"; #if defined(Q_OS_LINUX) - s=settings.value (p,"acroread").toString(); + s=settings.value (p,"xdg-open").toString(); #else #if defined(Q_OS_MACX) s=settings.value (p,"/usr/bin/open").toString(); @@ -582,6 +603,11 @@ editMenu->addAction (a); actionEditMoveDown=a; + a = new QAction( QPixmap(iconPath+"editsort.png" ), tr( "Sort children","Edit menu" ), this ); + connect( a, SIGNAL( activated() ), this, SLOT( editSortChildren() ) ); + a->setEnabled (true); + a->addTo( tb ); + actionEditSortChildren=a; a = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ),this); a->setShortcut ( Qt::Key_ScrollLock ); @@ -1784,7 +1810,7 @@ // Create temporary directory for packing bool ok; - QString tmpMapDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX"); + QString tmpMapDir=makeTmpDir (ok,"vym-pack"); if (!ok) { QMessageBox::critical( 0, tr( "Critical Load Error" ), @@ -1863,7 +1889,7 @@ { me->setFilePath (fn); tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName()); - if (fn.left(9)!="/tmp/vym-") + if (!isInTmpDir (fn)) { // Only append to lastMaps if not loaded from a tmpDir // e.g. imported bookmarks are in a tmpDir @@ -2008,7 +2034,7 @@ { // Create temporary directory for packing bool ok; - QString tmpMapDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX"); + QString tmpMapDir=makeTmpDir (ok,"vym-zip"); if (!ok) { QMessageBox::critical( 0, tr( "Critical Load Error" ), @@ -2536,7 +2562,12 @@ tr("Please use Settings->")+tr("Set application to open an URL")); return; } +#if defined(Q_OS_WIN32) + // There's no sleep in VCEE, replace it with Qt's QThread::wait(). + this->thread()->wait(3000); +#else sleep (3); +#endif } if (browser.contains("konqueror")) { @@ -2546,11 +2577,21 @@ // Try to open new tab in existing konqueror started previously by vym p=new QProcess (this); args.clear(); - args<< QString("konqueror-%1").arg(procBrowser->pid())<< - "konqueror-mainwindow#1"<< - "newTab" << +#if defined(Q_OS_WIN32) + // In Win32, pid is not a longlong, but a pointer to a _PROCESS_INFORMATION structure. + // Redundant change in Win32, as there's no konqueror, but I wanted to follow the original logic. + args<< QString("konqueror-%1").arg(procBrowser->pid()->dwProcessId)<< + "konqueror-mainwindow#1"<< + "newTab" << urls.at(i); +#else + args<< QString("konqueror-%1").arg(procBrowser->pid())<< + "konqueror-mainwindow#1"<< + "newTab" << + urls.at(i); +#endif p->start ("dcop",args); + cout << args.join(" ").ascii()<waitForStarted() ) success=false; } if (!success) @@ -2819,6 +2860,12 @@ currentMapEditor()->moveBranchDown(); } +void Main::editSortChildren() +{ + if (currentMapEditor()) + currentMapEditor()->sortChildren(); +} + void Main::editToggleScroll() { if (currentMapEditor()) @@ -3631,6 +3678,9 @@ #if defined(Q_OS_MACX) searchList << "./vym.app/Contents/Resources/doc"; #else + #if defined(VYM_DOCDIR) + searchList << VYM_DOCDIR; + #endif // default path in SUSE LINUX searchList <<"/usr/share/doc/packages/vym"; #endif @@ -3757,3 +3807,31 @@ } } + + +////////////////////////////////// +/* +@@ -2544,18 +2576,27 @@ + // Try to open new tab in existing konqueror started previously by vym + p=new QProcess (this); + args.clear(); +- args<< QString("konqueror-%1").arg(procBrowser->pid())<< +- "konqueror-mainwindow#1"<< +- "newTab" << ++#if defined(Q_OS_WIN32) ++ // In Win32, pid is not a longlong, but a pointer to a _PROCESS_INFORMATION structure. ++ // Redundant change in Win32, as there's no konqueror, but I wanted to follow the original logic. ++ args<< QString("konqueror-%1").arg(procBrowser->pid()->dwProcessId)<< ++ "konqueror-mainwindow#1"<< ++ "newTab" << + urls.at(i); ++#else ++ args<< QString("konqueror-%1").arg(procBrowser->pid())<< ++ "konqueror-mainwindow#1"<< ++ "newTab" << ++ urls.at(i); ++#endif + p->start ("dcop",args); + if ( !p->waitForStarted() ) success=false; + } +*/