void FLFormRecordDB::closeEvent( QCloseEvent * e ) {
    if ( focusWidget() ) {
        FLFieldDB * fdb = ::qt_cast<FLFieldDB *>( focusWidget()->parentWidget() );
        if ( fdb && fdb->autoComFrame_ && fdb->autoComFrame_->isVisible() ) {
            fdb->autoComFrame_->hide();
            return;
        }
    }

    if ( cursor_ ) {
        int levels = FLSqlCursor::transactionLevel() - initTransLevel;
        if ( levels > 0 )
            cursor_->rollbackOpened( levels,
                                     tr( "Se han detectado transacciones no finalizadas en la última operación.\n" ) +
                                     tr( "Se van a cancelar las transacciones pendientes.\n" ) );
        if ( accepted ) {
            if ( !cursor_->commit() )
                return ;
            afterCommitTransaction();
        } else {
            if ( !cursor_->rollback() )
                return ;
            else
                cursor_->QSqlCursor::select();
        }
        emit closed();
        if ( oldCursorCtxt )
            cursor_->setContext( oldCursorCtxt );
    } else
        emit closed();
    QWidget::closeEvent( e );
    deleteLater();
}
void SudokuWidget::keyPressEvent(QKeyEvent* event)
{
    int id(0);
    for(int i(0); i<81; ++i)
        if(_cases[i] == focusWidget()) id = i;

    int x(0), y(0);
    for(int i(0); i<81; ++i)
        if(grille[0][i/9][i%9] == id)
        { x = i%9; y = i/9; }
    switch(event->key())
    {
    case Qt::Key_Left:
        if(x>0)
            id = grille[0][y][x-1];
        break;
    case Qt::Key_Up:
        if(y>0)
            id = grille[0][y-1][x];
        break;
    case Qt::Key_Right:
        if(x<8)
            id = grille[0][y][x+1];
        break;
    case Qt::Key_Down:
        if(y<8)
            id = grille[0][y+1][x];
        break;
    default:
        event->ignore();
        return;
    }
    if(id>=0 && id<81) _cases[id]->setFocus(Qt::TabFocusReason);
}
Exemple #3
0
/*!
    Returns a QTextFormat object that specifies the format for
    component \a s.
*/
QTextFormat QInputContext::standardFormat(StandardFormat s) const
{
    QWidget *focus = focusWidget();
    const QPalette &pal = focus ? focus->palette() : qApp->palette();

    QTextCharFormat fmt;
    QColor bg;
    switch (s) {
    case QInputContext::PreeditFormat: {
        fmt.setUnderlineStyle(QTextCharFormat::DashUnderline);
#ifndef Q_WS_WIN
        int h1, s1, v1, h2, s2, v2;
        pal.color(QPalette::Base).getHsv(&h1, &s1, &v1);
        pal.color(QPalette::Background).getHsv(&h2, &s2, &v2);
        bg.setHsv(h1, s1, (v1 + v2) / 2);
        fmt.setBackground(QBrush(bg));
#endif
        break;
    }
    case QInputContext::SelectionFormat: {
        bg = pal.text().color();
        fmt.setBackground(QBrush(bg));
        fmt.setForeground(pal.background());
        break;
    }
    }
    return fmt;
}
Exemple #4
0
void MDialog::keyPressEvent(QKeyEvent* event) {
    current_button_ =  list.indexOf(static_cast<MToolButton*> (focusWidget()));
    switch (event->key()){
        case Qt::Key_Escape:
            close();
            break;
        case Qt::Key_Up:
            if (0<(current_button_+6)%9<9) {
                current_button_ = (current_button_+6)%9;
            }
            break;
        case Qt::Key_Down:
            if (0<(current_button_+3)%9<9) {
                current_button_ = (current_button_+3)%9;
            }
            break;
        case Qt::Key_Left:
            if (0<(current_button_+8)%9<9) {
                current_button_ = (current_button_+8)%9;
            }
            break;
        case Qt::Key_Right:
            if (0<(current_button_+1)%9<9) {
                current_button_ = (current_button_+1)%9;
            }
            break;
        default:
            break;
    }
    update();
}
void MInputContext::mouseHandler(int x, QMouseEvent *event)
{
    Q_UNUSED(x);

    qDebug() << "MInputContext" << "in" << __PRETTY_FUNCTION__;
    qDebug() << "MInputContext" << " event pos: " << event->globalPos() << " cursor pos:" << x;

    if (event->type() == QEvent::MouseButtonPress && (x < 0 || x > preedit.length())) {
        reset();
        return;
    }

    // input method server needs to be informed about clicks
    if (event->type() == QEvent::MouseButtonRelease && x >= 0) {

        // Query preedit rectangle and pass it to im server if found.
        // In case of plain QT application, null rectangle will be passed.
        QWidget *focused = focusWidget();
        QRect preeditRect;

#ifdef HAVE_MEEGOTOUCH
        if (focused) {
            // TODO: Move M::PreeditRectangleQuery to MInputMethod
            Qt::InputMethodQuery query
                = static_cast<Qt::InputMethodQuery>(M::PreeditRectangleQuery);
            preeditRect = focused->inputMethodQuery(query).toRect();
        }
#else
        Q_UNUSED(focused);
#endif

        imServer->mouseClickedOnPreedit(event->globalPos(), preeditRect);
    }
}
Exemple #6
0
void CTaskType::slotCreateEditDialog(const QString &action)
{
    if (currentDatabase().isOpen()) {

        QString::compare(action, "add") == 0 ? act = Action::Add : act = Action::Edit;

        cppsstDialog->setWindowTitle(QString("Задача"));

        emit enabledComboBox(false);

        if (treeCppsst == focusWidget()){
            if (act == Action::Add){

                QList<QString> param;
                if (fillListSelectedRecord(param)){
                    cppsstDialog->fillFormSelectedRecord(param, act);
                    cppsstDialog->show();
                }
            } else if (act == Action::Edit){
                if (!modelSelectionTask->selection().isEmpty()){

                    QList<QString> param;
                    if (fillListSelectedRecord(param)){
                        cppsstDialog->fillFormSelectedRecord(param, act);
                        cppsstDialog->show();
                    }
                } else
                    CCommunicate::showing(QString("Не удается выполнить, запись не выбрана"));
            }
        }else
           CCommunicate::showing(QString("Не удается выполнить, таблица/запись не выбрана"));
    } else
        CCommunicate::showing(QString("Не удается выполнить, база данных не доступна"));
}
Exemple #7
0
void CSupplierDialog::slotDeleteProducer()
{
    QList<QVariant> list;
    QSqlQuery       stored;

    if (focusWidget()->objectName() == ui->treeProducer->objectName()){
        if (modelSelectionProducer->selection().isEmpty()){
            CCommunicate::showing(QString("Не удается выполнить, производитель не выбран"));
            return;
        }
    }

    CMessage answer(this, "Удаление", "Подтверждаете удаление?");
    QPushButton *buttonSave    = answer.addButton(QString("Удалить"), QMessageBox::ActionRole);
    QPushButton *buttonCancel  = answer.addButton(QString("Отмена"),  QMessageBox::ActionRole);

    answer.exec();

    if (answer.clickedButton() == buttonSave){
        const unsigned code = modelSelectionProducer->currentIndex().sibling(modelSelectionProducer->currentIndex().row(), 0).data().toUInt();
        list.append(code);

        stored = CDictionaryCore::execStored(CDictionaryCore::currentDatabase(), "DeleteProducerGroup", CDictionaryCore::storageHashTable(list));
        stored.finish();

        modelProducer->removeRows(modelSelectionProducer->currentIndex().row(), 1, QModelIndex());

        removable = true;

    } else if (answer.clickedButton() == buttonCancel){
        answer.reject();
    }
}
Exemple #8
0
void
IBusInputContext::update ()
{
	QWidget *widget = focusWidget ();

	if (widget == NULL) {
		return;
	}

	QRect rect = widget->inputMethodQuery(Qt::ImMicroFocus).toRect ();

	QPoint topleft = widget->mapToGlobal(QPoint(0,0));
	rect.translate (topleft);

	client->setCursorLocation (this, rect);

#if 0
	QVariant value;
	qDebug () << "== update == ";
	value = widget->inputMethodQuery(Qt::ImMicroFocus);
	qDebug () << "Qt::ImMicroFocus " << value;
	value = widget->inputMethodQuery(Qt::ImFont);
	qDebug () << "Qt::ImFont " <<value;
	value = widget->inputMethodQuery(Qt::ImCursorPosition);
	qDebug () << "Qt::ImCursorPosition " << value;
	value = widget->inputMethodQuery(Qt::ImSurroundingText);
	qDebug () << "Qt::ImSurroundingText " << value;
	value = widget->inputMethodQuery(Qt::ImCurrentSelection);
	qDebug () << "Qt::ImCurrentSelection " << value;
#endif
}
void QInputGeneratorGeneric::keyPress(Qt::Key key, Qt::KeyboardModifiers mod, bool autoRepeat)
{
    QTT_TRACE_FUNCTION();
    qttDebug() << "keyPress" << key << mod << autoRepeat;
    Q_UNUSED(autoRepeat);
    keyEvent(Press, focusWidget(), key, mod);
}
void ClientWidget::enableActions()
{
	bool c = false;

	int row = clientTable->currentRow();
	if( row < 0 )
		c = false;
	else
		c = true;

	toolBar->setActionEnabled( editClientAction, c );
	toolBar->setActionEnabled( newClientAccountAction, c );
	toolBar->setActionEnabled( removeClientAction, c );

	QWidget *w = focusWidget();
	if( w )
	{
		if( w == (QWidget *)accountTable )
			c = true;
		else
			c = false;

		toolBar->setActionEnabled( removeClientAccountAction, c );
	}

	if( socket->state() != QAbstractSocket::UnconnectedState || sSocket->state() != QAbstractSocket::UnconnectedState )
		c = false;
	else
		c = true;

	toolBar->setActionEnabled( reloadAction, c );
}
Exemple #11
0
bool KexiComboBoxTableEdit::eventFilter(QObject *o, QEvent *e)
{
#if 0
    if (e->type() != QEvent::Paint
            && e->type() != QEvent::Leave
            && e->type() != QEvent::MouseMove
            && e->type() != QEvent::HoverMove
            && e->type() != QEvent::HoverEnter
            && e->type() != QEvent::HoverLeave)
    {
        kDebug() << e << o;
        kDebug() << "FOCUS WIDGET:" << focusWidget();
    }
#endif
    KexiTableView *tv = dynamic_cast<KexiTableView*>(m_scrollView);
    if (tv && e->type() == QEvent::KeyPress) {
        if (tv->eventFilter(o, e)) {
            return true;
        }
    }
    if (!column()->isReadOnly() && e->type() == QEvent::MouseButtonPress && m_scrollView) {
        QPoint gp = static_cast<QMouseEvent*>(e)->globalPos()
                    + QPoint(m_scrollView->childX(d->button), m_scrollView->childY(d->button));
        QRect r(d->button->mapToGlobal(d->button->geometry().topLeft()),
                d->button->mapToGlobal(d->button->geometry().bottomRight()));
        if (o == popup() && popup()->isVisible() && r.contains(gp)) {
            m_mouseBtnPressedWhenPopupVisible = true;
        }
    }
    return false;
}
Exemple #12
0
void CameraMainWindow::updateActions()
{
    bool p=false,v=false;
    QWidget *foc = focusWidget();
    if ( foc == camera->photo ) {
        p = true; v = false;
    } else if ( foc == camera->video ) {
        v = true; p = false;
    }
    if(a_pview)
        a_pview->setVisible(p);
    if(a_timer)
        a_timer->setVisible(p);
    if ( video_supported && a_vview )
        a_vview->setVisible(v);
    //a_settings->setVisible(p || v);
    bool th=!p && !v;
    if ( th ) {

        int i;
        for (i=0; i<nthumb; i++) {
            if ( thumb[i] == foc ) {
                selectThumb(i);
                break;
            }
        }
        if ( i==nthumb || thumb[i]->icon().isNull() )
            selectThumb(-1);
    } else {

        selectThumb(-1);
    }
}
Exemple #13
0
void MainWindow::copySelection()
{
    if (focusWidget() == ui->messageText)
    {
        ui->messageText->copy();
        return;
    }
    QApplication::clipboard()->setText(ui->tableView->selectionAsText());
}
/*!
    \reimp
 */
