Merge branch 'master' of github.com:Sankore/Sankore-3.1

preferencesAboutTextFull
Aleksei Kanash 12 years ago
commit ed2996c981
  1. 46
      src/domain/UBAngleWidget.cpp
  2. 25
      src/domain/UBAngleWidget.h

@ -0,0 +1,46 @@
#include "UBAngleWidget.h"
#include <QPainter>
UBAngleWidget::UBAngleWidget(QWidget *parent)
: QWidget(parent)
{
this->setFixedSize(45,30);
this->setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
this->setAttribute(Qt::WA_TranslucentBackground);
QImage mask_img(width(), height(), QImage::Format_Mono);
mask_img.fill(0xff);
QPainter mask_ptr(&mask_img);
mask_ptr.setBrush( QBrush( QColor(0, 0, 0) ) );
mask_ptr.drawRoundedRect(0,0,this->geometry().width() - 6,this->geometry().height() - 6,1,1);
bmpMask = QBitmap::fromImage(mask_img);
this->setMask(bmpMask);
}
UBAngleWidget::~UBAngleWidget()
{
}
void UBAngleWidget::paintEvent(QPaintEvent *event)
{
Q_UNUSED(event);
this->move(this->cursor().pos().x(), this->cursor().pos().y() - 30);
QPainter painter(this);
painter.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
QBrush brush(Qt::white);
painter.setBrush(brush);
painter.drawRoundedRect(1,1,this->geometry().width() - 10,this->geometry().height() - 10,1,1);
painter.setPen(QColor(85,50,127));
painter.setFont(QFont("Arial", 10));
painter.drawText(1,1,this->geometry().width() - 10,this->geometry().height() - 10, Qt::AlignCenter, text);
}
void UBAngleWidget::setText(QString newText)
{
text = newText;
text.append(QChar(176));
}

@ -0,0 +1,25 @@
#ifndef UBANGLEWIDGET_H
#define UBANGLEWIDGET_H
#include <QWidget>
#include <QBitmap>
class UBAngleWidget : public QWidget
{
Q_OBJECT
public:
UBAngleWidget(QWidget *parent = 0);
~UBAngleWidget();
void setText(QString);
protected:
void paintEvent(QPaintEvent *event);
private:
QString text;
QBitmap bmpMask;
};
#endif // UBANGLEWIDGET_H
Loading…
Cancel
Save