Skip to content

Commit a5ee350

Browse files
committed
~ Fixed dependency mistake.
(Relates to f4a32c4)
1 parent 9b0c7fd commit a5ee350

File tree

4 files changed

+20
-7
lines changed

4 files changed

+20
-7
lines changed

ImageViewBase.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,19 @@
2121
#include "PixmapRenderer.h"
2222
#include "BackgroundExecutor.h"
2323
#include "Dpm.h"
24-
#include "Dpi.h"
2524
#include "ScopedIncDec.h"
2625
#include "imageproc/PolygonUtils.h"
2726
#include "imageproc/Transform.h"
2827
#include "OpenGLSupport.h"
2928
#include "ColorSchemeManager.h"
3029
#include "UnitsProvider.h"
31-
#include "StatusBarPanel.h"
30+
#include "Utils.h"
31+
#include <QApplication>
3232
#include <QScrollBar>
3333
#include <QSettings>
3434
#include <QPointer>
3535
#include <QPaintEngine>
3636
#include <QMouseEvent>
37-
#include <QApplication>
3837
#include <QGLWidget>
3938
#include <QtWidgets/QMainWindow>
4039
#include <QtWidgets/QStatusBar>
@@ -595,8 +594,8 @@ void ImageViewBase::showEvent(QShowEvent* event) {
595594
QWidget::showEvent(event);
596595

597596
if (auto* mainWindow = dynamic_cast<QMainWindow*>(window())) {
598-
if (auto* statusBarPanel = mainWindow->statusBar()->findChild<StatusBarPanel*>()) {
599-
statusBarPanel->setInfoProvider(&infoProvider());
597+
if (auto* infoObserver = Utils::castOrFindChild<ImageViewInfoObserver*>(mainWindow->statusBar())) {
598+
infoObserver->setInfoProvider(&infoProvider());
600599
}
601600
}
602601
}

ImageViewInfoObserver.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <QtCore/QPointF>
77
#include <QtCore/QSizeF>
88

9+
class ImageViewInfoProvider;
910
class Dpi;
1011

1112
class ImageViewInfoObserver {
@@ -19,6 +20,9 @@ class ImageViewInfoObserver {
1920
virtual void updateDpi(const Dpi& dpi) = 0;
2021

2122
virtual void clearImageViewInfo() = 0;
23+
24+
virtual void setInfoProvider(ImageViewInfoProvider* infoProvider) {
25+
}
2226
};
2327

2428

StatusBarPanel.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Q_OBJECT
4242

4343
void updateUnits(Units) override;
4444

45-
void setInfoProvider(ImageViewInfoProvider* infoProvider);
45+
void setInfoProvider(ImageViewInfoProvider* infoProvider) override;
4646

4747
private:
4848
void mousePosChanged();

Utils.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,21 @@ Utils::mapSetValue(std::unordered_map<K, V, Hash, Pred, Alloc>& map, const K& ke
104104

105105
template<typename T>
106106
T Utils::castOrFindChild(QObject* object) {
107+
if (object == nullptr) {
108+
return nullptr;
109+
}
110+
107111
if (auto result = dynamic_cast<T>(object)) {
108112
return result;
109113
} else {
110-
return object->findChild<T>();
114+
for (QObject* child : object->children()) {
115+
if (result = castOrFindChild<T>(child)) {
116+
return result;
117+
}
118+
}
111119
}
120+
121+
return nullptr;
112122
}
113123

114124
#endif // ifndef UTILS_H_

0 commit comments

Comments
 (0)