Commit 39f712a2 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Adapt build system to build against qt6 + fix compile error

parent c55407db
Pipeline #116921 passed with stage
in 32 seconds
......@@ -9,7 +9,7 @@ set (RELEASE_SERVICE_VERSION "${RELEASE_SERVICE_VERSION_MAJOR}.${RELEASE_SERVICE
project(kmag VERSION ${RELEASE_SERVICE_VERSION})
set(QT_MIN_VERSION "5.15.0")
set(KF5_MIN_VERSION "5.85.0")
set(KF5_MIN_VERSION "5.90.0")
find_package(ECM ${KF5_MIN_VERSION} REQUIRED NO_MODULE)
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH})
......@@ -22,7 +22,7 @@ include(ECMInstallIcons)
include(FeatureSummary)
include(ECMSetupVersion)
find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS
find_package(Qt${QT_MAJOR_VERSION} ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS
Core
Widgets
PrintSupport
......
......@@ -24,9 +24,9 @@ target_link_libraries(kmag
KF5::KIOCore
KF5::I18n
KF5::XmlGui
Qt::Core
Qt::Widgets
Qt::PrintSupport
Qt${QT_MAJOR_VERSION}::Core
Qt${QT_MAJOR_VERSION}::Widgets
Qt${QT_MAJOR_VERSION}::PrintSupport
)
if(QAccessibilityClient_FOUND)
......
......@@ -27,12 +27,12 @@
#include <QApplication>
#include <QClipboard>
#include <QDebug>
#include <QDesktopWidget>
#include <QFileDialog>
#include <QImageWriter>
#include <QMenuBar>
#include <QPainter>
#include <QPrintDialog>
#include <QScreen>
#include <QTemporaryFile>
// include files for KF5
......@@ -627,7 +627,8 @@ void KmagApp::slotToggleRefresh()
void KmagApp::slotModeWholeScreen()
{
m_zoomView->followMouse(false);
m_zoomView->setSelRectPos(QRect (0, 0, QApplication::desktop()->width(), QApplication::desktop()->height()));
const QRect screenGeometry = m_zoomView->screen()->availableGeometry();
m_zoomView->setSelRectPos(QRect (0, 0, screenGeometry.width(), screenGeometry.height()));
m_zoomView->showSelRect(false);
m_zoomView->setFitToWindow (false);
m_modeFollowMouse->setChecked(false);
......
......@@ -22,7 +22,7 @@
// Qt
#include <QApplication>
#include <QBitmap>
#include <QDesktopWidget>
#include <QScreen>
#include <QMouseEvent>
// KF5
#include <KLocalizedString>
......@@ -261,10 +261,11 @@ void KMagSelWin::setSelRect (const QRect &_selRect)
selRect.setLeft (0);
if (selRect.top() < 0)
selRect.setTop (0);
if (selRect.right() > QApplication::desktop()->width())
selRect.setRight (QApplication::desktop()->width());
if (selRect.bottom() > QApplication::desktop()->height())
selRect.setBottom (QApplication::desktop()->height());
const QRect screenGeometry = screen()->availableGeometry();
if (selRect.right() > screenGeometry.width())
selRect.setRight (screenGeometry.width());
if (selRect.bottom() > screenGeometry.height())
selRect.setBottom (screenGeometry.height());
setGeometry (
selRect.left() - getFrameSize(),
......
......@@ -29,7 +29,6 @@
// include files for Qt
#include <QApplication>
#include <QBitmap>
#include <QDesktopWidget>
#include <QScrollBar>
#include <QScreen>
#include <QPainter>
......@@ -642,6 +641,7 @@ void KMagZoomView::mouseReleaseEvent(QMouseEvent *e)
*/
void KMagZoomView::mouseMoveEvent(QMouseEvent *e)
{
const QRect screenGeometry = screen()->availableGeometry();
if(m_mouseMode == ResizeSelection) {
// In resize selection mode
// set the current mouse position as the bottom, right corner
......@@ -657,20 +657,21 @@ void KMagZoomView::mouseMoveEvent(QMouseEvent *e)
// make sure the mouse position is not taking the grab window outside
// the display
const QRect screenGeometry = screen()->availableGeometry();
if(newCenter.x() < m_selRect.width()/2) {
// set X to the minimum possible X
newCenter.setX(m_selRect.width()/2);
} else if(newCenter.x() >= QApplication::desktop()->width()-m_selRect.width()/2) {
} else if(newCenter.x() >= screenGeometry.width()-m_selRect.width()/2) {
// set X to the maximum possible X
newCenter.setX(QApplication::desktop()->width()-m_selRect.width()/2-1);
newCenter.setX(screenGeometry.width()-m_selRect.width()/2-1);
}
if(newCenter.y() < m_selRect.height()/2) {
// set Y to the minimum possible Y
newCenter.setY(m_selRect.height()/2);
} else if(newCenter.y() >= QApplication::desktop()->height()-m_selRect.height()/2) {
} else if(newCenter.y() >= screenGeometry.height()-m_selRect.height()/2) {
// set Y to the maximum possible Y
newCenter.setY(QApplication::desktop()->height()-m_selRect.height()/2-1);
newCenter.setY(screenGeometry.height()-m_selRect.height()/2-1);
}
// move to the new center
m_selRect.moveCenter(newCenter);
......@@ -691,17 +692,17 @@ void KMagZoomView::mouseMoveEvent(QMouseEvent *e)
if(newCenter.x() < m_selRect.width()/2) {
// set X to the minimum possible X
newCenter.setX(m_selRect.width()/2);
} else if(newCenter.x() >= QApplication::desktop()->width()-m_selRect.width()/2) {
} else if(newCenter.x() >= screenGeometry.width()-m_selRect.width()/2) {
// set X to the maximum possible X
newCenter.setX(QApplication::desktop()->width()-m_selRect.width()/2-1);
newCenter.setX(screenGeometry.width()-m_selRect.width()/2-1);
}
if(newCenter.y() < m_selRect.height()/2) {
// set Y to the minimum possible Y
newCenter.setY(m_selRect.height()/2);
} else if(newCenter.y() >= QApplication::desktop()->height()-m_selRect.height()/2) {
} else if(newCenter.y() >= screenGeometry.height()-m_selRect.height()/2) {
// set Y to the maximum possible Y
newCenter.setY(QApplication::desktop()->height()-m_selRect.height()/2-1);
newCenter.setY(screenGeometry.height()-m_selRect.height()/2-1);
}
// move to the new center
......@@ -752,8 +753,9 @@ void KMagZoomView::keyPressEvent(QKeyEvent *e)
{
if (e->modifiers() & Qt::ControlModifier)
{
if (m_selRect.right()+offset >= QApplication::desktop()->width())
m_selRect.setRight (QApplication::desktop()->width()-1);
const QRect screenGeometry = screen()->availableGeometry();
if (m_selRect.right()+offset >= screenGeometry.width())
m_selRect.setRight (screenGeometry.width()-1);
else
m_selRect.setRight (m_selRect.right()+offset);
}
......@@ -767,8 +769,9 @@ void KMagZoomView::keyPressEvent(QKeyEvent *e)
}
else if (m_followMouse == false)
{
if (m_selRect.right()+offset >= QApplication::desktop()->width())
m_selRect.moveTopRight (QPoint (QApplication::desktop()->width()-1, m_selRect.top()));
const QRect screenGeometry = screen()->availableGeometry();
if (m_selRect.right()+offset >= screenGeometry.width())
m_selRect.moveTopRight (QPoint (screenGeometry.width()-1, m_selRect.top()));
else
m_selRect.translate (offset,0);
}
......@@ -804,8 +807,9 @@ void KMagZoomView::keyPressEvent(QKeyEvent *e)
{
if (e->modifiers() & Qt::ControlModifier)
{
if (m_selRect.bottom()+offset >= QApplication::desktop()->height())
m_selRect.setBottom (QApplication::desktop()->height()-1);
const QRect screenGeometry = screen()->availableGeometry();
if (m_selRect.bottom()+offset >= screenGeometry.height())
m_selRect.setBottom (screenGeometry.height()-1);
else
m_selRect.setBottom (m_selRect.bottom()+offset);
}
......@@ -819,8 +823,9 @@ void KMagZoomView::keyPressEvent(QKeyEvent *e)
}
else if (m_followMouse == false)
{
if (m_selRect.bottom()+offset >= QApplication::desktop()->height())
m_selRect.moveBottomLeft (QPoint (m_selRect.left(), QApplication::desktop()->height()-1));
const QRect screenGeometry = screen()->availableGeometry();
if (m_selRect.bottom()+offset >= screenGeometry.height())
m_selRect.moveBottomLeft (QPoint (m_selRect.left(), screenGeometry.height()-1));
else
m_selRect.translate (0, offset);
}
......@@ -872,22 +877,22 @@ void KMagZoomView::fitToWindow()
m_selRect.setWidth(newWidth);
m_selRect.setHeight(newHeight);
const QRect screenGeometry = screen()->availableGeometry();
// make sure the selection window does not go outside of the display
if(currCenter.x() < m_selRect.width()/2) {
// set X to the minimum possible X
currCenter.setX(m_selRect.width()/2);
} else if(currCenter.x() >= QApplication::desktop()->width()-m_selRect.width()/2) {
} else if(currCenter.x() >= screenGeometry.width()-m_selRect.width()/2) {
// set X to the maximum possible X
currCenter.setX(QApplication::desktop()->width()-m_selRect.width()/2-1);
currCenter.setX(screenGeometry.width()-m_selRect.width()/2-1);
}
if(currCenter.y() < m_selRect.height()/2) {
// set Y to the minimum possible Y
currCenter.setY(m_selRect.height()/2);
} else if(currCenter.y() >= QApplication::desktop()->height()-m_selRect.height()/2) {
} else if(currCenter.y() >= screenGeometry.height()-m_selRect.height()/2) {
// set Y to the maximum possible Y
currCenter.setY(QApplication::desktop()->height()-m_selRect.height()/2-1);
currCenter.setY(screenGeometry.height()-m_selRect.height()/2-1);
}
m_selRect.moveCenter(currCenter);
......@@ -935,20 +940,21 @@ void KMagZoomView::grabFrame()
// make sure the mouse position is not taking the grab window outside
// the display
const QRect screenGeometry = screen()->availableGeometry();
if(newCenter.x() < m_selRect.width()/2) {
// set X to the minimum possible X
newCenter.setX(m_selRect.width()/2);
} else if(newCenter.x() >= QApplication::desktop()->width()-m_selRect.width()/2) {
} else if(newCenter.x() >= screenGeometry.width()-m_selRect.width()/2) {
// set X to the maximum possible X
newCenter.setX(QApplication::desktop()->width()-m_selRect.width()/2-1);
newCenter.setX(screenGeometry.width()-m_selRect.width()/2-1);
}
if(newCenter.y() < m_selRect.height()/2) {
// set Y to the minimum possible Y
newCenter.setY(m_selRect.height()/2);
} else if(newCenter.y() >= QApplication::desktop()->height()-m_selRect.height()/2) {
} else if(newCenter.y() >= screenGeometry.height()-m_selRect.height()/2) {
// set Y to the maximum possible Y
newCenter.setY(QApplication::desktop()->height()-m_selRect.height()/2-1);
newCenter.setY(screenGeometry.height()-m_selRect.height()/2-1);
}
// move to the new center
m_selRect.moveCenter(newCenter);
......@@ -962,7 +968,7 @@ void KMagZoomView::grabFrame()
// grab screenshot from the screen and put it in the pixmap
QScreen *screen = qApp->primaryScreen(); // ## How to select the right screen?
m_coloredPixmap = screen->grabWindow(QApplication::desktop()->winId(), selRect.x(), selRect.y(),
m_coloredPixmap = screen->grabWindow(winId(), selRect.x(), selRect.y(),
selRect.width(), selRect.height());
// colorize the grabbed pixmap
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment