diff options
author | Kissaki <kissaki@gmx.de> | 2015-10-03 15:33:48 +0300 |
---|---|---|
committer | Kissaki <kissaki@gmx.de> | 2015-10-11 19:30:06 +0300 |
commit | 8bf9b0a1ed99d192946fed96cfbb206600f701dc (patch) | |
tree | dd0108d8938565cb9404c97c6fa595fa1d3cc934 /src/mumble/OverlayConfig.cpp | |
parent | f732ec4c7d02f06a0ac18a3245af9e691a32188e (diff) |
Make overlay FPS and clock positionable
* Implement #1068, making the FPS and clock in the overlay positionable
like our user-block
* Introduce class OverlayPositionableItem to generalize our red
draggable anchor to set the position in the overlay settings
** Has a configuration and a display mode; with and without the anchor
** Receives a pointer to the position setting
The fps position was already set up to save, the timer not.
Use storage names according to the show flags ("time" rather than
"clock").
The anchor ("handle") and text-item are added to the scene as independant
objects to allow moving the anchor to the bottom/right, at which point
the item is prevented from bleeding over the edge (so a linked movement
of individual items with custom behavior at the right/bottom edge case).
Additional Notes:
Using relative values for positioning, the default values are best-effort
values. The space between the items (the top value of the FPS) will differ
between different screen/scene sizes.
The position is saved as a rectangle, even though a point would be enough.
Handling of visibility is sub-optimal, but works. (As we use two
independent, linked items, we have to implement our own setVisible
method, and currently only call in OverlayConfig (when using config
mode).
It looks like the overlaytext used to create a text pixmap could be
replaced by QGraphicsTextItem.
Diffstat (limited to 'src/mumble/OverlayConfig.cpp')
-rw-r--r-- | src/mumble/OverlayConfig.cpp | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/src/mumble/OverlayConfig.cpp b/src/mumble/OverlayConfig.cpp index 4b53efdaa..0051368bc 100644 --- a/src/mumble/OverlayConfig.cpp +++ b/src/mumble/OverlayConfig.cpp @@ -34,6 +34,7 @@ #include "Overlay.h" #include "OverlayUserGroup.h" +#include "OverlayPositionableItem.h" #include "OverlayText.h" #include "User.h" #include "Channel.h" @@ -58,7 +59,7 @@ static ConfigWidget *OverlayConfigDialogNew(Settings &st) { static ConfigRegistrar registrar(6000, OverlayConfigDialogNew); #endif -void OverlayConfig::initDisplay() { +void OverlayConfig::initDisplayFps() { // set up FPS preview qgsFpsPreview.clear(); qgsFpsPreview.setBackgroundBrush(qgvFpsPreview->backgroundBrush()); @@ -72,18 +73,26 @@ void OverlayConfig::initDisplay() { qgvFpsPreview->setScene(&qgsFpsPreview); qgvFpsPreview->centerOn(qgpiFpsDemo); + qgpiFpsLive = new OverlayPositionableItem(&s.os.qrfFps, true); + qgpiFpsLive->setZValue(-2.0f); + refreshFpsLive(); +} + +void OverlayConfig::initDisplayClock() { + qgpiTimeLive = new OverlayPositionableItem(&s.os.qrfTime, true); + qgpiTimeLive->setZValue(-2.0f); + refreshTimeLive(); +} + +void OverlayConfig::initDisplay() { // set up overlay preview qgpiScreen = new QGraphicsPixmapItem(); qgpiScreen->setPixmap(qpScreen); qgpiScreen->setOpacity(0.5f); qgpiScreen->setZValue(-10.0f); - qgpiFpsLive = new QGraphicsPixmapItem(); - qgpiFpsLive->setZValue(-2.0f); - qgpiTimeLive = new QGraphicsPixmapItem(); - qgpiTimeLive->setZValue(-2.0f); - refreshFpsLive(); - refreshTimeLive(); + initDisplayFps(); + initDisplayClock(); qgtiInstructions = new QGraphicsTextItem(); qgtiInstructions->setHtml(QString::fromLatin1("<ul><li>%1</li><li>%2</li><li>%3</li></ul>").arg( @@ -129,24 +138,23 @@ void OverlayConfig::refreshFpsDemo() { void OverlayConfig::refreshFpsLive() { if (s.os.bFps) { - qgpiFpsLive->setPos(s.os.qrfFps.topLeft() * fViewScale); qgpiFpsLive->setPixmap(bpFpsDemo.scaled(bpFpsDemo.size() * fViewScale)); qgpiFpsLive->setOffset((-bpFpsDemo.qpBasePoint + QPoint(0, bpFpsDemo.iAscent)) * fViewScale); } else { qgpiFpsLive->setPixmap(QPixmap()); } + qgpiFpsLive->setItemVisible(s.os.bFps); } void OverlayConfig::refreshTimeLive() { if (s.os.bTime) { bpTimeDemo = OverlayTextLine(QString::fromLatin1("%1").arg(QTime::currentTime().toString()), s.os.qfFps).createPixmap(s.os.qcFps); - qgpiTimeLive->setPixmap(bpTimeDemo); - qgpiTimeLive->setPos(s.os.qrfTime.topLeft() * fViewScale); qgpiTimeLive->setPixmap(bpTimeDemo.scaled(bpTimeDemo.size() * fViewScale)); qgpiTimeLive->setOffset((-bpTimeDemo.qpBasePoint + QPoint(0, bpTimeDemo.iAscent)) * fViewScale); } else { qgpiTimeLive->setPixmap(QPixmap()); } + qgpiTimeLive->setItemVisible(s.os.bTime); } OverlayConfig::OverlayConfig(Settings &st) : @@ -429,6 +437,9 @@ void OverlayConfig::resizeScene(bool force) { qgvView->fitInView(qgs.sceneRect(), Qt::KeepAspectRatio); oug->updateLayout(); oug->updateUsers(); + + qgpiFpsLive->updateRender(); + qgpiTimeLive->updateRender(); } void OverlayConfig::on_qpbAdd_clicked() { |