Add .gitattributes rules for text and binary handling

This commit is contained in:
Felix Kauselmann
2018-07-01 21:29:59 +02:00
parent 4f6618c096
commit d5a11fb16b
377 changed files with 54049 additions and 53970 deletions

View File

@ -1,75 +1,75 @@
#include "help_about_dialog.h"
#include <QVBoxLayout>
#include <QTabWidget>
#include <QTextBrowser>
#include <QApplication>
#include <QFile>
#include <QTextStream>
#include <QTextCodec>
#include <QDesktopWidget>
#include "yacreader_global.h"
HelpAboutDialog::HelpAboutDialog(QWidget * parent)
:QDialog(parent)
{
QVBoxLayout * layout = new QVBoxLayout();
tabWidget = new QTabWidget();
tabWidget->addTab(aboutText = new QTextBrowser(), tr("About"));
aboutText->setOpenExternalLinks(true);
//aboutText->setFont(QFont("Comic Sans MS", 10)); //purisa
tabWidget->addTab(helpText = new QTextBrowser(), tr("Help"));
helpText->setOpenExternalLinks(true);
//helpText->setFont(QFont("Comic Sans MS", 10));
//helpText->setDisabled(true);
//tabWidget->addTab(,"About Qt");
layout->addWidget(tabWidget);
layout->setContentsMargins(1,3,1,1);
setLayout(layout);
resize(500, QApplication::desktop()->availableGeometry().height()*0.83);
}
HelpAboutDialog::~HelpAboutDialog()
{
delete aboutText;
delete helpText;
delete tabWidget;
}
HelpAboutDialog::HelpAboutDialog(const QString & pathAbout,const QString & pathHelp,QWidget * parent)
:QDialog(parent)
{
loadAboutInformation(pathAbout);
loadHelp(pathHelp);
}
void HelpAboutDialog::loadAboutInformation(const QString & path)
{
aboutText->setHtml(fileToString(path).arg(VERSION));
aboutText->moveCursor(QTextCursor::Start);
}
void HelpAboutDialog::loadHelp(const QString & path)
{
helpText->setHtml(fileToString(path));
helpText->moveCursor(QTextCursor::Start);
}
QString HelpAboutDialog::fileToString(const QString & path)
{
QFile f(path);
f.open(QIODevice::ReadOnly);
QTextStream txtS(&f);
txtS.setCodec(QTextCodec::codecForName("UTF-8"));
QString content = txtS.readAll();
f.close();
return content;
#include "help_about_dialog.h"
#include <QVBoxLayout>
#include <QTabWidget>
#include <QTextBrowser>
#include <QApplication>
#include <QFile>
#include <QTextStream>
#include <QTextCodec>
#include <QDesktopWidget>
#include "yacreader_global.h"
HelpAboutDialog::HelpAboutDialog(QWidget * parent)
:QDialog(parent)
{
QVBoxLayout * layout = new QVBoxLayout();
tabWidget = new QTabWidget();
tabWidget->addTab(aboutText = new QTextBrowser(), tr("About"));
aboutText->setOpenExternalLinks(true);
//aboutText->setFont(QFont("Comic Sans MS", 10)); //purisa
tabWidget->addTab(helpText = new QTextBrowser(), tr("Help"));
helpText->setOpenExternalLinks(true);
//helpText->setFont(QFont("Comic Sans MS", 10));
//helpText->setDisabled(true);
//tabWidget->addTab(,"About Qt");
layout->addWidget(tabWidget);
layout->setContentsMargins(1,3,1,1);
setLayout(layout);
resize(500, QApplication::desktop()->availableGeometry().height()*0.83);
}
HelpAboutDialog::~HelpAboutDialog()
{
delete aboutText;
delete helpText;
delete tabWidget;
}
HelpAboutDialog::HelpAboutDialog(const QString & pathAbout,const QString & pathHelp,QWidget * parent)
:QDialog(parent)
{
loadAboutInformation(pathAbout);
loadHelp(pathHelp);
}
void HelpAboutDialog::loadAboutInformation(const QString & path)
{
aboutText->setHtml(fileToString(path).arg(VERSION));
aboutText->moveCursor(QTextCursor::Start);
}
void HelpAboutDialog::loadHelp(const QString & path)
{
helpText->setHtml(fileToString(path));
helpText->moveCursor(QTextCursor::Start);
}
QString HelpAboutDialog::fileToString(const QString & path)
{
QFile f(path);
f.open(QIODevice::ReadOnly);
QTextStream txtS(&f);
txtS.setCodec(QTextCodec::codecForName("UTF-8"));
QString content = txtS.readAll();
f.close();
return content;
}

View File

@ -1,28 +1,28 @@
#ifndef HELP_ABOUT_DIALOG_H
#define HELP_ABOUT_DIALOG_H
#include <QDialog>
class QTabWidget;
class QTextBrowser;
class HelpAboutDialog : public QDialog
{
Q_OBJECT
public:
HelpAboutDialog(QWidget * parent=0);
HelpAboutDialog(const QString & pathAbout,const QString & pathHelp,QWidget * parent =0);
~HelpAboutDialog();
public slots:
void loadAboutInformation(const QString & path);
void loadHelp(const QString & path);
private:
QTabWidget *tabWidget;
QTextBrowser *aboutText;
QTextBrowser *helpText;
QString fileToString(const QString & path);
};
#ifndef HELP_ABOUT_DIALOG_H
#define HELP_ABOUT_DIALOG_H
#include <QDialog>
class QTabWidget;
class QTextBrowser;
class HelpAboutDialog : public QDialog
{
Q_OBJECT
public:
HelpAboutDialog(QWidget * parent=0);
HelpAboutDialog(const QString & pathAbout,const QString & pathHelp,QWidget * parent =0);
~HelpAboutDialog();
public slots:
void loadAboutInformation(const QString & path);
void loadHelp(const QString & path);
private:
QTabWidget *tabWidget;
QTextBrowser *aboutText;
QTextBrowser *helpText;
QString fileToString(const QString & path);
};
#endif // HELP_ABOUT_DIALOG_H

View File

@ -1,187 +1,187 @@
#include "yacreader_busy_widget.h"
#include <QDebug>
#include <QPainter>
#include <QPixmapCache>
#include <QGradient>
YACReaderBusyWidget::YACReaderBusyWidget(QWidget *parent)
:QWidget(parent)
{
setFixedSize(70,70);
BusyIndicator * busy = new BusyIndicator(this);
busy->setIndicatorStyle(BusyIndicator::StyleArc);
busy->setColor(Qt::white);
busy->move(20,20);
}
void YACReaderBusyWidget::paintEvent(QPaintEvent * event)
{
Q_UNUSED(event);
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing);
painter.drawPixmap(0,0,width(),height(),QPixmap(":/images/busy_background.png"));
}
BusyIndicator::BusyIndicator(QWidget *parent) :
QWidget(parent),
startAngle(0),
m_style(StyleArc)
{
QSizePolicy policy(QSizePolicy::Preferred, QSizePolicy::Fixed);
policy.setHeightForWidth(true);
setSizePolicy(policy);
fillColor = palette().color(QPalette::WindowText);
timer.setInterval(16);
connect(&timer, SIGNAL(timeout()), this, SLOT(rotate()));
timer.start();
}
void BusyIndicator::rotate()
{
startAngle += 9;
startAngle %= 360;
update();
}
void BusyIndicator::setIndicatorStyle(IndicatorStyle style)
{
m_style = style;
update();
}
void BusyIndicator::setColor(QColor color)
{
fillColor = color;
}
const BusyIndicator::IndicatorStyle BusyIndicator::indicatorStyle() const
{
return m_style;
}
QPixmap BusyIndicator::generatePixmap(int side)
{
QPixmap pixmap(QSize(side, side));
pixmap.fill(QColor(255, 255, 255, 0));
QPainter painter(&pixmap);
painter.setRenderHint(QPainter::Antialiasing);
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;
}
void BusyIndicator::drawRectStyle(QPainter *painter)
{
// QColor color = palette().color(QPalette::WindowText);
QColor color = fillColor;
QBrush brush(color);
painter->setPen(Qt::NoPen);
painter->rotate(startAngle);
float angle = 0;
while (angle < 360) {
painter->setBrush(brush);
painter->drawRect(-8, -100, 16, 35);
painter->rotate(30);
angle += 30;
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);
painter->rotate(startAngle);
float angle = 0;
while (angle < 360) {
painter->setBrush(brush);
painter->drawEllipse(-10, -100, 30, 30);
painter->rotate(30);
angle += 30;
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);
QPen pen;
pen.setWidth(30);
pen.setBrush(QBrush(gradient));
painter->setPen(pen);
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);
QPixmap pixmap;
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing);
int side = qMin(width(), height());
if(!QPixmapCache::find(key, &pixmap)) {
pixmap = generatePixmap(side);
QPixmapCache::insert(key, pixmap);
}
painter.translate(width() / 2 - side / 2, height() / 2 - side / 2);
painter.drawPixmap(0, 0, side, side, pixmap);
}
QSize BusyIndicator::minimumSizeHint() const
{
return QSize(30, 30);
}
QSize BusyIndicator::sizeHint() const
{
return QSize(30, 30);
}
#include "yacreader_busy_widget.h"
#include <QDebug>
#include <QPainter>
#include <QPixmapCache>
#include <QGradient>
YACReaderBusyWidget::YACReaderBusyWidget(QWidget *parent)
:QWidget(parent)
{
setFixedSize(70,70);
BusyIndicator * busy = new BusyIndicator(this);
busy->setIndicatorStyle(BusyIndicator::StyleArc);
busy->setColor(Qt::white);
busy->move(20,20);
}
void YACReaderBusyWidget::paintEvent(QPaintEvent * event)
{
Q_UNUSED(event);
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing);
painter.drawPixmap(0,0,width(),height(),QPixmap(":/images/busy_background.png"));
}
BusyIndicator::BusyIndicator(QWidget *parent) :
QWidget(parent),
startAngle(0),
m_style(StyleArc)
{
QSizePolicy policy(QSizePolicy::Preferred, QSizePolicy::Fixed);
policy.setHeightForWidth(true);
setSizePolicy(policy);
fillColor = palette().color(QPalette::WindowText);
timer.setInterval(16);
connect(&timer, SIGNAL(timeout()), this, SLOT(rotate()));
timer.start();
}
void BusyIndicator::rotate()
{
startAngle += 9;
startAngle %= 360;
update();
}
void BusyIndicator::setIndicatorStyle(IndicatorStyle style)
{
m_style = style;
update();
}
void BusyIndicator::setColor(QColor color)
{
fillColor = color;
}
const BusyIndicator::IndicatorStyle BusyIndicator::indicatorStyle() const
{
return m_style;
}
QPixmap BusyIndicator::generatePixmap(int side)
{
QPixmap pixmap(QSize(side, side));
pixmap.fill(QColor(255, 255, 255, 0));
QPainter painter(&pixmap);
painter.setRenderHint(QPainter::Antialiasing);
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;
}
void BusyIndicator::drawRectStyle(QPainter *painter)
{
// QColor color = palette().color(QPalette::WindowText);
QColor color = fillColor;
QBrush brush(color);
painter->setPen(Qt::NoPen);
painter->rotate(startAngle);
float angle = 0;
while (angle < 360) {
painter->setBrush(brush);
painter->drawRect(-8, -100, 16, 35);
painter->rotate(30);
angle += 30;
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);
painter->rotate(startAngle);
float angle = 0;
while (angle < 360) {
painter->setBrush(brush);
painter->drawEllipse(-10, -100, 30, 30);
painter->rotate(30);
angle += 30;
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);
QPen pen;
pen.setWidth(30);
pen.setBrush(QBrush(gradient));
painter->setPen(pen);
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);
QPixmap pixmap;
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing);
int side = qMin(width(), height());
if(!QPixmapCache::find(key, &pixmap)) {
pixmap = generatePixmap(side);
QPixmapCache::insert(key, pixmap);
}
painter.translate(width() / 2 - side / 2, height() / 2 - side / 2);
painter.drawPixmap(0, 0, side, side, pixmap);
}
QSize BusyIndicator::minimumSizeHint() const
{
return QSize(30, 30);
}
QSize BusyIndicator::sizeHint() const
{
return QSize(30, 30);
}

View File

@ -1,50 +1,50 @@
#ifndef YACREADER_BUSYINDICATOR_H
#define YACREADER_BUSYINDICATOR_H
#include <QTimer>
#include <QWidget>
class YACReaderBusyWidget : public QWidget
{
Q_OBJECT
public:
explicit YACReaderBusyWidget(QWidget *parent = 0);
void paintEvent(QPaintEvent *);
};
class BusyIndicator : public QWidget
{
Q_OBJECT
public:
enum IndicatorStyle{StyleRect, StyleEllipse, StyleArc};
explicit BusyIndicator(QWidget *parent = 0);
void paintEvent(QPaintEvent *);
QSize minimumSizeHint() const;
QSize sizeHint() const;
void setIndicatorStyle(IndicatorStyle);
void setColor(QColor color);
const IndicatorStyle indicatorStyle() const;
signals:
private slots:
void rotate();
private:
QPixmap generatePixmap(int sideLength);
void drawRectStyle(QPainter *painter);
void drawEllipseStyle(QPainter *painter);
void drawArcStyle(QPainter *painter);
QTimer timer;
int startAngle;
IndicatorStyle m_style;
QColor fillColor;
};
#endif // BUSYINDICATOR_H
#ifndef YACREADER_BUSYINDICATOR_H
#define YACREADER_BUSYINDICATOR_H
#include <QTimer>
#include <QWidget>
class YACReaderBusyWidget : public QWidget
{
Q_OBJECT
public:
explicit YACReaderBusyWidget(QWidget *parent = 0);
void paintEvent(QPaintEvent *);
};
class BusyIndicator : public QWidget
{
Q_OBJECT
public:
enum IndicatorStyle{StyleRect, StyleEllipse, StyleArc};
explicit BusyIndicator(QWidget *parent = 0);
void paintEvent(QPaintEvent *);
QSize minimumSizeHint() const;
QSize sizeHint() const;
void setIndicatorStyle(IndicatorStyle);
void setColor(QColor color);
const IndicatorStyle indicatorStyle() const;
signals:
private slots:
void rotate();
private:
QPixmap generatePixmap(int sideLength);
void drawRectStyle(QPainter *painter);
void drawEllipseStyle(QPainter *painter);
void drawArcStyle(QPainter *painter);
QTimer timer;
int startAngle;
IndicatorStyle m_style;
QColor fillColor;
};
#endif // BUSYINDICATOR_H

View File

@ -1,38 +1,38 @@
#include "yacreader_dark_menu.h"
#include <QLabel>
#include <QPixmap>
#include <QHBoxLayout>
YACReaderDarkMenu::YACReaderDarkMenu(QWidget * parent)
:QMenu(parent)
{
//solid color: #454545
QString style = "QMenu {background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #6B6B6B, stop: 1 #424242); "
"border-left: 1px solid qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #BCBCBC, stop: 1 #4C4C4C);"
"border-right: 1px solid qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #BCBCBC, stop: 1 #4C4C4C);"
"border-top: 1px solid #BCBCBC;"
"border-bottom: 1px solid #4C4C4C;"
"padding-top:5px;padding-bottom:5px;}"
"QMenu::separator {height:0px;border-top: 1px solid #292929; border-bottom:1px solid #737373; margin-left:-1px; margin-right:-1px;}"
"QMenu::item {color:#CFD1D1;padding: 5px 25px 5px 32px;}"
"QMenu::item::selected {background-color:#242424;border-top: 1px solid #151515; border-bottom:1px solid #737373;}"
"QMenu::icon {padding-left:15px;}";
setStyleSheet(style);
/*
QPixmap p(":/images/icon.png");
QLabel * l = new QLabel();
l->setPixmap(p);
l->move(0,-10);
//test
YACReaderDarkMenu * customMenu = new YACReaderDarkMenu(this);
customMenu->addAction(toggleFullScreenAction);
customMenu->addAction(createLibraryAction);
customMenu->addSeparator();
customMenu->addAction(openComicAction);
customMenu->show();
*/
#include "yacreader_dark_menu.h"
#include <QLabel>
#include <QPixmap>
#include <QHBoxLayout>
YACReaderDarkMenu::YACReaderDarkMenu(QWidget * parent)
:QMenu(parent)
{
//solid color: #454545
QString style = "QMenu {background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #6B6B6B, stop: 1 #424242); "
"border-left: 1px solid qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #BCBCBC, stop: 1 #4C4C4C);"
"border-right: 1px solid qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #BCBCBC, stop: 1 #4C4C4C);"
"border-top: 1px solid #BCBCBC;"
"border-bottom: 1px solid #4C4C4C;"
"padding-top:5px;padding-bottom:5px;}"
"QMenu::separator {height:0px;border-top: 1px solid #292929; border-bottom:1px solid #737373; margin-left:-1px; margin-right:-1px;}"
"QMenu::item {color:#CFD1D1;padding: 5px 25px 5px 32px;}"
"QMenu::item::selected {background-color:#242424;border-top: 1px solid #151515; border-bottom:1px solid #737373;}"
"QMenu::icon {padding-left:15px;}";
setStyleSheet(style);
/*
QPixmap p(":/images/icon.png");
QLabel * l = new QLabel();
l->setPixmap(p);
l->move(0,-10);
//test
YACReaderDarkMenu * customMenu = new YACReaderDarkMenu(this);
customMenu->addAction(toggleFullScreenAction);
customMenu->addAction(createLibraryAction);
customMenu->addSeparator();
customMenu->addAction(openComicAction);
customMenu->show();
*/
}

View File

@ -1,14 +1,14 @@
#ifndef YACREADER_DARK_MENU_H
#define YACREADER_DARK_MENU_H
#include <QMenu>
class YACReaderDarkMenu : public QMenu
{
Q_OBJECT
public:
YACReaderDarkMenu(QWidget * parent = 0);
};
#ifndef YACREADER_DARK_MENU_H
#define YACREADER_DARK_MENU_H
#include <QMenu>
class YACReaderDarkMenu : public QMenu
{
Q_OBJECT
public:
YACReaderDarkMenu(QWidget * parent = 0);
};
#endif // YACREADER_DARK_MENU_H

View File

@ -1,106 +1,106 @@
#include "yacreader_deleting_progress.h"
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QProgressBar>
#include <QPushButton>
#include <QLabel>
#include <QPainter>
YACReaderDeletingProgress::YACReaderDeletingProgress(QWidget *parent) :
QWidget(parent)
{
QVBoxLayout * contentLayout = new QVBoxLayout(this);
QLabel * iconLabel = new QLabel();
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->setStyleSheet("QLabel {color:#ABABAB; padding:0 0 0 0px; margin:0px; font-size:18px; font-weight:bold;}");
QProgressBar * progressBar = new QProgressBar();
progressBar->setTextVisible(false);
progressBar->setFixedHeight(6);
progressBar->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed);
progressBar->setRange (0,10);
progressBar->setValue(5);
progressBar->setStyleSheet(
"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"));
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->addSpacing(13);
contentLayout->addWidget(progressBar);
contentLayout->addSpacing(13);
contentLayout->addWidget(button,0,Qt::AlignHCenter);
contentLayout->addSpacing(18);
contentLayout->setMargin(0);
setLayout(contentLayout);
setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
resize( sizeHint() );
}
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 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");
borderTop = pL.height();
borderRight = pRM.width();
borderBottom = pBM.height();
borderLeft = pLM.width();
int width = this->width()-borderRight-borderLeft;
int height = this->height()-borderTop-borderBottom;
QPainter painter(this);
//corners
painter.drawPixmap(0,0,pL);
painter.drawPixmap(this->width()-borderRight,0,pR);
painter.drawPixmap(0,this->height()-pBL.height(),pBL);
painter.drawPixmap(this->width()-pBR.width(),this->height()-borderBottom,pBR);
//middle
painter.drawPixmap(borderRight,0,width,borderTop,pM);
painter.drawPixmap(0,borderTop,borderLeft,height,pLM);
painter.drawPixmap(width+borderLeft,borderTop,borderRight,height,pRM);
painter.drawPixmap(pBR.width(),height+borderTop,this->width()-pBR.width()-pBL.width(),pBR.height(),pBM);
//center
painter.fillRect(borderLeft,borderTop,width,height,QColor("#FAFAFA"));
QWidget::paintEvent(event);
}
QSize YACReaderDeletingProgress::sizeHint() const
{
return QSize(textMessage->sizeHint().width()+120,185);
}
#include "yacreader_deleting_progress.h"
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QProgressBar>
#include <QPushButton>
#include <QLabel>
#include <QPainter>
YACReaderDeletingProgress::YACReaderDeletingProgress(QWidget *parent) :
QWidget(parent)
{
QVBoxLayout * contentLayout = new QVBoxLayout(this);
QLabel * iconLabel = new QLabel();
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->setStyleSheet("QLabel {color:#ABABAB; padding:0 0 0 0px; margin:0px; font-size:18px; font-weight:bold;}");
QProgressBar * progressBar = new QProgressBar();
progressBar->setTextVisible(false);
progressBar->setFixedHeight(6);
progressBar->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed);
progressBar->setRange (0,10);
progressBar->setValue(5);
progressBar->setStyleSheet(
"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"));
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->addSpacing(13);
contentLayout->addWidget(progressBar);
contentLayout->addSpacing(13);
contentLayout->addWidget(button,0,Qt::AlignHCenter);
contentLayout->addSpacing(18);
contentLayout->setMargin(0);
setLayout(contentLayout);
setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
resize( sizeHint() );
}
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 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");
borderTop = pL.height();
borderRight = pRM.width();
borderBottom = pBM.height();
borderLeft = pLM.width();
int width = this->width()-borderRight-borderLeft;
int height = this->height()-borderTop-borderBottom;
QPainter painter(this);
//corners
painter.drawPixmap(0,0,pL);
painter.drawPixmap(this->width()-borderRight,0,pR);
painter.drawPixmap(0,this->height()-pBL.height(),pBL);
painter.drawPixmap(this->width()-pBR.width(),this->height()-borderBottom,pBR);
//middle
painter.drawPixmap(borderRight,0,width,borderTop,pM);
painter.drawPixmap(0,borderTop,borderLeft,height,pLM);
painter.drawPixmap(width+borderLeft,borderTop,borderRight,height,pRM);
painter.drawPixmap(pBR.width(),height+borderTop,this->width()-pBR.width()-pBL.width(),pBR.height(),pBM);
//center
painter.fillRect(borderLeft,borderTop,width,height,QColor("#FAFAFA"));
QWidget::paintEvent(event);
}
QSize YACReaderDeletingProgress::sizeHint() const
{
return QSize(textMessage->sizeHint().width()+120,185);
}

View File

@ -1,26 +1,26 @@
#ifndef YACREADER_DELETING_PROGRESS_H
#define YACREADER_DELETING_PROGRESS_H
#include <QWidget>
class QLabel;
class YACReaderDeletingProgress : public QWidget
{
Q_OBJECT
public:
explicit YACReaderDeletingProgress(QWidget *parent = 0);
QSize sizeHint() const;
signals:
public slots:
protected:
void paintEvent(QPaintEvent *);
private:
QLabel * textMessage;
};
#endif // YACREADER_DELETING_PROGRESS_H
#ifndef YACREADER_DELETING_PROGRESS_H
#define YACREADER_DELETING_PROGRESS_H
#include <QWidget>
class QLabel;
class YACReaderDeletingProgress : public QWidget
{
Q_OBJECT
public:
explicit YACReaderDeletingProgress(QWidget *parent = 0);
QSize sizeHint() const;
signals:
public slots:
protected:
void paintEvent(QPaintEvent *);
private:
QLabel * textMessage;
};
#endif // YACREADER_DELETING_PROGRESS_H

View File

@ -1,39 +1,39 @@
#include "yacreader_field_edit.h"
#include <QAction>
#include <QFocusEvent>
YACReaderFieldEdit::YACReaderFieldEdit(QWidget * parent)
:QLineEdit(parent)
{
setPlaceholderText(tr("Click to overwrite"));
setModified(false);
restore = new QAction(tr("Restore to default"),this);
this->addAction(restore);
//this->setContextMenuPolicy(Qt::ActionsContextMenu);
}
void YACReaderFieldEdit::focusInEvent(QFocusEvent* e)
{
if (e->reason() == Qt::MouseFocusReason)
{
setModified(true);
setPlaceholderText("");
}
QLineEdit::focusInEvent(e);
}
void YACReaderFieldEdit::clear()
{
setPlaceholderText(tr("Click to overwrite"));
QLineEdit::clear();
QLineEdit::setModified(false);
}
void YACReaderFieldEdit::setDisabled(bool disabled)
{
if(disabled)
setPlaceholderText("");
QLineEdit::setDisabled(disabled);
#include "yacreader_field_edit.h"
#include <QAction>
#include <QFocusEvent>
YACReaderFieldEdit::YACReaderFieldEdit(QWidget * parent)
:QLineEdit(parent)
{
setPlaceholderText(tr("Click to overwrite"));
setModified(false);
restore = new QAction(tr("Restore to default"),this);
this->addAction(restore);
//this->setContextMenuPolicy(Qt::ActionsContextMenu);
}
void YACReaderFieldEdit::focusInEvent(QFocusEvent* e)
{
if (e->reason() == Qt::MouseFocusReason)
{
setModified(true);
setPlaceholderText("");
}
QLineEdit::focusInEvent(e);
}
void YACReaderFieldEdit::clear()
{
setPlaceholderText(tr("Click to overwrite"));
QLineEdit::clear();
QLineEdit::setModified(false);
}
void YACReaderFieldEdit::setDisabled(bool disabled)
{
if(disabled)
setPlaceholderText("");
QLineEdit::setDisabled(disabled);
}

View File

@ -1,23 +1,23 @@
#ifndef YACREADER_FIELD_EDIT_H
#define YACREADER_FIELD_EDIT_H
#include <QLineEdit>
class QAction;
class QFocusEvent;
class YACReaderFieldEdit : public QLineEdit
{
Q_OBJECT
public:
YACReaderFieldEdit(QWidget * parent = 0);
void clear();
void setDisabled(bool disabled);
protected:
void focusInEvent(QFocusEvent* e);
private:
QAction * restore;
};
#ifndef YACREADER_FIELD_EDIT_H
#define YACREADER_FIELD_EDIT_H
#include <QLineEdit>
class QAction;
class QFocusEvent;
class YACReaderFieldEdit : public QLineEdit
{
Q_OBJECT
public:
YACReaderFieldEdit(QWidget * parent = 0);
void clear();
void setDisabled(bool disabled);
protected:
void focusInEvent(QFocusEvent* e);
private:
QAction * restore;
};
#endif // YACREADER_FIELD_EDIT_H

View File

@ -1,53 +1,53 @@
#include "yacreader_field_plain_text_edit.h"
#include <QAction>
YACReaderFieldPlainTextEdit::YACReaderFieldPlainTextEdit(QWidget * parent)
:QPlainTextEdit(parent)
{
document()->setModified(false);
setPlainText(tr("Click to overwrite"));
restore = new QAction(tr("Restore to default"),this);
this->addAction(restore);
//this->setContextMenuPolicy(Qt::ActionsContextMenu);
}
void YACReaderFieldPlainTextEdit::focusInEvent(QFocusEvent* e)
{
if (e->reason() == Qt::MouseFocusReason || e->reason() == Qt::TabFocusReason)
{
document()->setModified(true);
if(toPlainText()==tr("Click to overwrite"))
setPlainText("");
}
QPlainTextEdit::focusInEvent(e);
}
void YACReaderFieldPlainTextEdit::focusOutEvent(QFocusEvent* e)
{
/*if (e->reason() == Qt::MouseFocusReason || e->reason() == Qt::TabFocusReason)
{
if(toPlainText().isEmpty())
{
setPlainText(tr("Click to overwrite"));
document()->setModified(false);
}
}
*/
QPlainTextEdit::focusOutEvent(e);
}
void YACReaderFieldPlainTextEdit::clear()
{
QPlainTextEdit::clear();
document()->setModified(false);
setPlainText(tr("Click to overwrite"));
}
void YACReaderFieldPlainTextEdit::setDisabled(bool disabled)
{
if(disabled)
setPlainText(tr("Click to overwrite"));
QPlainTextEdit::setDisabled(disabled);
}
#include "yacreader_field_plain_text_edit.h"
#include <QAction>
YACReaderFieldPlainTextEdit::YACReaderFieldPlainTextEdit(QWidget * parent)
:QPlainTextEdit(parent)
{
document()->setModified(false);
setPlainText(tr("Click to overwrite"));
restore = new QAction(tr("Restore to default"),this);
this->addAction(restore);
//this->setContextMenuPolicy(Qt::ActionsContextMenu);
}
void YACReaderFieldPlainTextEdit::focusInEvent(QFocusEvent* e)
{
if (e->reason() == Qt::MouseFocusReason || e->reason() == Qt::TabFocusReason)
{
document()->setModified(true);
if(toPlainText()==tr("Click to overwrite"))
setPlainText("");
}
QPlainTextEdit::focusInEvent(e);
}
void YACReaderFieldPlainTextEdit::focusOutEvent(QFocusEvent* e)
{
/*if (e->reason() == Qt::MouseFocusReason || e->reason() == Qt::TabFocusReason)
{
if(toPlainText().isEmpty())
{
setPlainText(tr("Click to overwrite"));
document()->setModified(false);
}
}
*/
QPlainTextEdit::focusOutEvent(e);
}
void YACReaderFieldPlainTextEdit::clear()
{
QPlainTextEdit::clear();
document()->setModified(false);
setPlainText(tr("Click to overwrite"));
}
void YACReaderFieldPlainTextEdit::setDisabled(bool disabled)
{
if(disabled)
setPlainText(tr("Click to overwrite"));
QPlainTextEdit::setDisabled(disabled);
}

View File

@ -1,25 +1,25 @@
#ifndef YACREADER_FIELD_PLAIN_TEXT_EDIT_H
#define YACREADER_FIELD_PLAIN_TEXT_EDIT_H
#include <QPlainTextEdit>
class QAction;
class QFocusEvent;
class YACReaderFieldPlainTextEdit : public QPlainTextEdit
{
Q_OBJECT
public:
YACReaderFieldPlainTextEdit(QWidget * parent = 0);
void clear();
void setDisabled(bool disabled);
protected:
void focusInEvent(QFocusEvent* e);
void focusOutEvent(QFocusEvent* e);
private:
QAction * restore;
};
#ifndef YACREADER_FIELD_PLAIN_TEXT_EDIT_H
#define YACREADER_FIELD_PLAIN_TEXT_EDIT_H
#include <QPlainTextEdit>
class QAction;
class QFocusEvent;
class YACReaderFieldPlainTextEdit : public QPlainTextEdit
{
Q_OBJECT
public:
YACReaderFieldPlainTextEdit(QWidget * parent = 0);
void clear();
void setDisabled(bool disabled);
protected:
void focusInEvent(QFocusEvent* e);
void focusOutEvent(QFocusEvent* e);
private:
QAction * restore;
};
#endif // YACREADER_FIELD_PLAIN_TEXT_EDIT_H

View File

@ -1,18 +1,18 @@
#include "yacreader_flow.h"
#include <QMouseEvent>
YACReaderFlow::YACReaderFlow(QWidget * parent,FlowType flowType) : PictureFlow(parent,flowType) {}
void YACReaderFlow::mousePressEvent(QMouseEvent* event)
{
PictureFlow::mousePressEvent(event, slideSize().width());
}
void YACReaderFlow::mouseDoubleClickEvent(QMouseEvent* event)
{
if((event->x() > (width()-slideSize().width())/2)&&(event->x() < (width()+slideSize().width())/2))
emit selected(centerIndex());
}
#include "yacreader_flow.h"
#include <QMouseEvent>
YACReaderFlow::YACReaderFlow(QWidget * parent,FlowType flowType) : PictureFlow(parent,flowType) {}
void YACReaderFlow::mousePressEvent(QMouseEvent* event)
{
PictureFlow::mousePressEvent(event, slideSize().width());
}
void YACReaderFlow::mouseDoubleClickEvent(QMouseEvent* event)
{
if((event->x() > (width()-slideSize().width())/2)&&(event->x() < (width()+slideSize().width())/2))
emit selected(centerIndex());
}

View File

@ -1,21 +1,21 @@
#ifndef YACREADER_FLOW_H
#define YACREADER_FLOW_H
#include "pictureflow.h"
class QMouseEvent;
class YACReaderFlow : public PictureFlow
{
Q_OBJECT
public:
YACReaderFlow(QWidget * parent,FlowType flowType = CoverFlowLike);
void mousePressEvent(QMouseEvent* event);
void mouseDoubleClickEvent(QMouseEvent* event);
signals:
void selected(unsigned int centerIndex);
};
#ifndef YACREADER_FLOW_H
#define YACREADER_FLOW_H
#include "pictureflow.h"
class QMouseEvent;
class YACReaderFlow : public PictureFlow
{
Q_OBJECT
public:
YACReaderFlow(QWidget * parent,FlowType flowType = CoverFlowLike);
void mousePressEvent(QMouseEvent* event);
void mouseDoubleClickEvent(QMouseEvent* event);
signals:
void selected(unsigned int centerIndex);
};
#endif // YACREADER_FLOW_H

View File

@ -1,54 +1,54 @@
#include "yacreader_flow_config_widget.h"
#include <QVBoxLayout>
#include <QGroupBox>
#include <QRadioButton>
#include <QLabel>
YACReaderFlowConfigWidget::YACReaderFlowConfigWidget(QWidget * parent )
:QWidget(parent)
{
QVBoxLayout * layout = new QVBoxLayout(this);
QGroupBox *groupBox = new QGroupBox(tr("How to show covers:"));
radio1 = new QRadioButton(tr("CoverFlow look"));
radio2 = new QRadioButton(tr("Stripe look"));
radio3 = new QRadioButton(tr("Overlapped Stripe look"));
QVBoxLayout *vbox = new QVBoxLayout;
QHBoxLayout * opt1 = new QHBoxLayout;
opt1->addWidget(radio1);
QLabel * lOpt1 = new QLabel();
lOpt1->setPixmap(QPixmap(":/images/flow1.png"));
opt1->addStretch();
opt1->addWidget(lOpt1);
vbox->addLayout(opt1);
QHBoxLayout * opt2 = new QHBoxLayout;
opt2->addWidget(radio2);
QLabel * lOpt2 = new QLabel();
lOpt2->setPixmap(QPixmap(":/images/flow2.png"));
opt2->addStretch();
opt2->addWidget(lOpt2);
vbox->addLayout(opt2);
QHBoxLayout * opt3 = new QHBoxLayout;
opt3->addWidget(radio3);
QLabel * lOpt3 = new QLabel();
lOpt3->setPixmap(QPixmap(":/images/flow3.png"));
opt3->addStretch();
opt3->addWidget(lOpt3);
vbox->addLayout(opt3);
//vbox->addStretch(1);
groupBox->setLayout(vbox);
layout->addWidget(groupBox);
layout->setContentsMargins(0,0,0,0);
setLayout(layout);
#include "yacreader_flow_config_widget.h"
#include <QVBoxLayout>
#include <QGroupBox>
#include <QRadioButton>
#include <QLabel>
YACReaderFlowConfigWidget::YACReaderFlowConfigWidget(QWidget * parent )
:QWidget(parent)
{
QVBoxLayout * layout = new QVBoxLayout(this);
QGroupBox *groupBox = new QGroupBox(tr("How to show covers:"));
radio1 = new QRadioButton(tr("CoverFlow look"));
radio2 = new QRadioButton(tr("Stripe look"));
radio3 = new QRadioButton(tr("Overlapped Stripe look"));
QVBoxLayout *vbox = new QVBoxLayout;
QHBoxLayout * opt1 = new QHBoxLayout;
opt1->addWidget(radio1);
QLabel * lOpt1 = new QLabel();
lOpt1->setPixmap(QPixmap(":/images/flow1.png"));
opt1->addStretch();
opt1->addWidget(lOpt1);
vbox->addLayout(opt1);
QHBoxLayout * opt2 = new QHBoxLayout;
opt2->addWidget(radio2);
QLabel * lOpt2 = new QLabel();
lOpt2->setPixmap(QPixmap(":/images/flow2.png"));
opt2->addStretch();
opt2->addWidget(lOpt2);
vbox->addLayout(opt2);
QHBoxLayout * opt3 = new QHBoxLayout;
opt3->addWidget(radio3);
QLabel * lOpt3 = new QLabel();
lOpt3->setPixmap(QPixmap(":/images/flow3.png"));
opt3->addStretch();
opt3->addWidget(lOpt3);
vbox->addLayout(opt3);
//vbox->addStretch(1);
groupBox->setLayout(vbox);
layout->addWidget(groupBox);
layout->setContentsMargins(0,0,0,0);
setLayout(layout);
}

View File

@ -1,19 +1,19 @@
#ifndef YACREADER_FLOW_CONFIG_WIDGET_H
#define YACREADER_FLOW_CONFIG_WIDGET_H
#include <QWidget>
class QRadioButton;
class YACReaderFlowConfigWidget : public QWidget
{
Q_OBJECT
public:
QRadioButton *radio1;
QRadioButton *radio2;
QRadioButton *radio3;
YACReaderFlowConfigWidget(QWidget * parent = 0);
};
#ifndef YACREADER_FLOW_CONFIG_WIDGET_H
#define YACREADER_FLOW_CONFIG_WIDGET_H
#include <QWidget>
class QRadioButton;
class YACReaderFlowConfigWidget : public QWidget
{
Q_OBJECT
public:
QRadioButton *radio1;
QRadioButton *radio2;
QRadioButton *radio3;
YACReaderFlowConfigWidget(QWidget * parent = 0);
};
#endif // YACREADER_FLOW_CONFIG_WIDGET_H

View File

@ -1,240 +1,240 @@
#include "yacreader_gl_flow_config_widget.h"
#include "yacreader_spin_slider_widget.h"
#include "yacreader_flow_gl.h" //TODO
#include <QVBoxLayout>
#include <QGroupBox>
#include <QRadioButton>
#include <QLabel>
#include <QPushButton>
YACReaderGLFlowConfigWidget::YACReaderGLFlowConfigWidget(QWidget * parent /* = 0 */)
:QWidget(parent)
{
QVBoxLayout * layout = new QVBoxLayout(this);
//PRESETS------------------------------------------------------------------
QGroupBox *groupBox = new QGroupBox(tr("Presets:"));
radioClassic = new QRadioButton(tr("Classic look"));
//connect(radioClassic,SIGNAL(toggled(bool)),this,SLOT(setClassicConfig()));
radioStripe = new QRadioButton(tr("Stripe look"));
//connect(radioStripe,SIGNAL(toggled(bool)),this,SLOT(setStripeConfig()));
radioOver = new QRadioButton(tr("Overlapped Stripe look"));
//connect(radioOver,SIGNAL(toggled(bool)),this,SLOT(setOverlappedStripeConfig()));
radionModern = new QRadioButton(tr("Modern look"));
//connect(radionModern,SIGNAL(toggled(bool)),this,SLOT(setModernConfig()));
radioDown = new QRadioButton(tr("Roulette look"));
//connect(radioDown,SIGNAL(toggled(bool)),this,SLOT(setRouletteConfig()));
QVBoxLayout *vbox = new QVBoxLayout;
QHBoxLayout * opt1 = new QHBoxLayout;
opt1->addWidget(radioClassic);
QLabel * lOpt1 = new QLabel();
lOpt1->setPixmap(QPixmap(":/images/flow1.png"));
opt1->addStretch();
opt1->addWidget(lOpt1);
vbox->addLayout(opt1);
QHBoxLayout * opt2 = new QHBoxLayout;
opt2->addWidget(radioStripe);
QLabel * lOpt2 = new QLabel();
lOpt2->setPixmap(QPixmap(":/images/flow2.png"));
opt2->addStretch();
opt2->addWidget(lOpt2);
vbox->addLayout(opt2);
QHBoxLayout * opt3 = new QHBoxLayout;
opt3->addWidget(radioOver);
QLabel * lOpt3 = new QLabel();
lOpt3->setPixmap(QPixmap(":/images/flow3.png"));
opt3->addStretch();
opt3->addWidget(lOpt3);
vbox->addLayout(opt3);
QHBoxLayout * opt4 = new QHBoxLayout;
opt4->addWidget(radionModern);
QLabel * lOpt4 = new QLabel();
lOpt4->setPixmap(QPixmap(":/images/flow4.png"));
opt4->addStretch();
opt4->addWidget(lOpt4);
vbox->addLayout(opt4);
QHBoxLayout * opt5 = new QHBoxLayout;
opt5->addWidget(radioDown);
QLabel * lOpt5 = new QLabel();
lOpt5->setPixmap(QPixmap(":/images/flow5.png"));
opt5->addStretch();
opt5->addWidget(lOpt5);
vbox->addLayout(opt5);
showAdvancedOptions = new QPushButton(tr("Show advanced settings"));
showAdvancedOptions->setCheckable(true);
connect(showAdvancedOptions,SIGNAL(toggled(bool)),this,SLOT(avancedOptionToogled(bool)));
vbox->addWidget(showAdvancedOptions,0,Qt::AlignRight);
groupBox->setLayout(vbox);
//OPTIONS------------------------------------------------------------------
optionsGroupBox = new QGroupBox(tr("Custom:"));
xRotation = new YACReaderSpinSliderWidget(this);
xRotation->setText(tr("View angle"));
xRotation->setRange(0,90);
//connect(xRotation,SIGNAL(valueChanged(int)),this,SIGNAL(optionsChanged()));
//connect(xRotation,SIGNAL(valueChanged(int)),this,SLOT(saveXRotation(int)));
yPosition = new YACReaderSpinSliderWidget(this);
yPosition->setText(tr("Position"));
yPosition->setRange(-100,100);
//connect(yPosition,SIGNAL(valueChanged(int)),this,SIGNAL(optionsChanged()));
//connect(yPosition,SIGNAL(valueChanged(int)),this,SLOT(saveYPosition(int)));
coverDistance = new YACReaderSpinSliderWidget(this);
coverDistance->setText(tr("Cover gap"));
coverDistance->setRange(0,150);
//connect(coverDistance,SIGNAL(valueChanged(int)),this,SIGNAL(optionsChanged()));
//connect(coverDistance,SIGNAL(valueChanged(int)),this,SLOT(saveCoverDistance(int)));
centralDistance = new YACReaderSpinSliderWidget(this);
centralDistance->setText(tr("Central gap"));
centralDistance->setRange(0,150);
//connect(centralDistance,SIGNAL(valueChanged(int)),this,SIGNAL(optionsChanged()));
//connect(centralDistance,SIGNAL(valueChanged(int)),this,SLOT(saveCentralDistance(int)));
zoomLevel = new YACReaderSpinSliderWidget(this);
zoomLevel->setText(tr("Zoom"));
zoomLevel->setRange(-20,0);
//connect(zoomLevel,SIGNAL(valueChanged(int)),this,SIGNAL(optionsChanged()));
//connect(zoomLevel,SIGNAL(valueChanged(int)),this,SLOT(saveZoomLevel(int)));
yCoverOffset = new YACReaderSpinSliderWidget(this);
yCoverOffset->setText(tr("Y offset"));
yCoverOffset->setRange(-50,50);
//connect(yCoverOffset,SIGNAL(valueChanged(int)),this,SIGNAL(optionsChanged()));
//connect(yCoverOffset,SIGNAL(valueChanged(int)),this,SLOT(saveYCoverOffset(int)));
zCoverOffset = new YACReaderSpinSliderWidget(this);
zCoverOffset->setText(tr("Z offset"));
zCoverOffset->setRange(-50,50);
//connect(zCoverOffset,SIGNAL(valueChanged(int)),this,SIGNAL(optionsChanged()));
//connect(zCoverOffset,SIGNAL(valueChanged(int)),this,SLOT(saveZCoverOffset(int)));
coverRotation = new YACReaderSpinSliderWidget(this);
coverRotation->setText(tr("Cover Angle"));
coverRotation->setRange(0,360);
//connect(coverRotation,SIGNAL(valueChanged(int)),this,SIGNAL(optionsChanged()));
//connect(coverRotation,SIGNAL(valueChanged(int)),this,SLOT(saveCoverRotation(int)));
fadeOutDist = new YACReaderSpinSliderWidget(this);
fadeOutDist->setText(tr("Visibility"));
fadeOutDist->setRange(0,10);
//connect(fadeOutDist,SIGNAL(valueChanged(int)),this,SIGNAL(optionsChanged()));
//connect(fadeOutDist,SIGNAL(valueChanged(int)),this,SLOT(saveFadeOutDist(int)));
lightStrength = new YACReaderSpinSliderWidget(this);
lightStrength->setText(tr("Light"));
lightStrength->setRange(0,10);
//connect(lightStrength,SIGNAL(valueChanged(int)),this,SIGNAL(optionsChanged()));
//connect(lightStrength,SIGNAL(valueChanged(int)),this,SLOT(saveLightStrength(int)));
maxAngle = new YACReaderSpinSliderWidget(this);
maxAngle->setText(tr("Max angle"));
maxAngle->setRange(0,90);
//connect(maxAngle,SIGNAL(valueChanged(int)),this,SIGNAL(optionsChanged()));
//connect(maxAngle,SIGNAL(valueChanged(int)),this,SLOT(saveMaxAngle(int)));
QVBoxLayout *optionsLayoutStretch = new QVBoxLayout;
optionsLayoutStretch->setContentsMargins(0,0,0,0);
QGridLayout *optionsLayout = new QGridLayout;
optionsLayout->addWidget(xRotation,0,0);
optionsLayout->addWidget(yPosition,0,1);
optionsLayout->addWidget(coverDistance,1,0);
optionsLayout->addWidget(centralDistance,1,1);
optionsLayout->addWidget(zoomLevel,2,0);
optionsLayout->addWidget(yCoverOffset,2,1);
optionsLayout->addWidget(zCoverOffset,3,0);
optionsLayout->addWidget(coverRotation,3,1);
optionsLayout->addWidget(fadeOutDist,4,0);
optionsLayout->addWidget(lightStrength,4,1);
optionsLayout->addWidget(maxAngle,5,0);
optionsLayoutStretch->addLayout(optionsLayout);
optionsLayoutStretch->addStretch();
optionsGroupBox->setLayout(optionsLayoutStretch);
QHBoxLayout * groupBoxesLayout = new QHBoxLayout;
groupBoxesLayout->addWidget(groupBox);
groupBoxesLayout->addWidget(optionsGroupBox);
optionsGroupBox->hide();
QHBoxLayout * performanceSliderLayout = new QHBoxLayout;
performanceSliderLayout->addWidget(new QLabel(tr("Low Performance")));
performanceSliderLayout->addWidget(performanceSlider = new QSlider(Qt::Horizontal));
performanceSliderLayout->addWidget(new QLabel(tr("High Performance")));
performanceSlider->setMinimum(0);
performanceSlider->setMaximum(3);
performanceSlider->setSingleStep(1);
performanceSlider->setPageStep(1);
performanceSlider->setTickInterval(1);
performanceSlider->setTickPosition(QSlider::TicksRight);
QHBoxLayout * vSyncLayout = new QHBoxLayout;
vSyncCheck = new QCheckBox(tr("Use VSync (improve the image quality in fullscreen mode, worse performance)"));
vSyncLayout->addStretch();
vSyncLayout->addWidget(vSyncCheck);
QVBoxLayout * performanceLayout = new QVBoxLayout;
performanceLayout->addLayout(performanceSliderLayout);
performanceLayout->addLayout(vSyncLayout);
QGroupBox *performanceGroupBox = new QGroupBox(tr("Performance:"));
//connect(performanceSlider, SIGNAL(valueChanged(int)),this,SLOT(savePerformance(int)));
//connect(performanceSlider, SIGNAL(valueChanged(int)),this,SLOT(optionsChanged()));
performanceGroupBox->setLayout(performanceLayout);
layout->addLayout(groupBoxesLayout);
layout->addWidget(performanceGroupBox);
layout->setContentsMargins(0,0,0,0);
setLayout(layout);
}
void YACReaderGLFlowConfigWidget::avancedOptionToogled(bool show)
{
if(show)
optionsGroupBox->show();
else
optionsGroupBox->hide();
}
void YACReaderGLFlowConfigWidget::setValues(Preset preset)
{
xRotation->setValue(preset.cfRX);
yPosition->setValue(preset.cfY*100);
coverDistance->setValue(preset.xDistance*100);
centralDistance->setValue(preset.centerDistance*100);
zoomLevel->setValue(preset.cfZ);
yCoverOffset->setValue(preset.yDistance*100);
zCoverOffset->setValue(preset.zDistance*100);
coverRotation->setValue(preset.rotation*-1);
fadeOutDist->setValue(preset.animationFadeOutDist);
lightStrength->setValue(preset.viewRotateLightStrenght);
maxAngle->setValue(preset.viewAngle);
}
#include "yacreader_gl_flow_config_widget.h"
#include "yacreader_spin_slider_widget.h"
#include "yacreader_flow_gl.h" //TODO
#include <QVBoxLayout>
#include <QGroupBox>
#include <QRadioButton>
#include <QLabel>
#include <QPushButton>
YACReaderGLFlowConfigWidget::YACReaderGLFlowConfigWidget(QWidget * parent /* = 0 */)
:QWidget(parent)
{
QVBoxLayout * layout = new QVBoxLayout(this);
//PRESETS------------------------------------------------------------------
QGroupBox *groupBox = new QGroupBox(tr("Presets:"));
radioClassic = new QRadioButton(tr("Classic look"));
//connect(radioClassic,SIGNAL(toggled(bool)),this,SLOT(setClassicConfig()));
radioStripe = new QRadioButton(tr("Stripe look"));
//connect(radioStripe,SIGNAL(toggled(bool)),this,SLOT(setStripeConfig()));
radioOver = new QRadioButton(tr("Overlapped Stripe look"));
//connect(radioOver,SIGNAL(toggled(bool)),this,SLOT(setOverlappedStripeConfig()));
radionModern = new QRadioButton(tr("Modern look"));
//connect(radionModern,SIGNAL(toggled(bool)),this,SLOT(setModernConfig()));
radioDown = new QRadioButton(tr("Roulette look"));
//connect(radioDown,SIGNAL(toggled(bool)),this,SLOT(setRouletteConfig()));
QVBoxLayout *vbox = new QVBoxLayout;
QHBoxLayout * opt1 = new QHBoxLayout;
opt1->addWidget(radioClassic);
QLabel * lOpt1 = new QLabel();
lOpt1->setPixmap(QPixmap(":/images/flow1.png"));
opt1->addStretch();
opt1->addWidget(lOpt1);
vbox->addLayout(opt1);
QHBoxLayout * opt2 = new QHBoxLayout;
opt2->addWidget(radioStripe);
QLabel * lOpt2 = new QLabel();
lOpt2->setPixmap(QPixmap(":/images/flow2.png"));
opt2->addStretch();
opt2->addWidget(lOpt2);
vbox->addLayout(opt2);
QHBoxLayout * opt3 = new QHBoxLayout;
opt3->addWidget(radioOver);
QLabel * lOpt3 = new QLabel();
lOpt3->setPixmap(QPixmap(":/images/flow3.png"));
opt3->addStretch();
opt3->addWidget(lOpt3);
vbox->addLayout(opt3);
QHBoxLayout * opt4 = new QHBoxLayout;
opt4->addWidget(radionModern);
QLabel * lOpt4 = new QLabel();
lOpt4->setPixmap(QPixmap(":/images/flow4.png"));
opt4->addStretch();
opt4->addWidget(lOpt4);
vbox->addLayout(opt4);
QHBoxLayout * opt5 = new QHBoxLayout;
opt5->addWidget(radioDown);
QLabel * lOpt5 = new QLabel();
lOpt5->setPixmap(QPixmap(":/images/flow5.png"));
opt5->addStretch();
opt5->addWidget(lOpt5);
vbox->addLayout(opt5);
showAdvancedOptions = new QPushButton(tr("Show advanced settings"));
showAdvancedOptions->setCheckable(true);
connect(showAdvancedOptions,SIGNAL(toggled(bool)),this,SLOT(avancedOptionToogled(bool)));
vbox->addWidget(showAdvancedOptions,0,Qt::AlignRight);
groupBox->setLayout(vbox);
//OPTIONS------------------------------------------------------------------
optionsGroupBox = new QGroupBox(tr("Custom:"));
xRotation = new YACReaderSpinSliderWidget(this);
xRotation->setText(tr("View angle"));
xRotation->setRange(0,90);
//connect(xRotation,SIGNAL(valueChanged(int)),this,SIGNAL(optionsChanged()));
//connect(xRotation,SIGNAL(valueChanged(int)),this,SLOT(saveXRotation(int)));
yPosition = new YACReaderSpinSliderWidget(this);
yPosition->setText(tr("Position"));
yPosition->setRange(-100,100);
//connect(yPosition,SIGNAL(valueChanged(int)),this,SIGNAL(optionsChanged()));
//connect(yPosition,SIGNAL(valueChanged(int)),this,SLOT(saveYPosition(int)));
coverDistance = new YACReaderSpinSliderWidget(this);
coverDistance->setText(tr("Cover gap"));
coverDistance->setRange(0,150);
//connect(coverDistance,SIGNAL(valueChanged(int)),this,SIGNAL(optionsChanged()));
//connect(coverDistance,SIGNAL(valueChanged(int)),this,SLOT(saveCoverDistance(int)));
centralDistance = new YACReaderSpinSliderWidget(this);
centralDistance->setText(tr("Central gap"));
centralDistance->setRange(0,150);
//connect(centralDistance,SIGNAL(valueChanged(int)),this,SIGNAL(optionsChanged()));
//connect(centralDistance,SIGNAL(valueChanged(int)),this,SLOT(saveCentralDistance(int)));
zoomLevel = new YACReaderSpinSliderWidget(this);
zoomLevel->setText(tr("Zoom"));
zoomLevel->setRange(-20,0);
//connect(zoomLevel,SIGNAL(valueChanged(int)),this,SIGNAL(optionsChanged()));
//connect(zoomLevel,SIGNAL(valueChanged(int)),this,SLOT(saveZoomLevel(int)));
yCoverOffset = new YACReaderSpinSliderWidget(this);
yCoverOffset->setText(tr("Y offset"));
yCoverOffset->setRange(-50,50);
//connect(yCoverOffset,SIGNAL(valueChanged(int)),this,SIGNAL(optionsChanged()));
//connect(yCoverOffset,SIGNAL(valueChanged(int)),this,SLOT(saveYCoverOffset(int)));
zCoverOffset = new YACReaderSpinSliderWidget(this);
zCoverOffset->setText(tr("Z offset"));
zCoverOffset->setRange(-50,50);
//connect(zCoverOffset,SIGNAL(valueChanged(int)),this,SIGNAL(optionsChanged()));
//connect(zCoverOffset,SIGNAL(valueChanged(int)),this,SLOT(saveZCoverOffset(int)));
coverRotation = new YACReaderSpinSliderWidget(this);
coverRotation->setText(tr("Cover Angle"));
coverRotation->setRange(0,360);
//connect(coverRotation,SIGNAL(valueChanged(int)),this,SIGNAL(optionsChanged()));
//connect(coverRotation,SIGNAL(valueChanged(int)),this,SLOT(saveCoverRotation(int)));
fadeOutDist = new YACReaderSpinSliderWidget(this);
fadeOutDist->setText(tr("Visibility"));
fadeOutDist->setRange(0,10);
//connect(fadeOutDist,SIGNAL(valueChanged(int)),this,SIGNAL(optionsChanged()));
//connect(fadeOutDist,SIGNAL(valueChanged(int)),this,SLOT(saveFadeOutDist(int)));
lightStrength = new YACReaderSpinSliderWidget(this);
lightStrength->setText(tr("Light"));
lightStrength->setRange(0,10);
//connect(lightStrength,SIGNAL(valueChanged(int)),this,SIGNAL(optionsChanged()));
//connect(lightStrength,SIGNAL(valueChanged(int)),this,SLOT(saveLightStrength(int)));
maxAngle = new YACReaderSpinSliderWidget(this);
maxAngle->setText(tr("Max angle"));
maxAngle->setRange(0,90);
//connect(maxAngle,SIGNAL(valueChanged(int)),this,SIGNAL(optionsChanged()));
//connect(maxAngle,SIGNAL(valueChanged(int)),this,SLOT(saveMaxAngle(int)));
QVBoxLayout *optionsLayoutStretch = new QVBoxLayout;
optionsLayoutStretch->setContentsMargins(0,0,0,0);
QGridLayout *optionsLayout = new QGridLayout;
optionsLayout->addWidget(xRotation,0,0);
optionsLayout->addWidget(yPosition,0,1);
optionsLayout->addWidget(coverDistance,1,0);
optionsLayout->addWidget(centralDistance,1,1);
optionsLayout->addWidget(zoomLevel,2,0);
optionsLayout->addWidget(yCoverOffset,2,1);
optionsLayout->addWidget(zCoverOffset,3,0);
optionsLayout->addWidget(coverRotation,3,1);
optionsLayout->addWidget(fadeOutDist,4,0);
optionsLayout->addWidget(lightStrength,4,1);
optionsLayout->addWidget(maxAngle,5,0);
optionsLayoutStretch->addLayout(optionsLayout);
optionsLayoutStretch->addStretch();
optionsGroupBox->setLayout(optionsLayoutStretch);
QHBoxLayout * groupBoxesLayout = new QHBoxLayout;
groupBoxesLayout->addWidget(groupBox);
groupBoxesLayout->addWidget(optionsGroupBox);
optionsGroupBox->hide();
QHBoxLayout * performanceSliderLayout = new QHBoxLayout;
performanceSliderLayout->addWidget(new QLabel(tr("Low Performance")));
performanceSliderLayout->addWidget(performanceSlider = new QSlider(Qt::Horizontal));
performanceSliderLayout->addWidget(new QLabel(tr("High Performance")));
performanceSlider->setMinimum(0);
performanceSlider->setMaximum(3);
performanceSlider->setSingleStep(1);
performanceSlider->setPageStep(1);
performanceSlider->setTickInterval(1);
performanceSlider->setTickPosition(QSlider::TicksRight);
QHBoxLayout * vSyncLayout = new QHBoxLayout;
vSyncCheck = new QCheckBox(tr("Use VSync (improve the image quality in fullscreen mode, worse performance)"));
vSyncLayout->addStretch();
vSyncLayout->addWidget(vSyncCheck);
QVBoxLayout * performanceLayout = new QVBoxLayout;
performanceLayout->addLayout(performanceSliderLayout);
performanceLayout->addLayout(vSyncLayout);
QGroupBox *performanceGroupBox = new QGroupBox(tr("Performance:"));
//connect(performanceSlider, SIGNAL(valueChanged(int)),this,SLOT(savePerformance(int)));
//connect(performanceSlider, SIGNAL(valueChanged(int)),this,SLOT(optionsChanged()));
performanceGroupBox->setLayout(performanceLayout);
layout->addLayout(groupBoxesLayout);
layout->addWidget(performanceGroupBox);
layout->setContentsMargins(0,0,0,0);
setLayout(layout);
}
void YACReaderGLFlowConfigWidget::avancedOptionToogled(bool show)
{
if(show)
optionsGroupBox->show();
else
optionsGroupBox->hide();
}
void YACReaderGLFlowConfigWidget::setValues(Preset preset)
{
xRotation->setValue(preset.cfRX);
yPosition->setValue(preset.cfY*100);
coverDistance->setValue(preset.xDistance*100);
centralDistance->setValue(preset.centerDistance*100);
zoomLevel->setValue(preset.cfZ);
yCoverOffset->setValue(preset.yDistance*100);
zCoverOffset->setValue(preset.zDistance*100);
coverRotation->setValue(preset.rotation*-1);
fadeOutDist->setValue(preset.animationFadeOutDist);
lightStrength->setValue(preset.viewRotateLightStrenght);
maxAngle->setValue(preset.viewAngle);
}

View File

@ -1,51 +1,51 @@
#ifndef YACREADER_GL_FLOW_CONFIG_WIDGET_H
#define YACREADER_GL_FLOW_CONFIG_WIDGET_H
#include "yacreader_flow_gl.h" //TODO
#include <QWidget>
class QRadioButton;
class YACReaderSpinSliderWidget;
class QSlider;
class QCheckBox;
class QPushButton;
class QGroupBox;
class YACReaderGLFlowConfigWidget : public QWidget
{
Q_OBJECT
public:
YACReaderGLFlowConfigWidget(QWidget * parent = 0);
//GL.........................
QRadioButton *radioClassic;
QRadioButton *radioStripe;
QRadioButton *radioOver;
QRadioButton *radionModern;
QRadioButton *radioDown;
YACReaderSpinSliderWidget * xRotation;
YACReaderSpinSliderWidget * yPosition;
YACReaderSpinSliderWidget * coverDistance;
YACReaderSpinSliderWidget * centralDistance;
YACReaderSpinSliderWidget * zoomLevel;
YACReaderSpinSliderWidget * yCoverOffset;
YACReaderSpinSliderWidget * zCoverOffset;
YACReaderSpinSliderWidget * coverRotation;
YACReaderSpinSliderWidget * fadeOutDist;
YACReaderSpinSliderWidget * lightStrength;
YACReaderSpinSliderWidget * maxAngle;
QSlider * performanceSlider;
QCheckBox * vSyncCheck;
QPushButton * showAdvancedOptions;
QGroupBox *optionsGroupBox;
public slots:
void setValues(Preset preset);
void avancedOptionToogled(bool show);
};
#ifndef YACREADER_GL_FLOW_CONFIG_WIDGET_H
#define YACREADER_GL_FLOW_CONFIG_WIDGET_H
#include "yacreader_flow_gl.h" //TODO
#include <QWidget>
class QRadioButton;
class YACReaderSpinSliderWidget;
class QSlider;
class QCheckBox;
class QPushButton;
class QGroupBox;
class YACReaderGLFlowConfigWidget : public QWidget
{
Q_OBJECT
public:
YACReaderGLFlowConfigWidget(QWidget * parent = 0);
//GL.........................
QRadioButton *radioClassic;
QRadioButton *radioStripe;
QRadioButton *radioOver;
QRadioButton *radionModern;
QRadioButton *radioDown;
YACReaderSpinSliderWidget * xRotation;
YACReaderSpinSliderWidget * yPosition;
YACReaderSpinSliderWidget * coverDistance;
YACReaderSpinSliderWidget * centralDistance;
YACReaderSpinSliderWidget * zoomLevel;
YACReaderSpinSliderWidget * yCoverOffset;
YACReaderSpinSliderWidget * zCoverOffset;
YACReaderSpinSliderWidget * coverRotation;
YACReaderSpinSliderWidget * fadeOutDist;
YACReaderSpinSliderWidget * lightStrength;
YACReaderSpinSliderWidget * maxAngle;
QSlider * performanceSlider;
QCheckBox * vSyncCheck;
QPushButton * showAdvancedOptions;
QGroupBox *optionsGroupBox;
public slots:
void setValues(Preset preset);
void avancedOptionToogled(bool show);
};
#endif // YACREADER_GL_FLOW_CONFIG_WIDGET_H

View File

@ -1,172 +1,172 @@
#include "yacreader_library_item_widget.h"
#include <QHBoxLayout>
#include <QLabel>
#include <QToolButton>
#include <QMouseEvent>
YACReaderLibraryItemWidget::YACReaderLibraryItemWidget(QString n/*ame*/, QString p/*ath*/, QWidget *parent) :
QWidget(parent),name(n),path(p),isSelected(false)
{
QHBoxLayout * mainLayout = new QHBoxLayout;
mainLayout->setMargin(0);
mainLayout->setSpacing(0);
//installEventFilter(this);
QPixmap iconPixmap(":/images/sidebar/libraryIcon.png");
icon = new QLabel(this);
icon->setPixmap(iconPixmap);
nameLabel = new QLabel(name,this);
options = new QToolButton(this);
#ifdef Q_OS_MAC
//TODO fix this crazy hack for having a propper retina icon for the options
//this hack has been perpetrated using Qt 5.5.0
QString sourceOptionsImage;
if(devicePixelRatio()>1)
sourceOptionsImage = ":/images/sidebar/libraryOptions@2x.png";
else
sourceOptionsImage = ":/images/sidebar/libraryOptions.png";
QPixmap iconOptionsPixmap(sourceOptionsImage);
iconOptionsPixmap.setDevicePixelRatio(devicePixelRatio());
QLabel * helperLabel = new QLabel(options);
helperLabel->move(4,2);
helperLabel->setFixedSize(14,14);
helperLabel->setPixmap(iconOptionsPixmap);
#else
options->setIcon(QIcon(":/images/sidebar/libraryOptions.png"));
#endif
options->setHidden(true);
options->setFixedWidth(18);
options->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Minimum);
options->setStyleSheet("QToolButton {border:none;}");
connect(options,SIGNAL(clicked()),this,SIGNAL(showOptions()));
/*up = new QToolButton(this);
up->setIcon(QIcon(":/images/libraryUp.png"));
up->setHidden(true);
up->setFixedWidth(18);
up->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Minimum);
down = new QToolButton(this);
down->setIcon(QIcon(":/images/libraryDown.png"));
down->setHidden(true);
down->setFixedWidth(18);
down->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Minimum);*/
mainLayout->addWidget(icon);
mainLayout->addWidget(nameLabel,Qt::AlignLeft);
mainLayout->addStretch();
mainLayout->addWidget(options);
/*mainLayout->addWidget(up);
mainLayout->addWidget(down);*/
setLayout(mainLayout);
#ifndef Q_OS_MAC
QString styleSheet = "background-color:transparent; color:#DDDFDF;";
setStyleSheet(styleSheet);
#endif
QString iconStyleSheet = "QLabel {padding:0 0 0 24px; margin:0px}";
icon->setStyleSheet(iconStyleSheet);
QString nameLabelStyleSheet = "QLabel {padding:0 0 0 3px; margin:0px;}";
nameLabel->setStyleSheet(nameLabelStyleSheet);
setMinimumHeight(20);
}
void YACReaderLibraryItemWidget::showUpDownButtons(bool show)
{
up->setHidden(!show);
down->setHidden(!show);
}
/*
bool YACReaderLibraryItemWidget::eventFilter(QObject *object, QEvent *event){
if(!isSelected && object==this && (event->type()==QEvent::Enter))
{
QString styleSheet = "background-color:#5E5E5E; border-top: 1px solid #5E5E5E;border-bottom: 1px solid #5E5E5E; ";
setStyleSheet(styleSheet);
up->setHidden(false);
down->setHidden(false);
options->setHidden(false);
return true;
}
if(!isSelected && object==this && (event->type()==QEvent::Leave))
{
QString styleSheet = "background-color:#454545; border-top: 1px solid #454545;border-bottom: 1px solid #454545;";
setStyleSheet(styleSheet);
up->setHidden(true);
down->setHidden(true);
options->setHidden(true);
return true;
}
if(object==this && (event->type()==QEvent::MouseButtonRelease))
{
QString styleSheet = "background-color:#2E2E2E; border-top: 1px solid #1F1F1F;border-bottom: 1px solid #636363; padding-top:1px; padding-bottom:1px;";
setStyleSheet(styleSheet);
emit(selected(name,path));
isSelected = true;
return true;
}
return false;
}*/
void YACReaderLibraryItemWidget::deselect()
{
#ifdef Q_OS_MAC
QString styleSheet = "background-color:transparent;";
setStyleSheet(styleSheet);
#else
QString styleSheet = "background-color:transparent; color:#DDDFDF;";
setStyleSheet(styleSheet);
#endif
QPixmap iconPixmap(":/images/sidebar/libraryIcon.png");
icon->setPixmap(iconPixmap);
/*up->setHidden(true);
down->setHidden(true);*/
options->setHidden(true);
isSelected = false;
}
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:#91c4f4; border-bottom:1px solid #91c4f4;";
#else
QString styleSheet = "color: white; background-color:#2E2E2E; font-weight:bold;";
#endif
setStyleSheet(styleSheet);
options->setHidden(false);
QPixmap iconPixmap(":/images/sidebar/libraryIconSelected.png");
icon->setPixmap(iconPixmap);
isSelected = true;
}
void YACReaderLibraryItemWidget::setName(const QString & name)
{
this->name = name;
nameLabel->setText(name);
}
#include "yacreader_library_item_widget.h"
#include <QHBoxLayout>
#include <QLabel>
#include <QToolButton>
#include <QMouseEvent>
YACReaderLibraryItemWidget::YACReaderLibraryItemWidget(QString n/*ame*/, QString p/*ath*/, QWidget *parent) :
QWidget(parent),name(n),path(p),isSelected(false)
{
QHBoxLayout * mainLayout = new QHBoxLayout;
mainLayout->setMargin(0);
mainLayout->setSpacing(0);
//installEventFilter(this);
QPixmap iconPixmap(":/images/sidebar/libraryIcon.png");
icon = new QLabel(this);
icon->setPixmap(iconPixmap);
nameLabel = new QLabel(name,this);
options = new QToolButton(this);
#ifdef Q_OS_MAC
//TODO fix this crazy hack for having a propper retina icon for the options
//this hack has been perpetrated using Qt 5.5.0
QString sourceOptionsImage;
if(devicePixelRatio()>1)
sourceOptionsImage = ":/images/sidebar/libraryOptions@2x.png";
else
sourceOptionsImage = ":/images/sidebar/libraryOptions.png";
QPixmap iconOptionsPixmap(sourceOptionsImage);
iconOptionsPixmap.setDevicePixelRatio(devicePixelRatio());
QLabel * helperLabel = new QLabel(options);
helperLabel->move(4,2);
helperLabel->setFixedSize(14,14);
helperLabel->setPixmap(iconOptionsPixmap);
#else
options->setIcon(QIcon(":/images/sidebar/libraryOptions.png"));
#endif
options->setHidden(true);
options->setFixedWidth(18);
options->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Minimum);
options->setStyleSheet("QToolButton {border:none;}");
connect(options,SIGNAL(clicked()),this,SIGNAL(showOptions()));
/*up = new QToolButton(this);
up->setIcon(QIcon(":/images/libraryUp.png"));
up->setHidden(true);
up->setFixedWidth(18);
up->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Minimum);
down = new QToolButton(this);
down->setIcon(QIcon(":/images/libraryDown.png"));
down->setHidden(true);
down->setFixedWidth(18);
down->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Minimum);*/
mainLayout->addWidget(icon);
mainLayout->addWidget(nameLabel,Qt::AlignLeft);
mainLayout->addStretch();
mainLayout->addWidget(options);
/*mainLayout->addWidget(up);
mainLayout->addWidget(down);*/
setLayout(mainLayout);
#ifndef Q_OS_MAC
QString styleSheet = "background-color:transparent; color:#DDDFDF;";
setStyleSheet(styleSheet);
#endif
QString iconStyleSheet = "QLabel {padding:0 0 0 24px; margin:0px}";
icon->setStyleSheet(iconStyleSheet);
QString nameLabelStyleSheet = "QLabel {padding:0 0 0 3px; margin:0px;}";
nameLabel->setStyleSheet(nameLabelStyleSheet);
setMinimumHeight(20);
}
void YACReaderLibraryItemWidget::showUpDownButtons(bool show)
{
up->setHidden(!show);
down->setHidden(!show);
}
/*
bool YACReaderLibraryItemWidget::eventFilter(QObject *object, QEvent *event){
if(!isSelected && object==this && (event->type()==QEvent::Enter))
{
QString styleSheet = "background-color:#5E5E5E; border-top: 1px solid #5E5E5E;border-bottom: 1px solid #5E5E5E; ";
setStyleSheet(styleSheet);
up->setHidden(false);
down->setHidden(false);
options->setHidden(false);
return true;
}
if(!isSelected && object==this && (event->type()==QEvent::Leave))
{
QString styleSheet = "background-color:#454545; border-top: 1px solid #454545;border-bottom: 1px solid #454545;";
setStyleSheet(styleSheet);
up->setHidden(true);
down->setHidden(true);
options->setHidden(true);
return true;
}
if(object==this && (event->type()==QEvent::MouseButtonRelease))
{
QString styleSheet = "background-color:#2E2E2E; border-top: 1px solid #1F1F1F;border-bottom: 1px solid #636363; padding-top:1px; padding-bottom:1px;";
setStyleSheet(styleSheet);
emit(selected(name,path));
isSelected = true;
return true;
}
return false;
}*/
void YACReaderLibraryItemWidget::deselect()
{
#ifdef Q_OS_MAC
QString styleSheet = "background-color:transparent;";
setStyleSheet(styleSheet);
#else
QString styleSheet = "background-color:transparent; color:#DDDFDF;";
setStyleSheet(styleSheet);
#endif
QPixmap iconPixmap(":/images/sidebar/libraryIcon.png");
icon->setPixmap(iconPixmap);
/*up->setHidden(true);
down->setHidden(true);*/
options->setHidden(true);
isSelected = false;
}
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:#91c4f4; border-bottom:1px solid #91c4f4;";
#else
QString styleSheet = "color: white; background-color:#2E2E2E; font-weight:bold;";
#endif
setStyleSheet(styleSheet);
options->setHidden(false);
QPixmap iconPixmap(":/images/sidebar/libraryIconSelected.png");
icon->setPixmap(iconPixmap);
isSelected = true;
}
void YACReaderLibraryItemWidget::setName(const QString & name)
{
this->name = name;
nameLabel->setText(name);
}

