mirror of
https://github.com/YACReader/yacreader
synced 2025-07-17 20:44:32 -04:00
Format code using clang-format
This commit is contained in:
@ -8,97 +8,94 @@
|
||||
#include <QPushButton>
|
||||
#include <QToolButton>
|
||||
|
||||
|
||||
DropShadowLabel::DropShadowLabel(QWidget* parent) :
|
||||
QLabel(parent)
|
||||
{ }
|
||||
|
||||
void DropShadowLabel::drawText(QPainter *painter,
|
||||
QPoint offset)
|
||||
DropShadowLabel::DropShadowLabel(QWidget *parent)
|
||||
: QLabel(parent)
|
||||
{
|
||||
Q_ASSERT(painter != 0);
|
||||
}
|
||||
|
||||
// Draw shadow.
|
||||
painter->setPen(QPen(textColor));
|
||||
painter->drawText(rect().translated(offset),
|
||||
alignment(), text());
|
||||
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,
|
||||
QPoint offset)
|
||||
QPoint offset)
|
||||
{
|
||||
Q_ASSERT(painter != 0);
|
||||
|
||||
// Draw shadow.
|
||||
painter->setPen(QPen(dropShadowColor));
|
||||
painter->drawText(rect().translated(offset),
|
||||
alignment(), text());
|
||||
Q_ASSERT(painter != 0);
|
||||
|
||||
// Draw shadow.
|
||||
painter->setPen(QPen(dropShadowColor));
|
||||
painter->drawText(rect().translated(offset),
|
||||
alignment(), text());
|
||||
}
|
||||
|
||||
|
||||
void DropShadowLabel::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
Q_UNUSED(event);
|
||||
|
||||
QPainter painter(this);
|
||||
painter.setFont(font());
|
||||
QPainter painter(this);
|
||||
painter.setFont(font());
|
||||
#ifndef Q_OS_MAC
|
||||
drawTextEffect(&painter, QPoint(contentsMargins().left(), 1));
|
||||
drawTextEffect(&painter, QPoint(contentsMargins().left(), 1));
|
||||
#endif
|
||||
drawText(&painter, QPoint(contentsMargins().left(), 0));
|
||||
drawText(&painter, QPoint(contentsMargins().left(), 0));
|
||||
}
|
||||
|
||||
void DropShadowLabel::setColor(const QColor & color)
|
||||
void DropShadowLabel::setColor(const QColor &color)
|
||||
{
|
||||
textColor = color;
|
||||
textColor = color;
|
||||
}
|
||||
|
||||
void DropShadowLabel::setDropShadowColor(const QColor & color)
|
||||
void DropShadowLabel::setDropShadowColor(const QColor &color)
|
||||
{
|
||||
dropShadowColor = color;
|
||||
dropShadowColor = color;
|
||||
}
|
||||
|
||||
|
||||
|
||||
YACReaderTitledToolBar::YACReaderTitledToolBar(const QString & title, QWidget *parent) :
|
||||
QWidget(parent)
|
||||
YACReaderTitledToolBar::YACReaderTitledToolBar(const QString &title, QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
QHBoxLayout * mainLayout = new QHBoxLayout;
|
||||
mainLayout->setMargin(0);
|
||||
mainLayout->setSpacing(0);
|
||||
QHBoxLayout *mainLayout = new QHBoxLayout;
|
||||
mainLayout->setMargin(0);
|
||||
mainLayout->setSpacing(0);
|
||||
|
||||
QString styleSheet = "QWidget {border:0px;}";
|
||||
QString styleSheet = "QWidget {border:0px;}";
|
||||
setStyleSheet(styleSheet);
|
||||
|
||||
nameLabel = new DropShadowLabel(this);
|
||||
nameLabel->setText(title);
|
||||
nameLabel = new DropShadowLabel(this);
|
||||
nameLabel->setText(title);
|
||||
#ifdef Q_OS_MAC
|
||||
QString nameLabelStyleSheet = "QLabel {padding:0 0 0 10px; 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("#808080"));
|
||||
//nameLabel->setDropShadowColor(QColor("#F9FAFB"));
|
||||
#else
|
||||
QString nameLabelStyleSheet = "QLabel {padding:0 0 0 10px; margin:0px; font-size:11px; font-weight:bold;}";
|
||||
nameLabel->setColor(QColor("#BDBFBF"));
|
||||
nameLabel->setDropShadowColor(QColor("#000000"));
|
||||
QString nameLabelStyleSheet = "QLabel {padding:0 0 0 10px; margin:0px; font-size:11px; font-weight:bold;}";
|
||||
nameLabel->setColor(QColor("#BDBFBF"));
|
||||
nameLabel->setDropShadowColor(QColor("#000000"));
|
||||
#endif
|
||||
nameLabel->setStyleSheet(nameLabelStyleSheet);
|
||||
nameLabel->setStyleSheet(nameLabelStyleSheet);
|
||||
|
||||
mainLayout->addWidget(nameLabel,Qt::AlignLeft);
|
||||
mainLayout->addStretch();
|
||||
mainLayout->addWidget(nameLabel, Qt::AlignLeft);
|
||||
mainLayout->addStretch();
|
||||
|
||||
setLayout(mainLayout);
|
||||
setLayout(mainLayout);
|
||||
|
||||
setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum);
|
||||
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
|
||||
|
||||
setMinimumHeight(25);
|
||||
}
|
||||
|
||||
|
||||
void YACReaderTitledToolBar::addAction(QAction * action)
|
||||
void YACReaderTitledToolBar::addAction(QAction *action)
|
||||
{
|
||||
QHBoxLayout * mainLayout = dynamic_cast<QHBoxLayout *>(layout());
|
||||
QHBoxLayout *mainLayout = dynamic_cast<QHBoxLayout *>(layout());
|
||||
|
||||
//fix for QToolButton and retina support in OSX
|
||||
#ifdef Q_OS_MAC
|
||||
QPushButton * pb = new QPushButton(this);
|
||||
QPushButton *pb = new QPushButton(this);
|
||||
pb->setCursor(QCursor(Qt::ArrowCursor));
|
||||
pb->setIcon(action->icon());
|
||||
pb->addAction(action);
|
||||
@ -107,12 +104,12 @@ void YACReaderTitledToolBar::addAction(QAction * action)
|
||||
|
||||
mainLayout->addWidget(pb);
|
||||
#else
|
||||
QToolButton * tb = new QToolButton(this);
|
||||
QToolButton *tb = new QToolButton(this);
|
||||
tb->setCursor(QCursor(Qt::ArrowCursor));
|
||||
tb->setDefaultAction(action);
|
||||
tb->setIconSize(QSize(16,16));
|
||||
tb->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum);
|
||||
//tb->setStyleSheet("QToolButton:hover {background-color:#C5C5C5;}");
|
||||
tb->setIconSize(QSize(16, 16));
|
||||
tb->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
|
||||
//tb->setStyleSheet("QToolButton:hover {background-color:#C5C5C5;}");
|
||||
|
||||
mainLayout->addWidget(tb);
|
||||
#endif
|
||||
@ -120,17 +117,17 @@ void YACReaderTitledToolBar::addAction(QAction * action)
|
||||
|
||||
void YACReaderTitledToolBar::addSpacing(int spacing)
|
||||
{
|
||||
QHBoxLayout * mainLayout = dynamic_cast<QHBoxLayout *>(layout());
|
||||
QHBoxLayout *mainLayout = dynamic_cast<QHBoxLayout *>(layout());
|
||||
|
||||
mainLayout->addSpacing(spacing);
|
||||
}
|
||||
|
||||
void YACReaderTitledToolBar::addSepartor()
|
||||
{
|
||||
QHBoxLayout * mainLayout = dynamic_cast<QHBoxLayout *>(layout());
|
||||
QHBoxLayout *mainLayout = dynamic_cast<QHBoxLayout *>(layout());
|
||||
|
||||
QWidget * w = new QWidget(this);
|
||||
w->setFixedSize(1,14);
|
||||
QWidget *w = new QWidget(this);
|
||||
w->setFixedSize(1, 14);
|
||||
#ifdef Q_OS_MAC
|
||||
w->setStyleSheet("QWidget {background-color:#AFAFAF;}");
|
||||
#else
|
||||
|
Reference in New Issue
Block a user