// from: http://stackoverflow.com/questions/5298614/change-the-size-of-qt-dialogs-depending-on-the-platform void MainWindow::adjustAppearanceToOS(QWidget *rootWidget) { int fontSize = -1; #ifdef Q_OS_WIN fontSize = 8; #elif __APPLE__ fontSize = 12; #elif __linux fontSize = 11; #endif if (rootWidget == NULL) return; QObject *child = NULL; QObjectList Containers; QObject *container = NULL; QStringList DoNotAffect; // Make an exception list (Objects not to be affected) // DoNotAffect.append("widgetName"); // Append root to containers Containers.append(rootWidget); while (!Containers.isEmpty()) { container = Containers.takeFirst(); if (container != NULL) for (int i = 0; i < container->children().size(); i++) { child = container->children()[i]; if (!child->isWidgetType() || DoNotAffect.contains(child->objectName())) continue; if (child->children().size() > 0) Containers.append(child); // (if the object is not of the correct type, it will be NULL) QLabel *label = qobject_cast<QLabel *>(child); if (label != NULL) { label->setText(label->text().replace(QRegExp("font-size:.*;"), "")); QFont font = label->font(); font.setPointSize(fontSize); label->setFont(font); } } } }
QObjectList *Project::formList( bool resolveFakeObjects ) const { QObjectList *l = new QObjectList; for ( QPtrListIterator<FormFile> forms(formfiles); forms.current(); ++forms ) { FormFile* f = forms.current(); if ( f->formWindow() ) { if ( resolveFakeObjects && f->formWindow()->isFake() ) l->append( objectForFakeForm( f->formWindow() ) ); else l->append( f->formWindow()->child( 0, "QWidget" ) ); } else if ( f->isFake() ) { l->append( objectForFakeFormFile( f ) ); } } return l; }
/* * Description : create the details of this widget. */ void IRStationDetailsView::createDetails() { setObjectName(STATION_DETAILS_VIEW_OBJECT_NAME); QObjectList roots; roots.append(this); iLoader.setObjectTree(roots); iLoader.load(STATION_DETAILS_VIEW_LAYOUT_FILENAME); HbAction *exitAction = qobject_cast<HbAction *> (iLoader.findObject(EXIT_ACTION)); connect(exitAction, SIGNAL(triggered()), iApplication, SIGNAL(quit())); // Find the station information objects iScrollArea = qobject_cast<HbScrollArea *>(iLoader.findObject(STATION_DETAILS_VIEW_OBJECT_SCROLL_AREA)); HbScrollBar *scrollbar = iScrollArea->verticalScrollBar(); scrollbar->setVisible(true); scrollbar->setInteractive(true); iScrollArea->setVerticalScrollBarPolicy(HbScrollArea::ScrollBarAsNeeded); iContainer = qobject_cast<HbWidget *> (iLoader.findObject(STATION_DETAILS_VIEW_OBJECT_SCROLLAREA_CONTENTS)); iStationName = qobject_cast<HbLabel *> (iLoader.findObject(STATION_DETAILS_VIEW_OBJECT_STATION_NAME)); iGenres = qobject_cast<HbLabel *> (iLoader.findObject(STATION_DETAILS_VIEW_OBJECT_GENRE)); iLanguage = qobject_cast<HbLabel *> (iLoader.findObject(STATION_DETAILS_VIEW_OBJECT_LANGUAGE)); iCountry = qobject_cast<HbLabel *> (iLoader.findObject(STATION_DETAILS_VIEW_OBJECT_COUNTRY)); iBitRate = qobject_cast<HbLabel *> (iLoader.findObject(STATION_DETAILS_VIEW_OBJECT_BITE_RATE)); iDescription = qobject_cast<HbLabel *> (iLoader.findObject(STATION_DETAILS_VIEW_OBJECT_DESCRIPTION)); iNowPlayingUrl = qobject_cast<HbLabel *> (iLoader.findObject(STATION_DETAILS_VIEW_OBJECT_STATION_URL)); }
BtCpUiDeviceDetailsView::BtCpUiDeviceDetailsView(QGraphicsItem *parent) :CpBaseSettingView( 0 , parent ) { mSoftKeyBackAction = new HbAction(Hb::BackNaviAction, this); BTUI_ASSERT_X(mSoftKeyBackAction, "BtCpUiDeviceDetailsView::BtCpUiDeviceDetailsView", "can't create back action"); // Create view for the application. // Set the name for the view. The name should be same as the view's // name in docml. setObjectName("bt_device_details_view"); mLoader = new HbDocumentLoader(); // Pass the view to documentloader. Document loader uses this view // when docml is parsed, instead of creating new view. QObjectList objectList; objectList.append(this); mLoader->setObjectTree(objectList); // read view info from docml file bool ok = false; mLoader->load( BTUI_DEVICEDETAILSVIEW_DOCML, &ok ); // Exit if the file format is invalid BTUI_ASSERT_X( ok, "bt-device-details-view", "Invalid docml file" ); mLayout = new QGraphicsLinearLayout(Qt::Vertical, this); mGroupBox = new HbGroupBox(); mLayout->addItem(mGroupBox); setLayout( mLayout ); }
/*! Returns a list of static plugin instances (root components) held by the plugin loader. */ QObjectList QPluginLoader::staticInstances() { QObjectList instances; StaticInstanceFunctionList *functions = staticInstanceFunctionList(); if (functions) { for (int i = 0; i < functions->count(); ++i) instances.append((*functions)[i]()); } return instances; }
// ------------------------------------------------------------------------- QObjectList JsLayer::getRoutes() { QObjectList objList; JsRoutePtrListIterator i(m_routes); while( i.hasNext() ) { objList.append( i.next().get()->getObject() ); } return objList; }
QObject* ObjectNameMapper::objectFromName(const QString& path ) const { Q_ASSERT(!path.isEmpty()); QObject* obj = 0; QStringList names = path.split(delimiter, QString::KeepEmptyParts); Q_ASSERT(names.size()>1); QStringList::const_iterator iname = names.constBegin(); ++iname; // omit allways empty first string before leading delimmiterdeli QObjectList olist; foreach (QWidget* w, QApplication::topLevelWidgets()) { olist.append(w); }
QList<GTAbstractGUIAction*> GTCrazyUserMonitor::formGUIActions(QWidget* widget) const { QList<GTAbstractGUIAction*> actionList; SAFE_POINT(NULL != widget, "", actionList); QObjectList objectList = widget->findChildren<QObject*>(); objectList.append(widget); foreach(QObject* o, objectList) { GTAbstractGUIAction* guiAction = GTRandomGUIActionFactory::create(o); if (NULL != guiAction) { actionList.append(guiAction); } }
QObjectList BookmarksController::suggestSimilar(QString suggest) { QMap<QString, QString> bookmarksMap = m_bm->findBookmarks(suggest); QMap<QString, QString> historyMap = WRT::HistoryManager::getSingleton()->findHistory(suggest); // Now combine the result QObjectList suggestions; QMapIterator<QString,QString> bhi(historyMap); while (bhi.hasNext()) { bhi.next(); suggestions.append(new Suggestion(bhi.key(), bhi.value())); } QMapIterator<QString,QString> bmi(bookmarksMap); while (bmi.hasNext()) { bmi.next(); if (historyMap.contains(bmi.key())) continue; suggestions.append(new Suggestion(bmi.key(), bmi.value())); } return suggestions; }
// all toplevel windows except popups and the desktop static QObjectList topLevelObjects() { QObjectList list; const QWindowList tlw(QGuiApplication::topLevelWindows()); for (int i = 0; i < tlw.count(); ++i) { QWindow *w = tlw.at(i); if (w->type() != Qt::Popup && w->type() != Qt::Desktop) { if (QAccessibleInterface *root = w->accessibleRoot()) { if (root->object()) list.append(root->object()); } } } return list; }
void MvcpThread::do_cls(mvcp a_mvcp, QObject* parent) { QObjectList* result = new QObjectList; mvcp_dir dir = mvcp_dir_init(a_mvcp, parent->property("path").toString().toUtf8().constData()); int n = mvcp_dir_count(dir); for (int i = 0; i < n; i++) { mvcp_dir_entry_t entry; mvcp_dir_get(dir, i, &entry); QObject* o = new QObject; o->setObjectName(QString::fromUtf8(entry.full)); o->setProperty("name", QString::fromUtf8(entry.name)); o->setProperty("dir", entry.dir); o->setProperty("size", entry.size); result->append(o); } mvcp_dir_close(dir); emit clsResult(parent, result); }
/*! Loads widgets and objects from the docml file. */ void WlanLoginView::loadDocml() { OstTraceFunctionEntry0( WLANLOGINVIEW_LOADDOCML_ENTRY ); setObjectName(QString("wlanLoginView")); QObjectList objectList; objectList.append(this); mDocLoader->setObjectTree(objectList); bool ok = false; mDocLoader->load(wlanLoginViewDocml, &ok); Q_ASSERT(ok); //Fetch pointer for progress bar mProgressBar = reinterpret_cast<HbProgressBar *>( mDocLoader->findObject("progressBar")); Q_ASSERT(mProgressBar); //Fetch pointer for scroll area content mScrollAreaContent = reinterpret_cast<HbWidget *>( mDocLoader->findObject("scrollAreaContent")); Q_ASSERT(mScrollAreaContent); //Fetch pointer for Web View mWebView = reinterpret_cast<WlanLoginWebView *>( mDocLoader->findObject("webView")); Q_ASSERT(mWebView); //Fetch pointer for cancel action mCancelAction = qobject_cast<HbAction*> ( mDocLoader->findObject("cancelAction")); Q_ASSERT(mCancelAction != NULL); //Fetch pointer for next action mNextAction = qobject_cast<HbAction*> ( mDocLoader->findObject("nextAction")); Q_ASSERT(mNextAction != NULL); OstTraceFunctionExit0( WLANLOGINVIEW_LOADDOCML_EXIT ); }
/* * Description: initializing. */ void IRNowPlayingView::initialize() { LOG_METHOD; setObjectName(NOW_PLAYING_VIEW_OBJECT_NAME); QObjectList roots; roots.append(this); iLoader.setObjectTree(roots); // Load XML file iLoader.load(NOW_PLAYING_VIEW_LAYOUT_FILENAME); initMenu(); initToolBar(); initWidget(); #ifdef SUBTITLE_STR_BY_LOCID setTitle(hbTrId("txt_irad_title_internet_radio")); #else setTitle("Internet radio"); #endif handleOrientationChanged(getViewManager()->orientation()); }
/*! \internal */ void QDeclarativeGeoMap::populateMap() { QObjectList kids = children(); QList<QQuickItem *> quickKids = childItems(); for (int i=0; i < quickKids.count(); ++i) kids.append(quickKids.at(i)); for (int i = 0; i < kids.size(); ++i) { // dispatch items appropriately QDeclarativeGeoMapItemView *mapView = qobject_cast<QDeclarativeGeoMapItemView *>(kids.at(i)); if (mapView) { m_mapViews.append(mapView); setupMapView(mapView); continue; } QDeclarativeGeoMapItemBase *mapItem = qobject_cast<QDeclarativeGeoMapItemBase *>(kids.at(i)); if (mapItem) { addMapItem(mapItem); } } }
void IRTermsConsView::initViewContents() { setObjectName(TERMS_CONS_VIEW_BASE_OBJECT_VIEW); QObjectList roots; roots.append(this); iLoader.setObjectTree(roots); iLoader.load(TERMS_CONS_VIEW_LAYOUT_FILENAME); // load correct orientation connect( getViewManager(), SIGNAL( orientationChanged(Qt::Orientation) ), this, SLOT( handleOrientationChanged(Qt::Orientation) ) ); handleOrientationChanged(getViewManager()->orientation()); HbPushButton *acceptButton = qobject_cast<HbPushButton *>(iLoader.findObject(TERMS_CONS_VIEW_ACCEPT_BTN)); HbPushButton *declineButton = qobject_cast<HbPushButton *>(iLoader.findObject(TERMS_CONS_VIEW_DECLINE_BTN)); connect( acceptButton, SIGNAL(released()), iApplication, SLOT(handleTermsConsAccepted()) ); connect( declineButton, SIGNAL(released()), iApplication, SIGNAL(quit()) ); }
static void removeObjectFromList(const QQmlProperty &property, QObject *objectToBeRemoved, QQmlEngine * engine) { QQmlListReference listReference(property.object(), property.name().toUtf8(), engine); if (!QmlPrivateGate::hasFullImplementedListInterface(listReference)) { qWarning() << "Property list interface not fully implemented for Class " << property.property().typeName() << " in property " << property.name() << "!"; return; } int count = listReference.count(); QObjectList objectList; for (int i = 0; i < count; i ++) { QObject *listItem = listReference.at(i); if (listItem && listItem != objectToBeRemoved) objectList.append(listItem); } listReference.clear(); foreach (QObject *object, objectList) listReference.append(object); }
QObjectList Snippets::getList() { QObjectList result; foreach(GVA::ChromeSnippet *snippet, m_snippetMap) { result.append(snippet); }
void QtHelpers::GenAdjustWidgetAppearanceToOS(QWidget *rootWidget) { if (rootWidget == NULL) return; QObject *child = NULL; QObjectList Containers; QObject *container = NULL; QStringList DoNotAffect; // Make an exception list (Objects not to be affected) DoNotAffect.append("aboutTitleLabel"); // about Dialog DoNotAffect.append("aboutVersionLabel"); // about Dialog DoNotAffect.append("aboutCopyrightLabel"); // about Dialog DoNotAffect.append("aboutUrlLabel"); // about Dialog DoNotAffect.append("aboutLicenseLabel"); // about Dialog // Set sizes according to OS: #ifdef __APPLE__ int ButtonHeight = 35; int cmbxHeight = 30; QFont cntrlFont("Myriad Pro", 14); QFont txtFont("Myriad Pro", 14); #elif _WIN32 // Win XP/7 int ButtonHeight = 24; int cmbxHeight = 20; QFont cntrlFont("MS Shell Dlg 2", 8); QFont txtFont("MS Shell Dlg 2", 8); #else int ButtonHeight = 24; int cmbxHeight = 24; QFont cntrlFont("Ubuntu Condensed", 10); QFont txtFont("Ubuntu", 10); #endif // Append root to containers Containers.append(rootWidget); while (!Containers.isEmpty()) { container = Containers.takeFirst(); if (container != NULL) { for (int ChIdx=0; ChIdx < container->children().size(); ChIdx++) { child = container->children()[ChIdx]; if (!child->isWidgetType() || DoNotAffect.contains(child->objectName())) continue; // Append containers to Stack for recursion if (child->children().size() > 0) Containers.append(child); else { // Cast child object to button and label // (if the object is not of the correct type, it will be NULL) QPushButton *button = qobject_cast<QPushButton *>(child); QLabel *label = qobject_cast<QLabel *>(child); QComboBox *cmbx = qobject_cast<QComboBox *>(child); QLineEdit *ln = qobject_cast<QLineEdit *>(child); QTreeWidget *tree = qobject_cast<QTreeWidget *>(child); QPlainTextEdit *plain = qobject_cast<QPlainTextEdit *>(child); QCheckBox *check = qobject_cast<QCheckBox *>(child); if (button != NULL) { button->setMinimumHeight(ButtonHeight); // Win button->setMaximumHeight(ButtonHeight); // Win button->setFont(cntrlFont); } else if (cmbx != NULL) { cmbx->setFont(cntrlFont); cmbx->setMaximumHeight(cmbxHeight); } else if (label != NULL) label->setFont(txtFont); else if (ln != NULL) ln->setFont(txtFont); else if (tree != NULL) { tree->header()->setFont(txtFont); } else if (plain != NULL) plain->setFont(txtFont); else if (check != NULL) check->setFont(txtFont); } } } } }
/*! View layout loading from XML */ void NmViewerView::loadViewLayout() { NM_FUNCTION; // Use document loader to load the view bool ok(false); setObjectName(QString(NMUI_MESSAGE_VIEWER_VIEW)); QObjectList objectList; objectList.append(this); // Pass the view to documentloader. Document loader uses this view // when docml is parsed, instead of creating new view. // documentloader is created in constructor mDocumentLoader->setObjectTree(objectList); mWidgetList = mDocumentLoader->load(NMUI_MESSAGE_VIEWER_XML, &ok); if (ok) { // Create content and content layout // qobject_cast not work in this case, using reinterpret_cast mViewerContent = reinterpret_cast<HbWidget *>( mDocumentLoader->findObject(NMUI_MESSAGE_VIEWER_CONTENT)); // Find scroll area mScrollArea = reinterpret_cast<HbScrollArea *>( mDocumentLoader->findObject(NMUI_MESSAGE_VIEWER_SCROLL_AREA)); if (mScrollArea) { mScrollArea->setParentItem(this); mScrollArea->setScrollDirections(Qt::Vertical | Qt::Horizontal); connect(mScrollArea, SIGNAL(scrollPositionChanged(QPointF)), this, SLOT(contentScrollPositionChanged(QPointF))); // Get scroll area contents and set layout margins mScrollAreaContents = qobject_cast<HbWidget *>( mDocumentLoader->findObject(NMUI_MESSAGE_VIEWER_SCROLL_AREA_CONTENTS)); if (mScrollAreaContents) { QGraphicsLayout *layout = mScrollAreaContents->layout(); if (layout){ layout->setContentsMargins(0,0,0,0); } // Set white pixmap to backgrounditem QPixmap whitePixmap(NmWhitePixmapSize,NmWhitePixmapSize); whitePixmap.fill(Qt::white); QGraphicsPixmapItem *pixmapItem = new QGraphicsPixmapItem(whitePixmap); mScrollAreaContents->setBackgroundItem(pixmapItem); } // Load headerwidget mHeaderWidget = qobject_cast<NmViewerHeader *>( mDocumentLoader->findObject(NMUI_MESSAGE_VIEWER_HEADER)); if (mHeaderWidget) { mHeaderWidget->setView(this); mHeaderWidget->rescaleHeader(mScreenSize); mHeaderWidget->setMessage(mMessage); QPointF headerStartPos = mHeaderWidget->scenePos(); mHeaderStartScenePos = QPointF(0,headerStartPos.y()); } // Load webview mWebView = reinterpret_cast<NmMailViewerWK *>( mDocumentLoader->findObject(QString(NMUI_MESSAGE_VIEWER_SCROLL_WEB_VIEW))); if (mWebView) { // Set auto load images and private browsing(no history) attributes QWebSettings *settings = mWebView->settings(); if (settings) { settings->setAttribute(QWebSettings::AutoLoadImages, true); settings->setAttribute(QWebSettings::PrivateBrowsingEnabled, true); } QWebPage *page = mWebView->page(); if (page) { QWebFrame *frame = page->mainFrame(); if (frame) { frame->setScrollBarPolicy(Qt::Vertical,Qt::ScrollBarAlwaysOff); frame->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff); frame->setTextSizeMultiplier(NmZoomFactor); connect(mWebView->page()->mainFrame(), SIGNAL(contentsSizeChanged(const QSize&)), this, SLOT(scaleWebViewWhenLoading(const QSize&))); } } } } } }
QObjectList Scenery3dStelPluginInterface::getExtensionList() const { QObjectList ret; ret.append(new Scenery3dRemoteControlService()); return ret; }