View File

@ -1,45 +1,45 @@
#ifndef YACREADER_LIBRARY_ITEM_WIDGET_H
#define YACREADER_LIBRARY_ITEM_WIDGET_H
#include <QWidget>
class QLabel;
class QToolButton;
class QMouseEvent;
class QEvent;
class YACReaderLibraryItemWidget : public QWidget
{
Q_OBJECT
public:
YACReaderLibraryItemWidget(QString name, QString path, QWidget *parent = 0);
QString name;
QString path;
signals:
void selected(QString,QString);
void showOptions();
public slots:
void showUpDownButtons(bool show);
//bool eventFilter(QObject *object, QEvent *event);
void select();
void deselect();
void setName(const QString & name);
private:
QLabel * icon;
QLabel * nameLabel;
QToolButton * options;
QToolButton * up;
QToolButton * down;
bool isSelected;
};
#endif // YACREADER_LIBRARY_ITEM_WIDGET_H
#ifndef YACREADER_LIBRARY_ITEM_WIDGET_H
#define YACREADER_LIBRARY_ITEM_WIDGET_H
#include <QWidget>
class QLabel;
class QToolButton;
class QMouseEvent;
class QEvent;
class YACReaderLibraryItemWidget : public QWidget
{
Q_OBJECT
public:
YACReaderLibraryItemWidget(QString name, QString path, QWidget *parent = 0);
QString name;
QString path;
signals:
void selected(QString,QString);
void showOptions();
public slots:
void showUpDownButtons(bool show);
//bool eventFilter(QObject *object, QEvent *event);
void select();
void deselect();
void setName(const QString & name);
private:
QLabel * icon;
QLabel * nameLabel;
QToolButton * options;
QToolButton * up;
QToolButton * down;
bool isSelected;
};
#endif // YACREADER_LIBRARY_ITEM_WIDGET_H

View File

@ -1,128 +1,128 @@
#include "yacreader_library_list_widget.h"
#include "yacreader_library_item_widget.h"
#include <QVBoxLayout>
#include <QMouseEvent>
#include <QMenu>
#include "qnaturalsorting.h"
YACReaderLibraryListWidget::YACReaderLibraryListWidget(QWidget *parent) :
QWidget(parent),currentLibraryIndex(-1)
{
QVBoxLayout * mainLayout = new QVBoxLayout;
mainLayout->setSpacing(0);
mainLayout->setMargin(0);
this->setLayout(mainLayout);
}
void YACReaderLibraryListWidget::addItem(QString name, QString path)
{
QVBoxLayout * mainLayout = dynamic_cast<QVBoxLayout *>(layout());
YACReaderLibraryItemWidget * library = new YACReaderLibraryItemWidget(name,path,this);
connect(library,SIGNAL(showOptions()),this,SLOT(showContextMenu()));
QList<YACReaderLibraryItemWidget *>::iterator itr;
int i = 0;
for(itr = librariesList.begin(); itr!=librariesList.end() && !naturalSortLessThanCI(name,(*itr)->name);itr++)
i++;
librariesList.insert(itr,library);
//connect(library,SIGNAL(selected(QString,QString)),this,SIGNAL(librarySelected(QString,QString)));
//connect(library,SIGNAL(selected(QString,QString)),this,SLOT(updateLibraries(QString,QString)));
mainLayout->insertWidget(i,library);
}
QString YACReaderLibraryListWidget::currentText()
{
return librariesList.at(currentLibraryIndex)->name;
}
int YACReaderLibraryListWidget::findText(QString text)
{
for(int i=0;i<librariesList.count();i++)
{
if(librariesList.at(i)->name == text)
return i;
}
return -1;
}
void YACReaderLibraryListWidget::setCurrentIndex(int index)
{
if(index>=0 && index < librariesList.count())
{
librariesList.at(index)->select();
currentLibraryIndex = index;
deselectAllBut(index);
emit currentIndexChanged(librariesList.at(currentLibraryIndex)->name);
}
}
int YACReaderLibraryListWidget::currentIndex()
{
return currentLibraryIndex;
}
void YACReaderLibraryListWidget::removeItem(int index)
{
YACReaderLibraryItemWidget * itemWidget = librariesList.at(index);
this->layout()->removeWidget(itemWidget);
librariesList.removeAt(index);
if(librariesList.count()>0)
{
setCurrentIndex(0);
}
delete itemWidget;
}
void YACReaderLibraryListWidget::mousePressEvent ( QMouseEvent * event )
{
if(librariesList.count()>0)
{
int h = librariesList.at(0)->height();
int item = event->pos().y() / h;
if(item!=currentLibraryIndex)
{
setCurrentIndex(item);
}
}
}
void YACReaderLibraryListWidget::deselectAllBut(int index)
{
for(int i=0;i<librariesList.count();i++)
{
if(i!=index)
librariesList.at(i)->deselect();
}
}
void YACReaderLibraryListWidget::showContextMenu()
{
YACReaderLibraryItemWidget * itemWidget = librariesList.at(currentLibraryIndex);
QMenu::exec(actions(),itemWidget->mapToGlobal(QPoint(itemWidget->width()-8,itemWidget->height()/2)));
}
void YACReaderLibraryListWidget::renameCurrentLibrary(QString newName)
{
YACReaderLibraryItemWidget * itemWidget = librariesList.at(currentLibraryIndex);
this->layout()->removeWidget(itemWidget);
librariesList.removeOne(itemWidget);
itemWidget->setName(newName);
QList<YACReaderLibraryItemWidget *>::iterator itr;
int i = 0;
for(itr = librariesList.begin(); itr!=librariesList.end() && !naturalSortLessThanCI(newName,(*itr)->name);itr++)
i++;
librariesList.insert(itr,itemWidget);
QVBoxLayout * mainLayout = dynamic_cast<QVBoxLayout *>(layout());
mainLayout->insertWidget(i,itemWidget);
currentLibraryIndex = i;
}
#include "yacreader_library_list_widget.h"
#include "yacreader_library_item_widget.h"
#include <QVBoxLayout>
#include <QMouseEvent>
#include <QMenu>
#include "qnaturalsorting.h"
YACReaderLibraryListWidget::YACReaderLibraryListWidget(QWidget *parent) :
QWidget(parent),currentLibraryIndex(-1)
{
QVBoxLayout * mainLayout = new QVBoxLayout;
mainLayout->setSpacing(0);
mainLayout->setMargin(0);
this->setLayout(mainLayout);
}
void YACReaderLibraryListWidget::addItem(QString name, QString path)
{
QVBoxLayout * mainLayout = dynamic_cast<QVBoxLayout *>(layout());
YACReaderLibraryItemWidget * library = new YACReaderLibraryItemWidget(name,path,this);
connect(library,SIGNAL(showOptions()),this,SLOT(showContextMenu()));
QList<YACReaderLibraryItemWidget *>::iterator itr;
int i = 0;
for(itr = librariesList.begin(); itr!=librariesList.end() && !naturalSortLessThanCI(name,(*itr)->name);itr++)
i++;
librariesList.insert(itr,library);
//connect(library,SIGNAL(selected(QString,QString)),this,SIGNAL(librarySelected(QString,QString)));
//connect(library,SIGNAL(selected(QString,QString)),this,SLOT(updateLibraries(QString,QString)));
mainLayout->insertWidget(i,library);
}
QString YACReaderLibraryListWidget::currentText()
{
return librariesList.at(currentLibraryIndex)->name;
}
int YACReaderLibraryListWidget::findText(QString text)
{
for(int i=0;i<librariesList.count();i++)
{
if(librariesList.at(i)->name == text)
return i;
}
return -1;
}
void YACReaderLibraryListWidget::setCurrentIndex(int index)
{
if(index>=0 && index < librariesList.count())
{
librariesList.at(index)->select();
currentLibraryIndex = index;
deselectAllBut(index);
emit currentIndexChanged(librariesList.at(currentLibraryIndex)->name);
}
}
int YACReaderLibraryListWidget::currentIndex()
{
return currentLibraryIndex;
}
void YACReaderLibraryListWidget::removeItem(int index)
{
YACReaderLibraryItemWidget * itemWidget = librariesList.at(index);
this->layout()->removeWidget(itemWidget);
librariesList.removeAt(index);
if(librariesList.count()>0)
{
setCurrentIndex(0);
}
delete itemWidget;
}
void YACReaderLibraryListWidget::mousePressEvent ( QMouseEvent * event )
{
if(librariesList.count()>0)
{
int h = librariesList.at(0)->height();
int item = event->pos().y() / h;
if(item!=currentLibraryIndex)
{
setCurrentIndex(item);
}
}
}
void YACReaderLibraryListWidget::deselectAllBut(int index)
{
for(int i=0;i<librariesList.count();i++)
{
if(i!=index)
librariesList.at(i)->deselect();
}
}
void YACReaderLibraryListWidget::showContextMenu()
{
YACReaderLibraryItemWidget * itemWidget = librariesList.at(currentLibraryIndex);
QMenu::exec(actions(),itemWidget->mapToGlobal(QPoint(itemWidget->width()-8,itemWidget->height()/2)));
}
void YACReaderLibraryListWidget::renameCurrentLibrary(QString newName)
{
YACReaderLibraryItemWidget * itemWidget = librariesList.at(currentLibraryIndex);
this->layout()->removeWidget(itemWidget);
librariesList.removeOne(itemWidget);
itemWidget->setName(newName);
QList<YACReaderLibraryItemWidget *>::iterator itr;
int i = 0;
for(itr = librariesList.begin(); itr!=librariesList.end() && !naturalSortLessThanCI(newName,(*itr)->name);itr++)
i++;
librariesList.insert(itr,itemWidget);
QVBoxLayout * mainLayout = dynamic_cast<QVBoxLayout *>(layout());
mainLayout->insertWidget(i,itemWidget);
currentLibraryIndex = i;
}

