Example #1
0
void MainWindow::callSlot(QString text)
{
	ui.scrollArea->setWidget(new QWidget());
	QWidget* camera = CameraFactory::CreateCamera();	

	if(text == QStringLiteral("全屏显示"))
	{
		CameraFactory::SetLBScreen(QStringLiteral("屏幕恢复"));

		camera->setParent(this);
		camera->setWindowFlags(Qt::Window);
		camera->showFullScreen();
		camera->setFocus();
	}	
	else
	{
		CameraFactory::SetLBScreen(QStringLiteral("全屏显示"));
		ui.scrollArea->setWidget(camera);
		camera->setFocus();
		//camera->setParent(ui.scrollArea);
		//camera->show();
		//camera->setFocus();
	}

	connect(camera, SIGNAL(backSignal()), this, SLOT(reportSlot()));
	connect(camera, SIGNAL(imageSignal(QString)), this, SLOT(loadNewImage(QString)));
	connect(camera, SIGNAL(fullScreenSignal(QString)), this, SLOT(fullScreenSlot(QString)));
}
void QGroupBox::fixFocus()
{
    QFocusData * fd = focusData();
    QWidget * orig = fd->home();
    QWidget * best = 0;
    QWidget * candidate = 0;
    QWidget * w = orig;
    do {
        QWidget * p = w;
        while( p && p != this && !p->isTopLevel() )
            p = p->parentWidget();
        if ( p == this && ( w->focusPolicy() & TabFocus ) == TabFocus
                && w->isVisibleTo(this) ) {
            if ( w->hasFocus()
#ifndef QT_NO_RADIOBUTTON
                    || ( !best && ::qt_cast<QRadioButton*>(w)
                         && ((QRadioButton*)w)->isChecked() )
#endif
               )
                // we prefer a checked radio button or a widget that
                // already has focus, if there is one
                best = w;
            else if ( !candidate )
                // but we'll accept anything that takes focus
                candidate = w;
        }
        w = fd->next();
    } while( w != orig );
    if ( best )
        best->setFocus();
    else if ( candidate )
        candidate->setFocus();
}
Example #3
0
/*!
    \property QStackedLayout::currentIndex
    \brief the index position of the widget that is visible

    The current index is -1 if there is no current widget.

    \sa currentWidget(), indexOf()
*/
void QStackedLayout::setCurrentIndex(int index)
{
    Q_D(QStackedLayout);
    QWidget *prev = currentWidget();
    QWidget *next = widget(index);
    if (!next || next == prev)
        return;

    bool reenableUpdates = false;
    QWidget *parent = parentWidget();

    if (parent && parent->updatesEnabled()) {
        reenableUpdates = true;
        parent->setUpdatesEnabled(false);
    }

    QWidget *fw = parent ? parent->window()->focusWidget() : 0;
    if (prev) {
        prev->clearFocus();
        if (d->stackingMode == StackOne)
            prev->hide();
    }

    d->index = index;
    next->raise();
    next->show();

    // try to move focus onto the incoming widget if focus
    // was somewhere on the outgoing widget.

    if (parent) {
        if (fw && (prev && prev->isAncestorOf(fw))) { // focus was on old page
            // look for the best focus widget we can find
            if (QWidget *nfw = next->focusWidget())
                nfw->setFocus();
            else {
                // second best: first child widget in the focus chain
                QWidget *i = fw;
                while ((i = i->nextInFocusChain()) != fw) {
                    if (((i->focusPolicy() & Qt::TabFocus) == Qt::TabFocus)
                        && !i->focusProxy() && i->isVisibleTo(next) && i->isEnabled()
                        && next->isAncestorOf(i)) {
                        i->setFocus();
                        break;
                    }
                }
                // third best: incoming widget
                if (i == fw )
                    next->setFocus();
            }
        }
    }
    if (reenableUpdates)
        parent->setUpdatesEnabled(true);
    emit currentChanged(index);
}
Example #4
0
void MainWindow::toggleComandLineFocus()
{
    QWidget *cmd = cmdLine();
    if(cmd->hasFocus()) {
        QWidget *editor = mEditors->currentEditor();
        if(editor) editor->setFocus(Qt::OtherFocusReason);
    }
    else
        cmd->setFocus(Qt::OtherFocusReason);
}
Example #5
0
void ModeManager::setFocusToCurrentMode()
{
    IMode *mode = currentMode();
    QTC_ASSERT(mode, return);
    QWidget *widget = mode->widget();
    if (widget) {
        QWidget *focusWidget = widget->focusWidget();
        if (focusWidget)
            focusWidget->setFocus();
        else
            widget->setFocus();
    }
}
Example #6
0
/*!\reimp
*/
bool QLabel::event(QEvent *e)
{
    Q_D(QLabel);
    QEvent::Type type = e->type();

#ifndef QT_NO_SHORTCUT
    if (type == QEvent::Shortcut) {
        QShortcutEvent *se = static_cast<QShortcutEvent *>(e);
        if (se->shortcutId() == d->shortcutId) {
            QWidget * w = d->buddy;
            QAbstractButton *button = qobject_cast<QAbstractButton *>(w);
            if (w->focusPolicy() != Qt::NoFocus)
                w->setFocus(Qt::ShortcutFocusReason);
            if (button && !se->isAmbiguous())
                button->animateClick();
            else
                window()->setAttribute(Qt::WA_KeyboardFocusChange);
            return true;
        }
    } else
#endif
    if (type == QEvent::Resize) {
        if (d->control)
            d->textLayoutDirty = true;
    } else if (e->type() == QEvent::StyleChange
#ifdef Q_WS_MAC
               || e->type() == QEvent::MacSizeChange
#endif
               ) {
        d->setLayoutItemMargins(QStyle::SE_LabelLayoutItem);
        d->updateLabel();
    }

    return QFrame::event(e);
}
void DlgInputDialogImp::setType( DlgInputDialogImp::Type t )
{
    inputtype = t;

    QWidget *input = 0;
    switch (inputtype)
    {
    case LineEdit:
        input = lineEdit;
        break;
    case SpinBox:
        input = spinBox;
        break;
    case UIntBox:
        input = uIntSpinBox;
        break;
    case FloatSpinBox:
        input = floatSpinBox;
        break;
    case ComboBox:
        input = comboBox;
        break;
    default:
        break;
    }

    if (input) {
        stack->setCurrentWidget(input->parentWidget());
        stack->setFixedHeight( input->sizeHint().height() );
        input->setFocus();
        label->setBuddy( input );
    }
}
Example #8
0
void GuiMainWindow::currentChanged(int index)
{
    if (index < 0)
        return;
    if (index < (signed)widgetAtIndex.size()) {
        auto it = widgetAtIndex[index];
        if (it.first) {
            if (it.first->focusWidget())
                it.first->focusWidget()->setFocus();
        } else if (it.second)
            it.second->setFocus();
        return;
    }

    // slow_mode: if tab is inserted just now, widgetAtIndex may not
    // be up-to-date.
    if (tabArea->widget(index)) {
        QWidget *currWgt = tabArea->widget(index);
        if (qobject_cast<GuiSplitter*>(currWgt)) {
            if (currWgt->focusWidget())
                currWgt->focusWidget()->setFocus();
        } else if (qobject_cast<GuiTerminalWindow*>(currWgt))
            currWgt->setFocus();
    }
}
void SettingsDialog::keyReleaseEvent(QKeyEvent *ke)
{
    QWidget *wnd = 0;
    ke->accept();
    switch (ke->key())
    {
    case Qt::Key_Up:
    case Qt::Key_Left:
    case Qt::Key_Right:
    case Qt::Key_Down:
    case Qt::Key_PageDown:
    case Qt::Key_PageUp:
        wnd = ui::moveFocus(&content_widget_, ke->key());
        if (wnd)
        {
            wnd->setFocus();
        }
        break;
    case Qt::Key_Return:
        break;
    case Qt::Key_Escape:
        reject();
        break;
    }
}
Example #10
0
void BaseMainPage::focusNextRightChild()
{
	if(!m_pCtrlPage)
		return;
	if(isNavigatorMode())
	{
		if(m_nNavigatorCnt <= 0)
			return;

		int tindex = (m_nCurrentNavigator+1)%m_nNavigatorCnt;
		navigatorPageAt(tindex);
		return;
	}

	QObjectList list = m_pCtrlPage->xList;
	if(list.length() == 0)
		return;

	QObject *obj = m_pCtrlPage->focusWidget();
	int index = list.indexOf(obj);
	if(index == -1)
		index = list.length()-1;
	if(index == list.length()-1)
	{
		index = -1;
	}
	index++;
	QWidget *tab =static_cast<QWidget *>(list.at(index));
	tab->setFocus();
}
Example #11
0
void
Core::selectEditor(Komposer::Editor *editor)
{
    if(!editor)
        return;

    KParts::Part *part = editor->part();

    editor->select();

    QPtrList<KParts::Part> *partList = const_cast<QPtrList<KParts::Part>*>(
                                           m_partManager->parts());
    if(partList->find(part) == -1)
        addPart(part);

    m_partManager->setActivePart(part);
    QWidget *view = part->widget();
    Q_ASSERT(view);

    kdDebug() << "Raising view " << view << endl;
    if(view)
    {
        m_stack->raiseWidget(view);
        view->show();
        view->setFocus();
        m_currentEditor = editor;
    }
}
Example #12
0
void DictFrame::keyReleaseEvent(QKeyEvent *ke)
{
    QWidget * wnd = 0;
    QPushButton * btn = 0;
    int key = ke->key();
    if (key == Qt::Key_Escape || key == ui::Device_Menu_Key)
    {
        ke->accept();
        onCloseClicked();
        return;
    }

    if (internalState() == LOOKUP)
    {
        emit keyReleaseSignal(ke->key());
        return;
    }

    ke->accept();
    switch (ke->key())
    {
    case Qt::Key_Up:
    case Qt::Key_Left:
    case Qt::Key_Right:
    case Qt::Key_Down:
        wnd = ui::moveFocus(this, key);
        if (wnd)
        {
            wnd->setFocus();
        }
        break;
    default:
        break;
    }
}
Example #13
0
File: app.cpp Project: speakman/qlc
//
// A window title was selected from window menu, show that window
//
void App::slotWindowMenuCallback(int item)
{
  QPtrList <QWidget> wl = workspace()->windowList();

  if (item == ID_WINDOW_CASCADE || item == ID_WINDOW_TILE)
    {
      return;
    }

  if (wl.count())
    {
      QWidget* widget;

      widget = wl.at(item);
      if (widget != NULL)
	{
	  widget->show();
	  widget->setFocus();
	}
      else
	{
	  assert(false);
	}
      
      disconnect(m_windowMenu);
    }
}
Example #14
0
void ViewSplitter::setActiveContainer(ViewContainer* container)
{
    QWidget* activeView = container->activeView();

    if (activeView)
        activeView->setFocus(Qt::OtherFocusReason);
}
void onInplaceWidgetDestroyed(QObject* object)
{
    // set focus to parent of inplace widget
    QWidget* parent = qobject_cast<QWidget*>(object->parent());
    if (parent)
        parent->setFocus();
}
Example #16
0
void Editor::open(const QFileInfo &info)
{
    if (!info.exists() || !info.isFile())
        return;
    int index = files->findData(info.absoluteFilePath());
    if (index >= 0) {
        files->setCurrentIndex(index);
        return;
    }
    QWidget *widget;
    if (QString(ALLOWED_IMAGE_EXTENSIONS).contains(info.suffix())) {
        Viewer *viewer = new Viewer(tabs);
        viewer->open(info);
        widget = viewer;
    } else if (QString(ALLOWED_TEXT_EXTENSIONS).contains(info.suffix())) {
        Coder *coder = new Coder(tabs);
        coder->open(info);
        widget = coder;
    } else
        return;
    QIcon icon = (editables.contains(info.suffix()) ? ::icon(info.suffix()) : ::icon("file"));
    index = tabs->addTab(widget, icon, info.fileName());
    files->addItem(icon, info.fileName(), info.absoluteFilePath());
    files->setCurrentIndex(index);
    tabs->setTabToolTip(index, info.absoluteFilePath());
    widget->setFocus();
    widget->setProperty("path", info.absoluteFilePath());
}
Example #17
0
File: app.cpp Project: speakman/qlc
void App::slotWindowMenuCallback(int item)
{
	QPtrList <QWidget> wl = workspace()->windowList();

	if (item == ID_WINDOW_CASCADE || item == ID_WINDOW_TILE)
	{
		return;
	}

	if (wl.count())
	{
		QWidget* widget;

		widget = wl.at(item);
		if (widget != NULL)
		{
			widget->show();
			widget->setFocus();
		}
		else
		{
			QMessageBox::critical(this,
					      "Unable to select window",
					      "Handle not found");
		}

		disconnect(m_windowMenu);
	}
}
Example #18
0
void OutputWidget::eventuallyDoFocus()
{
    QWidget* widget = currentWidget();
    if( focusOnSelect->isChecked() && !widget->hasFocus() ) {
        widget->setFocus( Qt::OtherFocusReason );
    }
}
Example #19
0
void QInputDialog::setType( Type t )
{
    QWidget *input = 0;
    switch ( t ) {
    case LineEdit:
	input = d->lineEdit;
	break;
    case SpinBox:
	input = d->spinBox;
	break;
    case ComboBox:
	input = d->comboBox;
	break;
    case EditableComboBox:
	input = d->editComboBox;
	break;
    default:
#if defined(QT_CHECK_STATE)
	qWarning( "QInputDialog::setType: Invalid type" );
#endif
	break;
    }
    if ( input ) {
	d->stack->raiseWidget( input );
	d->stack->setFixedHeight( input->sizeHint().height() );
	input->setFocus();
#ifndef QT_NO_ACCEL
	d->label->setBuddy( input );
#endif
    }

    d->type = t;
}
Example #20
0
void BaseMainPage::focusNextLeftChild()
{
	if(!m_pCtrlPage)
		return;

	if(isNavigatorMode())
	{
		if(m_nNavigatorCnt <= 0)
			return;

		int tIndex = 0;
		m_nCurrentNavigator == 0 ? tIndex = m_nNavigatorCnt-1 : tIndex = m_nCurrentNavigator-1;
		navigatorPageAt(tIndex);
		return;
	}

	QObjectList &list = m_pCtrlPage->xList;
	if(list.length() == 0)
		return;

	QObject *obj = m_pCtrlPage->focusWidget();
	int index = list.indexOf(obj);
	if(index == -1)
		index = 0;
	if(index == 0)
	{
		index = list.length();
	}
	index--;
	QWidget *tab =static_cast<QWidget *>(list.at(index));
	tab->setFocus();
}
Example #21
0
/*! This slot should get called when the current tab has
 *  changed.
 */
