Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove qt5 support and fix kf6 #556

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 4 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,27 +34,19 @@ if(UNIX AND NOT APPLE)
endif()

# FIND PACKAGES
find_package(Qt5 COMPONENTS Widgets QUIET)
if(Qt5_FOUND)
find_package(QT NAMES Qt5 REQUIRED COMPONENTS Core Widgets Svg PrintSupport)
else()
find_package(QT NAMES Qt6 REQUIRED COMPONENTS Core Widgets Svg PrintSupport OpenGLWidgets)
endif()
find_package(Qt6 COMPONENTS Widgets QUIET)
find_package(QT NAMES Qt6 REQUIRED COMPONENTS Core Widgets Svg PrintSupport OpenGLWidgets)

message(STATUS "Qt Version: " ${QT_VERSION})
if(QT_VERSION_MAJOR GREATER_EQUAL 6)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Widgets Svg PrintSupport OpenGLWidgets)
else()
find_package(Qt${QT_VERSION_MAJOR} 5.12 REQUIRED COMPONENTS Core Widgets Svg PrintSupport)
endif()
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Widgets Svg PrintSupport OpenGLWidgets)

if(EXIV2)
find_package(PkgConfig REQUIRED)
pkg_check_modules(Exiv2 REQUIRED IMPORTED_TARGET exiv2)
endif()

if(KDE_SUPPORT)
find_package(KF5WindowSystem REQUIRED)
find_package(KF6WindowSystem REQUIRED)
endif()

if(OPENCV_SUPPORT)
Expand Down
2 changes: 1 addition & 1 deletion plugins/player_mpv/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ set(CMAKE_AUTOMOC ON)
# only export CreatePlayerWidget function
ADD_DEFINITIONS(-DQIMGV_PLAYER_MPV_LIBRARY)

find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core Widgets)
find_package(QT NAMES Qt6 REQUIRED COMPONENTS Core Widgets)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Widgets)

