/*! \reimp */ int QAccessibleWidget::childAt(int x, int y) const { QWidget *w = widget(); if (!w->isVisible()) return -1; QPoint gp = w->mapToGlobal(QPoint(0, 0)); if (!QRect(gp.x(), gp.y(), w->width(), w->height()).contains(x, y)) return -1; QWidgetList list = childWidgets(w); int ccount = childCount(); // a complex child if (list.size() < ccount) { for (int i = 1; i <= ccount; ++i) { if (rect(i).contains(x, y)) return i; } return 0; } QPoint rp = w->mapFromGlobal(QPoint(x, y)); for (int i = 0; i<list.size(); ++i) { QWidget *child = list.at(i); if (!child->isWindow() && !child->isHidden() && child->geometry().contains(rp)) { return i + 1; } } return 0; }
void FormWindowBase::deleteWidgetList(const QWidgetList &widget_list) { switch (widget_list.size()) { case 0: break; case 1: { commandHistory()->beginMacro(tr("Delete '%1'").arg(widget_list.front()->objectName())); emit widgetRemoved(widget_list.front()); DeleteWidgetCommand *cmd = new DeleteWidgetCommand(this); cmd->init(widget_list.front()); commandHistory()->push(cmd); commandHistory()->endMacro(); } break; default: commandHistory()->beginMacro(tr("Delete")); foreach (QWidget *w, widget_list) { emit widgetRemoved(w); DeleteWidgetCommand *cmd = new DeleteWidgetCommand(this); cmd->init(w); commandHistory()->push(cmd); } commandHistory()->endMacro(); break; }
void pieDialog::updatePlot() { if (generalDialog->currentPage()==(QWidget *)pieOptions) { QPen pen=QPen(boxLineColor->color(),boxLineWidth->value(), style()); emit updatePie(pen, pattern(), boxRay->value(), boxFirstColor->currentItem()); } if (generalDialog->currentPage()==(QWidget*)frame) { if (!boxAll->isChecked()) return; QColor c = boxBackgroundColor->color(); QWidgetList* allPlots = mPlot->graphPtrs(); for (int i=0; i<(int)allPlots->count();i++) { Graph* g=(Graph*)allPlots->at(i); if (g) { g->drawBorder(boxBorderWidth->value(), boxBorderColor->color()); g->changeMargin(boxMargin->value()); g->setBackgroundColor(c); } } if (c == QColor(white) && mPlot->hasOverlapingLayers()) mPlot->updateTransparency(); } }
void InsertPageCommand::undo() { QWidget *page = m_form->objectTree()->lookup(m_name)->widget(); QWidget *parent = m_form->objectTree()->lookup(m_parentname)->widget(); QWidgetList list; list.append(page); KFormDesigner::Command *com = new KFormDesigner::DeleteWidgetCommand(*m_form, list); QByteArray classname = parent->metaObject()->className(); if (classname == "KFDTabWidget") { TabWidgetBase *tab = dynamic_cast<TabWidgetBase*>(parent); tab->removeTab(tab->indexOf(page)); } else if (classname == "QStackedWidget" || /* compat */ classname == "QWidgetStack") { QStackedWidget *stack = dynamic_cast<QStackedWidget*>(parent); int index = stack->indexOf(page); if (index > 0) index--; else if (index < (stack->count()-1)) index++; else index = -1; if (index >= 0) stack->setCurrentIndex(index); stack->removeWidget(page); } com->execute(); delete com; }
void DiffAnalystWindow::onWindowsMenuAboutToShow() { m_pWindowsMenu->clear (); int cascadeId = m_pWindowsMenu->insertItem ("&Cascade", this, SLOT (onCascade ())); int tileId = m_pWindowsMenu->insertItem ("&Tile", this, SLOT (onTile ())); int close_all_id = m_pWindowsMenu->insertItem ("Close Al&l", this, SLOT (onCloseAllWindows ())); if (m_pWs->windowList ().isEmpty ()) { m_pWindowsMenu->setItemEnabled (cascadeId, FALSE); m_pWindowsMenu->setItemEnabled (tileId, FALSE); m_pWindowsMenu->setItemEnabled (close_all_id, FALSE); } m_pWindowsMenu->insertSeparator (); QWidgetList windows = m_pWs->windowList (); for (int i = 0; i < int (windows.count ()); ++i) { int id = m_pWindowsMenu->insertItem (windows.at (i)->caption (), this, SLOT (onWindowsMenuActivated (int))); m_pWindowsMenu->setItemParameter (id, i); m_pWindowsMenu->setItemChecked (id, m_pWs->activeWindow () == windows.at (i)); } }
/* * Broadcast event to all windows */ bool lamexp_broadcast(int eventType, bool onlyToVisible) { if(QApplication *app = dynamic_cast<QApplication*>(QApplication::instance())) { qDebug("Broadcasting %d", eventType); bool allOk = true; QEvent poEvent(static_cast<QEvent::Type>(eventType)); QWidgetList list = app->topLevelWidgets(); while(!list.isEmpty()) { QWidget *widget = list.takeFirst(); if(!onlyToVisible || widget->isVisible()) { if(!app->sendEvent(widget, &poEvent)) { allOk = false; } } } qDebug("Broadcast %d done (%s)", eventType, (allOk ? "OK" : "Stopped")); return allOk; } else { qWarning("Broadcast failed, could not get QApplication instance!"); return false; } }
STDAPI DllCanUnloadNow() { if (GetCurrentThreadId() != qAxThreadId) return S_FALSE; if (qAxLockCount()) return S_FALSE; if (!qax_ownQApp) return S_OK; // check if qApp still runs widgets (in other DLLs) QWidgetList widgets = qApp->allWidgets(); int count = widgets.count(); for (int w = 0; w < widgets.count(); ++w) { // remove all Qt generated widgets QWidget *widget = widgets.at(w); if (widget->windowType() == Qt::Desktop || widget->objectName() == QLatin1String("Qt internal tablet widget")) count--; } if (count) return S_FALSE; // no widgets left - destroy qApp if (qax_hhook) UnhookWindowsHookEx(qax_hhook); delete qApp; qax_ownQApp = false; // never allow unloading - safety net for Internet Explorer return S_FALSE; }
extern "C" void qtns_shutdown() { if (clients.count() > 0) { QMap<QtNPInstance *, QX11EmbedWidget *>::iterator it = clients.begin(); while (it != clients.end()) { delete it.value(); ++it; } clients.clear(); } if (!ownsqapp) return; // check if qApp still runs widgets (in other DLLs) QWidgetList widgets = qApp->allWidgets(); int count = widgets.count(); for (int w = 0; w < widgets.count(); ++w) { // ignore all Qt generated widgets QWidget *widget = widgets.at(w); if (widget->windowFlags() & Qt::Desktop) count--; } if (count) // qApp still used return; delete qApp; ownsqapp = false; }
//********************************************************************** void TulipApp::windowsMenuAboutToShow() { windowsMenu->clear(); if(tabWidget->currentIndex()==-1) return; QWorkspace *currentWorkspace=controllerToWorkspace[tabIndexToController[tabWidget->currentIndex()]]; QAction* cascadeAction = windowsMenu->addAction("&Cascade", this, SLOT(cascade() ) ); QAction* tileAction = windowsMenu->addAction("&Tile", currentWorkspace, SLOT(tile() ) ); QAction* closeallAction = windowsMenu->addAction("Close All", this, SLOT(closeAll())); if ( currentWorkspace->windowList().isEmpty() ) { cascadeAction->setEnabled(false); tileAction->setEnabled(false); closeallAction->setEnabled(false); } else { windowsMenu->addSeparator(); QWidgetList windows = currentWorkspace->windowList(); for ( int i = 0; i < int(windows.count()); ++i ) { QAction* action = windowsMenu->addAction(windows.at(i)->windowTitle()); action->setChecked(currentWorkspace->activeWindow() == windows.at(i)); action->setData(QVariant(i)); } } }
void WindowMenu::onAboutToShow() { QWidget* win = QApplication::activeWindow(); pMinimize_->setEnabled(win); pZoom_->setEnabled(win && win->maximumSize() != win->minimumSize()); pBringAllToFront_->setEnabled(win); for (int i = windows_.size() - 1; i >= 0; i--) { QAction* pAction = windows_[i]; removeAction(pAction); windows_.removeAt(i); pAction->deleteLater(); } QWidgetList topLevels = QApplication::topLevelWidgets(); for (int i = 0; i < topLevels.size(); i++) { QWidget* pWindow = topLevels.at(i); if (!pWindow->isVisible()) continue; QAction* pAction = new QAction(pWindow->windowTitle(), pWindow); pAction->setData(QVariant::fromValue(pWindow)); pAction->setCheckable(true); if (pWindow->isActiveWindow()) pAction->setChecked(true); insertAction(pWindowPlaceholder_, pAction); connect(pAction, SIGNAL(triggered()), this, SLOT(showWindow())); windows_.append(pAction); } }
QWidgetList QAccessibleAbstractScrollArea::accessibleChildren() const { QWidgetList children; // Viewport. QWidget * viewport = abstractScrollArea()->viewport(); if (viewport) children.append(viewport); // Horizontal scrollBar container. QScrollBar *horizontalScrollBar = abstractScrollArea()->horizontalScrollBar(); if (horizontalScrollBar && horizontalScrollBar->isVisible()) { children.append(horizontalScrollBar->parentWidget()); } // Vertical scrollBar container. QScrollBar *verticalScrollBar = abstractScrollArea()->verticalScrollBar(); if (verticalScrollBar && verticalScrollBar->isVisible()) { children.append(verticalScrollBar->parentWidget()); } // CornerWidget. QWidget *cornerWidget = abstractScrollArea()->cornerWidget(); if (cornerWidget && cornerWidget->isVisible()) children.append(cornerWidget); return children; }
void QWidgetPrivate::raise_sys() { Q_Q(QWidget); //@@@ transaction if (q->isWindow()) { Q_ASSERT(q->testAttribute(Qt::WA_WState_Created)); QWidget::qwsDisplay()->setAltitude(q->internalWinId(), QWSChangeAltitudeCommand::Raise); // XXX: subsurfaces? #ifdef QT_NO_WINDOWGROUPHINT #else QObjectList childObjects = q->children(); if (!childObjects.isEmpty()) { QWidgetList toraise; for (int i = 0; i < childObjects.size(); ++i) { QObject *obj = childObjects.at(i); if (obj->isWidgetType()) { QWidget* w = static_cast<QWidget*>(obj); if (w->isWindow()) toraise.append(w); } } for (int i = 0; i < toraise.size(); ++i) { QWidget *w = toraise.at(i); if (w->isVisible()) w->raise(); } } #endif // QT_NO_WINDOWGROUPHINT } }
void RemoveStackPageAction::slotTriggered() { if ( !KexiUtils::objectIsA(m_receiver, "QStackedWidget") && /* compat */ !KexiUtils::objectIsA(m_receiver, "QWidgetStack")) { return; } QStackedWidget *stack = qobject_cast<QStackedWidget*>(m_receiver); QWidget *page = stack->currentWidget(); QWidgetList list; list.append(page); KFormDesigner::Command *com = new KFormDesigner::DeleteWidgetCommand(*m_container->form(), list); // raise prev/next widget int index = stack->indexOf(page); if (index > 0) { index--; } else if (index < (stack->count()-1)) { index++; } else { index = -1; } if (index >= 0) { stack->setCurrentIndex(index); } stack->removeWidget(page); m_container->form()->addCommand(com); }
/*! \reimp */ int QAccessibleWidget::indexOfChild(const QAccessibleInterface *child) const { if (!child) return -1; QWidgetList cl = childWidgets(widget()); return cl.indexOf(qobject_cast<QWidget *>(child->object())); }
QWidget * KvsObject_wrapper::findTopLevelWidgetToWrap(const QString &szClass,const QString &szName,bool bRecursive) { QWidgetList list = g_pApp->topLevelWidgets(); if(list.isEmpty()) return NULL; Q_FOREACH(QWidget * w,list) { //qDebug("TLW: %s::%s (look for %s::%s)",w->metaObject()->className(),w->objectName().toUtf8().data(),szClass.toUtf8().data(),szName.toUtf8().data()); if( ( szClass.isEmpty() || KviQString::equalCI(w->metaObject()->className(),szClass) ) && ( szName.isEmpty() || KviQString::equalCI(w->objectName(),szName) ) ) return w; } if(bRecursive) { Q_FOREACH(QWidget * w,list) { w = findWidgetToWrap(szClass,szName,w,bRecursive); if(w) return w; } }
void pieDialog::pickBackgroundColor() { QColor c = QColorDialog::getColor(boxBackgroundColor->color(), this); if ( !c.isValid() || c == boxBackgroundColor->color() ) return; boxBackgroundColor->setColor ( c ) ; if (boxAll->isChecked()) { QWidgetList* allPlots = mPlot->graphPtrs(); for (int i=0; i<(int)allPlots->count();i++) { Graph* g=(Graph*)allPlots->at(i); if (g) g->setBackgroundColor(c); } } else { Graph* g = (Graph*)mPlot->activeGraph(); if (g) g->setBackgroundColor(c); } if (c == QColor(white) && mPlot->hasOverlapingLayers()) mPlot->updateTransparency(); }
bool QLuaApplication::event(QEvent *e) { if (e->type() == QEvent::FileOpen) { QString f = static_cast<QFileOpenEvent*>(e)->file(); d->filesToOpen.append(f); emit fileOpenEvent(); return true; } else if (e->type() == QEvent::Close) { // carefully close all windows bool okay = true; QSet<QWidget*> closed; QWidgetList wl = topLevelWidgets(); while (okay && wl.size()) { QWidget *w = wl.takeFirst(); if (w == 0 || !w->isVisible() || w->windowType() == Qt::Desktop || closed.contains(w) ) continue; closed += w; okay = w->close(); wl = topLevelWidgets(); } // accept event on success e->setAccepted(okay); return true; } return QApplication::event(e); }
void ComplexplotWrapper::addToWindowSlot(QString window, int row, int column) { if(destroyed_) return; if(window != "") { QWidgetList widgets = qApp->topLevelWidgets(); for(QWidgetList::iterator i = widgets.begin(); i != widgets.end(); ++i) { if ((*i)->objectName() == window) { QGridLayout *l = (QGridLayout*)(*i)->layout(); if(row<0) row = l->count()/3; if(column<0) column = l->count()%3; l->addWidget(widget_, row, column); return; } } QWidget *p = new QWidget(); p->setObjectName(window); QGridLayout *layout = new QGridLayout(); p->setLayout(layout); if(row<0) row = 0; if(column<0) column = 0; layout->addWidget(widget_, row, column); p->show(); } }
void pieDialog::pickBorderColor() { QColor c = QColorDialog::getColor(boxBorderColor->color(), this); if ( !c.isValid() || c == boxBorderColor->color() ) return; boxBorderColor->setColor ( c ) ; if (boxAll->isChecked()) { QWidgetList* allPlots = mPlot->graphPtrs(); for (int i=0; i<(int)allPlots->count();i++) { Graph* g=(Graph*)allPlots->at(i); if (g) g->drawBorder(boxBorderWidth->value(), c); } } else { Graph* g = (Graph*)mPlot->activeGraph(); if (g) g->drawBorder(boxBorderWidth->value(), c); } }
void QStackedWidgetEventFilter::changeOrder() { QDesignerFormWindowInterface *fw = QDesignerFormWindowInterface::findFormWindow(stackedWidget()); if (!fw) return; const QWidgetList oldPages = qdesigner_internal::OrderDialog::pagesOfContainer(fw->core(), stackedWidget()); const int pageCount = oldPages.size(); if (pageCount < 2) return; qdesigner_internal::OrderDialog dlg(fw); dlg.setPageList(oldPages); if (dlg.exec() == QDialog::Rejected) return; const QWidgetList newPages = dlg.pageList(); if (newPages == oldPages) return; fw->beginCommand(tr("Change Page Order")); for(int i=0; i < pageCount; ++i) { if (newPages.at(i) == stackedWidget()->widget(i)) continue; qdesigner_internal::MoveStackedWidgetCommand *cmd = new qdesigner_internal::MoveStackedWidgetCommand(fw); cmd->init(stackedWidget(), newPages.at(i), i); fw->commandHistory()->push(cmd); } fw->endCommand(); }
QString DiffAnalystWindow::getNextDiffSessionName() { QString defaultName = "Untitled-"; int counter = 1; QStringList nameList; QString ret = ""; QWidgetList wl = m_pWs->windowList(QWorkspace::CreationOrder); QWidgetList::iterator it = wl.begin(); QWidgetList::iterator end = wl.end(); for( ; it != end ; it++) { nameList.push_back( (*it)->name() ); } while(1) { QString pattern = QString("^")+ defaultName + QString::number(counter) + "$"; QRegExp regExp(pattern); if(nameList.grep(regExp).size() == 0) { ret = defaultName + QString::number(counter); break; }else{ counter++; } } return ret; }
void closeEvent(QCloseEvent *evt){ QWidgetList windows = ws->windowList(); for (int i = 0; i < int(windows.count()); ++i) { GLWidget *window = (GLWidget *)windows.at(i); window->stopRendering(); } QMainWindow::closeEvent(evt); }
void UIUpdateHelper::BlockAllSignals(QWidget* w, bool bBlock) { QWidgetList widgets = w->findChildren<QWidget*>(); for (int i = 0; i < widgets.size(); i++) { widgets[i]->blockSignals(bBlock); } }
static QMainWindow* getMainWindow() { QWidgetList widgets = qApp->topLevelWidgets(); for (QWidgetList::iterator i = widgets.begin(); i != widgets.end(); ++i) if ((*i)->objectName() == "MainWindow") return (QMainWindow*) (*i); return NULL; }
QWidgetList RolloutBox::widgets() const { QWidgetList W; QList<QWidget*> L = findChildren<QWidget*>(); for (int i = 0; i < L.size(); ++i) { if ((L[i] != m_toolButton) && (L[i] != m_checkBox)) W.append(L[i]); } return W; }
void WinControl::checkForEnd( ) { if(!mod->endRun() && mod->startCom()) return; tm->stop(); QWidgetList wl = qApp->topLevelWidgets(); for(int i_w = 0; i_w < wl.size(); i_w++) wl[i_w]->setProperty("forceClose",true); qApp->closeAllWindows(); }
void ReportWriterWindow::closeEvent(QCloseEvent * e) { QWidgetList wl = ws->windowList(); QWidget * w = 0; for(w = wl.first(); w; w = wl.next()) { if(!w->close()) return; } e->accept(); }
/*! \reimp */ QAccessibleInterface *QAccessibleWidget::child(int index) const { Q_ASSERT(widget()); QWidgetList childList = childWidgets(widget()); if (index >= 0 && index < childList.size()) return QAccessible::queryAccessibleInterface(childList.at(index)); return 0; }
/*! \reimp */ int QAccessibleWidget::indexOfChild(const QAccessibleInterface *child) const { QWidgetList cl = childWidgets(widget()); int index = cl.indexOf(qobject_cast<QWidget *>(child->object())); if (index != -1) ++index; return index; }
void ActionModel::setItems(QDesignerFormEditorInterface *core, QAction *action, const QIcon &defaultIcon, QStandardItemList &sl) { // Tooltip, mostly for icon view mode QString firstTooltip = action->objectName(); const QString text = action->text(); if (!text.isEmpty()) { firstTooltip += QLatin1Char('\n'); firstTooltip += text; } Q_ASSERT(sl.size() == NumColumns); QStandardItem *item = sl[NameColumn]; item->setText(action->objectName()); QIcon icon = action->icon(); if (icon.isNull()) icon = defaultIcon; item->setIcon(icon); item->setToolTip(firstTooltip); item->setWhatsThis(firstTooltip); // Used const QWidgetList associatedDesignerWidgets = associatedWidgets(action); const bool used = !associatedDesignerWidgets.empty(); item = sl[UsedColumn]; item->setCheckState(used ? Qt::Checked : Qt::Unchecked); if (used) { QString usedToolTip; const QString separator = QLatin1String(", "); const int count = associatedDesignerWidgets.size(); for (int i = 0; i < count; i++) { if (i) usedToolTip += separator; usedToolTip += associatedDesignerWidgets.at(i)->objectName(); } item->setToolTip(usedToolTip); } else { item->setToolTip(QString()); } // text item = sl[TextColumn]; item->setText(action->text()); item->setToolTip(action->text()); // shortcut const QString shortcut = actionShortCut(core, action).value().toString(QKeySequence::NativeText); item = sl[ShortCutColumn]; item->setText(shortcut); item->setToolTip(shortcut); // checkable sl[CheckedColumn]->setCheckState(action->isCheckable() ? Qt::Checked : Qt::Unchecked); // ToolTip. This might be multi-line, rich text QString toolTip = action->toolTip(); item = sl[ToolTipColumn]; item->setToolTip(toolTip); item->setText(toolTip.replace(QLatin1Char('\n'), QLatin1Char(' '))); }