mirror of
				https://github.com/YACReader/yacreader
				synced 2025-11-04 01:05:06 -05:00 
			
		
		
		
	Replace potentially unterminated std::string::data() for pre-c++11
This commit is contained in:
		
							
								
								
									
										25
									
								
								custom_widgets/custom_widgets_yacreader.pri
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								custom_widgets/custom_widgets_yacreader.pri
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,25 @@
 | 
			
		||||
INCLUDEPATH += $$PWD
 | 
			
		||||
DEPENDPATH += $$PWD
 | 
			
		||||
 | 
			
		||||
HEADERS += $$PWD/help_about_dialog.h \
 | 
			
		||||
						$$PWD/yacreader_field_edit.h \
 | 
			
		||||
                        $$PWD/yacreader_field_plain_text_edit.h \
 | 
			
		||||
                        $$PWD/yacreader_flow.h \
 | 
			
		||||
                        $$PWD/yacreader_flow_config_widget.h \
 | 
			
		||||
                        $$PWD/yacreader_gl_flow_config_widget.h \
 | 
			
		||||
                        $$PWD/yacreader_options_dialog.h \
 | 
			
		||||
                        $$PWD/yacreader_spin_slider_widget.h \
 | 
			
		||||
                        $$PWD/yacreader_tool_bar_stretch.h \
 | 
			
		||||
						$$PWD/yacreader_busy_widget.h 
 | 
			
		||||
						
 | 
			
		||||
						 
 | 
			
		||||
SOURCES += $$PWD/help_about_dialog.cpp \
 | 
			
		||||
						 $$PWD/yacreader_field_edit.cpp \
 | 
			
		||||
                         $$PWD/yacreader_field_plain_text_edit.cpp \
 | 
			
		||||
                         $$PWD/yacreader_flow.cpp \
 | 
			
		||||
                         $$PWD/yacreader_flow_config_widget.cpp \
 | 
			
		||||
                         $$PWD/yacreader_gl_flow_config_widget.cpp \
 | 
			
		||||
                         $$PWD/yacreader_options_dialog.cpp \
 | 
			
		||||
                         $$PWD/yacreader_spin_slider_widget.cpp \
 | 
			
		||||
                         $$PWD/yacreader_tool_bar_stretch.cpp \
 | 
			
		||||
						$$PWD/yacreader_busy_widget.cpp
 | 
			
		||||
							
								
								
									
										41
									
								
								custom_widgets/custom_widgets_yacreaderlibrary.pri
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								custom_widgets/custom_widgets_yacreaderlibrary.pri
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,41 @@
 | 
			
		||||
INCLUDEPATH += $$PWD
 | 
			
		||||
DEPENDPATH += $$PWD
 | 
			
		||||
 | 
			
		||||
HEADERS += $$PWD/help_about_dialog.h \
 | 
			
		||||
						$$PWD/yacreader_field_edit.h \
 | 
			
		||||
                        $$PWD/yacreader_field_plain_text_edit.h \
 | 
			
		||||
                        $$PWD/yacreader_flow.h \
 | 
			
		||||
                        $$PWD/yacreader_flow_config_widget.h \
 | 
			
		||||
                        $$PWD/yacreader_gl_flow_config_widget.h \
 | 
			
		||||
                        $$PWD/yacreader_options_dialog.h \
 | 
			
		||||
                        $$PWD/yacreader_search_line_edit.h \
 | 
			
		||||
                        $$PWD/yacreader_spin_slider_widget.h \
 | 
			
		||||
                        $$PWD/yacreader_tool_bar_stretch.h \
 | 
			
		||||
						$$PWD/yacreader_titled_toolbar.h \
 | 
			
		||||
						$$PWD/yacreader_deleting_progress.h \
 | 
			
		||||
						$$PWD/yacreader_table_view.h \
 | 
			
		||||
						$$PWD/yacreader_sidebar.h \
 | 
			
		||||
						$$PWD/yacreader_library_list_widget.h \
 | 
			
		||||
						$$PWD/yacreader_library_item_widget.h \
 | 
			
		||||
						$$PWD/yacreader_treeview.h \
 | 
			
		||||
						$$PWD/yacreader_busy_widget.h 
 | 
			
		||||
						
 | 
			
		||||
						 
 | 
			
		||||
SOURCES += $$PWD/help_about_dialog.cpp \
 | 
			
		||||
						 $$PWD/yacreader_field_edit.cpp \
 | 
			
		||||
                         $$PWD/yacreader_field_plain_text_edit.cpp \
 | 
			
		||||
                         $$PWD/yacreader_flow.cpp \
 | 
			
		||||
                         $$PWD/yacreader_flow_config_widget.cpp \
 | 
			
		||||
                         $$PWD/yacreader_gl_flow_config_widget.cpp \
 | 
			
		||||
                         $$PWD/yacreader_options_dialog.cpp \
 | 
			
		||||
                         $$PWD/yacreader_search_line_edit.cpp \
 | 
			
		||||
                         $$PWD/yacreader_spin_slider_widget.cpp \
 | 
			
		||||
                         $$PWD/yacreader_tool_bar_stretch.cpp \
 | 
			
		||||
						 $$PWD/yacreader_titled_toolbar.cpp \
 | 
			
		||||
						 $$PWD/yacreader_deleting_progress.cpp \
 | 
			
		||||
						 $$PWD/yacreader_table_view.cpp \
 | 
			
		||||
						 $$PWD/yacreader_sidebar.cpp \
 | 
			
		||||
						$$PWD/yacreader_library_list_widget.cpp \
 | 
			
		||||
						$$PWD/yacreader_library_item_widget.cpp \
 | 
			
		||||
						$$PWD/yacreader_treeview.cpp \
 | 
			
		||||
						$$PWD/yacreader_busy_widget.cpp
 | 
			
		||||
							
								
								
									
										75
									
								
								custom_widgets/help_about_dialog.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										75
									
								
								custom_widgets/help_about_dialog.cpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +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;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										28
									
								
								custom_widgets/help_about_dialog.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								custom_widgets/help_about_dialog.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +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);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#endif // HELP_ABOUT_DIALOG_H
 | 
			
		||||
							
								
								
									
										187
									
								
								custom_widgets/yacreader_busy_widget.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										187
									
								
								custom_widgets/yacreader_busy_widget.cpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +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);
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										50
									
								
								custom_widgets/yacreader_busy_widget.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										50
									
								
								custom_widgets/yacreader_busy_widget.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +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
 | 
			
		||||
							
								
								
									
										38
									
								
								custom_widgets/yacreader_dark_menu.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								custom_widgets/yacreader_dark_menu.cpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +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();
 | 
			
		||||
	*/
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										14
									
								
								custom_widgets/yacreader_dark_menu.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								custom_widgets/yacreader_dark_menu.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +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);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#endif // YACREADER_DARK_MENU_H
 | 
			
		||||
							
								
								
									
										106
									
								
								custom_widgets/yacreader_deleting_progress.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										106
									
								
								custom_widgets/yacreader_deleting_progress.cpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +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);
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										26
									
								
								custom_widgets/yacreader_deleting_progress.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								custom_widgets/yacreader_deleting_progress.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +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
 | 
			
		||||
							
								
								
									
										39
									
								
								custom_widgets/yacreader_field_edit.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								custom_widgets/yacreader_field_edit.cpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +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);
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										23
									
								
								custom_widgets/yacreader_field_edit.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								custom_widgets/yacreader_field_edit.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +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;
 | 
			
		||||
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#endif // YACREADER_FIELD_EDIT_H
 | 
			
		||||
							
								
								
									
										53
									
								
								custom_widgets/yacreader_field_plain_text_edit.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										53
									
								
								custom_widgets/yacreader_field_plain_text_edit.cpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +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);
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										25
									
								
								custom_widgets/yacreader_field_plain_text_edit.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								custom_widgets/yacreader_field_plain_text_edit.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +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;
 | 
			
		||||
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#endif // YACREADER_FIELD_PLAIN_TEXT_EDIT_H
 | 
			
		||||
							
								
								
									
										23
									
								
								custom_widgets/yacreader_flow.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								custom_widgets/yacreader_flow.cpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,23 @@
 | 
			
		||||
#include "yacreader_flow.h"
 | 
			
		||||
 | 
			
		||||
#include <QMouseEvent>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
YACReaderFlow::YACReaderFlow(QWidget * parent,FlowType flowType) : PictureFlow(parent,flowType) {}
 | 
			
		||||
 | 
			
		||||
void YACReaderFlow::mousePressEvent(QMouseEvent* event)
 | 
			
		||||
{
 | 
			
		||||
	if(event->x() > (width()+slideSize().width())/2)
 | 
			
		||||
		showNext();
 | 
			
		||||
	else
 | 
			
		||||
		if(event->x() < (width()-slideSize().width())/2)
 | 
			
		||||
			showPrevious();
 | 
			
		||||
	//else (centered cover space)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void YACReaderFlow::mouseDoubleClickEvent(QMouseEvent* event)
 | 
			
		||||
{
 | 
			
		||||
	if((event->x() > (width()-slideSize().width())/2)&&(event->x() < (width()+slideSize().width())/2))
 | 
			
		||||
		emit selected(centerIndex());
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										21
									
								
								custom_widgets/yacreader_flow.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								custom_widgets/yacreader_flow.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +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);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#endif // YACREADER_FLOW_H
 | 
			
		||||
							
								
								
									
										54
									
								
								custom_widgets/yacreader_flow_config_widget.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										54
									
								
								custom_widgets/yacreader_flow_config_widget.cpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +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);
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										19
									
								
								custom_widgets/yacreader_flow_config_widget.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								custom_widgets/yacreader_flow_config_widget.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +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);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#endif // YACREADER_FLOW_CONFIG_WIDGET_H
 | 
			
		||||
							
								
								
									
										240
									
								
								custom_widgets/yacreader_gl_flow_config_widget.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										240
									
								
								custom_widgets/yacreader_gl_flow_config_widget.cpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +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);
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										51
									
								
								custom_widgets/yacreader_gl_flow_config_widget.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										51
									
								
								custom_widgets/yacreader_gl_flow_config_widget.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +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);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#endif // YACREADER_GL_FLOW_CONFIG_WIDGET_H
 | 
			
		||||
							
								
								
									
										155
									
								
								custom_widgets/yacreader_library_item_widget.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										155
									
								
								custom_widgets/yacreader_library_item_widget.cpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,155 @@
 | 
			
		||||
#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/libraryIcon.png");
 | 
			
		||||
	icon = new QLabel(this);
 | 
			
		||||
	icon->setPixmap(iconPixmap);
 | 
			
		||||
 | 
			
		||||
	nameLabel = new QLabel(name,this);
 | 
			
		||||
 | 
			
		||||
	options = new QToolButton(this);
 | 
			
		||||
	options->setIcon(QIcon(":/images/libraryOptions.png"));
 | 
			
		||||
	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/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;";
 | 
			
		||||
#else
 | 
			
		||||
	QString styleSheet = "color: white; background-color:#2E2E2E; font-weight:bold;";
 | 
			
		||||
#endif
 | 
			
		||||
	setStyleSheet(styleSheet);
 | 
			
		||||
 | 
			
		||||
	options->setHidden(false);
 | 
			
		||||
 | 
			
		||||
	QPixmap iconPixmap(":/images/libraryIconSelected.png");
 | 
			
		||||
	icon->setPixmap(iconPixmap);
 | 
			
		||||
 | 
			
		||||
	isSelected = true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void YACReaderLibraryItemWidget::setName(const QString & name)
 | 
			
		||||
{
 | 
			
		||||
	this->name = name;
 | 
			
		||||
	nameLabel->setText(name);
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										45
									
								
								custom_widgets/yacreader_library_item_widget.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										45
									
								
								custom_widgets/yacreader_library_item_widget.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +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
 | 
			
		||||
							
								
								
									
										128
									
								
								custom_widgets/yacreader_library_list_widget.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										128
									
								
								custom_widgets/yacreader_library_list_widget.cpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +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;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										37
									
								
								custom_widgets/yacreader_library_list_widget.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								custom_widgets/yacreader_library_list_widget.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +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
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										372
									
								
								custom_widgets/yacreader_options_dialog.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										372
									
								
								custom_widgets/yacreader_options_dialog.cpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,372 @@
 | 
			
		||||
#include "yacreader_options_dialog.h"
 | 
			
		||||
 | 
			
		||||
#include "yacreader_flow_config_widget.h"
 | 
			
		||||
#include "yacreader_gl_flow_config_widget.h"
 | 
			
		||||
#include "yacreader_spin_slider_widget.h"
 | 
			
		||||
#include "yacreader_global.h"
 | 
			
		||||
 | 
			
		||||
#include <QPushButton>
 | 
			
		||||
#include <QCheckBox>
 | 
			
		||||
#include <QRadioButton>
 | 
			
		||||
#include <QSlider>
 | 
			
		||||
#include <QSettings>
 | 
			
		||||
 | 
			
		||||
YACReaderOptionsDialog::YACReaderOptionsDialog(QWidget * parent)
 | 
			
		||||
	:QDialog(parent)
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
	sw = new YACReaderFlowConfigWidget(this);
 | 
			
		||||
	gl = new YACReaderGLFlowConfigWidget(this);
 | 
			
		||||
 | 
			
		||||
	accept = new QPushButton(tr("Save"));
 | 
			
		||||
	cancel = new QPushButton(tr("Cancel"));
 | 
			
		||||
 | 
			
		||||
	cancel->setDefault(true);
 | 
			
		||||
 | 
			
		||||
	connect(accept,SIGNAL(clicked()),this,SLOT(saveOptions()));
 | 
			
		||||
	connect(cancel,SIGNAL(clicked()),this,SLOT(restoreOptions())); //TODO fix this
 | 
			
		||||
	connect(cancel,SIGNAL(clicked()),this,SLOT(close()));
 | 
			
		||||
 | 
			
		||||
	useGL = new QCheckBox(tr("Use hardware acceleration (restart needed)"));
 | 
			
		||||
	connect(useGL,SIGNAL(stateChanged(int)),this,SLOT(saveUseGL(int)));
 | 
			
		||||
 | 
			
		||||
	//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()));
 | 
			
		||||
 | 
			
		||||
	//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)));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
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());
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void YACReaderOptionsDialog::saveOptions()
 | 
			
		||||
{
 | 
			
		||||
	emit(optionsChanged());
 | 
			
		||||
	close();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
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);
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
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);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void YACReaderOptionsDialog::restoreOptions(QSettings * settings)
 | 
			
		||||
{
 | 
			
		||||
	this->settings = settings;
 | 
			
		||||
 | 
			
		||||
	//FLOW CONFIG
 | 
			
		||||
 | 
			
		||||
	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;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
 | 
			
		||||
	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
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
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());
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
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);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void YACReaderOptionsDialog::setClassicConfig()
 | 
			
		||||
{
 | 
			
		||||
	settings->setValue(FLOW_TYPE_GL,CoverFlowLike);
 | 
			
		||||
 | 
			
		||||
	gl->setValues(presetYACReaderFlowClassicConfig);
 | 
			
		||||
 | 
			
		||||
	saveFlowParameters();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void YACReaderOptionsDialog::setStripeConfig()
 | 
			
		||||
{
 | 
			
		||||
	settings->setValue(FLOW_TYPE_GL,Strip);
 | 
			
		||||
 | 
			
		||||
	gl->setValues(presetYACReaderFlowStripeConfig);
 | 
			
		||||
 | 
			
		||||
	saveFlowParameters();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void YACReaderOptionsDialog::setOverlappedStripeConfig()
 | 
			
		||||
{
 | 
			
		||||
	settings->setValue(FLOW_TYPE_GL,StripOverlapped);
 | 
			
		||||
 | 
			
		||||
	gl->setValues(presetYACReaderFlowOverlappedStripeConfig);
 | 
			
		||||
 | 
			
		||||
	saveFlowParameters();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void YACReaderOptionsDialog::setModernConfig()
 | 
			
		||||
{
 | 
			
		||||
	settings->setValue(FLOW_TYPE_GL,Modern);
 | 
			
		||||
 | 
			
		||||
	gl->setValues(defaultYACReaderFlowConfig);
 | 
			
		||||
 | 
			
		||||
	saveFlowParameters();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void YACReaderOptionsDialog::setRouletteConfig()
 | 
			
		||||
{
 | 
			
		||||
	settings->setValue(FLOW_TYPE_GL,Roulette);
 | 
			
		||||
 | 
			
		||||
	gl->setValues(pressetYACReaderFlowDownConfig);
 | 
			
		||||
	
 | 
			
		||||
	saveFlowParameters();
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										61
									
								
								custom_widgets/yacreader_options_dialog.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										61
									
								
								custom_widgets/yacreader_options_dialog.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,61 @@
 | 
			
		||||
#ifndef YACREADER_OPTIONS_DIALOG_H
 | 
			
		||||
#define YACREADER_OPTIONS_DIALOG_H
 | 
			
		||||
 | 
			
		||||
#include <QDialog>
 | 
			
		||||
 | 
			
		||||
class YACReaderFlowConfigWidget;
 | 
			
		||||
class YACReaderGLFlowConfigWidget;
 | 
			
		||||
class QCheckBox;
 | 
			
		||||
class QPushButton;
 | 
			
		||||
class QSettings;
 | 
			
		||||
 | 
			
		||||
class YACReaderOptionsDialog : public QDialog
 | 
			
		||||
{
 | 
			
		||||
	Q_OBJECT
 | 
			
		||||
protected:
 | 
			
		||||
	YACReaderFlowConfigWidget * sw;
 | 
			
		||||
	YACReaderGLFlowConfigWidget * gl;
 | 
			
		||||
	QCheckBox * useGL;
 | 
			
		||||
 | 
			
		||||
	QPushButton * accept;
 | 
			
		||||
	QPushButton * cancel;
 | 
			
		||||
 | 
			
		||||
	QSettings * settings;
 | 
			
		||||
	QSettings * previousSettings;
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
	YACReaderOptionsDialog(QWidget * parent);
 | 
			
		||||
public slots:
 | 
			
		||||
	virtual void restoreOptions(QSettings * settings);
 | 
			
		||||
	virtual void saveOptions();
 | 
			
		||||
protected slots:
 | 
			
		||||
	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 setClassicConfigSW();
 | 
			
		||||
	virtual void setStripeConfigSW();
 | 
			
		||||
	virtual void setOverlappedStripeConfigSW();
 | 
			
		||||
	virtual void saveFlowParameters();
 | 
			
		||||
 | 
			
		||||
signals:
 | 
			
		||||
	void optionsChanged();
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#endif // YACREADER_OPTIONS_DIALOG_H
 | 
			
		||||
							
								
								
									
										55
									
								
								custom_widgets/yacreader_search_line_edit.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										55
									
								
								custom_widgets/yacreader_search_line_edit.cpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,55 @@
 | 
			
		||||
#include "yacreader_search_line_edit.h"
 | 
			
		||||
 | 
			
		||||
#include <QToolButton>
 | 
			
		||||
#include <QStyle>
 | 
			
		||||
#include <QLabel>
 | 
			
		||||
 | 
			
		||||
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 {border:none; background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #CACACA, stop: 0.15 #FFFFFF);; padding-left: %1px; padding-right: %2px; padding-bottom: 1px; margin-bottom: 0px;} ").arg(searchLabel->sizeHint().width() + frameWidth + 6).arg(clearButton->sizeHint().width() + frameWidth + 2));
 | 
			
		||||
#endif
 | 
			
		||||
	QSize msz = minimumSizeHint();
 | 
			
		||||
	setMinimumSize(qMax(msz.width(), clearButton->sizeHint().height() + frameWidth * 2 + 2),
 | 
			
		||||
				   qMax(msz.height(), clearButton->sizeHint().height() + frameWidth * 2 + 2));
 | 
			
		||||
 | 
			
		||||
#ifdef Q_OS_MAC
 | 
			
		||||
	setMaximumWidth(300);
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void YACReaderSearchLineEdit::resizeEvent(QResizeEvent *)
 | 
			
		||||
{
 | 
			
		||||
	QSize sz = clearButton->sizeHint();
 | 
			
		||||
	int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
 | 
			
		||||
	clearButton->move(rect().right() - frameWidth - sz.width(),
 | 
			
		||||
					  (rect().bottom() + 1 - sz.height())/2);
 | 
			
		||||
 | 
			
		||||
	QSize szl = searchLabel->sizeHint();
 | 
			
		||||
	searchLabel->move(6,(rect().bottom() + 1 - szl.height())/2);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void YACReaderSearchLineEdit::updateCloseButton(const QString& text)
 | 
			
		||||
{
 | 
			
		||||
	clearButton->setVisible(!text.isEmpty());
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										29
									
								
								custom_widgets/yacreader_search_line_edit.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								custom_widgets/yacreader_search_line_edit.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,29 @@
 | 
			
		||||
#ifndef YACREADER_SEARCH_LINE_EDIT_H
 | 
			
		||||
#define YACREADER_SEARCH_LINE_EDIT_H
 | 
			
		||||
 | 
			
		||||
#include <QLineEdit>
 | 
			
		||||
 | 
			
		||||
class QToolButton;
 | 
			
		||||
class QLabel;
 | 
			
		||||
 | 
			
		||||
class YACReaderSearchLineEdit : public QLineEdit
 | 
			
		||||
{
 | 
			
		||||
	Q_OBJECT
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
	YACReaderSearchLineEdit(QWidget *parent = 0);
 | 
			
		||||
 | 
			
		||||
protected:
 | 
			
		||||
	void resizeEvent(QResizeEvent *);
 | 
			
		||||
 | 
			
		||||
private slots:
 | 
			
		||||
	void updateCloseButton(const QString &text);
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
	QToolButton *clearButton;
 | 
			
		||||
	QLabel * searchLabel;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#endif // YACREADER_SEARCH_LINE_EDIT_H
 | 
			
		||||
							
								
								
									
										130
									
								
								custom_widgets/yacreader_sidebar.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										130
									
								
								custom_widgets/yacreader_sidebar.cpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,130 @@
 | 
			
		||||
#include "yacreader_sidebar.h"
 | 
			
		||||
 | 
			
		||||
#include <QPainter>
 | 
			
		||||
#include <QLayout>
 | 
			
		||||
 | 
			
		||||
#include "yacreader_treeview.h"
 | 
			
		||||
#include "yacreader_library_list_widget.h"
 | 
			
		||||
#include "yacreader_search_line_edit.h"
 | 
			
		||||
#include "yacreader_titled_toolbar.h"
 | 
			
		||||
 | 
			
		||||
YACReaderSideBar::YACReaderSideBar(QWidget *parent) :
 | 
			
		||||
	QWidget(parent)
 | 
			
		||||
{
 | 
			
		||||
	setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Minimum);
 | 
			
		||||
 | 
			
		||||
	//widgets
 | 
			
		||||
	foldersView = new YACReaderTreeView;
 | 
			
		||||
	selectedLibrary = new YACReaderLibraryListWidget;
 | 
			
		||||
	foldersFilter = new YACReaderSearchLineEdit();
 | 
			
		||||
 | 
			
		||||
	librariesTitle = new YACReaderTitledToolBar(tr("LIBRARIES"));
 | 
			
		||||
 | 
			
		||||
	foldersTitle = new YACReaderTitledToolBar(tr("FOLDERS"));
 | 
			
		||||
 | 
			
		||||
	selectedLibrary->setContextMenuPolicy(Qt::ActionsContextMenu);
 | 
			
		||||
	selectedLibrary->setAttribute(Qt::WA_MacShowFocusRect,false);
 | 
			
		||||
	selectedLibrary->setFocusPolicy(Qt::NoFocus);
 | 
			
		||||
 | 
			
		||||
	foldersFilter->setAttribute(Qt::WA_MacShowFocusRect,false);
 | 
			
		||||
	foldersFilter->setPlaceholderText(tr("Search folders and comics"));
 | 
			
		||||
 | 
			
		||||
	//layout
 | 
			
		||||
	QVBoxLayout * l = new QVBoxLayout;
 | 
			
		||||
 | 
			
		||||
	l->setContentsMargins(0,0,0,0);
 | 
			
		||||
#ifndef Q_OS_MAC
 | 
			
		||||
	l->addSpacing(5);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
	l->addWidget(librariesTitle);
 | 
			
		||||
 | 
			
		||||
#ifndef Q_OS_MAC
 | 
			
		||||
	{QWidget * w = new QWidget();
 | 
			
		||||
	w->setStyleSheet("QWidget {border:none; border-bottom:1px solid #636363;border-top:1px solid #292929;}");
 | 
			
		||||
	w->setMinimumHeight(2);
 | 
			
		||||
 | 
			
		||||
	l->addSpacing(4);
 | 
			
		||||
 | 
			
		||||
	l->addWidget(w);}
 | 
			
		||||
 | 
			
		||||
	l->addSpacing(3);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
	l->addWidget(selectedLibrary);
 | 
			
		||||
 | 
			
		||||
#ifndef Q_OS_MAC
 | 
			
		||||
	l->addSpacing(6);
 | 
			
		||||
 | 
			
		||||
	{QWidget * w = new QWidget();
 | 
			
		||||
	w->setStyleSheet("QWidget {border:none; border-bottom:1px solid #636363;border-top:1px solid #292929;}");
 | 
			
		||||
	w->setMinimumHeight(2);
 | 
			
		||||
 | 
			
		||||
	l->addSpacing(5);
 | 
			
		||||
 | 
			
		||||
	l->addWidget(w);}
 | 
			
		||||
 | 
			
		||||
	l->addSpacing(4);
 | 
			
		||||
#else
 | 
			
		||||
	l->addSpacing(6);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
	l->addWidget(foldersTitle);
 | 
			
		||||
 | 
			
		||||
#ifndef Q_OS_MAC
 | 
			
		||||
	{QWidget * w = new QWidget();
 | 
			
		||||
	w->setStyleSheet("QWidget {border:none; border-bottom:1px solid #636363;border-top:1px solid #292929;}");
 | 
			
		||||
	w->setMinimumHeight(2);
 | 
			
		||||
 | 
			
		||||
	l->addSpacing(4);
 | 
			
		||||
 | 
			
		||||
	l->addWidget(w);}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	l->addSpacing(4);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
	l->addWidget(foldersView);
 | 
			
		||||
 | 
			
		||||
	l->addWidget(foldersFilter);
 | 
			
		||||
 | 
			
		||||
	l->setSpacing(0);
 | 
			
		||||
	setLayout(l);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void YACReaderSideBar::paintEvent(QPaintEvent * event)
 | 
			
		||||
{
 | 
			
		||||
	Q_UNUSED(event)
 | 
			
		||||
 | 
			
		||||
#ifdef Q_OS_MAC
 | 
			
		||||
	QPainter painter(this);
 | 
			
		||||
 | 
			
		||||
	QLinearGradient lG(0,0,0,height());
 | 
			
		||||
 | 
			
		||||
	lG.setColorAt(0,QColor("#E8ECF1"));
 | 
			
		||||
	lG.setColorAt(1,QColor("#D1D8E0"));
 | 
			
		||||
 | 
			
		||||
	painter.fillRect(0,0,width(),height(),lG);
 | 
			
		||||
#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);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QSize YACReaderSideBar::sizeHint() const
 | 
			
		||||
{
 | 
			
		||||
	return QSize(275,200);
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										34
									
								
								custom_widgets/yacreader_sidebar.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								custom_widgets/yacreader_sidebar.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,34 @@
 | 
			
		||||
#ifndef YACREADER_SIDEBAR_H
 | 
			
		||||
#define YACREADER_SIDEBAR_H
 | 
			
		||||
 | 
			
		||||
#include <QWidget>
 | 
			
		||||
 | 
			
		||||
class YACReaderTreeView;
 | 
			
		||||
class YACReaderLibraryListWidget;
 | 
			
		||||
class YACReaderSearchLineEdit;
 | 
			
		||||
class YACReaderTitledToolBar;
 | 
			
		||||
class YACReaderTitledToolBar;
 | 
			
		||||
 | 
			
		||||
class YACReaderSideBar : public QWidget
 | 
			
		||||
{
 | 
			
		||||
	Q_OBJECT
 | 
			
		||||
public:
 | 
			
		||||
	explicit YACReaderSideBar(QWidget *parent = 0);
 | 
			
		||||
	QSize sizeHint() const;
 | 
			
		||||
 | 
			
		||||
	YACReaderTreeView * foldersView;
 | 
			
		||||
	YACReaderLibraryListWidget * selectedLibrary;
 | 
			
		||||
	YACReaderSearchLineEdit * foldersFilter;
 | 
			
		||||
	YACReaderTitledToolBar * librariesTitle;
 | 
			
		||||
	YACReaderTitledToolBar * foldersTitle;
 | 
			
		||||
	
 | 
			
		||||
signals:
 | 
			
		||||
	
 | 
			
		||||
public slots:
 | 
			
		||||
 | 
			
		||||
protected:
 | 
			
		||||
	void paintEvent(QPaintEvent *);
 | 
			
		||||
	
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#endif // YACREADER_SIDEBAR_H
 | 
			
		||||
							
								
								
									
										130
									
								
								custom_widgets/yacreader_social_dialog.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										130
									
								
								custom_widgets/yacreader_social_dialog.cpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +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()));
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										28
									
								
								custom_widgets/yacreader_social_dialog.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								custom_widgets/yacreader_social_dialog.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +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
 | 
			
		||||
							
								
								
									
										93
									
								
								custom_widgets/yacreader_spin_slider_widget.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										93
									
								
								custom_widgets/yacreader_spin_slider_widget.cpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +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);
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										35
									
								
								custom_widgets/yacreader_spin_slider_widget.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								custom_widgets/yacreader_spin_slider_widget.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +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);
 | 
			
		||||
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#endif // YACREADER_SPIN_SLIDER_WIDGET_H
 | 
			
		||||
							
								
								
									
										422
									
								
								custom_widgets/yacreader_table_view.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										422
									
								
								custom_widgets/yacreader_table_view.cpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,422 @@
 | 
			
		||||
#include "yacreader_table_view.h"
 | 
			
		||||
 | 
			
		||||
#include <QHeaderView>
 | 
			
		||||
#include <QResizeEvent>
 | 
			
		||||
#include <QPropertyAnimation>
 | 
			
		||||
#include <QPainter>
 | 
			
		||||
 | 
			
		||||
#include "tableitem.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<61>malo
 | 
			
		||||
#else
 | 
			
		||||
	verticalHeader()->setClickable(false); //TODO comportamiento an<61>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);*/
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
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();
 | 
			
		||||
 | 
			
		||||
	QTableView::mouseMoveEvent(event);
 | 
			
		||||
}
 | 
			
		||||
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);
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
void YACReaderTableView::leaveEvent(QEvent * event)
 | 
			
		||||
{
 | 
			
		||||
	closeRatingEditor();
 | 
			
		||||
	event->accept();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
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 = ((TableItem *)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 = ((TableItem *)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 = ((TableItem *)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;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										124
									
								
								custom_widgets/yacreader_table_view.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										124
									
								
								custom_widgets/yacreader_table_view.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,124 @@
 | 
			
		||||
#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);
 | 
			
		||||
 | 
			
		||||
	bool editing;
 | 
			
		||||
	QModelIndex currentIndexEditing;
 | 
			
		||||
	QWidget * myeditor;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
//---
 | 
			
		||||
 | 
			
		||||
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
 | 
			
		||||
							
								
								
									
										112
									
								
								custom_widgets/yacreader_titled_toolbar.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										112
									
								
								custom_widgets/yacreader_titled_toolbar.cpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,112 @@
 | 
			
		||||
#include "yacreader_titled_toolbar.h"
 | 
			
		||||
 | 
			
		||||
#include <QHBoxLayout>
 | 
			
		||||
#include <QLabel>
 | 
			
		||||
#include <QPixmap>
 | 
			
		||||
#include <QToolButton>
 | 
			
		||||
#include <QGraphicsDropShadowEffect>
 | 
			
		||||
#include <QPainter>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
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());
 | 
			
		||||
	//TODO find where is the '3' comming from?
 | 
			
		||||
	drawTextEffect(&painter, QPoint(contentsMargins().left(), 1));
 | 
			
		||||
	drawText(&painter, QPoint(contentsMargins().left(), 0));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void DropShadowLabel::setColor(const QColor & color)
 | 
			
		||||
{
 | 
			
		||||
	textColor = color;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
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("#707E8C"));
 | 
			
		||||
	nameLabel->setDropShadowColor(QColor("#F9FAFB"));
 | 
			
		||||
#else
 | 
			
		||||
	QString nameLabelStyleSheet = "QLabel {padding:0 0 0 10px; margin:0px; font-size:11px; font-weight:bold;}";
 | 
			
		||||
	nameLabel->setColor(QColor("#BDBFBF"));
 | 
			
		||||
	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());
 | 
			
		||||
 | 
			
		||||
	QToolButton * tb = new QToolButton(this);
 | 
			
		||||
	tb->setDefaultAction(action);
 | 
			
		||||
	tb->setIconSize(QSize(16,16));
 | 
			
		||||
	tb->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum);
 | 
			
		||||
	//tb->setStyleSheet("QToolButton:hover {background-color:#C5C5C5;}");
 | 
			
		||||
 | 
			
		||||
	mainLayout->addWidget(tb);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void YACReaderTitledToolBar::addSpacing(int spacing)
 | 
			
		||||
{
 | 
			
		||||
	QHBoxLayout * mainLayout = dynamic_cast<QHBoxLayout *>(layout());
 | 
			
		||||
 | 
			
		||||
	mainLayout->addSpacing(spacing);
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										45
									
								
								custom_widgets/yacreader_titled_toolbar.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										45
									
								
								custom_widgets/yacreader_titled_toolbar.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,45 @@
 | 
			
		||||
#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);
 | 
			
		||||
private:
 | 
			
		||||
	DropShadowLabel * nameLabel;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#endif // YACREADER_TITLED_TOOLBAR_H
 | 
			
		||||
							
								
								
									
										0
									
								
								custom_widgets/yacreader_tool_bar_stretch.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								custom_widgets/yacreader_tool_bar_stretch.cpp
									
									
									
									
									
										Normal file
									
								
							
							
								
								
									
										18
									
								
								custom_widgets/yacreader_tool_bar_stretch.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								custom_widgets/yacreader_tool_bar_stretch.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,18 @@
 | 
			
		||||
#ifndef YACREADER_TOOL_BAR_STRETCH_H
 | 
			
		||||
#define YACREADER_TOOL_BAR_STRETCH_H
 | 
			
		||||
 | 
			
		||||
#include <QWidget>
 | 
			
		||||
#include <QHBoxLayout>
 | 
			
		||||
 | 
			
		||||
class QToolBarStretch : public QWidget
 | 
			
		||||
{
 | 
			
		||||
public:
 | 
			
		||||
	QToolBarStretch(QWidget * parent=0):QWidget(parent)
 | 
			
		||||
	{
 | 
			
		||||
		QHBoxLayout * l= new QHBoxLayout();
 | 
			
		||||
		l->addStretch();
 | 
			
		||||
		setLayout(l);
 | 
			
		||||
	}
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#endif // YACREADER_TOOL_BAR_STRETCH_H
 | 
			
		||||
							
								
								
									
										80
									
								
								custom_widgets/yacreader_treeview.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										80
									
								
								custom_widgets/yacreader_treeview.cpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,80 @@
 | 
			
		||||
#include "yacreader_treeview.h"
 | 
			
		||||
#include "treeitem.h"
 | 
			
		||||
#include "treemodel.h"
 | 
			
		||||
 | 
			
		||||
#include <QHeaderView>
 | 
			
		||||
#include <QPainter>
 | 
			
		||||
 | 
			
		||||
YACReaderTreeView::YACReaderTreeView(QWidget *parent) :
 | 
			
		||||
    QTreeView(parent)
 | 
			
		||||
{
 | 
			
		||||
    setContextMenuPolicy(Qt::ActionsContextMenu);
 | 
			
		||||
    setContextMenuPolicy(Qt::ActionsContextMenu);
 | 
			
		||||
    header()->hide();
 | 
			
		||||
    setUniformRowHeights(true);
 | 
			
		||||
    setSelectionBehavior(QAbstractItemView::SelectRows);
 | 
			
		||||
    setAttribute(Qt::WA_MacShowFocusRect,false);
 | 
			
		||||
 | 
			
		||||
    setItemDelegate(new YACReaderTreeViewItemDeletegate(this));
 | 
			
		||||
 | 
			
		||||
#ifdef Q_OS_MAC
 | 
			
		||||
    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/expanded_branch_osx.png');}"
 | 
			
		||||
                               "QTreeView::branch:closed:selected:has-children {image: url(':/images/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/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/collapsed_branch_selected.png');}"
 | 
			
		||||
 | 
			
		||||
 "QTreeView::branch:open:has-children:!has-siblings,QTreeView::branch:open:has-children:has-siblings  {border-image: none;image: url(':/images/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/expanded_branch_selected.png');}"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                               );
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
YACReaderTreeViewItemDeletegate::YACReaderTreeViewItemDeletegate(QObject *parent)
 | 
			
		||||
    :QStyledItemDelegate(parent)
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void YACReaderTreeViewItemDeletegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
 | 
			
		||||
{
 | 
			
		||||
    TreeItem * item = static_cast<TreeItem *>(index.internalPointer());
 | 
			
		||||
 | 
			
		||||
    if(!item->data(TreeModel::Completed).toBool())
 | 
			
		||||
    {
 | 
			
		||||
        painter->save();
 | 
			
		||||
#ifdef Q_OS_MAC
 | 
			
		||||
        painter->setBrush(QBrush(QColor(85,95,127)));
 | 
			
		||||
#else
 | 
			
		||||
        painter->setBrush(QBrush(QColor(237,197,24)));
 | 
			
		||||
#endif
 | 
			
		||||
        painter->setPen(QPen(QBrush(),0));
 | 
			
		||||
        painter->drawRect(0,option.rect.y(),2,option.rect.height());
 | 
			
		||||
        painter->restore();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    QStyledItemDelegate::paint(painter, option, index);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										27
									
								
								custom_widgets/yacreader_treeview.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								custom_widgets/yacreader_treeview.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,27 @@
 | 
			
		||||
#ifndef YACREADER_TREEVIEW_H
 | 
			
		||||
#define YACREADER_TREEVIEW_H
 | 
			
		||||
 | 
			
		||||
#include <QTreeView>
 | 
			
		||||
#include <QStyledItemDelegate>
 | 
			
		||||
 | 
			
		||||
class YACReaderTreeView : public QTreeView
 | 
			
		||||
{
 | 
			
		||||
    Q_OBJECT
 | 
			
		||||
public:
 | 
			
		||||
    explicit YACReaderTreeView(QWidget *parent = 0);
 | 
			
		||||
    
 | 
			
		||||
signals:
 | 
			
		||||
    
 | 
			
		||||
public slots:
 | 
			
		||||
    
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
class YACReaderTreeViewItemDeletegate: public QStyledItemDelegate
 | 
			
		||||
{
 | 
			
		||||
    Q_OBJECT
 | 
			
		||||
public:
 | 
			
		||||
    explicit YACReaderTreeViewItemDeletegate(QObject *parent = 0);
 | 
			
		||||
    void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#endif // YACREADER_TREEVIEW_H
 | 
			
		||||
		Reference in New Issue
	
	Block a user