void EditorApplication::initialize(const std::string& configPath) { mEditorConfigPath = configPath; if(!readJson(configPath, mConfig)) { LOG(ERROR) << "Failed to read editor config file: \"" << configPath; QCoreApplication::exit(); } auto projectManagerConfig = mConfig.get<DataProxy>("projectManager"); if(!projectManagerConfig.second) { LOG(ERROR) << "No projectManager configs found in config file"; QCoreApplication::exit(); } if(!mProjectManager->initialize(projectManagerConfig.first)) { LOG(ERROR) << "Failed to initialize project manager"; QCoreApplication::exit(); } rootContext()->setContextProperty("editor", this); rootContext()->setContextProperty("projectManager", mProjectManager); emit(initializedEngine()); }
QStandardItemModel *ConversationData::makeContextModel( QMap<int, QStandardItem *> &items, bool editable) { auto ret = new QStandardItemModel(); auto rootItem = new QStandardItem(); rootItem->setText("Root context"); rootItem->setEditable(false); rootItem->setDragEnabled(false); rootItem->setDropEnabled(editable); rootItem->setData(rootContext()->id(), IDData); ret->invisibleRootItem()->appendRow(rootItem); items[rootContext()->id()] = rootItem; for(auto con : m_contexts) { if(items.contains(con->id())) continue; auto item = new QStandardItem(); item->setData(con->id(), IDData); item->setText(con->label()); item->setEditable(editable); item->setDragEnabled(editable); item->setDropEnabled(editable); items[con->id()] = item; } for(auto con : m_contexts) { if(!con->parent()) continue; items[con->parent()->id()]->appendRow(items[con->id()]); } // TODO: sort the elements in the tree return ret; }
void squeezeLiteGui::loadMusicScreen(void) { if( !controlHierarchy.contains("MusicScreen")) { ControlListModel *model = new ControlListModel(this); model->appendRow(new ControlListItem("Artists", QString("http://")+SqueezeBoxServerAddress+QString(":")+SqueezeBoxServerHttpPort+QString("/html/images/artists_40x40.png"), model)); model->appendRow(new ControlListItem("Albums", QString("http://")+SqueezeBoxServerAddress+QString(":")+SqueezeBoxServerHttpPort+QString("/html/images/albums_40x40.png"), model)); model->appendRow(new ControlListItem("Genres", QString("http://")+SqueezeBoxServerAddress+QString(":")+SqueezeBoxServerHttpPort+QString("/html/images/genres_40x40.png"), model)); model->appendRow(new ControlListItem("Years", QString("http://")+SqueezeBoxServerAddress+QString(":")+SqueezeBoxServerHttpPort+QString("/html/images/years_40x40.png"), model)); model->appendRow(new ControlListItem("New Music", QString("http://")+SqueezeBoxServerAddress+QString(":")+SqueezeBoxServerHttpPort+QString("/html/images/newmusic_40x40.png"), model)); model->appendRow(new ControlListItem("Random Mix", QString("http://")+SqueezeBoxServerAddress+QString(":")+SqueezeBoxServerHttpPort+QString("/plugins/RandomPlay/html/images/icon_40x40.png"), model)); model->appendRow(new ControlListItem("Music Folder", QString("http://")+SqueezeBoxServerAddress+QString(":")+SqueezeBoxServerHttpPort+QString("/html/images/musicfolder_40x40.png"), model)); model->appendRow(new ControlListItem("Playlists", QString("http://")+SqueezeBoxServerAddress+QString(":")+SqueezeBoxServerHttpPort+QString("/html/images/playlists_40x40.png"), model)); model->appendRow(new ControlListItem("Search", QString("http://")+SqueezeBoxServerAddress+QString(":")+SqueezeBoxServerHttpPort+QString("/html/images/search_40x40.png"), model)); controlHierarchy.insert("MusicScreen", model); rootContext()->setContextProperty("controlListModel", model); } else { rootContext()->setContextProperty("controlListModel", controlHierarchy["MusicScreen"]); } }
DeclarativeWindow::DeclarativeWindow (const QUrl& url, QVariantMap params, const QPoint& orig, ViewManager *viewMgr, ICoreProxy_ptr proxy, QWidget *parent) : QDeclarativeView (parent) { new Util::AutoResizeMixin (orig, [viewMgr] () { return viewMgr->GetFreeCoords (); }, this); if (!params.take ("keepOnFocusLeave").toBool ()) new Util::UnhoverDeleteMixin (this, SLOT (beforeDelete ())); setStyleSheet ("background: transparent"); setWindowFlags (Qt::Tool | Qt::FramelessWindowHint); setAttribute (Qt::WA_TranslucentBackground); for (const auto& cand : Util::GetPathCandidates (Util::SysPath::QML, "")) engine ()->addImportPath (cand); rootContext ()->setContextProperty ("colorProxy", new Util::ColorThemeProxy (proxy->GetColorThemeManager (), this)); for (const auto& key : params.keys ()) rootContext ()->setContextProperty (key, params [key]); engine ()->addImageProvider ("ThemeIcons", new Util::ThemeImageProvider (proxy)); setSource (url); connect (rootObject (), SIGNAL (closeRequested ()), this, SLOT (deleteLater ())); }
StatesEditorWidget::StatesEditorWidget(StatesEditorView *statesEditorView, StatesEditorModel *statesEditorModel) : QQuickWidget(), m_statesEditorView(statesEditorView), m_imageProvider(0), m_qmlSourceUpdateShortcut(0) { m_imageProvider = new Internal::StatesEditorImageProvider; m_imageProvider->setNodeInstanceView(statesEditorView->nodeInstanceView()); engine()->addImageProvider(QStringLiteral("qmldesigner_stateseditor"), m_imageProvider); engine()->addImportPath(qmlSourcesPath()); m_qmlSourceUpdateShortcut = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_F4), this); connect(m_qmlSourceUpdateShortcut, SIGNAL(activated()), this, SLOT(reloadQmlSource())); setResizeMode(QQuickWidget::SizeRootObjectToView); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); rootContext()->setContextProperty(QStringLiteral("statesEditorModel"), statesEditorModel); rootContext()->setContextProperty(QLatin1String("canAddNewStates"), true); Theming::insertTheme(&m_themeProperties); rootContext()->setContextProperty(QLatin1String("creatorTheme"), &m_themeProperties); Theming::registerIconProvider(engine()); setWindowTitle(tr("States", "Title of Editor widget")); // init the first load of the QML UI elements reloadQmlSource(); }
GreeterWindow::GreeterWindow(QWidget *parent) : QDeclarativeView(parent), m_greeter(new GreeterWrapper(this)) { setResizeMode(QDeclarativeView::SizeRootObjectToView); KDeclarative kdeclarative; kdeclarative.setDeclarativeEngine(engine()); kdeclarative.initialize(); //binds things like kconfig and icons kdeclarative.setupBindings(); KConfig config(LIGHTDM_CONFIG_DIR "/lightdm-kde-greeter.conf"); KConfigGroup configGroup = config.group("greeter"); QString theme = configGroup.readEntry("theme-name", "userbar"); QStringList dirs = KGlobal::dirs()->findDirs("appdata", "themes/"); Plasma::PackageStructure::Ptr packageStructure(new LightDMPackageStructure(this)); Plasma::Package package(dirs.last() + "/" + theme, packageStructure); if (!package.isValid()) { kError() << theme << " is not a valid theme. Falling back to \"userbar\" theme."; package = Plasma::Package(dirs.last() + "/" + "userbar", packageStructure); } if (!package.isValid()) { kFatal() << "Cannot find QML file for \"userbar\" theme. Something is wrong with this installation. Aborting."; } KGlobal::locale()->insertCatalog("lightdm_theme_" + theme); rootContext()->setContextProperty("config", new ConfigWrapper(package.filePath("configfile"), this)); rootContext()->setContextProperty("greeter", m_greeter); setSource(package.filePath("mainscript")); // Prevent screen flickering when the greeter starts up. This really needs to be sorted out in QML/Qt... setAttribute(Qt::WA_OpaquePaintEvent); setAttribute(Qt::WA_NoSystemBackground); // Shortcut to take a screenshot of the screen. Handy because it is not // possible to take a screenshot of the greeter in test mode without // including the cursor. QShortcut* cut = new QShortcut(this); cut->setKey(Qt::CTRL + Qt::ALT + Qt::Key_S); connect(cut, SIGNAL(activated()), SLOT(screenshot())); connect(m_greeter, SIGNAL(aboutToLogin()), SLOT(setRootImage())); QRect screen = QApplication::desktop()->rect(); setGeometry(screen); new PowerManagement(this); }
void App::startup() { qmlRegisterType<Fixture>("com.qlcplus.classes", 1, 0, "Fixture"); qmlRegisterType<Function>("com.qlcplus.classes", 1, 0, "Function"); qmlRegisterType<ModelSelector>("com.qlcplus.classes", 1, 0, "ModelSelector"); setTitle("Q Light Controller Plus"); setIcon(QIcon(":/qlcplus.png")); QFontDatabase::addApplicationFont(":/RobotoCondensed-Regular.ttf"); rootContext()->setContextProperty("qlcplus", this); initDoc(); //connect(m_doc, SIGNAL(loaded()), // this, SIGNAL(docLoadedChanged())); //qmlRegisterType<App>("com.qlcplus.app", 1, 0, "App"); m_ioManager = new InputOutputManager(m_doc); rootContext()->setContextProperty("ioManager", m_ioManager); m_fixtureBrowser = new FixtureBrowser(this, m_doc); rootContext()->setContextProperty("fixtureBrowser", m_fixtureBrowser); m_fixtureManager = new FixtureManager(this, m_doc); rootContext()->setContextProperty("fixtureManager", m_fixtureManager); m_functionManager = new FunctionManager(this, m_doc); rootContext()->setContextProperty("functionManager", m_functionManager); m_contextManager = new ContextManager(this, m_doc, m_fixtureManager, m_functionManager); rootContext()->setContextProperty("contextManager", m_contextManager); m_virtualConsole = new VirtualConsole(this, m_doc); rootContext()->setContextProperty("virtualConsole", m_virtualConsole); m_showManager = new ShowManager(this, m_doc); rootContext()->setContextProperty("showManager", m_showManager); // register an uncreatable type just to use the enums in QML qmlRegisterUncreatableType<ShowManager>("com.qlcplus.classes", 1, 0, "ShowManager", "Can't create a ShowManager !"); m_actionManager = new ActionManager(this, m_functionManager, m_showManager, m_virtualConsole); rootContext()->setContextProperty("actionManager", m_actionManager); // register an uncreatable type just to use the enums in QML qmlRegisterUncreatableType<ActionManager>("com.qlcplus.classes", 1, 0, "ActionManager", "Can't create an ActionManager !"); // Start up in non-modified state m_doc->resetModified(); // and here we go ! setSource(QUrl("qrc:/MainView.qml")); //m_contextManager->activateContext("2D"); }
Window::Window(QWindow *parent) : SceneGraph::Window(parent), m_environment(this), m_game(rootItem()) { qmlRegisterUncreatableType<Environment>("Environment", 1, 0, "Environment", "Uncreatable type!"); rootContext()->setContextProperty("app", &m_environment); rootContext()->setContextProperty("world", m_game.view()->world()->object()); m_game.view()->world()->mainAction()->registerUserInterface(rootContext()); setSource(QUrl("qrc:/UserInterface/main.qml")); setResizeMode(SizeRootObjectToView); connect(engine(), &QQmlEngine::quit, this, &QQuickView::close); }
int main(int argc, char *argv[]) { qmlRegisterType<Recorder>("harbour.recorder", 1, 0, "Recorder"); qmlRegisterType<DirectoryModel>("harbour.recorder", 1, 0, "DirectoryModel"); auto app = SailfishApp::application(argc, argv); QCoreApplication::setOrganizationName("harbour-recorder"); QCoreApplication::setOrganizationDomain("www.corne.info"); QCoreApplication::setApplicationName("Recorder"); auto view = SailfishApp::createView(); auto context = view->rootContext(); Recorder recorder; context->setContextProperty("recorder", &recorder); RecordingsModel sourceModel; sourceModel.setRecorder(&recorder); QSortFilterProxyModel recordingsModel; recordingsModel.setSourceModel(&sourceModel); recordingsModel.setSortRole(RecordingsModel::Modified); recordingsModel.setDynamicSortFilter(true); recordingsModel.sort(0, Qt::DescendingOrder); context->setContextProperty("recordingsModel", &recordingsModel); view->setSource(SailfishApp::pathTo("qml/harbour-recorder.qml")); view->show(); return app->exec(); }
void MainWindow::getGroups() { qDebug() << " GET GROUPS FROM QML "; QUrl current("https://api.vk.com/method/groups.get"); QUrlQuery query; query.addQueryItem("v","5.2"); query.addQueryItem("access_token",Token); query.addQueryItem("user_id","138685584"); query.addQueryItem("extended","1"); query.addQueryItem("count","1000"); query.addQueryItem("fields","members_count"); current.setQuery(query); QByteArray answer = GET(current); QVariantList List = JSON::parse(answer).toMap().value("response").toMap().value("items").toList(); // parse to list of objects Audio /*GET Audio QString du; for (int i=0; i<List.size(); i++) { QVariantMap current = List[i].toMap(); du = current.value("url").toString(); qDebug() << current.value("url").toString(); qDebug() << current.value("id").toString(); qDebug() << current.value("title").toString(); } */ QQmlContext* context = rootContext(); groupModel = new GroupModel(); for (int i=0; i<List.size(); i++) { QVariantMap current = List[i].toMap(); groupModel->addGroup(Group(current.value("name").toString(),current.value("type").toString(),current.value("photo_50").toString(),current.value("members_count").toString(),current.value("id").toString())); /*QVariantList attachments = current.value("attachments").toList(); for (int k=0; k<attachments.size(); k++) { QVariantMap cur = attachments[k].toMap(); if (cur.value("type").toString() == "audio") { qDebug() << "Audio"; qDebug() << cur.value("audio").toMap().value("url").toString(); links.append(cur.value("audio").toMap().value("url").toString()); } }*/ } context->setContextProperty("groupModel", groupModel); //if success loaded data if (1){ wallObj = rootObject(); QMetaObject::invokeMethod((QObject*)wallObj, "showGroupList"); } }
void MainWindow::buttonClicked() { rootContext()->setContextProperty(TAG_MODEL, QVariant()); if (reply_) { if (reply_->isRunning()) { disconnect(reply_, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(error(QNetworkReply::NetworkError))); disconnect(reply_, SIGNAL(finished()), this, SLOT(finished())); reply_->abort(); } reply_->deleteLater(); reply_ = nullptr; } QUrl url(GITHUB_API); QNetworkRequest request(url); request.setRawHeader("Accept", "application/json"); reply_ = manager_.get(request); connect(reply_, SIGNAL(error(QNetworkReply::NetworkError)), SLOT(error(QNetworkReply::NetworkError))); connect(reply_, SIGNAL(finished()), SLOT(finished())); }
MainWidget::MainWidget(QWidget *parent) : QDeclarativeView(parent) { // Switch to fullscreen in device #if defined(Q_OS_SYMBIAN) || defined(Q_WS_MAEMO_5) setWindowState(Qt::WindowFullScreen); #endif setResizeMode(QDeclarativeView::SizeRootObjectToView); // Register Tile to be available in QML qmlRegisterType<Tile>("gameCore", 1, 0, "Tile"); // Setup context m_context = rootContext(); m_context->setContextProperty("mainWidget", this); m_context->setContextProperty("gameData", &m_gameData); // Set view optimizations not already done for QDeclarativeView setAttribute(Qt::WA_OpaquePaintEvent); setAttribute(Qt::WA_NoSystemBackground); // Make QDeclarativeView use OpenGL backend QGLWidget *glWidget = new QGLWidget(this); setViewport(glWidget); setViewportUpdateMode(QGraphicsView::FullViewportUpdate); // Open root QML file setSource(QUrl(filename)); }
SystemCompositor::SystemCompositor() : VCompositor(this) , m_currentSurface(0) { // Enable the subsurface extension enableSubSurfaceExtension(); // System compositor protocol m_protocol = new SystemCompositorServer(this, QWaylandCompositor::handle()); // Allow QML to access this compositor rootContext()->setContextProperty("compositor", this); // All the screen is initially available m_availableGeometry = screen()->availableGeometry(); connect(screen(), SIGNAL(virtualGeometryChanged(QRect)), this, SIGNAL(screenGeometryChanged())); // Load the QML code setSource(QUrl("qrc:///qml/Compositor.qml")); setResizeMode(QQuickView::SizeRootObjectToView); setColor(Qt::black); winId(); connect(this, SIGNAL(windowAdded(QVariant)), rootObject(), SLOT(windowAdded(QVariant))); connect(this, SIGNAL(windowDestroyed(QVariant)), rootObject(), SLOT(windowDestroyed(QVariant))); connect(this, SIGNAL(windowResized(QVariant)), rootObject(), SLOT(windowResized(QVariant))); connect(this, SIGNAL(sceneGraphInitialized()), this, SLOT(sceneGraphInitialized()), Qt::DirectConnection); connect(this, SIGNAL(frameSwapped()), this, SLOT(frameSwapped())); }
SplashWindow::SplashWindow(bool testing) : QDeclarativeView(), m_stage(0), m_testing(testing) { setWindowFlags( Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint ); if (m_testing) { setWindowState(Qt::WindowFullScreen); } else { setWindowFlags(Qt::X11BypassWindowManagerHint); } rootContext()->setContextProperty("screenSize", size()); setSource(QUrl(themeDir(QApplication::arguments().at(1)) + "/main.qml")); setStyleSheet("background: #000000; border: none"); setAttribute(Qt::WA_OpaquePaintEvent); setAttribute(Qt::WA_NoSystemBackground); //be sure it will be eventually closed //FIXME: should never be stuck QTimer::singleShot(30000, this, SLOT(close())); }
void ConversationData::serialize(QXmlStreamWriter &xml) { xml.writeStartElement("data"); xml.writeStartElement("character-names"); for(auto n : m_characterNames) { xml.writeStartElement("character"); xml.writeAttribute("name", n); xml.writeEndElement(); // </character> } xml.writeEndElement(); // </character-names> xml.writeStartElement("contexts"); xml.writeAttribute("root", QString().setNum(rootContext()->id())); for(auto n : m_contexts) { xml.writeStartElement("context"); xml.writeAttribute("id", QString().setNum(n->id())); xml.writeAttribute("label", n->label()); if(!n->parent().isNull()) xml.writeAttribute("parent", QString().setNum(n->parent()->id())); xml.writeEndElement(); } xml.writeEndElement(); // </contexts> xml.writeEndElement(); // </data> }
InitQML::InitQML(QWidget *MainW,QWidget *parent) : QDeclarativeView(parent),mainW(MainW) { resetDone = false; QPalette pal = palette(); pal.setColor(QPalette::Window,QColor("black")); // setAutoFillBackground(true); pal.setColor( QPalette::Background, Qt::transparent); setPalette(pal); rip = new ResourceImageProvider(QDeclarativeImageProvider::Pixmap); rip->mainW = mainW; engine()->addImageProvider("background",rip); setSource(QUrl("qrc:/qml/init.qml")); QDeclarativeContext *context = rootContext(); context->setContextProperty("backgroundColor", QPalette().color(QPalette::Window)); QGraphicsObject *object = this->rootObject(); QObject *rect = object->findChild<QObject*>("imageRect"); /* if (!rect) qDebug() <<"Image Rect not found !!!!!!" << __FILE__ << __LINE__; else { rect->setProperty("src",); */ }
ResizeAwareQuickWidget::ResizeAwareQuickWidget(QWidget *parent) : QQuickWidget(parent), theButtonHeight(theButtonHeightPix), theButtonIconSize(theButtonIconPix), theWorldWidthInMeters(1.0), theWorldHeightInMeters(1.0), thePixPerMeter(100), theGameViewPtr(nullptr) { // Enable objects in the QML world to see our properties. rootContext()->setContextProperty(QStringLiteral("ResizeInfo"), this); // TODO/FIXME: Does this belong here??? qmlRegisterType<ViewItem>("TBEView", 1, 0, "ViewItem"); qmlRegisterType<ViewResizeRotateMoveUndo>("TBEView", 1, 0, "ViewResizeRotateMoveUndo"); qmlRegisterType<ViewWorldItem>("TBEView", 1, 0, "ViewWorldItem"); qmlRegisterType<GameQControls>("TBEView", 1, 0, "GameQControls"); // Pre-calculate the handle sizes, they normally won't change during play... QScreen* myQScreenPtr = QApplication::primaryScreen(); assert (myQScreenPtr != nullptr); theHandleHeight = theHandleSizeMM / 25.4 * myQScreenPtr->physicalDotsPerInchX(); if (theHandleHeight < theHandleMinPix) theHandleHeight = theHandleMinPix; theHandleWidth = theHandleSizeMM / 25.4 * myQScreenPtr->physicalDotsPerInchY(); if (theHandleWidth < theHandleMinPix) theHandleWidth = theHandleMinPix; }
Window::Window(QWindow *parent) : SceneGraph::Window(parent), m_environment(this), m_game(rootItem()) { rootContext()->setContextProperty("app", &m_environment); rootContext()->setContextProperty("world", m_game.view()->world()->object()); rootContext()->setContextProperty("player", m_game.view()->world()->player()->object()); m_game.view()->world()->mainAction()->registerUserInterface(rootContext()); setSource(QUrl("qrc:/UserInterface/main.qml")); setResizeMode(SizeRootObjectToView); connect(engine(), &QQmlEngine::quit, this, &QQuickView::close); connect(this, &Window::sceneGraphInitialized, this, &Window::onSceneGraphInitialized); connect(this, &Window::sceneGraphInvalidated, this, &Window::onSceneGraphInvalidated); }
TabUnhideListView::TabUnhideListView (const QList<TabClassInfo>& tcs, ICoreProxy_ptr proxy, QWidget *parent) : QDeclarativeView (parent) , Model_ (new UnhideListModel (this)) { new Util::UnhoverDeleteMixin (this); const auto& file = Util::GetSysPath (Util::SysPath::QML, "sb2", "TabUnhideListView.qml"); if (file.isEmpty ()) { qWarning () << Q_FUNC_INFO << "file not found"; deleteLater (); return; } setStyleSheet ("background: transparent"); setWindowFlags (Qt::ToolTip); setAttribute (Qt::WA_TranslucentBackground); rootContext ()->setContextProperty ("unhideListModel", Model_); rootContext ()->setContextProperty ("colorProxy", new Util::ColorThemeProxy (proxy->GetColorThemeManager (), this)); engine ()->addImageProvider ("ThemeIcons", new ThemeImageProvider (proxy)); setSource (QUrl::fromLocalFile (file)); for (const auto& tc : tcs) { auto item = new QStandardItem; item->setData (tc.TabClass_, UnhideListModel::Roles::TabClass); item->setData (tc.VisibleName_, UnhideListModel::Roles::TabName); item->setData (tc.Description_, UnhideListModel::Roles::TabDescription); item->setData (Util::GetAsBase64Src (tc.Icon_.pixmap (32, 32).toImage ()), UnhideListModel::Roles::TabIcon); Model_->appendRow (item); } connect (rootObject (), SIGNAL (closeRequested ()), this, SLOT (deleteLater ())); connect (rootObject (), SIGNAL (tabUnhideRequested (QString)), this, SLOT (unhide (QString)), Qt::QueuedConnection); }
void PopWindow::init() { resize(1, 1); setStyleSheet("background-color:transparent"); setWindowFlags(Qt::Window | Qt::FramelessWindowHint); setAttribute(Qt::WA_TranslucentBackground); rootContext()->setContextProperty("window", this); }
MailListView::MailListView (const ConvInfos_t& infos, ICoreProxy_ptr proxy, QWidget *parent) : QQuickWidget (parent) , Model_ (new MailListModel (this)) { new Util::UnhoverDeleteMixin (this); const auto& file = Util::GetSysPath (Util::SysPath::QML, "gmailnotifier", "MailListView.qml"); if (file.isEmpty ()) { qWarning () << Q_FUNC_INFO << "file not found"; deleteLater (); return; } const auto& now = QDateTime::currentDateTime (); for (const auto& info : infos) { auto item = new QStandardItem; item->setData (info.Title_, MailListModel::Roles::Subject); item->setData (info.AuthorEmail_, MailListModel::Roles::AuthorEmail); item->setData (info.AuthorName_, MailListModel::Roles::AuthorName); item->setData (info.Summary_, MailListModel::Roles::Summary); QString dateString; if (info.Modified_.secsTo (now) < 12 * 60 * 60) dateString = info.Modified_.time ().toString ("hh:mm"); else if (now.date ().day () == info.Modified_.date ().day () - 1) dateString = tr ("Yesterday, %1").arg (info.Modified_.time ().toString ()); else if (now.date ().year () == info.Modified_.date ().year ()) dateString = info.Modified_.date ().toString ("d MMM"); else dateString = info.Modified_.date ().toString (Qt::DefaultLocaleShortDate); item->setData (dateString, MailListModel::Roles::ModifiedDate); Model_->appendRow (item); } setStyleSheet ("background: transparent"); setWindowFlags (Qt::ToolTip); setAttribute (Qt::WA_TranslucentBackground); rootContext ()->setContextProperty ("mailListModel", Model_); rootContext ()->setContextProperty ("colorProxy", new Util::ColorThemeProxy (proxy->GetColorThemeManager (), this)); setSource (QUrl::fromLocalFile (file)); }
TooltipView::TooltipView (QAbstractItemModel *model, IColorThemeManager *manager, QWidget *parent) : QDeclarativeView (parent) , UnhoverDeleter_ (new Util::UnhoverDeleteMixin (this, SLOT (hide ()))) { setStyleSheet ("background: transparent"); setWindowFlags (Qt::ToolTip); setAttribute (Qt::WA_TranslucentBackground); rootContext ()->setContextProperty ("infoModel", model); rootContext ()->setContextProperty ("colorProxy", new Util::ColorThemeProxy (manager, this)); for (const auto& cand : Util::GetPathCandidates (Util::SysPath::QML, "")) engine ()->addImportPath (cand); setSource (QUrl::fromLocalFile (Util::GetSysPath (Util::SysPath::QML, "tpi", "Tooltip.qml"))); }
View::View(const QCommandLineParser &parser, QWindow *parent) : QQuickView(parent), m_settingsRoot(0) { Plasma::Theme theme(this); theme.setUseGlobalSettings(true); const QString package = parser.value("layout"); const QString module = parser.value("module"); const QString formFactor = parser.value("formfactor"); setResizeMode(QQuickView::SizeRootObjectToView); QQuickWindow::setDefaultAlphaBuffer(true); setIcon(QIcon::fromTheme("preferences-desktop")); setTitle(i18n("Active Settings")); KDeclarative::KDeclarative kdeclarative; kdeclarative.setDeclarativeEngine(engine()); kdeclarative.initialize(); //binds things like kconfig and icons kdeclarative.setupBindings(); m_package = Plasma::PluginLoader::self()->loadPackage("Plasma/Generic"); if (!package.isEmpty()) { m_package.setPath(package); } else { m_package.setPath("org.kde.active.settings"); } setIcon(QIcon::fromTheme(m_package.metadata().icon())); setTitle(m_package.metadata().name()); rootContext()->setContextProperty("startModule", module); rootContext()->setContextProperty("startFormFactor", formFactor); const QString qmlFile = m_package.filePath("mainscript"); //qDebug() << "mainscript: " << QUrl::fromLocalFile(m_package.filePath("mainscript")); setSource(QUrl::fromLocalFile(m_package.filePath("mainscript"))); show(); onStatusChanged(status()); connect(this, &QQuickView::statusChanged, this, &View::onStatusChanged); }
MainQmlView::MainQmlView() { m_rootContext = rootContext(); m_model = m_solver.rootsModel(); inflateObjects(); loadTypes(); load(QUrl("qrc:/qml/Main.qml")); }
ConfigurationView::ConfigurationView(QWidget* parent) : QDeclarativeView(parent), model() { qmlRegisterType<ConfigurationWidget>("Configuration", 1, 0, "ConfigurationWidget"); qmlRegisterType<ConfigurationModel>("Configuration", 1, 0, "ConfigurationModel"); qmlRegisterType<ConfigurationItem>("Configuration", 1, 0, "ConfigurationItem"); ConfigurationWidget::loadWidgets(engine()); rootContext()->setContextProperty("configurationModel", &model); }
void squeezeLiteGui::loadNowPlayingScreen(void) { DEBUGF("LOAD NOW PLAYING SCREEN"); if( !controlHierarchy.contains("NowPlaying")) { updateNowPlayingScreen(); } else { rootContext()->setContextProperty("controlListModel", controlHierarchy["NowPlaying"]); } NewSong(); }
bool FeedAppEngine::start() { QStringList dataList; dataList.append("Item 1"); dataList.append("Item 2"); dataList.append("Item 3"); dataList.append("Item 4"); QQmlContext *ctxt = rootContext(); ctxt->setContextProperty("myModel", QVariant::fromValue(dataList)); load(QUrl(QStringLiteral("qrc:///main.qml"))); }
WMain::WMain(QWidget *parent) : QDeclarativeView(parent) { m_context = rootContext(); m_context->setContextProperty("wMain", this); setAttribute(Qt::WA_OpaquePaintEvent); setAttribute(Qt::WA_NoSystemBackground); setSource(QUrl("qrc:/qml/main.qml")); }
/*! Main view's constructor, full of important stuff. Sets all global properties, sizing policy, connects important signals and slots, reads config file(s). */ CcfMain::CcfMain(CcfCommandLineParser *cmd, QWindow *parent) : QQuickView(parent), CcfError(), mCmdLnParser(cmd) { qmlRegisterType<CcfQmlBaseRosterMenu>("QmlBase", 0, 1, "BaseRosterMenu"); qmlRegisterType<CcfQmlBaseScenario>("QmlBase", 0, 1, "BaseScenario"); qmlRegisterType<CcfQmlBaseMap>("QmlBase", 0, 1, "Map"); qmlRegisterType<CcfQmlBaseUnit>("QmlBase", 0, 1, "BaseUnit"); qmlRegisterType<CcfQmlBaseSoldier>("QmlBase", 0, 1, "Soldier"); mLogger = new CcfLogger(this, mCmdLnParser->isDebug()); mGlobal = new CcfGlobal(this); mGameManager = new CcfGameManager(this); mEngineHelpers = new CcfEngineHelpers(this); initConfiguration(); rootContext()->setContextProperty("Global", mGlobal); rootContext()->setContextProperty("Config", mConfiguration); rootContext()->setContextProperty("GameManager", mGameManager); rootContext()->setContextProperty("EngineHelpers", mEngineHelpers); rootContext()->setContextProperty("Logger", mLogger); QString pwd = qApp->applicationDirPath() + "/"; rootContext()->setContextProperty("PWD", pwd); setResizeMode(QQuickView::SizeRootObjectToView); // connect(this, SIGNAL(sceneResized(QSize)), configuration, SLOT(windowResized(QSize))); connect(mConfiguration, SIGNAL(sizeModifiedInGame(int,int)), this, SLOT(forceViewportResize(int,int))); connect(engine(), SIGNAL(quit()), this, SLOT(quit())); connect(mConfiguration, SIGNAL(maximise()), this, SLOT(showMaximized())); connect(mConfiguration, SIGNAL(demaximise()), this, SLOT(showNormal())); connect(mGlobal, SIGNAL(disableQrc(QObject*)), this, SLOT(disableQrc(QObject*))); }
void MainWindow::createDeclarativeView() { m_tweetListModel = new TweetQmlListModel(m_oauthTwitter); //connect user stream to tweet home timeline connect(m_userStream, SIGNAL(statusesStream(QTweetStatus)), m_tweetListModel, SLOT(onStatusesStream(QTweetStatus))); connect(m_userStream, SIGNAL(deleteStatusStream(qint64,qint64)), m_tweetListModel, SLOT(onDeleteStatusStream(qint64,qint64))); // ### TODO: Test for syncing problems connect(m_userStream, SIGNAL(reconnected()), m_tweetListModel, SLOT(fetchLastTweets())); //try using REST API when streams fails connect(m_userStream, SIGNAL(failureConnect()), m_tweetListModel, SLOT(fetchLastTweets())); m_mentionsListModel = new MentionsQmlListModel(m_oauthTwitter); connect(m_userStream, SIGNAL(statusesStream(QTweetStatus)), m_mentionsListModel, SLOT(onStatusesStream(QTweetStatus))); connect(m_userStream, SIGNAL(deleteStatusStream(qint64,qint64)), m_mentionsListModel, SLOT(onDeleteStatusStream(qint64,qint64))); connect(m_userStream, SIGNAL(reconnected()), m_mentionsListModel, SLOT(fetchLastTweets())); m_directMessagesListModel = new DirectMessagesQmlListModel(m_oauthTwitter); connect(m_userStream, SIGNAL(directMessageStream(QTweetDMStatus)), m_directMessagesListModel, SLOT(onDirectMessageStream(QTweetDMStatus))); m_searchListModel = new SearchQmlListModel(m_oauthTwitter); m_userInfo = new UserInfo; m_userInfo->setOAuthTwitter(m_oauthTwitter); connect(m_userStream, SIGNAL(friendsList(QList<qint64>)), m_userInfo, SLOT(onUserStreamFriendsList(QList<qint64>))); m_userTimelineListModel = new UserTimelineListModel(m_oauthTwitter); m_conversationListModel = new ConversationListModel(m_oauthTwitter); rootContext()->setContextProperty("hometimelineListModel", m_tweetListModel); rootContext()->setContextProperty("mentionsListModel", m_mentionsListModel); rootContext()->setContextProperty("directMessagesListModel", m_directMessagesListModel); rootContext()->setContextProperty("searchListModel", m_searchListModel); rootContext()->setContextProperty("userInfo", m_userInfo); rootContext()->setContextProperty("userTimelineListModel", m_userTimelineListModel); rootContext()->setContextProperty("conversationListModel", m_conversationListModel); rootContext()->setContextProperty("rootWindow", this); //setSource(QUrl::fromLocalFile("qml/QTwitdget/Main.qml")); setMainQmlFile(QLatin1String("qml/QTwitdget/Main.qml")); }