//Main function (execution starts here after startup file) int main(void) { int i; int e; uint16_t temperature; init_GPIO_pins(); //Short delay during which we can communicate with MCU via debugger even if later user code causes error such as sleep state with no wakeup event that prevents debugger interface working //THIS MUST COME BEFORE ALL USER CODE TO ENSURE CHIPS CAN BE REPROGRAMMED EVEN IF THEY GET STUCK IN A SLEEP STATE LATER for (i = 0; i < 1000000; i++) { LED_on(); } GPIO_Init_Mode(GPIOA,GPIO_Pin_0,GPIO_Mode_IN_FLOATING); //User button. GPIO_Init_Mode(GPIOC,GPIO_Pin_11,GPIO_Mode_IN_FLOATING); //Accelerometer interrupt. delay_init(); LED_off(); LCDINIT(); home(); clear(); display(); //Surely some of these can be commented out. noCursor(); noBlink(); standby(); UART_init(); humidity_init(); ADC_init(); I2C_EEPROM(); I2C_ACCEL_INIT(); I2C_EE_LoadConfig(); logging_timer_init(); // I2C_EE_BufferWrite(Test_Buffer, EEPROM_WriteAddress1, 100); //I2C_EE_BufferRead(buffer, 0, 100); /*while(1){ if(LEDbyte==512){LEDbyte=1;} else {LEDbyte=LEDbyte<<1;} setLEDS(); setCursor(0,1); temperature=getTemperature(); writenumber( temperature/100); write('.'); writenumber((temperature/10)%10); write(' '); write(0xDF); write('C'); setCursor(0,0); writenumber(readhumidity(24)); //Needs real temperature write(' '); write('%'); write('R'); write('H'); delay_ms(50); check_and_process_received_command(); }*/ //currentstate=UPLOADING; while(1) { switch (currentstate){ case WAITING: if (GPIO_ReadInputDataBit(GPIOA,GPIO_Pin_0)) //Polling is probably ok here, since the loop will be very very fast. { currentstate=LOGGING; clear(); write('S'); write('t'); write('a'); write('r'); write('t'); write('i'); write('n'); write('g'); delay_ms(2000); clear(); I2C_EE_StartLog(); TIM4->CNT=0; } break; case LOGGING: if (GPIO_ReadInputDataBit(GPIOA,GPIO_Pin_0)){currentstate=WAITING;I2C_EE_FinishLog();break;} //Polling is probably ok here, since the loop will be very very fast. LEDbyte|= 1<<8; setLEDS(); if (TIM_GetFlagStatus(TIM3, TIM_FLAG_Update) != RESET) { TIM_ClearFlag(TIM3, TIM_IT_Update); temperature = getTemperature(); LogBuffer[0]=(temperature>>8)&0xFF; LogBuffer[1]=temperature&0xFF; LogBuffer[2]=readhumidity(LogBuffer[0]); I2C_ACCEL_READ(); I2C_EE_Log(LogBuffer); setCursor(0,1); writenumber(temperature/100); write('.'); writenumber(temperature%100); write(' '); write(0xDF); write('C'); write(' '); setCursor(0,0); writenumber(25); //Needs real temperature write(' '); write('%'); write('R'); write('H'); write(' '); LEDbyte&= ~(1<<8); setLEDS(); } break; case UPLOADING: currentstate=WAITING; I2C_EE_Upload(); break; case ERASING: currentstate=WAITING; I2C_EE_Erase(); break; case STREAMING: if (TIM_GetFlagStatus(TIM3, TIM_FLAG_Update) != RESET) { TIM_ClearFlag(TIM3, TIM_IT_Update); temperature = getTemperature(); LogBuffer[0]=(temperature>>8)&0xFF; LogBuffer[1]=temperature&0xFF; LogBuffer[2]=readhumidity(LogBuffer[0]); I2C_ACCEL_READ(); // I2C_EE_Log(LogBuffer); for (e=0;i<ENTRYBYTES;i++) { UART_send_byte(LogBuffer[e]); } setCursor(0,1); writenumber(temperature/100); write('.'); writenumber(temperature%100); write(' '); write(0xDF); write('C'); write(' '); setCursor(0,0); writenumber(25); //Needs real temperature write(' '); write('%'); write('R'); write('H'); write(' '); LEDbyte&= ~(1<<8); setLEDS(); } break; }
FxLine::FxLine( QWidget * _parent, FxMixerView * _mv, int _channelIndex ) : QWidget( _parent ), m_mv( _mv ), m_channelIndex( _channelIndex ), m_backgroundActive( Qt::SolidPattern ), m_strokeOuterActive( 0, 0, 0 ), m_strokeOuterInactive( 0, 0, 0 ), m_strokeInnerActive( 0, 0, 0 ), m_strokeInnerInactive( 0, 0, 0 ), m_inRename( false ) { if( !s_sendBgArrow ) { s_sendBgArrow = new QPixmap( embed::getIconPixmap( "send_bg_arrow", 29, 56 ) ); } if( !s_receiveBgArrow ) { s_receiveBgArrow = new QPixmap( embed::getIconPixmap( "receive_bg_arrow", 29, 56 ) ); } setFixedSize( 33, FxLineHeight ); setAttribute( Qt::WA_OpaquePaintEvent, true ); setCursor( QCursor( embed::getIconPixmap( "hand" ), 3, 3 ) ); // mixer sends knob m_sendKnob = new Knob( knobBright_26, this, tr( "Channel send amount" ) ); m_sendKnob->move( 3, 22 ); m_sendKnob->setVisible( false ); // send button indicator m_sendBtn = new SendButtonIndicator( this, this, m_mv ); m_sendBtn->move( 2, 2 ); // channel number m_lcd = new LcdWidget( 2, this ); m_lcd->setValue( m_channelIndex ); m_lcd->move( 4, 58 ); m_lcd->setMarginWidth( 1 ); QString name = Engine::fxMixer()->effectChannel( m_channelIndex )->m_name; setToolTip( name ); m_renameLineEdit = new QLineEdit(); m_renameLineEdit->setText( name ); m_renameLineEdit->setFixedWidth( 65 ); m_renameLineEdit->setFont( pointSizeF( font(), 7.5f ) ); m_renameLineEdit->setReadOnly( true ); m_renameLineEdit->installEventFilter( this ); QGraphicsScene * scene = new QGraphicsScene(); scene->setSceneRect( 0, 0, 33, FxLineHeight ); m_view = new QGraphicsView( this ); m_view->setStyleSheet( "border-style: none; background: transparent;" ); m_view->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); m_view->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); m_view->setAttribute( Qt::WA_TransparentForMouseEvents, true ); m_view->setScene( scene ); QGraphicsProxyWidget * proxyWidget = scene->addWidget( m_renameLineEdit ); proxyWidget->setRotation( -90 ); proxyWidget->setPos( 8, 145 ); connect( m_renameLineEdit, SIGNAL( editingFinished() ), this, SLOT( renameFinished() ) ); }
void RegexGraphicsItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { setCursor(Qt::OpenHandCursor); }
ColorEditor::ColorEditor(QWidget *parent) : QFrame(parent), d(new ColorEditorImpl(this)) { setFocusPolicy(Qt::StrongFocus); setFrameShape(QFrame::StyledPanel); setCursor(QCursor(Qt::ArrowCursor)); // Build UI // Close button auto closeBtn = new QToolButton(this); closeBtn->setFixedSize(24, 24); closeBtn->setIcon(QIcon(QLatin1String(Core::Constants::ICON_BUTTON_CLOSE))); connect(closeBtn, &QToolButton::clicked, this, &ColorEditor::close); // Color format selection d->rgbBtn->setText(QLatin1String("rgb")); d->hsvBtn->setText(QLatin1String("hsv")); d->hslBtn->setText(QLatin1String("hsl")); d->qmlRgbaBtn->setText(QLatin1String("Qt.rgba")); d->qmlHslaBtn->setText(QLatin1String("Qt.hsla")); d->vecBtn->setText(QLatin1String("vec")); d->hexBtn->setText(QLatin1String("hex")); d->rgbBtn->setCheckable(true); d->hsvBtn->setCheckable(true); d->hslBtn->setCheckable(true); d->qmlRgbaBtn->setCheckable(true); d->qmlHslaBtn->setCheckable(true); d->vecBtn->setCheckable(true); d->hexBtn->setCheckable(true); // Build layouts d->formatsLayout->setSpacing(0); d->colorFrame->setMinimumSize(QSize(30, 35)); auto rightLayout = new QVBoxLayout; rightLayout->addWidget(d->colorFrame); rightLayout->addStretch(); auto leftPanelLayout = new QVBoxLayout; leftPanelLayout->addWidget(closeBtn); leftPanelLayout->addStretch(); auto *colorWidgetsLayout = new QHBoxLayout; colorWidgetsLayout->addWidget(d->colorPicker); colorWidgetsLayout->addWidget(d->hueSlider); colorWidgetsLayout->addWidget(d->saturationSlider); colorWidgetsLayout->addWidget(d->valueSlider); colorWidgetsLayout->addWidget(d->opacitySlider); colorWidgetsLayout->addLayout(rightLayout); auto *centerLayout = new QVBoxLayout; centerLayout->addLayout(colorWidgetsLayout); centerLayout->addLayout(d->formatsLayout); auto *mainLayout = new QHBoxLayout(this); mainLayout->addLayout(leftPanelLayout); mainLayout->addSpacing(0); mainLayout->addLayout(centerLayout); // Color format selection logic d->btnGroup->addButton(d->rgbBtn); d->btnGroup->addButton(d->hsvBtn); d->btnGroup->addButton(d->hslBtn); d->btnGroup->addButton(d->qmlRgbaBtn); d->btnGroup->addButton(d->qmlHslaBtn); d->btnGroup->addButton(d->vecBtn); d->btnGroup->addButton(d->hexBtn); connect(d->btnGroup, static_cast<void (QButtonGroup::*)(QAbstractButton *)>(&QButtonGroup::buttonClicked), [=] (QAbstractButton *btn) { ColorFormat format; if (btn == d->rgbBtn) { format = ColorFormat::QCssRgbUCharFormat; } else if (btn == d->hsvBtn) { format = ColorFormat::QssHsvFormat; } else if (btn == d->hslBtn) { format = ColorFormat::CssHslFormat; } else if (btn == d->qmlRgbaBtn) { format = ColorFormat::QmlRgbaFormat; } else if (btn == d->qmlHslaBtn) { format = ColorFormat::QmlHslaFormat; } else if (btn == d->vecBtn) { format = ColorFormat::GlslFormat; } else if (btn == d->hexBtn) format = ColorFormat::HexFormat; d->setCurrentFormat(format); }); // Color changes logic connect(d->colorPicker, &ColorPickerWidget::colorChanged, [=](const QColor &pureColor) { QColor newColor(pureColor); newColor.setAlpha(d->opacitySlider->value()); d->updateColorWidgets(newColor, ColorEditorImpl::UpdateFromColorPicker); d->setCurrentColor(newColor); }); connect(d->hueSlider, &HueSlider::valueChanged, [=](int hue) { QColor newColor = QColor::fromHsv(hue, d->color.hsvSaturation(), d->color.value(), d->opacitySlider->value()); d->updateColorWidgets(newColor, ColorEditorImpl::UpdateFromHueSlider); d->setCurrentColor(newColor); }); connect(d->saturationSlider, &SaturationSlider::valueChanged, [=](int sat) { QColor newColor = QColor::fromHsv(d->color.hsvHue(), sat, d->color.value(), d->opacitySlider->value()); d->updateColorWidgets(newColor, ColorEditorImpl::UpdateFromSaturationSlider); d->setCurrentColor(newColor); }); connect(d->valueSlider, &ValueSlider::valueChanged, [=](int val) { QColor newColor = QColor::fromHsv(d->color.hsvHue(), d->color.hsvSaturation(), val, d->opacitySlider->value()); d->updateColorWidgets(newColor, ColorEditorImpl::UpdateFromValueSlider); d->setCurrentColor(newColor); }); connect(d->opacitySlider, &OpacitySlider::valueChanged, [=](int opacity) { QColor newColor = QColor::fromHsv(d->hueSlider->value(), d->color.hsvSaturation(), d->color.value(), opacity); d->updateColorWidgets(newColor, ColorEditorImpl::UpdateFromOpacitySlider); d->setCurrentColor(newColor); }); setColorCategory(ColorCategory::AnyCategory); setOutputFormat(ColorFormat::QCssRgbUCharFormat); setColor(Qt::red); }
void QgsComposerItem::updateCursor( const QPointF& itemPos ) { setCursor( cursorForPosition( itemPos ) ); }
ActionLineEditButton::ActionLineEditButton( QWidget *parent ) : QAbstractButton(parent), action_(0), popup_(0) { setCursor(Qt::PointingHandCursor); }
void Text::dragTo(const QPointF& p) { setCursor(p, QTextCursor::KeepAnchor); score()->setUpdateAll(); score()->end(); }
Splitter( BrowserBar *w ) : QWidget( w, "divider" ) { setCursor( QCursor(SplitHCursor) ); styleChange( style() ); }
/** \brief Initialisation of MicroOLED Library. Setup IO pins for SPI port then send initialisation commands to the SSD1306 controller inside the OLED. */ void MicroOLED::begin() { // default 5x7 font setFontType(0); setColor(WHITE); setDrawMode(NORM); setCursor(0,0); pinMode(dcPin, OUTPUT); pinMode(rstPin, OUTPUT); // Set up the selected interface: if (interface == MODE_SPI) spiSetup(); else if (interface == MODE_I2C) i2cSetup(); else if (interface == MODE_PARALLEL) parallelSetup(); // Display reset routine pinMode(rstPin, OUTPUT); // Set RST pin as OUTPUT digitalWrite(rstPin, HIGH); // Initially set RST HIGH delay(5); // VDD (3.3V) goes high at start, lets just chill for 5 ms digitalWrite(rstPin, LOW); // Bring RST low, reset the display delay(10); // wait 10ms digitalWrite(rstPin, HIGH); // Set RST HIGH, bring out of reset // Display Init sequence for 64x48 OLED module command(DISPLAYOFF); // 0xAE command(SETDISPLAYCLOCKDIV); // 0xD5 command(0x80); // the suggested ratio 0x80 command(SETMULTIPLEX); // 0xA8 command(0x2F); command(SETDISPLAYOFFSET); // 0xD3 command(0x0); // no offset command(SETSTARTLINE | 0x0); // line #0 command(CHARGEPUMP); // enable charge pump command(0x14); command(NORMALDISPLAY); // 0xA6 command(DISPLAYALLONRESUME); // 0xA4 command(SEGREMAP | 0x1); command(COMSCANDEC); command(SETCOMPINS); // 0xDA command(0x12); command(SETCONTRAST); // 0x81 command(0x8F); command(SETPRECHARGE); // 0xd9 command(0xF1); command(SETVCOMDESELECT); // 0xDB command(0x40); command(DISPLAYON); //--turn on oled panel clear(ALL); // Erase hardware memory inside the OLED controller to avoid random data in memory. }
void ChartWidget::mouseMoveEvent(QMouseEvent* e) { const QPoint& pos = e->pos(); m_ptMouseWidget = pos; m_ptMousePixmap = m_ptMouseWidget - m_rcPixmap.topLeft(); if (m_bDragging) { const ChartPointInfo& info = m_clickInfo; ViewWaveInfo* vwi = info.vwi; WaveInfo* wave = (vwi != NULL) ? vwi->waveInfo() : NULL; if (m_bSelecting) { // While selecting, don't let the mouse move out of the pixmap if (m_ptMousePixmap.x() < 0) m_ptMousePixmap.setX(0); else if (m_ptMousePixmap.x() >= m_rcPixmap.width()) m_ptMousePixmap.setX(m_rcPixmap.width() - 1); update(); } else if (info.iChosenPeak >= 0) { int x = pos.x() - m_rcPixmap.left(); int didx = m_pixmap->xToCenterSample(info.vwi->wave(), x); moveMarkerHandle(vwi, info.iChosenPeak, info.iMarkerDidx, didx); } else if (wave != NULL) { // REFACTOR: I don't know what this statement is doing here -- ellis, 2010-10-04 if (e->modifiers() == Qt::ControlModifier && m_chartS->params().peakMode == EadMarkerMode_Edit && wave == m_pixmap->waveOfPeaks()) { setCursor(Qt::PointingHandCursor); } else { // How much has the mouse been moved in total during this drag? double nStart = m_pixmap->yToValue(vwi, m_ptClickPixmap.y()); double nEnd = m_pixmap->yToValue(vwi, m_ptMousePixmap.y()); double nVolts = nEnd - nStart; double nOffset = nVolts / vwi->voltsPerDivision(); // Set the channel offset appropriately vwi->setDivisionOffset(m_nDragOrigDivisionOffset - nOffset); m_chartS->redraw(); } } else { int nDiffXOrig = m_ptMousePixmap.x() - m_ptClickPixmap.x(); int nDiffSamplesOrig = m_pixmap->widthToSampleCount(-nDiffXOrig); int iSample = m_nClickSampleOffset + nDiffSamplesOrig; m_chartS->setSampleOffset(iSample); } } else { updateMouseCursor(e->modifiers()); } updateStatus(); }
void GenCertDialog::genPerson() { /* Check the data from the GUI. */ std::string genLoc = ui.node_input->text().toUtf8().constData(); RsPgpId PGPId; bool isHiddenLoc = false; if (ui.hidden_checkbox->isChecked()) { std::string hl = ui.hiddenaddr_input->text().toStdString(); uint16_t port = ui.hiddenport_spinBox->value(); if (!RsInit::SetHiddenLocation(hl, port)) /* parses it */ { /* Message Dialog */ QMessageBox::warning(this, tr("Invalid hidden node"), tr("Please enter a valid address of the form: 31769173498.onion:7800 or [52 characters].b32.i2p"), QMessageBox::Ok); return; } isHiddenLoc = true; } if (!genNewGPGKey) { if (genLoc.length() < 3) { /* Message Dialog */ QMessageBox::warning(this, tr("PGP key pair generation failure"), tr("Node field is required with a minimum of 3 characters"), QMessageBox::Ok); return; } int pgpidx = ui.genPGPuser->currentIndex(); if (pgpidx < 0) { /* Message Dialog */ QMessageBox::warning(this, tr("Profile generation failure"), tr("Missing PGP certificate"), QMessageBox::Ok); return; } QVariant data = ui.genPGPuser->itemData(pgpidx); PGPId = RsPgpId((data.toString()).toStdString()); } else { if (ui.password_input->text().length() < 3 || ui.name_input->text().length() < 3 || genLoc.length() < 3) { /* Message Dialog */ QMessageBox::warning(this, tr("PGP key pair generation failure"), tr("All fields are required with a minimum of 3 characters"), QMessageBox::Ok); return; } if(ui.password_input->text() != ui.password_input_2->text()) { QMessageBox::warning(this, tr("PGP key pair generation failure"), tr("Passwords do not match"), QMessageBox::Ok); return; } //generate a new gpg key std::string err_string; ui.no_gpg_key_label->setText(tr("Generating new PGP key pair, please be patient: this process needs generating large prime numbers, and can take some minutes on slow computers. \n\nFill in your PGP password when asked, to sign your new key.")); ui.no_gpg_key_label->show(); ui.new_gpg_key_checkbox->hide(); ui.name_label->hide(); ui.name_input->hide(); // ui.email_label->hide(); // ui.email_input->hide(); ui.password_label_2->hide(); ui.password_input_2->hide(); ui.password_label->hide(); ui.password_input->hide(); ui.genPGPuserlabel->hide(); ui.genPGPuser->hide(); ui.node_label->hide(); ui.node_input->hide(); ui.genButton2->hide(); ui.importIdentity_PB->hide(); ui.genprofileinfo_label->hide(); ui.hidden_checkbox->hide(); ui.adv_checkbox->hide(); ui.keylength_label->hide(); ui.keylength_comboBox->hide(); setCursor(Qt::WaitCursor) ; QCoreApplication::processEvents(); while(QAbstractEventDispatcher::instance()->processEvents(QEventLoop::AllEvents)) ; std::string email_str = "" ; RsAccounts::GeneratePGPCertificate( ui.name_input->text().toUtf8().constData(), email_str.c_str(), ui.password_input->text().toUtf8().constData(), PGPId, ui.keylength_comboBox->itemData(ui.keylength_comboBox->currentIndex()).toInt(), err_string); setCursor(Qt::ArrowCursor) ; } //generate a random ssl password std::string sslPasswd = RSRandom::random_alphaNumericString(RsInit::getSslPwdLen()) ; /* GenerateSSLCertificate - selects the PGP Account */ //RsInit::SelectGPGAccount(PGPId); RsPeerId sslId; std::cerr << "GenCertDialog::genPerson() Generating SSL cert with gpg id : " << PGPId << std::endl; std::string err; this->hide();//To show dialog asking password PGP Key. bool okGen = RsAccounts::GenerateSSLCertificate(PGPId, "", genLoc, "", isHiddenLoc, sslPasswd, sslId, err); if (okGen) { /* complete the process */ RsInit::LoadPassword(sslPasswd); if (Rshare::loadCertificate(sslId, false)) { accept(); } } else { /* Message Dialog */ QMessageBox::warning(this, tr("Profile generation failure"), tr("Failed to generate your new certificate, maybe PGP password is wrong!"), QMessageBox::Ok); reject(); } }
void MeshGraphItemVelocityHandle::mousePressEvent(QGraphicsSceneMouseEvent *event) { setCursor(Qt::ClosedHandCursor); QGraphicsItem::mousePressEvent(event); }
void MeshGraphItemVelocityHandle::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { setCursor(Qt::OpenHandCursor); QGraphicsItem::mouseReleaseEvent(event); }
void login2::sLogin() { QSqlDatabase db; QString databaseURL; databaseURL = _databaseURL; if (_demoOption->isChecked()) databaseURL = _evalDatabaseURL.arg(_username->text().trimmed()); else if(_cloudOption->isChecked()) databaseURL = _cloudDatabaseURL.arg(_company->text().trimmed()); QString protocol; QString hostName; QString dbName; QString port; parseDatabaseURL(databaseURL, protocol, hostName, dbName, port); if (_splash) { _splash->show(); _splash->raise(); _splash->showMessage(tr("Initializing the Database Connector"), SplashTextAlignment, SplashTextColor); qApp->processEvents(); } // Open the Database Driver if (_multipleConnections) db = QSqlDatabase::addDatabase("QPSQL7", dbName); else db = QSqlDatabase::addDatabase("QPSQL7"); if (!db.isValid()) { if (_splash) _splash->hide(); QMessageBox::warning( this, tr("No Database Driver"), tr("<p>A connection could not be established with " "the specified Database as the Proper Database " "Drivers have not been installed. Contact your " "Systems Administator.")); return; } if(hostName.isEmpty() || dbName.isEmpty()) { if (_splash) _splash->hide(); QMessageBox::warning(this, tr("Incomplete Connection Options"), tr("<p>One or more connection options are missing. " "Please check that you have specified the host " "name, database name, and any other required " "options.") ); return; } db.setDatabaseName(dbName); db.setHostName(hostName); db.setPort(port.toInt()); _cUsername = _username->text().trimmed(); _cPassword = _password->text().trimmed(); _cCompany = _company->text().trimmed(); if(_cloudOption->isChecked()) { if(_cCompany.isEmpty()) { QMessageBox::warning(this, tr("Incomplete Connection Options"), tr("<p>You must specify the Company name to connect to the cloud.")); return; } _cUsername = _cUsername + "_" + _cCompany; } db.setUserName(_cUsername); if(_demoOption->isChecked()) { QString passwd = QMd5(QString(_cPassword + "private" + _cUsername)); db.setPassword(passwd); } else if(_cloudOption->isChecked()) { QString passwd = QMd5(QString(_cPassword + "cloudkey" + _cUsername)); db.setPassword(passwd); } else { if(_enhancedAuth) { QString passwd = QMd5(QString(_cPassword + "xTuple" + _cUsername)); db.setPassword(passwd); } else db.setPassword(_cPassword); if(_requireSSL) db.setConnectOptions("requiressl=1"); } setCursor(QCursor(Qt::WaitCursor)); if (_splash) { _splash->showMessage(tr("Connecting to the Database"), SplashTextAlignment, SplashTextColor); qApp->processEvents(); } // Try to connect to the Database bool result = db.open(); if(!result && _enhancedAuth) { QString altpasswd = QMd5(QString(_cPassword + "OpenMFG" + _cUsername)); db.setPassword(altpasswd); result = db.open(); if(result) { altpasswd = QMd5(QString(_cPassword + "xTuple" + _cUsername)); XSqlQuery chgpass(QString("ALTER USER %1 WITH PASSWORD '%2'").arg(_cUsername).arg(altpasswd)); } } if (!result) { if(_requireSSL) db.setConnectOptions(); if (_splash) _splash->hide(); setCursor(QCursor(Qt::ArrowCursor)); QMessageBox::critical(this, tr("Cannot Connect to xTuple ERP Server"), tr("<p>Sorry, can't connect to the specified xTuple ERP server. " "<p>This may be due to a problem with your user name, password, or server connection information. " "<p>Below is more detail on the connection problem: " "<p>%1" ) .arg(db.lastError().databaseText().replace('\n', "<br>") )); if (!_captive) { _username->setText(""); _username->setFocus(); } else _password->setFocus(); _password->setText(""); return; } xtsettingsSetValue("/xTuple/_demoOption", (bool)_demoOption->isChecked()); xtsettingsSetValue("/xTuple/_cloudOption", (bool)_cloudOption->isChecked()); xtsettingsSetValue("/xTuple/cloud_company", _company->text()); if (_splash) { _splash->showMessage(tr("Logging into the Database"), SplashTextAlignment, SplashTextColor); qApp->processEvents(); } if(!_nonxTupleDB) { XSqlQuery login( "SELECT login() AS result," " CURRENT_USER AS user;" ); setCursor(QCursor(Qt::ArrowCursor)); if (login.first()) { int result = login.value("result").toInt(); if (result < 0) { if (_splash) _splash->hide(); QMessageBox::critical(this, tr("Error Logging In"), storedProcErrorLookup("login", result)); return; } _user = login.value("user").toString(); _databaseURL = databaseURL; updateRecentOptions(); if (login.exec("SELECT getEffectiveXtUser() AS user;") && login.first() && ! login.value("user").toString().isEmpty()) _user = login.value("user").toString(); // no error check - older databases don't have getEffectiveXtUser accept(); } else if (login.lastError().type() != QSqlError::NoError) { if (_splash) _splash->hide(); QMessageBox::critical(this, tr("System Error"), tr("A System Error occurred at %1::%2:\n%3") .arg(__FILE__).arg(__LINE__) .arg(login.lastError().databaseText())); } else { if (_splash) _splash->hide(); QMessageBox::critical(this, tr("System Error"), tr("<p>An unknown error occurred at %1::%2. You may" " not log in to the specified xTuple ERP Server " "at this time.") .arg(__FILE__).arg(__LINE__)); } } else { setCursor(QCursor(Qt::ArrowCursor)); _databaseURL = databaseURL; updateRecentOptions(); accept(); } }
void GRolloverButton::hoverMoveEvent( QGraphicsSceneHoverEvent *e ) { GLabelItem::hoverMoveEvent( e ); setCursor( QCursor( Qt::PointingHandCursor ) ); }
void FramelessWin2::GetMoveDirect(QPoint cursorPoint) { QRect rect = this->rect(); QPoint tl = mapToGlobal(rect.topLeft()); QPoint rb = mapToGlobal(rect.bottomRight()); int x = cursorPoint.x(); int y = cursorPoint.y(); //左上角 if( x-m_padding <= tl.x() && x >= tl.x() && y - m_padding <= tl.y() && y >= tl.y()) { m_direct = FramelessWin2::LEFTTOP; setCursor(Qt::SizeFDiagCursor); } //左下角 else if (x - m_padding <= tl.x() && x > tl.x() && y - m_padding <= rb.y() && y >= rb.y()) { m_direct = LEFTDOWN; setCursor(Qt::SizeBDiagCursor); } //左边 else if (x <= tl.x() + m_padding && x >= tl.x()) { m_direct = LEFT; setCursor(Qt::SizeHorCursor); } //右上角 else if (x <= rb.x() && x + m_padding >= rb.x() && y >= tl.y() && y - m_padding <= tl.y()) { m_direct = RIGHTTOP; setCursor(Qt::SizeBDiagCursor); } //右下角 else if (x <= rb.x() && x + m_padding >= rb.x() && y <= rb.y() && y + m_padding >= rb.y()) { m_direct = RIGHTDOWN; setCursor(Qt::SizeFDiagCursor); } //右边 else if (x <= rb.x() && x + m_padding >= rb.x()) { m_direct = RIGHT; setCursor(Qt::SizeHorCursor); } //上 else if (y > tl.y() && y < tl.y()+m_padding) { m_direct = UP; setCursor(Qt::SizeVerCursor); } else if (y <= rb.y() && y + m_padding >= rb.y()) { m_direct = DOWN; setCursor(Qt::SizeVerCursor); } else { m_direct = UNKOWN; setCursor(Qt::ArrowCursor); } }
void Editor::mouseMoveEvent(QMouseEvent *event) { hide = false; //Resizing Top Left if(resizingTL == true) { rect.setTopLeft(event->pos()); handleTL.moveCenter(event->pos()); handleTR.moveCenter(rect.topRight()); handleBL.moveCenter(rect.bottomLeft()); handleBR.moveCenter(rect.bottomRight()); handleT.moveCenter(QPoint(rect.topRight().x()-(rect.width()/2), rect.top())); handleB.moveCenter(QPoint(rect.bottomRight().x()-(rect.width()/2),rect.bottom())); handleL.moveCenter(QPoint(rect.left(), rect.bottomRight().y()-(rect.height()/2))); handleR.moveCenter(QPoint(rect.right(), rect.bottomRight().y()-(rect.height()/2))); } //Resizing Top Right if(resizingTR == true) { rect.setTopRight(event->pos()); handleTL.moveCenter(rect.topLeft()); handleTR.moveCenter(event->pos()); handleBL.moveCenter(rect.bottomLeft()); handleBR.moveCenter(rect.bottomRight()); handleT.moveCenter(QPoint(rect.topRight().x()-(rect.width()/2), rect.top())); handleB.moveCenter(QPoint(rect.bottomRight().x()-(rect.width()/2),rect.bottom())); handleL.moveCenter(QPoint(rect.left(), rect.bottomRight().y()-(rect.height()/2))); handleR.moveCenter(QPoint(rect.right(), rect.bottomRight().y()-(rect.height()/2))); } //Resizing Bottom Left if(resizingBL == true) { rect.setBottomLeft(event->pos()); handleTL.moveCenter(rect.topLeft()); handleTR.moveCenter(rect.topRight()); handleBL.moveCenter(event->pos()); handleBR.moveCenter(rect.bottomRight()); handleT.moveCenter(QPoint(rect.topRight().x()-(rect.width()/2), rect.top())); handleB.moveCenter(QPoint(rect.bottomRight().x()-(rect.width()/2),rect.bottom())); handleL.moveCenter(QPoint(rect.left(), rect.bottomRight().y()-(rect.height()/2))); handleR.moveCenter(QPoint(rect.right(), rect.bottomRight().y()-(rect.height()/2))); } //Resizing Bottom Right if(resizingBR == true) { rect.setBottomRight(event->pos()); handleTL.moveCenter(rect.topLeft()); handleTR.moveCenter(rect.topRight()); handleBL.moveCenter(rect.bottomLeft()); handleBR.moveCenter(event->pos()); handleT.moveCenter(QPoint(rect.topRight().x()-(rect.width()/2), rect.top())); handleB.moveCenter(QPoint(rect.bottomRight().x()-(rect.width()/2),rect.bottom())); handleL.moveCenter(QPoint(rect.left(), rect.bottomRight().y()-(rect.height()/2))); handleR.moveCenter(QPoint(rect.right(), rect.bottomRight().y()-(rect.height()/2))); } //Resizing Top if(resizingT == true) { rect.setTop(event->pos().y()); handleTL.moveCenter(rect.topLeft()); handleTR.moveCenter(rect.topRight()); handleBL.moveCenter(rect.bottomLeft()); handleBR.moveCenter(rect.bottomRight()); handleT.moveCenter(QPoint(rect.topRight().x()-(rect.width()/2), event->pos().y())); handleL.moveCenter(QPoint(rect.left(), rect.bottomRight().y()-(rect.height()/2))); handleR.moveCenter(QPoint(rect.right(), rect.bottomRight().y()-(rect.height()/2))); } //Resizing Bottom if(resizingB == true) { rect.setBottom(event->pos().y()); handleTL.moveCenter(rect.topLeft()); handleTR.moveCenter(rect.topRight()); handleBL.moveCenter(rect.bottomLeft()); handleBR.moveCenter(rect.bottomRight()); handleB.moveCenter(QPoint(rect.bottomRight().x()-(rect.width()/2), event->pos().y())); handleL.moveCenter(QPoint(rect.left(), rect.bottomRight().y()-(rect.height()/2))); handleR.moveCenter(QPoint(rect.right(), rect.bottomRight().y()-(rect.height()/2))); } //Resizing Left if(resizingL == true) { rect.setLeft(event->pos().x()); handleTL.moveCenter(rect.topLeft()); handleTR.moveCenter(rect.topRight()); handleBL.moveCenter(rect.bottomLeft()); handleBR.moveCenter(rect.bottomRight()); handleT.moveCenter(QPoint(rect.topRight().x()-(rect.width()/2), rect.top())); handleB.moveCenter(QPoint(rect.bottomRight().x()-(rect.width()/2),rect.bottom())); handleL.moveCenter(QPoint(event->pos().x(), rect.bottomRight().y()-(rect.height()/2))); } //Resizing Right if(resizingR == true) { rect.setRight(event->pos().x()); handleTL.moveCenter(rect.topLeft()); handleTR.moveCenter(rect.topRight()); handleBL.moveCenter(rect.bottomLeft()); handleBR.moveCenter(rect.bottomRight()); handleT.moveCenter(QPoint(rect.topRight().x()-(rect.width()/2), rect.top())); handleB.moveCenter(QPoint(rect.bottomRight().x()-(rect.width()/2),rect.bottom())); handleR.moveCenter(QPoint(event->pos().x(), rect.bottomRight().y()-(rect.height()/2))); } //Move if(move == true) { rect.translate(event->pos()-origin); handleTL.moveCenter(rect.topLeft()); handleTR.moveCenter(rect.topRight()); handleBL.moveCenter(rect.bottomLeft()); handleBR.moveCenter(rect.bottomRight()); handleT.moveCenter(QPoint(rect.topRight().x()-(rect.width()/2), rect.top())); handleB.moveCenter(QPoint(rect.bottomRight().x()-(rect.width()/2),rect.bottom())); handleL.moveCenter(QPoint(rect.left(), rect.bottomRight().y()-(rect.height()/2))); handleR.moveCenter(QPoint(rect.right(), rect.bottomRight().y()-(rect.height()/2))); origin=event->pos(); } //Draw cursor if(handleBR.contains(event->pos()) || handleTL.contains(event->pos())) //Bottom Rigth or Top Left { cursor.setShape(Qt::SizeFDiagCursor); }else if(handleTR.contains(event->pos()) || handleBL.contains(event->pos())) //Top Rigth or Bottom Left { cursor.setShape(Qt::SizeBDiagCursor); }else if(handleT.contains(event->pos()) || handleB.contains(event->pos())) //Top or Bottom { cursor.setShape(Qt::SizeVerCursor); }else if(handleL.contains(event->pos()) || handleR.contains(event->pos())) //Rigth or Left { cursor.setShape(Qt::SizeHorCursor); }else if(rect.contains(event->pos()) && !rect.contains(event->pos(),true)) //Move { cursor.setShape(Qt::SizeAllCursor); }else{ cursor.setShape(Qt::ArrowCursor); //Default } setCursor(cursor); text->setGeometry(rect.x()+1,rect.y()+1,rect.width()-1,rect.height()-1); //Update textEdit following border //Update position of options buttons textB->move(rect.right()+xOffset,rect.top()); fontComboBox->move(rect.right()+2*xOffset,rect.top()); textColorB->move(rect.right()+2*xOffset+183,rect.top()); textBDimension->move(rect.right()+xOffset,textB->y()+yOffset); textLessB->move(rect.right()+2*xOffset,textB->y()+yOffset); textDefaultB->move(rect.right()+3*xOffset,textB->y()+yOffset); textMoreB->move(rect.right()+4*xOffset,textB->y()+yOffset); backgroundB->move(rect.right()+xOffset,textBDimension->y()+yOffset); backgroundPreviousB->move(rect.right()+2*xOffset,textBDimension->y()+yOffset); backgroundNextB->move(rect.right()+3*xOffset,textBDimension->y()+yOffset); backgroundColorB->move(rect.right()+4*xOffset,textBDimension->y()+yOffset); musicB->move(rect.right()+xOffset,backgroundB->y()+yOffset); musicPreviousB->move(rect.right()+2*xOffset,backgroundB->y()+yOffset); musicNextB->move(rect.right()+3*xOffset,backgroundB->y()+yOffset); musicMuteB->move(rect.right()+4*xOffset,backgroundB->y()+yOffset); keyboardB->move(rect.right()+xOffset,musicB->y()+yOffset); keyboardPreviousB->move(rect.right()+2*xOffset,musicB->y()+yOffset); keyboardNextB->move(rect.right()+3*xOffset,musicB->y()+yOffset); keyboardMuteB->move(rect.right()+4*xOffset,musicB->y()+yOffset); fileB->move(rect.right()+xOffset,keyboardB->y()+yOffset); loadB->move(rect.right()+2*xOffset,keyboardB->y()+yOffset); saveB->move(rect.right()+3*xOffset,keyboardB->y()+yOffset); saveAsB->move(rect.right()+4*xOffset,keyboardB->y()+yOffset); //show advanced buttons if(textB->underMouse()) { fontComboBox->show(); textColorB->show(); textLessB->hide(); textDefaultB->hide(); textMoreB->hide(); backgroundPreviousB->hide(); backgroundNextB->hide(); backgroundColorB->hide(); musicPreviousB->hide(); musicNextB->hide(); musicMuteB->hide(); keyboardPreviousB->hide(); keyboardNextB->hide(); keyboardMuteB->hide(); loadB->hide(); saveB->hide(); saveAsB->hide(); } if(textBDimension->underMouse()) { fontComboBox->hide(); textColorB->hide(); textLessB->show(); textDefaultB->show(); textMoreB->show(); backgroundPreviousB->hide(); backgroundNextB->hide(); backgroundColorB->hide(); musicPreviousB->hide(); musicNextB->hide(); musicMuteB->hide(); keyboardPreviousB->hide(); keyboardNextB->hide(); keyboardMuteB->hide(); loadB->hide(); saveB->hide(); saveAsB->hide(); } if(backgroundB->underMouse()) { fontComboBox->hide(); textColorB->hide(); textLessB->hide(); textDefaultB->hide(); textMoreB->hide(); backgroundPreviousB->show(); backgroundNextB->show(); backgroundColorB->show(); musicPreviousB->hide(); musicNextB->hide(); musicMuteB->hide(); keyboardPreviousB->hide(); keyboardNextB->hide(); keyboardMuteB->hide(); loadB->hide(); saveB->hide(); saveAsB->hide(); } if(musicB->underMouse()) { fontComboBox->hide(); textColorB->hide(); textLessB->hide(); textDefaultB->hide(); textMoreB->hide(); backgroundPreviousB->hide(); backgroundNextB->hide(); backgroundColorB->hide(); musicPreviousB->show(); musicNextB->show(); musicMuteB->show(); keyboardPreviousB->hide(); keyboardNextB->hide(); keyboardMuteB->hide(); loadB->hide(); saveB->hide(); saveAsB->hide(); } if(keyboardB->underMouse()) { fontComboBox->hide(); textColorB->hide(); textLessB->hide(); textDefaultB->hide(); textMoreB->hide(); backgroundPreviousB->hide(); backgroundNextB->hide(); backgroundColorB->hide(); musicPreviousB->hide(); musicNextB->hide(); musicMuteB->hide(); keyboardPreviousB->show(); keyboardNextB->show(); keyboardMuteB->show(); loadB->hide(); saveB->hide(); saveAsB->hide(); } if(fileB->underMouse()) { fontComboBox->hide(); textColorB->hide(); textLessB->hide(); textDefaultB->hide(); textMoreB->hide(); backgroundPreviousB->hide(); backgroundNextB->hide(); backgroundColorB->hide(); musicPreviousB->hide(); musicNextB->hide(); musicMuteB->hide(); keyboardPreviousB->hide(); keyboardNextB->hide(); keyboardMuteB->hide(); loadB->show(); saveB->show(); saveAsB->show(); } //Opacity slider slider->move(rect.center().x()-60, rect.bottom()+10); //redraw interface update(); }
void UniversalAdapter::home() { setCursor(0, 0); }
////////////////////////////////////////////////////////////////////// // Called when mouse moves and does different things depending //on the state of the mouse buttons for dragging the demod bar or // filter edges. ////////////////////////////////////////////////////////////////////// void CPlotter::mouseMoveEvent(QMouseEvent* event) { QPoint pt = event->pos(); /* mouse enter / mouse leave events */ if (m_OverlayPixmap.rect().contains(pt)) { //is in Overlay bitmap region if (event->buttons() == Qt::NoButton) { bool onTag=false; if(pt.y()<15*3) //FIXME { for(int i=0; i<m_BookmarkTags.size() && !onTag; i++) { if(m_BookmarkTags[i].first.contains(event->pos())) onTag=true; } } //if no mouse button monitor grab regions and change cursor icon if(onTag) { setCursor(QCursor(Qt::PointingHandCursor)); m_CursorCaptured=BOOKMARK; } else if (isPointCloseTo(pt.x(), m_DemodFreqX, m_CursorCaptureDelta)) { //in move demod box center frequency region if (CENTER != m_CursorCaptured) setCursor(QCursor(Qt::SizeHorCursor)); m_CursorCaptured = CENTER; if (m_TooltipsEnabled) QToolTip::showText(event->globalPos(), QString("Demod: %1 kHz") .arg(m_DemodCenterFreq/1.e3f, 0, 'f', 3), this, rect()); } else if (isPointCloseTo(pt.x(), m_DemodHiCutFreqX, m_CursorCaptureDelta)) { //in move demod hicut region if (RIGHT != m_CursorCaptured) setCursor(QCursor(Qt::SizeFDiagCursor)); m_CursorCaptured = RIGHT; if (m_TooltipsEnabled) QToolTip::showText(event->globalPos(), QString("High cut: %1 Hz") .arg(m_DemodHiCutFreq), this, rect()); } else if (isPointCloseTo(pt.x(), m_DemodLowCutFreqX, m_CursorCaptureDelta)) { //in move demod lowcut region if (LEFT != m_CursorCaptured) setCursor(QCursor(Qt::SizeBDiagCursor)); m_CursorCaptured = LEFT; if (m_TooltipsEnabled) QToolTip::showText(event->globalPos(), QString("Low cut: %1 Hz") .arg(m_DemodLowCutFreq), this, rect()); } else if (isPointCloseTo(pt.x(), m_YAxisWidth/2, m_YAxisWidth/2)) { if (YAXIS != m_CursorCaptured) setCursor(QCursor(Qt::OpenHandCursor)); m_CursorCaptured = YAXIS; if (m_TooltipsEnabled) QToolTip::hideText(); } else if (isPointCloseTo(pt.y(), m_XAxisYCenter, m_CursorCaptureDelta+5)) { if (XAXIS != m_CursorCaptured) setCursor(QCursor(Qt::OpenHandCursor)); m_CursorCaptured = XAXIS; if (m_TooltipsEnabled) QToolTip::hideText(); } else { //if not near any grab boundaries if (NONE != m_CursorCaptured) { setCursor(QCursor(Qt::ArrowCursor)); m_CursorCaptured = NONE; } if (m_TooltipsEnabled) QToolTip::showText(event->globalPos(), QString("F: %1 kHz") .arg(freqFromX(pt.x())/1.e3f, 0, 'f', 3), this, rect()); } m_GrabPosition = 0; } } else { //not in Overlay region if (event->buttons() == Qt::NoButton) { if (NONE != m_CursorCaptured) setCursor(QCursor(Qt::ArrowCursor)); m_CursorCaptured = NONE; m_GrabPosition = 0; } if (m_TooltipsEnabled) QToolTip::showText(event->globalPos(), QString("F: %1 kHz") .arg(freqFromX(pt.x())/1.e3f, 0, 'f', 3), this, rect()); } // process mouse moves while in cursor capture modes if (YAXIS == m_CursorCaptured) { if (event->buttons() & Qt::LeftButton) { setCursor(QCursor(Qt::ClosedHandCursor)); // move Y scale up/down float delta_px = m_Yzero - pt.y(); float delta_db = delta_px * fabs(m_MindB-m_MaxdB)/(float)m_OverlayPixmap.height(); m_MindB -= delta_db; m_MaxdB -= delta_db; if (m_Running) m_DrawOverlay = true; else drawOverlay(); m_PeakHoldValid = false; m_Yzero = pt.y(); } } else if (XAXIS == m_CursorCaptured) { if (event->buttons() & (Qt::LeftButton | Qt::MidButton)) { setCursor(QCursor(Qt::ClosedHandCursor)); // pan viewable range or move center frequency int delta_px = m_Xzero - pt.x(); qint64 delta_hz = delta_px * m_Span / m_OverlayPixmap.width(); if (event->buttons() & Qt::MidButton) { m_CenterFreq += delta_hz; m_DemodCenterFreq += delta_hz; emit newCenterFreq(m_CenterFreq); } else { setFftCenterFreq(m_FftCenter + delta_hz); } if (m_Running) m_DrawOverlay = true; else drawOverlay(); m_PeakHoldValid = false; m_Xzero = pt.x(); } } else if (LEFT == m_CursorCaptured) { // moving in demod lowcut region if (event->buttons() & (Qt::LeftButton|Qt::RightButton)) { //moving in demod lowcut region with left button held if (m_GrabPosition != 0) { m_DemodLowCutFreq = freqFromX(pt.x()-m_GrabPosition ) - m_DemodCenterFreq; m_DemodLowCutFreq = roundFreq(m_DemodLowCutFreq, m_FilterClickResolution); if (m_symetric && (event->buttons() & Qt::LeftButton)) // symetric adjustment { m_DemodHiCutFreq = -m_DemodLowCutFreq; } clampDemodParameters(); emit newFilterFreq(m_DemodLowCutFreq, m_DemodHiCutFreq); if (m_Running) m_DrawOverlay = true; // schedule update of overlay during draw() else drawOverlay(); // not running so update overlay now } else { //save initial grab postion from m_DemodFreqX m_GrabPosition = pt.x()-m_DemodLowCutFreqX; } } else if (event->buttons() & ~Qt::NoButton) { setCursor(QCursor(Qt::ArrowCursor)); m_CursorCaptured = NONE; } } else if (RIGHT == m_CursorCaptured) { // moving in demod highcut region if (event->buttons() & (Qt::LeftButton|Qt::RightButton)) { // moving in demod highcut region with right button held if (m_GrabPosition != 0) { m_DemodHiCutFreq = freqFromX( pt.x()-m_GrabPosition ) - m_DemodCenterFreq; m_DemodHiCutFreq = roundFreq(m_DemodHiCutFreq, m_FilterClickResolution); if (m_symetric && (event->buttons() & Qt::LeftButton)) // symetric adjustment { m_DemodLowCutFreq = -m_DemodHiCutFreq; } clampDemodParameters(); emit newFilterFreq(m_DemodLowCutFreq, m_DemodHiCutFreq); if (m_Running) m_DrawOverlay = true; // schedule update of overlay during draw() else drawOverlay(); // not running so update oiverlay now } else { //save initial grab postion from m_DemodFreqX m_GrabPosition = pt.x()-m_DemodHiCutFreqX; } } else if (event->buttons() & ~Qt::NoButton) { setCursor(QCursor(Qt::ArrowCursor)); m_CursorCaptured = NONE; } } else if (CENTER == m_CursorCaptured) { // moving inbetween demod lowcut and highcut region if (event->buttons() & Qt::LeftButton) { // moving inbetween demod lowcut and highcut region with left button held if (m_GrabPosition != 0) { m_DemodCenterFreq = roundFreq(freqFromX(pt.x()-m_GrabPosition), m_ClickResolution ); emit newDemodFreq(m_DemodCenterFreq, m_DemodCenterFreq-m_CenterFreq); if (m_Running) m_DrawOverlay = true; // schedule update of overlay during draw() else drawOverlay(); // not running so update oiverlay now m_PeakHoldValid = false; } else { //save initial grab postion from m_DemodFreqX m_GrabPosition = pt.x()-m_DemodFreqX; } } else if (event->buttons() & ~Qt::NoButton) { setCursor(QCursor(Qt::ArrowCursor)); m_CursorCaptured = NONE; } } else //if cursor not captured { m_GrabPosition = 0; } if (!this->rect().contains(pt)) { if(NONE != m_CursorCaptured) setCursor(QCursor(Qt::ArrowCursor)); m_CursorCaptured = NONE; } }
void GcWindow::mouseMoveEvent(QMouseEvent *e) { if (!resizable()) return; if (dragState == None) { // set the cursor shape setCursorShape(spotHotSpot(e)); return; } // work out the relative move x and y int relx = mapFromGlobal(QCursor::pos()).x() - mX; int rely = mapFromGlobal(QCursor::pos()).y() - mY; switch (dragState) { default: case Move : //move(oX + relx, oY + rely); #if QT_VERSION < 0x040700 setCursor(Qt::ClosedHandCursor); #else setCursor(Qt::DragMoveCursor); #endif emit moving(this); break; case TLCorner : { int newWidth = oWidth - relx; int newHeight = oHeight - rely; // need to move and resize if (newWidth > 30 && newHeight > 30) { move(oX + relx, oY + rely); setNewSize(newWidth, newHeight); emit resizing(this); } } break; case TRCorner : { int newWidth = oWidth + relx; int newHeight = oHeight - rely; // need to move and resize if changes on y plane if (newWidth > 30 && newHeight > 30) { move(oX, oY + rely); setNewSize(newWidth, newHeight); emit resizing(this); } } break; case BLCorner : { int newWidth = oWidth - relx; int newHeight = oHeight + rely; // need to move and resize if (newWidth > 30 && newHeight > 30) { move(oX + relx, oY); setNewSize(newWidth, newHeight); emit resizing(this); } } break; case BRCorner : { int newWidth = oWidth + relx; int newHeight = oHeight + rely; // need to move and resize if (newWidth > 30 && newHeight > 30) { setNewSize(newWidth, newHeight); emit resizing(this); } } break; case Top : { int newHeight = oHeight - rely; // need to move and resize if (newHeight > 30) { move (oX, oY + rely); setNewSize(oWidth, newHeight); emit resizing(this); } } break; case Bottom : { int newHeight = oHeight + rely; // need to move and resize if (newHeight > 30) { setNewSize(oWidth, newHeight); emit resizing(this); } } break; case Left : { int newWidth = oWidth - relx; // need to move and resize if (newWidth > 30) { move (oX + relx, oY); setNewSize(newWidth, oHeight); emit resizing(this); } } break; case Right : { int newWidth = oWidth + relx; // need to move and resize if (newWidth > 30) { setNewSize(newWidth, oHeight); emit resizing(this); } } break; } oX = pos().x(); oY = pos().y(); //repaint(); //QApplication::processEvents(); // flicker... }
void ChartWidget::mousePressEvent(QMouseEvent* e) { //qDebug() << "mousePressEvent"; QRect rcWaveforms = m_rcPixmap; ChartPointInfo info; QPoint ptPixmap = e->pos() - m_rcPixmap.topLeft(); m_pixmap->fillChartPointInfo(ptPixmap, &info); m_clickInfo = info; ViewWaveInfo* vwi = info.vwi; m_ptMouseWidget = e->pos(); m_ptMousePixmap = ptPixmap; m_ptClickWidget = m_ptMouseWidget; m_ptClickPixmap = m_ptMousePixmap; m_nClickSampleOffset = m_chartS->sampleOffset(); const WaveInfo* wave = NULL; if (vwi != NULL) wave = vwi->wave(); if (e->button() == Qt::LeftButton) { // If the user Ctrl+clicks on the selected FID wave while in peak editing mode: if (e->modifiers() == Qt::ControlModifier) { // If the user Ctrl+clicks on the selected FID wave while in peak editing mode: if (wave != NULL && m_chartS->params().peakMode == EadMarkerMode_Edit) { if (info.iChosenPeak < 0) addMarker(vwi, m_ptClickPixmap.x()); else if (wave->peaksChosen[info.iChosenPeak].type == MarkerType_EadPeakXY) { addEadPeakXYEndPoint(vwi, info.iChosenPeak); } } } else { bool bIgnore = false; // Force no dragging of markers unless in edit mode: if (m_chartS->params().peakMode != EadMarkerMode_Edit) { if (m_clickInfo.iChosenPeak >= 0) bIgnore = true; } if (bIgnore) { ; } // Clicked on a chosen peak: else if (info.iChosenPeak >= 0) { m_bDragging = true; setCursor(Qt::SizeHorCursor); } // Clicked on a detected peak: else if (info.didxPossiblePeak >= 0) { vwi->choosePeakAtDidx(info.didxPossiblePeak); } // Clicked on a wave: else if (wave != NULL) { m_bDragging = true; // REFACTOR: remove m_waveDrag and use m_clickInfo instead //m_waveDrag = vwi->waveInfo(); m_nDragOrigDivisionOffset = vwi->divisionOffset(); setCursor(Qt::SizeVerCursor); } else if (rcWaveforms.contains(e->pos())) { m_bDragging = true; m_bSelecting = true; setCursor(Qt::IBeamCursor); updateStatus(); update(); } else { m_bDragging = false; } } } else if (e->button() == Qt::MidButton) { m_clickInfo.iChosenPeak = -1; m_clickInfo.iMarkerDidx = -1; m_clickInfo.vwi = NULL; m_bDragging = true; setCursor(Qt::SizeHorCursor); } updateStatus(); }
void B9Projector::mouseMoveEvent ( QMouseEvent * pEvent ) { setCursor(Qt::CrossCursor); QTimer::singleShot(500, this, SLOT(hideCursor())); QWidget::mouseMoveEvent(pEvent); }
void QgsGeometryCheckerSetupTab::runChecks() { // Get selected layer const QList<QgsVectorLayer *> layers = getSelectedLayers(); if ( layers.isEmpty() ) return; if ( ui.radioButtonOutputNew->isChecked() ) { for ( QgsVectorLayer *layer : layers ) { if ( layer->dataProvider()->dataSourceUri().startsWith( ui.lineEditOutputDirectory->text() ) ) { QMessageBox::critical( this, tr( "Check Geometries" ), tr( "The chosen output directory contains one or more input layers." ) ); return; } } } QgsVectorLayer *lineLayerCheckLayer = ui.comboLineLayerIntersection->isEnabled() ? dynamic_cast<QgsVectorLayer *>( QgsProject::instance()->mapLayer( ui.comboLineLayerIntersection->currentData().toString() ) ) : nullptr; QgsVectorLayer *followBoundaryCheckLayer = ui.comboBoxFollowBoundaries->isEnabled() ? dynamic_cast<QgsVectorLayer *>( QgsProject::instance()->mapLayer( ui.comboBoxFollowBoundaries->currentData().toString() ) ) : nullptr; if ( layers.contains( lineLayerCheckLayer ) || layers.contains( followBoundaryCheckLayer ) ) { QMessageBox::critical( this, tr( "Check Geometries" ), tr( "The selected input layers cannot contain a layer also selected for a topology check." ) ); return; } for ( QgsVectorLayer *layer : layers ) { if ( layer->isEditable() ) { QMessageBox::critical( this, tr( "Check Geometries" ), tr( "Input layer '%1' is not allowed to be in editing mode." ).arg( layer->name() ) ); return; } } bool selectedOnly = ui.checkBoxInputSelectedOnly->isChecked(); // Set window busy setCursor( Qt::WaitCursor ); mRunButton->setEnabled( false ); ui.labelStatus->setText( tr( "<b>Preparing output...</b>" ) ); ui.labelStatus->show(); QApplication::processEvents( QEventLoop::ExcludeUserInputEvents ); QList<QgsVectorLayer *> processLayers; if ( ui.radioButtonOutputNew->isChecked() ) { // Get output directory and file extension QDir outputDir = QDir( ui.lineEditOutputDirectory->text() ); QString outputDriverName = ui.comboBoxOutputFormat->currentData().toString(); QgsVectorFileWriter::MetaData metadata; if ( !QgsVectorFileWriter::driverMetadata( outputDriverName, metadata ) ) { QMessageBox::critical( this, tr( "Check Geometries" ), tr( "The specified output format cannot be recognized." ) ); mRunButton->setEnabled( true ); ui.labelStatus->hide(); unsetCursor(); return; } QString outputExtension = metadata.ext; // List over input layers, check which existing project layers need to be removed and create output layers QString filenamePrefix = ui.lineEditFilenamePrefix->text(); QSettings().setValue( "/geometry_checker/previous_values/filename_prefix", filenamePrefix ); QStringList toRemove; QStringList createErrors; for ( QgsVectorLayer *layer : layers ) { QString outputPath = outputDir.absoluteFilePath( filenamePrefix + layer->name() + "." + outputExtension ); // Remove existing layer with same uri from project for ( QgsVectorLayer *projectLayer : QgsProject::instance()->layers<QgsVectorLayer *>() ) { if ( projectLayer->dataProvider()->dataSourceUri().startsWith( outputPath ) ) { toRemove.append( projectLayer->id() ); } } // Create output layer QString errMsg; QgsVectorFileWriter::WriterError err = QgsVectorFileWriter::writeAsVectorFormat( layer, outputPath, layer->dataProvider()->encoding(), layer->crs(), outputDriverName, selectedOnly, &errMsg ); if ( err != QgsVectorFileWriter::NoError ) { createErrors.append( errMsg ); continue; } QgsVectorLayer *newlayer = new QgsVectorLayer( outputPath, QFileInfo( outputPath ).completeBaseName(), QStringLiteral( "ogr" ) ); if ( selectedOnly ) { QgsFeature feature; // Get features to select (only selected features were written up to this point) QgsFeatureIds selectedFeatures = newlayer->allFeatureIds(); // Write non-selected feature ids QgsFeatureList features; QgsFeatureIterator it = layer->getFeatures(); while ( it.nextFeature( feature ) ) { if ( !layer->selectedFeatureIds().contains( feature.id() ) ) { features.append( feature ); } } newlayer->dataProvider()->addFeatures( features ); // Set selected features newlayer->selectByIds( selectedFeatures ); } processLayers.append( newlayer ); } // Remove layers from project if ( !toRemove.isEmpty() ) { QgsProject::instance()->removeMapLayers( toRemove ); } // Error if an output layer could not be created if ( !createErrors.isEmpty() ) { QMessageBox::critical( this, tr( "Check Geometries" ), tr( "Failed to create one or more output layers:\n%1" ).arg( createErrors.join( "\n" ) ) ); mRunButton->setEnabled( true ); ui.labelStatus->hide(); unsetCursor(); return; } } else { processLayers = layers; } // Check if output layers are editable QList<QgsVectorLayer *> nonEditableLayers; for ( QgsVectorLayer *layer : qgis::as_const( processLayers ) ) { if ( ( layer->dataProvider()->capabilities() & QgsVectorDataProvider::ChangeGeometries ) == 0 ) { nonEditableLayers.append( layer ); } } if ( !nonEditableLayers.isEmpty() ) { QStringList nonEditableLayerNames; for ( QgsVectorLayer *layer : nonEditableLayers ) { nonEditableLayerNames.append( layer->name() ); } if ( QMessageBox::Yes != QMessageBox::question( this, tr( "Check Geometries" ), tr( "The following output layers are in a format that does not support editing features:\n%1\n\nThe geometry check can be performed, but it will not be possible to fix any errors. Do you want to continue?" ).arg( nonEditableLayerNames.join( "\n" ) ), QMessageBox::Yes, QMessageBox::No ) ) { if ( ui.radioButtonOutputNew->isChecked() ) { for ( QgsVectorLayer *layer : qgis::as_const( processLayers ) ) { QString layerPath = layer->dataProvider()->dataSourceUri(); delete layer; if ( ui.comboBoxOutputFormat->currentText() == QLatin1String( "ESRI Shapefile" ) ) { QgsVectorFileWriter::deleteShapeFile( layerPath ); } else { QFile( layerPath ).remove(); } } mRunButton->setEnabled( true ); ui.labelStatus->hide(); unsetCursor(); } return; } } // Setup checker ui.labelStatus->setText( tr( "<b>Building spatial index...</b>" ) ); QApplication::processEvents( QEventLoop::ExcludeUserInputEvents ); QMap<QString, QgsFeaturePool *> featurePools; for ( QgsVectorLayer *layer : qgis::as_const( processLayers ) ) { featurePools.insert( layer->id(), new QgsVectorDataProviderFeaturePool( layer, selectedOnly ) ); } // LineLayerIntersection check is enabled, make sure there is also a feature pool for that layer if ( ui.checkLineLayerIntersection->isChecked() && !featurePools.keys().contains( ui.comboLineLayerIntersection->currentData().toString() ) ) { QgsVectorLayer *layer = dynamic_cast<QgsVectorLayer *>( QgsProject::instance()->mapLayer( ui.comboLineLayerIntersection->currentData().toString() ) ); Q_ASSERT( layer ); featurePools.insert( layer->id(), new QgsVectorDataProviderFeaturePool( layer, selectedOnly ) ); } QgsGeometryCheckerContext *context = new QgsGeometryCheckerContext( ui.spinBoxTolerance->value(), QgsProject::instance()->crs(), featurePools, QgsProject::instance()->transformContext() ); QList<QgsGeometryCheck *> checks; for ( const QgsGeometryCheckFactory *factory : QgsGeometryCheckFactoryRegistry::getCheckFactories() ) { QgsGeometryCheck *check = factory->createInstance( context, ui ); if ( check ) { checks.append( check ); } } QgsGeometryChecker *checker = new QgsGeometryChecker( checks, context ); emit checkerStarted( checker ); if ( ui.radioButtonOutputNew->isChecked() ) { QList<QgsMapLayer *> addLayers; for ( QgsVectorLayer *layer : qgis::as_const( processLayers ) ) { addLayers.append( layer ); } QgsProject::instance()->addMapLayers( addLayers ); } // Run ui.buttonBox->addButton( mAbortButton, QDialogButtonBox::ActionRole ); mRunButton->hide(); ui.progressBar->setRange( 0, 0 ); ui.labelStatus->hide(); ui.progressBar->show(); ui.widgetInputs->setEnabled( false ); QEventLoop evLoop; QFutureWatcher<void> futureWatcher; connect( checker, &QgsGeometryChecker::progressValue, ui.progressBar, &QProgressBar::setValue ); connect( &futureWatcher, &QFutureWatcherBase::finished, &evLoop, &QEventLoop::quit ); connect( mAbortButton, &QAbstractButton::clicked, &futureWatcher, &QFutureWatcherBase::cancel ); connect( mAbortButton, &QAbstractButton::clicked, this, &QgsGeometryCheckerSetupTab::showCancelFeedback ); mIsRunningInBackground = true; int maxSteps = 0; futureWatcher.setFuture( checker->execute( &maxSteps ) ); ui.progressBar->setRange( 0, maxSteps ); evLoop.exec(); mIsRunningInBackground = false; // Restore window unsetCursor(); mAbortButton->setEnabled( true ); ui.buttonBox->removeButton( mAbortButton ); mRunButton->setEnabled( true ); mRunButton->show(); ui.progressBar->hide(); ui.labelStatus->hide(); ui.widgetInputs->setEnabled( true ); // Show result emit checkerFinished( !futureWatcher.isCanceled() ); }
void NBaseMiniAppWidget::leaveEvent(QEvent *event) { setCursor(Qt::ArrowCursor); NBaseMoveableWidget::leaveEvent(event); }
void TextBox::setEditable(bool editable) { mEditable = editable; setCursor(editable ? Cursor::IBeam : Cursor::Arrow); }
void RegexGraphicsItem::mousePressEvent(QGraphicsSceneMouseEvent *event) { setCursor(Qt::ClosedHandCursor); }
void ArrangeItem::mousePressEvent(QGraphicsSceneMouseEvent * event) { QGraphicsItem::mousePressEvent(event); setCursor(getCursorByPos(event->pos())); m_timer->stop(); }
/*! \reimp */ bool QToolBar::event(QEvent *event) { Q_D(QToolBar); switch (event->type()) { case QEvent::Timer: if (d->waitForPopupTimer.timerId() == static_cast<QTimerEvent*>(event)->timerId()) { QWidget *w = QApplication::activePopupWidget(); if (!waitForPopup(this, w)) { d->waitForPopupTimer.stop(); if (!this->underMouse()) d->layout->setExpanded(false); } } break; case QEvent::Hide: if (!isHidden()) break; // fallthrough intended case QEvent::Show: d->toggleViewAction->setChecked(event->type() == QEvent::Show); emit visibilityChanged(event->type() == QEvent::Show); #if defined(Q_WS_MAC) if (toolbarInUnifiedToolBar(this)) { // I can static_cast because I did the qobject_cast in the if above, therefore // we must have a QMainWindowLayout here. QMainWindowLayout *mwLayout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(parentWidget())); mwLayout->fixSizeInUnifiedToolbar(this); mwLayout->syncUnifiedToolbarVisibility(); } #endif // Q_WS_MAC break; case QEvent::ParentChange: d->layout->checkUsePopupMenu(); #if defined(Q_WS_MAC) if (parentWidget() && parentWidget()->isWindow()) qt_mac_updateToolBarButtonHint(parentWidget()); #endif break; case QEvent::MouseButtonPress: { if (d->mousePressEvent(static_cast<QMouseEvent*>(event))) return true; break; } case QEvent::MouseButtonRelease: if (d->mouseReleaseEvent(static_cast<QMouseEvent*>(event))) return true; break; case QEvent::HoverEnter: case QEvent::HoverLeave: // there's nothing special to do here and we don't want to update the whole widget return true; case QEvent::HoverMove: { #ifndef QT_NO_CURSOR QHoverEvent *e = static_cast<QHoverEvent*>(event); QStyleOptionToolBar opt; initStyleOption(&opt); if (style()->subElementRect(QStyle::SE_ToolBarHandle, &opt, this).contains(e->pos())) setCursor(Qt::SizeAllCursor); else unsetCursor(); #endif break; } case QEvent::MouseMove: if (d->mouseMoveEvent(static_cast<QMouseEvent*>(event))) return true; break; #ifdef Q_OS_WINCE case QEvent::ContextMenu: { QContextMenuEvent* contextMenuEvent = static_cast<QContextMenuEvent*>(event); QWidget* child = childAt(contextMenuEvent->pos()); QAbstractButton* button = qobject_cast<QAbstractButton*>(child); if (button) button->setDown(false); } break; #endif case QEvent::Leave: if (d->state != 0 && d->state->dragging) { #ifdef Q_OS_WIN // This is a workaround for loosing the mouse on Vista. QPoint pos = QCursor::pos(); QMouseEvent fake(QEvent::MouseMove, mapFromGlobal(pos), pos, Qt::NoButton, QApplication::mouseButtons(), QApplication::keyboardModifiers()); d->mouseMoveEvent(&fake); #endif } else { if (!d->layout->expanded) break; QWidget *w = QApplication::activePopupWidget(); if (waitForPopup(this, w)) { d->waitForPopupTimer.start(POPUP_TIMER_INTERVAL, this); break; } d->waitForPopupTimer.stop(); d->layout->setExpanded(false); break; } default: break; } return QWidget::event(event); }
void NBaseMiniAppWidget::enterEvent(QEvent *event) { setCursor(Qt::PointingHandCursor); NBaseMoveableWidget::enterEvent(event); }
UBRubberBand::enm_resizingMode UBRubberBand::determineResizingMode(QPoint pos) { if (mMouseIsPressed) return mResizingMode; QRect resizerTop (mResizingBorderHeight , 0 , rect().width()-2*mResizingBorderHeight, mResizingBorderHeight ); QRect resizerBottom (mResizingBorderHeight , rect().height() - mResizingBorderHeight, rect().width()-2*mResizingBorderHeight, mResizingBorderHeight ); QRect resizerLeft (0 , mResizingBorderHeight , mResizingBorderHeight , rect().height() - 2*mResizingBorderHeight); QRect resizerRight (rect().width()-mResizingBorderHeight, mResizingBorderHeight , mResizingBorderHeight , rect().height() - 2*mResizingBorderHeight); QRect resizerTopLeft (0 , 0 , mResizingBorderHeight, mResizingBorderHeight); QRect resizerTopRight (rect().width()-mResizingBorderHeight, 0 , mResizingBorderHeight, mResizingBorderHeight); QRect resizerBottomLeft (0 , rect().height() - mResizingBorderHeight, mResizingBorderHeight, mResizingBorderHeight); QRect resizerBottomRight(rect().width()-mResizingBorderHeight, rect().height() - mResizingBorderHeight, mResizingBorderHeight, mResizingBorderHeight); enm_resizingMode resizingMode; QTransform cursorTransrofm; if (resizerTop.contains(pos)) { resizingMode = Top; cursorTransrofm.rotate(90); } else if (resizerBottom.contains(pos)) { resizingMode = Bottom; cursorTransrofm.rotate(90); } else if (resizerLeft.contains(pos)) { resizingMode = Left; } else if (resizerRight.contains(pos)) { resizingMode = Right; } else if (resizerTopLeft.contains(pos)) { resizingMode = TopLeft; cursorTransrofm.rotate(45); } else if (resizerTopRight.contains(pos)) { resizingMode = TopRight; cursorTransrofm.rotate(-45); } else if (resizerBottomLeft.contains(pos)) { resizingMode = BottomLeft; cursorTransrofm.rotate(-45); } else if (resizerBottomRight.contains(pos)) { resizingMode = BottomRight; cursorTransrofm.rotate(45); } else resizingMode = None; if (None != resizingMode) { QPixmap pix(":/images/cursors/resize.png"); QCursor resizeCursor = QCursor(pix.transformed(cursorTransrofm, Qt::SmoothTransformation), pix.width() / 2, pix.height() / 2); setCursor(resizeCursor); } else unsetCursor(); return resizingMode; }