diff --git a/CMakeLists.txt b/CMakeLists.txt index c7243db02..cbf65f0d6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -342,28 +342,6 @@ if (USE_DBUS) else() endif (USE_DBUS) -############################################################################## - -function(check_private_headers_exist module private_includes_var) -message(STATUS "Checking whether private include directories for module ${module} exist") -foreach(_dir ${private_includes_var}) - if(NOT EXISTS "${_dir}") - message(FATAL_ERROR "The private include directory ${_dir} for module ${module} do not exist! Please make sure your Qt5 installation contains private headers.\nThe required directories:\n ${private_includes_var}") - endif() -endforeach() -endfunction() -function(check_private_header_exists _file _dirs) -set(_found FALSE) -foreach(_dir ${_dirs}) - if(EXISTS "${_dir}/${_file}") - set(_found TRUE) - endif() -endforeach() -if(NOT _found) - message(FATAL_ERROR "The private include file ${_file} was not found in directory ${_dirs}! Please make sure your Qt5 installation contains private headers.") -endif() -endfunction() - ############################################################################## ## Qt5 setup setup if (ENABLE_QT) @@ -372,24 +350,7 @@ if (ENABLE_QT) if (Qt5Widgets_FOUND) message(STATUS "Will enable Qt launcher GUI") message(STATUS " Qt5Widgets version: ${Qt5Widgets_VERSION_STRING}") - message(STATUS " Qt5Widgets include dir: ${Qt5Widgets_INCLUDE_DIRS}") - - # copied from KDAB's GammaRay CMakeLists.txt - # Sanity checking, we need private includes for the following modules - - check_private_headers_exist("Qt5Gui" "${Qt5Gui_PRIVATE_INCLUDE_DIRS}") - - #HACK: CMake with broken Qt5Quick_PRIVATE_INCLUDE_DIRS - if (NOT "${Qt5Quick_PRIVATE_INCLUDE_DIRS}" MATCHES "/QtQuick/") - string(REPLACE "/QtCore" "/QtQuick" replaceme "${Qt5Core_PRIVATE_INCLUDE_DIRS}") - list(APPEND Qt5Quick_PRIVATE_INCLUDE_DIRS ${Qt5Qml_PRIVATE_INCLUDE_DIRS}) - list(APPEND Qt5Quick_PRIVATE_INCLUDE_DIRS ${replaceme}) - list(REMOVE_DUPLICATES Qt5Quick_PRIVATE_INCLUDE_DIRS) - endif() - check_private_header_exists("private/qquickitem_p.h" "${Qt5Quick_PRIVATE_INCLUDE_DIRS}") - - message(STATUS " Qt5Quick private include dir: ${Qt5Quick_PRIVATE_INCLUDE_DIRS}") - + message(STATUS " Qt5Widgets include dir: ${Qt5Widgets_INCLUDE_DIRS}") set(HAVE_QT 1) else() # don't try to build FGQCanvas if Qt wasn't found correctly diff --git a/src/GUI/CMakeLists.txt b/src/GUI/CMakeLists.txt index 4f9d18bce..fbb64a7e5 100644 --- a/src/GUI/CMakeLists.txt +++ b/src/GUI/CMakeLists.txt @@ -148,15 +148,13 @@ if (HAVE_QT) PreviewImageItem.hxx ThumbnailImageItem.cxx ThumbnailImageItem.hxx - FlickableExtentQuery.cxx - FlickableExtentQuery.hxx PopupWindowTracker.cxx PopupWindowTracker.hxx ) set_property(TARGET fgqmlui PROPERTY AUTOMOC ON) target_link_libraries(fgqmlui Qt5::Quick Qt5::Network Qt5::Qml SimGearCore) - target_include_directories(fgqmlui PRIVATE ${PROJECT_BINARY_DIR}/src/GUI ${Qt5Quick_PRIVATE_INCLUDE_DIRS}) + target_include_directories(fgqmlui PRIVATE ${PROJECT_BINARY_DIR}/src/GUI) endif() diff --git a/src/GUI/FlickableExtentQuery.cxx b/src/GUI/FlickableExtentQuery.cxx deleted file mode 100644 index 95c4fc1e0..000000000 --- a/src/GUI/FlickableExtentQuery.cxx +++ /dev/null @@ -1,46 +0,0 @@ -#include "FlickableExtentQuery.hxx" - -#include - -class FriendFlickable : public QQuickFlickable -{ -public: - friend class FlickableExtentQuery; -}; - -FlickableExtentQuery::FlickableExtentQuery(QObject *parent) : QObject(parent) -{ - -} - -qreal FlickableExtentQuery::verticalExtent() const -{ - QQuickFlickable* flick = qobject_cast(m_flickable); - if (!flick) { - return 0; - } - - FriendFlickable* ff = static_cast(flick); - qreal extent = -ff->maxYExtent() + ff->minYExtent(); - return extent; -} - -qreal FlickableExtentQuery::minYExtent() const -{ - QQuickFlickable* flick = qobject_cast(m_flickable); - if (!flick) { - return 0; - } - - FriendFlickable* ff = static_cast(flick); - return ff->minYExtent(); -} - -void FlickableExtentQuery::setFlickable(QQuickItem *flickable) -{ - if (m_flickable == flickable) - return; - - m_flickable = flickable; - emit flickableChanged(m_flickable); -} diff --git a/src/GUI/FlickableExtentQuery.hxx b/src/GUI/FlickableExtentQuery.hxx deleted file mode 100644 index 3e60e05ef..000000000 --- a/src/GUI/FlickableExtentQuery.hxx +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef FLICKABLEEXTENTQUERY_HXX -#define FLICKABLEEXTENTQUERY_HXX - -#include -#include - -/** - * @brief FlickableExtentQuery exists to expose some unfortunately private - * information from a Flickable, to mimic what QQC2 Scrollbar does internlly. - */ -class FlickableExtentQuery : public QObject -{ - Q_OBJECT - - Q_PROPERTY(QQuickItem* flickable READ flickable WRITE setFlickable NOTIFY flickableChanged) - -public: - explicit FlickableExtentQuery(QObject *parent = nullptr); - - QQuickItem* flickable() const - { - return m_flickable; - } - - Q_INVOKABLE qreal verticalExtent() const; - - Q_INVOKABLE qreal minYExtent() const; - -signals: - - void flickableChanged(QQuickItem* flickable); - -public slots: - -void setFlickable(QQuickItem* flickable); - -private: - QQuickItem* m_flickable = nullptr; -}; - -#endif // FLICKABLEEXTENTQUERY_HXX diff --git a/src/GUI/LauncherController.cxx b/src/GUI/LauncherController.cxx index 2c2ad3cb0..893c82c6d 100644 --- a/src/GUI/LauncherController.cxx +++ b/src/GUI/LauncherController.cxx @@ -33,7 +33,6 @@ #include "RecentLocationsModel.hxx" #include "ThumbnailImageItem.hxx" #include "PreviewImageItem.hxx" -#include "FlickableExtentQuery.hxx" #include "MPServersModel.h" #include "AircraftSearchFilterModel.hxx" #include "DefaultAircraftLocator.hxx" @@ -101,7 +100,6 @@ void LauncherController::initQML() qmlRegisterUncreatableType("FlightGear.Launcher", 1, 0, "MPServers", "Singleton API"); qmlRegisterType("FlightGear.Launcher", 1, 0, "FileDialog"); - qmlRegisterType("FlightGear.Launcher", 1, 0, "FlickableExtentQuery"); qmlRegisterType("FlightGear.Launcher", 1, 0, "AircraftInfo"); qmlRegisterType("FlightGear.Launcher", 1, 0, "PopupWindowTracker"); diff --git a/src/GUI/qml/Scrollbar.qml b/src/GUI/qml/Scrollbar.qml index b63e86620..34e08ba42 100644 --- a/src/GUI/qml/Scrollbar.qml +++ b/src/GUI/qml/Scrollbar.qml @@ -1,5 +1,4 @@ import QtQuick 2.4 -import FlightGear.Launcher 1.0 Item { @@ -8,7 +7,6 @@ Item implicitWidth: 14 property Flickable flickable: parent - readonly property real heightRatio: flickable ? flickable.visibleArea.heightRatio : 0 readonly property int barSize: Math.max(height * heightRatio, width * 3); @@ -24,9 +22,10 @@ Item return visArea.yPosition / (1.0 - visArea.heightRatio); } - FlickableExtentQuery { - id: extentQuery - flickable: root.flickable + function verticalExtent() + { + var f = root.flickable; + return (f.height / f.visibleArea.heightRatio) - f.height; } MouseArea { @@ -35,8 +34,7 @@ Item anchors.fill: parent onClicked: { var clickPos = (mouse.y / height) - var cy = clickPos * extentQuery.verticalExtent() - extentQuery.minYExtent(); - flickable.contentY = cy; + flickable.contentY = clickPos * verticalExtent(); } visible: root.enabled } @@ -76,10 +74,9 @@ Item onMouseYChanged: { var position = (thumb.y / root.scrollRange) - var cy = position * extentQuery.verticalExtent() - extentQuery.minYExtent(); - flickable.contentY = cy; + flickable.contentY = position * verticalExtent(); } } } - } + } // of track item }