View File

@ -1,37 +1,37 @@
#ifndef YACREADER_LIBRARY_LIST_WIDGET_H
#define YACREADER_LIBRARY_LIST_WIDGET_H
#include <QWidget>
class YACReaderLibraryItemWidget;
class QMouseEvent;
class YACReaderLibraryListWidget : public QWidget
{
Q_OBJECT
public:
explicit YACReaderLibraryListWidget(QWidget *parent = 0);
signals:
void currentIndexChanged(QString text);
public slots:
QString currentText();
int findText(QString text);
void setCurrentIndex(int index);
void addItem(QString name, QString path);
int currentIndex();
void removeItem(int index);
void showContextMenu();
void renameCurrentLibrary(QString newName);
protected:
void mousePressEvent ( QMouseEvent * event );
private:
int currentLibraryIndex;
QList < YACReaderLibraryItemWidget* > librariesList;
void deselectAllBut(int index);
};
#endif // YACREADER_LIBRARY_LIST_WIDGET_H
#ifndef YACREADER_LIBRARY_LIST_WIDGET_H
#define YACREADER_LIBRARY_LIST_WIDGET_H
#include <QWidget>
class YACReaderLibraryItemWidget;
class QMouseEvent;
class YACReaderLibraryListWidget : public QWidget
{
Q_OBJECT
public:
explicit YACReaderLibraryListWidget(QWidget *parent = 0);
signals:
void currentIndexChanged(QString text);
public slots:
QString currentText();
int findText(QString text);
void setCurrentIndex(int index);
void addItem(QString name, QString path);
int currentIndex();
void removeItem(int index);
void showContextMenu();
void renameCurrentLibrary(QString newName);
protected:
void mousePressEvent ( QMouseEvent * event );
private:
int currentLibraryIndex;
QList < YACReaderLibraryItemWidget* > librariesList;
void deselectAllBut(int index);
};
#endif // YACREADER_LIBRARY_LIST_WIDGET_H

View File

@ -1,409 +1,409 @@
#include "yacreader_options_dialog.h"
#include "yacreader_flow_config_widget.h"
#ifndef NO_OPENGL
#include "yacreader_gl_flow_config_widget.h"
#else
#include "pictureflow.h"
#endif
#include "yacreader_spin_slider_widget.h"
#include "yacreader_global.h"
#include <QPushButton>
#include <QCheckBox>
#include <QRadioButton>
#include <QSlider>
#include <QSettings>
#include <QGroupBox>
#include <QVBoxLayout>
YACReaderOptionsDialog::YACReaderOptionsDialog(QWidget * parent)
:QDialog(parent)
{
sw = new YACReaderFlowConfigWidget(this);
#ifndef NO_OPENGL
gl = new YACReaderGLFlowConfigWidget(this);
#endif
accept = new QPushButton(tr("Save"));
cancel = new QPushButton(tr("Cancel"));
cancel->setDefault(true);
QVBoxLayout * shortcutsLayout = new QVBoxLayout();
QPushButton * shortcutsButton = new QPushButton(tr("Edit shortcuts"));
shortcutsLayout->addWidget(shortcutsButton);
shortcutsBox = new QGroupBox(tr("Shortcuts"));
shortcutsBox->setLayout(shortcutsLayout);
connect(shortcutsButton,SIGNAL(clicked()),this,SIGNAL(editShortcuts()));
connect(accept,SIGNAL(clicked()),this,SLOT(saveOptions()));
connect(cancel,SIGNAL(clicked()),this,SLOT(restoreOptions())); //TODO fix this
connect(cancel,SIGNAL(clicked()),this,SLOT(close()));
#ifndef NO_OPENGL
useGL = new QCheckBox(tr("Use hardware acceleration (restart needed)"));
connect(useGL,SIGNAL(stateChanged(int)),this,SLOT(saveUseGL(int)));
#endif
#ifdef FORCE_ANGLE
useGL->setHidden(true);
#endif
//sw CONNECTIONS
connect(sw->radio1,SIGNAL(toggled(bool)),this,SLOT(setClassicConfigSW()));
connect(sw->radio2,SIGNAL(toggled(bool)),this,SLOT(setStripeConfigSW()));
connect(sw->radio3,SIGNAL(toggled(bool)),this,SLOT(setOverlappedStripeConfigSW()));
#ifndef NO_OPENGL
//gl CONNECTIONS
connect(gl->radioClassic,SIGNAL(toggled(bool)),this,SLOT(setClassicConfig()));
connect(gl->radioStripe,SIGNAL(toggled(bool)),this,SLOT(setStripeConfig()));
connect(gl->radioOver,SIGNAL(toggled(bool)),this,SLOT(setOverlappedStripeConfig()));
connect(gl->radionModern,SIGNAL(toggled(bool)),this,SLOT(setModernConfig()));
connect(gl->radioDown,SIGNAL(toggled(bool)),this,SLOT(setRouletteConfig()));
connect(gl->radioClassic,SIGNAL(toggled(bool)),this,SIGNAL(optionsChanged()));
connect(gl->radioStripe,SIGNAL(toggled(bool)),this,SIGNAL(optionsChanged()));
connect(gl->radioOver,SIGNAL(toggled(bool)),this,SIGNAL(optionsChanged()));
connect(gl->radionModern,SIGNAL(toggled(bool)),this,SIGNAL(optionsChanged()));
connect(gl->radioDown,SIGNAL(toggled(bool)),this,SIGNAL(optionsChanged()));
connect(gl->xRotation,SIGNAL(valueChanged(int)),this,SLOT(saveXRotation(int)));
connect(gl->xRotation,SIGNAL(valueChanged(int)),this,SIGNAL(optionsChanged()));
connect(gl->yPosition,SIGNAL(valueChanged(int)),this,SLOT(saveYPosition(int)));
connect(gl->yPosition,SIGNAL(valueChanged(int)),this,SIGNAL(optionsChanged()));
connect(gl->coverDistance,SIGNAL(valueChanged(int)),this,SLOT(saveCoverDistance(int)));
connect(gl->coverDistance,SIGNAL(valueChanged(int)),this,SIGNAL(optionsChanged()));
connect(gl->centralDistance,SIGNAL(valueChanged(int)),this,SLOT(saveCentralDistance(int)));
connect(gl->centralDistance,SIGNAL(valueChanged(int)),this,SIGNAL(optionsChanged()));
connect(gl->zoomLevel,SIGNAL(valueChanged(int)),this,SLOT(saveZoomLevel(int)));
connect(gl->zoomLevel,SIGNAL(valueChanged(int)),this,SIGNAL(optionsChanged()));
connect(gl->yCoverOffset,SIGNAL(valueChanged(int)),this,SLOT(saveYCoverOffset(int)));
connect(gl->yCoverOffset,SIGNAL(valueChanged(int)),this,SIGNAL(optionsChanged()));
connect(gl->zCoverOffset,SIGNAL(valueChanged(int)),this,SLOT(saveZCoverOffset(int)));
connect(gl->zCoverOffset,SIGNAL(valueChanged(int)),this,SIGNAL(optionsChanged()));
connect(gl->coverRotation,SIGNAL(valueChanged(int)),this,SLOT(saveCoverRotation(int)));
connect(gl->coverRotation,SIGNAL(valueChanged(int)),this,SIGNAL(optionsChanged()));
connect(gl->fadeOutDist,SIGNAL(valueChanged(int)),this,SLOT(saveFadeOutDist(int)));
connect(gl->fadeOutDist,SIGNAL(valueChanged(int)),this,SIGNAL(optionsChanged()));
connect(gl->lightStrength,SIGNAL(valueChanged(int)),this,SLOT(saveLightStrength(int)));
connect(gl->lightStrength,SIGNAL(valueChanged(int)),this,SIGNAL(optionsChanged()));
connect(gl->maxAngle,SIGNAL(valueChanged(int)),this,SLOT(saveMaxAngle(int)));
connect(gl->maxAngle,SIGNAL(valueChanged(int)),this,SIGNAL(optionsChanged()));
connect(gl->performanceSlider, SIGNAL(valueChanged(int)),this,SLOT(savePerformance(int)));
connect(gl->performanceSlider, SIGNAL(valueChanged(int)),this,SIGNAL(optionsChanged()));
connect(gl->vSyncCheck,SIGNAL(stateChanged(int)),this,SLOT(saveUseVSync(int)));
#endif
}
#ifndef NO_OPENGL
void YACReaderOptionsDialog::savePerformance(int value)
{
settings->setValue(PERFORMANCE,value);
}
void YACReaderOptionsDialog::saveUseVSync(int b)
{
settings->setValue(V_SYNC,b);
}
void YACReaderOptionsDialog::saveFlowParameters()
{
settings->setValue(X_ROTATION,gl->xRotation->getValue());
settings->setValue(Y_POSITION,gl->yPosition->getValue());
settings->setValue(COVER_DISTANCE,gl->coverDistance->getValue());
settings->setValue(CENTRAL_DISTANCE,gl->centralDistance->getValue());
settings->setValue(ZOOM_LEVEL,gl->zoomLevel->getValue());
settings->setValue(Y_COVER_OFFSET,gl->yCoverOffset->getValue());
settings->setValue(Z_COVER_OFFSET,gl->zCoverOffset->getValue());
settings->setValue(COVER_ROTATION,gl->coverRotation->getValue());
settings->setValue(FADE_OUT_DIST,gl->fadeOutDist->getValue());
settings->setValue(LIGHT_STRENGTH,gl->lightStrength->getValue());
settings->setValue(MAX_ANGLE,gl->maxAngle->getValue());
}
#endif
void YACReaderOptionsDialog::saveOptions()
{
emit(optionsChanged());
close();
}
#ifndef NO_OPENGL
void YACReaderOptionsDialog::saveUseGL(int b)
{
if(Qt::Checked == b)
{
sw->setVisible(false);
gl->setVisible(true);
}
else
{
gl->setVisible(false);
sw->setVisible(true);
}
resize(0,0);
settings->setValue(USE_OPEN_GL,b);
}
#endif
#ifndef NO_OPENGL
void YACReaderOptionsDialog::saveXRotation(int value)
{
settings->setValue(FLOW_TYPE_GL,Custom);
settings->setValue(X_ROTATION,value);
}
void YACReaderOptionsDialog::saveYPosition(int value)
{
settings->setValue(FLOW_TYPE_GL,Custom);
settings->setValue(Y_POSITION,value);
}
void YACReaderOptionsDialog::saveCoverDistance(int value)
{
settings->setValue(FLOW_TYPE_GL,Custom);
settings->setValue(COVER_DISTANCE,value);
}
void YACReaderOptionsDialog::saveCentralDistance(int value)
{
settings->setValue(FLOW_TYPE_GL,Custom);
settings->setValue(CENTRAL_DISTANCE,value);
}
void YACReaderOptionsDialog::saveZoomLevel(int value)
{
settings->setValue(FLOW_TYPE_GL,Custom);
settings->setValue(ZOOM_LEVEL,value);
}
void YACReaderOptionsDialog::saveYCoverOffset(int value)
{
settings->setValue(FLOW_TYPE_GL,Custom);
settings->setValue(Y_COVER_OFFSET,value);
}
void YACReaderOptionsDialog::saveZCoverOffset(int value)
{
settings->setValue(FLOW_TYPE_GL,Custom);
settings->setValue(Z_COVER_OFFSET,value);
}
void YACReaderOptionsDialog::saveCoverRotation(int value)
{
settings->setValue(FLOW_TYPE_GL,Custom);
settings->setValue(COVER_ROTATION,value);
}
void YACReaderOptionsDialog::saveFadeOutDist(int value)
{
settings->setValue(FLOW_TYPE_GL,Custom);
settings->setValue(FADE_OUT_DIST,value);
}
void YACReaderOptionsDialog::saveLightStrength(int value)
{
settings->setValue(FLOW_TYPE_GL,Custom);
settings->setValue(LIGHT_STRENGTH,value);
}
void YACReaderOptionsDialog::saveMaxAngle(int value)
{
settings->setValue(FLOW_TYPE_GL,Custom);
settings->setValue(MAX_ANGLE,value);
}
#endif
void YACReaderOptionsDialog::restoreOptions(QSettings * settings)
{
this->settings = settings;
//FLOW CONFIG
#ifndef NO_OPENGL
if(settings->contains(USE_OPEN_GL) && settings->value(USE_OPEN_GL).toInt() == Qt::Checked)
{
sw->setVisible(false);
gl->setVisible(true);
useGL->setChecked(true);
}
else
{
gl->setVisible(false);
sw->setVisible(true);
useGL->setChecked(false);
}
if(!settings->contains(FLOW_TYPE_GL))
{
setClassicConfig();
gl->radioClassic->setChecked(true);
gl->performanceSlider->setValue(1);
return;
}
if(settings->contains(V_SYNC) && settings->value(V_SYNC).toInt() == Qt::Checked)
gl->vSyncCheck->setChecked(true);
else
gl->vSyncCheck->setChecked(false);
gl->performanceSlider->setValue(settings->value(PERFORMANCE).toInt());
FlowType flowType;
switch(settings->value(FLOW_TYPE_GL).toInt())
{
case 0:
flowType = CoverFlowLike;
break;
case 1:
flowType = Strip;
break;
case 2:
flowType = StripOverlapped;
break;
case 3:
flowType = Modern;
break;
case 4:
flowType = Roulette;
break;
case 5:
flowType = Custom;
break;
default:
flowType = CoverFlowLike;
}
if(flowType == Custom)
{
loadConfig();
return;
}
if(flowType == CoverFlowLike)
{
setClassicConfig();
gl->radioClassic->setChecked(true);
return;
}
if(flowType == Strip)
{
setStripeConfig();
gl->radioStripe->setChecked(true);
return;
}
if(flowType == StripOverlapped)
{
setOverlappedStripeConfig();
gl->radioOver->setChecked(true);
return;
}
if(flowType == Modern)
{
setModernConfig();
gl->radionModern->setChecked(true);
return;
}
if(flowType == Roulette)
{
setRouletteConfig();
gl->radioDown->setChecked(true);
return;
}
//END FLOW CONFIG
#endif
}
void YACReaderOptionsDialog::restoreOptions()
{
restoreOptions(settings);
}
#ifndef NO_OPENGL
void YACReaderOptionsDialog::loadConfig()
{
gl->xRotation->setValue(settings->value(X_ROTATION).toInt());
gl->yPosition->setValue(settings->value(Y_POSITION).toInt());
gl->coverDistance->setValue(settings->value(COVER_DISTANCE).toInt());
gl->centralDistance->setValue(settings->value(CENTRAL_DISTANCE).toInt());
gl->zoomLevel->setValue(settings->value(ZOOM_LEVEL).toInt());
gl->yCoverOffset->setValue(settings->value(Y_COVER_OFFSET).toInt());
gl->zCoverOffset->setValue(settings->value(Z_COVER_OFFSET).toInt());
gl->coverRotation->setValue(settings->value(COVER_ROTATION).toInt());
gl->fadeOutDist->setValue(settings->value(FADE_OUT_DIST).toInt());
gl->lightStrength->setValue(settings->value(LIGHT_STRENGTH).toInt());
gl->maxAngle->setValue(settings->value(MAX_ANGLE).toInt());
}
#endif
void YACReaderOptionsDialog::setClassicConfigSW()
{
settings->setValue(FLOW_TYPE_SW,CoverFlowLike);
}
void YACReaderOptionsDialog::setStripeConfigSW()
{
settings->setValue(FLOW_TYPE_SW,Strip);
}
void YACReaderOptionsDialog::setOverlappedStripeConfigSW()
{
settings->setValue(FLOW_TYPE_SW,StripOverlapped);
}
#ifndef NO_OPENGL
void YACReaderOptionsDialog::setClassicConfig()
{
gl->setValues(presetYACReaderFlowClassicConfig);
saveFlowParameters();
settings->setValue(FLOW_TYPE_GL,CoverFlowLike);
}
void YACReaderOptionsDialog::setStripeConfig()
{
gl->setValues(presetYACReaderFlowStripeConfig);
saveFlowParameters();
settings->setValue(FLOW_TYPE_GL,Strip);
}
void YACReaderOptionsDialog::setOverlappedStripeConfig()
{
gl->setValues(presetYACReaderFlowOverlappedStripeConfig);
saveFlowParameters();
settings->setValue(FLOW_TYPE_GL,StripOverlapped);
}
void YACReaderOptionsDialog::setModernConfig()
{
gl->setValues(defaultYACReaderFlowConfig);
saveFlowParameters();
settings->setValue(FLOW_TYPE_GL,Modern);
}
void YACReaderOptionsDialog::setRouletteConfig()
{
gl->setValues(pressetYACReaderFlowDownConfig);
saveFlowParameters();
settings->setValue(FLOW_TYPE_GL,Roulette);
}
#endif
#include "yacreader_options_dialog.h"
#include "yacreader_flow_config_widget.h"
#ifndef NO_OPENGL
#include "yacreader_gl_flow_config_widget.h"
#else
#include "pictureflow.h"
#endif
#include "yacreader_spin_slider_widget.h"
#include "yacreader_global.h"
#include <QPushButton>
#include <QCheckBox>
#include <QRadioButton>
#include <QSlider>
#include <QSettings>
#include <QGroupBox>
#include <QVBoxLayout>
YACReaderOptionsDialog::YACReaderOptionsDialog(QWidget * parent)
:QDialog(parent)
{
sw = new YACReaderFlowConfigWidget(this);
#ifndef NO_OPENGL
gl = new YACReaderGLFlowConfigWidget(this);
#endif
accept = new QPushButton(tr("Save"));
cancel = new QPushButton(tr("Cancel"));
cancel->setDefault(true);
QVBoxLayout * shortcutsLayout = new QVBoxLayout();
QPushButton * shortcutsButton = new QPushButton(tr("Edit shortcuts"));
shortcutsLayout->addWidget(shortcutsButton);
shortcutsBox = new QGroupBox(tr("Shortcuts"));
shortcutsBox->setLayout(shortcutsLayout);
connect(shortcutsButton,SIGNAL(clicked()),this,SIGNAL(editShortcuts()));
connect(accept,SIGNAL(clicked()),this,SLOT(saveOptions()));
connect(cancel,SIGNAL(clicked()),this,SLOT(restoreOptions())); //TODO fix this
connect(cancel,SIGNAL(clicked()),this,SLOT(close()));
#ifndef NO_OPENGL
useGL = new QCheckBox(tr("Use hardware acceleration (restart needed)"));
connect(useGL,SIGNAL(stateChanged(int)),this,SLOT(saveUseGL(int)));
#endif
#ifdef FORCE_ANGLE
useGL->setHidden(true);
#endif
//sw CONNECTIONS
connect(sw->radio1,SIGNAL(toggled(bool)),this,SLOT(setClassicConfigSW()));
connect(sw->radio2,SIGNAL(toggled(bool)),this,SLOT(setStripeConfigSW()));
connect(sw->radio3,SIGNAL(toggled(bool)),this,SLOT(setOverlappedStripeConfigSW()));
#ifndef NO_OPENGL
//gl CONNECTIONS
connect(gl->radioClassic,SIGNAL(toggled(bool)),this,SLOT(setClassicConfig()));
connect(gl->radioStripe,SIGNAL(toggled(bool)),this,SLOT(setStripeConfig()));
connect(gl->radioOver,SIGNAL(toggled(bool)),this,SLOT(setOverlappedStripeConfig()));
connect(gl->radionModern,SIGNAL(toggled(bool)),this,SLOT(setModernConfig()));
connect(gl->radioDown,SIGNAL(toggled(bool)),this,SLOT(setRouletteConfig()));
connect(gl->radioClassic,SIGNAL(toggled(bool)),this,SIGNAL(optionsChanged()));
connect(gl->radioStripe,SIGNAL(toggled(bool)),this,SIGNAL(optionsChanged()));
connect(gl->radioOver,SIGNAL(toggled(bool)),this,SIGNAL(optionsChanged()));
connect(gl->radionModern,SIGNAL(toggled(bool)),this,SIGNAL(optionsChanged()));
connect(gl->radioDown,SIGNAL(toggled(bool)),this,SIGNAL(optionsChanged()));
connect(gl->xRotation,SIGNAL(valueChanged(int)),this,SLOT(saveXRotation(int)));
connect(gl->xRotation,SIGNAL(valueChanged(int)),this,SIGNAL(optionsChanged()));
connect(gl->yPosition,SIGNAL(valueChanged(int)),this,SLOT(saveYPosition(int)));
connect(gl->yPosition,SIGNAL(valueChanged(int)),this,SIGNAL(optionsChanged()));
connect(gl->coverDistance,SIGNAL(valueChanged(int)),this,SLOT(saveCoverDistance(int)));
connect(gl->coverDistance,SIGNAL(valueChanged(int)),this,SIGNAL(optionsChanged()));
connect(gl->centralDistance,SIGNAL(valueChanged(int)),this,SLOT(saveCentralDistance(int)));
connect(gl->centralDistance,SIGNAL(valueChanged(int)),this,SIGNAL(optionsChanged()));
connect(gl->zoomLevel,SIGNAL(valueChanged(int)),this,SLOT(saveZoomLevel(int)));
connect(gl->zoomLevel,SIGNAL(valueChanged(int)),this,SIGNAL(optionsChanged()));
connect(gl->yCoverOffset,SIGNAL(valueChanged(int)),this,SLOT(saveYCoverOffset(int)));
connect(gl->yCoverOffset,SIGNAL(valueChanged(int)),this,SIGNAL(optionsChanged()));
connect(gl->zCoverOffset,SIGNAL(valueChanged(int)),this,SLOT(saveZCoverOffset(int)));
connect(gl->zCoverOffset,SIGNAL(valueChanged(int)),this,SIGNAL(optionsChanged()));
connect(gl->coverRotation,SIGNAL(valueChanged(int)),this,SLOT(saveCoverRotation(int)));
connect(gl->coverRotation,SIGNAL(valueChanged(int)),this,SIGNAL(optionsChanged()));
connect(gl->fadeOutDist,SIGNAL(valueChanged(int)),this,SLOT(saveFadeOutDist(int)));
connect(gl->fadeOutDist,SIGNAL(valueChanged(int)),this,SIGNAL(optionsChanged()));
connect(gl->lightStrength,SIGNAL(valueChanged(int)),this,SLOT(saveLightStrength(int)));
connect(gl->lightStrength,SIGNAL(valueChanged(int)),this,SIGNAL(optionsChanged()));
connect(gl->maxAngle,SIGNAL(valueChanged(int)),this,SLOT(saveMaxAngle(int)));
connect(gl->maxAngle,SIGNAL(valueChanged(int)),this,SIGNAL(optionsChanged()));
connect(gl->performanceSlider, SIGNAL(valueChanged(int)),this,SLOT(savePerformance(int)));
connect(gl->performanceSlider, SIGNAL(valueChanged(int)),this,SIGNAL(optionsChanged()));
connect(gl->vSyncCheck,SIGNAL(stateChanged(int)),this,SLOT(saveUseVSync(int)));
#endif
}
#ifndef NO_OPENGL
void YACReaderOptionsDialog::savePerformance(int value)
{
settings->setValue(PERFORMANCE,value);
}
void YACReaderOptionsDialog::saveUseVSync(int b)
{
settings->setValue(V_SYNC,b);
}
void YACReaderOptionsDialog::saveFlowParameters()
{
settings->setValue(X_ROTATION,gl->xRotation->getValue());
settings->setValue(Y_POSITION,gl->yPosition->getValue());
settings->setValue(COVER_DISTANCE,gl->coverDistance->getValue());
settings->setValue(CENTRAL_DISTANCE,gl->centralDistance->getValue());
settings->setValue(ZOOM_LEVEL,gl->zoomLevel->getValue());
settings->setValue(Y_COVER_OFFSET,gl->yCoverOffset->getValue());
settings->setValue(Z_COVER_OFFSET,gl->zCoverOffset->getValue());
settings->setValue(COVER_ROTATION,gl->coverRotation->getValue());
settings->setValue(FADE_OUT_DIST,gl->fadeOutDist->getValue());
settings->setValue(LIGHT_STRENGTH,gl->lightStrength->getValue());
settings->setValue(MAX_ANGLE,gl->maxAngle->getValue());
}
#endif
void YACReaderOptionsDialog::saveOptions()
{
emit(optionsChanged());
close();
}
#ifndef NO_OPENGL
void YACReaderOptionsDialog::saveUseGL(int b)
{
if(Qt::Checked == b)
{
sw->setVisible(false);
gl->setVisible(true);
}
else
{
gl->setVisible(false);
sw->setVisible(true);
}
resize(0,0);
settings->setValue(USE_OPEN_GL,b);
}
#endif
#ifndef NO_OPENGL
void YACReaderOptionsDialog::saveXRotation(int value)
{
settings->setValue(FLOW_TYPE_GL,Custom);
settings->setValue(X_ROTATION,value);
}
void YACReaderOptionsDialog::saveYPosition(int value)
{
settings->setValue(FLOW_TYPE_GL,Custom);
settings->setValue(Y_POSITION,value);
}
void YACReaderOptionsDialog::saveCoverDistance(int value)
{
settings->setValue(FLOW_TYPE_GL,Custom);
settings->setValue(COVER_DISTANCE,value);
}
void YACReaderOptionsDialog::saveCentralDistance(int value)
{
settings->setValue(FLOW_TYPE_GL,Custom);
settings->setValue(CENTRAL_DISTANCE,value);
}
void YACReaderOptionsDialog::saveZoomLevel(int value)
{
settings->setValue(FLOW_TYPE_GL,Custom);
settings->setValue(ZOOM_LEVEL,value);
}
void YACReaderOptionsDialog::saveYCoverOffset(int value)
{
settings->setValue(FLOW_TYPE_GL,Custom);
settings->setValue(Y_COVER_OFFSET,value);
}
void YACReaderOptionsDialog::saveZCoverOffset(int value)
{
settings->setValue(FLOW_TYPE_GL,Custom);
settings->setValue(Z_COVER_OFFSET,value);
}
void YACReaderOptionsDialog::saveCoverRotation(int value)
{
settings->setValue(FLOW_TYPE_GL,Custom);
settings->setValue(COVER_ROTATION,value);
}
void YACReaderOptionsDialog::saveFadeOutDist(int value)
{
settings->setValue(FLOW_TYPE_GL,Custom);
settings->setValue(FADE_OUT_DIST,value);
}
void YACReaderOptionsDialog::saveLightStrength(int value)
{
settings->setValue(FLOW_TYPE_GL,Custom);
settings->setValue(LIGHT_STRENGTH,value);
}
void YACReaderOptionsDialog::saveMaxAngle(int value)
{
settings->setValue(FLOW_TYPE_GL,Custom);
settings->setValue(MAX_ANGLE,value);
}
#endif
void YACReaderOptionsDialog::restoreOptions(QSettings * settings)
{
this->settings = settings;
//FLOW CONFIG
#ifndef NO_OPENGL
if(settings->contains(USE_OPEN_GL) && settings->value(USE_OPEN_GL).toInt() == Qt::Checked)
{
sw->setVisible(false);
gl->setVisible(true);
useGL->setChecked(true);
}
else
{
gl->setVisible(false);
sw->setVisible(true);
useGL->setChecked(false);
}
if(!settings->contains(FLOW_TYPE_GL))
{
setClassicConfig();
gl->radioClassic->setChecked(true);
gl->performanceSlider->setValue(1);
return;
}
if(settings->contains(V_SYNC) && settings->value(V_SYNC).toInt() == Qt::Checked)
gl->vSyncCheck->setChecked(true);
else
gl->vSyncCheck->setChecked(false);
gl->performanceSlider->setValue(settings->value(PERFORMANCE).toInt());
FlowType flowType;
switch(settings->value(FLOW_TYPE_GL).toInt())
{
case 0:
flowType = CoverFlowLike;
break;
case 1:
flowType = Strip;
break;
case 2:
flowType = StripOverlapped;
break;
case 3:
flowType = Modern;
break;
case 4:
flowType = Roulette;
break;
case 5:
flowType = Custom;
break;
default:
flowType = CoverFlowLike;
}
if(flowType == Custom)
{
loadConfig();
return;
}
if(flowType == CoverFlowLike)
{
setClassicConfig();
gl->radioClassic->setChecked(true);
return;
}
if(flowType == Strip)
{
setStripeConfig();
gl->radioStripe->setChecked(true);
return;
}
if(flowType == StripOverlapped)
{
setOverlappedStripeConfig();
gl->radioOver->setChecked(true);
return;
}
if(flowType == Modern)
{
setModernConfig();
gl->radionModern->setChecked(true);
return;
}
if(flowType == Roulette)
{
setRouletteConfig();
gl->radioDown->setChecked(true);
return;
}
//END FLOW CONFIG
#endif
}
void YACReaderOptionsDialog::restoreOptions()
{
restoreOptions(settings);
}
#ifndef NO_OPENGL
void YACReaderOptionsDialog::loadConfig()
{
gl->xRotation->setValue(settings->value(X_ROTATION).toInt());
gl->yPosition->setValue(settings->value(Y_POSITION).toInt());
gl->coverDistance->setValue(settings->value(COVER_DISTANCE).toInt());
gl->centralDistance->setValue(settings->value(CENTRAL_DISTANCE).toInt());
gl->zoomLevel->setValue(settings->value(ZOOM_LEVEL).toInt());
gl->yCoverOffset->setValue(settings->value(Y_COVER_OFFSET).toInt());
gl->zCoverOffset->setValue(settings->value(Z_COVER_OFFSET).toInt());
gl->coverRotation->setValue(settings->value(COVER_ROTATION).toInt());
gl->fadeOutDist->setValue(settings->value(FADE_OUT_DIST).toInt());
gl->lightStrength->setValue(settings->value(LIGHT_STRENGTH).toInt());
gl->maxAngle->setValue(settings->value(MAX_ANGLE).toInt());
}
#endif
void YACReaderOptionsDialog::setClassicConfigSW()
{
settings->setValue(FLOW_TYPE_SW,CoverFlowLike);
}
void YACReaderOptionsDialog::setStripeConfigSW()
{
settings->setValue(FLOW_TYPE_SW,Strip);
}
void YACReaderOptionsDialog::setOverlappedStripeConfigSW()
{
settings->setValue(FLOW_TYPE_SW,StripOverlapped);
}
#ifndef NO_OPENGL
void YACReaderOptionsDialog::setClassicConfig()
{
gl->setValues(presetYACReaderFlowClassicConfig);
saveFlowParameters();
settings->setValue(FLOW_TYPE_GL,CoverFlowLike);
}
void YACReaderOptionsDialog::setStripeConfig()
{
gl->setValues(presetYACReaderFlowStripeConfig);
saveFlowParameters();
settings->setValue(FLOW_TYPE_GL,Strip);
}
void YACReaderOptionsDialog::setOverlappedStripeConfig()
{
gl->setValues(presetYACReaderFlowOverlappedStripeConfig);
saveFlowParameters();
settings->setValue(FLOW_TYPE_GL,StripOverlapped);
}
void YACReaderOptionsDialog::setModernConfig()
{
gl->setValues(defaultYACReaderFlowConfig);
saveFlowParameters();
settings->setValue(FLOW_TYPE_GL,Modern);
}
void YACReaderOptionsDialog::setRouletteConfig()
{
gl->setValues(pressetYACReaderFlowDownConfig);
saveFlowParameters();
settings->setValue(FLOW_TYPE_GL,Roulette);
}
#endif

