Ejemplo n.º 1
0
bool PreferencesDialog::eventFilter(QObject *obj, QEvent *event)
{
    // Use mouse click and enter press on the frames to pop up a colour dialog
    if (obj == ui->fr_bin_bg  || obj == ui->fr_bin_fg ||
        obj == ui->fr_reg_bg  || obj == ui->fr_reg_fg ||
        obj == ui->fr_null_bg || obj == ui->fr_null_fg)
    {
        if (event->type() == QEvent::KeyPress)
        {
            QKeyEvent *key = static_cast<QKeyEvent *>(event);
            // Not interesting, so send to the parent (might be shortcuts)
            if((key->key() != Qt::Key_Enter) && (key->key() != Qt::Key_Return))
            {
                return QDialog::eventFilter(obj, event);
            }
        }
        else if (event->type() != QEvent::MouseButtonPress)
        {
            // Not a key event neither a mouse event, send to the parent
            return QDialog::eventFilter(obj, event);
        }

        QFrame *frame = qobject_cast<QFrame *>(obj);
        QColor oldColour = frame->palette().color(frame->backgroundRole());
        QColor colour = QColorDialog::getColor(oldColour, frame);

        if (colour.isValid())
        {
            QPalette palette = frame->palette();
            palette.setColor(frame->backgroundRole(), colour);
            frame->setPalette(palette);
        }
        // Consume
        return true;
    }

    // Send any other events to the parent
    return QDialog::eventFilter(obj, event);
}
Ejemplo n.º 2
0
void gpSessionView::InitLayout()
{
    // layout to hold the two main vboxlayouts;
    QHBoxLayout* pMainLayout = new QHBoxLayout;

    QVBoxLayout* pThumbLayout = new QVBoxLayout;
    QVBoxLayout* pImageLayout = new QVBoxLayout;

    // Create the image section
    m_pImageLabel = new QLabel;

    // This pixmap is set so that the label will demand the max size possible
    QPixmap placeHolderPixmap(GP_IMAGE_SECTION_WIDTH, GP_IMAGE_SECTION_WIDTH);
    m_pImageLabel->setPixmap(placeHolderPixmap);

    m_pImageLabel->setMaximumWidth(GP_IMAGE_SECTION_WIDTH);
    m_pImageLabel->setMaximumHeight(GP_IMAGE_SECTION_WIDTH);

    // Create the frame analysis section:
    m_pCurrentFrameCaptionLabel = new QLabel(GPU_STR_dashboard_MainImageCaptionRunning);
    m_pCurrentFrameCaptionLabel->setStyleSheet(AF_STR_captionLabelStyleSheetMain);

    m_pCurrentFrameDetailsLabel = new QLabel;
    QLabel* pPropsHTMLLabelCaption = new QLabel(GPU_STR_dashboard_ExecutionCaption);
    m_pCurrentFrameDetailsLabel->setStyleSheet("font-weight: bold; color: gray; font-size: 15px;");

    pPropsHTMLLabelCaption->setStyleSheet(AF_STR_captionLabelStyleSheetMain);
    m_pPropsHTMLLabel = new QLabel;
    m_pPropsHTMLLabel->setTextFormat(Qt::RichText);

    QFrame* pImageFrameWidget = new QFrame;
    QPalette p = pImageFrameWidget->palette();
    p.setColor(backgroundRole(), Qt::white);
    p.setColor(QPalette::Base, Qt::white);
    p.setColor(QPalette::Shadow, Qt::red);
    pImageFrameWidget->setAutoFillBackground(true);
    pImageFrameWidget->setPalette(p);
    pImageFrameWidget->setLineWidth(1);
    pImageFrameWidget->setMidLineWidth(1);
    pImageFrameWidget->setFrameStyle(QFrame::Panel | QFrame::Raised);


    QVBoxLayout* pImageFrameLayout = new QVBoxLayout;
    m_pCurrentFrameDetailsLabel->setContentsMargins(0, 0, 0, 0);

    pImageFrameLayout->addWidget(m_pCurrentFrameDetailsLabel, 0, Qt::AlignCenter);
    pImageFrameLayout->addWidget(m_pImageLabel, 0, Qt::AlignCenter);
    pImageFrameWidget->setLayout(pImageFrameLayout);

    pImageLayout->addWidget(m_pCurrentFrameCaptionLabel);
    pImageLayout->addSpacing(4);
    pImageLayout->addWidget(pImageFrameWidget);
    pImageLayout->addStretch();
    pImageLayout->addWidget(pPropsHTMLLabelCaption);
    pImageLayout->addWidget(m_pPropsHTMLLabel);

    FillExecutionDetails();

    // Create the frame analysis section:
    m_pCapturedFramesCaptionLabel = new QLabel(GPU_STR_dashboard_CapturedFramesCaption);
    m_pCapturedFramesCaptionLabel->setStyleSheet(AF_STR_captionLabelStyleSheetMain);

#define GP_SessionViewButtonStyle "QToolButton { border: 1px solid transparent; background-color: transparent; font-weight: bold; color: gray; }" \
    "QToolButton:hover { border: 1px solid gray; background-color: #CDE6F7; color: black;}"

    QHBoxLayout* pButtonsLayout = new QHBoxLayout;
    pButtonsLayout->addStretch();

    m_pCaptureButton = new QToolButton;
    m_pCaptureButton->setText(GPU_STR_dashboard_CaptureButton);
    m_pCaptureButton->setStyleSheet(GP_SessionViewButtonStyle);
    m_pCaptureButton->setToolTip(GPU_STR_dashboard_CaptureTooltip);

    m_pStopButton = new QToolButton;
    m_pStopButton->setStyleSheet(GP_SessionViewButtonStyle);
    m_pStopButton->setText(GPU_STR_dashboard_StopButton);
    m_pStopButton->setToolTip(GPU_STR_dashboard_StopTooltip);

    m_pOpenTimelineButton = new QToolButton;
    m_pOpenTimelineButton->setStyleSheet(GP_SessionViewButtonStyle);
    m_pOpenTimelineButton->setText(GPU_STR_dashboard_OpenTimelineButton);
    m_pOpenTimelineButton->setToolTip(GPU_STR_dashboard_OpenTimelineTooltip);

    bool rc = connect(m_pCaptureButton, SIGNAL(clicked()), this, SLOT(OnCaptureButtonClick()));
    GT_ASSERT(rc);

    rc = connect(m_pStopButton, SIGNAL(clicked()), this, SLOT(OnStopButtonClick()));
    GT_ASSERT(rc);

    rc = connect(m_pOpenTimelineButton, SIGNAL(clicked()), this, SLOT(OnOpenTimelineButtonClick()));
    GT_ASSERT(rc);

    QPixmap captureButtonIcon;
    acIconSize largerButtonIcon = acGetScaledIconSize(AC_32x32_ICON);
    int iconDim = acIconSizeToPixelSize(largerButtonIcon);
    QSize iconSize(iconDim, iconDim);
    acSetIconInPixmap(captureButtonIcon, AC_ICON_EXECUTION_CAPTURE, largerButtonIcon);
    m_pCaptureButton->setIcon(captureButtonIcon);
    m_pCaptureButton->setIconSize(iconSize);
    m_pCaptureButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
    m_pCaptureButton->setFixedWidth(acScalePixelSizeToDisplayDPI(GP_SESSION_VIEW_BUTTON_SIZE));

    QPixmap stopButtonIcon;
    acSetIconInPixmap(stopButtonIcon, AC_ICON_EXECUTION_STOP, largerButtonIcon);
    m_pStopButton->setIcon(stopButtonIcon);
    m_pStopButton->setIconSize(iconSize);
    m_pStopButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
    m_pStopButton->setFixedWidth(acScalePixelSizeToDisplayDPI(GP_SESSION_VIEW_BUTTON_SIZE));

    QPixmap openTimelineButtonIcon;
    acSetIconInPixmap(openTimelineButtonIcon, AC_ICON_FRAME_ANALYSIS_APP_TREE_TIMELINE, largerButtonIcon);
    m_pOpenTimelineButton->setIcon(openTimelineButtonIcon);
    m_pOpenTimelineButton->setIconSize(iconSize);
    m_pOpenTimelineButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
    m_pOpenTimelineButton->setFixedWidth(acScalePixelSizeToDisplayDPI(GP_SESSION_VIEW_BUTTON_SIZE));

#if AMDT_BUILD_CONFIGURATION == AMDT_DEBUG_BUILD
    m_pSimulateUserCaptureButton = new QToolButton;
    m_pSimulateUserCaptureButton->setText("Capture Simulate");
    QImage captureInv(captureButtonIcon.toImage());
    captureInv.invertPixels(QImage::InvertRgb);
    m_pSimulateUserCaptureButton->setIcon(QPixmap::fromImage(captureInv));
    m_pSimulateUserCaptureButton->setIconSize(iconSize);
    m_pSimulateUserCaptureButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
    m_pSimulateUserCaptureButton->setStyleSheet(GP_SessionViewButtonStyle);
    rc = connect(m_pSimulateUserCaptureButton, SIGNAL(clicked()), this, SLOT(OnSimulateCaptureButtonClick()));
    GT_ASSERT(rc);
    // pButtonsLayout->addWidget(m_pSimulateUserCaptureButton);
#endif

    pButtonsLayout->addWidget(m_pCaptureButton);
    pButtonsLayout->addWidget(m_pStopButton);
    pButtonsLayout->addWidget(m_pOpenTimelineButton);
    pButtonsLayout->addStretch();
    pImageFrameLayout->addLayout(pButtonsLayout, Qt::AlignCenter | Qt::AlignVCenter);
    pImageFrameLayout->addStretch();

    // Initialize and fill the thumbnail view
    m_pSnapshotsThumbView = new acThumbnailView;
    m_pSnapshotsThumbView->SetItemTooltip(GPU_STR_dashboard_ItemTooltip);

    rc = connect(m_pSnapshotsThumbView, SIGNAL(ItemDoubleClicked(const QVariant&)), this, SLOT(OnItemDoubleClicked(const QVariant&)));
    GT_ASSERT(rc);
    rc = connect(m_pSnapshotsThumbView, SIGNAL(ItemPressed(const QVariant&)), this, SLOT(OnItemPressed(const QVariant&)));
    GT_ASSERT(rc);

    pThumbLayout->addWidget(m_pCapturedFramesCaptionLabel);
    pThumbLayout->addWidget(m_pSnapshotsThumbView, Qt::AlignLeft);

    QWidget* pLeftWidget = new QWidget;
    QWidget* pRightWidget = new QWidget;
    pLeftWidget->setLayout(pImageLayout);
    pRightWidget->setLayout(pThumbLayout);
    pLeftWidget->setMinimumWidth(200);
    pRightWidget->setMinimumWidth(200);

    pMainLayout->addWidget(pLeftWidget, 0);
    pMainLayout->addWidget(pRightWidget, 1);

    setLayout(pMainLayout);
}
Ejemplo n.º 3
0
MainWindow::MainWindow(DVRServerRepository *serverRepository, QWidget *parent)
    : QMainWindow(parent), m_serverRepository(serverRepository), m_trayIcon(0)
{
    Q_ASSERT(m_serverRepository);

    bcApp->mainWindow = this;
    connect(bcApp->eventDownloadManager(), SIGNAL(eventVideoDownloadAdded(EventVideoDownload*)),
            this, SLOT(showDownloadsWindow()));

    setUnifiedTitleAndToolBarOnMac(true);
	resize(1100, 750);
    createMenu();
    updateTrayIcon();
    setObjectName("MainWindow");

    statusBar()->addPermanentWidget(new StatusBandwidthWidget(statusBar()));
    statusBar()->addWidget(new StatusBarServerAlert(m_serverRepository, statusBar()));

#ifdef Q_OS_MAC
    statusBar()->setSizeGripEnabled(false);
    if (style()->inherits("QMacStyle"))
        statusBar()->setFixedHeight(24);
#endif

    /* Experimental toolbar */
    m_mainToolbar = new QToolBar(tr("Main"));
    m_mainToolbar->setMovable(false);
    m_mainToolbar->setIconSize(QSize(16, 16));
    m_mainToolbar->addAction(QIcon(QLatin1String(":/icons/cassette.png")), tr("Events"), this, SLOT(showEventsWindow()));
	m_expandAllServersAction = m_mainToolbar->addAction(QIcon(QLatin1String(":/icons/expand-all.png")), tr("Expand All Servers"));
	m_collapseAllServersAction = m_mainToolbar->addAction(QIcon(QLatin1String(":/icons/collapse-all.png")), tr("Collapse All Servers"));
    addToolBar(Qt::TopToolBarArea, m_mainToolbar);

    /* Splitters */
    m_leftSplit = new MacSplitter(Qt::Horizontal);
    m_centerSplit = new MacSplitter(Qt::Vertical);

    /* Live view */
    m_liveView = new LiveViewWindow(serverRepository, this);

    /* Recent events */
    QWidget *eventsWidget = createRecentEvents();

    /* Layouts */
    m_leftSplit->addWidget(createSourcesList());
    m_leftSplit->addWidget(m_centerSplit);
    m_leftSplit->setStretchFactor(1, 1);
    m_leftSplit->setCollapsible(0, false);
    m_leftSplit->setCollapsible(1, false);

    m_centerSplit->addWidget(m_liveView);
    m_centerSplit->addWidget(eventsWidget);
    m_centerSplit->setStretchFactor(0, 1);
    m_centerSplit->setCollapsible(0, false);
    m_centerSplit->setCollapsible(1, false);

    /* Set center widget */
    QWidget *center = new QWidget;
    QBoxLayout *centerLayout = new QVBoxLayout(center);
    centerLayout->setMargin(0);
    centerLayout->setSpacing(0);
    centerLayout->addWidget(m_leftSplit, 1);
    setCentralWidget(center);

#ifdef Q_OS_WIN
    /* There is no top border on the statusbar on Windows, and we need one. */
    if (style()->inherits("QWindowsStyle"))
    {
        QFrame *line = new QFrame;
        line->setFrameStyle(QFrame::Plain | QFrame::HLine);
        QPalette p = line->palette();
        p.setColor(QPalette::WindowText, QColor(171, 175, 183));
        line->setPalette(p);
        line->setFixedHeight(1);
        centerLayout->addWidget(line);
    }
#endif

    QSettings settings;
    bcApp->liveView->setBandwidthMode(settings.value(QLatin1String("ui/liveview/bandwidthMode")).toInt());
    restoreGeometry(settings.value(QLatin1String("ui/main/geometry")).toByteArray());
    if (!m_centerSplit->restoreState(settings.value(QLatin1String("ui/main/centerSplit")).toByteArray()))
    {
        m_centerSplit->setSizes(QList<int>() << 1000 << 130);
    }
    if (!m_leftSplit->restoreState(settings.value(QLatin1String("ui/main/leftSplit")).toByteArray()))
    {
#ifdef Q_OS_MAC
        m_leftSplit->setSizes(QList<int>() << 210 << 1000);
#else
        m_leftSplit->setSizes(QList<int>() << 190 << 1000);
#endif
    }

    m_leftSplit->setHandleWidth(2);
    m_centerSplit->setHandleWidth(2);

    QString lastLayout = settings.value(QLatin1String("ui/cameraArea/lastLayout"), tr("Default")).toString();
    m_liveView->setLayout(lastLayout);

    connect(m_liveView, SIGNAL(layoutChanged(QString)), SLOT(liveViewLayoutChanged(QString)));
    connect(m_leftSplit, SIGNAL(splitterMoved(int,int)), SLOT(updateToolbarWidth()));
    updateToolbarWidth();

    connect(bcApp, SIGNAL(sslConfirmRequired(DVRServer*,QList<QSslError>,QSslConfiguration)),
            SLOT(sslConfirmRequired(DVRServer*,QList<QSslError>,QSslConfiguration)));
    connect(bcApp, SIGNAL(queryLivePaused()), SLOT(queryLivePaused()));
    connect(m_serverRepository, SIGNAL(serverAdded(DVRServer*)), SLOT(onServerAdded(DVRServer*)));

    foreach (DVRServer *s, m_serverRepository->servers())
        onServerAdded(s);

    connect(qApp, SIGNAL(aboutToQuit()), SLOT(saveSettings()));

    m_sourcesList->setFocus(Qt::OtherFocusReason);

    connect(m_expandAllServersAction, SIGNAL(triggered()), m_sourcesList, SLOT(expandAll()));
    connect(m_collapseAllServersAction, SIGNAL(triggered()), m_sourcesList, SLOT(collapseAll()));

    retranslateUI();

    if (settings.value(QLatin1String("ui/saveSession"), false).toBool())
        m_liveView->restoreSession();
}