void UserEventTabDlg::currentChanged(int index)
{
  QWidget* tab = myTabs->widget(index);
  tab->setFocus();  // prevents users from accidentally typing in the wrong widget
  updateTitle(tab);
  clearEvents(tab);
}
Example #22
0
bool pixosIfaceOptsDialog::validate()
{
    bool valid = true;
    QString combobox = m_dialog->iface_type->currentText();
    QString type = m_dialog->iface_type->itemData(
        m_dialog->iface_type->currentIndex()).toString();
    QWidget *focus = NULL;
    QString message;

    if (type == "8021q")
    {
        // VLAN ID must be set between 1 <= vid <= 4'094
        // QSpinBox widget enforces these limits
        ;
    }

    if (!valid)
    {
        QMessageBox::warning(this, "Firewall Builder",
                             tr("Input not valid: %1").arg(message), "&Continue",
                             QString::null, QString::null, 0, 1);
        focus->setFocus();
    }
    return valid;
}
Example #23
0
void Klipper::slotShowBarcode()
{
    using namespace prison;
    const HistoryStringItem* item = dynamic_cast<const HistoryStringItem*>(m_history->first());

    KDialog dlg;
    dlg.setModal( true );
    dlg.setCaption( i18n("Mobile Barcode") );
    dlg.setButtons( KDialog::Ok );

    QWidget* mw = new QWidget(&dlg);
    QHBoxLayout* layout = new QHBoxLayout(mw);

    BarcodeWidget* qrcode = new BarcodeWidget(new QRCodeBarcode());
    BarcodeWidget* datamatrix = new BarcodeWidget(new DataMatrixBarcode());

    if (item) {
        qrcode->setData( item->text() );
        datamatrix->setData( item->text() );
    }

    layout->addWidget(qrcode);
    layout->addWidget(datamatrix);

    mw->setFocus();
    dlg.setMainWidget( mw );
    dlg.adjustSize();

    dlg.exec();
}
Example #24
0
void QGroupBoxPrivate::_q_fixFocus(Qt::FocusReason reason)
{
    Q_Q(QGroupBox);
    QWidget *fw = q->focusWidget();
    if (!fw || fw == q) {
        QWidget * best = 0;
        QWidget * candidate = 0;
        QWidget * w = q;
        while ((w = w->nextInFocusChain()) != q) {
            if (q->isAncestorOf(w) && (w->focusPolicy() & Qt::TabFocus) == Qt::TabFocus && w->isVisibleTo(q)) {
                if (!best && qobject_cast<QRadioButton*>(w) && ((QRadioButton*)w)->isChecked())
                    // we prefer a checked radio button or a widget that
                    // already has focus, if there is one
                    best = w;
                else if (!candidate)
                    // but we'll accept anything that takes focus
                    candidate = w;
            }
        }
        if (best)
            fw = best;
        else if (candidate)
            fw = candidate;
    }
    if (fw)
        fw->setFocus(reason);
}
Example #25
0
void ItemOrderList::setCurrentItem(int row)
{
    QListWidgetItem *currentItem = listItem(row);
    ui->listWidgetItems->setCurrentItem(currentItem, QItemSelectionModel::ClearAndSelect);
    QWidget *widget = createWidget(currentItem);
    widget->setFocus();
}
void MpdClientDialog::keyReleaseEvent(QKeyEvent *ke)
{
    switch(ke->key())
    {
    case Qt::Key_Left:
    case Qt::Key_Right:
    {
        QWidget *wnd = ui::moveFocus(&button_widget_, ke->key());
        if (wnd)
        {
            wnd->setFocus();
            onyx::screen::instance().flush();
            onyx::screen::instance().updateWidget(&button_widget_, onyx::screen::ScreenProxy::DW, false);
        }
        break;
    }
    case Qt::Key_Escape:
        done();
        break;
    case Qt::Key_Return:
    case Qt::Key_PageDown:
    case Qt::Key_PageUp:
    case Qt::Key_Up:
    case Qt::Key_Down:
    case Qt::Key_Menu:
    default:
        break;
    }
}
Example #27
0
void TabWidget::setCurrentIndex(int tabIndex)
{
    QWidget *w = currentWidget();
    const int current = (isTreeModeEnabled() && w != NULL && w->isHidden()) ? -1 : currentIndex();

    if (tabIndex == current)
        return;

    if (tabIndex != -1) {
        m_stackedWidget->setCurrentIndex(tabIndex);

        w = currentWidget();
        if (w == NULL)
            return;

        w->show();
        if (isTreeModeEnabled() ? m_tabTree->hasFocus() : m_tabBar->hasFocus())
            w->setFocus();

        if ( isTreeModeEnabled() )
            m_tabTree->setCurrentTabIndex(tabIndex);
        else
            m_tabBar->setCurrentIndex(tabIndex);
    } else if (w != NULL) {
        if (w->hasFocus())
            isTreeModeEnabled() ? m_tabTree->setFocus() : m_tabBar->setFocus();
        w->hide();
    }

    emit currentChanged(tabIndex, current);
}
Example #28
0
void TabbedWidget::tabChanged(const int &index)
{
	// A new tab has been selected, so give the focus to its widget
	QWidget* widget = mTabWidget->widget(index);
	if (widget)
		widget->setFocus();
}
void KOnlineBankingSetupWizard::newPage(int id)
{
  QWidget* focus = 0;

  bool ok = true;
  if ((id - d->m_prevPage) == 1) { // one page forward?
    switch (d->m_prevPage) {
      case 0:
        ok = finishFiPage();
        // open the KDE wallet if not already opened
        if (ok && !d->m_wallet) {
          d->m_wallet = Wallet::openWallet(Wallet::NetworkWallet(), winId(), Wallet::Asynchronous);
          connect(d->m_wallet, SIGNAL(walletOpened(bool)), SLOT(walletOpened(bool)));
        }
        focus = m_editUsername;
        break;
      case 1:
        ok = finishLoginPage();
        focus = m_listAccount;
        break;
      case 2:
        m_fDone = ok = finishAccountPage();
        break;
    }

    if (ok) {
      if (focus) {
        focus->setFocus();
      }
    } else {
      // force to go back to prev page
      back();
    }
  } else {
Example #30
0
void ApplicationWindow::windowsMenuActivated( int id )
{
    QWidget* w = ws->windowList().at( id );
    if ( w ) {
	w->showNormal();
	w->setFocus();
    }
}