void ScreenShotPage::takeScreenshot()
{
    QPixmap screenshot;

    screenshot = QPixmap::grabWindow(scene()->views().at(0)->effectiveWinId());

    QString path;

    if (QDir(ImagesPath).exists())
        path = ImagesPath;
    else
        path = QDir::homePath();

    QString fileFormat(QString("%1/%2-%3.png").arg(path).arg(QDate::currentDate().toString("yyyyMMdd")).arg(QTime::currentTime().toString("hhmmss")));

    if (!screenshot.save(fileFormat))
        mWarning("MWindow") << "Could not save screenshot to" << path;

    playScreenshotEffect();

    MBanner * bannerPath = new MBanner();
    bannerPath->setObjectName("pathBanner");
    bannerPath->setStyleName("InformationBanner");
    bannerPath->setTitle("Screenshot has been saved in: " + fileFormat);
    bannerPath->appear(scene(), MSceneWindow::DestroyWhenDone);
}
void Ut_WidgetNotificationSink::testUpdateActions()
{
    // Create notification parameters
    Notification notification;
    TestNotificationParameters parameters;
    parameters.add(NotificationWidgetParameterFactory::createActionParameter("content0 0 0 0"));
    notification.setParameters(parameters);

    // Create an info banner with one action
    MBanner infoBanner;
    QAction *action = new QAction(&infoBanner);
    infoBanner.addAction(action);

    // There shouldn't be any MRemoteActions at this point but the action should be added
    QCOMPARE(contents.count(), 0);
    QCOMPARE(actions.count(), 1);
    QCOMPARE(actions[&infoBanner].at(0), action);

    // Update the actions
    m_subject->updateActions(&infoBanner, notification);

    // There should be a MRemoteAction at this point
    QCOMPARE(contents.count(), 1);
    QCOMPARE(contents[0], QString("content0 0 0 0"));
    QCOMPARE(actions.count(), 1);
    QVERIFY(dynamic_cast<MRemoteAction *>(actions[&infoBanner].at(0)) != NULL);
    QCOMPARE(dynamic_cast<MRemoteAction *>(actions[&infoBanner].at(0))->toString(), QString("content0 0 0 0"));
}
Esempio n. 3
0
void AppWindow::showMessage(QString msg, int timeout)
{
	Q_UNUSED(timeout);

	MBanner *infoBanner = new MBanner();
	infoBanner->setStyleName("ShortEventBanner");
	infoBanner->setTitle(msg);
	infoBanner->appear(this, MSceneWindow::DestroyWhenDone);
	// Не работает, делается через CSS для #ShortEventBanner
	//infoBanner->style()->setProperty("disappear-timeout", 100);
}
void ConversationPage::saveAttachment()
{
    QMailMessage message(m_id);
    for (uint i = 1; i < message.partCount(); ++i)
    {
        const QMailMessagePart &sourcePart(message.partAt(i));
        if (sourcePart.location().toString(false) == m_selectedAttachment.location().toString(false))
        {
           sourcePart.writeBodyTo(m_downloadFolder);
        }
    }
    MBanner *infoBanner = new MBanner();
    //% "Download completed"
    infoBanner->setSubtitle (qtTrId("xx_download_completed"));
    infoBanner->appear(MSceneWindow::DestroyWhenDone);
}
void NotificationAreaView::updateLayout()
{
    // Remove all banners from the banner layout (do not destroy them)
    while (bannerPolicy->count() > 0) {
        bannerPolicy->removeAt(0);
    }

    // Add up to the maximum amount of banners to the layout
    bool removableBannersExist = false;
    for (int i = 0; (style()->maxBanners() < 0 || i < style()->maxBanners()) && i < model()->banners().count(); i++) {
        MBanner *banner = model()->banners().at(i);
        removableBannersExist |= banner->property(WidgetNotificationSink::USER_REMOVABLE_PROPERTY).toBool();
        bannerPolicy->addItem(banner);
    }

    // If there are more than maximum number of banners to be added show "and more"
    bool andMoreVisible = style()->maxBanners() >= 0 && model()->banners().count() > style()->maxBanners();
    andMore->setStyleName(andMoreVisible ? "AndMoreVisible" : "AndMore");
    andMore->setVisible(andMoreVisible);

    // If removable banners exist make the clear button visible
    clearButton->setStyleName((removableBannersExist && style()->clearButton()) ? "NotificationAreaClearButtonVisible" : "NotificationAreaClearButton");
}