diff -r 96b8406d4a2f -r 7d91b35c1b6f mainwindow.cpp --- a/mainwindow.cpp Mon Mar 27 20:21:58 2006 +0000 +++ b/mainwindow.cpp Tue Mar 28 20:04:04 2006 +0000 @@ -101,6 +101,7 @@ extern QAction *actionEditMoveDown; extern QAction *actionEditToggleScroll; extern QAction* actionEditOpenURL; +extern QAction* actionEditOpenURLTab; extern QAction* actionEditURL; extern QAction* actionEditHeading2URL; extern QAction* actionEditBugzilla2URL; @@ -207,6 +208,8 @@ makeSubDirs (clipboardDir); clipboardEmpty=true; + procBrowser=NULL; + // FIXME not used currently // Set random seed (random used for object IDs) // QTime t = QTime::currentTime(); // set random seed @@ -519,6 +522,11 @@ a->setEnabled (false); actionEditOpenURL=a; + a = new QAction( tr( "Open URL in new tab" ), QPixmap(), tr( "Open URL in new tab" ), ALT + Key_U, this, "urltab" ); + connect( a, SIGNAL( activated() ), this, SLOT( editOpenURLTab() ) ); + a->setEnabled (false); + actionEditOpenURLTab=a; + a = new QAction( tr( "Edit URL" ), QPixmap(), tr( "Edit URL"+QString("...") ), SHIFT + CTRL + Key_U, this, "url" ); connect( a, SIGNAL( activated() ), this, SLOT( editURL() ) ); a->setEnabled (false); @@ -1134,6 +1142,7 @@ branchContextMenu->insertSeparator(); actionEditOpenURL->addTo ( branchContextMenu ); + actionEditOpenURLTab->addTo ( branchContextMenu ); actionEditURL->addTo ( branchContextMenu ); actionEditHeading2URL->addTo ( branchContextMenu ); if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false)) @@ -2177,8 +2186,53 @@ void Main::editOpenURL() { + // Open new browser if (currentMapEditor()) - currentMapEditor()->openURL(); + { + QString url=currentMapEditor()->getURL(); + if (url=="") return; + QString browser=settings.readEntry("/vym/mainwindow/readerURL" ); + procBrowser = new QProcess( this ); + + procBrowser->addArgument( browser); + procBrowser->addArgument( url); + + if ( !procBrowser->start() ) + { + // try to set path to browser + QMessageBox::warning(0, + tr("Warning"), + tr("Couldn't find a viewer to open %1.\n").arg(url)+ + tr("Please use Settings->")+tr("Set application to open an URL")); + settingsURL() ; + } + } +} +void Main::editOpenURLTab() +{ + if (currentMapEditor()) + { + QString url=currentMapEditor()->getURL(); + if (url=="") return; + QString browser=settings.readEntry("/vym/mainwindow/readerURL" ); + if (browser.contains("konqueror") && procBrowser && procBrowser->isRunning()) + { + // Try to open new tab in existing browser + QProcess *p=new QProcess (this); + p->addArgument ("dcop"); + p->addArgument (QString("konqueror-%1").arg(procBrowser->processIdentifier())); + p->addArgument ("konqueror-mainwindow#1"); + p->addArgument ("newTab"); + p->addArgument (url); + if ( !p->start() ) + // try to set browser + QMessageBox::warning(0, + tr("Warning"), + tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror")); + } else + // Open new browser + editOpenURL(); + } } void Main::editURL() @@ -2573,7 +2627,7 @@ // Default browser is set in constructor bool ok; QString text = QInputDialog::getText( - "VYM", tr("Enter path for pdf reader:"), QLineEdit::Normal, + "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal, settings.readEntry("/vym/mainwindow/readerPDF"), &ok, this ); if (ok) settings.writeEntry ("/vym/mainwindow/readerPDF",text); @@ -2586,7 +2640,7 @@ // Default browser is set in constructor bool ok; QString text = QInputDialog::getText( - "VYM", tr("Enter path for application to open an URL:"), QLineEdit::Normal, + "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal, settings.readEntry("/vym/mainwindow/readerURL") , &ok, this ); if (ok) @@ -2686,10 +2740,11 @@ if ( !pdfProc->start() ) { // error handling - QMessageBox::critical(0, - tr("Critcal error"), - tr("Couldn't find a viewer to read vym.pdf.\n" - "Please use Settings->")+tr("Set application to open pdf files")); + QMessageBox::warning(0, + tr("Warning"), + tr("Couldn't find a viewer to open %1.\n").arg("vym.pdf")+ + tr("Please use Settings->")+tr("Set application to open PDF files")); + settingsPDF(); return; } }