~ubuntu-branches/ubuntu/trusty/avogadro/trusty-proposed

« back to all changes in this revision

Viewing changes to avogadro/src/mainwindow.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Rohan Garg
  • Date: 2011-05-20 18:55:49 UTC
  • mfrom: (3.2.13 sid)
  • Revision ID: james.westby@ubuntu.com-20110520185549-berzu8h9f9330xji
Tags: 1.0.3-1ubuntu1
* Merge from debian, remaining changes (LP: #787458, #784267)
  - Disable builds for ARM as build dependency on libOpenGL and 
    libQtOpenGL

Show diffs side-by-side

added added

removed removed

Lines of Context:
317
317
    QAction *redoAction = d->undoStack->createRedoAction( this );
318
318
    redoAction->setIcon( QIcon( QLatin1String( ":/icons/edit-redo.png" ) ) );
319
319
    redoAction->setShortcuts( QKeySequence::Redo );
 
320
    ui.actionClear->setShortcuts( QList<QKeySequence>() << QKeySequence("Backspace") << QKeySequence("Del"));
320
321
    if ( ui.menuEdit->actions().count() ) {
321
322
      QAction *firstAction = ui.menuEdit->actions().at( 0 );
322
323
      ui.menuEdit->insertAction( firstAction, redoAction );
747
748
      }
748
749
#endif
749
750
 
750
 
      // check to see if we already have an open window
751
 
      MainWindow *existing = findMainWindow( fileName );
752
 
      if ( existing ) {
753
 
        existing->show();
754
 
        existing->raise();
755
 
        existing->activateWindow();
756
 
        return;
 
751
      // If current window is not empty or has non-default file name,
 
752
      // check if we already have an open window with this file
 
753
      if ( !isDefaultFileName(d->fileName) ||
 
754
           (d->molecule && d->molecule->numAtoms()) ) {
 
755
        MainWindow *existing = findMainWindow( fileName );
 
756
        if ( existing ) {
 
757
          existing->show();
 
758
          existing->raise();
 
759
          existing->activateWindow();
 
760
          return;
 
761
        }
757
762
      }
758
763
 
759
764
      // if we have nothing open or modified
2906
2911
        QStringList menuPath = menuPathString.split( '>' );
2907
2912
        // Root menus are a special case, we need to check menuBar()
2908
2913
        foreach( QAction *menu, menuBar()->actions() ) {
2909
 
          if ( menu->text() == menuPath.at( 0 ) ) {
 
2914
          // Strip "&" off of comparison to prevent "duplicate" menus.
 
2915
          QString cleanedExtensionMenu = menuPath.at(0);
 
2916
          QString cleanedMenu = menu->text();
 
2917
          cleanedExtensionMenu.remove('&');
 
2918
          cleanedMenu.remove('&');
 
2919
          if (cleanedMenu == cleanedExtensionMenu) {
2910
2920
            path = menu->menu();
2911
2921
            break;
2912
2922
          }
2925
2935
          // Go through each submenu level, find the match
2926
2936
          // and update the "path" pointer
2927
2937
          for ( int i = 1; i < menuPath.size(); ++i ) {
2928
 
 
 
2938
            bool found = false;
2929
2939
            foreach( QAction *menu, path->actions() ) {
2930
2940
              if ( menu->text() == menuPath.at( i ) ) {
2931
2941
                nextPath = menu->menu();
 
2942
                found = true;
2932
2943
                break;
2933
2944
              }
2934
2945
            } // end checking menu items
2935
2946
 
2936
 
            if ( !nextPath ) {
 
2947
            if ( !found ) {
2937
2948
              // add a new submenu
2938
2949
              nextPath = path->addMenu( menuPath.at( i ) );
2939
2950
            }