View File

@ -1,73 +1,73 @@
#ifndef YACREADER_OPTIONS_DIALOG_H
#define YACREADER_OPTIONS_DIALOG_H
#include <QDialog>
class YACReaderFlowConfigWidget;
#ifndef NO_OPENGL
class YACReaderGLFlowConfigWidget;
#endif
class QCheckBox;
class QPushButton;
class QSettings;
class QGroupBox;
class YACReaderOptionsDialog : public QDialog
{
Q_OBJECT
protected:
YACReaderFlowConfigWidget * sw;
#ifndef NO_OPENGL
YACReaderGLFlowConfigWidget * gl;
QCheckBox * useGL;
#endif
QPushButton * accept;
QPushButton * cancel;
QGroupBox * shortcutsBox;
QSettings * settings;
QSettings * previousSettings;
public:
YACReaderOptionsDialog(QWidget * parent);
public slots:
virtual void restoreOptions(QSettings * settings);
virtual void restoreOptions();
virtual void saveOptions();
protected slots:
#ifndef NO_OPENGL
virtual void savePerformance(int value);
virtual void saveUseVSync(int b);
virtual void saveUseGL(int b);
virtual void saveXRotation(int value);
virtual void saveYPosition(int value);
virtual void saveCoverDistance(int value);
virtual void saveCentralDistance(int value);
virtual void saveZoomLevel(int value);
virtual void saveYCoverOffset(int value);
virtual void saveZCoverOffset(int value);
virtual void saveCoverRotation(int value);
virtual void saveFadeOutDist(int value);
virtual void saveLightStrength(int value);
virtual void saveMaxAngle(int value);
virtual void loadConfig();
virtual void setClassicConfig();
virtual void setStripeConfig();
virtual void setOverlappedStripeConfig();
virtual void setModernConfig();
virtual void setRouletteConfig();
virtual void saveFlowParameters();
#endif
virtual void setClassicConfigSW();
virtual void setStripeConfigSW();
virtual void setOverlappedStripeConfigSW();
signals:
void optionsChanged();
void editShortcuts();
};
#endif // YACREADER_OPTIONS_DIALOG_H
#ifndef YACREADER_OPTIONS_DIALOG_H
#define YACREADER_OPTIONS_DIALOG_H
#include <QDialog>
class YACReaderFlowConfigWidget;
#ifndef NO_OPENGL
class YACReaderGLFlowConfigWidget;
#endif
class QCheckBox;
class QPushButton;
class QSettings;
class QGroupBox;
class YACReaderOptionsDialog : public QDialog
{
Q_OBJECT
protected:
YACReaderFlowConfigWidget * sw;
#ifndef NO_OPENGL
YACReaderGLFlowConfigWidget * gl;
QCheckBox * useGL;
#endif
QPushButton * accept;
QPushButton * cancel;
QGroupBox * shortcutsBox;
QSettings * settings;
QSettings * previousSettings;
public:
YACReaderOptionsDialog(QWidget * parent);
public slots:
virtual void restoreOptions(QSettings * settings);
virtual void restoreOptions();
virtual void saveOptions();
protected slots:
#ifndef NO_OPENGL
virtual void savePerformance(int value);
virtual void saveUseVSync(int b);
virtual void saveUseGL(int b);
virtual void saveXRotation(int value);
virtual void saveYPosition(int value);
virtual void saveCoverDistance(int value);
virtual void saveCentralDistance(int value);
virtual void saveZoomLevel(int value);
virtual void saveYCoverOffset(int value);
virtual void saveZCoverOffset(int value);
virtual void saveCoverRotation(int value);
virtual void saveFadeOutDist(int value);
virtual void saveLightStrength(int value);
virtual void saveMaxAngle(int value);
virtual void loadConfig();
virtual void setClassicConfig();
virtual void setStripeConfig();
virtual void setOverlappedStripeConfig();
virtual void setModernConfig();
virtual void setRouletteConfig();
virtual void saveFlowParameters();
#endif
virtual void setClassicConfigSW();
virtual void setStripeConfigSW();
virtual void setOverlappedStripeConfigSW();
signals:
void optionsChanged();
void editShortcuts();
};
#endif // YACREADER_OPTIONS_DIALOG_H

View File

@ -1,146 +1,146 @@
#include "yacreader_search_line_edit.h"
#include <QToolButton>
#include <QStyle>
#include <QLabel>
#include <QRegExpValidator>
#include "QsLog.h"
YACReaderSearchLineEdit::YACReaderSearchLineEdit(QWidget *parent)
: QLineEdit(parent)
{
clearButton = new QToolButton(this);
searchLabel = new QLabel(this);
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);
#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));
#else
setStyleSheet(QString("QLineEdit {color: #ABABAB; border:none; border-radius: 4px; background-color:#404040; padding-left: %1px; padding-right: %2px; padding-bottom: 1px; margin-right: 9px;} ").arg(searchLabel->sizeHint().width() + frameWidth + 6 + 5).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));
#ifdef Q_OS_MAC
setMaximumWidth(212);
#else
setMaximumWidth(173);
setFixedHeight(26);
#endif
setAttribute(Qt::WA_MacShowFocusRect,false);
setPlaceholderText(tr("type to search"));
//search modifiers
modifiers << "[read]" << "[unread]";//<< "[author]";
modifiersCompleter = new QCompleter(modifiers);
QString regExpString;
foreach(QString modifier, modifiers)
{
regExpString = regExpString + modifier.replace("[","\\[").replace("]","\\]") + ".*|";
}
regExpString = regExpString + "[^\\[].*";
QLOG_TRACE () << regExpString;
QRegExp regExp(regExpString);
QValidator *validator = new QRegExpValidator(regExp, this);
setValidator(validator);
setCompleter(modifiersCompleter);
connect(this,SIGNAL(textChanged(QString)),this,SLOT(processText(QString)));
}
void YACReaderSearchLineEdit::clearText()
{
disconnect(this,SIGNAL(textChanged(QString)),this,SLOT(processText(QString)));
clear();
connect(this,SIGNAL(textChanged(QString)),this,SLOT(processText(QString)));
}
//modifiers are not returned
const QString YACReaderSearchLineEdit::text()
{
QString text = QLineEdit::text();
QRegExp regExp("\\[.*\\]");
return text.remove(regExp).trimmed();
}
void YACReaderSearchLineEdit::resizeEvent(QResizeEvent *)
{
#ifdef Q_OS_MAC
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);
#else
QSize sz = clearButton->sizeHint();
int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
int marginRight = style()->pixelMetric(QStyle::PM_LayoutRightMargin);
clearButton->move(rect().right() - frameWidth - sz.width() - marginRight - 6,
(rect().bottom() + 2 - sz.height())/2);
QSize szl = searchLabel->sizeHint();
searchLabel->move(8,(rect().bottom() + 2 - szl.height())/2);
#endif
}
void YACReaderSearchLineEdit::updateCloseButton(const QString& text)
{
clearButton->setVisible(!text.isEmpty());
}
void YACReaderSearchLineEdit::processText(const QString &text)
{
QRegExp regExp("(\\[.*\\])(.*)");
if(text.startsWith("["))
{
if(regExp.exactMatch(text)) //avoid search while the modifiers are being written
{
QString modifier = regExp.cap(1);
QString searchText = regExp.cap(2).trimmed();
int indexOfModifier = modifiers.indexOf(modifier);
if(indexOfModifier != -1)
{
QLOG_TRACE() << "modifier : " << modifier << "text : " << searchText;
emit filterChanged(static_cast<YACReader::SearchModifiers>(indexOfModifier+1), searchText); //TODO, do not use on indexOF
}
else
{
QLOG_ERROR() << "invalid modifier : " << modifier;
}
}
QLOG_TRACE() << "full text :" << text << " : " << regExp.indexIn(text);
}
else
{
QLOG_TRACE() << "NoModifiers : " << text;
emit filterChanged(YACReader::NoModifiers,text);
}
}
#include "yacreader_search_line_edit.h"
#include <QToolButton>
#include <QStyle>
#include <QLabel>
#include <QRegExpValidator>
#include "QsLog.h"
YACReaderSearchLineEdit::YACReaderSearchLineEdit(QWidget *parent)
: QLineEdit(parent)
{
clearButton = new QToolButton(this);
searchLabel = new QLabel(this);
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);
#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));
#else
setStyleSheet(QString("QLineEdit {color: #ABABAB; border:none; border-radius: 4px; background-color:#404040; padding-left: %1px; padding-right: %2px; padding-bottom: 1px; margin-right: 9px;} ").arg(searchLabel->sizeHint().width() + frameWidth + 6 + 5).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));
#ifdef Q_OS_MAC
setMaximumWidth(212);
#else
setMaximumWidth(173);
setFixedHeight(26);
#endif
setAttribute(Qt::WA_MacShowFocusRect,false);
setPlaceholderText(tr("type to search"));
//search modifiers
modifiers << "[read]" << "[unread]";//<< "[author]";
modifiersCompleter = new QCompleter(modifiers);
QString regExpString;
foreach(QString modifier, modifiers)
{
regExpString = regExpString + modifier.replace("[","\\[").replace("]","\\]") + ".*|";
}
regExpString = regExpString + "[^\\[].*";
QLOG_TRACE () << regExpString;
QRegExp regExp(regExpString);
QValidator *validator = new QRegExpValidator(regExp, this);
setValidator(validator);
setCompleter(modifiersCompleter);
connect(this,SIGNAL(textChanged(QString)),this,SLOT(processText(QString)));
}
void YACReaderSearchLineEdit::clearText()
{
disconnect(this,SIGNAL(textChanged(QString)),this,SLOT(processText(QString)));
clear();
connect(this,SIGNAL(textChanged(QString)),this,SLOT(processText(QString)));
}
//modifiers are not returned
const QString YACReaderSearchLineEdit::text()
{
QString text = QLineEdit::text();
QRegExp regExp("\\[.*\\]");
return text.remove(regExp).trimmed();
}
void YACReaderSearchLineEdit::resizeEvent(QResizeEvent *)
{
#ifdef Q_OS_MAC
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);
#else
QSize sz = clearButton->sizeHint();
int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
int marginRight = style()->pixelMetric(QStyle::PM_LayoutRightMargin);
clearButton->move(rect().right() - frameWidth - sz.width() - marginRight - 6,
(rect().bottom() + 2 - sz.height())/2);
QSize szl = searchLabel->sizeHint();
searchLabel->move(8,(rect().bottom() + 2 - szl.height())/2);
#endif
}
void YACReaderSearchLineEdit::updateCloseButton(const QString& text)
{
clearButton->setVisible(!text.isEmpty());
}
void YACReaderSearchLineEdit::processText(const QString &text)
{
QRegExp regExp("(\\[.*\\])(.*)");
if(text.startsWith("["))
{
if(regExp.exactMatch(text)) //avoid search while the modifiers are being written
{
QString modifier = regExp.cap(1);
QString searchText = regExp.cap(2).trimmed();
int indexOfModifier = modifiers.indexOf(modifier);
if(indexOfModifier != -1)
{
QLOG_TRACE() << "modifier : " << modifier << "text : " << searchText;
emit filterChanged(static_cast<YACReader::SearchModifiers>(indexOfModifier+1), searchText); //TODO, do not use on indexOF
}
else
{
QLOG_ERROR() << "invalid modifier : " << modifier;
}
}
QLOG_TRACE() << "full text :" << text << " : " << regExp.indexIn(text);
}
else
{
QLOG_TRACE() << "NoModifiers : " << text;
emit filterChanged(YACReader::NoModifiers,text);
}
}

View File

@ -1,40 +1,40 @@
#ifndef YACREADER_SEARCH_LINE_EDIT_H
#define YACREADER_SEARCH_LINE_EDIT_H
#include <QLineEdit>
#include <QCompleter>
#include "yacreader_global.h"
class QToolButton;
class QLabel;
class YACReaderSearchLineEdit : public QLineEdit
{
Q_OBJECT
public:
YACReaderSearchLineEdit(QWidget *parent = 0);
void clearText(); //no signal emited;
const QString text();
protected:
void resizeEvent(QResizeEvent *);
signals:
void filterChanged(const YACReader::SearchModifiers, QString);
private slots:
void updateCloseButton(const QString &text);
void processText(const QString & text);
private:
QToolButton *clearButton;
QLabel * searchLabel;
QCompleter * modifiersCompleter;
QStringList modifiers;
};
#endif // YACREADER_SEARCH_LINE_EDIT_H
#ifndef YACREADER_SEARCH_LINE_EDIT_H
#define YACREADER_SEARCH_LINE_EDIT_H
#include <QLineEdit>
#include <QCompleter>
#include "yacreader_global.h"
class QToolButton;
class QLabel;
class YACReaderSearchLineEdit : public QLineEdit
{
Q_OBJECT
public:
YACReaderSearchLineEdit(QWidget *parent = 0);
void clearText(); //no signal emited;
const QString text();
protected:
void resizeEvent(QResizeEvent *);
signals:
void filterChanged(const YACReader::SearchModifiers, QString);
private slots:
void updateCloseButton(const QString &text);
void processText(const QString & text);
private:
QToolButton *clearButton;
QLabel * searchLabel;
QCompleter * modifiersCompleter;
QStringList modifiers;
};
#endif // YACREADER_SEARCH_LINE_EDIT_H

View File

@ -1,203 +1,203 @@
#include "yacreader_sidebar.h"
#include <QPainter>
#include <QLayout>
#include "yacreader_folders_view.h"
#include "yacreader_reading_lists_view.h"
#include "yacreader_library_list_widget.h"
#include "yacreader_search_line_edit.h"
#include "yacreader_titled_toolbar.h"
#include "yacreader_global_gui.h"
YACReaderSideBar::YACReaderSideBar(QWidget *parent) :
QWidget(parent)
{
setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Minimum);
settings = new QSettings(YACReader::getSettingsPath()+"/YACReaderLibrary.ini",QSettings::IniFormat); //TODO unificar la creación del fichero de config con el servidor
settings->beginGroup("libraryConfig");
//widgets
foldersView = new YACReaderFoldersView;
readingListsView = new YACReaderReadingListsView;
selectedLibrary = new YACReaderLibraryListWidget;
#ifdef Q_OS_MAC
librariesTitle = new YACReaderTitledToolBar(tr("Libraries"));
foldersTitle = new YACReaderTitledToolBar(tr("Folders"));
readingListsTitle = new YACReaderTitledToolBar(tr("Reading Lists"));
#else
librariesTitle = new YACReaderTitledToolBar(tr("LIBRARIES"));
foldersTitle = new YACReaderTitledToolBar(tr("FOLDERS"));
readingListsTitle = new YACReaderTitledToolBar(tr("READING LISTS"));
#endif
splitter = new QSplitter(this);
splitter->setOrientation(Qt::Vertical);
#ifndef Q_OS_MAC
splitter->setStyleSheet("QSplitter::handle { "
" image: none; background-color = black; "
" }"
"QSplitter::handle:vertical { height: 39px;}");
#else
splitter->setStyleSheet("QSplitter::handle:vertical { height: 26px; background-color: transparent;}");
#endif
selectedLibrary->setContextMenuPolicy(Qt::ActionsContextMenu);
selectedLibrary->setAttribute(Qt::WA_MacShowFocusRect,false);
selectedLibrary->setFocusPolicy(Qt::NoFocus);
//layout
QVBoxLayout * l = new QVBoxLayout;
l->setContentsMargins(0,0,0,0);
//LIBRARIES-------------------------------------------------------
#ifndef Q_OS_MAC
l->addSpacing(5);
#endif
l->addWidget(librariesTitle);
#ifndef Q_OS_MAC
l->addSpacing(4);
l->addWidget(new YACReaderSideBarSeparator(this));
l->addSpacing(3);
#endif
l->addWidget(selectedLibrary);
#ifndef Q_OS_MAC
l->addSpacing(11);
#else
l->addSpacing(6);
#endif
//END LIBRARIES---------------------------------------------------
//FOLDERS---------------------------------------------------------
QWidget * foldersContainer = new QWidget(this);
QVBoxLayout * foldersLayout = new QVBoxLayout;
foldersLayout->setContentsMargins(0,0,0,0);
foldersLayout->setSpacing(0);
#ifndef Q_OS_MAC
//foldersLayout->addSpacing(6);
//foldersLayout->addSpacing(5);
foldersLayout->addWidget(new YACReaderSideBarSeparator(this));
foldersLayout->addSpacing(4);
#else
//foldersLayout->addSpacing(6);
#endif
foldersLayout->addWidget(foldersTitle);
#ifndef Q_OS_MAC
foldersLayout->addSpacing(4);
foldersLayout->addWidget(new YACReaderSideBarSeparator(this));
foldersLayout->addSpacing(4);
#endif
foldersLayout->addWidget(foldersView);
foldersLayout->addSpacing(6);
foldersContainer->setLayout(foldersLayout);
splitter->addWidget(foldersContainer);
//END FOLDERS------------------------------------------------------
//READING LISTS----------------------------------------------------
splitter->addWidget(readingListsView);
QVBoxLayout * readingListsHeaderLayout = new QVBoxLayout;
readingListsHeaderLayout->setContentsMargins(0,0,0,0);
readingListsHeaderLayout->setSpacing(0);
#ifndef Q_OS_MAC
//readingListsHeaderLayout->addSpacing(6);
//readingListsHeaderLayout->addSpacing(5);
readingListsHeaderLayout->addWidget(new YACReaderSideBarSeparator(this));
readingListsHeaderLayout->addSpacing(4);
#else
//readingListsHeaderLayout->addSpacing(6);
#endif
readingListsHeaderLayout->addWidget(readingListsTitle);
#ifndef Q_OS_MAC
readingListsHeaderLayout->addSpacing(4);
readingListsHeaderLayout->addWidget(new YACReaderSideBarSeparator(this));
readingListsHeaderLayout->addSpacing(4);
#endif
//readingListsLayout->addWidget(readingListsView);
readingListsHeaderLayout->addStretch();
QSplitterHandle * handle = splitter->handle(1);
//handle->setCursor(QCursor(Qt::ArrowCursor));
handle->setLayout(readingListsHeaderLayout);
//END READING LISTS------------------------------------------------
l->addWidget(splitter);
l->setSpacing(0);
setLayout(l);
if(settings->contains(SIDEBAR_SPLITTER_STATUS))
splitter->restoreState(settings->value(SIDEBAR_SPLITTER_STATUS).toByteArray());
}
void YACReaderSideBar::paintEvent(QPaintEvent * event)
{
Q_UNUSED(event)
#ifdef Q_OS_MAC
QPainter painter(this);
painter.fillRect(0,0,width(),height(),QColor("#F1F1F1"));
#else
QPainter painter(this);
painter.fillRect(0,0,width(),height(),QColor("#454545"));
//QWidget::paintEvent(event);
#endif
//QPixmap shadow(":/images/side_bar/shadow.png");
//painter.drawPixmap(width()-shadow.width(),0,shadow.width(),height(),shadow);
// painter.setRenderHint(QPainter::Antialiasing);
// painter.drawLine(rect().topLeft(), rect().bottomRight());
//QWidget::paintEvent(event);
}
void YACReaderSideBar::closeEvent(QCloseEvent *event)
{
QWidget::closeEvent(event);
settings->setValue(SIDEBAR_SPLITTER_STATUS, splitter->saveState());
}
QSize YACReaderSideBar::sizeHint() const
{
return QSize(275,200);
}
YACReaderSideBarSeparator::YACReaderSideBarSeparator(QWidget *parent)
:QWidget(parent)
{
setFixedHeight(1);
}
void YACReaderSideBarSeparator::paintEvent(QPaintEvent * event)
{
Q_UNUSED(event)
QPainter painter(this);
painter.fillRect(5,0,width()-10,height(),QColor("#575757"));
}
#include "yacreader_sidebar.h"
#include <QPainter>
#include <QLayout>
#include "yacreader_folders_view.h"
#include "yacreader_reading_lists_view.h"
#include "yacreader_library_list_widget.h"
#include "yacreader_search_line_edit.h"
#include "yacreader_titled_toolbar.h"
#include "yacreader_global_gui.h"
YACReaderSideBar::YACReaderSideBar(QWidget *parent) :
QWidget(parent)
{
setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Minimum);
settings = new QSettings(YACReader::getSettingsPath()+"/YACReaderLibrary.ini",QSettings::IniFormat); //TODO unificar la creación del fichero de config con el servidor
settings->beginGroup("libraryConfig");
//widgets
foldersView = new YACReaderFoldersView;
readingListsView = new YACReaderReadingListsView;
selectedLibrary = new YACReaderLibraryListWidget;
#ifdef Q_OS_MAC
librariesTitle = new YACReaderTitledToolBar(tr("Libraries"));
foldersTitle = new YACReaderTitledToolBar(tr("Folders"));
readingListsTitle = new YACReaderTitledToolBar(tr("Reading Lists"));
#else
librariesTitle = new YACReaderTitledToolBar(tr("LIBRARIES"));
foldersTitle = new YACReaderTitledToolBar(tr("FOLDERS"));
readingListsTitle = new YACReaderTitledToolBar(tr("READING LISTS"));
#endif
splitter = new QSplitter(this);
splitter->setOrientation(Qt::Vertical);
#ifndef Q_OS_MAC
splitter->setStyleSheet("QSplitter::handle { "
" image: none; background-color = black; "
" }"
"QSplitter::handle:vertical { height: 39px;}");
#else
splitter->setStyleSheet("QSplitter::handle:vertical { height: 26px; background-color: transparent;}");
#endif
selectedLibrary->setContextMenuPolicy(Qt::ActionsContextMenu);
selectedLibrary->setAttribute(Qt::WA_MacShowFocusRect,false);
selectedLibrary->setFocusPolicy(Qt::NoFocus);
//layout
QVBoxLayout * l = new QVBoxLayout;
l->setContentsMargins(0,0,0,0);
//LIBRARIES-------------------------------------------------------
#ifndef Q_OS_MAC
l->addSpacing(5);
#endif
l->addWidget(librariesTitle);
#ifndef Q_OS_MAC
l->addSpacing(4);
l->addWidget(new YACReaderSideBarSeparator(this));
l->addSpacing(3);
#endif
l->addWidget(selectedLibrary);
#ifndef Q_OS_MAC
l->addSpacing(11);
#else
l->addSpacing(6);
#endif
//END LIBRARIES---------------------------------------------------
//FOLDERS---------------------------------------------------------
QWidget * foldersContainer = new QWidget(this);
QVBoxLayout * foldersLayout = new QVBoxLayout;
foldersLayout->setContentsMargins(0,0,0,0);
foldersLayout->setSpacing(0);
#ifndef Q_OS_MAC
//foldersLayout->addSpacing(6);
//foldersLayout->addSpacing(5);
foldersLayout->addWidget(new YACReaderSideBarSeparator(this));
foldersLayout->addSpacing(4);
#else
//foldersLayout->addSpacing(6);
#endif
foldersLayout->addWidget(foldersTitle);
#ifndef Q_OS_MAC
foldersLayout->addSpacing(4);
foldersLayout->addWidget(new YACReaderSideBarSeparator(this));
foldersLayout->addSpacing(4);
#endif
foldersLayout->addWidget(foldersView);
foldersLayout->addSpacing(6);
foldersContainer->setLayout(foldersLayout);
splitter->addWidget(foldersContainer);
//END FOLDERS------------------------------------------------------
//READING LISTS----------------------------------------------------
splitter->addWidget(readingListsView);
QVBoxLayout * readingListsHeaderLayout = new QVBoxLayout;
readingListsHeaderLayout->setContentsMargins(0,0,0,0);
readingListsHeaderLayout->setSpacing(0);
#ifndef Q_OS_MAC
//readingListsHeaderLayout->addSpacing(6);
//readingListsHeaderLayout->addSpacing(5);
readingListsHeaderLayout->addWidget(new YACReaderSideBarSeparator(this));
readingListsHeaderLayout->addSpacing(4);
#else
//readingListsHeaderLayout->addSpacing(6);
#endif
readingListsHeaderLayout->addWidget(readingListsTitle);
#ifndef Q_OS_MAC
readingListsHeaderLayout->addSpacing(4);
readingListsHeaderLayout->addWidget(new YACReaderSideBarSeparator(this));
readingListsHeaderLayout->addSpacing(4);
#endif
//readingListsLayout->addWidget(readingListsView);
readingListsHeaderLayout->addStretch();
QSplitterHandle * handle = splitter->handle(1);
//handle->setCursor(QCursor(Qt::ArrowCursor));
handle->setLayout(readingListsHeaderLayout);
//END READING LISTS------------------------------------------------
l->addWidget(splitter);
l->setSpacing(0);
setLayout(l);
if(settings->contains(SIDEBAR_SPLITTER_STATUS))
splitter->restoreState(settings->value(SIDEBAR_SPLITTER_STATUS).toByteArray());
}
void YACReaderSideBar::paintEvent(QPaintEvent * event)
{
Q_UNUSED(event)
#ifdef Q_OS_MAC
QPainter painter(this);
painter.fillRect(0,0,width(),height(),QColor("#F1F1F1"));
#else
QPainter painter(this);
painter.fillRect(0,0,width(),height(),QColor("#454545"));
//QWidget::paintEvent(event);
#endif
//QPixmap shadow(":/images/side_bar/shadow.png");
//painter.drawPixmap(width()-shadow.width(),0,shadow.width(),height(),shadow);
// painter.setRenderHint(QPainter::Antialiasing);
// painter.drawLine(rect().topLeft(), rect().bottomRight());
//QWidget::paintEvent(event);
}
void YACReaderSideBar::closeEvent(QCloseEvent *event)
{
QWidget::closeEvent(event);
settings->setValue(SIDEBAR_SPLITTER_STATUS, splitter->saveState());
}
QSize YACReaderSideBar::sizeHint() const
{
return QSize(275,200);
}
YACReaderSideBarSeparator::YACReaderSideBarSeparator(QWidget *parent)
:QWidget(parent)
{
setFixedHeight(1);
}
void YACReaderSideBarSeparator::paintEvent(QPaintEvent * event)
{
Q_UNUSED(event)
QPainter painter(this);
painter.fillRect(5,0,width()-10,height(),QColor("#575757"));
}

