Beispiel #1
0
void KviMainWindow::installAccelerators()
{
	m_pAccellerators->append(KviShortcut::create(KVI_SHORTCUTS_WIN_PREV, this, SLOT(switchToPrevWindow()), nullptr, Qt::ApplicationShortcut));
	m_pAccellerators->append(KviShortcut::create(KVI_SHORTCUTS_WIN_NEXT, this, SLOT(switchToNextWindow()), nullptr, Qt::ApplicationShortcut));
	m_pAccellerators->append(KviShortcut::create(KVI_SHORTCUTS_WIN_PREV_CONTEXT, this, SLOT(switchToPrevWindowInContext()), nullptr, Qt::ApplicationShortcut));
	m_pAccellerators->append(KviShortcut::create(KVI_SHORTCUTS_WIN_NEXT_CONTEXT, this, SLOT(switchToNextWindowInContext()), nullptr, Qt::ApplicationShortcut));
	m_pAccellerators->append(KviShortcut::create(KVI_SHORTCUTS_WIN_PREV_HIGHLIGHT, this, SLOT(switchToPrevHighlightedWindow()), nullptr, Qt::ApplicationShortcut));
	m_pAccellerators->append(KviShortcut::create(KVI_SHORTCUTS_WIN_NEXT_HIGHLIGHT, this, SLOT(switchToNextHighlightedWindow()), nullptr, Qt::ApplicationShortcut));
	m_pAccellerators->append(KviShortcut::create(KVI_SHORTCUTS_WIN_CLOSE, this, SLOT(closeActiveWindow()), nullptr, Qt::ApplicationShortcut));
	m_pAccellerators->append(KviShortcut::create(KVI_SHORTCUTS_WIN_PREV_TAB, this, SLOT(switchToPrevWindow()), nullptr, Qt::ApplicationShortcut));
	m_pAccellerators->append(KviShortcut::create(KVI_SHORTCUTS_WIN_NEXT_TAB, this, SLOT(switchToNextWindow()), nullptr, Qt::ApplicationShortcut));

	static int accel_table[] = {
		Qt::Key_1 + Qt::ControlModifier, // script accels...
		Qt::Key_2 + Qt::ControlModifier,
		Qt::Key_3 + Qt::ControlModifier,
		Qt::Key_4 + Qt::ControlModifier,
		Qt::Key_5 + Qt::ControlModifier,
		Qt::Key_6 + Qt::ControlModifier,
		Qt::Key_7 + Qt::ControlModifier,
		Qt::Key_8 + Qt::ControlModifier,
		Qt::Key_9 + Qt::ControlModifier,
		Qt::Key_0 + Qt::ControlModifier,
		Qt::Key_F2,
		Qt::Key_F3,
		Qt::Key_F4,
		Qt::Key_F5,
		Qt::Key_F6,
		Qt::Key_F7,
		Qt::Key_F8,
		Qt::Key_F9,
		Qt::Key_F10,
		Qt::Key_F11,
		Qt::Key_F12,
		Qt::Key_F1 + Qt::ShiftModifier,
		Qt::Key_F2 + Qt::ShiftModifier,
		Qt::Key_F3 + Qt::ShiftModifier,
		Qt::Key_F4 + Qt::ShiftModifier,
		Qt::Key_F5 + Qt::ShiftModifier,
		Qt::Key_F6 + Qt::ShiftModifier,
		Qt::Key_F7 + Qt::ShiftModifier,
		Qt::Key_F8 + Qt::ShiftModifier,
		Qt::Key_F9 + Qt::ShiftModifier,
		Qt::Key_F10 + Qt::ShiftModifier,
		Qt::Key_F11 + Qt::ShiftModifier,
		Qt::Key_F12 + Qt::ShiftModifier,
		0
	};

	int i = 0, keys = 0;
	while((keys = accel_table[i]))
	{
		m_pAccellerators->append(KviShortcut::create(keys, this, SLOT(accelActivated()), SLOT(accelActivated()), Qt::ApplicationShortcut));
		i++;
	}
}
bool QWorkspace::qt_invoke( int _id, QUObject* _o )
{
    switch ( _id - staticMetaObject()->slotOffset() ) {
    case 0: cascade(); break;
    case 1: tile(); break;
    case 2: closeActiveWindow(); break;
    case 3: closeAllWindows(); break;
    case 4: activateNextWindow(); break;
    case 5: activatePrevWindow(); break;
    case 6: normalizeActiveWindow(); break;
    case 7: minimizeActiveWindow(); break;
    case 8: showOperationMenu(); break;
    case 9: popupOperationMenu((const QPoint&)*((const QPoint*)static_QUType_ptr.get(_o+1))); break;
    case 10: operationMenuActivated((int)static_QUType_int.get(_o+1)); break;
    case 11: operationMenuAboutToShow(); break;
    case 12: toolMenuAboutToShow(); break;
    case 13: activatePreviousWindow(); break;
    case 14: dockWindowsShow(); break;
    case 15: scrollBarChanged(); break;
    default:
	return QWidget::qt_invoke( _id, _o );
    }
    return TRUE;
}
Beispiel #3
0
void MainWindow::createActions()
{


	openAction = new QAction(QIcon(":/images/open.png"), tr("&Open..."),
	                         this);
	openAction->setShortcut(tr("Ctrl+O"));
	openAction->setStatusTip(tr("Open an existing file"));
	connect(openAction, SIGNAL(triggered()), this, SLOT(open()));

	saveAction = new QAction(QIcon(":/images/save.png"), tr("&Save"),
	                         this);
	saveAction->setShortcut(tr("Ctrl+S"));
	saveAction->setStatusTip(tr("Save the file to disk"));
	connect(saveAction, SIGNAL(triggered()), this, SLOT(save()));

	saveAsAction = new QAction(tr("Save &As..."), this);
	saveAsAction->setStatusTip(tr("Save the file under a new name"));
	connect(saveAsAction, SIGNAL(triggered()), this, SLOT(saveAs()));

	exitAction = new QAction(tr("E&xit"), this);
	exitAction->setShortcut(tr("Ctrl+Q"));
	exitAction->setStatusTip(tr("Exit the application"));
	connect(exitAction, SIGNAL(triggered()), this, SLOT(close()));

	closeAction = new QAction(tr("Cl&ose"), this);
	closeAction->setShortcut(tr("Ctrl+F4"));
	closeAction->setStatusTip(tr("Close the active window"));
	connect(closeAction, SIGNAL(triggered()),
	        workspace, SLOT(closeActiveWindow()));

	closeAllAction = new QAction(tr("Close &All"), this);
	closeAllAction->setStatusTip(tr("Close all windows"));
	connect(closeAllAction, SIGNAL(triggered()),
	        workspace, SLOT(closeAllWindows()));

	tileAction = new QAction(tr("&Tile"), this);
	tileAction->setStatusTip(tr("Tile the windows"));
	connect(tileAction, SIGNAL(triggered()), workspace, SLOT(tile()));

	cascadeAction = new QAction(tr("&Cascade"), this);
	cascadeAction->setStatusTip(tr("Cascade the windows"));
	connect(cascadeAction, SIGNAL(triggered()),
	        workspace, SLOT(cascade()));

	nextAction = new QAction(tr("Ne&xt"), this);
	nextAction->setShortcut(tr("Ctrl+F6"));
	nextAction->setStatusTip(tr("Move the focus to the next window"));
	connect(nextAction, SIGNAL(triggered()),
	        workspace, SLOT(activateNextWindow()));

	previousAction = new QAction(tr("Pre&vious"), this);
	previousAction->setShortcut(tr("Ctrl+Shift+F6"));
	previousAction->setStatusTip(tr("Move the focus to the previous "
	                                "window"));
	connect(previousAction, SIGNAL(triggered()),
	        workspace, SLOT(activatePreviousWindow()));

	separatorAction = new QAction(this);
	separatorAction->setSeparator(true);

	aboutAction = new QAction(tr("&About"), this);
	aboutAction->setStatusTip(tr("Show the application's About box"));
	connect(aboutAction, SIGNAL(triggered()), this, SLOT(about()));

	powerSpectrumFFTAction = new QAction(tr("Power spectrum with &FFT"), this);
	powerSpectrumFFTAction->setIcon(QIcon(":/images/fft.png"));
	powerSpectrumFFTAction->setShortcut(tr("Ctrl+F"));
	powerSpectrumFFTAction->setStatusTip(tr("Get power spectrum using FFT"));
	connect(powerSpectrumFFTAction, SIGNAL(triggered()), this, SLOT(getPowerSpectrumUsingFFT()));

	powerSpectrumDCTAction = new QAction(tr("Power spectrum with &DCT"), this);
	powerSpectrumDCTAction->setIcon(QIcon(":/images/dct.png"));
	powerSpectrumDCTAction->setShortcut(tr("Ctrl+D"));
	powerSpectrumDCTAction->setStatusTip(tr("Get power spectrum using DCT"));
	connect(powerSpectrumDCTAction, SIGNAL(triggered()), this, SLOT(getPowerSpectrumUsingDCT()));

	linearConvolutionFFTAction = new QAction(tr("Convolution using FFT"), this);
	linearConvolutionFFTAction->setIcon(QIcon(":/images/cfft.png"));
	linearConvolutionFFTAction->setShortcut(tr("Ctrl+L"));
	linearConvolutionFFTAction->setStatusTip(tr("Convolution using FFT"));
	connect(linearConvolutionFFTAction, SIGNAL(triggered()), this, SLOT(convolutionFFTDialog()));


	linearConvolutionDCTAction = new QAction(tr("Convolution using DCT"), this);
	linearConvolutionDCTAction->setIcon(QIcon(":/images/cdct.png"));
	linearConvolutionDCTAction->setShortcut(tr("Ctrl+K"));
	linearConvolutionDCTAction->setStatusTip(tr("Convolution using DCT"));
	connect(linearConvolutionDCTAction, SIGNAL(triggered()), this, SLOT(convolutionDCTDialog()));

	windowActionGroup = new QActionGroup(this);
}
/*
The "Window" menu item is created dynamically;  This slot creates the menu items
for the Window menu before it's shown.
*/
void CMDIWindow::windowMenuAboutToShow()
{
#ifdef DEBUG
  qDebug("CMDIWindow::windowMenuAboutToShow()");
#endif
  
  windowMenu->clear();
  
  int consoleWindowId = windowMenu->insertItem(consoleWindow->caption(), this, SLOT(consoleWindowDisplay()));
  windowMenu->setItemParameter(consoleWindowId, 0);
  windowMenu->setItemChecked(consoleWindowId, !consoleWindow->isHidden());
  windowMenu->insertSeparator();
  
  int closeId = windowMenu->insertItem(getPixmapIcon("closeIcon"), tr("Cl&ose"), this, SLOT(closeActiveWindow()));
  int closeAllId = windowMenu->insertItem(getPixmapIcon("closeAllIcon"), tr("Close Al&l"), this, SLOT(closeAllWindows()));
  windowMenu->insertSeparator();
  int cascadeId = windowMenu->insertItem(getPixmapIcon("cascadeIcon"), tr("&Cascade"), CApplication::Application()->workSpace(), SLOT(cascade()));
  int tileId = windowMenu->insertItem(getPixmapIcon("tileIcon"), tr("&Tile"), CApplication::Application()->workSpace(), SLOT(tile()));
  QWidgetList openWindows = CApplication::Application()->workSpace()->windowList();
  
  if ( ((openWindows.count() <= 1) || (CApplication::Application()->workSpace()->windowList().isEmpty())) && (consoleWindow->isHidden()))
  {
    windowMenu->setItemEnabled( closeId, false);
    windowMenu->setItemEnabled( closeAllId, false);
    windowMenu->setItemEnabled( cascadeId, false);
    windowMenu->setItemEnabled( tileId, false);
  }
  else
    if (openWindows.count() > 1)
      windowMenu->insertSeparator();
    for ( int i = 1; i < int(openWindows.count()); ++i )
    {
      int id = windowMenu->insertItem(openWindows.at(i)->caption(), this, SLOT(windowActivated(int)));
      windowMenu->setItemParameter(id, i);
      windowMenu->setItemChecked(id, CApplication::Application()->workSpace()->activeWindow() == openWindows.at(i));
    }
}