8 Commits

Author SHA1 Message Date
fe0b36dc34 feat: add a fullscreen shortcut 2020-05-19 14:08:29 +08:00
1864ff5b7f test: Create macos.yml (#3)
Use GitHub Action to test building under macOS
2020-04-25 23:42:21 +08:00
fb1ad2ba06 misc: cpack info for debian package 2020-04-20 10:57:27 +08:00
e3dfc9c673 feat(ci): build and use kimageformats plugins 2020-03-03 13:51:25 +08:00
eb648e3112 fix: use format() to check if we support such format 2020-03-03 09:53:23 +08:00
5495fa06d3 fix: okay it's jfif... 2020-02-24 19:48:22 +08:00
41e75f10b5 misc: add jiff as a valid image file suffix 2020-02-23 23:04:54 +08:00
6b0e4b6767 fix: should clear gallery when paste image 2020-02-22 17:09:36 +08:00
6 changed files with 82 additions and 11 deletions

17
.github/workflows/macos.yml vendored Normal file
View 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

View File

@ -133,7 +133,7 @@ install (
# CPACK: General Settings # CPACK: General Settings
set (CPACK_GENERATOR "TBZ2") 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_DESCRIPTION_SUMMARY "Yet another image viewer")
set (CPACK_PACKAGE_VENDOR "Gary Wang") set (CPACK_PACKAGE_VENDOR "Gary Wang")
set (CPACK_PACKAGE_CONTACT "https://github.com/BLumia/PineapplePictures/issues/") set (CPACK_PACKAGE_CONTACT "https://github.com/BLumia/PineapplePictures/issues/")
@ -143,6 +143,8 @@ elseif (APPLE)
# ... # ...
elseif (UNIX) 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() endif()
include(CPack) include(CPack)

View File

@ -1,24 +1,49 @@
environment: environment:
CMAKE_INSTALL_ROOT: C:\projects\cmake
matrix: matrix:
- build_name: mingw73_32_qt5_12_6 - build_name: mingw73_32_qt5_12_6
QTPATH: C:\Qt\5.12.6\mingw73_32 QTPATH: C:\Qt\5.12.6\mingw73_32
MINGW32: C:\Qt\Tools\mingw730_32 MINGW32: C:\Qt\Tools\mingw730_32
install: install:
- mkdir %CMAKE_INSTALL_ROOT%
- cd %APPVEYOR_BUILD_FOLDER% - cd %APPVEYOR_BUILD_FOLDER%
- git submodule update --init --recursive - git submodule update --init --recursive
- set PATH=%PATH%;%QTPATH%\bin;%MINGW32%\bin - set PATH=%PATH%;%CMAKE_INSTALL_ROOT%;%QTPATH%\bin;%MINGW32%\bin
build_script: 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 - mkdir build
- cd 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
- mingw32-make install - mingw32-make install
# fixme: I don't know how to NOT make the binary installed to the ./bin/ folder... # fixme: I don't know how to NOT make the binary installed to the ./bin/ folder...
- cd bin - cd bin
- windeployqt --no-quick-import --no-translations --no-opengl-sw --no-angle --no-system-d3d-compiler --release .\ppic.exe - windeployqt --verbose=2 --no-quick-import --no-translations --no-opengl-sw --no-angle --no-system-d3d-compiler --release .\ppic.exe
- tree # for debug..
- tree /f
artifacts: artifacts:
- path: build\bin - path: build\bin

View File

@ -39,8 +39,10 @@ void GraphicsView::showFileFromUrl(const QUrl &url, bool doRequestGallery)
QImageReader imageReader(filePath); QImageReader imageReader(filePath);
imageReader.setAutoTransform(true); imageReader.setAutoTransform(true);
imageReader.setDecideFormatFromContent(true); imageReader.setDecideFormatFromContent(true);
QImage::Format imageFormat = imageReader.imageFormat(); // Since if the image format / plugin does not support this feature, imageFormat() will returns an invalid format.
if (imageFormat == QImage::Format_Invalid) { // 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")); showText(tr("File is not a valid image"));
} else { } else {
showImage(QPixmap::fromImageReader(&imageReader)); showImage(QPixmap::fromImageReader(&imageReader));

View File

@ -113,6 +113,10 @@ MainWindow::MainWindow(QWidget *parent) :
connect(quitAppShorucut, &QShortcut::activated, connect(quitAppShorucut, &QShortcut::activated,
std::bind(&MainWindow::quitAppAction, this, false)); 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); QShortcut * prevPictureShorucut = new QShortcut(QKeySequence(Qt::Key_PageUp), this);
connect(prevPictureShorucut, &QShortcut::activated, connect(prevPictureShorucut, &QShortcut::activated,
this, &MainWindow::galleryPrev); this, &MainWindow::galleryPrev);
@ -121,6 +125,10 @@ MainWindow::MainWindow(QWidget *parent) :
connect(nextPictureShorucut, &QShortcut::activated, connect(nextPictureShorucut, &QShortcut::activated,
this, &MainWindow::galleryNext); this, &MainWindow::galleryNext);
QShortcut * fullscreenShorucut = new QShortcut(QKeySequence(QKeySequence::FullScreen), this);
connect(fullscreenShorucut, &QShortcut::activated,
this, &MainWindow::toggleFullscreen);
centerWindow(); centerWindow();
} }
@ -185,12 +193,18 @@ QUrl MainWindow::currentImageFileUrl() const
return QUrl(); return QUrl();
} }
void MainWindow::clearGallery()
{
m_currentFileIndex = -1;
m_files.clear();
}
void MainWindow::loadGalleryBySingleLocalFile(const QString &path) void MainWindow::loadGalleryBySingleLocalFile(const QString &path)
{ {
QFileInfo info(path); QFileInfo info(path);
QDir dir(info.path()); QDir dir(info.path());
QString currentFileName = info.fileName(); 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); QDir::Files | QDir::NoSymLinks, QDir::NoSort);
QCollator collator; QCollator collator;
@ -198,8 +212,7 @@ void MainWindow::loadGalleryBySingleLocalFile(const QString &path)
std::sort(entryList.begin(), entryList.end(), collator); std::sort(entryList.begin(), entryList.end(), collator);
m_currentFileIndex = -1; clearGallery();
m_files.clear();
for (int i = 0; i < entryList.count(); i++) { for (int i = 0; i < entryList.count(); i++) {
const QString & oneEntry = entryList.at(i); const QString & oneEntry = entryList.at(i);
@ -357,6 +370,7 @@ void MainWindow::contextMenuEvent(QContextMenuEvent *event)
QAction * pasteImage = new QAction(tr("&Paste Image")); QAction * pasteImage = new QAction(tr("&Paste Image"));
connect(pasteImage, &QAction::triggered, this, [ = ](){ connect(pasteImage, &QAction::triggered, this, [ = ](){
clearGallery();
m_graphicsView->showImage(clipboardImage); m_graphicsView->showImage(clipboardImage);
}); });
@ -551,3 +565,12 @@ void MainWindow::quitAppAction(bool force)
closeWindow(); closeWindow();
} }
} }
void MainWindow::toggleFullscreen()
{
if (isFullScreen()) {
showNormal();
} else {
showFullScreen();
}
}

View File

@ -27,6 +27,7 @@ public:
void adjustWindowSizeBySceneRect(); void adjustWindowSizeBySceneRect();
QUrl currentImageFileUrl() const; QUrl currentImageFileUrl() const;
void clearGallery();
void loadGalleryBySingleLocalFile(const QString &path); void loadGalleryBySingleLocalFile(const QString &path);
void galleryPrev(); void galleryPrev();
void galleryNext(); void galleryNext();
@ -52,6 +53,7 @@ protected slots:
void toggleStayOnTop(); void toggleStayOnTop();
bool stayOnTop(); bool stayOnTop();
void quitAppAction(bool force = false); void quitAppAction(bool force = false);
void toggleFullscreen();
private: private:
QPoint m_oldMousePos; QPoint m_oldMousePos;