View File

@ -1,47 +1,47 @@
#ifndef YACREADER_SIDEBAR_H
#define YACREADER_SIDEBAR_H
#include <QtWidgets>
class YACReaderFoldersView;
class YACReaderLibraryListWidget;
class YACReaderSearchLineEdit;
class YACReaderTitledToolBar;
class YACReaderTitledToolBar;
class YACReaderReadingListsView;
class YACReaderSideBarSeparator : public QWidget
{
public:
explicit YACReaderSideBarSeparator(QWidget * parent = 0);
protected:
void paintEvent(QPaintEvent *event);
};
class YACReaderSideBar : public QWidget
{
Q_OBJECT
public:
explicit YACReaderSideBar(QWidget *parent = 0);
QSize sizeHint() const;
YACReaderFoldersView * foldersView;
YACReaderReadingListsView * readingListsView;
YACReaderLibraryListWidget * selectedLibrary;
YACReaderTitledToolBar * librariesTitle;
YACReaderTitledToolBar * foldersTitle;
YACReaderTitledToolBar * readingListsTitle;
signals:
public slots:
protected:
void paintEvent(QPaintEvent *);
void closeEvent ( QCloseEvent * event );
QSettings * settings;
QSplitter * splitter;
};
#endif // YACREADER_SIDEBAR_H
#ifndef YACREADER_SIDEBAR_H
#define YACREADER_SIDEBAR_H
#include <QtWidgets>
class YACReaderFoldersView;
class YACReaderLibraryListWidget;
class YACReaderSearchLineEdit;
class YACReaderTitledToolBar;
class YACReaderTitledToolBar;
class YACReaderReadingListsView;
class YACReaderSideBarSeparator : public QWidget
{
public:
explicit YACReaderSideBarSeparator(QWidget * parent = 0);
protected:
void paintEvent(QPaintEvent *event);
};
class YACReaderSideBar : public QWidget
{
Q_OBJECT
public:
explicit YACReaderSideBar(QWidget *parent = 0);
QSize sizeHint() const;
YACReaderFoldersView * foldersView;
YACReaderReadingListsView * readingListsView;
YACReaderLibraryListWidget * selectedLibrary;
YACReaderTitledToolBar * librariesTitle;
YACReaderTitledToolBar * foldersTitle;
YACReaderTitledToolBar * readingListsTitle;
signals:
public slots:
protected:
void paintEvent(QPaintEvent *);
void closeEvent ( QCloseEvent * event );
QSettings * settings;
QSplitter * splitter;
};
#endif // YACREADER_SIDEBAR_H

View File

