1.1 --- a/mainwindow.cpp Mon Mar 27 20:21:58 2006 +0000
1.2 +++ b/mainwindow.cpp Tue Mar 28 20:04:04 2006 +0000
1.3 @@ -101,6 +101,7 @@
1.4 extern QAction *actionEditMoveDown;
1.5 extern QAction *actionEditToggleScroll;
1.6 extern QAction* actionEditOpenURL;
1.7 +extern QAction* actionEditOpenURLTab;
1.8 extern QAction* actionEditURL;
1.9 extern QAction* actionEditHeading2URL;
1.10 extern QAction* actionEditBugzilla2URL;
1.11 @@ -207,6 +208,8 @@
1.12 makeSubDirs (clipboardDir);
1.13 clipboardEmpty=true;
1.14
1.15 + procBrowser=NULL;
1.16 +
1.17 // FIXME not used currently
1.18 // Set random seed (random used for object IDs)
1.19 // QTime t = QTime::currentTime(); // set random seed
1.20 @@ -519,6 +522,11 @@
1.21 a->setEnabled (false);
1.22 actionEditOpenURL=a;
1.23
1.24 + a = new QAction( tr( "Open URL in new tab" ), QPixmap(), tr( "Open URL in new tab" ), ALT + Key_U, this, "urltab" );
1.25 + connect( a, SIGNAL( activated() ), this, SLOT( editOpenURLTab() ) );
1.26 + a->setEnabled (false);
1.27 + actionEditOpenURLTab=a;
1.28 +
1.29 a = new QAction( tr( "Edit URL" ), QPixmap(), tr( "Edit URL"+QString("...") ), SHIFT + CTRL + Key_U, this, "url" );
1.30 connect( a, SIGNAL( activated() ), this, SLOT( editURL() ) );
1.31 a->setEnabled (false);
1.32 @@ -1134,6 +1142,7 @@
1.33
1.34 branchContextMenu->insertSeparator();
1.35 actionEditOpenURL->addTo ( branchContextMenu );
1.36 + actionEditOpenURLTab->addTo ( branchContextMenu );
1.37 actionEditURL->addTo ( branchContextMenu );
1.38 actionEditHeading2URL->addTo ( branchContextMenu );
1.39 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
1.40 @@ -2177,8 +2186,53 @@
1.41
1.42 void Main::editOpenURL()
1.43 {
1.44 + // Open new browser
1.45 if (currentMapEditor())
1.46 - currentMapEditor()->openURL();
1.47 + {
1.48 + QString url=currentMapEditor()->getURL();
1.49 + if (url=="") return;
1.50 + QString browser=settings.readEntry("/vym/mainwindow/readerURL" );
1.51 + procBrowser = new QProcess( this );
1.52 +
1.53 + procBrowser->addArgument( browser);
1.54 + procBrowser->addArgument( url);
1.55 +
1.56 + if ( !procBrowser->start() )
1.57 + {
1.58 + // try to set path to browser
1.59 + QMessageBox::warning(0,
1.60 + tr("Warning"),
1.61 + tr("Couldn't find a viewer to open %1.\n").arg(url)+
1.62 + tr("Please use Settings->")+tr("Set application to open an URL"));
1.63 + settingsURL() ;
1.64 + }
1.65 + }
1.66 +}
1.67 +void Main::editOpenURLTab()
1.68 +{
1.69 + if (currentMapEditor())
1.70 + {
1.71 + QString url=currentMapEditor()->getURL();
1.72 + if (url=="") return;
1.73 + QString browser=settings.readEntry("/vym/mainwindow/readerURL" );
1.74 + if (browser.contains("konqueror") && procBrowser && procBrowser->isRunning())
1.75 + {
1.76 + // Try to open new tab in existing browser
1.77 + QProcess *p=new QProcess (this);
1.78 + p->addArgument ("dcop");
1.79 + p->addArgument (QString("konqueror-%1").arg(procBrowser->processIdentifier()));
1.80 + p->addArgument ("konqueror-mainwindow#1");
1.81 + p->addArgument ("newTab");
1.82 + p->addArgument (url);
1.83 + if ( !p->start() )
1.84 + // try to set browser
1.85 + QMessageBox::warning(0,
1.86 + tr("Warning"),
1.87 + tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
1.88 + } else
1.89 + // Open new browser
1.90 + editOpenURL();
1.91 + }
1.92 }
1.93
1.94 void Main::editURL()
1.95 @@ -2573,7 +2627,7 @@
1.96 // Default browser is set in constructor
1.97 bool ok;
1.98 QString text = QInputDialog::getText(
1.99 - "VYM", tr("Enter path for pdf reader:"), QLineEdit::Normal,
1.100 + "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
1.101 settings.readEntry("/vym/mainwindow/readerPDF"), &ok, this );
1.102 if (ok)
1.103 settings.writeEntry ("/vym/mainwindow/readerPDF",text);
1.104 @@ -2586,7 +2640,7 @@
1.105 // Default browser is set in constructor
1.106 bool ok;
1.107 QString text = QInputDialog::getText(
1.108 - "VYM", tr("Enter path for application to open an URL:"), QLineEdit::Normal,
1.109 + "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
1.110 settings.readEntry("/vym/mainwindow/readerURL")
1.111 , &ok, this );
1.112 if (ok)
1.113 @@ -2686,10 +2740,11 @@
1.114 if ( !pdfProc->start() )
1.115 {
1.116 // error handling
1.117 - QMessageBox::critical(0,
1.118 - tr("Critcal error"),
1.119 - tr("Couldn't find a viewer to read vym.pdf.\n"
1.120 - "Please use Settings->")+tr("Set application to open pdf files"));
1.121 + QMessageBox::warning(0,
1.122 + tr("Warning"),
1.123 + tr("Couldn't find a viewer to open %1.\n").arg("vym.pdf")+
1.124 + tr("Please use Settings->")+tr("Set application to open PDF files"));
1.125 + settingsPDF();
1.126 return;
1.127 }
1.128 }