void Watcher::trayIconToOn(Document *document) { if(!document) takeTemporarySnapshot(); trayMenu->setIcon(trayIconOn); QTimer::singleShot(1000, this, SLOT(trayIconToOff())); feeling->display(document); }
Watcher::Watcher(QObject *parent) : WatcherBase(parent) { watcher = new QFileSystemWatcher(this); trayIconOff = QIcon(":/icons/res_tray_icon_black.png"); trayIconOn = QIcon(":/icons/res_tray_icon_color.png"); trayMenu = new QSystemTrayIcon(this); connect(trayMenu, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), SLOT(trayActivated(QSystemTrayIcon::ActivationReason))); trayIconToOff(); QMenu *trayElements = new QMenu(Global::mainWindow); trayElements->addAction(tr("Show timeline"), this, SLOT(trayActivateApp())); trayElements->addAction(tr("Write a note"), this, SLOT(writeNote())); trayMenu->setContextMenu(trayElements); trayMenu->show(); feeling = new WatcherFeeling(); feeling->setStyleSheet(Global::mainWindow->styleSheet()); }
Rekall::Rekall(const QStringList &arguments, QWidget *parent) : QDialog(parent) { trayIconWorking = false; trayIconIndex = 0; trayIconIndexOld = 9999; Global::rekall = this; qApp->setAttribute(Qt::AA_UseHighDpiPixmaps); //Update updateManager = 0; forceUpdate = false; firstTimeOpened = newVersionOfRekall = false; if(arguments.contains("-forceupdate")) forceUpdate = true; //Tray icon trayTimer.setInterval(500); connect(&trayTimer, SIGNAL(timeout()), SLOT(trayIconToOnPrivate())); connect(&trayTimerOff, SIGNAL(timeout()), SLOT(trayIconToOffPrivate())); QString prefix = "mac"; #ifdef Q_OS_WIN prefix = "win"; #endif for(quint16 i = 0 ; i <= 17 ; i++) trayIcons << QIcon(QString(":/icons/rekall-menubar-%1-%2.png").arg(prefix).arg(i, 2, 10, QChar('0'))); trayIcon = new QSystemTrayIcon(this); trayIconToOffPrivate(); trayTimer.start(); connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), SLOT(trayActivated(QSystemTrayIcon::ActivationReason))); //Interfaces Global::userInfos = new UserInfos(this); Global::http = new Http(this); Analyse *analyse = new Analyse(this); Global::analyse = analyse; connect(analyse, SIGNAL(trayChanged(QString,bool)), SLOT(analyseTrayChanged(QString,bool))); connect(analyse, SIGNAL(trayIconToOff()), SLOT(trayIconToOff())); connect(analyse, SIGNAL(trayIconToOn(qint16)), SLOT(trayIconToOn(qint16))); //Wrapper web Global::userInfos->setDockIcon(this, false); Global::webWrapper = new WebWrapper(); /* VideoPlayer *player = new VideoPlayer(); player->open(QUrl::fromLocalFile("/Users/guillaume/Documents/Rekall/Walden/Captations/captation WALDEN_TPV.mov")); player->seek(4000); */ trayMenu = new QMenu(this); trayMenu->setSeparatorsCollapsible(true); trayAnalyse = trayMenu->addAction(tr("File analysis…")); trayAnalysePause = trayMenu->addAction(tr("Pause analysis")); trayAnalysePause->setCheckable(true); connect(trayAnalysePause, SIGNAL(toggled(bool)), SLOT(trayAnalysePaused())); trayMenu->addSeparator(); trayMenu->addAction(tr("Open welcome page"), this, SLOT(openWebPage())); trayMenu->addAction(tr("Open welcome page in webrowser"), this, SLOT(openWebPageInBrowser())); //trayMenu->addAction(tr("Create a new project"), this, SLOT(addProject())); trayMenu->addSeparator(); trayMenuProjects = trayMenu->addAction(tr("Quit Rekall"), this, SLOT(closeRekall())); trayIcon->setContextMenu(trayMenu); trayIcon->show(); trayIconToOnPrivate(); QSettings settings; quint16 projectCount = settings.beginReadArray("projects"); /* if(projectCount == 0) { addProject(new Project("walden", "Walden", true, QFileInfo("/Users/guillaume/Documents/Rekall/Walden"), this)); addProject(new Project("joris-test", "Joris", false, QFileInfo("/Users/guillaume/Documents/Rekall/joris-test"), this)); } */ connect(Global::udp, SIGNAL(outgoingMessage(QString,quint16,QString,QList<QVariant>)), SLOT(incomingMessage(QString,quint16,QString,QList<QVariant>))); for(quint16 projectIndex = 0 ; projectIndex < projectCount ; projectIndex++) { settings.setArrayIndex(projectIndex); Project *project = new Project(settings.value("name").toString(), settings.value("friendlyName").toString(), true, QFileInfo(settings.value("path").toString()), this); addProject(project); } settings.endArray(); //foreach(ProjectInterface *project, Global::projects) // project->load(); //Global settings creation if needed globalSettings = new QSettings(); if((globalSettings) && ((!globalSettings->childKeys().contains("id")) || (arguments.contains("-newuser")))) { firstTimeOpened = true; qsrand(QDateTime::currentDateTime().toTime_t()); updateAnonymousId = QString::number(qrand()); globalSettings->setValue("id", updateAnonymousId); globalSettings->setValue("version", ""); globalSettings->setValue("updatePeriod", 1); globalSettings->setValue("lastUpdate", QDateTime(QDate(2000, 01, 01))); } //Update management if((globalSettings) && (globalSettings->childKeys().contains("id"))) { QDateTime updateLastDate = globalSettings->value("lastUpdate") .toDateTime(); quint16 updatePeriod = globalSettings->value("updatePeriod").toUInt(); updateAnonymousId = globalSettings->value("id") .toString(); QString applicationVersionSettings = globalSettings->value("version").toString(); if(applicationVersionSettings != QCoreApplication::applicationVersion()) { globalSettings->setValue("version", QCoreApplication::applicationVersion()); firstTimeOpened = true; } qDebug("Last update : %s (should update each %d day(s))", qPrintable(updateLastDate.toString("dd/MM/yyyy hh:mm:ss")), updatePeriod); if((updateLastDate.daysTo(QDateTime::currentDateTime()) >= updatePeriod) || (forceUpdate)) checkForUpdates(); } askScreenshot = askAddProject = 0; startTimer(50); if(firstTimeOpened) showMessage(tr("Welcome!\nRekall is now running!")); else showMessage(tr("Rekall is now running!")); if(!arguments.contains("-silent")) openWebPage(); /* QWebView *webView = new QWebView(); webView->load(QUrl("http://127.0.0.1:23411")); webView->show(); */ }