@ -1,130 +1,130 @@
#include "yacreader_social_dialog.h"
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QProgressBar>
#include <QPushButton>
#include <QLabel>
#include <QPainter>
#include <QToolButton>
#include <QPlainTextEdit>
#include <QGraphicsDropShadowEffect>
#include "comic_db.h"
YACReaderSocialDialog::YACReaderSocialDialog(QWidget *parent) :
QWidget(parent)
{
//setWindowFlags(Qt::Window | Qt::Dialog | Qt::FramelessWindowHint);
//setModal(true);
QToolButton * close = new QToolButton(this);
close->setIcon(QIcon(":/images/social_dialog/close.png"));
QToolButton * facebook = new QToolButton(this);
facebook->setIcon(QIcon(":/images/social_dialog/facebook.png"));
QToolButton * twitter = new QToolButton(this);
twitter->setIcon(QIcon(":/images/social_dialog/twitter.png"));
QToolButton * google = new QToolButton(this);
google->setIcon(QIcon(":/images/social_dialog/google+.png"));
QString styleSheet = "QToolButton {border:none; }";
close->setStyleSheet(styleSheet);
facebook->setStyleSheet(styleSheet);
twitter->setStyleSheet(styleSheet);
google->setStyleSheet(styleSheet);
QLabel * icon = new QLabel(this);
icon->setPixmap(QPixmap(":/images/social_dialog/icon.png"));
plainText = new QTextEdit (this);
plainText->setStyleSheet("QTextEdit {border:none; padding:11px; font-size:12px; font-weight:bold; color:#525757;}");
QTextCursor cursor(plainText->textCursor());
QTextBlockFormat blockFormat = cursor.blockFormat();
blockFormat.setLineHeight(12,QTextBlockFormat::SingleHeight);
cursor.setBlockFormat(blockFormat);
QLabel * sendTo = new QLabel(tr("send to:"),this);
sendTo->setStyleSheet("QLabel{color:#ABABAB; font-size:12px; font-weight:bold;}");
setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
resize( sizeHint() );
close->move(437,5);
QWidget * send = new QWidget(this);
QHBoxLayout * sendLayout = new QHBoxLayout;
QPushButton * follow = new QPushButton(tr("Follow YACReader!"),this);
follow->setStyleSheet("QPushButton{border:none; color:#FFFFFF;background:#404040; padding: 9px 25px 9px 25px; font-weight:bold; font-size:12px;}"
"QPushButton:hover{background:#E3B800;}");
sendLayout->setMargin(0);
sendLayout->setSpacing(0);
sendLayout->addWidget(sendTo,1,Qt::AlignHCenter);
sendLayout->addSpacing(11);
sendLayout->addWidget(facebook,0,Qt::AlignHCenter);
sendLayout->addSpacing(6);
sendLayout->addWidget(twitter,0,Qt::AlignHCenter);
sendLayout->addSpacing(6);
sendLayout->addWidget(google,0,Qt::AlignHCenter);
send->setLayout(sendLayout);
send->move(317,259);
icon->move(279,14);
plainText->setFixedSize(291,155);
plainText->move(169,96);
follow->move(230,307);
connect(close,SIGNAL(released()),this,SLOT(close()));
}
void YACReaderSocialDialog::paintEvent(QPaintEvent * event)
{
QPainter painter(this);
//center
painter.fillRect(169,0,291,369,QColor("#F0F0F0"));
painter.fillRect(169,96,291,155,QColor("#FFFFFF"));
//QPixmap cover = QPixmap("c:/temp/6.jpg").scaledToHeight(369,Qt::SmoothTransformation);
painter.drawPixmap(0,0,169,369,cover,0,0, (169 * cover.height())/369 ,cover.height());
QPixmap shadow(":/images/social_dialog/shadow.png");
painter.drawPixmap(169-shadow.width(),0,shadow.width(),369,shadow);
QPixmap separtor(":/images/social_dialog/separator.png");
painter.drawPixmap(169,96-separtor.height(),separtor);
QPen pen("#C3CAD6");
painter.setPen(pen);
painter.drawLine(169,251,460,251);
QWidget::paintEvent(event);
}
QSize YACReaderSocialDialog::sizeHint() const
{
return QSize(460,369);
}
void YACReaderSocialDialog::setComic(ComicDB & comic, QString & basePath)
{
this->cover = comic.info.getCover(basePath).scaledToHeight(369,Qt::SmoothTransformation);
plainText->setText(tr("I am reading %1 using YACReader.").arg(comic.path.split('/').last()));
#include "yacreader_social_dialog.h"
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QProgressBar>
#include <QPushButton>
#include <QLabel>
#include <QPainter>
#include <QToolButton>
#include <QPlainTextEdit>
#include <QGraphicsDropShadowEffect>
#include "comic_db.h"
YACReaderSocialDialog::YACReaderSocialDialog(QWidget *parent) :
QWidget(parent)
{
//setWindowFlags(Qt::Window | Qt::Dialog | Qt::FramelessWindowHint);
//setModal(true);
QToolButton * close = new QToolButton(this);
close->setIcon(QIcon(":/images/social_dialog/close.png"));
QToolButton * facebook = new QToolButton(this);
facebook->setIcon(QIcon(":/images/social_dialog/facebook.png"));
QToolButton * twitter = new QToolButton(this);
twitter->setIcon(QIcon(":/images/social_dialog/twitter.png"));
QToolButton * google = new QToolButton(this);
google->setIcon(QIcon(":/images/social_dialog/google+.png"));
QString styleSheet = "QToolButton {border:none; }";
close->setStyleSheet(styleSheet);
facebook->setStyleSheet(styleSheet);
twitter->setStyleSheet(styleSheet);
google->setStyleSheet(styleSheet);
QLabel * icon = new QLabel(this);
icon->setPixmap(QPixmap(":/images/social_dialog/icon.png"));
plainText = new QTextEdit (this);
plainText->setStyleSheet("QTextEdit {border:none; padding:11px; font-size:12px; font-weight:bold; color:#525757;}");
QTextCursor cursor(plainText->textCursor());
QTextBlockFormat blockFormat = cursor.blockFormat();
blockFormat.setLineHeight(12,QTextBlockFormat::SingleHeight);
cursor.setBlockFormat(blockFormat);
QLabel * sendTo = new QLabel(tr("send to:"),this);
sendTo->setStyleSheet("QLabel{color:#ABABAB; font-size:12px; font-weight:bold;}");
setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
resize( sizeHint() );
close->move(437,5);
QWidget * send = new QWidget(this);
QHBoxLayout * sendLayout = new QHBoxLayout;
QPushButton * follow = new QPushButton(tr("Follow YACReader!"),this);
follow->setStyleSheet("QPushButton{border:none; color:#FFFFFF;background:#404040; padding: 9px 25px 9px 25px; font-weight:bold; font-size:12px;}"
"QPushButton:hover{background:#E3B800;}");
sendLayout->setMargin(0);
sendLayout->setSpacing(0);
sendLayout->addWidget(sendTo,1,Qt::AlignHCenter);
sendLayout->addSpacing(11);
sendLayout->addWidget(facebook,0,Qt::AlignHCenter);
sendLayout->addSpacing(6);
sendLayout->addWidget(twitter,0,Qt::AlignHCenter);
sendLayout->addSpacing(6);
sendLayout->addWidget(google,0,Qt::AlignHCenter);
send->setLayout(sendLayout);
send->move(317,259);
icon->move(279,14);
plainText->setFixedSize(291,155);
plainText->move(169,96);
follow->move(230,307);
connect(close,SIGNAL(released()),this,SLOT(close()));
}
void YACReaderSocialDialog::paintEvent(QPaintEvent * event)
{
QPainter painter(this);
//center
painter.fillRect(169,0,291,369,QColor("#F0F0F0"));
painter.fillRect(169,96,291,155,QColor("#FFFFFF"));
//QPixmap cover = QPixmap("c:/temp/6.jpg").scaledToHeight(369,Qt::SmoothTransformation);
painter.drawPixmap(0,0,169,369,cover,0,0, (169 * cover.height())/369 ,cover.height());
QPixmap shadow(":/images/social_dialog/shadow.png");
painter.drawPixmap(169-shadow.width(),0,shadow.width(),369,shadow);
QPixmap separtor(":/images/social_dialog/separator.png");
painter.drawPixmap(169,96-separtor.height(),separtor);
QPen pen("#C3CAD6");
painter.setPen(pen);
painter.drawLine(169,251,460,251);
QWidget::paintEvent(event);
}
QSize YACReaderSocialDialog::sizeHint() const
{
return QSize(460,369);
}
void YACReaderSocialDialog::setComic(ComicDB & comic, QString & basePath)
{
this->cover = comic.info.getCover(basePath).scaledToHeight(369,Qt::SmoothTransformation);
plainText->setText(tr("I am reading %1 using YACReader.").arg(comic.path.split('/').last()));
}

View File

@ -1,28 +1,28 @@
#ifndef YACREADER_SOCIAL_DIALOG_H
#define YACREADER_SOCIAL_DIALOG_H
#include <QWidget>
class QPixmap;
class QTextEdit;
class ComicDB;
class YACReaderSocialDialog : public QWidget
{
Q_OBJECT
public:
explicit YACReaderSocialDialog(QWidget *parent = 0);
QSize sizeHint() const;
signals:
public slots:
void setComic(ComicDB & comic,QString & basePath);
protected:
void paintEvent(QPaintEvent *);
private:
QPixmap cover;
QTextEdit * plainText;
};
#endif // YACREADER_SOCIAL_DIALOG_H
#ifndef YACREADER_SOCIAL_DIALOG_H
#define YACREADER_SOCIAL_DIALOG_H
#include <QWidget>
class QPixmap;
class QTextEdit;
class ComicDB;
class YACReaderSocialDialog : public QWidget
{
Q_OBJECT
public:
explicit YACReaderSocialDialog(QWidget *parent = 0);
QSize sizeHint() const;
signals:
public slots:
void setComic(ComicDB & comic,QString & basePath);
protected:
void paintEvent(QPaintEvent *);
private:
QPixmap cover;
QTextEdit * plainText;
};
#endif // YACREADER_SOCIAL_DIALOG_H

View File

@ -1,93 +1,93 @@
#include "yacreader_spin_slider_widget.h"
#include <QHBoxLayout>
#include <QLabel>
#include <QSpinBox>
#include <QSlider>
YACReaderSpinSliderWidget::YACReaderSpinSliderWidget(QWidget * parent,bool strechableSlider)
:QWidget(parent),tracking(true)
{
QHBoxLayout * layout = new QHBoxLayout;
layout->addWidget(label = new QLabel(this),1);
if(!strechableSlider)
layout->addStretch();
spinBox = new QSpinBox(this);
layout->addWidget(spinBox);
slider = new QSlider(Qt::Horizontal,this);
layout->addWidget(slider);
if(strechableSlider)
{
layout->setStretchFactor(slider,0.85);
layout->setStretchFactor(spinBox,0);
layout->setStretchFactor(label,0.15);
}
connect(spinBox, SIGNAL(valueChanged(int)), slider, SLOT(setValue(int)));
connect(slider, SIGNAL(valueChanged(int)), spinBox, SLOT(setValue(int)));
connect(slider, SIGNAL(valueChanged(int)), this, SLOT(valueWillChange(int)));
connect(spinBox, SIGNAL(valueChanged(int)), this, SLOT(valueWillChangeFromSpinBox(int)));
connect(slider, SIGNAL(sliderReleased()), this, SLOT(sliderRelease()));
setLayout(layout);
}
void YACReaderSpinSliderWidget::valueWillChange(int v)
{
Q_UNUSED(v)
if(tracking)
emit valueChanged(spinBox->value());
}
void YACReaderSpinSliderWidget::valueWillChangeFromSpinBox(int v)
{
Q_UNUSED(v)
if(!tracking && !slider->isSliderDown())
emit valueChanged(spinBox->value());
}
void YACReaderSpinSliderWidget::sliderRelease()
{
if(!tracking)
emit valueChanged(spinBox->value());
}
void YACReaderSpinSliderWidget::setRange(int lowValue, int topValue, int step)
{
spinBox->setMinimum(lowValue);
spinBox->setMaximum(topValue);
spinBox->setSingleStep(step);
slider->setMinimum(lowValue);
slider->setMaximum(topValue);
slider->setSingleStep(step);
}
void YACReaderSpinSliderWidget::setValue(int value)
{
disconnect(spinBox, SIGNAL(valueChanged(int)), this, SLOT(valueWillChange(int)));
spinBox->setValue(value);
connect(spinBox, SIGNAL(valueChanged(int)), this, SLOT(valueWillChange(int)));
}
void YACReaderSpinSliderWidget::setText(const QString & text)
{
label->setText(text);
}
int YACReaderSpinSliderWidget::getValue()
{
return spinBox->value();
}
QSize YACReaderSpinSliderWidget::minimumSizeHint() const
{
return QSize(270, 25);
}
void YACReaderSpinSliderWidget::setTracking(bool b)
{
tracking = b;
//slider->setTracking(b);
}
#include "yacreader_spin_slider_widget.h"
#include <QHBoxLayout>
#include <QLabel>
#include <QSpinBox>
#include <QSlider>
YACReaderSpinSliderWidget::YACReaderSpinSliderWidget(QWidget * parent,bool strechableSlider)
:QWidget(parent),tracking(true)
{
QHBoxLayout * layout = new QHBoxLayout;
layout->addWidget(label = new QLabel(this),1);
if(!strechableSlider)
layout->addStretch();
spinBox = new QSpinBox(this);
layout->addWidget(spinBox);
slider = new QSlider(Qt::Horizontal,this);
layout->addWidget(slider);
if(strechableSlider)
{
layout->setStretchFactor(slider,0.85);
layout->setStretchFactor(spinBox,0);
layout->setStretchFactor(label,0.15);
}
connect(spinBox, SIGNAL(valueChanged(int)), slider, SLOT(setValue(int)));
connect(slider, SIGNAL(valueChanged(int)), spinBox, SLOT(setValue(int)));
connect(slider, SIGNAL(valueChanged(int)), this, SLOT(valueWillChange(int)));
connect(spinBox, SIGNAL(valueChanged(int)), this, SLOT(valueWillChangeFromSpinBox(int)));
connect(slider, SIGNAL(sliderReleased()), this, SLOT(sliderRelease()));
setLayout(layout);
}
void YACReaderSpinSliderWidget::valueWillChange(int v)
{
Q_UNUSED(v)
if(tracking)
emit valueChanged(spinBox->value());
}
void YACReaderSpinSliderWidget::valueWillChangeFromSpinBox(int v)
{
Q_UNUSED(v)
if(!tracking && !slider->isSliderDown())
emit valueChanged(spinBox->value());
}
void YACReaderSpinSliderWidget::sliderRelease()
{
if(!tracking)
emit valueChanged(spinBox->value());
}
void YACReaderSpinSliderWidget::setRange(int lowValue, int topValue, int step)
{
spinBox->setMinimum(lowValue);
spinBox->setMaximum(topValue);
spinBox->setSingleStep(step);
slider->setMinimum(lowValue);
slider->setMaximum(topValue);
slider->setSingleStep(step);
}
void YACReaderSpinSliderWidget::setValue(int value)
{
disconnect(spinBox, SIGNAL(valueChanged(int)), this, SLOT(valueWillChange(int)));
spinBox->setValue(value);
connect(spinBox, SIGNAL(valueChanged(int)), this, SLOT(valueWillChange(int)));
}
void YACReaderSpinSliderWidget::setText(const QString & text)
{
label->setText(text);
}
int YACReaderSpinSliderWidget::getValue()
{
return spinBox->value();
}
QSize YACReaderSpinSliderWidget::minimumSizeHint() const
{
return QSize(270, 25);
}
void YACReaderSpinSliderWidget::setTracking(bool b)
{
tracking = b;
//slider->setTracking(b);
}

View File

@ -1,35 +1,35 @@
#ifndef YACREADER_SPIN_SLIDER_WIDGET_H
#define YACREADER_SPIN_SLIDER_WIDGET_H
#include <QWidget>
class QLabel;
class QSpinBox;
class QSlider;
class YACReaderSpinSliderWidget : public QWidget
{
Q_OBJECT
private:
QLabel * label;
QSpinBox * spinBox;
QSlider * slider;
bool tracking;
public:
YACReaderSpinSliderWidget(QWidget * parent = 0,bool strechableSlider = false);
public slots:
void setRange(int lowValue, int topValue, int step=1);
void setValue(int value);
void setText(const QString & text);
int getValue();
QSize minimumSizeHint() const;
void setTracking(bool b);
void valueWillChange(int);
void valueWillChangeFromSpinBox(int);
void sliderRelease();
signals:
void valueChanged(int);
};
#ifndef YACREADER_SPIN_SLIDER_WIDGET_H
#define YACREADER_SPIN_SLIDER_WIDGET_H
#include <QWidget>
class QLabel;
class QSpinBox;
class QSlider;
class YACReaderSpinSliderWidget : public QWidget
{
Q_OBJECT
private:
QLabel * label;
QSpinBox * spinBox;
QSlider * slider;
bool tracking;
public:
YACReaderSpinSliderWidget(QWidget * parent = 0,bool strechableSlider = false);
public slots:
void setRange(int lowValue, int topValue, int step=1);
void setValue(int value);
void setText(const QString & text);
int getValue();
QSize minimumSizeHint() const;
void setTracking(bool b);
void valueWillChange(int);
void valueWillChangeFromSpinBox(int);
void sliderRelease();
signals:
void valueChanged(int);
};
#endif // YACREADER_SPIN_SLIDER_WIDGET_H

View File

@ -1,488 +1,488 @@
#include "yacreader_table_view.h"
#include <QHeaderView>
#include <QResizeEvent>
#include <QPropertyAnimation>
#include <QPainter>
#include <QDrag>
#include <QMimeData>
#include <QApplication>
#include <QBuffer>
#include <qmath.h>
#include "QsLog.h"
#include "comic_item.h"
YACReaderTableView::YACReaderTableView(QWidget *parent) :
QTableView(parent),showDelete(false),editing(false),myeditor(0)
{
setAlternatingRowColors(true);
verticalHeader()->setAlternatingRowColors(true);
setStyleSheet("QTableView {alternate-background-color: #F2F2F2;background-color: #FAFAFA; outline: 0px;}"// border: 1px solid #999999; border-right:none; border-bottom:none;}"
"QTableCornerButton::section {background-color:#F5F5F5; border:none; border-bottom:1px solid #B8BDC4; border-right:1px solid qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #D1D1D1, stop: 1 #B8BDC4);}"
"QTableView::item {outline: 0px; border-bottom: 1px solid #DFDFDF;border-top: 1px solid #FEFEFE; padding-bottom:1px; color:#252626;}"
"QTableView {border-top:1px solid #B8B8B8;border-bottom:none;border-left:1px solid #B8B8B8;border-right:none;}"
#ifdef Q_OS_MAC
"QTableView {border-top:1px solid #B8B8B8;border-bottom:none;border-left:none;border-right:none;}"
"QTableView::item:selected {outline: 0px; border-bottom: 1px solid #3875D7;border-top: 1px solid #3875D7; padding-bottom:1px; background-color: #3875D7; color: #FFFFFF; }"
#else
"QTableView::item:selected {outline: 0px; border-bottom: 1px solid #D4D4D4;border-top: 1px solid #D4D4D4; padding-bottom:1px; background-color: #D4D4D4; }"
#endif
"QHeaderView::section:horizontal {background-color:#F5F5F5; border-bottom:1px solid #B8BDC4; border-right:1px solid qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #D1D1D1, stop: 1 #B8BDC4); border-left:none; border-top:none; padding:4px; color:#313232;}"
"QHeaderView::section:vertical {border-bottom: 1px solid #DFDFDF;border-top: 1px solid #FEFEFE;}"
//"QTableView::item:hover {border-bottom: 1px solid #A3A3A3;border-top: 1px solid #A3A3A3; padding-bottom:1px; background-color: #A3A3A3; color: #FFFFFF; }"
"");
//comicView->setItemDelegate(new YACReaderComicViewDelegate());
setContextMenuPolicy(Qt::ActionsContextMenu);
setShowGrid(false);
#if QT_VERSION >= 0x050000
verticalHeader()->setSectionResizeMode(QHeaderView::Fixed);
#else
verticalHeader()->setResizeMode(QHeaderView::Fixed);
#endif
//comicView->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
horizontalHeader()->setStretchLastSection(true);
#if QT_VERSION >= 0x050000
horizontalHeader()->setSectionsClickable(false);
#else
horizontalHeader()->setClickable(false);
#endif
//comicView->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents);
verticalHeader()->setDefaultSectionSize(24);
#if QT_VERSION >= 0x050000
verticalHeader()->setSectionsClickable(false); //TODO comportamiento anómalo
#else
verticalHeader()->setClickable(false); //TODO comportamiento anómalo
#endif
setCornerButtonEnabled(false);
setSelectionBehavior(QAbstractItemView::SelectRows);
setSelectionMode(QAbstractItemView::ExtendedSelection);
setItemDelegateForColumn(11,new YACReaderRatingDelegate(this));
setEditTriggers(QAbstractItemView::NoEditTriggers);
setMouseTracking(true);
/*deletingProgress = new YACReaderDeletingProgress(this);
showDeletingProgressAnimation = new QPropertyAnimation(deletingProgress,"pos");
showDeletingProgressAnimation->setDuration(150);*/
//drag: if the default drag is enabled there is no way for setting a custom image
//TODO report bug/suggestion
//setDragEnabled(true);
//setDragDropMode(QAbstractItemView::DragDrop);
setAcceptDrops(true);
}
void YACReaderTableView::mouseMoveEvent(QMouseEvent *event)
{
QModelIndex mi = indexAt(event->pos());
if(mi.isValid())
{
QList<QModelIndex> selectedIndexes = this->selectedIndexes();
if(selectedIndexes.contains(mi))
{
if(mi.column() == 11)
{
if(!editing)
{
editing = true;
currentIndexEditing = mi;
edit(mi);
myeditor = indexWidget(mi);
}
else if(mi.row() != currentIndexEditing.row())
closeRatingEditor();
}
else
closeRatingEditor();
}
else
closeRatingEditor();
}
else
closeRatingEditor();
//are we in a drag action??
if(event->buttons() & Qt::LeftButton) {
int distance = (event->pos() - startDragPos).manhattanLength();
if (distance >= QApplication::startDragDistance())
performDrag();
}
//disabled mouseMoveEvent in the parent class
}
void YACReaderTableView::mousePressEvent(QMouseEvent * event)
{
QTableView::mousePressEvent(event);
QModelIndex mi = indexAt(event->pos());
if(mi.isValid())
{
QList<QModelIndex> selectedIndexes = this->selectedIndexes();
if(selectedIndexes.contains(mi))
{
if(mi.column() == 11)
{
if(!editing)
{
editing = true;
currentIndexEditing = mi;
edit(mi);
myeditor = indexWidget(mi);
}
return;
}
}
}
//this could be the origin of a new drag acction
if(event->button() == Qt::LeftButton)
{
startDragPos = event->pos();
}
}
void YACReaderTableView::leaveEvent(QEvent * event)
{
closeRatingEditor();
event->accept();
}
void YACReaderTableView::performDrag()
{
QLOG_DEBUG() << "performDrag";
QDrag *drag = new QDrag(this);
drag->setMimeData(model()->mimeData(selectionModel()->selectedRows()));
drag->setPixmap(QPixmap(":/images/comics_view_toolbar/openInYACReader.png")); //TODO add better image
/*Qt::DropAction dropAction =*/ drag->exec(Qt::CopyAction | Qt::MoveAction, Qt::CopyAction);
}
void YACReaderTableView::dragEnterEvent(QDragEnterEvent *event)
{
QTableView::dragEnterEvent(event);
if(model()->canDropMimeData(event->mimeData(),event->proposedAction(),0,0,QModelIndex()))
event->acceptProposedAction();
QLOG_DEBUG() << "drag enter table";
}
void YACReaderTableView::dragMoveEvent(QDragMoveEvent *event)
{
QTableView::dragMoveEvent(event);
if(model()->canDropMimeData(event->mimeData(),event->proposedAction(),0,0,QModelIndex()))
event->acceptProposedAction();
QLOG_DEBUG() << "dragMoveEvent table";
}
void YACReaderTableView::dropEvent(QDropEvent *event)
{
QTableView::dropEvent(event);
if(model()->canDropMimeData(event->mimeData(),event->proposedAction(),0,0,QModelIndex()))
event->acceptProposedAction();
QLOG_DEBUG() << "drop on table";
}
void YACReaderTableView::closeRatingEditor()
{
editing = false;
if(myeditor!=0)
closeEditor(myeditor,QAbstractItemDelegate::NoHint);
myeditor = 0;
}
void YACReaderTableView::closeEditor ( QWidget * editor, QAbstractItemDelegate::EndEditHint hint )
{
editing = false;
myeditor = 0;
QTableView::closeEditor(editor,hint);
}
void YACReaderTableView::commitData ( QWidget * editor )
{
//TODO
StarEditor *starEditor = qobject_cast<StarEditor *>(editor);
if(starEditor->getShouldCommitData())
emit comicRated(((StarEditor *)editor)->starRating().starCount(),currentIndexEditing);
}
void YACReaderTableView::showDeleteProgress()
{
/*showDelete = true;
showDeletingProgressAnimation->setStartValue(deletingProgress->pos());
showDeletingProgressAnimation->setEndValue(QPoint((width()-deletingProgress->width())/2 ,1));
showDeletingProgressAnimation->start();*/
}
void YACReaderTableView::hideDeleteProgress()
{
/*showDelete = false;
if(showDeletingProgressAnimation->state()==QPropertyAnimation::Running)
showDeletingProgressAnimation->stop();
showDeletingProgressAnimation->setStartValue(deletingProgress->pos());
showDeletingProgressAnimation->setEndValue(QPoint((width()-deletingProgress->width())/2 ,-deletingProgress->height()));
showDeletingProgressAnimation->start();*/
}
void YACReaderTableView::resizeEvent(QResizeEvent * event)
{
/*event->size();
if(showDelete)
deletingProgress->move((event->size().width()-deletingProgress->width())/2 ,1);
else
deletingProgress->move((event->size().width()-deletingProgress->width())/2 ,-deletingProgress->height());*/
QTableView::resizeEvent(event);
}
//------------------------------------------------------------------------------
//YACReaderRatingDelegate-------------------------------------------------------
//------------------------------------------------------------------------------
void YACReaderRatingDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
const QModelIndex &index) const
{
int rating = ((ComicItem *)index.internalPointer())->data(11).toInt();
StarRating starRating(rating);
QStyledItemDelegate::paint(painter, option, index);
if(!(option.state & QStyle::State_Editing))
{
if (option.state & QStyle::State_Selected)
starRating.paintSelected(painter, option.rect, option.palette,
StarRating::ReadOnly);
else
starRating.paint(painter, option.rect, option.palette,
StarRating::ReadOnly);
}
}
QSize YACReaderRatingDelegate::sizeHint(const QStyleOptionViewItem &option,
const QModelIndex &index) const
{
Q_UNUSED(option)
int rating = ((ComicItem *)index.internalPointer())->data(11).toInt();
StarRating starRating(rating);
return starRating.sizeHint();
}
QWidget *YACReaderRatingDelegate::createEditor(QWidget *parent,
const QStyleOptionViewItem &option,
const QModelIndex &index) const
{
Q_UNUSED(option)
Q_UNUSED(index)
StarEditor *editor = new StarEditor(parent);
connect(editor, SIGNAL(editingFinished()),
this, SLOT(sendCloseEditor()));
connect(editor, SIGNAL(commitData()),
this, SLOT(sendCommitData()));
return editor;
}
void YACReaderRatingDelegate::setEditorData(QWidget *editor,
const QModelIndex &index) const
{
int rating = ((ComicItem *)index.internalPointer())->data(11).toInt();
StarRating starRating(rating);
StarEditor *starEditor = qobject_cast<StarEditor *>(editor);
starEditor->setStarRating(starRating);
}
void YACReaderRatingDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
const QModelIndex &index) const
{
QStyledItemDelegate::setModelData(editor, model, index);
}
void YACReaderRatingDelegate::sendCommitData()
{
StarEditor *editor = qobject_cast<StarEditor *>(sender());
emit commitData(editor);
}
void YACReaderRatingDelegate::sendCloseEditor()
{
StarEditor *editor = qobject_cast<StarEditor *>(sender());
emit closeEditor(editor);
}
//-------------------------------------------------------------------------------
//StarRating---------------------------------------------------------------------
//-------------------------------------------------------------------------------
const int PaintingScaleFactor = 20;
StarRating::StarRating(int starCount, int maxStarCount)
{
myStarCount = starCount;
myMaxStarCount = maxStarCount;
int numVertex = 5;
double pi = 3.14159265359;
double angle = 3.14159265359 / numVertex;
float rOuter = 0.3f;
float rInner = 0.15f;
for (int i = 0; i < 2 * numVertex; i++)
{
double r = (i & 1) == 0 ? rOuter : rInner;
starPolygon << QPointF(0.5 + cos((i * angle)-pi/2) * r, 0.5 + sin((i * angle)-pi/2) * r);
}
diamondPolygon << QPointF(0.4, 0.5) << QPointF(0.5, 0.4)
<< QPointF(0.6, 0.5) << QPointF(0.5, 0.6)
<< QPointF(0.4, 0.5);
}
QSize StarRating::sizeHint() const
{
return PaintingScaleFactor * QSize(myMaxStarCount, 1);
}
void StarRating::paint(QPainter *painter, const QRect &rect,
const QPalette &palette, EditMode mode) const
{
Q_UNUSED(palette)
painter->save();
painter->setRenderHint(QPainter::Antialiasing, true);
painter->setPen(Qt::NoPen);
//if (mode == Editable) {
// painter->setBrush(palette.highlight());
//} else {
QBrush brush(QColor("#e9be0f"));
painter->setBrush(brush);
//}
int yOffset = (rect.height() - PaintingScaleFactor) / 2;
painter->translate(rect.x(), rect.y() + yOffset);
painter->scale(PaintingScaleFactor, PaintingScaleFactor);
for (int i = 0; i < myMaxStarCount; ++i) {
if (i < myStarCount) {
painter->drawPolygon(starPolygon, Qt::WindingFill);
} else if (mode == Editable) {
painter->drawEllipse(QPointF(0.5,0.5),0.08,0.08);//(diamondPolygon, Qt::WindingFill);
}
painter->translate(1.0, 0.0);
}
painter->restore();
}
void StarRating::paintSelected(QPainter *painter, const QRect &rect,
const QPalette &palette, EditMode mode, QColor color) const
{
Q_UNUSED(palette)
Q_UNUSED(mode)
painter->save();
painter->setRenderHint(QPainter::Antialiasing, true);
painter->setPen(Qt::NoPen);
QBrush star(color);
QBrush dot(QColor("#ffffff"));
int yOffset = (rect.height() - PaintingScaleFactor) / 2;
painter->translate(rect.x(), rect.y() + yOffset);
painter->scale(PaintingScaleFactor, PaintingScaleFactor);
for (int i = 0; i < myMaxStarCount; ++i) {
if (i < myStarCount) {
painter->setBrush(star);
painter->drawPolygon(starPolygon, Qt::WindingFill);
} else {
painter->setBrush(dot);
painter->drawEllipse(QPointF(0.5,0.5),0.08,0.08);
}
painter->translate(1.0, 0.0);
}
painter->restore();
}
void StarRating::paintSelected(QPainter *painter, const QRect &rect,
const QPalette &palette, EditMode mode) const
{
paintSelected(painter,rect, palette,mode,QColor("#ffffff"));
}
//-------------------------------------------------------------------------------
//StarEditor---------------------------------------------------------------------
//-------------------------------------------------------------------------------
StarEditor::StarEditor(QWidget *parent)
: QWidget(parent),shouldCommitData(false)
{
//setMouseTracking(true);
//setAutoFillBackground(true);
}
QSize StarEditor::sizeHint() const
{
return myStarRating.sizeHint();
}
void StarEditor::paintEvent(QPaintEvent *)
{
/*
QPainter painter(this);
myStarRating.paintSelected(&painter, rect(), this->palette(),
StarRating::Editable,QColor("#615f59"));*/
}
void StarEditor::mouseMoveEvent(QMouseEvent *event)
{
Q_UNUSED(event)
/*int star = starAtPosition(event->x());
if (star != myStarRating.starCount() && star != -1) {
myStarRating.setStarCount(star);
update();
}*/
}
void StarEditor::leaveEvent(QEvent * event){
emit editingFinished();
QWidget::leaveEvent(event);
}
void StarEditor::mousePressEvent(QMouseEvent * event )
{
if(event->button() == Qt::LeftButton)
{
int star = starAtPosition(event->x());
if (star != myStarRating.starCount() && star != -1) {
myStarRating.setStarCount(star);
shouldCommitData = true;
emit commitData();
}
}
}
int StarEditor::starAtPosition(int x)
{
int star = (x / (myStarRating.sizeHint().width()
/ myStarRating.maxStarCount())) + 1;
if (star <= 0 || star > myStarRating.maxStarCount())
return -1;
return star;
}
#include "yacreader_table_view.h"
#include <QHeaderView>
#include <QResizeEvent>
#include <QPropertyAnimation>
#include <QPainter>
#include <QDrag>
#include <QMimeData>
#include <QApplication>
#include <QBuffer>
#include <qmath.h>
#include "QsLog.h"
#include "comic_item.h"
YACReaderTableView::YACReaderTableView(QWidget *parent) :
QTableView(parent),showDelete(false),editing(false),myeditor(0)
{
setAlternatingRowColors(true);
verticalHeader()->setAlternatingRowColors(true);
setStyleSheet("QTableView {alternate-background-color: #F2F2F2;background-color: #FAFAFA; outline: 0px;}"// border: 1px solid #999999; border-right:none; border-bottom:none;}"
"QTableCornerButton::section {background-color:#F5F5F5; border:none; border-bottom:1px solid #B8BDC4; border-right:1px solid qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #D1D1D1, stop: 1 #B8BDC4);}"
"QTableView::item {outline: 0px; border-bottom: 1px solid #DFDFDF;border-top: 1px solid #FEFEFE; padding-bottom:1px; color:#252626;}"
"QTableView {border-top:1px solid #B8B8B8;border-bottom:none;border-left:1px solid #B8B8B8;border-right:none;}"
#ifdef Q_OS_MAC
"QTableView {border-top:1px solid #B8B8B8;border-bottom:none;border-left:none;border-right:none;}"
"QTableView::item:selected {outline: 0px; border-bottom: 1px solid #3875D7;border-top: 1px solid #3875D7; padding-bottom:1px; background-color: #3875D7; color: #FFFFFF; }"
#else
"QTableView::item:selected {outline: 0px; border-bottom: 1px solid #D4D4D4;border-top: 1px solid #D4D4D4; padding-bottom:1px; background-color: #D4D4D4; }"
#endif
"QHeaderView::section:horizontal {background-color:#F5F5F5; border-bottom:1px solid #B8BDC4; border-right:1px solid qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #D1D1D1, stop: 1 #B8BDC4); border-left:none; border-top:none; padding:4px; color:#313232;}"
"QHeaderView::section:vertical {border-bottom: 1px solid #DFDFDF;border-top: 1px solid #FEFEFE;}"
//"QTableView::item:hover {border-bottom: 1px solid #A3A3A3;border-top: 1px solid #A3A3A3; padding-bottom:1px; background-color: #A3A3A3; color: #FFFFFF; }"
"");
//comicView->setItemDelegate(new YACReaderComicViewDelegate());
setContextMenuPolicy(Qt::ActionsContextMenu);
setShowGrid(false);
#if QT_VERSION >= 0x050000
verticalHeader()->setSectionResizeMode(QHeaderView::Fixed);
#else
verticalHeader()->setResizeMode(QHeaderView::Fixed);
#endif
//comicView->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
horizontalHeader()->setStretchLastSection(true);
#if QT_VERSION >= 0x050000
horizontalHeader()->setSectionsClickable(false);
#else
horizontalHeader()->setClickable(false);
#endif
//comicView->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents);
verticalHeader()->setDefaultSectionSize(24);
#if QT_VERSION >= 0x050000
verticalHeader()->setSectionsClickable(false); //TODO comportamiento anómalo
#else
verticalHeader()->setClickable(false); //TODO comportamiento anómalo
#endif
setCornerButtonEnabled(false);
setSelectionBehavior(QAbstractItemView::SelectRows);
setSelectionMode(QAbstractItemView::ExtendedSelection);
setItemDelegateForColumn(11,new YACReaderRatingDelegate(this));
setEditTriggers(QAbstractItemView::NoEditTriggers);
setMouseTracking(true);
/*deletingProgress = new YACReaderDeletingProgress(this);
showDeletingProgressAnimation = new QPropertyAnimation(deletingProgress,"pos");
showDeletingProgressAnimation->setDuration(150);*/
//drag: if the default drag is enabled there is no way for setting a custom image
//TODO report bug/suggestion
//setDragEnabled(true);
//setDragDropMode(QAbstractItemView::DragDrop);
setAcceptDrops(true);
}
void YACReaderTableView::mouseMoveEvent(QMouseEvent *event)
{
QModelIndex mi = indexAt(event->pos());
if(mi.isValid())
{
QList<QModelIndex> selectedIndexes = this->selectedIndexes();
if(selectedIndexes.contains(mi))
{
if(mi.column() == 11)
{
if(!editing)
{
editing = true;
currentIndexEditing = mi;
edit(mi);
myeditor = indexWidget(mi);
}
else if(mi.row() != currentIndexEditing.row())
closeRatingEditor();
}
else
closeRatingEditor();
}
else
closeRatingEditor();
}
else
closeRatingEditor();
//are we in a drag action??
if(event->buttons() & Qt::LeftButton) {
int distance = (event->pos() - startDragPos).manhattanLength();
if (distance >= QApplication::startDragDistance())
performDrag();
}
//disabled mouseMoveEvent in the parent class
}
void YACReaderTableView::mousePressEvent(QMouseEvent * event)
{
QTableView::mousePressEvent(event);
QModelIndex mi = indexAt(event->pos());
if(mi.isValid())
{
QList<QModelIndex> selectedIndexes = this->selectedIndexes();
if(selectedIndexes.contains(mi))
{
if(mi.column() == 11)
{
if(!editing)
{
editing = true;
currentIndexEditing = mi;
edit(mi);
myeditor = indexWidget(mi);
}
return;
}
}
}
//this could be the origin of a new drag acction
if(event->button() == Qt::LeftButton)
{
startDragPos = event->pos();
}
}
void YACReaderTableView::leaveEvent(QEvent * event)
{
closeRatingEditor();
event->accept();
}
void YACReaderTableView::performDrag()
{
QLOG_DEBUG() << "performDrag";
QDrag *drag = new QDrag(this);
drag->setMimeData(model()->mimeData(selectionModel()->selectedRows()));
drag->setPixmap(QPixmap(":/images/comics_view_toolbar/openInYACReader.png")); //TODO add better image
/*Qt::DropAction dropAction =*/ drag->exec(Qt::CopyAction | Qt::MoveAction, Qt::CopyAction);
}
void YACReaderTableView::dragEnterEvent(QDragEnterEvent *event)
{
QTableView::dragEnterEvent(event);
if(model()->canDropMimeData(event->mimeData(),event->proposedAction(),0,0,QModelIndex()))
event->acceptProposedAction();
QLOG_DEBUG() << "drag enter table";
}
void YACReaderTableView::dragMoveEvent(QDragMoveEvent *event)
{
QTableView::dragMoveEvent(event);
if(model()->canDropMimeData(event->mimeData(),event->proposedAction(),0,0,QModelIndex()))
event->acceptProposedAction();
QLOG_DEBUG() << "dragMoveEvent table";
}
void YACReaderTableView::dropEvent(QDropEvent *event)
{
QTableView::dropEvent(event);
if(model()->canDropMimeData(event->mimeData(),event->proposedAction(),0,0,QModelIndex()))
event->acceptProposedAction();
QLOG_DEBUG() << "drop on table";
}
void YACReaderTableView::closeRatingEditor()
{
editing = false;
if(myeditor!=0)
closeEditor(myeditor,QAbstractItemDelegate::NoHint);
myeditor = 0;
}
void YACReaderTableView::closeEditor ( QWidget * editor, QAbstractItemDelegate::EndEditHint hint )
{
editing = false;
myeditor = 0;
QTableView::closeEditor(editor,hint);
}
void YACReaderTableView::commitData ( QWidget * editor )
{
//TODO
StarEditor *starEditor = qobject_cast<StarEditor *>(editor);
if(starEditor->getShouldCommitData())
emit comicRated(((StarEditor *)editor)->starRating().starCount(),currentIndexEditing);
}
void YACReaderTableView::showDeleteProgress()
{
/*showDelete = true;
showDeletingProgressAnimation->setStartValue(deletingProgress->pos());
showDeletingProgressAnimation->setEndValue(QPoint((width()-deletingProgress->width())/2 ,1));
showDeletingProgressAnimation->start();*/
}
void YACReaderTableView::hideDeleteProgress()
{
/*showDelete = false;
if(showDeletingProgressAnimation->state()==QPropertyAnimation::Running)
showDeletingProgressAnimation->stop();
showDeletingProgressAnimation->setStartValue(deletingProgress->pos());
showDeletingProgressAnimation->setEndValue(QPoint((width()-deletingProgress->width())/2 ,-deletingProgress->height()));
showDeletingProgressAnimation->start();*/
}
void YACReaderTableView::resizeEvent(QResizeEvent * event)
{
/*event->size();
if(showDelete)
deletingProgress->move((event->size().width()-deletingProgress->width())/2 ,1);
else
deletingProgress->move((event->size().width()-deletingProgress->width())/2 ,-deletingProgress->height());*/
QTableView::resizeEvent(event);
}
//------------------------------------------------------------------------------
//YACReaderRatingDelegate-------------------------------------------------------
//------------------------------------------------------------------------------
void YACReaderRatingDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
const QModelIndex &index) const
{
int rating = ((ComicItem *)index.internalPointer())->data(11).toInt();
StarRating starRating(rating);
QStyledItemDelegate::paint(painter, option, index);
if(!(option.state & QStyle::State_Editing))
{
if (option.state & QStyle::State_Selected)
starRating.paintSelected(painter, option.rect, option.palette,
StarRating::ReadOnly);
else
starRating.paint(painter, option.rect, option.palette,
StarRating::ReadOnly);
}
}
QSize YACReaderRatingDelegate::sizeHint(const QStyleOptionViewItem &option,
const QModelIndex &index) const
{
Q_UNUSED(option)
int rating = ((ComicItem *)index.internalPointer())->data(11).toInt();
StarRating starRating(rating);
return starRating.sizeHint();
}
QWidget *YACReaderRatingDelegate::createEditor(QWidget *parent,
const QStyleOptionViewItem &option,
const QModelIndex &index) const
{
Q_UNUSED(option)
Q_UNUSED(index)
StarEditor *editor = new StarEditor(parent);
connect(editor, SIGNAL(editingFinished()),
this, SLOT(sendCloseEditor()));
connect(editor, SIGNAL(commitData()),
this, SLOT(sendCommitData()));
return editor;
}
void YACReaderRatingDelegate::setEditorData(QWidget *editor,
const QModelIndex &index) const
{
int rating = ((ComicItem *)index.internalPointer())->data(11).toInt();
StarRating starRating(rating);
StarEditor *starEditor = qobject_cast<StarEditor *>(editor);
starEditor->setStarRating(starRating);
}
void YACReaderRatingDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
const QModelIndex &index) const
{
QStyledItemDelegate::setModelData(editor, model, index);
}
void YACReaderRatingDelegate::sendCommitData()
{
StarEditor *editor = qobject_cast<StarEditor *>(sender());
emit commitData(editor);
}
void YACReaderRatingDelegate::sendCloseEditor()
{
StarEditor *editor = qobject_cast<StarEditor *>(sender());
emit closeEditor(editor);
}
//-------------------------------------------------------------------------------
//StarRating---------------------------------------------------------------------
//-------------------------------------------------------------------------------
const int PaintingScaleFactor = 20;
StarRating::StarRating(int starCount, int maxStarCount)
{
myStarCount = starCount;
myMaxStarCount = maxStarCount;
int numVertex = 5;
double pi = 3.14159265359;
double angle = 3.14159265359 / numVertex;
float rOuter = 0.3f;
float rInner = 0.15f;
for (int i = 0; i < 2 * numVertex; i++)
{
double r = (i & 1) == 0 ? rOuter : rInner;
starPolygon << QPointF(0.5 + cos((i * angle)-pi/2) * r, 0.5 + sin((i * angle)-pi/2) * r);
}
diamondPolygon << QPointF(0.4, 0.5) << QPointF(0.5, 0.4)
<< QPointF(0.6, 0.5) << QPointF(0.5, 0.6)
<< QPointF(0.4, 0.5);
}
QSize StarRating::sizeHint() const
{
return PaintingScaleFactor * QSize(myMaxStarCount, 1);
}
void StarRating::paint(QPainter *painter, const QRect &rect,
const QPalette &palette, EditMode mode) const
{
Q_UNUSED(palette)
painter->save();
painter->setRenderHint(QPainter::Antialiasing, true);
painter->setPen(Qt::NoPen);
//if (mode == Editable) {
// painter->setBrush(palette.highlight());
//} else {
QBrush brush(QColor("#e9be0f"));
painter->setBrush(brush);
//}
int yOffset = (rect.height() - PaintingScaleFactor) / 2;
painter->translate(rect.x(), rect.y() + yOffset);
painter->scale(PaintingScaleFactor, PaintingScaleFactor);
for (int i = 0; i < myMaxStarCount; ++i) {
if (i < myStarCount) {
painter->drawPolygon(starPolygon, Qt::WindingFill);
} else if (mode == Editable) {
painter->drawEllipse(QPointF(0.5,0.5),0.08,0.08);//(diamondPolygon, Qt::WindingFill);
}
painter->translate(1.0, 0.0);
}
painter->restore();
}
void StarRating::paintSelected(QPainter *painter, const QRect &rect,
const QPalette &palette, EditMode mode, QColor color) const
{
Q_UNUSED(palette)
Q_UNUSED(mode)
painter->save();
painter->setRenderHint(QPainter::Antialiasing, true);
painter->setPen(Qt::NoPen);
QBrush star(color);
QBrush dot(QColor("#ffffff"));
int yOffset = (rect.height() - PaintingScaleFactor) / 2;
painter->translate(rect.x(), rect.y() + yOffset);
painter->scale(PaintingScaleFactor, PaintingScaleFactor);
for (int i = 0; i < myMaxStarCount; ++i) {
if (i < myStarCount) {
painter->setBrush(star);
painter->drawPolygon(starPolygon, Qt::WindingFill);
} else {
painter->setBrush(dot);
painter->drawEllipse(QPointF(0.5,0.5),0.08,0.08);
}
painter->translate(1.0, 0.0);
}
painter->restore();
}
void StarRating::paintSelected(QPainter *painter, const QRect &rect,
const QPalette &palette, EditMode mode) const
{
paintSelected(painter,rect, palette,mode,QColor("#ffffff"));
}
//-------------------------------------------------------------------------------
//StarEditor---------------------------------------------------------------------
//-------------------------------------------------------------------------------
StarEditor::StarEditor(QWidget *parent)
: QWidget(parent),shouldCommitData(false)
{
//setMouseTracking(true);
//setAutoFillBackground(true);
}
QSize StarEditor::sizeHint() const
{
return myStarRating.sizeHint();
}
void StarEditor::paintEvent(QPaintEvent *)
{
/*
QPainter painter(this);
myStarRating.paintSelected(&painter, rect(), this->palette(),
StarRating::Editable,QColor("#615f59"));*/
}
void StarEditor::mouseMoveEvent(QMouseEvent *event)
{
Q_UNUSED(event)
/*int star = starAtPosition(event->x());
if (star != myStarRating.starCount() && star != -1) {
myStarRating.setStarCount(star);
update();
}*/
}
void StarEditor::leaveEvent(QEvent * event){
emit editingFinished();
QWidget::leaveEvent(event);
}
void StarEditor::mousePressEvent(QMouseEvent * event )
{
if(event->button() == Qt::LeftButton)
{
int star = starAtPosition(event->x());
if (star != myStarRating.starCount() && star != -1) {
myStarRating.setStarCount(star);
shouldCommitData = true;
emit commitData();
}
}
}
int StarEditor::starAtPosition(int x)
{
int star = (x / (myStarRating.sizeHint().width()
/ myStarRating.maxStarCount())) + 1;
if (star <= 0 || star > myStarRating.maxStarCount())
return -1;
return star;
}

View File

