Exemple #1
0
QList<QUrl> Eyes::availableSources()
{
    if( m_sources.isEmpty() )
        updateSources();

    return m_sources;
}
Exemple #2
0
void MainWindow::action(QAction * action)
{
    if (action->text() == "Load Model File") {
        QString  fileName = QFileDialog::getOpenFileName(this, tr("Open Model File"), "./", tr("Model Files (*.xml)"));
        if (metaModel.setModel(fileName) == true) {
            QMessageBox msg;
            msg.setText("Model File read correctly.");
            msg.exec();
        } else {
            QMessageBox msg;
            msg.setText("Model File read failed.");
            msg.exec();
        }
    }

    if (action->text() == "Load Log File") {
        QString  fileName = QFileDialog::getOpenFileName(this, tr("Open Log File"), "./", tr("Log Files"));
        if (metaModel.parse(fileName) == true) {
            QMessageBox msg;
            msg.setText("Log File read correctly.");
            msg.exec();

            updateSources();

        } else {
            QMessageBox msg;
            msg.setText("Log File read failed.");
            msg.exec();
        }

    }

}
void BleImageProcess::keyPressEvent(QKeyEvent *e)
{
    if (!m_activePair) return;

    int key = e->key();
    if (key == Qt::Key_Delete) {
        m_activePair->source->stopCapture();

        if (m_sources.contains(*m_activePair)) {
            m_sources.removeAll(*m_activePair);
            m_activePair = NULL;
        }

        updateSources();
        update();
    } else if (key == Qt::Key_Up) {
        onUpBtnClicked();
    } else if (key == Qt::Key_Down) {
        onDownBtnClicked();
    } else if (key == Qt::Key_Left) {
        onLeftBtnClicked();
    } else if (key == Qt::Key_Right) {
        onRightBtnClicked();
    } else if (key == Qt::Key_PageUp) {
        onIncBtnClicked();
    } else if (key == Qt::Key_PageDown) {
        onDecBtnClicked();
    } else {
        QWidget::keyPressEvent(e);
    }
}
void BleImageProcess::mouseDoubleClickEvent(QMouseEvent */*e*/)
{
    if (!m_activePair) return;

    m_activePair->rect = rect();

    updateSources();
    update();
}
void BleImageProcess::addCaptureSource(BleSourceAbstract *source, int x, int y, int w, int h)
{
    QRect rt = QRect(x, y, w, h);
    SourcePair pair = {source, rt};
    m_sources.append(pair);
    m_activePair = &m_sources.front();

    updateSources();
    update();
}
bool KdeObservatory::eventFilter(QObject *receiver, QEvent *event)
{
    if (!m_viewProviders.isEmpty() &&
        dynamic_cast<QGraphicsWidget *>(receiver) == m_mainContainer &&
        event->type() == QEvent::GraphicsSceneResize)
    {
        delete m_transitionTimer;
        m_viewTransitionTimer->stop();
        createViews();
        updateSources();
        m_viewTransitionTimer->start();
        m_transitionTimer = new QTimeLine(500, this);
        connect(m_transitionTimer, SIGNAL(finished()), this, SLOT(timeLineFinished()));
        return true;
    }
    else
        return Plasma::PopupApplet::eventFilter(receiver, event);
}
void BleImageProcess::mouseMoveEvent(QMouseEvent *event)
{
    if (!m_activePair) return;

    QRect topLeftRect(m_activePair->rect.x(), m_activePair->rect.y(), 8, 8);
    QRect bottomRightRect(m_activePair->rect.bottomRight().x() - 8, m_activePair->rect.bottomRight().y() - 8, 8, 8);

    if (topLeftRect.contains(event->pos())) {
        setCursor(Qt::SizeFDiagCursor);
    } else if (bottomRightRect.contains(event->pos())) {
        setCursor(Qt::SizeFDiagCursor);
    } else if (m_activePair->rect.contains(event->pos())) {
        setCursor(Qt::SizeAllCursor);
    } else {
        setCursor(Qt::ArrowCursor);
    }

    if (m_startResize) {
        if (m_resizeFromTopLeft) {
            m_activePair->rect.setTopLeft(event->pos());
        }

        if (m_resizeFromBottomRight){
            m_activePair->rect.setBottomRight(event->pos());
        }
    }

    if (m_startMove) {
        QPoint diff = QPoint(event->pos().x() - m_lastMovePoint.x(), event->pos().y() - m_lastMovePoint.y());

        int w = m_activePair->rect.width();
        int h = m_activePair->rect.height();
        m_activePair->rect.setTopLeft(QPoint(m_activePair->rect.x() + diff.x(), m_activePair->rect.y() + diff.y()));
        m_activePair->rect.setWidth(w);
        m_activePair->rect.setHeight(h);
    }

    if (m_startResize || m_startMove) {
        updateSources();
    }

    update();
    m_lastMovePoint = event->pos();
}
void KdeObservatory::safeInit()
{
    if (m_projects.count() == 0)
    {
        configChanged();
        saveConfig();
        createViewProviders();
        createTimers();
        createViews();

        m_sourceCounter = 4;

        m_engine->connectSource("topActiveProjects", this);
        m_engine->connectSource("topProjectDevelopers", this);
        m_engine->connectSource("commitHistory", this);
        m_engine->connectSource("krazyReport", this);
    }

    updateSources();
}
void KdeObservatory::configAccepted()
{
    // General properties
    m_activityRangeType = (m_configGeneral->activitiesFullHistory->isChecked()) ? 0:(m_configGeneral->activitiesInPastDays->isChecked()) ? 1:2;
    m_commitExtent = m_configGeneral->commitExtent->value();
    m_commitFrom = m_configGeneral->fromDate->date().toString("yyyyMMdd");
    m_commitTo   = m_configGeneral->toDate  ->date().toString("yyyyMMdd");
    m_enableAutoViewChange = (m_configGeneral->enableAutoViewChange->checkState() == Qt::Checked) ? true:false;
    QTime viewsDelay = m_configGeneral->viewsDelay->time();
    m_viewsDelay = viewsDelay.second() + viewsDelay.minute()*60 + viewsDelay.hour()*3600;

    m_activeViews.clear();
    QStringList viewNames;
    QList<bool> viewActives;

    for (int i = 0; i < m_configViews->activeViews->count(); ++i)
    {
        QListWidgetItem *item = m_configViews->activeViews->item(i);
        QString viewName = item->text();
        bool viewActive = (item->checkState() == Qt::Checked) ? true:false;
        m_activeViews << QPair<QString, bool>(viewName, viewActive);
        viewNames << viewName;
        viewActives << viewActive;
    }

    m_viewTransitionTimer->setInterval(m_viewsDelay * 1000);

    // Projects properties
    QStringList projectNames;
    QStringList projectCommitSubjects;
    QStringList projectKrazyReports;
    QStringList projectKrazyFilePrefix;
    QStringList projectIcons;

    m_projects.clear();

    int projectsCount = m_configProjects->projects->rowCount();
    for (int i = 0; i < projectsCount; ++i)
    {
        Project project;
        project.commitSubject = m_configProjects->projects->item(i, 1)->text();
        project.krazyReport = m_configProjects->projects->item(i, 2)->text();
        project.krazyFilePrefix = m_configProjects->projects->item(i, 3)->text();
        project.icon = m_configProjects->projects->item(i, 0)->data(Qt::UserRole).value<QString>();
        m_projects[m_configProjects->projects->item(i, 0)->text()] = project;
        projectNames << m_configProjects->projects->item(i, 0)->text();
        projectCommitSubjects << project.commitSubject;
        projectKrazyReports << project.krazyReport;
        projectKrazyFilePrefix << project.krazyFilePrefix;
        projectIcons << project.icon;
    }

    m_configViews->on_views_currentIndexChanged(i18n("Top Active Projects"));
    m_topActiveProjectsViewProjects = m_configViews->m_projectsInView[i18n("Top Active Projects")];
    m_topDevelopersViewProjects = m_configViews->m_projectsInView[i18n("Top Developers")];
    m_commitHistoryViewProjects = m_configViews->m_projectsInView[i18n("Commit History")];
    m_krazyReportViewProjects = m_configViews->m_projectsInView[i18n("Krazy Report")];

    saveConfig();

    m_lastViewCount = m_views.count();
    createTimers();
    createViews();
    updateSources();
}
void BleImageProcess::setProcessThread(QThread *thread)
{
    m_processThread = thread;

    updateSources();
}