bool QScrollArea::focusNextPrevChild(bool next)
{
    if (QWidget::focusNextPrevChild(next)) {
        if (QWidget *fw = focusWidget())
            ensureWidgetVisible(fw);
        return true;
    }
    return false;
}
Exemple #15
0
void MainWindow::selectAll()
{
    if (focusWidget() == ui->messageText)
    {
        ui->messageText->selectAll();
        return;
    }
    ui->tableView->selectAll();
}
Exemple #16
0
void XMainWindow::showEvent(QShowEvent *event)
{
  if(!_private->_shown)
  {
    _private->_shown = true;
//qDebug("isModal() %s", isModal()?"true":"false");

    QRect availableGeometry = QApplication::desktop()->availableGeometry();
    if(!omfgThis->showTopLevel() && !isModal())
      availableGeometry = omfgThis->workspace()->geometry();

    QString objName = objectName();
    QPoint pos = xtsettingsValue(objName + "/geometry/pos").toPoint();
    QSize lsize = xtsettingsValue(objName + "/geometry/size").toSize();

    if(lsize.isValid() && xtsettingsValue(objName + "/geometry/rememberSize", true).toBool() && (metaObject()->className() != QString("xTupleDesigner")))
      resize(lsize);

    setAttribute(Qt::WA_DeleteOnClose);
    if(omfgThis->showTopLevel() || isModal())
    {
      omfgThis->_windowList.append(this);
      statusBar()->show();
      QRect r(pos, size());
      if(!pos.isNull() && availableGeometry.contains(r) && xtsettingsValue(objName + "/geometry/rememberPos", true).toBool())
        move(pos);
    }
    else
    {
      QWidget * fw = focusWidget();
      omfgThis->workspace()->addWindow(this);
      QRect r(pos, size());
      if(!pos.isNull() && availableGeometry.contains(r) && xtsettingsValue(objName + "/geometry/rememberPos", true).toBool())
        move(pos);
      // This originally had to be after the show? Will it work here?
      if(fw)
        fw->setFocus();
    }

    _private->loadScriptEngine();

    QList<XCheckBox*> allxcb = findChildren<XCheckBox*>();
    for (int i = 0; i < allxcb.size(); ++i)
      allxcb.at(i)->init();

    shortcuts::setStandardKeys(this);
  }

  bool blocked = _private->_action->blockSignals(true);
  _private->_action->setChecked(true);
  _private->_action->blockSignals(blocked);

  _private->callShowEvent(event);

  QMainWindow::showEvent(event);
}
void QGCINInputContext::reset()
{
//    printf("reset %x %d %d\n", focusWidget(), isComposing(), composingText.isNull());

    if ( focusWidget() && isComposing() && ! composingText.isNull() ) {
	QInputContext::reset();

	resetClientState();
    }
}
void MyInputPanelContext::updatePosition()
{
    QWidget *widget = focusWidget();
    if (!widget)
        return;

    QRect widgetRect = widget->rect();
    QPoint panelPos = QPoint(widgetRect.left(), widgetRect.bottom() + 2);
    panelPos = widget->mapToGlobal(panelPos);
    inputPanel->move(panelPos);
}
void QGCINInputContext::setMicroFocus(int x, int y, int, int h, QFont *f)
{
    QWidget *widget = focusWidget();

    if (widget ) {
	QPoint p( x, y );
	QPoint p2 = widget->mapTo( widget->topLevelWidget(), QPoint( 0, 0 ) );
	p = widget->topLevelWidget()->mapFromGlobal( p );
	setComposePosition(p.x(), p.y() + h);
   }
}
Exemple #20
0
void PScreen::sendEvent(PTouchEvent *touch, PKeyEvent *key)
{
	if (touch->locked())
	{
		PWidget * wid = touch->locked();
		wid->processEvent(key, touch);
		return;
	}

	//focused widget ask first
	if (focusWidget() && focusWidget()->sendEvent(key, touch))
		return;

	PWidget * t = child;
	while (t)
	{
		if (t->sendEvent(key, touch))
			return;
		t = t->nextSibling();
	}
}
Exemple #21
0
ContentView* CatalogView::focusItem()
{
    QWidget *wnd = focusWidget();
    foreach(ContentView *item, sub_items_)
    {
        if (item == wnd)
        {
            return item;
        }
    }
    return 0;
}
Exemple #22
0
void XWidget::showEvent(QShowEvent *event)
{
  if(!_private->_shown)
  {
    _private->_shown = true;
    if (windowFlags() & (Qt::Window | Qt::Dialog))
    {
      QRect availableGeometry = QApplication::desktop()->availableGeometry();
      if(!omfgThis->showTopLevel() && !isModal())
        availableGeometry = QRect(QPoint(0, 0), omfgThis->workspace()->size());

      QString objName = objectName();
      QPoint pos = xtsettingsValue(objName + "/geometry/pos").toPoint();
      QSize lsize = xtsettingsValue(objName + "/geometry/size").toSize();

      if(lsize.isValid() && xtsettingsValue(objName + "/geometry/rememberSize", true).toBool())
        resize(lsize);

      setAttribute(Qt::WA_DeleteOnClose);
      if(omfgThis->showTopLevel() || isModal())
      {
        omfgThis->_windowList.append(this);
        QRect r(pos, size());
        if(!pos.isNull() && availableGeometry.contains(r) && xtsettingsValue(objName + "/geometry/rememberPos", true).toBool())
          move(pos);
      }
      else
      {
        QWidget * fw = focusWidget();
        omfgThis->workspace()->addWindow(this);
        QRect r(pos, size());
        if(!pos.isNull() && availableGeometry.contains(r) && xtsettingsValue(objName + "/geometry/rememberPos", true).toBool() && parentWidget())
          parentWidget()->move(pos);
        // This originally had to be after the show? Will it work here?
        if(fw)
          fw->setFocus();
      }
    }

    _private->loadScriptEngine();

    QList<XCheckBox*> allxcb = findChildren<XCheckBox*>();
    for (int i = 0; i < allxcb.size(); ++i)
      allxcb.at(i)->init();

    shortcuts::setStandardKeys(this);
  }

  _private->callShowEvent(event);

  QWidget::showEvent(event);
}
void QMacInputContext::setFocusWidget(QWidget *w)
{
    if (!w)
        lastFocusWid = focusWidget();
    createTextDocument();
#ifndef QT_MAC_USE_COCOA
    if(w)
        ActivateTSMDocument(textDocument);
    else
        DeactivateTSMDocument(textDocument);
#endif
    QInputContext::setFocusWidget(w);
}
Exemple #24
0
bool ShowBox::isEditing() const
{
    if (!isActiveWindow())
    {
        return false;
    }
    QList<QWidget*> editors;
    foreach (auto box, findChildren<QSpinBox*>())
    {
        editors << box;
    }
    return editors.contains(focusWidget());
}
Exemple #25
0
bool MDialog::event(QEvent* e) {
    bool ret = QDialog::event ( e );
    //TODO just the buttons
    if (e->type() == QEvent::UpdateRequest)
    {
        if (list.size()<9) {
            onyx::screen::instance().updateWidget(this);
        } else {
            onyx::screen::instance().updateWidget(focusWidget());
        }
    }
    return ret;
}
Exemple #26
0
bool CCustomer::eventFilter(QObject *object, QEvent *event)
{
    if (object == qobject_cast<QTreeView*>(treeFaces)) {
        if (event->type() == QEvent::FocusIn){
            focusedWidget = focusWidget();
            return false;
        } else if (event->type() == QEvent::FocusOut){
            treeFaces->clearFocus();
            return false;
        }
    }
    return QWidget::eventFilter(object, event);
}
Exemple #27
0
void FormStyle::PictureButtonCliked()
{
	QString pMS = Func.fileDialog( OPEN_FILE, this, "QMPlay", curP, Texts[34]/*Obrazy*/ + " (*.bmp *.gif *.jpg *.jpeg *.png *.pbm *.pgm *.ppm *.xbm *.xpm *.ico *.svg);;" + Texts[30] + " (*)" )[0];
	if ( !pMS.isEmpty() )
	{
		Func.CURP(pMS);
		if ( focusWidget()->objectName() == "bP2_2" )
			mainWindowPixmap = pMS;
	}
	else if ( !mainWindowPixmap.isNull() && QMessageBox::information( this,"QMPlay",Texts[121]/*czy wyczyscic obraz*/,3,4 ) == 3 )
		mainWindowPixmap = 0;
	setButtonsColor();
}
Exemple #28
0
void QWSInputContext::update()
{
    QWidget *w = focusWidget();
    if (!w)
        return;

    QWidget *tlw = w->window();
    int winid = tlw->winId();

    int widgetid = w->winId();
    QPaintDevice::qwsDisplay()->sendIMUpdate(QWSInputMethod::Update, winid, widgetid);

}
Exemple #29
0
void MyInputPanelContext::updatePosition()
{
  QWidget *widget = focusWidget();
  if (!widget)
    return;

  QRect widgetRect = widget->rect();
  QPoint panelPos = QPoint(widgetRect.left(), widgetRect.top());
  panelPos = widget->mapToGlobal(panelPos);
  if(panelPos.y()+widgetRect.height()>550)
    inputPanel->move(100,100);
  else
    inputPanel->move(100,550);
}
Exemple #30
0
void QUimInputContext::unsetFocus()
{
#ifdef ENABLE_DEBUG
    qDebug( "QUimInputContext: %p->unsetFocus(), focusWidget()=%p",
            this, focusWidget() );
#endif
    uim_focus_out_context( m_uc );

    cwin->hide();

    m_HelperManager->checkHelperConnection();

    uim_helper_client_focus_out( m_uc );
}