Merge pull request #277 from YACReader/feature/qt6-migration

Feature: qt6 migration (part 1: remove all qt5.15 deprecations)
This commit is contained in:
Luis Ángel San Martín 2021-10-24 09:53:12 +02:00 committed by GitHub
commit 7268de0197
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
111 changed files with 660 additions and 1345 deletions

View File

@ -70,6 +70,8 @@ macx {
QT += network widgets core multimedia svg
greaterThan(QT_MAJOR_VERSION, 5): QT += openglwidgets core5compat
#CONFIG += release
CONFIG -= flat

View File

@ -3,9 +3,9 @@
#include <QGridLayout>
#include <QLabel>
#include <QApplication>
#include <QDesktopWidget>
#include <QFrame>
#include <QImage>
#include <QScreen>
#include "bookmarks.h"
@ -32,7 +32,12 @@ BookmarksDialog::BookmarksDialog(QWidget *parent)
label->setStyleSheet(labelsStyle);
}
int heightDesktopResolution = QApplication::desktop()->screenGeometry().height();
QScreen *screen = parent != nullptr ? parent->window()->screen() : nullptr;
if (screen == nullptr) {
screen = QApplication::screens().constFirst();
}
int heightDesktopResolution = screen != nullptr ? screen->size().height() : 600;
int height, width;
height = heightDesktopResolution * 0.50;
width = height * 0.65;
@ -85,7 +90,7 @@ BookmarksDialog::BookmarksDialog(QWidget *parent)
QPalette Pal(palette());
// set black background
Pal.setColor(QPalette::Background, QColor("#454545"));
Pal.setColor(QPalette::Window, QColor(0x454545));
this->setAutoFillBackground(true);
this->setPalette(Pal);
@ -133,7 +138,7 @@ bool BookmarksDialog::eventFilter(QObject *obj, QEvent *event)
{
if (event->type() == QEvent::MouseButtonPress) {
if (obj == images.at(0)) {
emit(goToPage(lastPage));
emit goToPage(lastPage);
close();
event->accept();
}
@ -142,7 +147,7 @@ bool BookmarksDialog::eventFilter(QObject *obj, QEvent *event)
bool b;
int page = pages.at(i)->text().toInt(&b) - 1;
if (b) {
emit(goToPage(page));
emit goToPage(page);
close();
}
event->accept();

View File

@ -61,7 +61,7 @@ void GoToDialog::goTo()
{
unsigned int page = pageNumber->text().toInt();
if (page >= 1 && page <= v->top()) {
emit(goToPage(page - 1));
emit goToPage(page - 1);
close();
}
}

View File

@ -195,14 +195,14 @@ void GoToFlow::updateImageData()
void GoToFlow::wheelEvent(QWheelEvent *event)
{
if (event->delta() < 0)
if (event->angleDelta().y() < 0)
flow->showNext();
else
flow->showPrevious();
event->accept();
}
void GoToFlow::setFlowType(FlowType flowType)
void GoToFlow::setFlowType(YACReader::FlowType flowType)
{
flow->setFlowType(flowType);
}

View File

@ -60,7 +60,7 @@ public slots:
void reset() override;
void setNumSlides(unsigned int slides) override;
void setImageReady(int index, const QByteArray &image) override;
void setFlowType(FlowType flowType) override;
void setFlowType(YACReader::FlowType flowType) override;
void updateConfig(QSettings *settings) override;
void setFlowRightToLeft(bool b) override;
};

View File

@ -24,7 +24,7 @@ public:
void setNumSlides(unsigned int slides) override;
void setImageReady(int index, const QByteArray &image) override;
void updateConfig(QSettings *settings);
void updateConfig(QSettings *settings) override;
void setFlowRightToLeft(bool b) override;
private:

View File

@ -32,8 +32,8 @@ GoToFlowToolBar::GoToFlowToolBar(QWidget *parent)
" border-radius: 1px;"
"}");
connect(slider, &QSlider::valueChanged, this, [&](int v) { emit(setCenter(v)); });
connect(slider, &QSlider::valueChanged, this, [=](int v) { emit(setPage(v)); });
connect(slider, &QSlider::valueChanged, this, &GoToFlowToolBar::setCenter);
connect(slider, &QSlider::valueChanged, this, &GoToFlowToolBar::setPage);
pageHint = new QLabel("<b>" + tr("Page : ") + "</b>", this);
v = new QIntValidator(this);
@ -71,7 +71,7 @@ GoToFlowToolBar::GoToFlowToolBar(QWidget *parent)
connect(goToButton, &QPushButton::clicked, this, &GoToFlowToolBar::goTo);
normalLayout->setMargin(0);
normalLayout->setContentsMargins(0, 0, 0, 0);
normalLayout->setSpacing(0);
normalLayout->addStretch();
normalLayout->addWidget(pageHint);
@ -93,7 +93,7 @@ GoToFlowToolBar::GoToFlowToolBar(QWidget *parent)
void GoToFlowToolBar::paintEvent(QPaintEvent *)
{
QPainter painter(this);
painter.fillRect(0, 0, width(), height(), QColor("#99000000"));
painter.fillRect(0, 0, width(), height(), QColor(0x99000000));
}
void GoToFlowToolBar::setPage(int pageNumber)
@ -112,14 +112,14 @@ void GoToFlowToolBar::goTo()
{
unsigned int page = edit->text().toInt();
if (page >= 1 && page <= v->top()) {
emit(goToPage(page - 1));
emit goToPage(page - 1);
}
}
void GoToFlowToolBar::centerSlide()
{
if (edit->text().toInt() != 0)
emit(setCenter(edit->text().toInt() - 1));
emit setCenter(edit->text().toInt() - 1);
}
void GoToFlowToolBar::updateOptions()

View File

@ -12,7 +12,7 @@ GoToFlowWidget::GoToFlowWidget(QWidget *parent)
: QWidget(parent)
{
mainLayout = new QVBoxLayout(this);
mainLayout->setMargin(0);
mainLayout->setContentsMargins(0, 0, 0, 0);
mainLayout->setSpacing(0);
toolBar = new GoToFlowToolBar(this);

View File

@ -25,7 +25,7 @@ public slots:
virtual void reset() = 0;
virtual void centerSlide(int slide) = 0;
virtual void setPageNumber(int page);
virtual void setFlowType(FlowType flowType) = 0;
virtual void setFlowType(YACReader::FlowType flowType) = 0;
virtual void setNumSlides(unsigned int slides) = 0;
virtual void setImageReady(int index, const QByteArray &image) = 0;
virtual void updateSize();

View File

@ -38,9 +38,9 @@ void MagnifyingGlass::updateImage(int x, int y)
int zoomHeight = static_cast<int>(height() * zoomLevel);
auto p = (Viewer *)parent();
int currentPos = p->verticalScrollBar()->sliderPosition();
const QPixmap *image = p->pixmap();
int iWidth = image->width();
int iHeight = image->height();
const QPixmap image = p->pixmap();
int iWidth = image.width();
int iHeight = image.height();
float wFactor = static_cast<float>(iWidth) / p->widget()->width();
float hFactor = static_cast<float>(iHeight) / p->widget()->height();
zoomWidth *= wFactor;
@ -67,12 +67,12 @@ void MagnifyingGlass::updateImage(int x, int y)
outImage = true;
}
if (xp + zoomWidth >= image->width()) {
zw -= xp + zw - image->width();
if (xp + zoomWidth >= image.width()) {
zw -= xp + zw - image.width();
outImage = true;
}
if (yp + zoomHeight >= image->height()) {
zh -= yp + zh - image->height();
if (yp + zoomHeight >= image.height()) {
zh -= yp + zh - image.height();
outImage = true;
}
if (outImage) {
@ -81,11 +81,11 @@ void MagnifyingGlass::updateImage(int x, int y)
img.fill(Configuration::getConfiguration().getBackgroundColor());
if (zw > 0 && zh > 0) {
QPainter painter(&img);
painter.drawPixmap(xOffset, yOffset, image->copy(xp, yp, zw, zh));
painter.drawPixmap(xOffset, yOffset, image.copy(xp, yp, zw, zh));
}
setPixmap(QPixmap().fromImage(img));
} else
setPixmap(image->copy(xp, yp, zoomWidth, zoomHeight));
setPixmap(image.copy(xp, yp, zoomWidth, zoomHeight));
} else {
int xp = static_cast<int>(((x - p->widget()->pos().x()) * wFactor) - zoomWidth / 2);
int yp = static_cast<int>((y + currentPos) * hFactor - zoomHeight / 2);
@ -108,12 +108,12 @@ void MagnifyingGlass::updateImage(int x, int y)
outImage = true;
}
if (xp + zoomWidth >= image->width()) {
zw -= xp + zw - image->width();
if (xp + zoomWidth >= image.width()) {
zw -= xp + zw - image.width();
outImage = true;
}
if (yp + zoomHeight >= image->height()) {
zh -= yp + zh - image->height();
if (yp + zoomHeight >= image.height()) {
zh -= yp + zh - image.height();
outImage = true;
}
if (outImage) {
@ -122,11 +122,11 @@ void MagnifyingGlass::updateImage(int x, int y)
img.fill(Configuration::getConfiguration().getBackgroundColor());
if (zw > 0 && zh > 0) {
QPainter painter(&img);
painter.drawPixmap(xOffset, yOffset, image->copy(xp, yp, zw, zh));
painter.drawPixmap(xOffset, yOffset, image.copy(xp, yp, zw, zh));
}
setPixmap(QPixmap().fromImage(img));
} else
setPixmap(image->copy(xp, yp, zoomWidth, zoomHeight));
setPixmap(image.copy(xp, yp, zoomWidth, zoomHeight));
}
move(static_cast<int>(x - float(width()) / 2), static_cast<int>(y - float(height()) / 2));
}
@ -144,28 +144,28 @@ void MagnifyingGlass::wheelEvent(QWheelEvent *event)
switch (event->modifiers()) {
// size
case Qt::NoModifier:
if (event->delta() < 0)
if (event->angleDelta().y() < 0)
sizeUp();
else
sizeDown();
break;
// size height
case Qt::ControlModifier:
if (event->delta() < 0)
if (event->angleDelta().y() < 0)
heightUp();
else
heightDown();
break;
// size width
case Qt::AltModifier:
if (event->delta() < 0)
if (event->angleDelta().y() < 0)
widthUp();
else
widthDown();
break;
// zoom level
case Qt::ShiftModifier:
if (event->delta() < 0)
if (event->angleDelta().y() < 0)
zoomIn();
else
zoomOut();

View File

@ -26,7 +26,6 @@
#include <algorithm>
#include <QApplication>
#include <QCoreApplication>
#include <QDesktopWidget>
#include <QToolButton>
#include <QMenu>
#include <QFileDialog>
@ -146,8 +145,13 @@ void MainWindowViewer::setupUI()
connect(viewer, &Viewer::openPreviousComic, this, &MainWindowViewer::openPreviousComic);
setCentralWidget(viewer);
int heightDesktopResolution = QApplication::desktop()->screenGeometry().height();
int widthDesktopResolution = QApplication::desktop()->screenGeometry().width();
QScreen *screen = window()->screen();
if (screen == nullptr) {
screen = QApplication::screens().constFirst();
}
int heightDesktopResolution = screen != nullptr ? screen->size().height() : 600;
int widthDesktopResolution = screen != nullptr ? screen->size().height() : 1024;
int height, width;
height = static_cast<int>(heightDesktopResolution * 0.84);
width = static_cast<int>(height * 0.70);
@ -854,7 +858,7 @@ void MainWindowViewer::open(QString path, ComicDB &comic, QList<ComicDB> &siblin
optionsDialog->setFilters(currentComicDB.info.brightness, currentComicDB.info.contrast, currentComicDB.info.gamma);
}
void MainWindowViewer::open(QString path, qint64 comicId, qint64 libraryId, OpenComicSource source)
void MainWindowViewer::open(QString path, qint64 comicId, qint64 libraryId, YACReader::OpenComicSource source)
{
currentDirectory = path;
@ -974,9 +978,10 @@ void MainWindowViewer::saveImage()
if (!pathFile.isEmpty()) {
QFileInfo fi(pathFile);
currentDirectoryImgDest = fi.absolutePath();
const QPixmap *p = viewer->pixmap();
if (p != nullptr)
p->save(pathFile);
const QPixmap p = viewer->pixmap();
if (!p.isNull()) {
p.save(pathFile);
}
}
}

View File

@ -35,7 +35,7 @@ class MainWindowViewer : public QMainWindow
public slots:
void open();
void open(QString path, ComicDB &comic, QList<ComicDB> &siblings);
void open(QString path, qint64 comicId, qint64 libraryId, OpenComicSource source);
void open(QString path, qint64 comicId, qint64 libraryId, YACReader::OpenComicSource source);
void openFolder();
void openRecent();
void openLatestComic();

View File

@ -7,7 +7,7 @@ NotificationsLabelWidget::NotificationsLabelWidget(QWidget *parent)
{
auto layout = new QVBoxLayout;
layout->setSpacing(0);
layout->setMargin(0);
layout->setContentsMargins(0, 0, 0, 0);
setAttribute(Qt::WA_LayoutUsesWidgetRect, true);
effect = new QGraphicsOpacityEffect(this);
@ -47,7 +47,7 @@ void NotificationsLabelWidget::paintEvent(QPaintEvent *)
QPainterPath path;
path.addRoundedRect(QRectF(0, 0, width(), height()), 5.0, 5.0);
painter.setPen(Qt::NoPen);
painter.fillPath(path, QColor("#BB000000"));
painter.fillPath(path, QColor(0xBB000000));
painter.drawPath(path);
}

View File

@ -137,10 +137,10 @@ OptionsDialog::OptionsDialog(QWidget *parent)
auto scaleBox = new QGroupBox(tr("Fit options"));
auto scaleLayout = new QVBoxLayout();
scaleCheckbox = new QCheckBox(tr("Enlarge images to fit width/height"));
connect(scaleCheckbox, &QCheckBox::clicked,
connect(scaleCheckbox, &QCheckBox::clicked, scaleCheckbox,
[=](bool checked) {
Configuration::getConfiguration().setEnlargeImages(checked);
emit(changedImageOptions());
emit changedImageOptions();
});
scaleLayout->addWidget(scaleCheckbox);
@ -150,10 +150,10 @@ OptionsDialog::OptionsDialog(QWidget *parent)
auto doublePageBox = new QGroupBox(tr("Double Page options"));
auto doublePageBoxLayout = new QVBoxLayout();
coverSPCheckBox = new QCheckBox(tr("Show covers as single page"));
connect(coverSPCheckBox, &QCheckBox::clicked,
connect(coverSPCheckBox, &QCheckBox::clicked, coverSPCheckBox,
[=](bool checked) {
settings->setValue(COVER_IS_SP, checked);
emit(changedImageOptions());
emit changedImageOptions();
});
doublePageBoxLayout->addWidget(coverSPCheckBox);
@ -262,7 +262,7 @@ void OptionsDialog::updateColor(const QColor &color)
settings->setValue(BACKGROUND_COLOR, color);
emit(changedOptions());
emit changedOptions();
}
void OptionsDialog::brightnessChanged(int value)

View File

@ -9,10 +9,15 @@ PageLabelWidget::PageLabelWidget(QWidget *parent)
animation->setDuration(150);
animation->setEndValue(QPoint((parent->geometry().size().width() - this->width()), -this->height()));
int verticalRes = QApplication::desktop()->screenGeometry().height();
QScreen *screen = parent != nullptr ? parent->window()->screen() : nullptr;
if (screen == nullptr) {
screen = QApplication::screens().constFirst();
}
int verticalRes = screen != nullptr ? screen->size().height() : 600;
auto layout = new QHBoxLayout;
layout->setMargin(0);
layout->setContentsMargins(0, 0, 0, 0);
setContentsMargins(0, 0, 0, 0);
QSize labelSize;
@ -82,7 +87,7 @@ void PageLabelWidget::paintEvent(QPaintEvent *)
{
QPainter painter(this);
painter.fillRect(0, 0, width(), height(), QColor("#BB000000"));
painter.fillRect(0, 0, width(), height(), QColor(0xBB000000));
}
void PageLabelWidget::updatePosition()

View File

@ -348,7 +348,7 @@ void PageRender::run()
QImage img;
img.loadFromData(data);
if (degrees > 0) {
QMatrix m;
QTransform m;
m.rotate(degrees);
img = img.transformed(m, Qt::SmoothTransformation);
}

View File

@ -6,7 +6,10 @@
#include <QPixmap>
#include <QFile>
#include <QTextStream>
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#include <QTextCodec>
#endif
ShortcutsDialog::ShortcutsDialog(QWidget *parent)
: QDialog(parent) //,Qt::FramelessWindowHint)
@ -44,7 +47,13 @@ ShortcutsDialog::ShortcutsDialog(QWidget *parent)
QFile f(":/files/shortcuts.html");
f.open(QIODevice::ReadOnly);
QTextStream txtS(&f);
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
txtS.setEncoding(QStringConverter::Utf8);
#else
txtS.setCodec(QTextCodec::codecForName("UTF-8"));
#endif
QString content = txtS.readAll();
f.close();

View File

@ -20,7 +20,6 @@
#include <QFile>
#include <QPoint>
#include <QWidget>
#include <QTextCodec>
#include <QLabel>
#include <QTextEdit>
#include <QComboBox>
@ -51,7 +50,7 @@ YACReaderTranslator::YACReaderTranslator(Viewer *parent)
this->setAutoFillBackground(true);
this->setBackgroundRole(QPalette::Window);
QPalette p(this->palette());
p.setColor(QPalette::Window, QColor("#404040"));
p.setColor(QPalette::Window, QColor(0x404040));
this->setPalette(p);
auto layout = new QVBoxLayout(this);
@ -144,7 +143,6 @@ YACReaderTranslator::YACReaderTranslator(Viewer *parent)
resize(400, 479);
layout->setMargin(0);
layout->setContentsMargins(18, 12, 18, 12);
setContentsMargins(0, 0, 0, 0);
layout->setSpacing(0);
@ -289,26 +287,14 @@ void YACReaderTranslator::populateCombos()
void YACReaderTranslator::play()
{
// QMessageBox::question(this,"xxx",ttsSource.toString());
#if QT_VERSION >= 0x050000
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
player->setSource(ttsSource);
#else
player->setMedia(ttsSource);
#endif
player->play();
#else
MediaSource src(ttsSource);
src.setAutoDelete(true);
music->setCurrentSource(src);
music->play();
#endif
}
YACReaderTranslator::~YACReaderTranslator()
{
#if QT_VERSION >= 0x050000
#else
delete music;
#endif
}
void YACReaderTranslator::mousePressEvent(QMouseEvent *event)
@ -353,7 +339,7 @@ void TranslationLoader::run()
connect(&manager, &QNetworkAccessManager::finished, &q, &QEventLoop::quit);
QString url = "http://api.microsofttranslator.com/V2/Ajax.svc/Translate?appid=%1&from=%2&to=%3&text=%4&contentType=text/plain";
url = url.arg(APPID).arg(from).arg(to).arg(text);
url = url.arg(APPID, from, to, text);
QNetworkReply *reply = manager.get(QNetworkRequest(QUrl(url)));
@ -368,11 +354,11 @@ void TranslationLoader::run()
utf8 = utf8.remove(utf8.count() - 1, 1);
QString translated(utf8);
emit(requestFinished(translated));
emit requestFinished(translated);
} else
emit(error());
emit error();
} else {
emit(timeOut());
emit timeOut();
}
}
@ -396,7 +382,7 @@ void TextToSpeachLoader::run()
connect(&manager, &QNetworkAccessManager::finished, &q, &QEventLoop::quit);
QString url = "http://api.microsofttranslator.com/V2/Ajax.svc/Speak?appid=%1&language=%2&text=%3&contentType=text/plain";
url = url.arg(APPID).arg(language).arg(text);
url = url.arg(APPID, language, text);
QNetworkReply *reply = manager.get(QNetworkRequest(QUrl(url)));
@ -411,10 +397,10 @@ void TextToSpeachLoader::run()
utf8 = utf8.remove(utf8.count() - 1, 1);
utf8 = utf8.replace("\\", "");
emit(requestFinished(QUrl(utf8)));
emit requestFinished(QUrl(utf8));
} else
emit(error());
emit error();
} else {
emit(timeOut());
emit timeOut();
}
}

