void Tile::keyPressEvent(QKeyEvent *event) { if (event->key() == Qt::Key_Escape || event->key() == Qt::Key_Q) { Quit(); } else if (event->key() == Qt::Key_S) { Shuffle(); } else if (event->key() == Qt::Key_R) { Reset(); } else if (event->key() == Qt::Key_H) { Help(); } else if (event->key() == Qt::Key_O) { Solve(); } else if (event->key() == Qt::Key_Up) { //focusNextChild(); //qDebug() << qApp->focusWidget(); QPushButton *button = qobject_cast< QPushButton* >(qApp->focusWidget()); if (button) { keyUp(button); } } else if (event->key() == Qt::Key_Down) { //focusPreviousChild(); //qDebug() << qApp->focusWidget(); QPushButton *button = qobject_cast< QPushButton* >(qApp->focusWidget()); if (button) { keyDown(button); } } else if( event->key() == Qt::Key_Return ) { QPushButton *button = qobject_cast< QPushButton* >(qApp->focusWidget()); if (button) { button->click(); } } else { return; } }
void VCMatrix::slotInputValueChanged(quint32 universe, quint32 channel, uchar value) { /* Don't let input data thru in design mode */ if (mode() == Doc::Design || isEnabled() == false) return; quint32 pagedCh = (page() << 16) | channel; if (checkInputSource(universe, pagedCh, value, sender())) { m_slider->setValue((int) value); } else { QHashIterator<QPushButton *, VCMatrixControl *> it(m_controls); while(it.hasNext()) { it.next(); VCMatrixControl *control = it.value(); if (control->m_inputSource != NULL && control->m_inputSource->universe() == universe && control->m_inputSource->channel() == pagedCh) { QPushButton *button = it.key(); button->click(); } } } }
void TaskView::keyPressEvent(QKeyEvent* ke) { if (ActiveCtrl && ActiveDialog) { if (ke->key() == Qt::Key_Return || ke->key() == Qt::Key_Enter) { // get all buttons of the complete task dialog QList<QPushButton*> list = this->findChildren<QPushButton*>(); for (int i=0; i<list.size(); ++i) { QPushButton *pb = list.at(i); if (pb->isDefault() && pb->isVisible()) { if (pb->isEnabled()) pb->click(); return; } } } else if (ke->key() == Qt::Key_Escape) { // get only the buttons of the button box QDialogButtonBox* box = ActiveCtrl->standardButtons(); QList<QAbstractButton*> list = box->buttons(); for (int i=0; i<list.size(); ++i) { QAbstractButton *pb = list.at(i); if (box->buttonRole(pb) == QDialogButtonBox::RejectRole) { if (pb->isEnabled()) pb->click(); return; } } } } else { QScrollArea::keyPressEvent(ke); } }
void RemoteControl::dial(const QVariantList &args) { QString extension = args[0].toString(); DialPanel *xlet = this->get_xlet<DialPanel>("dial"); QComboBox *extension_input = xlet->findChild<QComboBox *>("extension_input"); QPushButton *button = xlet->findChild<QPushButton *>("dial_button"); extension_input->setEditText(extension); button->click(); }
bool DialogyWidget::clickButton(QDialogButtonBox::StandardButton standardButton) { QPushButton* pb = qobject_cast<QPushButton*>(focusWidget()); if (pb && pb->isVisible() && pb->isEnabled() && pb->hasFocus()) { pb->click(); return true; } QList<QDialogButtonBox*> buttonBoxes = findChildren<QDialogButtonBox*>(); for (int i = 0; i < buttonBoxes.size(); ++i) { QDialogButtonBox* buttonBox = buttonBoxes.at(i); pb = buttonBox->button(standardButton); if (pb && pb->isVisible() && pb->isEnabled()) { pb->click(); return true; } } return false; }
void MainInterface::menuTimeout() { QPushButton *Fn ; Fn = barui->findChild<QPushButton *> ("pushButton_F8"); if(Fn != NULL){ Fn->click(); } if(timer->isActive()) timer->stop(); }
void TaskView::keyPressEvent(QKeyEvent* ke) { if (ActiveCtrl && ActiveDialog) { if (ke->key() == Qt::Key_Return || ke->key() == Qt::Key_Enter) { // get all buttons of the complete task dialog QList<QPushButton*> list = this->findChildren<QPushButton*>(); for (int i=0; i<list.size(); ++i) { QPushButton *pb = list.at(i); if (pb->isDefault() && pb->isVisible()) { if (pb->isEnabled()) { #if defined(FC_OS_MACOSX) // #0001354: Crash on using Enter-Key for confirmation of chamfer or fillet entries QPoint pos = QCursor::pos(); QCursor::setPos(pb->parentWidget()->mapToGlobal(pb->pos())); #endif pb->click(); #if defined(FC_OS_MACOSX) QCursor::setPos(pos); #endif } return; } } } else if (ke->key() == Qt::Key_Escape) { // get only the buttons of the button box QDialogButtonBox* box = ActiveCtrl->standardButtons(); QList<QAbstractButton*> list = box->buttons(); for (int i=0; i<list.size(); ++i) { QAbstractButton *pb = list.at(i); if (box->buttonRole(pb) == QDialogButtonBox::RejectRole) { if (pb->isEnabled()) { #if defined(FC_OS_MACOSX) // #0001354: Crash on using Enter-Key for confirmation of chamfer or fillet entries QPoint pos = QCursor::pos(); QCursor::setPos(pb->parentWidget()->mapToGlobal(pb->pos())); #endif pb->click(); #if defined(FC_OS_MACOSX) QCursor::setPos(pos); #endif } return; } } } } else { QScrollArea::keyPressEvent(ke); } }
void VCMatrix::slotKeyPressed(const QKeySequence &keySequence) { if (isEnabled() == false) return; QHashIterator<QPushButton *, VCMatrixControl *> it(m_controls); while(it.hasNext()) { it.next(); VCMatrixControl *control = it.value(); if (control->m_keySequence == keySequence) { QPushButton *button = it.key(); button->click(); } } }
void tst_AddBookmarkDialog::addbookmarkdialog() { QFETCH(QString, url); QFETCH(QString, title); QFETCH(QDialogButtonBox::StandardButton, button); QFETCH(int, menuCount); QFETCH(int, toolbarCount); QFETCH(int, select); BookmarksManager *manager = BrowserApplication::bookmarksManager(); qRegisterMetaType<BookmarkNode *>("BookmarkNode *"); QSignalSpy spy(manager, SIGNAL(entryAdded(BookmarkNode *))); BookmarkNode *menu = manager->menu(); BookmarkNode *toolbar = manager->toolbar(); QCOMPARE(menu->children().count(), 0); QCOMPARE(toolbar->children().count(), 0); SubAddBookmarkDialog dialog(0, manager); dialog.setUrl(url); dialog.setTitle(title); QComboBox *combobox = dialog.findChild<QComboBox*>(); QVERIFY(combobox); if (select != -1) { combobox->setCurrentIndex(select); combobox->view()->setCurrentIndex(combobox->model()->index(select, 0)); } QDialogButtonBox *buttonBox = dialog.findChild<QDialogButtonBox*>(); QVERIFY(buttonBox); QPushButton *pushButton = buttonBox->button(button); pushButton->click(); QCOMPARE(spy.count(), menuCount + toolbarCount); QCOMPARE(menu->children().count(), menuCount); QCOMPARE(toolbar->children().count(), toolbarCount); BookmarkNode *node = 0; if (menuCount == 1) node = menu->children()[0]; if (toolbarCount == 1) node = toolbar->children()[0]; if (node) { QCOMPARE(node->title, title); QCOMPARE(node->url, url); } }
ZoomScrollTrack2::ZoomScrollTrack2(QWidget *parent) : QDialog(parent) { // // Set up the GUI // setFixedSize(782, 376); setWindowTitle("Zooming and Scrolling with Track Line (2)"); // The frame on the left side QFrame *frame = new QFrame(this); frame->setGeometry(4, 4, 120, 370); frame->setFrameShape(QFrame::StyledPanel); // Pointer push button QPushButton *pointerPB = new QPushButton(QIcon(":/pointer.png"), "Pointer", frame); pointerPB->setGeometry(4, 8, 112, 28); pointerPB->setStyleSheet("QPushButton { text-align:left; padding:5px}"); pointerPB->setCheckable(true); // Zoom In push button QPushButton *zoomInPB = new QPushButton(QIcon(":/zoomin.png"), "Zoom In", frame); zoomInPB->setGeometry(4, 36, 112, 28); zoomInPB->setStyleSheet("QPushButton { text-align:left; padding:5px}"); zoomInPB->setCheckable(true); // Zoom Out push button QPushButton *zoomOutPB = new QPushButton(QIcon(":/zoomout.png"), "Zoom Out", frame); zoomOutPB->setStyleSheet("QPushButton { text-align:left; padding:5px}"); zoomOutPB->setGeometry(4, 64, 112, 28); zoomOutPB->setCheckable(true); // The Pointer/Zoom In/Zoom Out buttons form a button group QButtonGroup *mouseUsage = new QButtonGroup(frame); mouseUsage->addButton(pointerPB, Chart::MouseUsageScroll); mouseUsage->addButton(zoomInPB, Chart::MouseUsageZoomIn); mouseUsage->addButton(zoomOutPB, Chart::MouseUsageZoomOut); connect(mouseUsage, SIGNAL(buttonPressed(int)), SLOT(onMouseUsageChanged(int))); // Start Date control (new QLabel("Start Date", frame))->setGeometry(6, 230, 112, 18); m_StartDate = new QDateEdit(frame); m_StartDate->setGeometry(4, 248, 113, 22); connect(m_StartDate, SIGNAL(dateTimeChanged(QDateTime)), SLOT(onStartDateChanged(QDateTime))); // Duration control (new QLabel("End Date", frame))->setGeometry(6, 284, 112, 18); m_EndDate = new QDateEdit(frame); m_EndDate->setGeometry(4, 302, 113, 22); connect(m_EndDate, SIGNAL(dateTimeChanged(QDateTime)), SLOT(onEndDateChanged(QDateTime))); // Chart Viewer m_ChartViewer = new QChartViewer(this); m_ChartViewer->setGeometry(128, 4, 650, 350); connect(m_ChartViewer, SIGNAL(viewPortChanged()), SLOT(onViewPortChanged())); connect(m_ChartViewer, SIGNAL(mouseMovePlotArea(QMouseEvent*)), SLOT(onMouseMovePlotArea(QMouseEvent*))); connect(m_ChartViewer, SIGNAL(mouseWheel(QWheelEvent*)), SLOT(onMouseWheelChart(QWheelEvent*))); // Horizontal scroll bar m_HScrollBar = new QScrollBar(Qt::Horizontal, this); m_HScrollBar->setGeometry(128, 356, 650, 17); connect(m_HScrollBar, SIGNAL(valueChanged(int)), SLOT(onHScrollBarChanged(int))); // // Initialize the chart // // Load the data loadData(); // Initialize the QChartViewer initChartViewer(m_ChartViewer); // Initially set the mouse to drag to scroll mode pointerPB->click(); // Trigger the ViewPortChanged event to draw the chart m_ChartViewer->updateViewPort(true, true); }
void MainInterface::keyPressEvent( QKeyEvent *k ) { QPalette palette; QColor color(255 ,0 ,0); palette.setColor(QPalette::WindowText,color); /*去除按键重复事件*/ if(!k->isAutoRepeat()){ k->accept(); QPushButton *Fn ; switch(k->key()) { case Qt::Key_F1: Fn = barui->findChild<QPushButton *> ("pushButton_F1"); if(Fn != NULL) Fn->click(); break; case Qt::Key_F2: Fn = barui->findChild<QPushButton *> ("pushButton_F2"); if(Fn != NULL) Fn->click(); break; case Qt::Key_F3: Fn = barui->findChild<QPushButton *> ("pushButton_F3"); if(Fn != NULL) Fn->click(); break; case Qt::Key_F4: Fn = barui->findChild<QPushButton *> ("pushButton_F4"); if(Fn != NULL) Fn->click(); break; case Qt::Key_F5: Fn = barui->findChild<QPushButton *> ("pushButton_F5"); if(Fn != NULL) Fn->click(); break; case Qt::Key_F6: Fn = barui->findChild<QPushButton *> ("pushButton_F6"); if(Fn != NULL) Fn->click(); break; case Qt::Key_F7: Fn = barui->findChild<QPushButton *> ("pushButton_F7"); if(Fn != NULL) Fn->click(); break; case Qt::Key_F8: Fn = barui->findChild<QPushButton *> ("pushButton_F8"); if(Fn != NULL){ if(barmap.key(barui) != 28){ Fn->click(); }else{ if(!timer->isActive()) timer->start(); } } break; case Qt::Key_X: ui->label_cux->setPalette(palette); command ->setFocus(); command ->setStatus(0x10); command ->setType(false ,true ,0x04 ,true ,0x03); target = L_SLOT << 8 | L_X_CURRENT; command ->setTarget(L_SLOT ,L_X_CURRENT); break; case Qt::Key_Y: ui->label_cuy->setPalette(palette); command ->setFocus(); command ->setStatus(0x10); command ->setType(false ,true ,0x04 ,true ,0x03); target = L_SLOT << 8 | L_Y_CURRENT; command ->setTarget(L_SLOT ,L_Y_CURRENT); break; case Qt::Key_Z: ui->label_cuz->setPalette(palette); command ->setFocus(); command ->setStatus(0x10); command ->setType(false ,true ,0x04 ,true ,0x03); target = L_SLOT << 8 | L_Z_CURRENT; command ->setTarget(L_SLOT ,L_Z_CURRENT); break; case Qt::Key_F9: case Qt::Key_F10: break; /*放电监听F11键*/ case Qt::Key_F11: spark_info->setBool(B_START ,false); break; case Qt::Key_F12: spark_info->setBool(B_START ,true); break; case Qt::Key_Up: case Qt::Key_Down: case Qt::Key_Left: case Qt::Key_Right: emit keyPress(k->key()); break; /*这里的Enter键用来响应放电数据表的段选和删除行*/ case Qt::Key_Enter: tableRowClick(ui->tableView->currentIndex()); break; default : break; } } else k->ignore(); }
VstEffectControlDialog::VstEffectControlDialog( VstEffectControls * _ctl ) : EffectControlDialog( _ctl ), m_pluginWidget( NULL ), m_plugin( NULL ), tbLabel( NULL ) { QGridLayout * l = new QGridLayout( this ); l->setContentsMargins( 10, 10, 10, 10 ); l->setVerticalSpacing( 2 ); l->setHorizontalSpacing( 2 ); if( _ctl != NULL && _ctl->m_effect != NULL && _ctl->m_effect->m_plugin != NULL ) { m_plugin = _ctl->m_effect->m_plugin; m_plugin->showEditor( NULL, true ); m_pluginWidget = m_plugin->pluginWidget(); #ifdef LMMS_BUILD_WIN32 if( !m_pluginWidget ) { m_pluginWidget = m_plugin->pluginWidget( false ); } #endif } if( m_pluginWidget ) { setWindowTitle( m_pluginWidget->windowTitle() ); setMinimumWidth( 250 ); QPushButton * btn = new QPushButton( tr( "Show/hide" ) ); btn->setCheckable( true ); connect( btn, SIGNAL( toggled( bool ) ), m_pluginWidget, SLOT( setVisible( bool ) ) ); emit btn->click(); btn->setMinimumWidth( 78 ); btn->setMaximumWidth( 78 ); btn->setMinimumHeight( 24 ); btn->setMaximumHeight( 24 ); m_managePluginButton = new pixmapButton( this, "" ); m_managePluginButton->setCheckable( false ); m_managePluginButton->setCursor( Qt::PointingHandCursor ); m_managePluginButton->setActiveGraphic( PLUGIN_NAME::getIconPixmap( "track_op_menu" ) ); m_managePluginButton->setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "track_op_menu" ) ); connect( m_managePluginButton, SIGNAL( clicked() ), _ctl, SLOT( managePlugin() ) ); toolTip::add( m_managePluginButton, tr( "Control VST-plugin from LMMS host" ) ); m_managePluginButton->setWhatsThis( tr( "Click here, if you want to control VST-plugin from host." ) ); m_managePluginButton->setMinimumWidth( 21 ); m_managePluginButton->setMaximumWidth( 21 ); m_managePluginButton->setMinimumHeight( 21 ); m_managePluginButton->setMaximumHeight( 21 ); m_openPresetButton = new pixmapButton( this, "" ); m_openPresetButton->setCheckable( false ); m_openPresetButton->setCursor( Qt::PointingHandCursor ); m_openPresetButton->setActiveGraphic( PLUGIN_NAME::getIconPixmap( "stepper-up-press" ) ); m_openPresetButton->setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "stepper-up" ) ); connect( m_openPresetButton, SIGNAL( clicked() ), _ctl, SLOT( openPreset() ) ); toolTip::add( m_openPresetButton, tr( "Open VST-plugin preset" ) ); m_openPresetButton->setWhatsThis( tr( "Click here, if you want to open another *.fxp, *.fxb VST-plugin preset." ) ); m_openPresetButton->setMinimumWidth( 16 ); m_openPresetButton->setMaximumWidth( 16 ); m_openPresetButton->setMinimumHeight( 16 ); m_openPresetButton->setMaximumHeight( 16 ); m_rolLPresetButton = new pixmapButton( this, "" ); m_rolLPresetButton->setCheckable( false ); m_rolLPresetButton->setCursor( Qt::PointingHandCursor ); m_rolLPresetButton->setActiveGraphic( PLUGIN_NAME::getIconPixmap( "stepper-left-press" ) ); m_rolLPresetButton->setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "stepper-left" ) ); connect( m_rolLPresetButton, SIGNAL( clicked() ), _ctl, SLOT( rolrPreset() ) ); connect( m_rolLPresetButton, SIGNAL( clicked() ), this, SLOT( update() ) ); toolTip::add( m_rolLPresetButton, tr( "Previous (-)" ) ); m_rolLPresetButton->setShortcut( Qt::Key_Minus ); m_rolLPresetButton->setWhatsThis( tr( "Click here, if you want to switch to another VST-plugin preset program." ) ); m_rolLPresetButton->setMinimumWidth( 16 ); m_rolLPresetButton->setMaximumWidth( 16 ); m_rolLPresetButton->setMinimumHeight( 16 ); m_rolLPresetButton->setMaximumHeight( 16 ); m_rolRPresetButton = new pixmapButton( this, "" ); m_rolRPresetButton->setCheckable( false ); m_rolRPresetButton->setCursor( Qt::PointingHandCursor ); m_rolRPresetButton->setActiveGraphic( PLUGIN_NAME::getIconPixmap( "stepper-right-press" ) ); m_rolRPresetButton->setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "stepper-right" ) ); connect( m_rolRPresetButton, SIGNAL( clicked() ), _ctl, SLOT( rollPreset() ) ); connect( m_rolRPresetButton, SIGNAL( clicked() ), this, SLOT( update() ) ); toolTip::add( m_rolRPresetButton, tr( "Next (+)" ) ); m_rolRPresetButton->setShortcut( Qt::Key_Plus ); m_rolRPresetButton->setWhatsThis( tr( "Click here, if you want to switch to another VST-plugin preset program." ) ); m_rolRPresetButton->setMinimumWidth( 16 ); m_rolRPresetButton->setMaximumWidth( 16 ); m_rolRPresetButton->setMinimumHeight( 16 ); m_rolRPresetButton->setMaximumHeight( 16 ); _ctl->m_selPresetButton = new QPushButton( tr( "" ), this ); _ctl->m_selPresetButton->setCheckable( false ); _ctl->m_selPresetButton->setCursor( Qt::PointingHandCursor ); _ctl->m_selPresetButton->setIcon( PLUGIN_NAME::getIconPixmap( "stepper-down" ) ); _ctl->m_selPresetButton->setWhatsThis( tr( "Click here to select presets that are currently loaded in VST." ) ); _ctl->m_selPresetButton->setMenu(_ctl->menu); _ctl->m_selPresetButton->setMinimumWidth( 16 ); _ctl->m_selPresetButton->setMaximumWidth( 16 ); _ctl->m_selPresetButton->setMinimumHeight( 16 ); _ctl->m_selPresetButton->setMaximumHeight( 16 ); m_savePresetButton = new pixmapButton( this, "" ); m_savePresetButton->setCheckable( false ); m_savePresetButton->setCursor( Qt::PointingHandCursor ); m_savePresetButton->setActiveGraphic( PLUGIN_NAME::getIconPixmap( "project_save", 21, 21 ) ); m_savePresetButton->setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "project_save", 21, 21 ) ); connect( m_savePresetButton, SIGNAL( clicked() ), _ctl, SLOT( savePreset() ) ); toolTip::add( m_savePresetButton, tr( "Save preset" ) ); m_savePresetButton->setWhatsThis( tr( "Click here, if you want to save current VST-plugin preset program." ) ); m_savePresetButton->setMinimumWidth( 21 ); m_savePresetButton->setMaximumWidth( 21 ); m_savePresetButton->setMinimumHeight( 21 ); m_savePresetButton->setMaximumHeight( 21 ); int newSize = m_pluginWidget->width() + 20; newSize = (newSize < 250) ? 250 : newSize; QWidget* resize = new QWidget(this); resize->resize( newSize, 10 ); QWidget* space0 = new QWidget(this); space0->resize(8, 10); QWidget* space1 = new QWidget(this); space1->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); QFont f( "Arial", 10 ); l->addItem( new QSpacerItem( newSize - 20, 30, QSizePolicy::Fixed, QSizePolicy::Fixed ), 1, 0 ); l->addWidget( resize, 2, 0, 1, 1, Qt::AlignCenter ); l->addWidget( m_pluginWidget, 3, 0, 1, 1, Qt::AlignCenter ); l->setRowStretch( 5, 1 ); l->setColumnStretch( 1, 1 ); QToolBar * tb = new QToolBar( this ); tb->resize( newSize , 32 ); tb->addWidget(space0); tb->addWidget( m_rolLPresetButton ); tb->addWidget( m_rolRPresetButton ); tb->addWidget( _ctl->m_selPresetButton ); tb->addWidget( m_openPresetButton ); tb->addWidget( m_savePresetButton ); tb->addWidget( m_managePluginButton ); tb->addWidget( btn ); tb->addWidget(space1); tbLabel = new QLabel( tr( "Effect by: " ), this ); tbLabel->setFont( pointSize<7>( f ) ); tbLabel->setTextFormat(Qt::RichText); tbLabel->setAlignment( Qt::AlignTop | Qt::AlignLeft ); tb->addWidget( tbLabel ); } }