LookAlikeMainPrivate::LookAlikeMainPrivate(LookAlikeMain *q) : QObject(q), m_currentAction(0), q_ptr(q) { // Less correct the problem with the DB first of all, if no other // application has dealt with it first. m_faceRecognitionResetter = new FaceRecognitionResetter(); if (!m_faceRecognitionResetter->isDBCorrected()) { m_faceRecognitionResetter->dealWithDB(1); } m_galleryModel = new GalleryModel(this); m_galleryModel->setFaceRecognitionEnabled(true); QSparqlConnection *connection = m_galleryModel->sparqlConnection(); m_trackerProvider = new TrackerContentProvider(connection, this); m_galleryModel->addContentProvider(m_trackerProvider); m_faceDatabaseProvider = new FaceDatabaseProvider(connection, this); m_faceTrackerProvider = new FaceTrackerProvider(connection, this); m_confirmedContactsListPage = new GalleryPeopleListPage(m_faceTrackerProvider->model()); m_proposedContactsListPage = new GalleryPeopleListPage(m_faceDatabaseProvider); m_gridPage = new GalleryGridPage(*m_galleryModel); m_fullScreenPage = new GalleryFullScreenPage(*m_galleryModel); m_confirmedContactsListPage->setStyleName("GalleryPage"); m_proposedContactsListPage->setStyleName("GalleryPage"); m_gridPage->setStyleName("GalleryPage"); m_fullScreenPage->setStyleName("GalleryPage"); MAction* allTabAction = new MAction("icon-m-toolbar-all-content-white", "", q); allTabAction->setLocation(MAction::ToolBarLocation); allTabAction->setCheckable(true); MAction* confirmedContactsTabAction = new MAction("icon-m-toolbar-known-people-white", "", q); confirmedContactsTabAction->setLocation(MAction::ToolBarLocation); confirmedContactsTabAction->setCheckable(true); MAction* proposedContactsAction = new MAction("icon-m-toolbar-unknown-people-white", "", q); proposedContactsAction->setLocation(MAction::ToolBarLocation); proposedContactsAction->setCheckable(true); MAction* landscapeTabAction = new MAction("icon-m-toolbar-no-people-white", "", q); landscapeTabAction->setLocation(MAction::ToolBarLocation); landscapeTabAction->setCheckable(true); QList<QAction*> actions; actions.append(allTabAction); actions.append(confirmedContactsTabAction); actions.append(proposedContactsAction); actions.append(landscapeTabAction); MToolBar* toolbar = new MToolBar(); toolbar->setStyleName("MToolbarTabStyleInverted"); toolbar->setOpacity(0.9); toolbar->setViewType(MToolBar::tabType); toolbar->addActions(actions); m_toolbarAction = new MWidgetAction(q); m_toolbarAction->setLocation(MAction::ToolBarLocation); m_toolbarAction->setWidget(toolbar); m_confirmFaceAction = new MAction("Confirm faces", q); m_confirmFaceAction->setLocation(MAction::ApplicationMenuLocation); m_deleteFaceAction = new MAction("Delete faces", q); m_deleteFaceAction->setLocation(MAction::ApplicationMenuLocation); m_aboutAction = new MAction("About", q); m_aboutAction->setLocation(MAction::ApplicationMenuLocation); const QPixmap *pixmap = MTheme::pixmap("icon-m-toolbar-view-menu-dimmed-white"); MImageWidget *menuImage = new MImageWidget(); menuImage->setImage(pixmap->toImage()); menuImage->setZoomFactor(1.f); menuImage->setMinimumWidth(88.f); MTheme::releasePixmap(pixmap); MWidgetAction* fakeAction= new MWidgetAction(q); fakeAction->setLocation(MAction::ToolBarLocation); fakeAction->setWidget(menuImage); m_confirmedContactsListPage->addAction(m_toolbarAction); m_confirmedContactsListPage->addAction(fakeAction); m_proposedContactsListPage->addAction(m_toolbarAction); m_proposedContactsListPage->addAction(fakeAction); connect(m_confirmedContactsListPage, SIGNAL(personSelected(QString,QString)), this, SLOT(onConfirmedContactSelected(QString,QString))); connect(m_proposedContactsListPage, SIGNAL(personSelected(QString,QString)), this, SLOT(onProposedContactPersonSelected(QString,QString))); connect(m_gridPage, SIGNAL(multiSelectionDone(QList<QUrl>)), this, SLOT(onMultiSelectionDone(QList<QUrl>))); connect(m_gridPage, SIGNAL(itemSelected(QUrl)), this, SLOT(onItemSelected(QUrl))); connect(m_fullScreenPage, SIGNAL(itemDeleted(QUrl)), m_faceDatabaseProvider, SLOT(update())); connect(m_trackerProvider, SIGNAL(dataChanged()), this, SLOT(onDataChanged())); connect(m_confirmFaceAction, SIGNAL(triggered()), this, SLOT(onConfirmFaceActionTriggered())); connect(m_deleteFaceAction, SIGNAL(triggered()), this, SLOT(onDeleteFaceActionTriggered())); connect(m_aboutAction, SIGNAL(triggered()), this, SLOT(onAboutActionTriggered())); connect(allTabAction, SIGNAL(toggled(bool)), this, SLOT(onAllTabActionToggled(bool))); connect(confirmedContactsTabAction, SIGNAL(toggled(bool)), this, SLOT(onConfirmedContactTabActionToggled(bool))); connect(proposedContactsAction, SIGNAL(toggled(bool)), this, SLOT(onProposedContactTabActionToggled(bool))); connect(landscapeTabAction, SIGNAL(toggled(bool)), this, SLOT(onLandscapeTabActionToggled(bool))); connect(m_gridPage, SIGNAL(appeared()), this, SLOT(onGridPageAppeared())); connect(m_fullScreenPage, SIGNAL(appeared()), this, SLOT(onFullscreenPageAppeared())); connect(m_fullScreenPage, SIGNAL(loadingActiveItemFailed(QString)), m_fullScreenPage, SLOT(disappear())); connect(m_galleryModel, SIGNAL(galleryItemsRemoved(int,int)), this, SLOT(onGalleryItemsRemoved())); allTabAction->toggle(); }
LogicPasteApp::LogicPasteApp(Application *app) : QObject(app), loginSheet_(NULL), ignoreSettingsEvent_(false) { qDebug() << "LogicPasteApp::LogicPasteApp()"; QCoreApplication::setOrganizationName("LogicProbe"); QCoreApplication::setApplicationName("LogicPaste"); qRegisterMetaType<PasteListing>("PasteListing"); pasteModel_ = new PasteModel(this); QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this); qml->setContextProperty("cs", this); qml->setContextProperty("model", pasteModel_); AppSettings *appSettings = AppSettings::instance(); if(!qml->hasErrors()) { tabbedPane_ = qml->createRootObject<TabbedPane>(); if(tabbedPane_) { // Paste page pastePage_ = tabbedPane_->findChild<Page*>("pastePage"); connect(pastePage_, SIGNAL(submitPaste()), this, SLOT(onSubmitPaste())); replaceDropDown(pastePage_, "formatDropDown"); // History page historyNav_ = tabbedPane_->findChild<NavigationPane*>("historyPage"); connect(historyNav_, SIGNAL(popTransitionEnded(bb::cascades::Page*)), this, SLOT(onPopFinished(bb::cascades::Page*))); historyPage_ = historyNav_->findChild<Page*>("pasteListPage"); connect(historyPage_, SIGNAL(refreshPage()), pasteModel_, SLOT(refreshHistory())); ListView *historyList = historyPage_->findChild<ListView*>("pasteList"); historyList->setDataModel(pasteModel_->historyModel()); connect(historyList, SIGNAL(openPaste(QString)), this, SLOT(onOpenHistoryPaste(QString))); connect(historyList, SIGNAL(copyUrl(QString)), this, SLOT(onCopyText(QString))); connect(historyList, SIGNAL(deletePaste(QString)), this, SLOT(onDeleteHistoryPaste(QString))); connect(pasteModel_, SIGNAL(historyUpdating()), historyPage_, SLOT(onRefreshStarted())); connect(pasteModel_, SIGNAL(historyUpdated(bool)), this, SLOT(onHistoryRefreshComplete(bool))); // Trending page trendingNav_ = tabbedPane_->findChild<NavigationPane*>("trendingPage"); connect(trendingNav_, SIGNAL(popTransitionEnded(bb::cascades::Page*)), this, SLOT(onPopFinished(bb::cascades::Page*))); trendingPage_ = trendingNav_->findChild<Page*>("pasteListPage"); trendingPage_->findChild<ActionItem*>("refreshAction")->setEnabled(true); connect(trendingPage_, SIGNAL(refreshPage()), pasteModel_, SLOT(refreshTrending())); ListView *trendingList = trendingPage_->findChild<ListView*>("pasteList"); trendingList->setDataModel(pasteModel_->trendingModel()); connect(trendingList, SIGNAL(openPaste(QString)), this, SLOT(onOpenTrendingPaste(QString))); connect(trendingList, SIGNAL(copyUrl(QString)), this, SLOT(onCopyText(QString))); connect(pasteModel_, SIGNAL(trendingUpdating()), trendingPage_, SLOT(onRefreshStarted())); connect(pasteModel_, SIGNAL(trendingUpdated(bool)), this, SLOT(onTrendingRefreshComplete(bool))); // Settings page settingsPage_ = tabbedPane_->findChild<Page*>("settingsPage"); CheckBox *sslCheckBox = settingsPage_->findChild<CheckBox *>("sslCheckBox"); sslCheckBox->setChecked(appSettings->useSsl()); CheckBox *formatterEnable = settingsPage_->findChild<CheckBox*>("formatterEnable"); formatterEnable->setChecked(appSettings->formatterEnabled()); CheckBox *formatterLineNumbering = settingsPage_->findChild<CheckBox*>("formatterLineNumbering"); formatterLineNumbering->setChecked(appSettings->formatterLineNumbering()); DropDown *formatterStyle = settingsPage_->findChild<DropDown*>("formatterStyle"); for(int i = formatterStyle->count() - 1; i >= 0; --i) { if(formatterStyle->at(i)->value() == appSettings->formatterStyle()) { formatterStyle->setSelectedIndex(i); break; } } connect(settingsPage_, SIGNAL(requestLogin()), this, SLOT(onRequestLogin())); connect(settingsPage_, SIGNAL(requestLogout()), this, SLOT(onRequestLogout())); connect(settingsPage_, SIGNAL(refreshUserDetails()), pasteModel_, SLOT(refreshUserDetails())); connect(settingsPage_, SIGNAL(connectionSettingsChanged()), this, SLOT(onConnectionSettingsChanged())); connect(settingsPage_, SIGNAL(pasteSettingsChanged()), this, SLOT(onPasteSettingsChanged())); connect(settingsPage_, SIGNAL(formatterSettingsChanged()), this, SLOT(onFormatterSettingsChanged())); connect(pasteModel_, SIGNAL(userDetailsUpdated()), this, SLOT(onUserDetailsUpdated())); connect(pasteModel_, SIGNAL(userDetailsError(QString)), this, SLOT(onUserDetailsError(QString))); connect(pasteModel_, SIGNAL(userAvatarUpdated()), this, SLOT(onUserAvatarUpdated())); connect(pasteModel_, SIGNAL(deletePasteError(PasteListing,QString)), this, SLOT(onDeletePasteError(PasteListing,QString))); FormatDropDown *formatDropDown = replaceDropDown(settingsPage_, "formatDropDown"); connect(formatDropDown, SIGNAL(selectedIndexChanged(int)), this, SLOT(onPasteSettingsChanged())); // Tabbed pane connect(tabbedPane_, SIGNAL(activePaneChanged(bb::cascades::AbstractPane*)), this, SLOT(onActivePaneChanged(bb::cascades::AbstractPane*))); app->setScene(tabbedPane_); // Create the pull-down menu ActionItem *aboutItem = ActionItem::create() .title(tr("About")) .image(QUrl("asset:///images/action-about.png")); connect(aboutItem, SIGNAL(triggered()), this, SLOT(onAboutActionTriggered())); Menu *menu = Menu::create() .addAction(aboutItem); app->setMenu(menu); if(pasteModel_->isAuthenticated()) { onUserDetailsUpdated(); onUserAvatarUpdated(); } refreshPastePageDefaults(); refreshMainActions(); } }