View File

@ -15,19 +15,13 @@ class YACReaderBusyWidget;
#include <QUrl>
#include "viewer.h"
#if QT_VERSION >= 0x050000
class QMediaPlayer;
#else
#include <Phonon/MediaObject>
using namespace Phonon;
#endif
class YACReaderTranslator : public QWidget
{
Q_OBJECT
public:
YACReaderTranslator(Viewer *parent = nullptr);
~YACReaderTranslator() override;
public slots:
void play();
@ -50,11 +44,7 @@ protected:
QPoint click;
private:
#if QT_VERSION >= 0x050000
QMediaPlayer *player;
#else
MediaObject *music;
#endif
QTextEdit *text;
QComboBox *from;

View File

@ -318,7 +318,7 @@ void Viewer::updatePage()
if (currentPage->isNull())
setPageUnavailableMessage();
else
emit(pageAvailable(true));
emit pageAvailable(true);
emit backgroundChanges();
@ -688,13 +688,15 @@ static void animateScroll(QPropertyAnimation &scroller, const QScrollBar &scroll
void Viewer::wheelEvent(QWheelEvent *event)
{
auto delta = event->angleDelta();
if (render->hasLoadedComic()) {
if (event->orientation() == Qt::Horizontal) {
animateScroll(*horizontalScroller, *horizontalScrollBar(), event->delta());
if (delta.x() != 0) {
animateScroll(*horizontalScroller, *horizontalScrollBar(), delta.x());
return;
}
if ((event->delta() < 0) && (verticalScrollBar()->sliderPosition() == verticalScrollBar()->maximum())) {
if ((delta.y() < 0) && (verticalScrollBar()->sliderPosition() == verticalScrollBar()->maximum())) {
if (wheelStop || verticalScrollBar()->maximum() == verticalScrollBar()->minimum()) {
if (getMovement(event) == Forward) {
next();
@ -706,7 +708,7 @@ void Viewer::wheelEvent(QWheelEvent *event)
} else
wheelStop = true;
} else {
if ((event->delta() > 0) && (verticalScrollBar()->sliderPosition() == verticalScrollBar()->minimum())) {
if ((delta.y() > 0) && (verticalScrollBar()->sliderPosition() == verticalScrollBar()->minimum())) {
if (wheelStop || verticalScrollBar()->maximum() == verticalScrollBar()->minimum()) {
if (getMovement(event) == Backward) {
prev();
@ -720,7 +722,7 @@ void Viewer::wheelEvent(QWheelEvent *event)
}
}
animateScroll(*verticalScroller, *verticalScrollBar(), event->delta());
animateScroll(*verticalScroller, *verticalScrollBar(), delta.y());
}
}
@ -763,17 +765,21 @@ void Viewer::mouseMoveEvent(QMouseEvent *event)
if (drag) {
int currentPosY = verticalScrollBar()->sliderPosition();
int currentPosX = horizontalScrollBar()->sliderPosition();
verticalScrollBar()->setSliderPosition(currentPosY = currentPosY + (yDragOrigin - event->y()));
horizontalScrollBar()->setSliderPosition(currentPosX = currentPosX + (xDragOrigin - event->x()));
verticalScrollBar()->setSliderPosition(currentPosY + (yDragOrigin - event->y()));
horizontalScrollBar()->setSliderPosition(currentPosX + (xDragOrigin - event->x()));
yDragOrigin = event->y();
xDragOrigin = event->x();
}
}
}
const QPixmap *Viewer::pixmap()
const QPixmap Viewer::pixmap()
{
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
return content->pixmap();
#else
return content->pixmap(Qt::ReturnByValue);
#endif
}
void Viewer::magnifyingGlassSwitch()
@ -955,7 +961,7 @@ void Viewer::setLoadingMessage()
hideMagnifyingGlass();
restoreMagnifyingGlass = true;
}
emit(pageAvailable(false));
emit pageAvailable(false);
configureContent(tr("Loading...please wait!"));
}
@ -965,7 +971,7 @@ void Viewer::setPageUnavailableMessage()
hideMagnifyingGlass();
restoreMagnifyingGlass = true;
}
emit(pageAvailable(false));
emit pageAvailable(false);
configureContent(tr("Page not available!"));
}
@ -1107,7 +1113,7 @@ void Viewer::showIsCoverMessage()
shouldOpenPrevious = true;
} else {
shouldOpenPrevious = false;
emit(openPreviousComic());
emit openPreviousComic();
}
shouldOpenNext = false; // single page comic
@ -1121,7 +1127,7 @@ void Viewer::showIsLastMessage()
shouldOpenNext = true;
} else {
shouldOpenNext = false;
emit(openNextComic());
emit openNextComic();
}
shouldOpenPrevious = false; // single page comic

View File

@ -178,7 +178,7 @@ private:
public:
Viewer(QWidget *parent = nullptr);
~Viewer();
const QPixmap *pixmap();
const QPixmap pixmap();
// Comic * getComic(){return comic;}
const BookmarksDialog *getBookmarksDialog() { return bd; }
// returns the current index starting in 1 [1,nPages]

View File

@ -55,7 +55,7 @@ YACReaderSlider::YACReaderSlider(QWidget *parent)
pLayout->addWidget(resetButton, 1, Qt::AlignHCenter | Qt::AlignBottom);
pLayout->setSpacing(elementsSpacing);
pLayout->setMargin(0);
pLayout->setContentsMargins(0, 0, 0, 0);
setLayout(pLayout);
setAutoFillBackground(false);
@ -79,7 +79,7 @@ void YACReaderSlider::paintEvent(QPaintEvent *)
{
QPainter painter(this);
painter.fillRect(0, 0, width(), height(), QColor("#BB000000"));
painter.fillRect(0, 0, width(), height(), QColor(0xBB000000));
}
void YACReaderSlider::show()

View File

@ -2,6 +2,7 @@
#define WIDTH_SLIDER_H
#include <QWidgetAction>
#include <QWidget>
class QLabel;
class QSlider;

View File