if(NOT WIN32)
Expand Down
6 changes: 1 addition & 5 deletions plugins/player_mpv/src/qthelper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,7 @@ struct node_builder {
return r;
}
bool test_type(const QVariant &v, QMetaType::Type t) {
// The Qt docs say: "Although this function is declared as returning
// "QVariant::Type(obsolete), the return value should be interpreted
// as QMetaType::Type."
// So a cast really seems to be needed to avoid warnings (urgh).
return static_cast<int>(v.type()) == static_cast<int>(t);
return v.userType() == static_cast<int>(t);
}
void set(mpv_node *dst, const QVariant &src) {
if (test_type(src, QMetaType::QString)) {
Expand Down
10 changes: 1 addition & 9 deletions qimgv/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,6 @@ set(TS_FILES
list(TRANSFORM TS_FILES PREPEND ${CMAKE_CURRENT_SOURCE_DIR}/res/translations/)
set_source_files_properties(${TS_FILES} PROPERTIES OUTPUT_LOCATION ${PROJECT_BINARY_DIR}/qimgv/translations)

# 1. Create 'qimgv_lupdate' target to update .ts files (needs to be called manually)
# 2. Compile .ts > .qm
if(${QT_VERSION_MAJOR} EQUAL 5)
add_custom_target(qimgv_lupdate COMMAND ${Qt5_LUPDATE_EXECUTABLE} -recursive
${CMAKE_CURRENT_SOURCE_DIR} -ts ${TS_FILES})
qt5_add_translation(QM_FILES ${TS_FILES})
endif()

# ADD EXECUTABLE
add_executable(qimgv
appversion.cpp
Expand Down Expand Up @@ -80,7 +72,7 @@ if(EXIV2)
target_compile_definitions(qimgv PRIVATE USE_EXIV2)
endif()
if(KDE_SUPPORT)
target_link_libraries(qimgv PRIVATE KF5::WindowSystem)
target_link_libraries(qimgv PRIVATE KF6::WindowSystem)
target_compile_definitions(qimgv PRIVATE USE_KDE_BLUR)
endif()
if(VIDEO_SUPPORT)
Expand Down
4 changes: 2 additions & 2 deletions qimgv/gui/folderview/foldergridview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ FolderGridView::FolderGridView(QWidget *parent)

void FolderGridView::dropEvent(QDropEvent *event) {
event->accept();
ThumbnailWidget *item = dynamic_cast<ThumbnailWidget*>(itemAt(event->pos()));
ThumbnailWidget *item = dynamic_cast<ThumbnailWidget*>(itemAt(event->position().toPoint()));
int index = -1;
if(item) {
index = thumbnails.indexOf(item);
Expand All @@ -44,7 +44,7 @@ void FolderGridView::dragEnterEvent(QDragEnterEvent *event) {

void FolderGridView::dragMoveEvent(QDragMoveEvent *event) {
event->accept();
ThumbnailWidget *item = dynamic_cast<ThumbnailWidget*>(itemAt(event->pos()));
ThumbnailWidget *item = dynamic_cast<ThumbnailWidget*>(itemAt(event->position().toPoint()));
int index = -1;
if(item)
index = thumbnails.indexOf(item);
Expand Down
2 changes: 1 addition & 1 deletion qimgv/gui/folderview/treeviewcustom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ TreeViewCustom::TreeViewCustom(QWidget *parent) : QTreeView(parent) {
}

void TreeViewCustom::dropEvent(QDropEvent *event) {
QModelIndex dropIndex = indexAt(event->pos());
QModelIndex dropIndex = indexAt(event->position().toPoint());
if(dropIndex.isValid()) {
QList<QString> paths;
// TODO: QUrl gave me some issues previosly, test
Expand Down
24 changes: 18 additions & 6 deletions qimgv/gui/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,14 @@ void MW::mouseReleaseEvent(QMouseEvent *event) {

void MW::mouseDoubleClickEvent(QMouseEvent *event) {
event->accept();
QMouseEvent *fakePressEvent = new QMouseEvent(QEvent::MouseButtonPress, event->pos(), event->button(), event->buttons(), event->modifiers());
QMouseEvent *fakePressEvent = new QMouseEvent(
QEvent::MouseButtonPress,
event->position(),
event->globalPosition(),
event->button(),
event->buttons(),
event->modifiers()
);
actionManager->processEvent(fakePressEvent);
actionManager->processEvent(event);
}
Expand Down Expand Up @@ -919,16 +926,21 @@ void MW::readSettings() {
// todo: remove/rename?
void MW::applyWindowedBackground() {
#ifdef USE_KDE_BLUR
if(settings->backgroundOpacity() == 1.0)
KWindowEffects::enableBlurBehind(winId(), false);
else
KWindowEffects::enableBlurBehind(winId(), settings->blurBackground());
QWindow* window = this->windowHandle();
if(window) {
if(settings->backgroundOpacity() == 1.0)
KWindowEffects::enableBlurBehind(window, false);
else
KWindowEffects::enableBlurBehind(window, settings->blurBackground());
}
#endif
}

void MW::applyFullscreenBackground() {
#ifdef USE_KDE_BLUR
KWindowEffects::enableBlurBehind(winId(), false);
QWindow* window = this->windowHandle();
if(window)
KWindowEffects::enableBlurBehind(window, false);
#endif
}

Expand Down
5 changes: 1 addition & 4 deletions qimgv/gui/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@
#include <QFileDialog>
#include <QMimeData>
#include <QImageWriter>

#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
#include <QDesktopWidget>
#endif
#include <QWindow>

#include "gui/customwidgets/floatingwidgetcontainer.h"
#include "gui/viewers/viewerwidget.h"
Expand Down
4 changes: 2 additions & 2 deletions qimgv/gui/overlays/mapoverlay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,15 +257,15 @@ void MapOverlay::updateMap(const QRectF &drawingRect) {
void MapOverlay::mousePressEvent(QMouseEvent *event) {
QWidget::mousePressEvent(event);
setCursor(Qt::ClosedHandCursor);
d->moveMainImage(event->x(), event->y());
d->moveMainImage(event->position().x(), event->position().y());
event->accept();
}

void MapOverlay::mouseMoveEvent(QMouseEvent *event) {
QWidget::mouseMoveEvent(event);

if(event->buttons() & Qt::LeftButton) {
d->moveMainImage(event->x(), event->y());
d->moveMainImage(event->position().x(), event->position().y());
}
event->accept();
}
Expand Down
2 changes: 1 addition & 1 deletion qimgv/gui/overlays/renameoverlay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void RenameOverlay::recalculateGeometry() {
void RenameOverlay::selectName() {
int end = ui->fileName->text().lastIndexOf(".");
if(end < 0)
end = ui->fileName->text().count();
end = ui->fileName->text().size();
ui->fileName->setSelection(0, end);
}

Expand Down
2 changes: 2 additions & 0 deletions qimgv/gui/panels/mainpanel/mainpanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ QSize MainPanel::sizeHint() const {
case PANEL_LEFT:
case PANEL_RIGHT:
return QSize(thumbnailStrip->itemSize().width() + 16, height());
default:
return QSize(0, 0);
}
}

Expand Down
12 changes: 0 additions & 12 deletions qimgv/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,6 @@ int main(int argc, char *argv[]) {
// do we still need this?
qputenv("QT_AUTO_SCREEN_SCALE_FACTOR","0");

// some qt5 hidpi vars
#if (QT_VERSION_MAJOR == 5)
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
#endif

// Qt6 hidpi rendering on windows still has artifacts
// This disables it for scale factors < 1.75
// In this case only fonts are scaled
Expand Down Expand Up @@ -97,12 +91,6 @@ int main(int argc, char *argv[]) {
mallopt(M_MMAP_THRESHOLD, 64000);
#endif

#ifdef USE_EXIV2
#if EXIV2_TEST_VERSION(0,27,4)
Exiv2::enableBMFF(true);
#endif
#endif

// use custom types in signals
qRegisterMetaType<ScalerRequest>("ScalerRequest");
qRegisterMetaType<Script>("Script");
Expand Down
4 changes: 2 additions & 2 deletions qimgv/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
enable_testing()
find_package(Qt5 REQUIRED COMPONENTS Test Widgets)
find_package(Qt6 REQUIRED COMPONENTS Test Widgets)

include_directories(${CMAKE_SOURCE_DIR})

add_executable(unit_tests test_mapoverlay.cpp)
target_link_libraries(unit_tests PRIVATE Qt5::Test Qt5::Widgets)
target_link_libraries(unit_tests PRIVATE Qt6::Test Qt6::Widgets)

add_test(NAME QUI_TEST COMMAND unit_tests)