@ -1,132 +1,132 @@
#ifndef YACREADER_TABLE_VIEW_H
#define YACREADER_TABLE_VIEW_H
#include <QTableView>
#include <QStyledItemDelegate>
class YACReaderDeletingProgress;
class QResizeEvent;
class QPropertyAnimation;
class YACReaderTableView : public QTableView
{
Q_OBJECT
public:
explicit YACReaderTableView(QWidget *parent = 0);
signals:
void comicRated(int,QModelIndex);
public slots:
void showDeleteProgress();
void hideDeleteProgress();
void closeRatingEditor();
protected slots:
virtual void closeEditor ( QWidget * editor, QAbstractItemDelegate::EndEditHint hint );
virtual void commitData ( QWidget * editor );
private:
YACReaderDeletingProgress * deletingProgress;
bool showDelete;
QPropertyAnimation * showDeletingProgressAnimation;
void resizeEvent(QResizeEvent * event);
void mouseMoveEvent(QMouseEvent *event);
void mousePressEvent(QMouseEvent * event);
void leaveEvent(QEvent * event);
void performDrag();
void dragEnterEvent(QDragEnterEvent * event);
void dragMoveEvent(QDragMoveEvent * event);
void dropEvent(QDropEvent * event);
bool editing;
QModelIndex currentIndexEditing;
QWidget * myeditor;
//drag from here
QPoint startDragPos;
};
//---
class YACReaderRatingDelegate : public QStyledItemDelegate
{
Q_OBJECT
public:
YACReaderRatingDelegate(QWidget *parent = 0) : QStyledItemDelegate(parent) {}
void paint(QPainter *painter, const QStyleOptionViewItem &option,
const QModelIndex &index) const;
QSize sizeHint(const QStyleOptionViewItem &option,
const QModelIndex &index) const;
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
const QModelIndex &index) const;
void setEditorData(QWidget *editor, const QModelIndex &index) const;
void setModelData(QWidget *editor, QAbstractItemModel *model,
const QModelIndex &index) const;
private slots:
void sendCloseEditor();
void sendCommitData();
};
//---
class StarRating
{
public:
enum EditMode { Editable, ReadOnly };
StarRating(int starCount = 1, int maxStarCount = 5);
void paint(QPainter *painter, const QRect &rect,
const QPalette &palette, EditMode mode) const;
void paintSelected(QPainter *painter, const QRect &rect,
const QPalette &palette, EditMode mode, QColor color) const;
void paintSelected(QPainter *painter, const QRect &rect,
const QPalette &palette, EditMode mode) const;
QSize sizeHint() const;
int starCount() const { return myStarCount; }
int maxStarCount() const { return myMaxStarCount; }
void setStarCount(int starCount) { myStarCount = starCount; }
void setMaxStarCount(int maxStarCount) { myMaxStarCount = maxStarCount; }
private:
QPolygonF starPolygon;
QPolygonF diamondPolygon;
int myStarCount;
int myMaxStarCount;
};
Q_DECLARE_METATYPE(StarRating);
//---
class StarEditor : public QWidget
{
Q_OBJECT
public:
StarEditor(QWidget *parent = 0);
QSize sizeHint() const;
void setStarRating(const StarRating &starRating) {
myStarRating = starRating;
}
StarRating starRating() { return myStarRating; }
bool getShouldCommitData() {return shouldCommitData;};
signals:
void editingFinished();
void commitData();
protected:
void paintEvent(QPaintEvent *event);
void mouseMoveEvent(QMouseEvent *event);
void mousePressEvent(QMouseEvent *event);
void leaveEvent(QEvent * event);
private:
int starAtPosition(int x);
StarRating myStarRating;
bool shouldCommitData;
};
#endif // YACREADER_TABLE_VIEW_H
#ifndef YACREADER_TABLE_VIEW_H
#define YACREADER_TABLE_VIEW_H
#include <QTableView>
#include <QStyledItemDelegate>
class YACReaderDeletingProgress;
class QResizeEvent;
class QPropertyAnimation;
class YACReaderTableView : public QTableView
{
Q_OBJECT
public:
explicit YACReaderTableView(QWidget *parent = 0);
signals:
void comicRated(int,QModelIndex);
public slots:
void showDeleteProgress();
void hideDeleteProgress();
void closeRatingEditor();
protected slots:
virtual void closeEditor ( QWidget * editor, QAbstractItemDelegate::EndEditHint hint );
virtual void commitData ( QWidget * editor );
private:
YACReaderDeletingProgress * deletingProgress;
bool showDelete;
QPropertyAnimation * showDeletingProgressAnimation;
void resizeEvent(QResizeEvent * event);
void mouseMoveEvent(QMouseEvent *event);
void mousePressEvent(QMouseEvent * event);
void leaveEvent(QEvent * event);
void performDrag();
void dragEnterEvent(QDragEnterEvent * event);
void dragMoveEvent(QDragMoveEvent * event);
void dropEvent(QDropEvent * event);
bool editing;
QModelIndex currentIndexEditing;
QWidget * myeditor;
//drag from here
QPoint startDragPos;
};
//---
class YACReaderRatingDelegate : public QStyledItemDelegate
{
Q_OBJECT
public:
YACReaderRatingDelegate(QWidget *parent = 0) : QStyledItemDelegate(parent) {}
void paint(QPainter *painter, const QStyleOptionViewItem &option,
const QModelIndex &index) const;
QSize sizeHint(const QStyleOptionViewItem &option,
const QModelIndex &index) const;
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
const QModelIndex &index) const;
void setEditorData(QWidget *editor, const QModelIndex &index) const;
void setModelData(QWidget *editor, QAbstractItemModel *model,
const QModelIndex &index) const;
private slots:
void sendCloseEditor();
void sendCommitData();
};
//---
class StarRating
{
public:
enum EditMode { Editable, ReadOnly };
StarRating(int starCount = 1, int maxStarCount = 5);
void paint(QPainter *painter, const QRect &rect,
const QPalette &palette, EditMode mode) const;
void paintSelected(QPainter *painter, const QRect &rect,
const QPalette &palette, EditMode mode, QColor color) const;
void paintSelected(QPainter *painter, const QRect &rect,
const QPalette &palette, EditMode mode) const;
QSize sizeHint() const;
int starCount() const { return myStarCount; }
int maxStarCount() const { return myMaxStarCount; }
void setStarCount(int starCount) { myStarCount = starCount; }
void setMaxStarCount(int maxStarCount) { myMaxStarCount = maxStarCount; }
private:
QPolygonF starPolygon;
QPolygonF diamondPolygon;
int myStarCount;
int myMaxStarCount;
};
Q_DECLARE_METATYPE(StarRating);
//---
class StarEditor : public QWidget
{
Q_OBJECT
public:
StarEditor(QWidget *parent = 0);
QSize sizeHint() const;
void setStarRating(const StarRating &starRating) {
myStarRating = starRating;
}
StarRating starRating() { return myStarRating; }
bool getShouldCommitData() {return shouldCommitData;};
signals:
void editingFinished();
void commitData();
protected:
void paintEvent(QPaintEvent *event);
void mouseMoveEvent(QMouseEvent *event);
void mousePressEvent(QMouseEvent *event);
void leaveEvent(QEvent * event);
private:
int starAtPosition(int x);
StarRating myStarRating;
bool shouldCommitData;
};
#endif // YACREADER_TABLE_VIEW_H

View File

@ -1,143 +1,143 @@
#include "yacreader_titled_toolbar.h"
#include <QAction>
#include <QHBoxLayout>
#include <QLabel>
#include <QPainter>
#include <QPixmap>
#include <QPushButton>
#include <QToolButton>
DropShadowLabel::DropShadowLabel(QWidget* 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,
QPoint offset)
{
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);
QPainter painter(this);
painter.setFont(font());
#ifndef Q_OS_MAC
drawTextEffect(&painter, QPoint(contentsMargins().left(), 1));
#endif
drawText(&painter, QPoint(contentsMargins().left(), 0));
}
void DropShadowLabel::setColor(const QColor & color)
{
textColor = color;
}
void DropShadowLabel::setDropShadowColor(const QColor & color)
{
dropShadowColor = color;
}
YACReaderTitledToolBar::YACReaderTitledToolBar(const QString & title, QWidget *parent) :
QWidget(parent)
{
QHBoxLayout * mainLayout = new QHBoxLayout;
mainLayout->setMargin(0);
mainLayout->setSpacing(0);
QString styleSheet = "QWidget {border:0px;}";
setStyleSheet(styleSheet);
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("#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"));
#endif
nameLabel->setStyleSheet(nameLabelStyleSheet);
mainLayout->addWidget(nameLabel,Qt::AlignLeft);
mainLayout->addStretch();
setLayout(mainLayout);
setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum);
setMinimumHeight(25);
}
void YACReaderTitledToolBar::addAction(QAction * action)
{
QHBoxLayout * mainLayout = dynamic_cast<QHBoxLayout *>(layout());
//fix for QToolButton and retina support in OSX
#ifdef Q_OS_MAC
QPushButton * pb = new QPushButton(this);
pb->setCursor(QCursor(Qt::ArrowCursor));
pb->setIcon(action->icon());
pb->addAction(action);
connect(pb, SIGNAL(clicked(bool)), action, SIGNAL(triggered(bool)));
mainLayout->addWidget(pb);
#else
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;}");
mainLayout->addWidget(tb);
#endif
}
void YACReaderTitledToolBar::addSpacing(int spacing)
{
QHBoxLayout * mainLayout = dynamic_cast<QHBoxLayout *>(layout());
mainLayout->addSpacing(spacing);
}
void YACReaderTitledToolBar::addSepartor()
{
QHBoxLayout * mainLayout = dynamic_cast<QHBoxLayout *>(layout());
QWidget * w = new QWidget(this);
w->setFixedSize(1,14);
#ifdef Q_OS_MAC
w->setStyleSheet("QWidget {background-color:#AFAFAF;}");
#else
w->setStyleSheet("QWidget {background-color:#6F6F6F;}");
#endif
mainLayout->addSpacing(10);
mainLayout->addWidget(w);
mainLayout->addSpacing(10);
}
#include "yacreader_titled_toolbar.h"
#include <QAction>
#include <QHBoxLayout>
#include <QLabel>
#include <QPainter>
#include <QPixmap>
#include <QPushButton>
#include <QToolButton>
DropShadowLabel::DropShadowLabel(QWidget* 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,
QPoint offset)
{
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);
QPainter painter(this);
painter.setFont(font());
#ifndef Q_OS_MAC
drawTextEffect(&painter, QPoint(contentsMargins().left(), 1));
#endif
drawText(&painter, QPoint(contentsMargins().left(), 0));
}
void DropShadowLabel::setColor(const QColor & color)
{
textColor = color;
}
void DropShadowLabel::setDropShadowColor(const QColor & color)
{
dropShadowColor = color;
}
YACReaderTitledToolBar::YACReaderTitledToolBar(const QString & title, QWidget *parent) :
QWidget(parent)
{
QHBoxLayout * mainLayout = new QHBoxLayout;
mainLayout->setMargin(0);
mainLayout->setSpacing(0);
QString styleSheet = "QWidget {border:0px;}";
setStyleSheet(styleSheet);
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("#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"));
#endif
nameLabel->setStyleSheet(nameLabelStyleSheet);
mainLayout->addWidget(nameLabel,Qt::AlignLeft);
mainLayout->addStretch();
setLayout(mainLayout);
setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum);
setMinimumHeight(25);
}
void YACReaderTitledToolBar::addAction(QAction * action)
{
QHBoxLayout * mainLayout = dynamic_cast<QHBoxLayout *>(layout());
//fix for QToolButton and retina support in OSX
#ifdef Q_OS_MAC
QPushButton * pb = new QPushButton(this);
pb->setCursor(QCursor(Qt::ArrowCursor));
pb->setIcon(action->icon());
pb->addAction(action);
connect(pb, SIGNAL(clicked(bool)), action, SIGNAL(triggered(bool)));
mainLayout->addWidget(pb);
#else
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;}");
mainLayout->addWidget(tb);
#endif
}
void YACReaderTitledToolBar::addSpacing(int spacing)
{
QHBoxLayout * mainLayout = dynamic_cast<QHBoxLayout *>(layout());
mainLayout->addSpacing(spacing);
}
void YACReaderTitledToolBar::addSepartor()
{
QHBoxLayout * mainLayout = dynamic_cast<QHBoxLayout *>(layout());
QWidget * w = new QWidget(this);
w->setFixedSize(1,14);
#ifdef Q_OS_MAC
w->setStyleSheet("QWidget {background-color:#AFAFAF;}");
#else
w->setStyleSheet("QWidget {background-color:#6F6F6F;}");
#endif
mainLayout->addSpacing(10);
mainLayout->addWidget(w);
mainLayout->addSpacing(10);
}

View File

@ -1,46 +1,46 @@
#ifndef YACREADER_TITLED_TOOLBAR_H
#define YACREADER_TITLED_TOOLBAR_H
#include <QWidget>
#include <QLabel>
#include <QPaintEvent>
#include <QPainter>
#include <QPoint>
class QIcon;
class DropShadowLabel : public QLabel
{
Q_OBJECT
public:
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);
};
class YACReaderTitledToolBar : public QWidget
{
Q_OBJECT
public:
explicit YACReaderTitledToolBar(const QString & title, QWidget *parent = 0);
signals:
public slots:
void addAction(QAction * action);
void addSpacing(int space);
void addSepartor();
private:
DropShadowLabel * nameLabel;
};
#endif // YACREADER_TITLED_TOOLBAR_H
#ifndef YACREADER_TITLED_TOOLBAR_H
#define YACREADER_TITLED_TOOLBAR_H
#include <QWidget>
#include <QLabel>
#include <QPaintEvent>
#include <QPainter>
#include <QPoint>
class QIcon;
class DropShadowLabel : public QLabel
{
Q_OBJECT
public:
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);
};
class YACReaderTitledToolBar : public QWidget
{
Q_OBJECT
public:
explicit YACReaderTitledToolBar(const QString & title, QWidget *parent = 0);
signals:
public slots:
void addAction(QAction * action);
void addSpacing(int space);
void addSepartor();
private:
DropShadowLabel * nameLabel;
};
#endif // YACREADER_TITLED_TOOLBAR_H

View File

@ -1,18 +1,18 @@
#ifndef YACREADER_TOOL_BAR_STRETCH_H
#define YACREADER_TOOL_BAR_STRETCH_H
#include <QWidget>
#include <QHBoxLayout>
class YACReaderToolBarStretch : public QWidget
{
public:
YACReaderToolBarStretch(QWidget * parent=0):QWidget(parent)
{
QHBoxLayout * l= new QHBoxLayout();
l->addStretch();
setLayout(l);
}
};
#endif // YACREADER_TOOL_BAR_STRETCH_H
#ifndef YACREADER_TOOL_BAR_STRETCH_H
#define YACREADER_TOOL_BAR_STRETCH_H
#include <QWidget>
#include <QHBoxLayout>
class YACReaderToolBarStretch : public QWidget
{
public:
YACReaderToolBarStretch(QWidget * parent=0):QWidget(parent)
{
QHBoxLayout * l= new QHBoxLayout();
l->addStretch();
setLayout(l);
}
};
#endif // YACREADER_TOOL_BAR_STRETCH_H

View File

@ -1,154 +1,154 @@
#include "yacreader_treeview.h"
YACReaderTreeView::YACReaderTreeView(QWidget *parent) :
QTreeView(parent)
{
setAcceptDrops(true);
setDragDropMode(QAbstractItemView::DropOnly);
setItemsExpandable(true);
//setDragEnabled(true);
/*viewport()->setAcceptDrops(true);
setDropIndicatorShown(true);*/
setContextMenuPolicy(Qt::CustomContextMenu);
header()->hide();
setUniformRowHeights(true);
setSelectionBehavior(QAbstractItemView::SelectRows);
setAttribute(Qt::WA_MacShowFocusRect,false);
#ifdef Q_OS_MAC
bool oldStyle = true;
switch (QSysInfo::MacVersion())
{
case QSysInfo::MV_SNOWLEOPARD:
case QSysInfo::MV_LION:
case QSysInfo::MV_MOUNTAINLION:
case QSysInfo::MV_MAVERICKS:
oldStyle = true; //TODO fix this
break;
default:
oldStyle = false;
break;
}
if(oldStyle)
{
setStyleSheet("QTreeView {background-color:transparent; border: none;}"
"QTreeView::item:selected {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;}"
"QTreeView::branch:selected {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;}"
"QTreeView::branch:open:selected:has-children {image: url(':/images/sidebar/expanded_branch_osx.png');}"
"QTreeView::branch:closed:selected:has-children {image: url(':/images/sidebar/collapsed_branch_osx.png');}"
"QScrollBar:vertical { border: none; background: #EFEFEF; width: 9px; margin: 0 3px 0 0; }"
"QScrollBar::handle:vertical { background: #DDDDDD; width: 7px; min-height: 20px; margin: 1px; border: 1px solid #D0D0D0; }"
"QScrollBar::add-line:vertical { border: none; background: #EFEFEF; height: 10px; subcontrol-position: bottom; subcontrol-origin: margin; margin: 0 3px 0 0;}"
"QScrollBar::sub-line:vertical { border: none; background: #EFEFEF; height: 10px; subcontrol-position: top; subcontrol-origin: margin; margin: 0 3px 0 0;}"
"QScrollBar::up-arrow:vertical {border:none;width: 9px;height: 6px;background: url(':/images/folders_view/line-up.png') center top no-repeat;}"
"QScrollBar::down-arrow:vertical {border:none;width: 9px;height: 6px;background: url(':/images/folders_view/line-down.png') center top no-repeat;}"
"QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical {background: none; }"
);
}
else
{
setStyleSheet("QTreeView {background-color:transparent; border: none;}"
"QTreeView::item:selected {background-color:#91c4f4; border-top: 1px solid #91c4f4; border-left:none;border-right:none;border-bottom:1px solid #91c4f4;}"
"QTreeView::branch:selected {background-color:#91c4f4; border-top: 1px solid #91c4f4; border-left:none;border-right:none;border-bottom:1px solid #91c4f4;}"
"QTreeView::branch:open:selected:has-children {image: url(':/images/sidebar/expanded_branch_osx.png');}"
"QTreeView::branch:closed:selected:has-children {image: url(':/images/sidebar/collapsed_branch_osx.png');}"
);
}
#else
setStyleSheet("QTreeView {background-color:transparent; border: none; color:#DDDFDF; outline:0; show-decoration-selected: 0;}"
"QTreeView::item:selected {background-color: #2E2E2E; color:white; font:bold;}"
"QTreeView::item:hover {background-color:#2E2E2E; color:white; font:bold;}"
"QTreeView::branch:selected {background-color:#2E2E2E;}"
"QScrollBar:vertical { border: none; background: #404040; width: 7px; margin: 0 3px 0 0; }"
"QScrollBar::handle:vertical { background: #DDDDDD; width: 7px; min-height: 20px; }"
"QScrollBar::add-line:vertical { border: none; background: #404040; height: 10px; subcontrol-position: bottom; subcontrol-origin: margin; margin: 0 3px 0 0;}"
"QScrollBar::sub-line:vertical { border: none; background: #404040; height: 10px; subcontrol-position: top; subcontrol-origin: margin; margin: 0 3px 0 0;}"
"QScrollBar::up-arrow:vertical {border:none;width: 9px;height: 6px;background: url(':/images/folders_view/line-up.png') center top no-repeat;}"
"QScrollBar::down-arrow:vertical {border:none;width: 9px;height: 6px;background: url(':/images/folders_view/line-down.png') center top no-repeat;}"
"QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical {background: none; }"
"QTreeView::branch:has-children:!has-siblings:closed,QTreeView::branch:closed:has-children:has-siblings {border-image: none;image: url(':/images/sidebar/branch-closed.png');}"
"QTreeView::branch:has-children:selected:!has-siblings:closed,QTreeView::branch:closed:selected:has-children:has-siblings {border-image: none;image: url(':/images/sidebar/collapsed_branch_selected.png');}"
"QTreeView::branch:open:has-children:!has-siblings,QTreeView::branch:open:has-children:has-siblings {border-image: none;image: url(':/images/sidebar/branch-open.png');}"
"QTreeView::branch:open:has-children:selected:!has-siblings,QTreeView::branch:open:has-children:selected:has-siblings {border-image: none;image: url(':/images/sidebar/expanded_branch_selected.png');}"
);
#endif
}
void YACReaderTreeView::mousePressEvent(QMouseEvent *event)
{
QTreeView::mousePressEvent(event);
QModelIndex destinationIndex = indexAt(event->pos());
if(!destinationIndex.isValid() && event->button() == Qt::LeftButton)
{
clearSelection();
}
}
void YACReaderTreeView::expandCurrent()
{
QModelIndex index = indexAt(expandPos);
if(index.isValid())
expand(index);
}
void YACReaderTreeView::dragEnterEvent(QDragEnterEvent *event)
{
QTreeView::dragEnterEvent(event);
}
void YACReaderTreeView::dragLeaveEvent(QDragLeaveEvent *event)
{
Q_UNUSED(event)
}
void YACReaderTreeView::dragMoveEvent(QDragMoveEvent *event)
{
QTreeView::dragMoveEvent(event);
//fix for drop auto expand
QModelIndex underMouse = indexAt(event->pos());
if( underMouse.isValid()) {
expandPos = event->pos();
connect(&expandTimer,SIGNAL(timeout()),this,SLOT(expandCurrent()));
expandTimer.setSingleShot(true);
expandTimer.start(500);
}
//force mouse hover decoration, TODO why the event loop is not working here?
if(!t.isActive())
{
t.setSingleShot(true);
t.setInterval(50);
t.start();
repaint();
}
}
void YACReaderTreeView::dropEvent(QDropEvent *event)
{
t.stop();
QTreeView::dropEvent(event);
}
#include "yacreader_treeview.h"
YACReaderTreeView::YACReaderTreeView(QWidget *parent) :
QTreeView(parent)
{
setAcceptDrops(true);
setDragDropMode(QAbstractItemView::DropOnly);
setItemsExpandable(true);
//setDragEnabled(true);
/*viewport()->setAcceptDrops(true);
setDropIndicatorShown(true);*/
setContextMenuPolicy(Qt::CustomContextMenu);
header()->hide();
setUniformRowHeights(true);
setSelectionBehavior(QAbstractItemView::SelectRows);
setAttribute(Qt::WA_MacShowFocusRect,false);
#ifdef Q_OS_MAC
bool oldStyle = true;
switch (QSysInfo::MacVersion())
{
case QSysInfo::MV_SNOWLEOPARD:
case QSysInfo::MV_LION:
case QSysInfo::MV_MOUNTAINLION:
case QSysInfo::MV_MAVERICKS:
oldStyle = true; //TODO fix this
break;
default:
oldStyle = false;
break;
}
if(oldStyle)
{
setStyleSheet("QTreeView {background-color:transparent; border: none;}"
"QTreeView::item:selected {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;}"
"QTreeView::branch:selected {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;}"
"QTreeView::branch:open:selected:has-children {image: url(':/images/sidebar/expanded_branch_osx.png');}"
"QTreeView::branch:closed:selected:has-children {image: url(':/images/sidebar/collapsed_branch_osx.png');}"
"QScrollBar:vertical { border: none; background: #EFEFEF; width: 9px; margin: 0 3px 0 0; }"
"QScrollBar::handle:vertical { background: #DDDDDD; width: 7px; min-height: 20px; margin: 1px; border: 1px solid #D0D0D0; }"
"QScrollBar::add-line:vertical { border: none; background: #EFEFEF; height: 10px; subcontrol-position: bottom; subcontrol-origin: margin; margin: 0 3px 0 0;}"
"QScrollBar::sub-line:vertical { border: none; background: #EFEFEF; height: 10px; subcontrol-position: top; subcontrol-origin: margin; margin: 0 3px 0 0;}"
"QScrollBar::up-arrow:vertical {border:none;width: 9px;height: 6px;background: url(':/images/folders_view/line-up.png') center top no-repeat;}"
"QScrollBar::down-arrow:vertical {border:none;width: 9px;height: 6px;background: url(':/images/folders_view/line-down.png') center top no-repeat;}"
"QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical {background: none; }"
);
}
else
{
setStyleSheet("QTreeView {background-color:transparent; border: none;}"
"QTreeView::item:selected {background-color:#91c4f4; border-top: 1px solid #91c4f4; border-left:none;border-right:none;border-bottom:1px solid #91c4f4;}"
"QTreeView::branch:selected {background-color:#91c4f4; border-top: 1px solid #91c4f4; border-left:none;border-right:none;border-bottom:1px solid #91c4f4;}"
"QTreeView::branch:open:selected:has-children {image: url(':/images/sidebar/expanded_branch_osx.png');}"
"QTreeView::branch:closed:selected:has-children {image: url(':/images/sidebar/collapsed_branch_osx.png');}"
);
}
#else
setStyleSheet("QTreeView {background-color:transparent; border: none; color:#DDDFDF; outline:0; show-decoration-selected: 0;}"
"QTreeView::item:selected {background-color: #2E2E2E; color:white; font:bold;}"
"QTreeView::item:hover {background-color:#2E2E2E; color:white; font:bold;}"
"QTreeView::branch:selected {background-color:#2E2E2E;}"
"QScrollBar:vertical { border: none; background: #404040; width: 7px; margin: 0 3px 0 0; }"
"QScrollBar::handle:vertical { background: #DDDDDD; width: 7px; min-height: 20px; }"
"QScrollBar::add-line:vertical { border: none; background: #404040; height: 10px; subcontrol-position: bottom; subcontrol-origin: margin; margin: 0 3px 0 0;}"
"QScrollBar::sub-line:vertical { border: none; background: #404040; height: 10px; subcontrol-position: top; subcontrol-origin: margin; margin: 0 3px 0 0;}"
"QScrollBar::up-arrow:vertical {border:none;width: 9px;height: 6px;background: url(':/images/folders_view/line-up.png') center top no-repeat;}"
"QScrollBar::down-arrow:vertical {border:none;width: 9px;height: 6px;background: url(':/images/folders_view/line-down.png') center top no-repeat;}"
"QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical {background: none; }"
"QTreeView::branch:has-children:!has-siblings:closed,QTreeView::branch:closed:has-children:has-siblings {border-image: none;image: url(':/images/sidebar/branch-closed.png');}"
"QTreeView::branch:has-children:selected:!has-siblings:closed,QTreeView::branch:closed:selected:has-children:has-siblings {border-image: none;image: url(':/images/sidebar/collapsed_branch_selected.png');}"
"QTreeView::branch:open:has-children:!has-siblings,QTreeView::branch:open:has-children:has-siblings {border-image: none;image: url(':/images/sidebar/branch-open.png');}"
"QTreeView::branch:open:has-children:selected:!has-siblings,QTreeView::branch:open:has-children:selected:has-siblings {border-image: none;image: url(':/images/sidebar/expanded_branch_selected.png');}"
);
#endif
}
void YACReaderTreeView::mousePressEvent(QMouseEvent *event)
{
QTreeView::mousePressEvent(event);
QModelIndex destinationIndex = indexAt(event->pos());
if(!destinationIndex.isValid() && event->button() == Qt::LeftButton)
{
clearSelection();
}
}
void YACReaderTreeView::expandCurrent()
{
QModelIndex index = indexAt(expandPos);
if(index.isValid())
expand(index);
}
void YACReaderTreeView::dragEnterEvent(QDragEnterEvent *event)
{
QTreeView::dragEnterEvent(event);
}
void YACReaderTreeView::dragLeaveEvent(QDragLeaveEvent *event)
{
Q_UNUSED(event)
}
void YACReaderTreeView::dragMoveEvent(QDragMoveEvent *event)
{
QTreeView::dragMoveEvent(event);
//fix for drop auto expand
QModelIndex underMouse = indexAt(event->pos());
if( underMouse.isValid()) {
expandPos = event->pos();
connect(&expandTimer,SIGNAL(timeout()),this,SLOT(expandCurrent()));
expandTimer.setSingleShot(true);
expandTimer.start(500);
}
//force mouse hover decoration, TODO why the event loop is not working here?
if(!t.isActive())
{
t.setSingleShot(true);
t.setInterval(50);
t.start();
repaint();
}
}
void YACReaderTreeView::dropEvent(QDropEvent *event)
{
t.stop();
QTreeView::dropEvent(event);
}

View File

@ -1,29 +1,29 @@
#ifndef YACREADER_TREEVIEW_H
#define YACREADER_TREEVIEW_H
#include <QtWidgets>
class YACReaderTreeView : public QTreeView
{
Q_OBJECT
public:
explicit YACReaderTreeView(QWidget *parent = 0);
void mousePressEvent(QMouseEvent *event);
protected slots:
//fix for drop auto expand
void expandCurrent();
protected:
//Drop to import
void dragEnterEvent(QDragEnterEvent *event);
void dragLeaveEvent(QDragLeaveEvent *event);
void dragMoveEvent(QDragMoveEvent *event);
void dropEvent(QDropEvent *event);
//fix for drop auto expand
QTimer expandTimer;
QTimer t;
QPoint expandPos;
};
#endif // YACREADER_TREEVIEW_H
#ifndef YACREADER_TREEVIEW_H
#define YACREADER_TREEVIEW_H
#include <QtWidgets>
class YACReaderTreeView : public QTreeView
{
Q_OBJECT
public:
explicit YACReaderTreeView(QWidget *parent = 0);
void mousePressEvent(QMouseEvent *event);
protected slots:
//fix for drop auto expand
void expandCurrent();
protected:
//Drop to import
void dragEnterEvent(QDragEnterEvent *event);
void dragLeaveEvent(QDragLeaveEvent *event);
void dragMoveEvent(QDragMoveEvent *event);
void dropEvent(QDropEvent *event);
//fix for drop auto expand
QTimer expandTimer;
QTimer t;
QPoint expandPos;
};
#endif // YACREADER_TREEVIEW_H