summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArno <am@disconnect.de>2010-12-13 18:10:47 +0100
committerArno <am@disconnect.de>2010-12-13 18:10:47 +0100
commit0336e3e0e2eb02f9ad8925f1def081d6e46d750b (patch)
treed1a61e5e1a916c1227d72dadb461b4ae68d154ba
parent9f0e70a4e0d57b0979330bb1f0301517b65c8ae8 (diff)
downloadSheMov-0336e3e0e2eb02f9ad8925f1def081d6e46d750b.tar.gz
SheMov-0336e3e0e2eb02f9ad8925f1def081d6e46d750b.tar.bz2
SheMov-0336e3e0e2eb02f9ad8925f1def081d6e46d750b.zip
Buxfixes for HoverWindow
Resize widget to content when switching from pixmap to text content. To get the size let QTextDocument render the HTML and then get the size. Also set the initial opacity to the configured value in the constructor.
-rw-r--r--hoverwindow.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/hoverwindow.cpp b/hoverwindow.cpp
index 9e09728..e9fcc64 100644
--- a/hoverwindow.cpp
+++ b/hoverwindow.cpp
@@ -10,13 +10,17 @@
#include <QApplication>
#include <QDesktopWidget>
#include <QSize>
+#include <QTextDocument>
+#include <QSettings>
#include "hoverwindow.h"
#include "smglobals.h"
HoverWindow::HoverWindow(QWidget *parent, Qt::WindowFlags f) : QWidget(parent, f), mAlignCenter(false), mDesktopHeight(-1){
setVisible(false);
- setWindowOpacity(0.7);
+ QSettings s;
+ int opacity = s.value("ui/hoveropacity", 7).toInt();
+ setWindowOpacity(opacity / 10.0);
setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
setStyleSheet("QLabel { background-color: #D6A583; color: black; border-width: 2px; border-style: solid; padding: 4px; }");
QDesktopWidget *desktop = qApp->desktop();
@@ -44,7 +48,11 @@ void HoverWindow::setContent(const QString &parent, const QStringList &children)
curText.append("<li>...</li>");
}
curText.append("</ul>");
+ QTextDocument doc;
+ doc.setHtml(curText);
mLabel->setText(curText);
+ setMinimumSize(doc.size().width() + 10, doc.size().height() + 10);
+ setMaximumSize(doc.size().width() + 10, doc.size().height() + 10);
}
void HoverWindow::setPixmap(const QPixmap &pm, bool scale){