diff -r fb97757e06c0 -r 0796c5592f00 mainwindow.cpp --- a/mainwindow.cpp Sat Mar 31 09:28:30 2007 +0000 +++ b/mainwindow.cpp Mon Apr 09 15:42:21 2007 +0000 @@ -154,6 +154,7 @@ setupFlagActions(); setupSettingsActions(); setupContextMenus(); + setupMacros(); if (settings.value( "/mainwindow/showTestMenu",false).toBool()) setupTestActions(); setupHelpActions(); @@ -446,7 +447,7 @@ actionEditHeading=a; a = new QAction( tr( "Edit heading","Edit menu" ), this); a->setStatusTip (tr( "edit Heading" )); - a->setShortcut ( Qt::Key_F2 ); //Edit heading + //a->setShortcut ( Qt::Key_F2 ); //Edit heading a->setShortcutContext (Qt::WindowShortcut); addAction (a); connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) ); @@ -1427,12 +1428,12 @@ QAction *a; a = new QAction( "Test function" , this); a->setStatusTip( "Call test function" ); - a->setShortcut (Qt::Key_F4 ); + //a->setShortcut (Qt::Key_F4 ); connect( a, SIGNAL( triggered() ), this, SLOT( testFunction() ) ); testMenu->addAction (a); a = new QAction( "Command" , this); a->setStatusTip( "Enter command to call in editor" ); - a->setShortcut (Qt::Key_F5 ); + //a->setShortcut (Qt::Key_F5 ); connect( a, SIGNAL( triggered() ), this, SLOT( testCommand() ) ); testMenu->addAction (a); } @@ -1556,10 +1557,10 @@ // Create actions for (int i = 0; i < MaxRecentFiles; ++i) { - recentFileActs[i] = new QAction(this); - recentFileActs[i]->setVisible(false); - fileLastMapsMenu->addAction(recentFileActs[i]); - connect(recentFileActs[i], SIGNAL(triggered()), + recentFileActions[i] = new QAction(this); + recentFileActions[i]->setVisible(false); + fileLastMapsMenu->addAction(recentFileActions[i]); + connect(recentFileActions[i], SIGNAL(triggered()), this, SLOT(fileLoadRecent())); } setupRecentMapsMenu(); @@ -1572,14 +1573,37 @@ int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles); for (int i = 0; i < numRecentFiles; ++i) { - //QString text = tr("&%1 %2").arg(i + 1).arg(strippedName(files[i])); QString text = tr("&%1 %2").arg(i + 1).arg(files[i]); - recentFileActs[i]->setText(text); - recentFileActs[i]->setData(files[i]); - recentFileActs[i]->setVisible(true); + recentFileActions[i]->setText(text); + recentFileActions[i]->setData(files[i]); + recentFileActions[i]->setVisible(true); } for (int j = numRecentFiles; j < MaxRecentFiles; ++j) - recentFileActs[j]->setVisible(false); + recentFileActions[j]->setVisible(false); +} + +void Main::setupMacros() +{ + for (int i = 0; i <= 11; i++) + { + macroActions[i] = new QAction(this); + macroActions[i]->setData(i); + addAction (macroActions[i]); + connect(macroActions[i], SIGNAL(triggered()), + this, SLOT(callMacro())); + } + macroActions[0]->setShortcut ( Qt::Key_F1 ); + macroActions[1]->setShortcut ( Qt::Key_F2 ); + macroActions[2]->setShortcut ( Qt::Key_F3 ); + macroActions[3]->setShortcut ( Qt::Key_F4 ); + macroActions[4]->setShortcut ( Qt::Key_F5 ); + macroActions[5]->setShortcut ( Qt::Key_F6 ); + macroActions[6]->setShortcut ( Qt::Key_F7 ); + macroActions[7]->setShortcut ( Qt::Key_F8 ); + macroActions[8]->setShortcut ( Qt::Key_F9 ); + macroActions[9]->setShortcut ( Qt::Key_F10 ); + macroActions[10]->setShortcut ( Qt::Key_F11 ); + macroActions[11]->setShortcut ( Qt::Key_F12 ); } void Main::hideEvent (QHideEvent * ) @@ -2257,9 +2281,9 @@ QStringList fl; QFileDialog *fd=new QFileDialog (this); fd->setCaption (tr("Export map as image")); + fd->setDirectory (lastImageDir); fd->setFileMode(QFileDialog::AnyFile); fd->setFilters (imageIO.getFilters() ); - fd->setDirectory (lastImageDir); if (fd->exec()) { fl=fd->selectedFiles(); @@ -3603,3 +3627,19 @@ QMessageBox::aboutQt( this, "Qt Application Example" ); } +void Main::callMacro () +{ + QAction *action = qobject_cast(sender()); + int i=-1; + if (action) + { + i=action->data().toInt(); + QString m=settings.value(QString("/macros/macro-%1").arg(i) ).toString(); + if (! m.isEmpty()) + { + cout <<"Main::callMacro m="<runScript (m); + } + } +} +