GlaucaDetailListWidget::GlaucaDetailListWidget(const QPixmap &icon, QWidget *parent):QWidget(parent){
    QHBoxLayout* mainLayout=new QHBoxLayout(this);
    QLabel iconLabel(this);
    iconLabel.setPixmap(icon.scaled(40,40));
    mainLayout->addWidget(&iconLabel);
    //QVBoxLayout* detailLayout=new QVBoxLayout(this);
    titleLabel=new QLabel(this);
    detailLabel=new QLabel(this);
    progressLayout=new QHBoxLayout(this);
    progress=new QProgressBar(this);
    progressLayout->addWidget(progress);
    progressLayout->addStretch(0);
    cancelButton=new QToolButton(this);
    stopButton=new QToolButton(this);
    continueButton=new QToolButton(this);
    progressLayout->addWidget(cancelButton,Qt::AlignRight);
    progressLayout->addWidget(stopButton,Qt::AlignRight);
    progressLayout->addWidget(continueButton,Qt::AlignRight);
    continueButton->hide();
    connect(stopButton,SIGNAL(clicked()),stopButton,SLOT(hide()));
    connect(stopButton,SIGNAL(clicked()),continueButton,SLOT(show()));
    connect(continueButton,SIGNAL(clicked()),continueButton,SLOT(hide()));
    connect(continueButton,SIGNAL(clicked()),stopButton,SLOT(show()));
}
Esempio n. 2
0
NotificationDialog::NotificationDialog(Notification *notification, QWidget *parent) : QDialog(parent),
	m_notification(notification),
	m_closeLabel(nullptr),
	m_closeTimer(0)
{
	QFrame *notificationFrame(new QFrame(this));
	notificationFrame->setObjectName(QLatin1String("notificationFrame"));
	notificationFrame->setStyleSheet(QLatin1String("#notificationFrame {padding:5px;border:1px solid #CCC;border-radius:10px;background:#F0F0f0;}"));
	notificationFrame->setCursor(QCursor(Qt::PointingHandCursor));
	notificationFrame->installEventFilter(this);

	QBoxLayout *mainLayout(new QBoxLayout(QBoxLayout::LeftToRight));
	mainLayout->setContentsMargins(0, 0, 0, 0);
	mainLayout->setSpacing(0);
	mainLayout->setSizeConstraint(QLayout::SetMinimumSize);
	mainLayout->addWidget(notificationFrame);

	QLabel *iconLabel(new QLabel(this));
	iconLabel->setPixmap(ThemesManager::createIcon(QLatin1String("otter-browser-32")).pixmap(32, 32));
	iconLabel->setStyleSheet(QLatin1String("padding:5px;"));

	QLabel *messageLabel(new QLabel(this));
	messageLabel->setText(m_notification->getMessage());
	messageLabel->setStyleSheet(QLatin1String("padding:5px;font-size:13px;"));
	messageLabel->setWordWrap(true);

	QStyleOption option;
	option.rect = QRect(0, 0, 16, 16);

	QPixmap pixmap(16, 16);
	pixmap.fill(Qt::transparent);

	QPainter painter(&pixmap);

	style()->drawPrimitive(QStyle::PE_IndicatorTabClose, &option, &painter, this);

	m_closeLabel = new QLabel(notificationFrame);
	m_closeLabel->setToolTip(tr("Close"));
	m_closeLabel->setPixmap(pixmap);
	m_closeLabel->setAlignment(Qt::AlignTop);
	m_closeLabel->setMargin(5);
	m_closeLabel->installEventFilter(this);

	QBoxLayout *notificationLayout(new QBoxLayout(QBoxLayout::LeftToRight));
	notificationLayout->setContentsMargins(0, 0, 0, 0);
	notificationLayout->setSpacing(0);
	notificationLayout->setSizeConstraint(QLayout::SetMinimumSize);
	notificationLayout->addWidget(iconLabel);
	notificationLayout->addWidget(messageLabel);
	notificationLayout->addWidget(m_closeLabel);

	notificationFrame->setLayout(notificationLayout);

	setLayout(mainLayout);
	setFixedWidth(400);
	setMinimumHeight(50);
	setMaximumHeight(150);
	setWindowOpacity(0);
	setWindowFlags(Qt::WindowStaysOnTopHint | Qt::Tool | Qt::FramelessWindowHint);
	setFocusPolicy(Qt::NoFocus);
	setAttribute(Qt::WA_DeleteOnClose, true);
	setAttribute(Qt::WA_ShowWithoutActivating, true);
	setAttribute(Qt::WA_TranslucentBackground, true);
	adjustSize();

	m_animation = new QPropertyAnimation(this, QStringLiteral("windowOpacity").toLatin1());
	m_animation->setDuration(500);
	m_animation->setStartValue(0.0);
	m_animation->setEndValue(1.0);
	m_animation->start();

	const int visibilityDuration(SettingsManager::getOption(SettingsManager::Interface_NotificationVisibilityDurationOption).toInt());

	if (visibilityDuration > 0)
	{
		m_closeTimer = startTimer(visibilityDuration * 1000);
	}
}