@ -2,11 +2,11 @@
#define YACREADER_LOCAL_CLIENT_H
#include "yacreader_global.h"
#include "comic_db.h"
#include <QObject>
class QLocalSocket;
class ComicDB;
class YACReaderLocalClient : public QObject
{

View File

@ -69,7 +69,9 @@ macx {
#CONFIG += release
CONFIG -= flat
QT += sql network widgets svg
QT += sql network widgets svg quickcontrols2
greaterThan(QT_MAJOR_VERSION, 5): QT += openglwidgets core5compat
# Input
HEADERS += comic_flow.h \

View File

@ -24,7 +24,7 @@ AddLabelDialog::AddLabelDialog(QWidget *parent)
list->addItem(new QListWidgetItem(QIcon(":/images/lists/label_light.png"), tr("light")));
list->addItem(new QListWidgetItem(QIcon(":/images/lists/label_dark.png"), tr("dark")));
QColor backgroundColor = this->palette().background().color();
QColor backgroundColor = this->palette().window().color();
list->setStyleSheet(QString("QListWidget {border : none; background-color: rgb(%1,%2,%3);}").arg(backgroundColor.red()).arg(backgroundColor.green()).arg(backgroundColor.blue()));
list->setMinimumHeight(225);

View File

@ -76,7 +76,7 @@ ClassicComicsView::ClassicComicsView(QWidget *parent)
layout->addWidget(sVertical);
setLayout(layout);
layout->setMargin(0);
layout->setContentsMargins(0, 0, 0, 0);
#ifdef Q_OS_MAC
sVertical->setCollapsible(1, false);
@ -364,7 +364,7 @@ void ClassicComicsView::setupSearchingIcon()
searchingIcon->setLayout(h);
QPalette pal(searchingIcon->palette());
pal.setColor(QPalette::Background, Qt::black);
pal.setColor(QPalette::Window, Qt::black);
searchingIcon->setAutoFillBackground(true);
searchingIcon->setPalette(pal);

View File

@ -105,7 +105,7 @@ void ComicFlow::keyPressEvent(QKeyEvent *event)
void ComicFlow::wheelEvent(QWheelEvent *event)
{
if (event->delta() < 0)
if (event->angleDelta().y() < 0)
showNext();
else
showPrevious();

View File

@ -20,12 +20,12 @@ ComicFlowWidgetSW::ComicFlowWidgetSW(QWidget *parent)
// TODO eleminar "padding"
QPalette Pal(palette());
// set black background
Pal.setColor(QPalette::Background, Qt::black);
Pal.setColor(QPalette::Window, Qt::black);
setAutoFillBackground(true);
setPalette(Pal);
// config
QMatrix m;
QTransform m;
m.rotate(-90);
m.scale(-1, 1);
QImage image(":/images/setRead.png");
@ -166,7 +166,7 @@ ComicFlowWidgetGL::ComicFlowWidgetGL(QWidget *parent)
// TODO eleminar "padding"
QPalette Pal(palette());
// set black background
Pal.setColor(QPalette::Background, Qt::black);
Pal.setColor(QPalette::Window, Qt::black);
setAutoFillBackground(true);
setPalette(Pal);
}

View File

@ -8,11 +8,7 @@
#include <QTableView>
#include <QVBoxLayout>
#include <QtWidgets>
#if QT_VERSION >= 0x050000
#include <QtConcurrent/QtConcurrentRun>
#else
#include <QtConcurrentRun>
#endif
#include "data_base_management.h"
#include <QJsonDocument>
#include <QJsonParseError>
@ -155,13 +151,23 @@ void ComicVineDialog::goNext()
QList<QPair<ComicDB, QString>> matchingInfo = sortVolumeComicsWidget->getMatchingInfo();
int count = selectVolumeWidget->getSelectedVolumeNumIssues();
QString publisher = selectVolumeWidget->getSelectedVolumePublisher();
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
QtConcurrent::run(&ComicVineDialog::getComicsInfo, this, matchingInfo, count, publisher);
#else
QtConcurrent::run(this, &ComicVineDialog::getComicsInfo, matchingInfo, count, publisher);
#endif
} else if (content->currentWidget() == selectComicWidget) {
showLoading();
QString comicId = selectComicWidget->getSelectedComicId();
int count = selectVolumeWidget->getSelectedVolumeNumIssues();
QString publisher = selectVolumeWidget->getSelectedVolumePublisher();
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
QtConcurrent::run(&ComicVineDialog::getComicInfo, this, comicId, count, publisher);
#else
QtConcurrent::run(this, &ComicVineDialog::getComicInfo, comicId, count, publisher);
#endif
}
}
@ -203,8 +209,14 @@ void ComicVineDialog::setComics(const QList<ComicDB> &comics)
QSize ComicVineDialog::sizeHint() const
{
int heightDesktopResolution = QApplication::desktop()->screenGeometry().height();
int widthDesktopResolution = QApplication::desktop()->screenGeometry().width();
QScreen *screen = window()->screen();
if (screen == nullptr) {
screen = QApplication::screens().constFirst();
}
int heightDesktopResolution = screen->geometry().height();
int widthDesktopResolution = screen->geometry().width();
int height, width;
height = qMax(529, static_cast<int>(heightDesktopResolution * 0.5));
width = height * 1.65;
@ -521,14 +533,14 @@ ComicDB ComicVineDialog::parseComicInfo(ComicDB &comic, const QString &json, int
comic.info.volume = result.value("volume").toMap().value("name");
if (result.contains("person_credits") && !result.value("person_credits").isNull()) {
QMap<QString, QString> authors = getAuthors(result.value("person_credits"));
auto authors = getAuthors(result.value("person_credits"));
QString writer = QStringList(authors.values("writer")).join("\n");
QString penciller = QStringList(authors.values("penciller")).join("\n");
QString inker = QStringList(authors.values("inker")).join("\n");
QString colorist = QStringList(authors.values("colorist")).join("\n");
QString letterer = QStringList(authors.values("letterer")).join("\n");
QString coverArtist = QStringList(authors.values("cover")).join("\n");
QString writer = authors.values("writer").join("\n");
QString penciller = authors.values("penciller").join("\n");
QString inker = authors.values("inker").join("\n");
QString colorist = authors.values("colorist").join("\n");
QString letterer = authors.values("letterer").join("\n");
QString coverArtist = authors.values("cover").join("\n");
comic.info.writer = writer;
comic.info.penciller = penciller;
@ -600,9 +612,9 @@ QString ComicVineDialog::getCharacters(const QVariant &json_characters)
return (characters.isEmpty()) ? "" : (characters.join("\n") + "\n");
}
QMap<QString, QString> ComicVineDialog::getAuthors(const QVariant &json_authors)
QMultiMap<QString, QString> ComicVineDialog::getAuthors(const QVariant &json_authors)
{
QMap<QString, QString> authors;
QMultiMap<QString, QString> authors;
QListIterator<QVariant> it(json_authors.toList());
QVariantMap resultsValue;
@ -614,17 +626,17 @@ QMap<QString, QString> ComicVineDialog::getAuthors(const QVariant &json_authors)
QStringList roles = resultsValue.value("role").toString().split(",");
foreach (QString role, roles) {
if (role.trimmed() == "writer")
authors.insertMulti("writer", authorName);
authors.insert("writer", authorName);
else if (role.trimmed() == "inker")
authors.insertMulti("inker", authorName);
authors.insert("inker", authorName);
else if (role.trimmed() == "penciler" || role.trimmed() == "penciller")
authors.insertMulti("penciller", authorName);
authors.insert("penciller", authorName);
else if (role.trimmed() == "colorist")
authors.insertMulti("colorist", authorName);
authors.insert("colorist", authorName);
else if (role.trimmed() == "letterer")
authors.insertMulti("letterer", authorName);
authors.insert("letterer", authorName);
else if (role.trimmed() == "cover")
authors.insertMulti("cover", authorName);
authors.insert("cover", authorName);
}
}

View File

@ -31,6 +31,8 @@ public:
void setComics(const QList<ComicDB> &comics);
QSize sizeHint() const override;
QSize minimumSizeHint() const override;
void getComicsInfo(QList<QPair<ComicDB, QString>> &matchingInfo, int count, const QString &publisher);
void getComicInfo(const QString &comicId, int count, const QString &publisher);
signals:
@ -56,15 +58,13 @@ protected slots:
void showSelectComic(const QString &json);
void showSortVolumeComics(const QString &json);
void queryTimeOut();
void getComicsInfo(QList<QPair<ComicDB, QString>> &matchingInfo, int count, const QString &publisher);
void getComicInfo(const QString &comicId, int count, const QString &publisher);
ComicDB parseComicInfo(ComicDB &comic, const QString &json, int count, const QString &publisher);
void setLoadingMessage(const QString &message);
void goToNextComic();
private:
QString getCharacters(const QVariant &json_characters);
QMap<QString, QString> getAuthors(const QVariant &json_authors);
QMultiMap<QString, QString> getAuthors(const QVariant &json_authors);
QPair<QString, QString> getFirstStoryArcIdAndName(const QVariant &json_story_arcs);
QPair<QString, QString> getArcNumberAndArcCount(const QString &storyArcId, const QString &comicId);

View File

@ -57,7 +57,7 @@ QVariant LocalComicListModel::data(const QModelIndex &index, int role) const
Qt::ItemFlags LocalComicListModel::flags(const QModelIndex &index) const
{
if (!index.isValid())
return nullptr;
return Qt::NoItemFlags;
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
}
@ -144,7 +144,7 @@ void LocalComicListModel::moveSelectionUp(const QList<QModelIndex> &selectedInde
beginMoveRows(mi.parent(), sourceRow, sourceLastRow, mi.parent(), destRow);
for (int i = sourceRow; i <= sourceLastRow; i++)
_data.swap(i, i - 1);
_data.swapItemsAt(i, i - 1);
endMoveRows();
}
@ -163,7 +163,7 @@ void LocalComicListModel::moveSelectionDown(const QList<QModelIndex> &selectedIn
beginMoveRows(mi.parent(), sourceRow, sourceLastRow, mi.parent(), destRow + 1);
for (int i = sourceLastRow; i >= sourceRow; i--)
_data.swap(i, i + 1);
_data.swapItemsAt(i, i + 1);
endMoveRows();
}

View File

@ -105,7 +105,7 @@ QVariant VolumeComicsModel::data(const QModelIndex &index, int role) const
Qt::ItemFlags VolumeComicsModel::flags(const QModelIndex &index) const
{
if (!index.isValid())
return nullptr;
return Qt::NoItemFlags;
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
}

View File

@ -102,7 +102,7 @@ QVariant VolumesModel::data(const QModelIndex &index, int role) const
Qt::ItemFlags VolumesModel::flags(const QModelIndex &index) const
{
if (!index.isValid())
return nullptr;
return Qt::NoItemFlags;
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
}

View File

@ -9,17 +9,6 @@
#include "QsLog.h"
QString getLastExecutedQuery(const QSqlQuery &query)
{
QString str = query.lastQuery();
QMapIterator<QString, QVariant> it(query.boundValues());
while (it.hasNext()) {
it.next();
str.replace(it.key(), it.value().toString());
}
return str;
}
YACReader::ComicQueryResultProcessor::ComicQueryResultProcessor()
: querySearchQueue(1)
{

View File

@ -47,7 +47,7 @@ public:
QRect textRect = option.rect;
textRect.setLeft(std::max(0, (option.rect.size().width() - fm.width(text)) / 2));
textRect.setLeft(std::max(0, (option.rect.size().width() - fm.horizontalAdvance(text)) / 2));
painter->drawText(textRect, text);
@ -62,7 +62,7 @@ public:
QFontMetrics fm(option.font);
QString text = qvariant_cast<QString>(index.data(Qt::DisplayRole));
return QSize(fm.width(text), fm.height());
return QSize(fm.horizontalAdvance(text), fm.height());
}
};
@ -114,7 +114,7 @@ EmptyFolderWidget::EmptyFolderWidget(QWidget *parent)
layout->addSpacing(12);
layout->addWidget(foldersView, 1);
layout->addStretch();
layout->setMargin(0);
layout->setContentsMargins(0, 0, 0, 0);
layout->setSpacing(0);
setContentsMargins(0, 0, 0, 0);

View File

@ -208,7 +208,7 @@ void GridComicsView::createCoverSizeSliderWidget()
bigLabel->setPixmap(QPixmap(":/images/comics_view_toolbar/big_size_grid_zoom.png"));
horizontalLayout->addWidget(bigLabel);
horizontalLayout->addSpacing(10);
horizontalLayout->setMargin(0);
horizontalLayout->setContentsMargins(0, 0, 0, 0);
coverSizeSliderWidget->setLayout(horizontalLayout);
// TODO add shortcuts (ctrl-+ and ctrl-- for zooming in out, + ctrl-0 for reseting the zoom)

View File

@ -48,7 +48,7 @@ YACReaderActivityIndicatorWidget::YACReaderActivityIndicatorWidget(QWidget *pare
setLayout(layout);
layout->setMargin(4);
layout->setContentsMargins(4, 4, 4, 4);
layout->setSpacing(0);
// setFixedHeight(3);
@ -87,7 +87,7 @@ ImportWidget::ImportWidget(QWidget *parent)
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
QPalette p(palette());
p.setColor(QPalette::Background, QColor(250, 250, 250));
p.setColor(QPalette::Window, QColor(250, 250, 250));
setAutoFillBackground(true);
setPalette(p);
@ -144,7 +144,7 @@ ImportWidget::ImportWidget(QWidget *parent)
coversViewLayout->addWidget(topDecorator, 0);
coversViewLayout->addWidget(coversView, 1);
coversViewLayout->addWidget(bottomDecorator, 0);
coversViewLayout->setMargin(0);
coversViewLayout->setContentsMargins(0, 0, 0, 0);
coversViewLayout->setSpacing(0);
QPushButton *stop = new QPushButton(tr("stop"));
@ -169,7 +169,7 @@ ImportWidget::ImportWidget(QWidget *parent)
topLayout->addSpacing(30);
topLayout->addLayout(textLayout, 1);
topLayout->addStretch();
topLayout->setMargin(0);
topLayout->setContentsMargins(0, 0, 0, 0);
topWidget->setLayout(topLayout);

View File

@ -117,7 +117,7 @@ void LibraryCreator::run()
#endif
if (!sevenzLib->load()) {
QLOG_ERROR() << "Loading 7z.dll : " + sevenzLib->errorString() << endl;
QLOG_ERROR() << "Loading 7z.dll : " + sevenzLib->errorString() << Qt::endl;
QCoreApplication::exit(YACReader::SevenZNotFound);
exit();
}

View File

@ -6,14 +6,12 @@
#include <QSplitter>
#include <QLabel>
#include <QDir>
#include <QDirModel>
#include <QHeaderView>
#include <QProcess>
#include <QtCore>
#include <QFileDialog>
#include <QHBoxLayout>
#include <QFileIconProvider>
#include <QMatrix>
#include <QSettings>
#include <QHeaderView>
@ -285,7 +283,7 @@ void LibraryWindow::doLayout()
rightLayout->addWidget(libraryToolBar);
rightLayout->addWidget(comicsViewsManager->containerWidget());
rightLayout->setMargin(0);
rightLayout->setContentsMargins(0, 0, 0, 0);
rightLayout->setSpacing(0);
QWidget *rightWidget = new QWidget();
@ -457,8 +455,6 @@ void LibraryWindow::doModels()
// lists
listsModel = new ReadingListModel(this);
listsModelProxy = new ReadingListModelProxy(this);
// setSearchFilter(YACReader::NoModifiers, ""); //clear search filter
}
void LibraryWindow::createActions()
@ -1584,7 +1580,7 @@ void LibraryWindow::addFolderToCurrentIndex()
"", &ok);
// chars not supported in a folder's name: / \ : * ? " < > |
QRegExp invalidChars("\\/\\:\\*\\?\\\"\\<\\>\\|\\\\"); // TODO this regexp is not properly written
QRegularExpression invalidChars("\\/\\:\\*\\?\\\"\\<\\>\\|\\\\"); // TODO this regexp is not properly written
bool isValid = !newFolderName.contains(invalidChars);
if (ok && !newFolderName.isEmpty() && isValid) {
@ -2379,7 +2375,7 @@ void LibraryWindow::asignNumbers()
void LibraryWindow::openContainingFolderComic()
{
QModelIndex modelIndex = comicsViewsManager->comicsView->currentIndex();
QFileInfo file = QDir::cleanPath(currentPath() + comicsModel->getComicPath(modelIndex));
QFileInfo file(QDir::cleanPath(currentPath() + comicsModel->getComicPath(modelIndex)));
#if defined Q_OS_UNIX && !defined Q_OS_MAC
QString path = file.absolutePath();
QDesktopServices::openUrl(QUrl("file:///" + path, QUrl::TolerantMode));

View File

@ -11,7 +11,7 @@ NoLibrariesWidget::NoLibrariesWidget(QWidget *parent)
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
QPalette p(palette());
p.setColor(QPalette::Background, QColor(250, 250, 250));
p.setColor(QPalette::Window, QColor(250, 250, 250));
setAutoFillBackground(true);
setPalette(p);
@ -52,7 +52,7 @@ NoLibrariesWidget::NoLibrariesWidget(QWidget *parent)
topLayout->addSpacing(30);
topLayout->addLayout(textLayout, 1);
topLayout->addStretch();
topLayout->setMargin(0);
topLayout->setContentsMargins(0, 0, 0, 0);
topWidget->setLayout(topLayout);

View File

@ -33,7 +33,7 @@ NoSearchResultsWidget::NoSearchResultsWidget(QWidget *parent)
layout->addSpacing(30);
layout->addWidget(titleLabel);
layout->addStretch();
layout->setMargin(0);
layout->setContentsMargins(0, 0, 0, 0);
layout->setSpacing(0);
setContentsMargins(0, 0, 0, 0);

View File

@ -9,7 +9,6 @@
#include <QHBoxLayout>
#include <QApplication>
#include <QDesktopWidget>
#include <QSizePolicy>
#include <QFormLayout>
#include <QCheckBox>
@ -51,8 +50,13 @@ PropertiesDialog::PropertiesDialog(QWidget *parent)
mainWidget->setLayout(mainLayout);
mainLayout->setSizeConstraint(QLayout::SetMinimumSize);
int heightDesktopResolution = QApplication::desktop()->screenGeometry().height();
int widthDesktopResolution = QApplication::desktop()->screenGeometry().width();
QScreen *screen = parent != nullptr ? parent->window()->screen() : nullptr;
if (screen == nullptr) {
screen = QApplication::screens().constFirst();
}
int heightDesktopResolution = screen->geometry().height();
int widthDesktopResolution = screen->geometry().width();
int sHeight, sWidth;
sHeight = static_cast<int>(heightDesktopResolution * 0.65);
sWidth = static_cast<int>(sHeight * 1.4);

View File

@ -1,7 +1,6 @@
<RCC>
<qresource prefix="/">
<file>qml/GridComicsView.qml</file>
<file>qml/YACReaderScrollView.qml</file>
<file>qml/tick.png</file>
<file>qml/reading.png</file>
<file>qml/star_menu.png</file>
@ -27,6 +26,5 @@
<file>qml/InfoTick.qml</file>
<file>qml/InfoFavorites.qml</file>
<file>qml/InfoRating.qml</file>
<file>qml/YACReaderScrollViewStyle.qml</file>
</qresource>
</RCC>

View File

@ -1,15 +1,13 @@
import QtQuick 2.6
import QtQuick 2.15
import QtQuick.Controls 1.4
import QtQuick.Layouts 1.2
import QtGraphicalEffects 1.0
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.12
import com.yacreader.ComicInfo 1.0
import com.yacreader.ComicDB 1.0
Rectangle {
Rectangle {
color : "transparent"
id: mainContainer

View File

@ -1,5 +1,5 @@
import QtQuick 2.3
import QtQuick.Controls 1.4
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtGraphicalEffects 1.0

View File

@ -1,10 +1,12 @@
import QtQuick 2.9
import QtQuick 2.15
import QtQuick.Controls 1.4
import QtQuick.Layouts 1.3
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.12
import QtGraphicalEffects 1.0
import QtQuick.Controls.Styles 1.4
import Qt.labs.animation 1.0
import com.yacreader.ComicModel 1.0
@ -12,12 +14,11 @@ import com.yacreader.ComicInfo 1.0
import com.yacreader.ComicDB 1.0
SplitView {
//anchors.fill: parent
orientation: Qt.Horizontal
handleDelegate:Rectangle {
width: 1
height: 1
color: "#202020"
handle: Rectangle {
border.width : 0
implicitWidth: 10
color: info_container.color
}
Rectangle {
@ -47,8 +48,8 @@ Rectangle {
color: backgroundColor
width: parent.width - (info_container.visible ? info_container.width : 0)
Layout.fillWidth: true
Layout.minimumWidth: coverWidth + 100
SplitView.fillWidth: true
SplitView.minimumWidth: coverWidth + 100
height: parent.height
anchors.margins: 0
@ -364,12 +365,24 @@ Rectangle {
}
Menu {
background: Rectangle {
implicitWidth: 42
implicitHeight: 100
//border.color: "#222"
//color: "#444"
}
id: ratingConextMenu
MenuItem { text: "1"; enabled: true; iconSource:"star_menu.png"; onTriggered: comicRatingHelper.rate(index,1) }
MenuItem { text: "2"; enabled: true; iconSource:"star_menu.png"; onTriggered: comicRatingHelper.rate(index,2) }
MenuItem { text: "3"; enabled: true; iconSource:"star_menu.png"; onTriggered: comicRatingHelper.rate(index,3) }
MenuItem { text: "4"; enabled: true; iconSource:"star_menu.png"; onTriggered: comicRatingHelper.rate(index,4) }
MenuItem { text: "5"; enabled: true; iconSource:"star_menu.png"; onTriggered: comicRatingHelper.rate(index,5) }
Action { text: "1"; enabled: true; icon.source:"star_menu.png"; onTriggered: comicRatingHelper.rate(index,1) }
Action { text: "2"; enabled: true; icon.source:"star_menu.png"; onTriggered: comicRatingHelper.rate(index,2) }
Action { text: "3"; enabled: true; icon.source:"star_menu.png"; onTriggered: comicRatingHelper.rate(index,3) }
Action { text: "4"; enabled: true; icon.source:"star_menu.png"; onTriggered: comicRatingHelper.rate(index,4) }
Action { text: "5"; enabled: true; icon.source:"star_menu.png"; onTriggered: comicRatingHelper.rate(index,5) }
delegate: MenuItem {
implicitHeight: 30
}
}
}
@ -383,41 +396,18 @@ Rectangle {
}
}
ScrollView {
__wheelAreaScrollSpeed: grid.cellHeight * 0.40
Rectangle {
id: scrollView
objectName: "topScrollView"
anchors.fill: parent
anchors.margins: 0
children: grid
color: "transparent"
function scrollToOrigin() {
flickableItem.contentY = showCurrentComic ? -270 : -20
flickableItem.contentX = 0
}
style: YACReaderScrollViewStyle {
transientScrollBars: false
incrementControl: Item {}
decrementControl: Item {}
handle: Item {
implicitWidth: 16
implicitHeight: 26
Rectangle {
color: "#88424242"
anchors.fill: parent
anchors.topMargin: 6
anchors.leftMargin: 4
anchors.rightMargin: 4
anchors.bottomMargin: 6
border.color: "#AA313131"
border.width: 1
radius: 8
}
}
scrollBarBackground: Item {
implicitWidth: 16
implicitHeight: 26
}
grid.contentY = grid.originY
grid.contentX = grid.originX
}
DropArea {
@ -620,34 +610,13 @@ Rectangle {
Layout.maximumHeight: (currentComicVisualView.height * 0.32)
Layout.maximumWidth: 960
contentItem: currentComicInfoSinopsis
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
horizontalScrollBarPolicy: Qt.ScrollBarAlwaysOff
contentItem: currentComicInfoSinopsis
id: synopsisScroller
style: ScrollViewStyle {
transientScrollBars: false
incrementControl: Item {}
decrementControl: Item {}
handle: Item {
implicitWidth: 12
implicitHeight: 26
Rectangle {
color: "#424246"
anchors.fill: parent
anchors.topMargin: 6
anchors.leftMargin: 9
anchors.rightMargin: 0
anchors.bottomMargin: 6
radius: 2
}
}
scrollBarBackground: Item {
implicitWidth: 14
implicitHeight: 26
}
}
clip: true
Text {
Layout.maximumWidth: 960
@ -680,18 +649,16 @@ Rectangle {
anchors.bottomMargin: 15
onClicked: comicOpener.triggerOpenCurrentComic()
style: ButtonStyle {
background: Rectangle {
implicitWidth: 100
implicitHeight: 30
border.width: control.activeFocus ? 2 : 1
border.width: readButton.activeFocus ? 2 : 1
border.color: "#FFCC00"
radius: height / 2
color: "#FFCC00"
}
label: Text {
contentItem: Text {
renderType: Text.NativeRendering
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
@ -699,9 +666,8 @@ Rectangle {
font.pointSize: 12
font.bold: true
color: "white"
text: control.text
text: readButton.text
}
}
}
@ -725,26 +691,21 @@ Rectangle {
anchors.fill: parent
cellHeight: cellCustomHeight
header: currentComicView
//highlight: appHighlight
focus: true
model: comicsList
delegate: appDelegate
anchors.topMargin: 0 //showCurrentComic ? 0 : 20
anchors.bottomMargin: 20
anchors.topMargin: 0
anchors.bottomMargin: 10
anchors.leftMargin: 0
anchors.rightMargin: 0
pixelAligned: true
//flickDeceleration: -2000
highlightFollowsCurrentItem: true
currentIndex: 0
cacheBuffer: 0
footer: Rectangle { //fix for the scroll issue, TODO find what causes the issue (some times the bottoms cells are hidden for the toolbar, no full scroll)
height : 25
width : parent.width
color : "#00000000"
}
//disable flickable behaviour
interactive: false
move: Transition {
NumberAnimation { properties: "x,y"; duration: 250 }
@ -780,116 +741,130 @@ Rectangle {
}
function calculateCellWidths(cWidth) {
var wholeCells = Math.floor(width / cWidth);
var rest = width - (cWidth * wholeCells)
grid.cellWidth = cWidth + Math.floor(rest / wholeCells);
//console.log("cWidth",cWidth,"wholeCells=",wholeCells,"rest=",rest,"cellWidth=",cellWidth,"width=",width);
}
WheelHandler {
onWheel: {
if (grid.contentHeight <= grid.height) {
return;
}
var newValue = Math.min((grid.contentHeight - grid.height - (showCurrentComic ? 270 : 20)), (Math.max(grid.originY , grid.contentY - event.angleDelta.y)));
grid.contentY = newValue;
}
}
ScrollBar.vertical: ScrollBar {
visible: grid.contentHeight > grid.height
contentItem: Item {
implicitWidth: 12
implicitHeight: 26
Rectangle {
color: "#88424242"
anchors.fill: parent
anchors.topMargin: 6
anchors.leftMargin: 3
anchors.rightMargin: 2
anchors.bottomMargin: 6
border.color: "#AA313131"
border.width: 1
radius: 3.5
}
}
}
Keys.onPressed: {
if (event.modifiers & Qt.ControlModifier || event.modifiers & Qt.ShiftModifier) {
event.accepted = true
return;
}
var numCells = grid.numCellsPerRow();
var ci = 0;
if (event.key === Qt.Key_Right) {
ci = Math.min(grid.currentIndex+1,grid.count - 1);
}
else if (event.key === Qt.Key_Left) {
ci = Math.max(0,grid.currentIndex-1);
}
else if (event.key === Qt.Key_Up) {
ci = Math.max(0,grid.currentIndex-numCells);
}
else if (event.key === Qt.Key_Down) {
ci = Math.min(grid.currentIndex+numCells,grid.count - 1);
} else {
return;
}
event.accepted = true;
grid.currentIndex = -1
comicsSelectionHelper.clear();
currentIndexHelper.setCurrentIndex(ci);
grid.currentIndex = ci;
}
}
focus: true
Keys.onPressed: {
if (event.modifiers & Qt.ControlModifier || event.modifiers & Qt.ShiftModifier)
return;
var numCells = grid.numCellsPerRow();
var ci
if (event.key === Qt.Key_Right) {
ci = Math.min(grid.currentIndex+1,grid.count - 1);
}
else if (event.key === Qt.Key_Left) {
ci = Math.max(0,grid.currentIndex-1);
}
else if (event.key === Qt.Key_Up) {
ci = Math.max(0,grid.currentIndex-numCells);
}
else if (event.key === Qt.Key_Down) {
ci = Math.min(grid.currentIndex+numCells,grid.count - 1);
} else {
return;
}
event.accepted = true;
//var ci = grid.currentIndex;
grid.currentIndex = -1
comicsSelectionHelper.clear();
currentIndexHelper.setCurrentIndex(ci);
grid.currentIndex = ci;
}
//}
/*MouseArea {
anchors.fill: parent
onClicked: {
clicked.accepted = false;
console.log("xx");
}
onWheel: {
var newValue = Math.max(0,scrollView.flickableItem.contentY - wheel.angleDelta.y)
scrollView.flickableItem.contentY = newValue
}
}*/
/*ScrollBar {
flickable: grid;
}
PerformanceMeter {
anchors {top: parent.top; left: parent.left; margins: 4}
id: performanceMeter
width: 128
height: 64
enabled: (dummyValue || !dummyValue)
}*/
}
}
Rectangle {
id: info_container
objectName: "infoContainer"
Layout.preferredWidth: 350
Layout.minimumWidth: 350
Layout.maximumWidth: 960
SplitView.preferredWidth: 350
SplitView.minimumWidth: 350
SplitView.maximumWidth: 960
height: parent.height
color: infoBackgroundColor
visible: showInfo
ScrollView {
__wheelAreaScrollSpeed: 75
Flickable{
id: infoFlickable
anchors.fill: parent
anchors.margins: 0
horizontalScrollBarPolicy: Qt.ScrollBarAlwaysOff
contentWidth: infoView.width
contentHeight: infoView.height
style: ScrollViewStyle {
transientScrollBars: false
incrementControl: Item {}
decrementControl: Item {}
handle: Item {
implicitWidth: 10
ComicInfoView {
id: infoView
width: info_container.width
}
WheelHandler {
onWheel: {
if (infoFlickable.contentHeight <= infoFlickable.height) {
return;
}
var newValue = Math.min((infoFlickable.contentHeight - infoFlickable.height), (Math.max(infoFlickable.originY , infoFlickable.contentY - event.angleDelta.y)));
infoFlickable.contentY = newValue;
}
}
ScrollBar.vertical: ScrollBar {
visible: infoFlickable.contentHeight > infoFlickable.height
contentItem: Item {
implicitWidth: 12
implicitHeight: 26
Rectangle {
color: "#424246"
anchors.fill: parent
anchors.topMargin: 6
anchors.leftMargin: 4
anchors.leftMargin: 5
anchors.rightMargin: 4
anchors.bottomMargin: 6
radius: 2
}
}
scrollBarBackground: Item {
implicitWidth: 14
implicitHeight: 26
}
}
ComicInfoView {
width: info_container.width
}
}
}
}

View File

@ -1,8 +1,6 @@
import QtQuick 2.5
import QtQuick 2.15
import QtQuick.Controls 1.2
import QtGraphicalEffects 1.0
import QtQuick.Controls.Styles 1.4
import QtQuick.Controls 2.15
import com.yacreader.ComicModel 1.0
@ -59,39 +57,49 @@ Rectangle {
y: flow.height + flow.additionalBottomSpace - 6
height: parent.height - y
clip: true
color: infoBackgroundColor
ScrollView {
__wheelAreaScrollSpeed: 75
Flickable{
id: infoFlickable
anchors.fill: parent
anchors.margins: 0
horizontalScrollBarPolicy: Qt.ScrollBarAlwaysOff
contentWidth: infoView.width
contentHeight: infoView.height
style: ScrollViewStyle {
transientScrollBars: false
incrementControl: Item {}
decrementControl: Item {}
handle: Item {
implicitWidth: 10
WheelHandler {
onWheel: {
if (infoFlickable.contentHeight <= infoFlickable.height) {
return;
}
var newValue = Math.min((infoFlickable.contentHeight - infoFlickable.height), (Math.max(infoFlickable.originY , infoFlickable.contentY - event.angleDelta.y)));
infoFlickable.contentY = newValue;
}
}
ScrollBar.vertical: ScrollBar {
visible: infoFlickable.contentHeight > infoFlickable.height
contentItem: Item {
implicitWidth: 12
implicitHeight: 26
Rectangle {
color: "#424246"
anchors.fill: parent
anchors.topMargin: 6
anchors.leftMargin: 4
anchors.leftMargin: 5
anchors.rightMargin: 4
anchors.bottomMargin: 6
radius: 2
}
}
scrollBarBackground: Item {
implicitWidth: 14
implicitHeight: 26
}
}
ComicInfoView {
id: infoView
width: info_container.width - 14
}
}

View File

@ -1,4 +1,4 @@
import QtQuick 2.6
import QtQuick 2.15
import QtGraphicalEffects 1.0

View File

@ -1,4 +1,4 @@
import QtQuick 2.6
import QtQuick 2.15
import QtGraphicalEffects 1.0
@ -45,6 +45,4 @@ Row {
}
}
}
}

View File

@ -1,4 +1,4 @@
import QtQuick 2.6
import QtQuick 2.15
import QtGraphicalEffects 1.0
@ -26,4 +26,3 @@ Item {
color: read ? readTickCheckedColor : readTickUncheckedColor
}
}

View File

@ -1,357 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL3$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see http://www.qt.io/terms-conditions. For further
** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 3 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPLv3 included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 3 requirements
** will be met: https://www.gnu.org/licenses/lgpl.html.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 2.0 or later as published by the Free
** Software Foundation and appearing in the file LICENSE.GPL included in
** the packaging of this file. Please review the following information to
** ensure the GNU General Public License version 2.0 requirements will be
** met: http://www.gnu.org/licenses/gpl-2.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
import QtQuick 2.2
import QtQuick.Controls 1.2
import QtQuick.Controls.Private 1.0
import QtQuick.Controls.Styles 1.1
/*!
\qmltype ScrollView
\inqmlmodule QtQuick.Controls
\since 5.1
\ingroup views
\ingroup controls
\brief Provides a scrolling view within another Item.
\image scrollview.png
A ScrollView can be used either to replace a \l Flickable or decorate an
existing \l Flickable. Depending on the platform, it will add scroll bars and
a content frame.
Only one Item can be a direct child of the ScrollView and the child is implicitly anchored
to fill the scroll view.
Example:
\code
ScrollView {
Image { source: "largeImage.png" }
}
\endcode
In the previous example the Image item will implicitly get scroll behavior as if it was
used within a \l Flickable. The width and height of the child item will be used to
define the size of the content area.
Example:
\code
ScrollView {
ListView {
...
}
}
\endcode
In this case the content size of the ScrollView will simply mirror that of its contained
\l flickableItem.
You can create a custom appearance for a ScrollView by
assigning a \l {ScrollViewStyle}.
*/
FocusScope {
id: root
implicitWidth: 240
implicitHeight: 150
/*!
This property tells the ScrollView if it should render
a frame around its content.
The default value is \c false.
*/
property bool frameVisible: false
/*! \qmlproperty enumeration ScrollView::horizontalScrollBarPolicy
\since QtQuick.Controls 1.3
This property holds the policy for showing the horizontal scrollbar.
It can be any of the following values:
\list
\li Qt.ScrollBarAsNeeded
\li Qt.ScrollBarAlwaysOff
\li Qt.ScrollBarAlwaysOn
\endlist
The default policy is \c Qt.ScrollBarAsNeeded.
*/
property alias horizontalScrollBarPolicy: scroller.horizontalScrollBarPolicy
/*! \qmlproperty enumeration ScrollView::verticalScrollBarPolicy
\since QtQuick.Controls 1.3
This property holds the policy for showing the vertical scrollbar.
It can be any of the following values:
\list
\li Qt.ScrollBarAsNeeded
\li Qt.ScrollBarAlwaysOff
\li Qt.ScrollBarAlwaysOn
\endlist
The default policy is \c Qt.ScrollBarAsNeeded.
*/
property alias verticalScrollBarPolicy: scroller.verticalScrollBarPolicy
/*!
This property controls if there should be a highlight
around the frame when the ScrollView has input focus.
The default value is \c false.
\note This property is only applicable on some platforms, such
as Mac OS.
*/
property bool highlightOnFocus: false
/*!
\qmlproperty Item ScrollView::viewport
The viewport determines the current "window" on the contentItem.
In other words, it clips it and the size of the viewport tells you
how much of the content area is visible.
*/
property alias viewport: viewportItem
/*!
\qmlproperty Item ScrollView::flickableItem
The flickableItem of the ScrollView. If the contentItem provided
to the ScrollView is a Flickable, it will be the \l contentItem.
*/
readonly property alias flickableItem: internal.flickableItem
/*!
The contentItem of the ScrollView. This is set by the user.
Note that the definition of contentItem is somewhat different to that
of a Flickable, where the contentItem is implicitly created.
*/
default property Item contentItem
/*! \internal */
property alias __scroller: scroller
/*! \internal */
property alias __verticalScrollbarOffset: scroller.verticalScrollbarOffset
/*! \internal */
property alias __wheelAreaScrollSpeed: wheelArea.scrollSpeed
/*! \internal */
property int __scrollBarTopMargin: 0
/*! \internal */
property int __viewTopMargin: 0
/*! \internal */
property alias __horizontalScrollBar: scroller.horizontalScrollBar
/*! \internal */
property alias __verticalScrollBar: scroller.verticalScrollBar
/*! \qmlproperty Component ScrollView::style
The style Component for this control.
\sa {Qt Quick Controls Styles QML Types}
*/
property Component style: Settings.styleComponent(Settings.style, "ScrollViewStyle.qml", root)
/*! \internal */
property Style __style: styleLoader.item
activeFocusOnTab: true
onContentItemChanged: {
if (contentItem.hasOwnProperty("contentY") && // Check if flickable
contentItem.hasOwnProperty("contentHeight")) {
internal.flickableItem = contentItem // "Use content if it is a flickable
internal.flickableItem.parent = viewportItem
} else {
internal.flickableItem = flickableComponent.createObject(viewportItem)
contentItem.parent = internal.flickableItem.contentItem
}
internal.flickableItem.anchors.fill = viewportItem
if (!Settings.hasTouchScreen)
internal.flickableItem.interactive = false
}
children: Item {
id: internal
property Flickable flickableItem
Loader {
id: styleLoader
sourceComponent: style
onStatusChanged: {
if (status === Loader.Error)
console.error("Failed to load Style for", root)
}
property alias __control: root
}
Binding {
target: flickableItem
property: "contentHeight"
when: contentItem !== flickableItem
value: contentItem ? contentItem.height : 0
}
Binding {
target: flickableItem
when: contentItem !== flickableItem
property: "contentWidth"
value: contentItem ? contentItem.width : 0
}
Connections {
target: flickableItem
onContentYChanged: {
scroller.blockUpdates = true
scroller.verticalScrollBar.value = flickableItem.contentY - flickableItem.originY
scroller.blockUpdates = false
}
onContentXChanged: {
scroller.blockUpdates = true
scroller.horizontalScrollBar.value = flickableItem.contentX - flickableItem.originX
scroller.blockUpdates = false
}
}
anchors.fill: parent
Component {
id: flickableComponent
Flickable {}
}
WheelArea {
id: wheelArea
parent: flickableItem
z: -1
// ### Note this is needed due to broken mousewheel behavior in Flickable.
anchors.fill: parent
property int acceleration: 40
property int flickThreshold: Settings.dragThreshold
property real speedThreshold: 3
property real ignored: 0.001 // ## flick() does not work with 0 yVelocity
property int maxFlick: 400
property bool horizontalRecursionGuard: false
property bool verticalRecursionGuard: false
horizontalMinimumValue: 0
horizontalMaximumValue: flickableItem ? flickableItem.contentWidth - viewport.width : 0
verticalMinimumValue: 0
verticalMaximumValue: flickableItem ? flickableItem.contentHeight - viewport.height + __viewTopMargin : 0
// The default scroll speed for typical angle-based mouse wheels. The value
// comes originally from QTextEdit, which sets 20px steps by default, as well as
// QQuickWheelArea.
// TODO: centralize somewhere, QPlatformTheme?
scrollSpeed: 20 * (__style && __style.__wheelScrollLines || 1)
Connections {
target: flickableItem
onContentYChanged: {
wheelArea.verticalRecursionGuard = true
wheelArea.verticalValue = flickableItem.contentY - flickableItem.originY
wheelArea.verticalRecursionGuard = false
}
onContentXChanged: {
wheelArea.horizontalRecursionGuard = true
wheelArea.horizontalValue = flickableItem.contentX - flickableItem.originX
wheelArea.horizontalRecursionGuard = false
}
}
onVerticalValueChanged: {
if (!verticalRecursionGuard) {
var effectiveContentY = flickableItem.contentY - flickableItem.originY
if (effectiveContentY < flickThreshold && verticalDelta > speedThreshold) {
flickableItem.flick(ignored, Math.min(maxFlick, acceleration * verticalDelta))
} else if (effectiveContentY > flickableItem.contentHeight - flickThreshold - viewport.height
&& verticalDelta < -speedThreshold) {
flickableItem.flick(ignored, Math.max(-maxFlick, acceleration * verticalDelta))
} else {
flickableItem.contentY = verticalValue + flickableItem.originY
}
flickableItem.contentY = Math.min(verticalMaximumValue, Math.max(0, flickableItem.contentY));
}
}
onHorizontalValueChanged: {
if (!horizontalRecursionGuard)
flickableItem.contentX = horizontalValue + flickableItem.originX
}
}
ScrollViewHelper {
id: scroller
anchors.fill: parent
active: wheelArea.active
property bool outerFrame: !frameVisible || !(__style ? __style.__externalScrollBars : 0)
property int scrollBarSpacing: outerFrame ? 0 : (__style ? __style.__scrollBarSpacing : 0)
property int verticalScrollbarOffset: verticalScrollBar.visible && !verticalScrollBar.isTransient ?
verticalScrollBar.width + scrollBarSpacing : 0
property int horizontalScrollbarOffset: horizontalScrollBar.visible && !horizontalScrollBar.isTransient ?
horizontalScrollBar.height + scrollBarSpacing : 0
Loader {
id: frameLoader
sourceComponent: __style ? __style.frame : null
anchors.fill: parent
anchors.rightMargin: scroller.outerFrame ? 0 : scroller.verticalScrollbarOffset
anchors.bottomMargin: scroller.outerFrame ? 0 : scroller.horizontalScrollbarOffset
}
Item {
id: viewportItem
anchors.fill: frameLoader
anchors.topMargin: frameVisible ? __style.padding.top : 0
anchors.leftMargin: frameVisible ? __style.padding.left : 0
anchors.rightMargin: (frameVisible ? __style.padding.right : 0) + (scroller.outerFrame ? scroller.verticalScrollbarOffset : 0)
anchors.bottomMargin: (frameVisible ? __style.padding.bottom : 0) + (scroller.outerFrame ? scroller.horizontalScrollbarOffset : 0)
clip: true
}
}
FocusFrame { visible: highlightOnFocus && root.activeFocus }
}
}

View File

@ -1,403 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL3$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see http://www.qt.io/terms-conditions. For further
** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 3 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPLv3 included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 3 requirements
** will be met: https://www.gnu.org/licenses/lgpl.html.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 2.0 or later as published by the Free
** Software Foundation and appearing in the file LICENSE.GPL included in
** the packaging of this file. Please review the following information to
** ensure the GNU General Public License version 2.0 requirements will be
** met: http://www.gnu.org/licenses/gpl-2.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
import QtQuick 2.2
import QtQuick.Controls 1.2
import QtQuick.Controls.Private 1.0
/*!
\qmltype ScrollViewStyle
\inqmlmodule QtQuick.Controls.Styles
\since 5.1
\ingroup viewsstyling
\ingroup controlsstyling
\brief Provides custom styling for ScrollView
*/
Style {
id: root
/*! The \l ScrollView this style is attached to. */
readonly property ScrollView control: __control
/*! This property controls the frame border padding of the scrollView. */
padding {left: 1; top: 1; right: 1; bottom: 1}
/*! This Component paints the corner area between scroll bars */
property Component corner: Rectangle { color: "#ccc" }
/*! This component determines if the flickable should reposition itself at the
mouse location when clicked. */
property bool scrollToClickedPosition: true
/*! This property holds whether the scroll bars are transient. Transient scroll bars
appear when the content is scrolled and disappear when they are no longer needed.
The default value is platform dependent. */
property bool transientScrollBars: Settings.isMobile && Settings.hasTouchScreen
/*! This Component paints the frame around scroll bars. */
property Component frame: Rectangle {
color: control["backgroundVisible"] ? "white": "transparent"
border.color: "#999"
border.width: 1
radius: 1
visible: control.frameVisible
}
/*! This is the minimum extent of the scroll bar handle.
The default value is \c 30.
*/
property int minimumHandleLength: 30
/*! This property controls the edge overlap
between the handle and the increment/decrement buttons.
The default value is \c 30.
*/
property int handleOverlap: 1
/*! This component controls the appearance of the
scroll bar background.
You can access the following state properties:
\table
\row \li property bool \b styleData.hovered
\row \li property bool \b styleData.horizontal
\endtable
*/
property Component scrollBarBackground: Item {
property bool sticky: false
property bool hovered: styleData.hovered
implicitWidth: Math.round(TextSingleton.implicitHeight)
implicitHeight: Math.round(TextSingleton.implicitHeight)
clip: true
opacity: transientScrollBars ? 0.5 : 1.0
visible: !Settings.hasTouchScreen && (!transientScrollBars || sticky)
Rectangle {
anchors.fill: parent
color: "#ddd"
border.color: "#aaa"
anchors.rightMargin: styleData.horizontal ? -2 : -1
anchors.leftMargin: styleData.horizontal ? -2 : 0
anchors.topMargin: styleData.horizontal ? 0 : -2
anchors.bottomMargin: styleData.horizontal ? -1 : -2
}
onHoveredChanged: if (hovered) sticky = true
onVisibleChanged: if (!visible) sticky = false
}
/*! This component controls the appearance of the
scroll bar handle.
You can access the following state properties:
\table
\row \li property bool \b styleData.hovered
\row \li property bool \b styleData.pressed
\row \li property bool \b styleData.horizontal
\endtable
*/
property Component handle: Item {
property bool sticky: false
property bool hovered: __activeControl !== "none"
implicitWidth: Math.round(TextSingleton.implicitHeight) + 1
implicitHeight: Math.round(TextSingleton.implicitHeight) + 1
BorderImage {
id: img
opacity: styleData.pressed && !transientScrollBars ? 0.5 : styleData.hovered ? 1 : 0.8
source: "images/scrollbar-handle-" + (transientScrollBars ? "transient" : styleData.horizontal ? "horizontal" : "vertical") + ".png"
border.left: transientScrollBars ? 5 : 2
border.top: transientScrollBars ? 5 : 2
border.right: transientScrollBars ? 5 : 2
border.bottom: transientScrollBars ? 5 : 2
anchors.top: !styleData.horizontal ? parent.top : undefined
anchors.margins: transientScrollBars ? 2 : 0
anchors.bottom: parent.bottom
anchors.right: parent.right
anchors.left: styleData.horizontal ? parent.left : undefined
width: !styleData.horizontal && transientScrollBars ? sticky ? 13 : 10 : parent.width
height: styleData.horizontal && transientScrollBars ? sticky ? 13 : 10 : parent.height
Behavior on width { enabled: !styleData.horizontal && transientScrollBars; NumberAnimation { duration: 100 } }
Behavior on height { enabled: styleData.horizontal && transientScrollBars; NumberAnimation { duration: 100 } }
}
onHoveredChanged: if (hovered) sticky = true
onVisibleChanged: if (!visible) sticky = false
}
/*! This component controls the appearance of the
scroll bar increment button.
You can access the following state properties:
\table
\row \li property bool \b styleData.hovered
\row \li property bool \b styleData.pressed
\row \li property bool \b styleData.horizontal
\endtable
*/
property Component incrementControl: Rectangle {
visible: !transientScrollBars
implicitWidth: transientScrollBars ? 0 : Math.round(TextSingleton.implicitHeight)
implicitHeight: transientScrollBars ? 0 : Math.round(TextSingleton.implicitHeight)
Rectangle {
anchors.fill: parent
anchors.bottomMargin: -1
anchors.rightMargin: -1
border.color: "#aaa"
Rectangle {
anchors.fill: parent
anchors.margins: 1
color: "transparent"
border.color: "#44ffffff"
}
Image {
source: styleData.horizontal ? "images/arrow-right.png" : "images/arrow-down.png"
anchors.centerIn: parent
opacity: control.enabled ? 0.6 : 0.5
}
gradient: Gradient {
GradientStop {color: styleData.pressed ? "lightgray" : "white" ; position: 0}
GradientStop {color: styleData.pressed ? "lightgray" : "lightgray" ; position: 1}
}
}
}
/*! This component controls the appearance of the
scroll bar decrement button.
You can access the following state properties:
\table
\row \li property bool \b styleData.hovered
\row \li property bool \b styleData.pressed
\row \li property bool \b styleData.horizontal
\endtable
*/
property Component decrementControl: Rectangle {
visible: !transientScrollBars
implicitWidth: transientScrollBars ? 0 : Math.round(TextSingleton.implicitHeight)
implicitHeight: transientScrollBars ? 0 : Math.round(TextSingleton.implicitHeight)
Rectangle {
anchors.fill: parent
anchors.topMargin: styleData.horizontal ? 0 : -1
anchors.leftMargin: styleData.horizontal ? -1 : 0
anchors.bottomMargin: styleData.horizontal ? -1 : 0
anchors.rightMargin: styleData.horizontal ? 0 : -1
color: "lightgray"
Rectangle {
anchors.fill: parent
anchors.margins: 1
color: "transparent"
border.color: "#44ffffff"
}
Image {
source: styleData.horizontal ? "images/arrow-left.png" : "images/arrow-up.png"
anchors.centerIn: parent
anchors.verticalCenterOffset: styleData.horizontal ? 0 : -1
anchors.horizontalCenterOffset: styleData.horizontal ? -1 : 0
opacity: control.enabled ? 0.6 : 0.5
}
gradient: Gradient {
GradientStop {color: styleData.pressed ? "lightgray" : "white" ; position: 0}
GradientStop {color: styleData.pressed ? "lightgray" : "lightgray" ; position: 1}
}
border.color: "#aaa"
}
}
/*! \internal */
property Component __scrollbar: Item {
id: panel
property string activeControl: "none"
property bool scrollToClickPosition: true
property bool isTransient: transientScrollBars
property bool on: false
property bool raised: false
property bool sunken: __styleData.upPressed | __styleData.downPressed | __styleData.handlePressed
states: State {
name: "out"
when: isTransient
&& (!__stickyScrollbars || !flickableItem.moving)
&& panel.activeControl === "none"
&& !panel.on
&& !panel.raised
PropertyChanges { target: panel; opacity: 0 }
}
transitions: Transition {
to: "out"
SequentialAnimation {
PauseAnimation { duration: root.__scrollBarFadeDelay }
NumberAnimation { properties: "opacity"; duration: root.__scrollBarFadeDuration }
PropertyAction { target: panel; property: "visible"; value: false }
}
}
implicitWidth: __styleData.horizontal ? 200 : bg.implicitWidth
implicitHeight: __styleData.horizontal ? bg.implicitHeight : 200
function pixelMetric(arg) {
if (arg === "scrollbarExtent")
return (__styleData.horizontal ? bg.height : bg.width);
return 0;
}
function styleHint(arg) {
return false;
}
function hitTest(argX, argY) {
if (itemIsHit(handleControl, argX, argY))
return "handle"
else if (itemIsHit(incrementLoader, argX, argY))
return "up";
else if (itemIsHit(decrementLoader, argX, argY))
return "down";
else if (itemIsHit(bg, argX, argY)) {
if (__styleData.horizontal && argX < handleControl.x || !__styleData.horizontal && argY < handleControl.y)
return "upPage"
else
return "downPage"
}
return "none";
}
function subControlRect(arg) {
if (arg === "handle") {
return Qt.rect(handleControl.x, handleControl.y, handleControl.width, handleControl.height);
} else if (arg === "groove") {
if (__styleData.horizontal) {
return Qt.rect(incrementLoader.width - handleOverlap,
0,
__control.width - (incrementLoader.width + decrementLoader.width - handleOverlap * 2),
__control.height);
} else {
return Qt.rect(0,
incrementLoader.height - handleOverlap,
__control.width,
__control.height - (incrementLoader.height + decrementLoader.height - handleOverlap * 2));
}
}
return Qt.rect(0,0,0,0);
}
function itemIsHit(argItem, argX, argY) {
var pos = argItem.mapFromItem(__control, argX, argY);
return (pos.x >= 0 && pos.x <= argItem.width && pos.y >= 0 && pos.y <= argItem.height);
}
Loader {
id: incrementLoader
anchors.top: parent.top
anchors.left: parent.left
sourceComponent: decrementControl
property QtObject styleData: QtObject {
readonly property bool hovered: activeControl === "up"
readonly property bool pressed: __styleData.upPressed
readonly property bool horizontal: __styleData.horizontal
}
}
Loader {
id: bg
anchors.top: __styleData.horizontal ? undefined : incrementLoader.bottom
anchors.bottom: __styleData.horizontal ? undefined : decrementLoader.top
anchors.left: __styleData.horizontal ? incrementLoader.right : undefined
anchors.right: __styleData.horizontal ? decrementLoader.left : undefined
sourceComponent: scrollBarBackground
property QtObject styleData: QtObject {
readonly property bool horizontal: __styleData.horizontal
readonly property bool hovered: activeControl !== "none"
}
}
Loader {
id: decrementLoader
anchors.bottom: __styleData.horizontal ? undefined : parent.bottom
anchors.right: __styleData.horizontal ? parent.right : undefined
sourceComponent: incrementControl
property QtObject styleData: QtObject {
readonly property bool hovered: activeControl === "down"
readonly property bool pressed: __styleData.downPressed
readonly property bool horizontal: __styleData.horizontal
}
}
property var flickableItem: control.flickableItem
property int extent: Math.max(minimumHandleLength, __styleData.horizontal ?
(flickableItem ? flickableItem.width/flickableItem.contentWidth : 0 ) * bg.width :
(flickableItem ? flickableItem.height/flickableItem.contentHeight : 0) * bg.height)
readonly property real range: __control.maximumValue - __control.minimumValue
readonly property real begin: __control.value - __control.minimumValue
Loader {
id: handleControl
height: __styleData.horizontal ? implicitHeight : extent
width: __styleData.horizontal ? extent : implicitWidth
anchors.top: bg.top
anchors.left: bg.left
anchors.topMargin: __styleData.horizontal || range === 0 ? 0 : -handleOverlap + (2 * begin * (bg.height + (2 * handleOverlap) - extent) + range) / (2 * range)
anchors.leftMargin: __styleData.horizontal && range !== 0 ? -handleOverlap + (2 * begin * (bg.width + (2 * handleOverlap) - extent) + range) / (2 * range) : 0
sourceComponent: handle
property QtObject styleData: QtObject {
readonly property bool hovered: activeControl === "handle"
readonly property bool pressed: __styleData.handlePressed
readonly property bool horizontal: __styleData.horizontal
}
readonly property alias __activeControl: panel.activeControl
}
}
/*! \internal */
property bool __externalScrollBars: false
/*! \internal */
property int __scrollBarSpacing: 4
/*! \internal */
property int __scrollBarFadeDelay: 450
/*! \internal */
property int __scrollBarFadeDuration: 200
/*! \internal */
property bool __stickyScrollbars: false
}

View File

@ -48,6 +48,8 @@
#include "QsLog.h"
#include <QRegExp>
using stefanfrings::HttpRequest;
using stefanfrings::HttpRequestHandler;
using stefanfrings::HttpResponse;

View File

@ -117,7 +117,7 @@ ServerConfigDialog::ServerConfigDialog(QWidget *parent)
portLabel->setStyleSheet("QLabel {color:#575757; font-size:18px; font-family: Arial;}");
ip = new QComboBox(this);
connect(ip, QOverload<const QString &>::of(&QComboBox::activated), this, &ServerConfigDialog::regenerateQR);
connect(ip, &QComboBox::currentTextChanged, this, &ServerConfigDialog::regenerateQR);
ip->setFixedWidth(200);
ip->move(332, 153);
@ -135,7 +135,7 @@ ServerConfigDialog::ServerConfigDialog(QWidget *parent)
auto portWidgetLayout = new QHBoxLayout(this);
portWidgetLayout->addWidget(port);
portWidgetLayout->addWidget(accept);
portWidgetLayout->setMargin(0);
portWidgetLayout->setContentsMargins(0, 0, 0, 0);
portWidget->setLayout(portWidgetLayout);
portWidget->move(332, 244);
// accept->move(514,149);

View File

@ -37,7 +37,7 @@ void XMLInfoLibraryScanner::run()
#endif
if (!sevenzLib->load()) {
QLOG_ERROR() << "Loading 7z.dll : " + sevenzLib->errorString() << endl;
QLOG_ERROR() << "Loading 7z.dll : " + sevenzLib->errorString() << Qt::endl;
QCoreApplication::exit(YACReader::SevenZNotFound);
exit();
}

View File

@ -114,7 +114,7 @@ bool tryValues(QXmlStreamReader &reader, ComicInfo &info)
}
}
if (reader.name() == "BlackAndWhite") {
if (reader.name() == QString("BlackAndWhite")) {
auto string = reader.readElementText();
if (isValidText(string)) {
if (string == "Yes") {
@ -127,7 +127,7 @@ bool tryValues(QXmlStreamReader &reader, ComicInfo &info)
return true;
}
if (reader.name() == "Manga") {
if (reader.name() == QString("Manga")) {
auto string = reader.readElementText();
if (isValidText(string)) {
if (string == "Yes" || string == "YesAndRightToLeft") {
@ -140,7 +140,7 @@ bool tryValues(QXmlStreamReader &reader, ComicInfo &info)
return true;
}
if (reader.name() == "Web") {
if (reader.name() == QString("Web")) {
auto string = reader.readElementText();
if (isValidText(string)) {
auto comicVineId = string.split("-").last().replace("/", "");
@ -168,7 +168,7 @@ bool YACReader::parseXMLIntoInfo(const QByteArray &xmlRawData, ComicInfo &info)
if (tryValues(reader, info)) {
someDataWasParsed = true;
} else {
if (reader.name() != "ComicInfo") {
if (reader.name() != QString("ComicInfo")) {
reader.skipCurrentElement();
}
}

View File

@ -50,7 +50,7 @@ YACReaderMainToolBar::YACReaderMainToolBar(QWidget *parent)
fullscreenButton->setStyleSheet(qToolButtonStyleSheet);
fullscreenButton->setIconSize(QSize(24, 24));
mainLayout->setMargin(0);
mainLayout->setContentsMargins(0, 0, 0, 0);
mainLayout->setSpacing(0);
mainLayout->addSpacing(12);

View File

@ -16,6 +16,8 @@ DEFINES += SERVER_RELEASE NOMINMAX YACREADER_LIBRARY
include(headless_config.pri)
include(../dependencies/pdf_backend.pri)
greaterThan(QT_MAJOR_VERSION, 5): QT += core5compat
win32 {
LIBS += -loleaut32 -lole32 -lshell32 -luser32
QMAKE_CXXFLAGS_RELEASE += /MP /Ob2 /Oi /Ot /GT /GL
@ -37,6 +39,8 @@ unix:haiku {
CONFIG -= flat
QT += core sql network
greaterThan(QT_MAJOR_VERSION, 5): QT += core5compat
# Source files
HEADERS += ../YACReaderLibrary/library_creator.h \
../YACReaderLibrary/package_manager.h \

View File

@ -119,7 +119,7 @@ int main(int argc, char **argv)
if (parser.isSet(versionOption)) {
qout << "YACReaderLibraryServer"
<< " " << VERSION << endl;
<< " " << VERSION << Qt::endl;
return 0;
}
@ -199,7 +199,7 @@ int main(int argc, char **argv)
bool valid;
qint32 port = parser.value("port").toInt(&valid);
if (!valid || port < 1 || port > 65535) {
qout << "Error: " << parser.value("port") << " is not a valid port" << endl;
qout << "Error: " << parser.value("port") << " is not a valid port" << Qt::endl;
parser.showHelp();
return 0;
} else {
@ -304,7 +304,7 @@ int main(int argc, char **argv)
YACReaderLibraries libraries = DBHelper::getLibraries();
for (QString libraryName : libraries.getNames())
qout << libraryName << " : " << libraries.getPath(libraryName) << endl;
qout << libraryName << " : " << libraries.getPath(libraryName) << Qt::endl;
return 0;
} else if (command == "set-port") {

View File

@ -30,14 +30,16 @@ jobs:
- job: Linux
dependsOn: CodeFormatValidation
pool:
vmImage: 'ubuntu-18.04'
vmImage: 'ubuntu-20.04'
steps:
- script: |
sudo add-apt-repository 'deb http://download.opensuse.org/repositories/home:/selmf/xUbuntu_18.04/ /'
wget -qO - 'http://archive.neon.kde.org/public.key' | sudo apt-key add -
sudo apt-add-repository http://archive.neon.kde.org/dev/unstable
sudo apt-get update --allow-insecure-repositories
sudo apt-get install -y --allow-unauthenticated qt5-default qt5-qmake \
qtbase5-dev qtmultimedia5-dev libpoppler-qt5-dev \
libqt5opengl5-dev libunarr-dev qtdeclarative5-dev libqt5svg5-dev
libqt5opengl5-dev libunarr-dev qtdeclarative5-dev libqt5svg5-dev qtquickcontrols2-5-dev
displayName: 'Install dependencies'
- script: |
cd $(Build.SourcesDirectory)
@ -131,7 +133,7 @@ jobs:
variables:
- group: artifactory
pool:
vmImage: 'ubuntu-18.04'
vmImage: 'ubuntu-20.04'
steps:
- task: DownloadPipelineArtifact@2
inputs:
@ -159,7 +161,7 @@ jobs:
variables:
- group: github-releases
pool:
vmImage: 'ubuntu-18.04'
vmImage: 'ubuntu-20.04'
steps:
- task: DownloadPipelineArtifact@2
inputs:

View File

@ -142,8 +142,8 @@ void BookmarksList::deleteOldest(int num)
{
Q_UNUSED(num)
QString comic;
QDateTime date(QDate(10000, 1, 1)); // TODO MAX_DATE??
for (QMap<QString, Bookmark>::const_iterator itr = list.begin(); itr != list.end(); itr++) {
auto date = QDate().endOfDay();
for (QMap<QString, Bookmark>::const_iterator itr = list.constBegin(); itr != list.constEnd(); itr++) {
if (itr->added < date) {
comic = itr.key();
date = itr->added;

View File

@ -9,6 +9,7 @@
#include <QTimer>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QRegExp>
#define PREVIOUS_VERSION_TESTING "6.0.0"
@ -27,7 +28,6 @@ bool HttpVersionChecker::checkNewVersion(QString sourceContent)
{
QRegExp rx("#define VERSION \"([0-9]+).([0-9]+).([0-9]+)\"");
int index = 0;
bool newVersion = false;
bool sameVersion = true;
// bool currentVersionIsNewer = false;
@ -37,7 +37,7 @@ bool HttpVersionChecker::checkNewVersion(QString sourceContent)
QString version(VERSION);
#endif
QStringList sl = version.split(".");
if ((index = rx.indexIn(sourceContent)) != -1) {
if (rx.indexIn(sourceContent) != -1) {
int length = qMin(sl.size(), (rx.cap(4) != "") ? 4 : 3);
for (int i = 0; i < length; i++) {
if (rx.cap(i + 1).toInt() < sl.at(i).toInt()) {

View File

@ -1,7 +1,7 @@
#include "comic.h"
#include <QPixmap>
#include <QRegExp>
#include <QRegularExpression>
#include <QString>
#include <algorithm>
#include <QDir>
@ -27,7 +27,7 @@ QStringList Comic::getSupportedImageFormats()
{
QList<QByteArray> supportedImageFormats = QImageReader::supportedImageFormats();
QStringList supportedImageFormatStrings;
for (QByteArray item : supportedImageFormats) {
for (QByteArray &item : supportedImageFormats) {
supportedImageFormatStrings.append(QString::fromLocal8Bit("*." + item));
}
return supportedImageFormatStrings;
@ -37,7 +37,7 @@ QStringList Comic::getSupportedImageLiteralFormats()
{
QList<QByteArray> supportedImageFormats = QImageReader::supportedImageFormats();
QStringList supportedImageFormatStrings;
for (QByteArray item : supportedImageFormats) {
for (QByteArray &item : supportedImageFormats) {
supportedImageFormatStrings.append(QString::fromLocal8Bit(item));
}
return supportedImageFormatStrings;
@ -352,7 +352,7 @@ FileComic::FileComic()
FileComic::FileComic(const QString &path, int atPage)
: Comic(path, atPage)
{
load(path, atPage);
FileComic::load(path, atPage);
}
FileComic::~FileComic()
@ -604,7 +604,7 @@ void FileComic::process()
}
_index = _firstPage;
emit(openAt(_index));
emit openAt(_index);
int sectionIndex;
QList<QVector<quint32>> sections = getSections(sectionIndex);
@ -649,7 +649,7 @@ FolderComic::FolderComic()
FolderComic::FolderComic(const QString &path, int atPage)
: Comic(path, atPage)
{
load(path, atPage);
FolderComic::load(path, atPage);
}
FolderComic::~FolderComic()
@ -701,7 +701,7 @@ void FolderComic::process()
_index = _firstPage;
emit(openAt(_index));
emit openAt(_index);
emit pageChanged(0); // this indicates new comic, index=0
emit numPages(_pages.size());
@ -745,7 +745,7 @@ PDFComic::PDFComic()
PDFComic::PDFComic(const QString &path, int atPage)
: Comic(path, atPage)
{
load(path, atPage);
PDFComic::load(path, atPage);
}
PDFComic::~PDFComic()
@ -847,7 +847,7 @@ void PDFComic::process()
}
_index = _firstPage;
emit(openAt(_index));
emit openAt(_index);
// buffer index to avoid race conditions
int buffered_index = _index;
@ -994,15 +994,16 @@ QString get_most_common_prefix(const QList<QString> &pageNames)
uint maxFrequency = 0;
QString common_prefix = "";
foreach (QString key, frequency.keys()) {
auto keys = frequency.keys();
for (QString &key : keys) {
if (maxFrequency < frequency.value(key)) {
maxFrequency = frequency.value(key);
common_prefix = key;
}
}
QRegExp allNumberRegExp("\\d+");
if (allNumberRegExp.exactMatch(common_prefix)) {
QRegularExpression allNumberRegExp("\\A\\d+\\z");
if (allNumberRegExp.match(common_prefix).hasMatch()) {
return "";
}

View File

@ -123,8 +123,8 @@ public:
FileComic();
FileComic(const QString &path, int atPage = -1);
~FileComic();
virtual bool load(const QString &path, int atPage = -1);
virtual bool load(const QString &path, const ComicDB &comic);
bool load(const QString &path, int atPage = -1);
bool load(const QString &path, const ComicDB &comic);
static QList<QString> filter(const QList<QString> &src);
// ExtractDelegate
@ -150,7 +150,7 @@ public:
FolderComic(const QString &path, int atPage = -1);
~FolderComic();
virtual bool load(const QString &path, int atPage = -1);
bool load(const QString &path, int atPage = -1);
public slots:
@ -179,8 +179,8 @@ public:
PDFComic(const QString &path, int atPage = -1);
~PDFComic();
virtual bool load(const QString &path, int atPage = -1);
virtual bool load(const QString &path, const ComicDB &comic);
bool load(const QString &path, int atPage = -1);
bool load(const QString &path, const ComicDB &comic);
public slots:

View File

@ -253,7 +253,7 @@ public:
Q_PROPERTY(ComicInfo info MEMBER info)
ComicDB &operator=(const ComicDB &other);
bool operator==(const ComicDB &other) { return id == other.id; }
bool operator==(const ComicDB &other) const { return id == other.id; }
friend QDataStream &operator<<(QDataStream &, const ComicDB &);
friend QDataStream &operator>>(QDataStream &, ComicDB &);

View File

@ -950,7 +950,7 @@ void YACReaderFlowGL::setShowMarks(bool value)
showMarks = value;
}
void YACReaderFlowGL::setMarks(QVector<YACReaderComicReadStatus> marks)
void YACReaderFlowGL::setMarks(QVector<YACReader::YACReaderComicReadStatus> marks)
{
startAnimationTimer();
@ -963,7 +963,7 @@ void YACReaderFlowGL::setMarkImage(QImage &image)
// deleteTexture(markTexture);
// markTexture = bindTexture(image,GL_TEXTURE_2D,GL_RGBA,QGLContext::LinearFilteringBindOption | QGLContext::MipmapBindOption);
}
void YACReaderFlowGL::markSlide(int index, YACReaderComicReadStatus status)
void YACReaderFlowGL::markSlide(int index, YACReader::YACReaderComicReadStatus status)
{
startAnimationTimer();
@ -1276,7 +1276,7 @@ YACReaderPageFlowGL::~YACReaderPageFlowGL()
makeCurrent();
for (auto image : images) {
for (auto &image : images) {
if (image.texture != defaultTexture) {
if (image.texture->isCreated()) {
image.texture->destroy();

View File

@ -2,9 +2,17 @@
#ifndef __YACREADER_FLOW_GL_H
#define __YACREADER_FLOW_GL_H
#include <QtGlobal>
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
#include <QtOpenGLWidgets/QOpenGLWidget>
#include <QtOpenGL/QOpenGLTexture>
#else
#include <QOpenGLWidget>
#include <QOpenGLFunctions>
#include <QOpenGLTexture>
#endif
#include <QOpenGLFunctions>
#include <QtWidgets>
#include "pictureflow.h" //TODO mover los tipos de flow de sitio
@ -252,9 +260,9 @@ public slots:
// interface with yacreaderlibrary, compatibility
void setShowMarks(bool value);
void setMarks(QVector<YACReaderComicReadStatus> marks);
void setMarks(QVector<YACReader::YACReaderComicReadStatus> marks);
void setMarkImage(QImage &image);
void markSlide(int index, YACReaderComicReadStatus status);
void markSlide(int index, YACReader::YACReaderComicReadStatus status);
void unmarkSlide(int index);
void setSlideSize(QSize size);
void clear();

View File

@ -26,6 +26,8 @@
#include "pictureflow.h"
#include <QElapsedTimer>
// detect Qt version
#if QT_VERSION >= 0x040000
#define PICTUREFLOW_QT4
@ -1281,8 +1283,8 @@ void PictureFlow::resizeEvent(QResizeEvent *event)
#include <QTime>
void PictureFlow::updateAnimation() // bucle principal
{
QTime now;
now.start();
QElapsedTimer timer;
timer.start();
bool frameSkiped = false;
int old_center = d->state->centerIndex;
@ -1297,7 +1299,7 @@ void PictureFlow::updateAnimation() // bucle principal
if (d->state->centerIndex != old_center)
emit centerIndexChangedSilent(d->state->centerIndex);
if (d->animator->animating == true) {
int difference = 10 - now.elapsed();
int difference = 10 - timer.elapsed();
if (difference >= 0 && !frameSkiped)
QTimer::singleShot(difference, this, &PictureFlow::updateAnimation);
else {
@ -1338,7 +1340,7 @@ void PictureFlow::setMarkImage(const QImage &m)
d->state->mark = m;
}
void PictureFlow::markSlide(int index, YACReaderComicReadStatus readStatus)
void PictureFlow::markSlide(int index, YACReader::YACReaderComicReadStatus readStatus)
{
if (index < d->state->marks.size())
d->state->marks[index] = readStatus;
@ -1356,7 +1358,7 @@ void PictureFlow::unmarkSlide(int index)
d->state->marks[index] = YACReader::Unread;
}
void PictureFlow::setMarks(const QVector<YACReaderComicReadStatus> &m)
void PictureFlow::setMarks(const QVector<YACReader::YACReaderComicReadStatus> &m)
{
d->state->marks = m;
updateMarks();

View File

@ -187,21 +187,21 @@ public slots:
*/
void triggerRender();
void setFlowType(FlowType flowType);
void setFlowType(YACReader::FlowType flowType);
void setMarkImage(const QImage &mark);
void markSlide(int index, YACReaderComicReadStatus readStatus = Read);
void markSlide(int index, YACReader::YACReaderComicReadStatus readStatus = Read);
void updateMarks();
void unmarkSlide(int index);
void setMarks(const QVector<YACReaderComicReadStatus> &marks);
void setMarks(const QVector<YACReader::YACReaderComicReadStatus> &marks);
void setShowMarks(bool enable);
QVector<YACReaderComicReadStatus> getMarks();
QVector<YACReader::YACReaderComicReadStatus> getMarks();
void resortCovers(QList<int> newOrder);

View File

@ -2,7 +2,7 @@
ScrollManagement::ScrollManagement()
{
wheelTimer = new QTime();
wheelTimer = new QElapsedTimer();
wheelTimer->start();
wheelAccumulator = 0;
}
@ -23,10 +23,10 @@ ScrollManagement::Movement ScrollManagement::getMovement(QWheelEvent *event)
}
// Accumulate the delta
if ((event->delta() < 0) != (wheelAccumulator < 0)) // different sign means change in direction
if ((event->angleDelta().y() < 0) != (wheelAccumulator < 0)) // different sign means change in direction
wheelAccumulator = 0;
wheelAccumulator += event->delta();
wheelAccumulator += event->angleDelta().y();
// Do not process events too fast
if ((wheelTimer->elapsed() < timeThrottle)) {

View File

@ -1,7 +1,7 @@
#ifndef SCROLLMANAGAMENT_H
#define SCROLLMANAGAMENT_H
#include <QTime>
#include <QElapsedTimer>
#include <QWheelEvent>
class ScrollManagement
@ -18,7 +18,7 @@ public:
~ScrollManagement();
private:
QTime *wheelTimer;
QElapsedTimer *wheelTimer;
int wheelAccumulator;
};

View File

@ -4,11 +4,7 @@ using namespace YACReader;
QString YACReader::getSettingsPath()
{
#if QT_VERSION >= 0x050000
return QStandardPaths::writableLocation(QStandardPaths::DataLocation);
#else
return QDesktopServices::storageLocation(QDesktopServices::DataLocation);
#endif
return QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation);
}
QString YACReader::colorToName(LabelColors colors)

View File

@ -3,6 +3,7 @@
#include <QStandardPaths>
#include <QDataStream>
#include <QMetaType>
#define VERSION "9.8.2"

View File

@ -206,11 +206,11 @@ CompressedArchive::CompressedArchive(const QString &filePath, QObject *parent)
// GUID uuid = supportedFileFormats[i];
// qDebug() << "trying : " << uuid << endl;
if (szInterface->createObjectFunc(&supportedFileFormats[i], &IID_InArchive, (void **)&szInterface->archive) == S_OK) {
// qDebug() << "Can not open archive file : " + filePath << endl;
// qDebug() << "Can not open archive file : " + filePath << Qt::endl;
if (szInterface->archive->Open(file, 0, openCallback) == S_OK) {
valid = formatFound = true;
qDebug() << "Opened archive file : " + filePath << endl;
qDebug() << "Opened archive file : " + filePath << Qt::endl;
setupFilesNames();
return;
}
@ -218,7 +218,7 @@ CompressedArchive::CompressedArchive(const QString &filePath, QObject *parent)
#ifdef Q_OS_WIN
if (!formatFound) {
qDebug() << "Can not open archive" << endl;
qDebug() << "Can not open archive" << Qt::endl;
}
}
}
@ -258,7 +258,7 @@ CompressedArchive::CompressedArchive(const QString &filePath, QObject *parent)
qDebug() << "Error opening rar file :" + filePath;
return;
}
// qDebug() << "Can not open archive file : " + filePath << endl;
// qDebug() << "Can not open archive file : " + filePath << Qt::endl;
if (szInterface->archive->Open(file, 0, openCallback) == S_OK) {
valid = formatFound = true;
@ -311,7 +311,7 @@ CompressedArchive::CompressedArchive(const QString &filePath, QObject *parent)
}
#endif
if (!rarLib->load()) {
qDebug() << "Error Loading Rar.so : " + rarLib->errorString() << endl;
qDebug() << "Error Loading Rar.so : " + rarLib->errorString() << Qt::endl;
QCoreApplication::exit(700); // TODO yacreader_global can't be used here, it is GUI dependant, YACReader::SevenZNotFound
return false;
}
@ -328,34 +328,34 @@ CompressedArchive::CompressedArchive(const QString &filePath, QObject *parent)
#endif
}
if (!sevenzLib->load()) {
qDebug() << "Error Loading 7z.dll : " + sevenzLib->errorString() << endl;
qDebug() << "Error Loading 7z.dll : " + sevenzLib->errorString() << Qt::endl;
QCoreApplication::exit(700); // TODO yacreader_global can't be used here, it is GUI dependant, YACReader::SevenZNotFound
return false;
} else {
qDebug() << "Loading functions" << endl;
qDebug() << "Loading functions" << Qt::endl;
if ((szInterface->createObjectFunc = (CreateObjectFunc)sevenzLib->resolve("CreateObject")) == 0)
qDebug() << "fail loading function : CreateObject" << endl;
qDebug() << "fail loading function : CreateObject" << Qt::endl;
if ((szInterface->getMethodPropertyFunc = (GetMethodPropertyFunc)sevenzLib->resolve("GetMethodProperty")) == 0)
qDebug() << "fail loading function : GetMethodProperty" << endl;
qDebug() << "fail loading function : GetMethodProperty" << Qt::endl;
if ((szInterface->getNumberOfMethodsFunc = (GetNumberOfMethodsFunc)sevenzLib->resolve("GetNumberOfMethods")) == 0)
qDebug() << "fail loading function : GetNumberOfMethods" << endl;
qDebug() << "fail loading function : GetNumberOfMethods" << Qt::endl;
if ((szInterface->getNumberOfFormatsFunc = (GetNumberOfFormatsFunc)sevenzLib->resolve("GetNumberOfFormats")) == 0)
qDebug() << "fail loading function : GetNumberOfFormats" << endl;
qDebug() << "fail loading function : GetNumberOfFormats" << Qt::endl;
if ((szInterface->getHandlerPropertyFunc = (GetHandlerPropertyFunc)sevenzLib->resolve("GetHandlerProperty")) == 0)
qDebug() << "fail loading function : GetHandlerProperty" << endl;
qDebug() << "fail loading function : GetHandlerProperty" << Qt::endl;
if ((szInterface->getHandlerPropertyFunc2 = (GetHandlerPropertyFunc2)sevenzLib->resolve("GetHandlerProperty2")) == 0)
qDebug() << "fail loading function : GetHandlerProperty2" << endl;
qDebug() << "fail loading function : GetHandlerProperty2" << Qt::endl;
if ((szInterface->setLargePageModeFunc = (SetLargePageModeFunc)sevenzLib->resolve("SetLargePageMode")) == 0)
qDebug() << "fail loading function : SetLargePageMode" << endl;
qDebug() << "fail loading function : SetLargePageMode" << Qt::endl;
#ifdef Q_OS_UNIX
if ((szInterface->createObjectFuncRar = (CreateObjectFunc)rarLib->resolve("CreateObject")) == 0)
qDebug() << "fail loading function (rar) : CreateObject" << endl;
qDebug() << "fail loading function (rar) : CreateObject" << Qt::endl;
if ((szInterface->getMethodPropertyFuncRar = (GetMethodPropertyFunc)rarLib->resolve("GetMethodProperty")) == 0)
qDebug() << "fail loading function (rar) : GetMethodProperty" << endl;
qDebug() << "fail loading function (rar) : GetMethodProperty" << Qt::endl;
if ((szInterface->getNumberOfMethodsFuncRar = (GetNumberOfMethodsFunc)rarLib->resolve("GetNumberOfMethods")) == 0)
qDebug() << "fail loading function (rar) : GetNumberOfMethods" << endl;
qDebug() << "fail loading function (rar) : GetNumberOfMethods" << Qt::endl;
#endif
}
@ -376,6 +376,8 @@ CompressedArchive::CompressedArchive(const QString &filePath, QObject *parent)
isDir = VARIANT_BOOLToBool(prop.boolVal);
else if (prop.vt == VT_EMPTY)
isDir = false;
else
continue;
if (!isDir) {
szInterface->archive->GetProperty(i, kpidPath, &prop);
@ -443,7 +445,7 @@ CompressedArchive::CompressedArchive(const QString &filePath, QObject *parent)
else
result = szInterface->archive->Extract(currentIndexes.data(), currentIndexes.count(), false, extractCallback);
if (result != S_OK) {
qDebug() << "Extract Error" << endl;
qDebug() << "Extract Error" << Qt::endl;
}
return extractCallbackSpec->allFiles;
@ -466,7 +468,7 @@ CompressedArchive::CompressedArchive(const QString &filePath, QObject *parent)
HRESULT result = szInterface->archive->Extract(indices, 1, false, extractCallback);
if (result != S_OK) {
qDebug() << "Extract Error" << endl;
qDebug() << "Extract Error" << Qt::endl;
}
return QByteArray((char *)extractCallbackSpec->data, extractCallbackSpec->newFileSize);

View File

@ -309,7 +309,7 @@ STDMETHODIMP YCArchiveExtractCallback::CryptoGetTextPassword(BSTR *password)
// You can ask real password here from user
// Password = GetPassword(OutStream);
// PasswordIsDefined = true;
qDebug() << "Password is not defined" << endl;
qDebug() << "Password is not defined" << Qt::endl;
return E_ABORT;
}
return StringToBstr(Password, password);

View File

@ -44,7 +44,7 @@ STDMETHODIMP YCArchiveOpenCallback::CryptoGetTextPassword(BSTR *password)
// You can ask real password here from user
// Password = GetPassword(OutStream);
// PasswordIsDefined = true;
qDebug() << "Password is not defined" << endl;
qDebug() << "Password is not defined" << Qt::endl;
return E_ABORT;
}
return StringToBstr(Password, password);

View File

@ -2,7 +2,8 @@
# default values if they're not set on build time
# for a more detailed description, see INSTALL.TXT
CONFIG += c++11
CONFIG += c++17
win32:QMAKE_CXXFLAGS += /std:c++17 #enable c++17 explicitly in msvc
unix:QMAKE_CXXFLAGS_RELEASE += -DNDEBUG
win32:QMAKE_CXXFLAGS_RELEASE += /DNDEBUG
@ -31,17 +32,10 @@ defineTest(minQtVersion) {
return(false)
}
!minQtVersion(5, 9, 0) {
error(YACReader requires Qt 5.9 or newer but $$[QT_VERSION] was detected)
!minQtVersion(5, 15, 0) {
error(YACReader requires Qt 5.15 or newer but $$[QT_VERSION] was detected)
}
minQtVersion(6, 0, 0) {
error(YACReader does not support building with Qt6 (yet))
}
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x050900
DEFINES += QT_DEPRECATED_WARNINGS
# reduce log pollution
CONFIG += silent
@ -84,3 +78,11 @@ unix:!macx:!CONFIG(poppler):!CONFIG(pdfium):!CONFIG(no_pdf) {
macx:!CONFIG(pdfkit):!CONFIG(pdfium):!CONFIG(no_pdf) {
CONFIG += pdfkit
}
!CONFIG(poppler) {
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x050F00
} else {
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x050900
}
DEFINES += QT_DEPRECATED_WARNINGS

View File

@ -6,8 +6,11 @@
#include <QApplication>
#include <QFile>
#include <QTextStream>
#include <QScreen>
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#include <QTextCodec>
#include <QDesktopWidget>
#endif
#include "yacreader_global.h"
@ -31,7 +34,15 @@ HelpAboutDialog::HelpAboutDialog(QWidget *parent)
layout->setContentsMargins(1, 3, 1, 1);
setLayout(layout);
resize(500, QApplication::desktop()->availableGeometry().height() * 0.83);
QScreen *screen = parent != nullptr ? parent->window()->screen() : nullptr;
if (screen == nullptr) {
screen = QApplication::screens().constFirst();
}
int heightDesktopResolution = screen != nullptr ? screen->size().height() : 600;
resize(500, heightDesktopResolution * 0.83);
}
HelpAboutDialog::~HelpAboutDialog()
@ -56,7 +67,7 @@ void HelpAboutDialog::loadAboutInformation(const QString &path)
buildNumber = BUILD_NUMBER;
#endif
aboutText->setHtml(fileToString(path).arg(VERSION).arg(buildNumber));
aboutText->setHtml(fileToString(path).arg(VERSION, buildNumber));
aboutText->moveCursor(QTextCursor::Start);
}
@ -72,7 +83,11 @@ QString HelpAboutDialog::fileToString(const QString &path)
f.open(QIODevice::ReadOnly);
QTextStream txtS(&f);
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
txtS.setEncoding(QStringConverter::Utf8);
#else
txtS.setCodec(QTextCodec::codecForName("UTF-8"));
#endif
QString content = txtS.readAll();
f.close();

View File

@ -12,7 +12,6 @@ YACReader::RoundedCornersDialog::RoundedCornersDialog(QWidget *parent)
void YACReader::RoundedCornersDialog::paintEvent(QPaintEvent *)
{
qreal radius = 36.0; // desired radius in absolute pixels
qreal borderWidth = 0.0;
if (!(windowFlags() & Qt::FramelessWindowHint) && !testAttribute(Qt::WA_TranslucentBackground))
return; // nothing to do
@ -22,8 +21,7 @@ void YACReader::RoundedCornersDialog::paintEvent(QPaintEvent *)
// Paint thyself.
QRectF rect(QPointF(0, 0), size());
// Check for a border size.
qreal penWidth = borderWidth;
p.setPen(Qt::NoPen);
// Set the brush from palette role.

View File

@ -14,7 +14,7 @@ YACReader::WhatsNewDialog::WhatsNewDialog(QWidget *parent)
scrollArea->setContentsMargins(0, 0, 0, 0);
auto mainLayout = new QVBoxLayout(this);
mainLayout->setMargin(0);
mainLayout->setContentsMargins(0, 0, 0, 0);
auto contentLayout = new QGridLayout();
auto content = new QFrame();

View File

@ -46,7 +46,7 @@ YACReaderDeletingProgress::YACReaderDeletingProgress(QWidget *parent)
contentLayout->addWidget(button, 0, Qt::AlignHCenter);
contentLayout->addSpacing(18);
contentLayout->setMargin(0);
contentLayout->setContentsMargins(0, 0, 0, 0);
setLayout(contentLayout);

View File

@ -9,7 +9,7 @@ YACReaderLibraryItemWidget::YACReaderLibraryItemWidget(QString n /*ame*/, QStrin
: QWidget(parent), name(n), path(p), isSelected(false)
{
QHBoxLayout *mainLayout = new QHBoxLayout;
mainLayout->setMargin(0);
mainLayout->setContentsMargins(0, 0, 0, 0);
mainLayout->setSpacing(0);
// installEventFilter(this);

View File

@ -11,7 +11,7 @@ YACReaderLibraryListWidget::YACReaderLibraryListWidget(QWidget *parent)
{
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->setSpacing(0);
mainLayout->setMargin(0);
mainLayout->setContentsMargins(0, 0, 0, 0);
this->setLayout(mainLayout);
}

View File

@ -136,7 +136,7 @@ void YACReaderOptionsDialog::saveFlowParameters()
void YACReaderOptionsDialog::saveOptions()
{
emit(optionsChanged());
emit optionsChanged();
close();
}

View File

@ -4,8 +4,6 @@
#include <QStyle>
#include <QLabel>
#include <QRegExpValidator>
#include "QsLog.h"
YACReaderSearchLineEdit::YACReaderSearchLineEdit(QWidget *parent)
@ -47,26 +45,6 @@ YACReaderSearchLineEdit::YACReaderSearchLineEdit(QWidget *parent)
setAttribute(Qt::WA_MacShowFocusRect, false);
setPlaceholderText(tr("type to search"));
// search modifiers
modifiers << "[read]"
<< "[unread]"; //<< "[author]";
modifiersCompleter = new QCompleter(modifiers);
QString regExpString;
foreach (QString modifier, modifiers) {
regExpString = regExpString + modifier.replace("[", "\\[").replace("]", "\\]") + ".*|";
}
regExpString = regExpString + "[^\\[].*";
QLOG_TRACE() << regExpString;
QRegExp regExp(regExpString);
QValidator *validator = new QRegExpValidator(regExp, this);
setValidator(validator);
setCompleter(modifiersCompleter);
connect(this, &QLineEdit::textChanged, this, &YACReaderSearchLineEdit::processText);
}
@ -77,13 +55,9 @@ void YACReaderSearchLineEdit::clearText()
connect(this, &QLineEdit::textChanged, this, &YACReaderSearchLineEdit::processText);
}
// modifiers are not returned
const QString YACReaderSearchLineEdit::text()
{
QString text = QLineEdit::text();
QRegExp regExp("\\[.*\\]");
return text.remove(regExp).trimmed();
return QLineEdit::text();
}
void YACReaderSearchLineEdit::resizeEvent(QResizeEvent *)
@ -115,26 +89,5 @@ void YACReaderSearchLineEdit::updateCloseButton(const QString &text)
void YACReaderSearchLineEdit::processText(const QString &text)
{
QRegExp regExp("(\\[.*\\])(.*)");
if (text.startsWith("[")) {
if (regExp.exactMatch(text)) // avoid search while the modifiers are being written
{
QString modifier = regExp.cap(1);
QString searchText = regExp.cap(2).trimmed();
int indexOfModifier = modifiers.indexOf(modifier);
if (indexOfModifier != -1) {
QLOG_TRACE() << "modifier : " << modifier << "text : " << searchText;
emit filterChanged(static_cast<YACReader::SearchModifiers>(indexOfModifier + 1), searchText); // TODO, do not use on indexOF
} else {
QLOG_ERROR() << "invalid modifier : " << modifier;
}
}
QLOG_TRACE() << "full text :" << text << " : " << regExp.indexIn(text);
} else {
QLOG_TRACE() << "NoModifiers : " << text;
emit filterChanged(YACReader::NoModifiers, text);
}
emit filterChanged(YACReader::NoModifiers, text);
}

View File

@ -31,8 +31,6 @@ private slots:
private:
QToolButton *clearButton;
QLabel *searchLabel;
QCompleter *modifiersCompleter;
QStringList modifiers;
};
#endif // YACREADER_SEARCH_LINE_EDIT_H

View File

@ -18,12 +18,13 @@ private:
public:
YACReaderSpinSliderWidget(QWidget *parent = 0, bool strechableSlider = false);
QSize minimumSizeHint() const;
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);
@ -32,4 +33,4 @@ signals:
void valueChanged(int);
};
#endif // YACREADER_SPIN_SLIDER_WIDGET_H
#endif // YACREADER_SPIN_SLIDER_WIDGET_H

View File

@ -60,7 +60,7 @@ YACReaderTitledToolBar::YACReaderTitledToolBar(const QString &title, QWidget *pa
: QWidget(parent)
{
QHBoxLayout *mainLayout = new QHBoxLayout;
mainLayout->setMargin(0);
mainLayout->setContentsMargins(0, 0, 0, 0);
mainLayout->setSpacing(0);
QString styleSheet = "QWidget {border:0px;}";

View File

@ -2,6 +2,7 @@
#include "shortcuts_manager.h"
#include <QAction>
#include <QBrush>
ActionsShortcutsModel::ActionsShortcutsModel(QObject *parent)
: QAbstractItemModel(parent)
@ -59,7 +60,7 @@ QVariant ActionsShortcutsModel::data(const QModelIndex &index, int role) const
}
if (role == Qt::ForegroundRole && index.column() == KEYS && actions[index.row()]->shortcut().isEmpty())
return QBrush(QColor("#AAAAAA"));
return QBrush(QColor(0xAAAAAA));
if (role != Qt::DisplayRole)
return QVariant();

View File

@ -24,12 +24,15 @@
// OF THE POSSIBILITY OF SUCH DAMAGE.
#include "QsLogDestFile.h"
#include <QTextCodec>
#include <QDateTime>
#include <QString>
#include <QtGlobal>
#include <iostream>
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#include <QTextCodec>
#endif
const int QsLogging::SizeRotationStrategy::MaxBackupCount = 10;
QsLogging::RotationStrategy::~RotationStrategy() noexcept = default;
@ -148,8 +151,14 @@ QsLogging::FileDestination::FileDestination(const QString& filePath, RotationStr
if (!mFile.open(QFile::WriteOnly | QFile::Text | mRotationStrategy->recommendedOpenModeFlag())) {
std::cerr << "QsLog: could not open log file " << qPrintable(filePath);
}
mOutputStream.setDevice(&mFile);
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
mOutputStream.setEncoding(QStringConverter::Utf8);
#else
mOutputStream.setCodec(QTextCodec::codecForName("UTF-8"));
#endif
mRotationStrategy->setInitialInfo(mFile);
}
@ -167,10 +176,14 @@ void QsLogging::FileDestination::write(const LogMessage& message)
}
mRotationStrategy->setInitialInfo(mFile);
mOutputStream.setDevice(&mFile);
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
mOutputStream.setEncoding(QStringConverter::Utf8);
#else
mOutputStream.setCodec(QTextCodec::codecForName("UTF-8"));
#endif
}
mOutputStream << utf8Message << endl;
mOutputStream << utf8Message << Qt::endl;
mOutputStream.flush();
}

View File

@ -1,6 +1,27 @@
Dont forget to update the release number also in
QtWebApp.pro and httpserver/httpglobal.cpp.
1.8.3
21.03.2021
The minLevel for logging can now be configured as string:
DEBUG/ALL=0, INFO=4, WARNING=1, ERROR/CRITICAL=2, FATAL=3
Info messages are now positioned between DEBUG and WARNING.
I also added an example for HTTP Basic authorization.
1.8.2
08.03.2021
Fix threadId not printed in log file.
1.8.1
07.02.2021
Add Cookie attribute "SameSite".
SessionStore does now emit a signal when a session expires.
1.8.0
06.02.2021
Fix compatibility issues to Qt 4.7 and 6.0.
Removed qtservice, use the Non-Sucking Service Manager (https://nssm.cc/) instead.
1.7.11
28.12.2019
Fix Http Headers are not properly received if the two characters of

View File

@ -1,25 +1,22 @@
QtWebAppLib is a library to develop server-side web applications in C++.
It requires the Qt SDK version 4.7.0 or newer.
Works with Qt SDK version 4.7 until at least 6.0
License: LGPL v3.
Project homepage: http://stefanfrings.de/qtwebapp/index.html
Project homepage: http://stefanfrings.de/qtwebapp/index-en.html
Tutorial: http://stefanfrings.de/qtwebapp/tutorial/index.html
API doc: http://stefanfrings.de/qtwebapp/api/index.html
There are three demo applications that demonstrate how to use the library.
In Qt 6.0 or newer, you must install the optional "core5compat" component.
This package contains the QTextCodec class which is needed to decode template files.
It supports a lot more encodings, for example ISO-8859-15 with the EUR symbol.
Demo1 shows how to use the library by including the source code into your
project. This does not depend on the shared library.
project, the preferred method.
Demo2 shows how to link against the shared library.
Build the project QtWebApp to generate the shared library.
Demo3 shows how to use the qtservice component to start the application
as a Windows Service or Unix daemon. Start it with option -h to get help.
I recommend to include the library by source as shown in Demo1 and 3.
Stefan Frings
http://stefanfrings.de

View File

@ -28,16 +28,16 @@ HttpConnectionHandler::HttpConnectionHandler(const QSettings *settings, HttpRequ
readTimer.setSingleShot(true);
// Create TCP or SSL socket
createSocket();
createSocket();
socket->moveToThread(thread);
// Connect signals
connect(socket, &QIODevice::readyRead, this, &HttpConnectionHandler::read);
connect(socket, &QAbstractSocket::disconnected, this, &HttpConnectionHandler::disconnected);
connect(&readTimer, &QTimer::timeout, this, &HttpConnectionHandler::readTimeout);
connect(thread, &QThread::finished, this, &HttpConnectionHandler::thread_done);
connect(socket, SIGNAL(readyRead()), SLOT(read()));
connect(socket, SIGNAL(disconnected()), SLOT(disconnected()));
connect(&readTimer, SIGNAL(timeout()), SLOT(readTimeout()));
connect(thread, SIGNAL(finished()), this, SLOT(thread_done()));
qDebug("HttpConnectionHandler (%p): constructed", static_cast<void*>(this));
qDebug("HttpConnectionHandler (%p): constructed", static_cast<void*>(this));
}

View File

@ -20,7 +20,7 @@
namespace stefanfrings {
/** Alias type definition, for compatibility to different Qt versions */
#if QT_VERSION >= 0x050000
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
typedef qintptr tSocketDescriptor;
#else
typedef int tSocketDescriptor;

View File

@ -18,7 +18,7 @@ HttpConnectionHandlerPool::HttpConnectionHandlerPool(const QSettings *settings,
this->sslConfiguration=NULL;
loadSslConfig();
cleanupTimer.start(settings->value("cleanupInterval",1000).toInt());
connect(&cleanupTimer, &QTimer::timeout, this, &HttpConnectionHandlerPool::cleanup);
connect(&cleanupTimer, SIGNAL(timeout()), SLOT(cleanup()));
}
@ -77,7 +77,8 @@ void HttpConnectionHandlerPool::cleanup()
{
delete handler;
pool.removeOne(handler);
qDebug("HttpConnectionHandlerPool: Removed connection handler (%p), pool size is now %i",handler,pool.size());
long int poolSize=(long int)pool.size();
qDebug("HttpConnectionHandlerPool: Removed connection handler (%p), pool size is now %li",handler,poolSize);
break; // remove only one handler in each interval
}
}
@ -140,7 +141,7 @@ void HttpConnectionHandlerPool::loadSslConfig()
sslConfiguration->setLocalCertificate(certificate);
sslConfiguration->setPrivateKey(sslKey);
sslConfiguration->setPeerVerifyMode(QSslSocket::VerifyNone);
sslConfiguration->setProtocol(QSsl::TlsV1SslV3);
sslConfiguration->setProtocol(QSsl::AnyProtocol);
qDebug("HttpConnectionHandlerPool: SSL settings loaded");
#endif

View File

@ -14,7 +14,9 @@ HttpCookie::HttpCookie()
secure=false;
}
HttpCookie::HttpCookie(const QByteArray name, const QByteArray value, const int maxAge, const QByteArray path, const QByteArray comment, const QByteArray domain, const bool secure, const bool httpOnly)
HttpCookie::HttpCookie(const QByteArray name, const QByteArray value, const int maxAge, const QByteArray path,
const QByteArray comment, const QByteArray domain, const bool secure, const bool httpOnly,
const QByteArray sameSite)
{
this->name=name;
this->value=value;
@ -24,6 +26,7 @@ HttpCookie::HttpCookie(const QByteArray name, const QByteArray value, const int
this->domain=domain;
this->secure=secure;
this->httpOnly=httpOnly;
this->sameSite=sameSite;
this->version=1;
}
@ -32,6 +35,7 @@ HttpCookie::HttpCookie(const QByteArray source)
version=1;
maxAge=0;
secure=false;
httpOnly=false;
QList<QByteArray> list=splitCSV(source);
foreach(QByteArray part, list)
{
@ -76,6 +80,10 @@ HttpCookie::HttpCookie(const QByteArray source)
{
httpOnly=true;
}
else if (name=="SameSite")
{
sameSite=value;
}
else if (name=="Version")
{
version=value.toInt();
@ -125,6 +133,10 @@ QByteArray HttpCookie::toByteArray() const
if (httpOnly) {
buffer.append("; HttpOnly");
}
if (!sameSite.isEmpty()) {
buffer.append("; SameSite=");
buffer.append(sameSite);
}
buffer.append("; Version=");
buffer.append(QByteArray::number(version));
return buffer;
@ -170,6 +182,11 @@ void HttpCookie::setHttpOnly(const bool httpOnly)
this->httpOnly=httpOnly;
}
void HttpCookie::setSameSite(const QByteArray sameSite)
{
this->sameSite=sameSite;
}
QByteArray HttpCookie::getName() const
{
return name;
@ -210,6 +227,11 @@ bool HttpCookie::getHttpOnly() const
return httpOnly;
}
QByteArray HttpCookie::getSameSite() const
{
return sameSite;
}
int HttpCookie::getVersion() const
{
return version;

View File

@ -13,9 +13,8 @@
namespace stefanfrings {
/**
HTTP cookie as defined in RFC 2109. This class can also parse
RFC 2965 cookies, but skips fields that are not defined in RFC
2109.
HTTP cookie as defined in RFC 2109.
Supports some additional attributes of RFC6265bis.
*/
class DECLSPEC HttpCookie
@ -35,11 +34,13 @@ public:
@param domain Optional domain for that the cookie will be sent. Defaults to the current domain
@param secure If true, the cookie will be sent by the browser to the server only on secure connections
@param httpOnly If true, the browser does not allow client-side scripts to access the cookie
@param sameSite Declare if the cookie can only be read by the same site, which is a stronger
restriction than the domain. Allowed values: "Lax" and "Strict".
*/
HttpCookie(const QByteArray name, const QByteArray value, const int maxAge,
const QByteArray path="/", const QByteArray comment=QByteArray(),
const QByteArray domain=QByteArray(), const bool secure=false,
const bool httpOnly=false);
const bool httpOnly=false, const QByteArray sameSite=QByteArray());
/**
Create a cookie from a string.
@ -77,9 +78,15 @@ public:
/** Set secure mode, so that the cookie will be sent by the browser to the server only on secure connections */
void setSecure(const bool secure);
/** Set HTTP-only mode, so that he browser does not allow client-side scripts to access the cookie */
/** Set HTTP-only mode, so that the browser does not allow client-side scripts to access the cookie */
void setHttpOnly(const bool httpOnly);
/**
* Set same-site mode, so that the browser does not allow other web sites to access the cookie.
* Allowed values: "Lax" and "Strict".
*/
void setSameSite(const QByteArray sameSite);
/** Get the name of this cookie */
QByteArray getName() const;
@ -104,6 +111,9 @@ public:
/** Get the HTTP-only flag of this cookie */
bool getHttpOnly() const;
/** Get the same-site flag of this cookie */
QByteArray getSameSite() const;
/** Returns always 1 */
int getVersion() const;
@ -117,6 +127,7 @@ private:
QByteArray path;
bool secure;
bool httpOnly;
QByteArray sameSite;
int version;
};

View File

@ -2,6 +2,6 @@
const char* getQtWebAppLibVersion()
{
return "1.7.11";
return "1.8.3";
}

View File

@ -23,6 +23,5 @@
/** Get the library version number */
DECLSPEC const char* getQtWebAppLibVersion();
#endif // HTTPGLOBAL_H

Some files were not shown because too many files have changed in this diff Show More