corregida la drop shadow label

This commit is contained in:
Luis Ángel San Martín 2013-06-16 14:47:14 +02:00
parent 41af5cbab5
commit ebdb21f5a2
3 changed files with 35 additions and 10 deletions

View File

@ -230,11 +230,11 @@ void LibraryWindow::doLayout()
l->addWidget(librariesTitle); l->addWidget(librariesTitle);
l->addWidget(selectedLibrary); l->addWidget(selectedLibrary);
YACReaderTitledToolBar * foldersTitle = new YACReaderTitledToolBar(tr("FOLDERS")); YACReaderTitledToolBar * foldersTitle = new YACReaderTitledToolBar(tr("FOLDERS"));
foldersTitle->addAction(setRootIndexAction); foldersTitle->addAction(setRootIndexAction);
foldersTitle->addAction(expandAllNodesAction); foldersTitle->addAction(expandAllNodesAction);
foldersTitle->addAction(colapseAllNodesAction); foldersTitle->addAction(colapseAllNodesAction);
l->addWidget(foldersTitle); l->addWidget(foldersTitle);
l->addWidget(foldersView); l->addWidget(foldersView);

View File

@ -13,6 +13,16 @@ DropShadowLabel::DropShadowLabel(QWidget* parent) :
QLabel(parent) QLabel(parent)
{ } { }
void DropShadowLabel::drawText(QPainter *painter,
QPoint offset)
{
Q_ASSERT(painter != 0);
// Draw shadow.
painter->setPen(QPen(textColor));
painter->drawText(rect().translated(offset),
alignment(), text());
}
void DropShadowLabel::drawTextEffect(QPainter *painter, void DropShadowLabel::drawTextEffect(QPainter *painter,
QPoint offset) QPoint offset)
{ {
@ -26,11 +36,18 @@ void DropShadowLabel::drawTextEffect(QPainter *painter,
void DropShadowLabel::paintEvent(QPaintEvent *event) void DropShadowLabel::paintEvent(QPaintEvent *event)
{ {
Q_UNUSED(event);
QPainter painter(this); QPainter painter(this);
painter.setFont(font()); painter.setFont(font());
//TODO find where is the '3' comming from? //TODO find where is the '3' comming from?
drawTextEffect(&painter, QPoint(contentsMargins().left()+3, 1)); drawTextEffect(&painter, QPoint(contentsMargins().left(), 1));
QLabel::paintEvent(event); drawText(&painter, QPoint(contentsMargins().left(), 0));
}
void DropShadowLabel::setColor(const QColor & color)
{
textColor = color;
} }
void DropShadowLabel::setDropShadowColor(const QColor & color) void DropShadowLabel::setDropShadowColor(const QColor & color)
@ -50,13 +67,15 @@ YACReaderTitledToolBar::YACReaderTitledToolBar(const QString & title, QWidget *p
QString styleSheet = "QWidget {border:0px;}"; QString styleSheet = "QWidget {border:0px;}";
setStyleSheet(styleSheet); setStyleSheet(styleSheet);
DropShadowLabel * nameLabel = new DropShadowLabel(this); nameLabel = new DropShadowLabel(this);
nameLabel->setText(title); nameLabel->setText(title);
#ifdef Q_OS_MAC #ifdef Q_OS_MAC
QString nameLabelStyleSheet = "QLabel {color:#707E8C; padding:0 0 0 7px; margin:0px; font-size:11px; font-weight:bold;}"; QString nameLabelStyleSheet = "QLabel {padding:0 0 0 10px; margin:0px; font-size:11px; font-weight:bold;}";
nameLabel->setColor(QColor("#707E8C"));
nameLabel->setDropShadowColor(QColor("#F9FAFB")); nameLabel->setDropShadowColor(QColor("#F9FAFB"));
#else #else
QString nameLabelStyleSheet = "QLabel {color:#BDBFBF; padding:0 0 0 7px; margin:0px; font-size:11px; font-weight:bold;}"; QString nameLabelStyleSheet = "QLabel {padding:0 0 0 10px; margin:0px; font-size:11px; font-weight:bold;}";
nameLabel->setColor(QColor("#BDBFBF"));
nameLabel->setDropShadowColor(QColor("#000000")); nameLabel->setDropShadowColor(QColor("#000000"));
#endif #endif
nameLabel->setStyleSheet(nameLabelStyleSheet); nameLabel->setStyleSheet(nameLabelStyleSheet);
@ -82,5 +101,5 @@ void YACReaderTitledToolBar::addAction(QAction * action)
tb->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum); tb->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum);
//tb->setStyleSheet("QToolButton:hover {background-color:#C5C5C5;}"); //tb->setStyleSheet("QToolButton:hover {background-color:#C5C5C5;}");
mainLayout->addWidget(tb); mainLayout->addWidget(tb);
} }

View File

@ -17,10 +17,13 @@ public:
DropShadowLabel(QWidget* parent = 0); DropShadowLabel(QWidget* parent = 0);
void paintEvent(QPaintEvent *event); void paintEvent(QPaintEvent *event);
void setColor(const QColor & color);
void setDropShadowColor(const QColor & color); void setDropShadowColor(const QColor & color);
private: private:
QColor dropShadowColor; QColor dropShadowColor;
QColor textColor;
void drawText(QPainter *painter, QPoint offset);
void drawTextEffect(QPainter* painter, QPoint offset); void drawTextEffect(QPainter* painter, QPoint offset);
}; };
@ -34,6 +37,9 @@ signals:
public slots: public slots:
void addAction(QAction * action); void addAction(QAction * action);
private:
DropShadowLabel * nameLabel;
}; };
#endif // YACREADER_TITLED_TOOLBAR_H #endif // YACREADER_TITLED_TOOLBAR_H