/* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. */ #include #include #include "hoverwindow.h" HoverWindow::HoverWindow(QWidget *parent, Qt::WindowFlags f) : QWidget(parent, f){ setVisible(false); setWindowOpacity(0.7); setStyleSheet("QLabel { background-color: #D6A583; color: black; border-width: 2px; border-style: solid; padding: 4px; }"); QHBoxLayout *mainLayout = new QHBoxLayout; mainLayout->setContentsMargins(4, 4, 4, 4); mLabel = new QLabel; mainLayout->addWidget(mLabel); setLayout(mainLayout); } void HoverWindow::setContent(const QString &parent, const QStringList &children){ QString curText = QString("

%1

").arg(parent); curText.append(""); mLabel->setText(curText); } void HoverWindow::setPixmap(const QPixmap &pm){ QPixmap curPm = pm; if(curPm.height() > 500){ curPm = curPm.scaledToHeight(500); } if(curPm.width() > 300){ curPm = curPm.scaledToWidth(300); } mLabel->setPixmap(curPm); } int HoverWindow::pixmapHeight() const{ const QPixmap *pm = mLabel->pixmap(); return pm ? pm->height() : 0; }