mirror of
https://github.com/YACReader/yacreader
synced 2025-07-18 21:14:33 -04:00
fixed spaces/tabs mix
This commit is contained in:
@ -18,7 +18,7 @@ public slots:
|
||||
void loadHelp(const QString & path);
|
||||
|
||||
private:
|
||||
QTabWidget *tabWidget;
|
||||
QTabWidget *tabWidget;
|
||||
QTextBrowser *aboutText;
|
||||
QTextBrowser *helpText;
|
||||
QString fileToString(const QString & path);
|
||||
|
@ -23,164 +23,164 @@ void YACReaderBusyWidget::paintEvent(QPaintEvent * event)
|
||||
}
|
||||
|
||||
BusyIndicator::BusyIndicator(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
startAngle(0),
|
||||
m_style(StyleArc)
|
||||
QWidget(parent),
|
||||
startAngle(0),
|
||||
m_style(StyleArc)
|
||||
{
|
||||
QSizePolicy policy(QSizePolicy::Preferred, QSizePolicy::Fixed);
|
||||
policy.setHeightForWidth(true);
|
||||
setSizePolicy(policy);
|
||||
QSizePolicy policy(QSizePolicy::Preferred, QSizePolicy::Fixed);
|
||||
policy.setHeightForWidth(true);
|
||||
setSizePolicy(policy);
|
||||
|
||||
fillColor = palette().color(QPalette::WindowText);
|
||||
fillColor = palette().color(QPalette::WindowText);
|
||||
|
||||
timer.setInterval(16);
|
||||
connect(&timer, SIGNAL(timeout()), this, SLOT(rotate()));
|
||||
timer.start();
|
||||
timer.setInterval(16);
|
||||
connect(&timer, SIGNAL(timeout()), this, SLOT(rotate()));
|
||||
timer.start();
|
||||
}
|
||||
|
||||
void BusyIndicator::rotate()
|
||||
{
|
||||
startAngle += 9;
|
||||
startAngle %= 360;
|
||||
update();
|
||||
startAngle += 9;
|
||||
startAngle %= 360;
|
||||
update();
|
||||
}
|
||||
|
||||
void BusyIndicator::setIndicatorStyle(IndicatorStyle style)
|
||||
{
|
||||
m_style = style;
|
||||
update();
|
||||
m_style = style;
|
||||
update();
|
||||
}
|
||||
|
||||
void BusyIndicator::setColor(QColor color)
|
||||
{
|
||||
fillColor = color;
|
||||
fillColor = color;
|
||||
}
|
||||
|
||||
const BusyIndicator::IndicatorStyle BusyIndicator::indicatorStyle() const
|
||||
{
|
||||
return m_style;
|
||||
return m_style;
|
||||
}
|
||||
|
||||
|
||||
QPixmap BusyIndicator::generatePixmap(int side)
|
||||
{
|
||||
QPixmap pixmap(QSize(side, side));
|
||||
pixmap.fill(QColor(255, 255, 255, 0));
|
||||
QPixmap pixmap(QSize(side, side));
|
||||
pixmap.fill(QColor(255, 255, 255, 0));
|
||||
|
||||
QPainter painter(&pixmap);
|
||||
painter.setRenderHint(QPainter::Antialiasing);
|
||||
QPainter painter(&pixmap);
|
||||
painter.setRenderHint(QPainter::Antialiasing);
|
||||
|
||||
painter.translate(side / 2, side / 2);
|
||||
painter.scale(side / 200.0, side / 200.0);
|
||||
painter.translate(side / 2, side / 2);
|
||||
painter.scale(side / 200.0, side / 200.0);
|
||||
|
||||
switch (m_style) {
|
||||
case StyleRect:
|
||||
drawRectStyle(&painter);
|
||||
break;
|
||||
case StyleEllipse:
|
||||
drawEllipseStyle(&painter);
|
||||
break;
|
||||
case StyleArc:
|
||||
drawArcStyle(&painter);
|
||||
break;
|
||||
}
|
||||
return pixmap;
|
||||
switch (m_style) {
|
||||
case StyleRect:
|
||||
drawRectStyle(&painter);
|
||||
break;
|
||||
case StyleEllipse:
|
||||
drawEllipseStyle(&painter);
|
||||
break;
|
||||
case StyleArc:
|
||||
drawArcStyle(&painter);
|
||||
break;
|
||||
}
|
||||
return pixmap;
|
||||
}
|
||||
|
||||
void BusyIndicator::drawRectStyle(QPainter *painter)
|
||||
{
|
||||
// QColor color = palette().color(QPalette::WindowText);
|
||||
QColor color = fillColor;
|
||||
QBrush brush(color);
|
||||
painter->setPen(Qt::NoPen);
|
||||
// QColor color = palette().color(QPalette::WindowText);
|
||||
QColor color = fillColor;
|
||||
QBrush brush(color);
|
||||
painter->setPen(Qt::NoPen);
|
||||
|
||||
painter->rotate(startAngle);
|
||||
painter->rotate(startAngle);
|
||||
|
||||
float angle = 0;
|
||||
while (angle < 360) {
|
||||
painter->setBrush(brush);
|
||||
painter->drawRect(-8, -100, 16, 35);
|
||||
float angle = 0;
|
||||
while (angle < 360) {
|
||||
painter->setBrush(brush);
|
||||
painter->drawRect(-8, -100, 16, 35);
|
||||
|
||||
painter->rotate(30);
|
||||
angle += 30;
|
||||
painter->rotate(30);
|
||||
angle += 30;
|
||||
|
||||
color.setAlphaF(angle / 360);
|
||||
brush.setColor(color);
|
||||
}
|
||||
color.setAlphaF(angle / 360);
|
||||
brush.setColor(color);
|
||||
}
|
||||
}
|
||||
|
||||
void BusyIndicator::drawEllipseStyle(QPainter *painter)
|
||||
{
|
||||
// QColor color = palette().color(QPalette::WindowText);
|
||||
QColor color = fillColor;
|
||||
QBrush brush(color);
|
||||
painter->setPen(Qt::NoPen);
|
||||
// QColor color = palette().color(QPalette::WindowText);
|
||||
QColor color = fillColor;
|
||||
QBrush brush(color);
|
||||
painter->setPen(Qt::NoPen);
|
||||
|
||||
painter->rotate(startAngle);
|
||||
painter->rotate(startAngle);
|
||||
|
||||
float angle = 0;
|
||||
while (angle < 360) {
|
||||
painter->setBrush(brush);
|
||||
painter->drawEllipse(-10, -100, 30, 30);
|
||||
float angle = 0;
|
||||
while (angle < 360) {
|
||||
painter->setBrush(brush);
|
||||
painter->drawEllipse(-10, -100, 30, 30);
|
||||
|
||||
painter->rotate(30);
|
||||
angle += 30;
|
||||
painter->rotate(30);
|
||||
angle += 30;
|
||||
|
||||
color.setAlphaF(angle / 360);
|
||||
brush.setColor(color);
|
||||
}
|
||||
color.setAlphaF(angle / 360);
|
||||
brush.setColor(color);
|
||||
}
|
||||
}
|
||||
|
||||
void BusyIndicator::drawArcStyle(QPainter *painter)
|
||||
{
|
||||
// QColor color = palette().color(QPalette::WindowText);
|
||||
QColor color = fillColor;
|
||||
QConicalGradient gradient(0, 0, -startAngle);
|
||||
gradient.setColorAt(0, color);
|
||||
color.setAlpha(0);
|
||||
gradient.setColorAt(0.8, color);
|
||||
color.setAlpha(255);
|
||||
gradient.setColorAt(1, color);
|
||||
// QColor color = palette().color(QPalette::WindowText);
|
||||
QColor color = fillColor;
|
||||
QConicalGradient gradient(0, 0, -startAngle);
|
||||
gradient.setColorAt(0, color);
|
||||
color.setAlpha(0);
|
||||
gradient.setColorAt(0.8, color);
|
||||
color.setAlpha(255);
|
||||
gradient.setColorAt(1, color);
|
||||
|
||||
QPen pen;
|
||||
pen.setWidth(30);
|
||||
pen.setBrush(QBrush(gradient));
|
||||
painter->setPen(pen);
|
||||
QPen pen;
|
||||
pen.setWidth(30);
|
||||
pen.setBrush(QBrush(gradient));
|
||||
painter->setPen(pen);
|
||||
|
||||
painter->drawArc(-85, -85, 170, 170, 0 * 16, 360 * 16);
|
||||
painter->drawArc(-85, -85, 170, 170, 0 * 16, 360 * 16);
|
||||
}
|
||||
|
||||
void BusyIndicator::paintEvent(QPaintEvent *)
|
||||
{
|
||||
QString key = QString("%1:%2:%3:%4:%5")
|
||||
.arg(metaObject()->className())
|
||||
.arg(width())
|
||||
.arg(height())
|
||||
.arg(startAngle)
|
||||
.arg(m_style);
|
||||
QString key = QString("%1:%2:%3:%4:%5")
|
||||
.arg(metaObject()->className())
|
||||
.arg(width())
|
||||
.arg(height())
|
||||
.arg(startAngle)
|
||||
.arg(m_style);
|
||||
|
||||
QPixmap pixmap;
|
||||
QPainter painter(this);
|
||||
painter.setRenderHint(QPainter::Antialiasing);
|
||||
QPixmap pixmap;
|
||||
QPainter painter(this);
|
||||
painter.setRenderHint(QPainter::Antialiasing);
|
||||
|
||||
int side = qMin(width(), height());
|
||||
int side = qMin(width(), height());
|
||||
|
||||
if(!QPixmapCache::find(key, &pixmap)) {
|
||||
pixmap = generatePixmap(side);
|
||||
QPixmapCache::insert(key, pixmap);
|
||||
}
|
||||
if(!QPixmapCache::find(key, &pixmap)) {
|
||||
pixmap = generatePixmap(side);
|
||||
QPixmapCache::insert(key, pixmap);
|
||||
}
|
||||
|
||||
painter.translate(width() / 2 - side / 2, height() / 2 - side / 2);
|
||||
painter.translate(width() / 2 - side / 2, height() / 2 - side / 2);
|
||||
|
||||
painter.drawPixmap(0, 0, side, side, pixmap);
|
||||
painter.drawPixmap(0, 0, side, side, pixmap);
|
||||
}
|
||||
|
||||
QSize BusyIndicator::minimumSizeHint() const
|
||||
{
|
||||
return QSize(30, 30);
|
||||
return QSize(30, 30);
|
||||
}
|
||||
|
||||
QSize BusyIndicator::sizeHint() const
|
||||
{
|
||||
return QSize(30, 30);
|
||||
return QSize(30, 30);
|
||||
}
|
||||
|
@ -14,37 +14,37 @@ public:
|
||||
|
||||
class BusyIndicator : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum IndicatorStyle{StyleRect, StyleEllipse, StyleArc};
|
||||
enum IndicatorStyle{StyleRect, StyleEllipse, StyleArc};
|
||||
|
||||
explicit BusyIndicator(QWidget *parent = 0);
|
||||
explicit BusyIndicator(QWidget *parent = 0);
|
||||
|
||||
void paintEvent(QPaintEvent *);
|
||||
QSize minimumSizeHint() const;
|
||||
QSize sizeHint() const;
|
||||
void paintEvent(QPaintEvent *);
|
||||
QSize minimumSizeHint() const;
|
||||
QSize sizeHint() const;
|
||||
|
||||
void setIndicatorStyle(IndicatorStyle);
|
||||
void setColor(QColor color);
|
||||
const IndicatorStyle indicatorStyle() const;
|
||||
void setIndicatorStyle(IndicatorStyle);
|
||||
void setColor(QColor color);
|
||||
const IndicatorStyle indicatorStyle() const;
|
||||
|
||||
signals:
|
||||
|
||||
private slots:
|
||||
void rotate();
|
||||
void rotate();
|
||||
|
||||
private:
|
||||
QPixmap generatePixmap(int sideLength);
|
||||
void drawRectStyle(QPainter *painter);
|
||||
void drawEllipseStyle(QPainter *painter);
|
||||
void drawArcStyle(QPainter *painter);
|
||||
QPixmap generatePixmap(int sideLength);
|
||||
void drawRectStyle(QPainter *painter);
|
||||
void drawEllipseStyle(QPainter *painter);
|
||||
void drawArcStyle(QPainter *painter);
|
||||
|
||||
QTimer timer;
|
||||
int startAngle;
|
||||
QTimer timer;
|
||||
int startAngle;
|
||||
|
||||
IndicatorStyle m_style;
|
||||
IndicatorStyle m_style;
|
||||
|
||||
QColor fillColor;
|
||||
QColor fillColor;
|
||||
};
|
||||
|
||||
#endif // BUSYINDICATOR_H
|
||||
|
@ -8,20 +8,20 @@
|
||||
#include <QPainter>
|
||||
|
||||
YACReaderDeletingProgress::YACReaderDeletingProgress(QWidget *parent) :
|
||||
QWidget(parent)
|
||||
QWidget(parent)
|
||||
{
|
||||
QVBoxLayout * contentLayout = new QVBoxLayout(this);
|
||||
|
||||
QLabel * iconLabel = new QLabel();
|
||||
QPixmap icon(":/images/deleting_progress/icon.png");
|
||||
iconLabel->setPixmap(icon);
|
||||
QPixmap icon(":/images/deleting_progress/icon.png");
|
||||
iconLabel->setPixmap(icon);
|
||||
iconLabel->setStyleSheet("QLabel {padding:0px; margin:0px;}");
|
||||
|
||||
textMessage = new QLabel(tr("Please wait, deleting in progress..."));
|
||||
textMessage = new QLabel(tr("Please wait, deleting in progress..."));
|
||||
|
||||
textMessage->setStyleSheet("QLabel {color:#ABABAB; padding:0 0 0 0px; margin:0px; font-size:18px; font-weight:bold;}");
|
||||
|
||||
QProgressBar * progressBar = new QProgressBar();
|
||||
QProgressBar * progressBar = new QProgressBar();
|
||||
|
||||
progressBar->setTextVisible(false);
|
||||
progressBar->setFixedHeight(6);
|
||||
@ -32,18 +32,18 @@ YACReaderDeletingProgress::YACReaderDeletingProgress(QWidget *parent) :
|
||||
"QProgressBar { border: none; border-radius: 3px; background: #ABABAB; margin:0; margin-left:16; margin-right:16px;}"
|
||||
"QProgressBar::chunk {background-color: #FFC745; border: none; border-radius: 3px;}");
|
||||
|
||||
QPushButton * button = new QPushButton(tr("cancel"));
|
||||
QPushButton * button = new QPushButton(tr("cancel"));
|
||||
|
||||
button->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
|
||||
|
||||
contentLayout->addSpacing(16);
|
||||
contentLayout->addWidget(iconLabel,0,Qt::AlignHCenter);
|
||||
contentLayout->addSpacing(11);
|
||||
contentLayout->addWidget(textMessage,0,Qt::AlignHCenter);
|
||||
contentLayout->addWidget(textMessage,0,Qt::AlignHCenter);
|
||||
contentLayout->addSpacing(13);
|
||||
contentLayout->addWidget(progressBar);
|
||||
contentLayout->addWidget(progressBar);
|
||||
contentLayout->addSpacing(13);
|
||||
contentLayout->addWidget(button,0,Qt::AlignHCenter);
|
||||
contentLayout->addWidget(button,0,Qt::AlignHCenter);
|
||||
contentLayout->addSpacing(18);
|
||||
|
||||
contentLayout->setMargin(0);
|
||||
@ -60,16 +60,16 @@ void YACReaderDeletingProgress::paintEvent(QPaintEvent * event)
|
||||
int borderTop, borderRight, borderBottom, borderLeft;
|
||||
|
||||
QPixmap pL(":/images/deleting_progress/imgTopLeft.png");
|
||||
QPixmap pM(":/images/deleting_progress/imgTopMiddle.png");
|
||||
QPixmap pR(":/images/deleting_progress/imgTopRight.png");
|
||||
QPixmap pM(":/images/deleting_progress/imgTopMiddle.png");
|
||||
QPixmap pR(":/images/deleting_progress/imgTopRight.png");
|
||||
|
||||
QPixmap pLM(":/images/deleting_progress/imgLeftMiddle.png");
|
||||
|
||||
QPixmap pRM(":/images/deleting_progress/imgRightMiddle.png");
|
||||
|
||||
QPixmap pBL(":/images/deleting_progress/imgBottomLeft.png");
|
||||
QPixmap pBM(":/images/deleting_progress/imgBottomMiddle.png");
|
||||
QPixmap pBR(":/images/deleting_progress/imgBottomRight.png");
|
||||
QPixmap pBM(":/images/deleting_progress/imgBottomMiddle.png");
|
||||
QPixmap pBR(":/images/deleting_progress/imgBottomRight.png");
|
||||
|
||||
borderTop = pL.height();
|
||||
borderRight = pRM.width();
|
||||
|
@ -7,12 +7,12 @@ class QLabel;
|
||||
|
||||
class YACReaderDeletingProgress : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit YACReaderDeletingProgress(QWidget *parent = 0);
|
||||
QSize sizeHint() const;
|
||||
explicit YACReaderDeletingProgress(QWidget *parent = 0);
|
||||
QSize sizeHint() const;
|
||||
signals:
|
||||
|
||||
|
||||
public slots:
|
||||
|
||||
protected:
|
||||
@ -20,7 +20,7 @@ protected:
|
||||
|
||||
private:
|
||||
QLabel * textMessage;
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // YACREADER_DELETING_PROGRESS_H
|
||||
|
@ -16,12 +16,12 @@ YACReaderFieldEdit::YACReaderFieldEdit(QWidget * parent)
|
||||
void YACReaderFieldEdit::focusInEvent(QFocusEvent* e)
|
||||
{
|
||||
if (e->reason() == Qt::MouseFocusReason)
|
||||
{
|
||||
setModified(true);
|
||||
{
|
||||
setModified(true);
|
||||
setPlaceholderText("");
|
||||
}
|
||||
}
|
||||
|
||||
QLineEdit::focusInEvent(e);
|
||||
QLineEdit::focusInEvent(e);
|
||||
}
|
||||
|
||||
void YACReaderFieldEdit::clear()
|
||||
|
@ -15,13 +15,13 @@ YACReaderFieldPlainTextEdit::YACReaderFieldPlainTextEdit(QWidget * parent)
|
||||
void YACReaderFieldPlainTextEdit::focusInEvent(QFocusEvent* e)
|
||||
{
|
||||
if (e->reason() == Qt::MouseFocusReason || e->reason() == Qt::TabFocusReason)
|
||||
{
|
||||
document()->setModified(true);
|
||||
{
|
||||
document()->setModified(true);
|
||||
if(toPlainText()==tr("Click to overwrite"))
|
||||
setPlainText("");
|
||||
}
|
||||
}
|
||||
|
||||
QPlainTextEdit::focusInEvent(e);
|
||||
QPlainTextEdit::focusInEvent(e);
|
||||
}
|
||||
|
||||
void YACReaderFieldPlainTextEdit::focusOutEvent(QFocusEvent* e)
|
||||
|
@ -9,7 +9,7 @@ class YACReaderFlow : public PictureFlow
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
YACReaderFlow(QWidget * parent,FlowType flowType = CoverFlowLike);
|
||||
YACReaderFlow(QWidget * parent,FlowType flowType = CoverFlowLike);
|
||||
|
||||
void mousePressEvent(QMouseEvent* event);
|
||||
void mouseDoubleClickEvent(QMouseEvent* event);
|
||||
|
@ -6,7 +6,7 @@
|
||||
#include <QMouseEvent>
|
||||
|
||||
YACReaderLibraryItemWidget::YACReaderLibraryItemWidget(QString n/*ame*/, QString p/*ath*/, QWidget *parent) :
|
||||
QWidget(parent),name(n),path(p),isSelected(false)
|
||||
QWidget(parent),name(n),path(p),isSelected(false)
|
||||
{
|
||||
QHBoxLayout * mainLayout = new QHBoxLayout;
|
||||
mainLayout->setMargin(0);
|
||||
@ -134,7 +134,7 @@ void YACReaderLibraryItemWidget::deselect()
|
||||
void YACReaderLibraryItemWidget::select()
|
||||
{
|
||||
#ifdef Q_OS_MAC
|
||||
QString styleSheet ="color: white; background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #6BAFE4, stop: 1 #3984D2); border-top: 2px solid qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #5EA3DF, stop: 1 #73B8EA); border-left:none;border-right:none;border-bottom:1px solid #3577C2;";
|
||||
QString styleSheet ="color: white; background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #6BAFE4, stop: 1 #3984D2); border-top: 2px solid qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #5EA3DF, stop: 1 #73B8EA); border-left:none;border-right:none;border-bottom:1px solid #3577C2;";
|
||||
#else
|
||||
QString styleSheet = "color: white; background-color:#2E2E2E; font-weight:bold;";
|
||||
#endif
|
||||
|
@ -10,21 +10,21 @@ class QEvent;
|
||||
|
||||
class YACReaderLibraryItemWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
YACReaderLibraryItemWidget(QString name, QString path, QWidget *parent = 0);
|
||||
YACReaderLibraryItemWidget(QString name, QString path, QWidget *parent = 0);
|
||||
QString name;
|
||||
QString path;
|
||||
|
||||
signals:
|
||||
void selected(QString,QString);
|
||||
void selected(QString,QString);
|
||||
void showOptions();
|
||||
|
||||
public slots:
|
||||
void showUpDownButtons(bool show);
|
||||
|
||||
//bool eventFilter(QObject *object, QEvent *event);
|
||||
//bool eventFilter(QObject *object, QEvent *event);
|
||||
void select();
|
||||
void deselect();
|
||||
void setName(const QString & name);
|
||||
|
@ -7,7 +7,7 @@
|
||||
#include "qnaturalsorting.h"
|
||||
|
||||
YACReaderLibraryListWidget::YACReaderLibraryListWidget(QWidget *parent) :
|
||||
QWidget(parent),currentLibraryIndex(-1)
|
||||
QWidget(parent),currentLibraryIndex(-1)
|
||||
{
|
||||
QVBoxLayout * mainLayout = new QVBoxLayout;
|
||||
mainLayout->setSpacing(0);
|
||||
|
@ -8,13 +8,13 @@ class QMouseEvent;
|
||||
|
||||
class YACReaderLibraryListWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit YACReaderLibraryListWidget(QWidget *parent = 0);
|
||||
|
||||
explicit YACReaderLibraryListWidget(QWidget *parent = 0);
|
||||
|
||||
signals:
|
||||
void currentIndexChanged(QString text);
|
||||
|
||||
|
||||
public slots:
|
||||
QString currentText();
|
||||
int findText(QString text);
|
||||
@ -30,7 +30,7 @@ private:
|
||||
int currentLibraryIndex;
|
||||
QList < YACReaderLibraryItemWidget* > librariesList;
|
||||
void deselectAllBut(int index);
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // YACREADER_LIBRARY_LIST_WIDGET_H
|
||||
|
@ -5,45 +5,45 @@
|
||||
#include <QLabel>
|
||||
|
||||
YACReaderSearchLineEdit::YACReaderSearchLineEdit(QWidget *parent)
|
||||
: QLineEdit(parent)
|
||||
: QLineEdit(parent)
|
||||
{
|
||||
clearButton = new QToolButton(this);
|
||||
clearButton = new QToolButton(this);
|
||||
searchLabel = new QLabel(this);
|
||||
|
||||
QPixmap pixmap(":/images/clearSearch.png");
|
||||
QPixmap pixmap(":/images/clearSearch.png");
|
||||
QPixmap pixmapIcon(":/images/iconSearch.png");
|
||||
|
||||
searchLabel->setStyleSheet("QLabel { border: none; padding: 0px; }");
|
||||
searchLabel->setPixmap(pixmapIcon);
|
||||
|
||||
clearButton->setIcon(QIcon(pixmap));
|
||||
clearButton->setIconSize(pixmap.size());
|
||||
clearButton->setCursor(Qt::ArrowCursor);
|
||||
clearButton->setStyleSheet("QToolButton { border: none; padding: 0px; }");
|
||||
clearButton->hide();
|
||||
connect(clearButton, SIGNAL(clicked()), this, SLOT(clear()));
|
||||
connect(this, SIGNAL(textChanged(const QString&)), this, SLOT(updateCloseButton(const QString&)));
|
||||
int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
|
||||
clearButton->setIcon(QIcon(pixmap));
|
||||
clearButton->setIconSize(pixmap.size());
|
||||
clearButton->setCursor(Qt::ArrowCursor);
|
||||
clearButton->setStyleSheet("QToolButton { border: none; padding: 0px; }");
|
||||
clearButton->hide();
|
||||
connect(clearButton, SIGNAL(clicked()), this, SLOT(clear()));
|
||||
connect(this, SIGNAL(textChanged(const QString&)), this, SLOT(updateCloseButton(const QString&)));
|
||||
int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
|
||||
#ifdef Q_OS_MAC
|
||||
setStyleSheet(QString("QLineEdit {border-top:1px solid #9F9F9F; border-bottom:1px solid #ACACAC; border-right:1px solid #ACACAC; border-left:1px solid #ACACAC; border-radius: 10px; background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #CACACA, stop: 0.15 #FFFFFF); padding-left: %1px; padding-right: %2px; padding-bottom: 1px; margin-bottom: 1px;} ").arg(searchLabel->sizeHint().width() + frameWidth + 6).arg(clearButton->sizeHint().width() + frameWidth + 2));
|
||||
setStyleSheet(QString("QLineEdit {border-top:1px solid #9F9F9F; border-bottom:1px solid #ACACAC; border-right:1px solid #ACACAC; border-left:1px solid #ACACAC; border-radius: 10px; background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #CACACA, stop: 0.15 #FFFFFF); padding-left: %1px; padding-right: %2px; padding-bottom: 1px; margin-bottom: 1px;} ").arg(searchLabel->sizeHint().width() + frameWidth + 6).arg(clearButton->sizeHint().width() + frameWidth + 2));
|
||||
#else
|
||||
setStyleSheet(QString("QLineEdit {border:none; background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #CACACA, stop: 0.15 #FFFFFF);; padding-left: %1px; padding-right: %2px; padding-bottom: 1px; margin-bottom: 0px;} ").arg(searchLabel->sizeHint().width() + frameWidth + 6).arg(clearButton->sizeHint().width() + frameWidth + 2));
|
||||
#endif
|
||||
QSize msz = minimumSizeHint();
|
||||
setMinimumSize(qMax(msz.width(), clearButton->sizeHint().height() + frameWidth * 2 + 2),
|
||||
qMax(msz.height(), clearButton->sizeHint().height() + frameWidth * 2 + 2));
|
||||
QSize msz = minimumSizeHint();
|
||||
setMinimumSize(qMax(msz.width(), clearButton->sizeHint().height() + frameWidth * 2 + 2),
|
||||
qMax(msz.height(), clearButton->sizeHint().height() + frameWidth * 2 + 2));
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
setMaximumWidth(300);
|
||||
setMaximumWidth(300);
|
||||
#endif
|
||||
}
|
||||
|
||||
void YACReaderSearchLineEdit::resizeEvent(QResizeEvent *)
|
||||
{
|
||||
QSize sz = clearButton->sizeHint();
|
||||
int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
|
||||
clearButton->move(rect().right() - frameWidth - sz.width(),
|
||||
(rect().bottom() + 1 - sz.height())/2);
|
||||
QSize sz = clearButton->sizeHint();
|
||||
int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
|
||||
clearButton->move(rect().right() - frameWidth - sz.width(),
|
||||
(rect().bottom() + 1 - sz.height())/2);
|
||||
|
||||
QSize szl = searchLabel->sizeHint();
|
||||
searchLabel->move(6,(rect().bottom() + 1 - szl.height())/2);
|
||||
@ -51,5 +51,5 @@ void YACReaderSearchLineEdit::resizeEvent(QResizeEvent *)
|
||||
|
||||
void YACReaderSearchLineEdit::updateCloseButton(const QString& text)
|
||||
{
|
||||
clearButton->setVisible(!text.isEmpty());
|
||||
clearButton->setVisible(!text.isEmpty());
|
||||
}
|
||||
|
@ -8,19 +8,19 @@ class QLabel;
|
||||
|
||||
class YACReaderSearchLineEdit : public QLineEdit
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
YACReaderSearchLineEdit(QWidget *parent = 0);
|
||||
YACReaderSearchLineEdit(QWidget *parent = 0);
|
||||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *);
|
||||
void resizeEvent(QResizeEvent *);
|
||||
|
||||
private slots:
|
||||
void updateCloseButton(const QString &text);
|
||||
void updateCloseButton(const QString &text);
|
||||
|
||||
private:
|
||||
QToolButton *clearButton;
|
||||
QToolButton *clearButton;
|
||||
QLabel * searchLabel;
|
||||
};
|
||||
|
||||
|
@ -11,9 +11,9 @@ class YACReaderTitledToolBar;
|
||||
|
||||
class YACReaderSideBar : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit YACReaderSideBar(QWidget *parent = 0);
|
||||
explicit YACReaderSideBar(QWidget *parent = 0);
|
||||
QSize sizeHint() const;
|
||||
|
||||
YACReaderTreeView * foldersView;
|
||||
@ -21,14 +21,14 @@ public:
|
||||
YACReaderSearchLineEdit * foldersFilter;
|
||||
YACReaderTitledToolBar * librariesTitle;
|
||||
YACReaderTitledToolBar * foldersTitle;
|
||||
|
||||
|
||||
signals:
|
||||
|
||||
|
||||
public slots:
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *);
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // YACREADER_SIDEBAR_H
|
||||
|
@ -10,44 +10,44 @@
|
||||
|
||||
|
||||
DropShadowLabel::DropShadowLabel(QWidget* parent) :
|
||||
QLabel(parent)
|
||||
QLabel(parent)
|
||||
{ }
|
||||
|
||||
void DropShadowLabel::drawText(QPainter *painter,
|
||||
QPoint offset)
|
||||
QPoint offset)
|
||||
{
|
||||
Q_ASSERT(painter != 0);
|
||||
Q_ASSERT(painter != 0);
|
||||
|
||||
// Draw shadow.
|
||||
painter->setPen(QPen(textColor));
|
||||
painter->drawText(rect().translated(offset),
|
||||
alignment(), text());
|
||||
// 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);
|
||||
Q_ASSERT(painter != 0);
|
||||
|
||||
// Draw shadow.
|
||||
painter->setPen(QPen(dropShadowColor));
|
||||
painter->drawText(rect().translated(offset),
|
||||
alignment(), text());
|
||||
// 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());
|
||||
//TODO find where is the '3' comming from?
|
||||
drawTextEffect(&painter, QPoint(contentsMargins().left(), 1));
|
||||
drawText(&painter, QPoint(contentsMargins().left(), 0));
|
||||
QPainter painter(this);
|
||||
painter.setFont(font());
|
||||
//TODO find where is the '3' comming from?
|
||||
drawTextEffect(&painter, QPoint(contentsMargins().left(), 1));
|
||||
drawText(&painter, QPoint(contentsMargins().left(), 0));
|
||||
}
|
||||
|
||||
void DropShadowLabel::setColor(const QColor & color)
|
||||
{
|
||||
textColor = color;
|
||||
textColor = color;
|
||||
}
|
||||
|
||||
void DropShadowLabel::setDropShadowColor(const QColor & color)
|
||||
@ -58,7 +58,7 @@ void DropShadowLabel::setDropShadowColor(const QColor & color)
|
||||
|
||||
|
||||
YACReaderTitledToolBar::YACReaderTitledToolBar(const QString & title, QWidget *parent) :
|
||||
QWidget(parent)
|
||||
QWidget(parent)
|
||||
{
|
||||
QHBoxLayout * mainLayout = new QHBoxLayout;
|
||||
mainLayout->setMargin(0);
|
||||
@ -67,15 +67,15 @@ YACReaderTitledToolBar::YACReaderTitledToolBar(const QString & title, QWidget *p
|
||||
QString styleSheet = "QWidget {border:0px;}";
|
||||
setStyleSheet(styleSheet);
|
||||
|
||||
nameLabel = new DropShadowLabel(this);
|
||||
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;}";
|
||||
nameLabel->setColor(QColor("#707E8C"));
|
||||
QString nameLabelStyleSheet = "QLabel {padding:0 0 0 10px; margin:0px; font-size:11px; font-weight:bold;}";
|
||||
nameLabel->setColor(QColor("#707E8C"));
|
||||
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"));
|
||||
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);
|
||||
@ -101,7 +101,7 @@ void YACReaderTitledToolBar::addAction(QAction * action)
|
||||
tb->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum);
|
||||
//tb->setStyleSheet("QToolButton:hover {background-color:#C5C5C5;}");
|
||||
|
||||
mainLayout->addWidget(tb);
|
||||
mainLayout->addWidget(tb);
|
||||
}
|
||||
|
||||
void YACReaderTitledToolBar::addSpacing(int spacing)
|
||||
|
@ -11,35 +11,35 @@ class QIcon;
|
||||
|
||||
class DropShadowLabel : public QLabel
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
DropShadowLabel(QWidget* parent = 0);
|
||||
void paintEvent(QPaintEvent *event);
|
||||
void setColor(const QColor & color);
|
||||
DropShadowLabel(QWidget* parent = 0);
|
||||
void paintEvent(QPaintEvent *event);
|
||||
void setColor(const QColor & color);
|
||||
void setDropShadowColor(const QColor & color);
|
||||
private:
|
||||
|
||||
QColor dropShadowColor;
|
||||
QColor textColor;
|
||||
void drawText(QPainter *painter, QPoint offset);
|
||||
void drawTextEffect(QPainter* painter, QPoint offset);
|
||||
QColor textColor;
|
||||
void drawText(QPainter *painter, QPoint offset);
|
||||
void drawTextEffect(QPainter* painter, QPoint offset);
|
||||
};
|
||||
|
||||
class YACReaderTitledToolBar : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit YACReaderTitledToolBar(const QString & title, QWidget *parent = 0);
|
||||
|
||||
explicit YACReaderTitledToolBar(const QString & title, QWidget *parent = 0);
|
||||
|
||||
signals:
|
||||
|
||||
|
||||
public slots:
|
||||
void addAction(QAction * action);
|
||||
void addAction(QAction * action);
|
||||
void addSpacing(int space);
|
||||
private:
|
||||
DropShadowLabel * nameLabel;
|
||||
DropShadowLabel * nameLabel;
|
||||
};
|
||||
|
||||
#endif // YACREADER_TITLED_TOOLBAR_H
|
||||
|
Reference in New Issue
Block a user