void MainWindow::setupTrayIcon() { QAction *actionMinimize = new QAction(this); actionMinimize->setText(tr("Minimize")); connect(actionMinimize, SIGNAL(triggered()), this, SLOT(showMinimized())); QAction *actionRestore = new QAction(this); actionRestore->setText(tr("Restore")); connect(actionRestore, SIGNAL(triggered()), this, SLOT(showNormal())); QAction *actionQuit = new QAction(this); actionQuit->setText("Quit"); QAction *actionLogout = new QAction(this); actionLogout->setText("Logout"); connect(actionLogout, SIGNAL(triggered()), this, SLOT(changeUserPass())); m_trayIconMenu = new QMenu(this); m_trayIconMenu->addAction(actionMinimize); m_trayIconMenu->addAction(actionRestore); m_trayIconMenu->addSeparator(); m_trayIconMenu->addAction(actionLogout); m_trayIconMenu->addAction(actionQuit); m_trayIcon = new QSystemTrayIcon(this); m_trayIcon->setIcon(QIcon(":/qtwidget_icon.ico")); m_trayIcon->setContextMenu(m_trayIconMenu); m_trayIcon->show(); connect(m_trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(trayIconActivated(QSystemTrayIcon::ActivationReason))); connect(actionQuit, SIGNAL(triggered()), qApp, SLOT(quit())); }
void MainWindow::startUp() { //read settings QSettings settings(QSettings::IniFormat, QSettings::UserScope, "QTwitdget", "QTwitdget"); m_userId = settings.value("user_id", 0).toInt(); m_userScreenName = settings.value("user_screenname").toString(); QString oauthToken = settings.value("oauth_token").toString(); QString oauthTokenSecret = settings.value("oauth_token_secret").toString(); if (!m_userScreenName.isEmpty()) emit userScreenNameChanged(); if(m_userId != 0 && !oauthToken.isEmpty() && !oauthTokenSecret.isEmpty()){ m_oauthTwitter->setOAuthToken(oauthToken.toUtf8()); m_oauthTwitter->setOAuthTokenSecret(oauthTokenSecret.toUtf8()); //create or change database according to user id createDatabase(QString::number(m_userId)); //show/animate tweets list page QGraphicsObject *obj = rootObject(); obj->setProperty("authed", true); //set user id in the models m_tweetListModel->setUserID(m_userId); m_mentionsListModel->setUserID(m_userId); m_directMessagesListModel->setUserID(m_userId); m_conversationListModel->setUserID(m_userId); //show last tweets from database m_tweetListModel->loadTweetsFromDatabase(); m_mentionsListModel->loadTweetsFromDatabase(); m_directMessagesListModel->loadTweetsFromDatabase(); //then fetch last 200 tweets m_tweetListModel->fetchLastTweets(); m_mentionsListModel->fetchLastTweets(); m_directMessagesListModel->fetchLastTweets(); m_userStream->startFetching(); } else { changeUserPass(); } }
void Core::init() { CoreSettings cs; // legacy QVariantMap dbsettings = cs.storageSettings().toMap(); _configured = initStorage(dbsettings.value("Backend").toString(), dbsettings.value("ConnectionProperties").toMap()); if (Quassel::isOptionSet("select-backend")) { selectBackend(Quassel::optionValue("select-backend")); exit(0); } if (!_configured) { if (!_storageBackends.count()) { qWarning() << qPrintable(tr("Could not initialize any storage backend! Exiting...")); qWarning() << qPrintable(tr("Currently, Quassel supports SQLite3 and PostgreSQL. You need to build your\n" "Qt library with the sqlite or postgres plugin enabled in order for quasselcore\n" "to work.")); exit(1); // TODO make this less brutal (especially for mono client -> popup) } qWarning() << "Core is currently not configured! Please connect with a Quassel Client for basic setup."; } if (Quassel::isOptionSet("add-user")) { createUser(); exit(0); } if (Quassel::isOptionSet("change-userpass")) { changeUserPass(Quassel::optionValue("change-userpass")); exit(0); } connect(&_server, SIGNAL(newConnection()), this, SLOT(incomingConnection())); connect(&_v6server, SIGNAL(newConnection()), this, SLOT(incomingConnection())); if (!startListening()) exit(1); // TODO make this less brutal if (Quassel::isOptionSet("oidentd")) _oidentdConfigGenerator = new OidentdConfigGenerator(this); }