Compare commits
11 Commits
Author | SHA1 | Date | |
---|---|---|---|
fe0b36dc34 | |||
1864ff5b7f | |||
fb1ad2ba06 | |||
e3dfc9c673 | |||
eb648e3112 | |||
5495fa06d3 | |||
41e75f10b5 | |||
6b0e4b6767 | |||
f49ed645fc | |||
8fe860e4bf | |||
2d07290fbe |
17
.github/workflows/macos.yml
vendored
Normal file
17
.github/workflows/macos.yml
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
name: MyCi_MacOS
|
||||
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: macos-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Install Qt
|
||||
uses: jurplel/install-qt-action@v2.2.1
|
||||
- name: Run a qt project
|
||||
run: |
|
||||
cmake ./
|
||||
make
|
@ -6,7 +6,7 @@ include (GNUInstallDirs)
|
||||
|
||||
set (CMAKE_AUTOMOC ON)
|
||||
set (CMAKE_AUTORCC ON)
|
||||
set (QT_MINIMUM_VERSION "5.7.1")
|
||||
set (QT_MINIMUM_VERSION "5.10")
|
||||
|
||||
find_package(Qt5 ${QT_MINIMUM_VERSION} CONFIG REQUIRED Widgets Svg LinguistTools)
|
||||
|
||||
@ -133,7 +133,7 @@ install (
|
||||
|
||||
# CPACK: General Settings
|
||||
set (CPACK_GENERATOR "TBZ2")
|
||||
set (CPACK_PACKAGE_NAME "PineapplePictures")
|
||||
set (CPACK_PACKAGE_NAME "pineapple-pictures")
|
||||
set (CPACK_PACKAGE_DESCRIPTION_SUMMARY "Yet another image viewer")
|
||||
set (CPACK_PACKAGE_VENDOR "Gary Wang")
|
||||
set (CPACK_PACKAGE_CONTACT "https://github.com/BLumia/PineapplePictures/issues/")
|
||||
@ -142,7 +142,9 @@ if (WIN32)
|
||||
elseif (APPLE)
|
||||
# ...
|
||||
elseif (UNIX)
|
||||
set(CPACK_SYSTEM_NAME "${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}")
|
||||
set (CPACK_SYSTEM_NAME "${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}")
|
||||
set (CPACK_DEBIAN_PACKAGE_DEPENDS "libqt5svg5")
|
||||
set (CPACK_DEBIAN_PACKAGE_RECOMMENDS "kimageformat-plugins")
|
||||
endif()
|
||||
|
||||
include(CPack)
|
||||
|
40
appveyor.yml
40
appveyor.yml
@ -1,27 +1,49 @@
|
||||
environment:
|
||||
CMAKE_INSTALL_ROOT: C:\projects\cmake
|
||||
matrix:
|
||||
- build_name: mingw73_32_qt5_12_5
|
||||
QTPATH: C:\Qt\5.12.5\mingw73_32
|
||||
- build_name: mingw73_32_qt5_12_6
|
||||
QTPATH: C:\Qt\5.12.6\mingw73_32
|
||||
MINGW32: C:\Qt\Tools\mingw730_32
|
||||
# - build_name: msvc2017_64
|
||||
# QTPATH: C:\Qt\5.11.2\msvc2017_64
|
||||
# MINGW32: C:\Qt\Tools\mingw530_32
|
||||
|
||||
install:
|
||||
- mkdir %CMAKE_INSTALL_ROOT%
|
||||
- cd %APPVEYOR_BUILD_FOLDER%
|
||||
- git submodule update --init --recursive
|
||||
- set PATH=%PATH%;%QTPATH%\bin;%MINGW32%\bin
|
||||
- set PATH=%PATH%;%CMAKE_INSTALL_ROOT%;%QTPATH%\bin;%MINGW32%\bin
|
||||
|
||||
build_script:
|
||||
# prepare
|
||||
- mkdir 3rdparty
|
||||
- cinst ninja
|
||||
# install ECM so we can build KImageFormats
|
||||
- cd 3rdparty
|
||||
- git clone -q git://anongit.kde.org/extra-cmake-modules.git
|
||||
- cd extra-cmake-modules
|
||||
- cmake -G "Ninja" . -DCMAKE_INSTALL_PREFIX=%CMAKE_INSTALL_ROOT%
|
||||
- cmake --build .
|
||||
- cmake --build . --target install
|
||||
- cd %APPVEYOR_BUILD_FOLDER%
|
||||
# install KImageFormats
|
||||
- cd 3rdparty
|
||||
- git clone git://anongit.kde.org/kimageformats.git
|
||||
- cd kimageformats
|
||||
- mkdir build
|
||||
- cd build
|
||||
- cmake -G "Unix Makefiles" -DCMAKE_MAKE_PROGRAM=mingw32-make -DCMAKE_INSTALL_PREFIX='%cd%' ..\
|
||||
- cmake .. -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS_RELEASE="-s" -DCMAKE_MAKE_PROGRAM=mingw32-make -DQT_PLUGIN_INSTALL_DIR=%QTPATH%\plugins
|
||||
- cmake --build . --config Release
|
||||
- cmake --build . --config Release --target install
|
||||
- cd %APPVEYOR_BUILD_FOLDER%
|
||||
# finally...
|
||||
- mkdir build
|
||||
- cd build
|
||||
- cmake .. -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_MAKE_PROGRAM=mingw32-make -DCMAKE_INSTALL_PREFIX='%cd%'
|
||||
- mingw32-make
|
||||
- mingw32-make install
|
||||
# fixme: I don't know how to NOT make the binary installed to the ./bin/ folder...
|
||||
- cd bin
|
||||
- windeployqt --no-quick-import --no-translations --no-opengl-sw --no-angle --no-system-d3d-compiler --release .\ppic.exe
|
||||
- tree
|
||||
- windeployqt --verbose=2 --no-quick-import --no-translations --no-opengl-sw --no-angle --no-system-d3d-compiler --release .\ppic.exe
|
||||
# for debug..
|
||||
- tree /f
|
||||
|
||||
artifacts:
|
||||
- path: build\bin
|
||||
|
@ -60,6 +60,17 @@ void GraphicsScene::showGif(const QString &filepath)
|
||||
this->setSceneRect(m_theThing->boundingRect());
|
||||
}
|
||||
|
||||
bool GraphicsScene::trySetTransformationMode(Qt::TransformationMode mode)
|
||||
{
|
||||
QGraphicsPixmapItem * pixmapItem = qgraphicsitem_cast<QGraphicsPixmapItem *>(m_theThing);
|
||||
if (pixmapItem) {
|
||||
pixmapItem->setTransformationMode(mode);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
QPixmap GraphicsScene::renderToPixmap()
|
||||
{
|
||||
QPixmap pixmap(sceneRect().toRect().size());
|
||||
|
@ -15,6 +15,8 @@ public:
|
||||
void showSvg(const QString &filepath);
|
||||
void showGif(const QString &filepath);
|
||||
|
||||
bool trySetTransformationMode(Qt::TransformationMode mode);
|
||||
|
||||
QPixmap renderToPixmap();
|
||||
|
||||
private:
|
||||
|
@ -39,8 +39,10 @@ void GraphicsView::showFileFromUrl(const QUrl &url, bool doRequestGallery)
|
||||
QImageReader imageReader(filePath);
|
||||
imageReader.setAutoTransform(true);
|
||||
imageReader.setDecideFormatFromContent(true);
|
||||
QImage::Format imageFormat = imageReader.imageFormat();
|
||||
if (imageFormat == QImage::Format_Invalid) {
|
||||
// Since if the image format / plugin does not support this feature, imageFormat() will returns an invalid format.
|
||||
// So we cannot use imageFormat() and check if it returns QImage::Format_Invalid to detect if we support the file.
|
||||
// QImage::Format imageFormat = imageReader.imageFormat();
|
||||
if (imageReader.format().isEmpty()) {
|
||||
showText(tr("File is not a valid image"));
|
||||
} else {
|
||||
showImage(QPixmap::fromImageReader(&imageReader));
|
||||
@ -117,6 +119,7 @@ void GraphicsView::zoomView(qreal scaleFactor)
|
||||
{
|
||||
m_enableFitInView = false;
|
||||
scale(scaleFactor, scaleFactor);
|
||||
applyTransformationModeByScaleFactor();
|
||||
emit navigatorViewRequired(!isThingSmallerThanWindowWith(transform()), m_rotateAngle);
|
||||
}
|
||||
|
||||
@ -136,6 +139,7 @@ void GraphicsView::rotateView(qreal rotateAngel)
|
||||
void GraphicsView::fitInView(const QRectF &rect, Qt::AspectRatioMode aspectRadioMode)
|
||||
{
|
||||
QGraphicsView::fitInView(rect, aspectRadioMode);
|
||||
applyTransformationModeByScaleFactor();
|
||||
}
|
||||
|
||||
void GraphicsView::checkAndDoFitInView()
|
||||
@ -213,9 +217,9 @@ void GraphicsView::dragEnterEvent(QDragEnterEvent *event)
|
||||
} else {
|
||||
event->ignore();
|
||||
}
|
||||
qDebug() << event->mimeData() << "Drag Enter Event"
|
||||
<< event->mimeData()->hasUrls() << event->mimeData()->hasImage()
|
||||
<< event->mimeData()->formats() << event->mimeData()->hasFormat("text/uri-list");
|
||||
// qDebug() << event->mimeData() << "Drag Enter Event"
|
||||
// << event->mimeData()->hasUrls() << event->mimeData()->hasImage()
|
||||
// << event->mimeData()->formats() << event->mimeData()->hasFormat("text/uri-list");
|
||||
|
||||
return QGraphicsView::dragEnterEvent(event);
|
||||
}
|
||||
@ -285,9 +289,9 @@ void GraphicsView::setCheckerboardEnabled(bool enabled)
|
||||
if (m_checkerboardEnabled) {
|
||||
// Prepare background check-board pattern
|
||||
QPixmap tilePixmap(0x20, 0x20);
|
||||
tilePixmap.fill(QColor(35, 35, 35, 110));
|
||||
tilePixmap.fill(QColor(35, 35, 35, 170));
|
||||
QPainter tilePainter(&tilePixmap);
|
||||
QColor color(40, 40, 40, 110);
|
||||
QColor color(45, 45, 45, 170);
|
||||
tilePainter.fillRect(0, 0, 0x10, 0x10, color);
|
||||
tilePainter.fillRect(0x10, 0x10, 0x10, 0x10, color);
|
||||
tilePainter.end();
|
||||
@ -298,6 +302,15 @@ void GraphicsView::setCheckerboardEnabled(bool enabled)
|
||||
}
|
||||
}
|
||||
|
||||
void GraphicsView::applyTransformationModeByScaleFactor()
|
||||
{
|
||||
if (this->scaleFactor() < 1) {
|
||||
scene()->trySetTransformationMode(Qt::SmoothTransformation);
|
||||
} else {
|
||||
scene()->trySetTransformationMode(Qt::FastTransformation);
|
||||
}
|
||||
}
|
||||
|
||||
void GraphicsView::resetWithScaleAndRotate(qreal scaleFactor, qreal rotateAngle)
|
||||
{
|
||||
QGraphicsView::resetTransform();
|
||||
|
@ -54,6 +54,7 @@ private:
|
||||
bool isThingSmallerThanWindowWith(const QTransform &transform) const;
|
||||
bool shouldIgnoreMousePressMoveEvent(const QMouseEvent *event) const;
|
||||
void setCheckerboardEnabled(bool enabled);
|
||||
void applyTransformationModeByScaleFactor();
|
||||
|
||||
void resetWithScaleAndRotate(qreal scaleFactor, qreal rotateAngle);
|
||||
|
||||
|
@ -113,6 +113,10 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
connect(quitAppShorucut, &QShortcut::activated,
|
||||
std::bind(&MainWindow::quitAppAction, this, false));
|
||||
|
||||
QShortcut * quitAppShorucut2 = new QShortcut(QKeySequence(Qt::Key_Escape), this);
|
||||
connect(quitAppShorucut2, &QShortcut::activated,
|
||||
std::bind(&MainWindow::quitAppAction, this, false));
|
||||
|
||||
QShortcut * prevPictureShorucut = new QShortcut(QKeySequence(Qt::Key_PageUp), this);
|
||||
connect(prevPictureShorucut, &QShortcut::activated,
|
||||
this, &MainWindow::galleryPrev);
|
||||
@ -121,6 +125,10 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
connect(nextPictureShorucut, &QShortcut::activated,
|
||||
this, &MainWindow::galleryNext);
|
||||
|
||||
QShortcut * fullscreenShorucut = new QShortcut(QKeySequence(QKeySequence::FullScreen), this);
|
||||
connect(fullscreenShorucut, &QShortcut::activated,
|
||||
this, &MainWindow::toggleFullscreen);
|
||||
|
||||
centerWindow();
|
||||
}
|
||||
|
||||
@ -185,12 +193,18 @@ QUrl MainWindow::currentImageFileUrl() const
|
||||
return QUrl();
|
||||
}
|
||||
|
||||
void MainWindow::clearGallery()
|
||||
{
|
||||
m_currentFileIndex = -1;
|
||||
m_files.clear();
|
||||
}
|
||||
|
||||
void MainWindow::loadGalleryBySingleLocalFile(const QString &path)
|
||||
{
|
||||
QFileInfo info(path);
|
||||
QDir dir(info.path());
|
||||
QString currentFileName = info.fileName();
|
||||
QStringList entryList = dir.entryList({"*.jpg", "*.jpeg", "*.png", "*.gif", "*.svg", "*.bmp"},
|
||||
QStringList entryList = dir.entryList({"*.jpg", "*.jpeg", "*.jfif", "*.png", "*.gif", "*.svg", "*.bmp"},
|
||||
QDir::Files | QDir::NoSymLinks, QDir::NoSort);
|
||||
|
||||
QCollator collator;
|
||||
@ -198,8 +212,7 @@ void MainWindow::loadGalleryBySingleLocalFile(const QString &path)
|
||||
|
||||
std::sort(entryList.begin(), entryList.end(), collator);
|
||||
|
||||
m_currentFileIndex = -1;
|
||||
m_files.clear();
|
||||
clearGallery();
|
||||
|
||||
for (int i = 0; i < entryList.count(); i++) {
|
||||
const QString & oneEntry = entryList.at(i);
|
||||
@ -268,8 +281,8 @@ void MainWindow::mousePressEvent(QMouseEvent *event)
|
||||
if (event->buttons() & Qt::LeftButton && !isMaximized()) {
|
||||
m_clickedOnWindow = true;
|
||||
m_oldMousePos = event->pos();
|
||||
qDebug() << m_oldMousePos << m_graphicsView->transform().m11()
|
||||
<< m_graphicsView->transform().m22() << m_graphicsView->matrix().m12();
|
||||
// qDebug() << m_oldMousePos << m_graphicsView->transform().m11()
|
||||
// << m_graphicsView->transform().m22() << m_graphicsView->matrix().m12();
|
||||
event->accept();
|
||||
}
|
||||
|
||||
@ -357,6 +370,7 @@ void MainWindow::contextMenuEvent(QContextMenuEvent *event)
|
||||
|
||||
QAction * pasteImage = new QAction(tr("&Paste Image"));
|
||||
connect(pasteImage, &QAction::triggered, this, [ = ](){
|
||||
clearGallery();
|
||||
m_graphicsView->showImage(clipboardImage);
|
||||
});
|
||||
|
||||
@ -551,3 +565,12 @@ void MainWindow::quitAppAction(bool force)
|
||||
closeWindow();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::toggleFullscreen()
|
||||
{
|
||||
if (isFullScreen()) {
|
||||
showNormal();
|
||||
} else {
|
||||
showFullScreen();
|
||||
}
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ public:
|
||||
void adjustWindowSizeBySceneRect();
|
||||
QUrl currentImageFileUrl() const;
|
||||
|
||||
void clearGallery();
|
||||
void loadGalleryBySingleLocalFile(const QString &path);
|
||||
void galleryPrev();
|
||||
void galleryNext();
|
||||
@ -52,6 +53,7 @@ protected slots:
|
||||
void toggleStayOnTop();
|
||||
bool stayOnTop();
|
||||
void quitAppAction(bool force = false);
|
||||
void toggleFullscreen();
|
||||
|
||||
private:
|
||||
QPoint m_oldMousePos;
|
||||
|
Reference in New Issue
Block a user