YoutubeController::YoutubeController(QObject *parent): QObject(parent), commentsTimerId_(0), updateMessagesIntervalMs_(DEFAULT_YOUTUBE_UPDATE_MESSAGES_INTERVAL_MS), liveChatId_("") { o2youtube_ = new O2Youtube(this); o2youtube_->setClientId("463300085238-11h8th4cbl9uoi4rd8pcl0e19sspn1s8.apps.googleusercontent.com"); o2youtube_->setClientSecret("PZE0m3Ym4lZRKWDWk6KQ9c7T"); connect(o2youtube_, SIGNAL(linkedChanged()), this, SLOT(onLinkedChanged())); connect(o2youtube_, SIGNAL(linkingFailed()), this, SLOT(onLinkingFailed())); connect(o2youtube_, SIGNAL(linkingSucceeded()), this, SLOT(onLinkingSucceeded())); connect(o2youtube_, SIGNAL(openBrowser(QUrl)), this, SLOT(onOpenBrowser(QUrl))); connect(o2youtube_, SIGNAL(closeBrowser()), this, SLOT(onCloseBrowser())); api_ = new YoutubeApi(this); connect(api_, SIGNAL(broadcastModelChanged()),this, SLOT(broadcastModelChanged())); connect(api_, SIGNAL(commentModelChanged()),this, SLOT(commentModelChanged())); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { //set up ui ui->setupUi(this); listModel= new QStandardItemModel(ui->listView); ui->listView->setModel(listModel); treeModel = new QStandardItemModel(ui->treeView); ui->treeView->setModel(treeModel); listMenu = new QMenu(this); treeMenu = new QMenu("TreeMenu",this); setting = new QSettings("my","feeder",this); subDialog = new SubscribeDialog(this); markArticleAsRead = new QAction("Mark As Read",this); markArticleAsUnread = new QAction("Mark As Unread",this); markFeedAllAsRead = new QAction("Mark All As Read",this); markCategoryAllAsRead = new QAction("Mark All As Read",this); //set up oauth2 o2 = new O2(this); nam = new QNetworkAccessManager(this); o2req = new O2Requestor(nam,o2,this); o2->setClientId(CLIENT_ID); o2->setClientSecret(CLIENT_SECRET); o2->setRequestUrl(REQUEST_URL); o2->setTokenUrl(TOKEN_URL); o2->setScope(SCOPE); o2->setLocalPort(8080); o2->setRefreshTokenUrl(REFRESH_TOKEN_URL); store = new O2SettingsStore(setting,"myfeederkey",this); store->setGroupKey("OAuth"); o2->setStore(store); //If we've already logged in, we can get userId and plan from //the local setting storage userId = store->value("id"); plan = store->value("plan"); qDebug() << userId<< plan; //We do the linking to log in. If we've already logged in, //it won't hurt any way. o2->link(); //connect connect(o2, SIGNAL(linkedChanged()), this, SLOT(onLinkedChanged())); connect(o2, SIGNAL(linkingFailed()), this, SLOT(onLinkingFailed())); connect(o2, SIGNAL(linkingSucceeded()), this, SLOT(onLinkingSucceeded())); connect(o2, SIGNAL(openBrowser(QUrl)), this, SLOT(onOpenBrowser(QUrl))); connect(o2,SIGNAL(tokenChanged()),this,SLOT(onTokenChanged())); connect(ui->treeView,SIGNAL(clicked(QModelIndex)),this,SLOT(on_treeView_clicked(QModelIndex))); connect(o2req,SIGNAL(finished(int,QNetworkReply::NetworkError,QByteArray)),this,SLOT(onReqFinished(int,QNetworkReply::NetworkError,QByteArray))); connect(ui->listView,SIGNAL(customContextMenuRequested(QPoint)),this,SLOT(on_listView_customContextMenuRequested(QPoint))); connect(subDialog,SIGNAL(accepted()),this,SLOT(on_subscibe())); connect(listMenu,SIGNAL(triggered(QAction*)),this,SLOT(on_listView_menu_triggered(QAction*))); connect(treeMenu,SIGNAL(triggered(QAction*)),this,SLOT(on_treeView_menu_triggered(QAction*))); reqCategories(); }