blob: 59c851eeb326a19801726532d6252d3c01772215 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
/*
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 <QHBoxLayout>
#include <QLabel>
#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("<p style=\"align: center; text-decoration: underline; font-weight: bold; margin-bottom: 0;\">%1</p>").arg(parent);
curText.append("<ul style=\"margin-left: -25; margin-top: 0px;\">");
int count = qMin(6, children.size());
int i = 0;
for(i = 0; i < count; ++i){
curText.append(QString("<li>%1</li>").arg(children.at(i)));
}
if(i < children.count()){
curText.append("<li>...</li>");
}
curText.append("</ul>");
mLabel->setText(curText);
}
void HoverWindow::setPixmap(const QPixmap &pm){
mLabel->setPixmap(pm);
}
|