diff -r 699f28529079 -r 41c3d7f9f532 mainwindow.cpp --- a/mainwindow.cpp Tue Aug 15 12:01:14 2006 +0000 +++ b/mainwindow.cpp Tue Aug 29 08:31:42 2006 +0000 @@ -63,6 +63,7 @@ extern QAction *actionEditToggleScroll; extern QAction* actionEditOpenURL; extern QAction* actionEditOpenURLTab; +extern QAction* actionEditOpenMultipleURLTabs; extern QAction* actionEditURL; extern QAction* actionEditHeading2URL; extern QAction* actionEditBugzilla2URL; @@ -214,6 +215,9 @@ connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ), this, SLOT( editorChanged( QWidget * ) ) ); + lineedit=new QLineEdit (this); + lineedit->hide(); + setCentralWidget(tabWidget); setupFileActions(); @@ -459,14 +463,13 @@ editMenu->addAction (a); actionEditUndo=a; - if (settings.value( "/mainwindow/showTestMenu",false).toBool()) - { - a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo" ), this); - a->setStatusTip (tr( "Redo" )); - a->setShortcut (Qt::CTRL + Qt::Key_Y ); - editMenu->addAction (a); - connect( a, SIGNAL( triggered() ), this, SLOT( editRedo() ) ); - } + a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo" ), this); + a->setStatusTip (tr( "Redo" )); + a->setShortcut (Qt::CTRL + Qt::Key_Y ); + tb->addAction (a); + editMenu->addAction (a); + connect( a, SIGNAL( triggered() ), this, SLOT( editRedo() ) ); + actionEditRedo=a; editMenu->addSeparator(); a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy" ), this); @@ -500,14 +503,14 @@ a = new QAction(tr( "Edit heading" ),this); a->setStatusTip ( tr( "edit Heading" )); a->setShortcut ( Qt::Key_Enter); - a->setShortcutContext (Qt::WindowShortcut); +// a->setShortcutContext (Qt::WindowShortcut); addAction (a); connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) ); actionListBranches.append(a); a = new QAction( tr( "Edit heading" ), this); a->setStatusTip (tr( "edit Heading" )); a->setShortcut (Qt::Key_Return ); - a->setShortcutContext (Qt::WindowShortcut); + //a->setShortcutContext (Qt::WindowShortcut); addAction (a); connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) ); actionListBranches.append(a); @@ -675,6 +678,13 @@ connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) ); actionEditOpenURLTab=a; + a = new QAction( tr( "Open all URLs in subtree" ), this); + a->setStatusTip (tr( "Open all URLs in subtree" )); + a->setShortcut (Qt::CTRL+Qt::Key_U ); + addAction(a); + connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) ); + actionEditOpenMultipleURLTabs=a; + a = new QAction(QPixmap(), tr( "Edit URL"+QString("...") ), this); a->setStatusTip ( tr( "Edit URL" ) ); a->setShortcut (Qt::SHIFT + Qt::CTRL + Qt::Key_U ); @@ -1503,7 +1513,6 @@ branchAddContextMenu->addSeparator(); branchAddContextMenu->addAction ( actionEditLoadImage); branchAddContextMenu->addSeparator(); - branchAddContextMenu->addAction ( actionEditLoadImage); branchAddContextMenu->addAction ( actionEditImportAdd ); branchAddContextMenu->addAction ( actionEditImportReplace ); @@ -1520,10 +1529,11 @@ branchContextMenu->addSeparator(); branchContextMenu->addAction ( actionEditOpenURL ); branchContextMenu->addAction ( actionEditOpenURLTab ); + branchContextMenu->addAction ( actionEditOpenMultipleURLTabs ); branchContextMenu->addAction ( actionEditURL ); branchContextMenu->addAction ( actionEditHeading2URL ); branchContextMenu->addAction ( actionEditBugzilla2URL ); - if (settings.value( "/mainwindow/showTestMenu",false).toBool() ) + if (settings.value( "/mainwindow/showTestMenu",true).toBool() ) { branchContextMenu->addAction ( actionEditFATE2URL ); } @@ -2433,6 +2443,7 @@ QMessageBox::Cancel | QMessageBox::Escape ); mb.setButtonText( QMessageBox::Yes, tr("Save map") ); mb.setButtonText( QMessageBox::No, tr("Discard changes") ); + mb.setModal (true); mb.show(); mb.setActiveWindow(); switch( mb.exec() ) { @@ -2508,20 +2519,86 @@ currentMapEditor()->findReset(); } +void Main::openTabs(QStringList urls) +{ + if (!urls.isEmpty()) + { + bool success=true; + QStringList args; + QString browser=settings.value("/mainwindow/readerURL" ).toString(); + QProcess *p; + if (!procBrowser || procBrowser->state()!=QProcess::Running) + { + QString u=urls.takeFirst(); + procBrowser = new QProcess( this ); + args<start(browser,args); + if ( !procBrowser->waitForStarted()) + { + // try to set path to browser + QMessageBox::warning(0, + tr("Warning"), + tr("Couldn't find a viewer to open %1.\n").arg(u)+ + tr("Please use Settings->")+tr("Set application to open an URL")); + return; + } + sleep (3); + } + if (browser.contains("konqueror")) + { + for (int i=0; ipid())<< + "konqueror-mainwindow#1"<< + "newTab" << + urls.at(i); + p->start ("dcop",args); + if ( !p->waitForStarted() ) success=false; + } + if (!success) + QMessageBox::warning(0, + tr("Warning"), + tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror")); + return; + } else if (browser.contains ("firefox") || browser.contains ("mozilla") ) + { + for (int i=0; istart (browser,args); + if ( !p->waitForStarted() ) success=false; + } + if (!success) + QMessageBox::warning(0, + tr("Warning"), + tr("Couldn't start %1 to open a new tab").arg(browser)); + return; + } + QMessageBox::warning(0, + tr("Warning"), + tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing.")); + } +} + void Main::editOpenURL() { // Open new browser if (currentMapEditor()) { QString url=currentMapEditor()->getURL(); + QStringList args; if (url=="") return; QString browser=settings.value("/mainwindow/readerURL" ).toString(); - procBrowser = new Q3Process( this ); - - procBrowser->addArgument( browser); - procBrowser->addArgument( url); - - if ( !procBrowser->start() ) + procBrowser = new QProcess( this ); + args<start(browser,args); + if ( !procBrowser->waitForStarted()) { // try to set path to browser QMessageBox::warning(0, @@ -2536,45 +2613,24 @@ { if (currentMapEditor()) { - QString url=currentMapEditor()->getURL(); - if (url=="") return; - QString browser=settings.value("/mainwindow/readerURL" ).toString(); - if (procBrowser && procBrowser->isRunning()) - { - if (browser.contains("konqueror")) - { - // Try to open new tab in existing konqueror started previously by vym - Q3Process *p=new Q3Process (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")); - return; - } else if (browser.contains ("firefox") || browser.contains ("mozilla") ) - { - // Try to open new tab in firefox - Q3Process *p=new Q3Process (this); - p->addArgument (browser); - p->addArgument ("-remote"); - p->addArgument (QString("openurl(%1,new-tab)").arg(url)); - if ( !p->start() ) - // try to set browser - QMessageBox::warning(0, - tr("Warning"), - tr("Couldn't start %1 to open a new tab").arg(browser)); - return; - } - } - // Open new browser - editOpenURL(); + QStringList urls; + urls.append(currentMapEditor()->getURL()); + openTabs (urls); } } +void Main::editOpenMultipleURLTabs() +{ + if (currentMapEditor()) + { + QStringList urls; + urls.append ("www.suse.de"); + urls.append ("www.google.de"); + urls.append ("www.heise.de"); + urls.append ("www.insilmaril.de"); + openTabs (urls); + } +} + void Main::editURL() { @@ -2600,6 +2656,54 @@ currentMapEditor()->editFATE2URL(); } +void Main::editHeading() +{ + if (lineedit->isVisible()) + { + if (currentMapEditor()) + currentMapEditor()->setHeading(lineedit->text()); + lineedit->releaseKeyboard(); + lineedit->hide(); + setFocus(); + } else + { + if (currentMapEditor()) + { + bool ok; + QPoint p; + QString s=currentMapEditor()->getHeading(ok,p); + + if (ok) + { +#if defined(Q_OS_MACX) + p = currentMapEditor()->mapToGlobal( currentMapEditor()->worldMatrix().map( p)); + QDialog *d =new QDialog(NULL); + QLineEdit *le=new QLineEdit (d); + d->setWindowFlags (Qt::FramelessWindowHint); + d->setGeometry(p.x(),p.y(),200,25); + le->resize (d->size()); + le->setText (s); + le->selectAll(); + connect (le, SIGNAL (returnPressed()), d, SLOT (accept())); + d->activateWindow(); + d->exec(); + currentMapEditor()->setHeading (le->text()); +#else + p = currentMapEditor()->mapTo(this, currentMapEditor()->worldMatrix().map( p)); + lineedit->setGeometry(p.x(),p.y(),200,25); + lineedit->setText(s); + lineedit->setCursorPosition(1); + lineedit->selectAll(); + lineedit->show(); + lineedit->grabKeyboard(); + lineedit->setFocus(); +#endif + + } + } + } +} + void Main::editOpenVymLink() { // Get current path to map @@ -2689,15 +2793,10 @@ } } -void Main::editHeading() -{ - if (currentMapEditor()) - currentMapEditor()->editHeading(); -} - void Main::editNewBranch() { - if (currentMapEditor()) + + if (!lineedit->isVisible() && currentMapEditor()) currentMapEditor()->addNewBranch(0); }