Skip to content

Commit

Permalink
~ Fixed dependency mistake.
Browse files Browse the repository at this point in the history
(Relates to f4a32c4)
  • Loading branch information
4lex4 committed Feb 18, 2018
1 parent 9b0c7fd commit a5ee350
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 7 deletions.
9 changes: 4 additions & 5 deletions ImageViewBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,19 @@
#include "PixmapRenderer.h"
#include "BackgroundExecutor.h"
#include "Dpm.h"
#include "Dpi.h"
#include "ScopedIncDec.h"
#include "imageproc/PolygonUtils.h"
#include "imageproc/Transform.h"
#include "OpenGLSupport.h"
#include "ColorSchemeManager.h"
#include "UnitsProvider.h"
#include "StatusBarPanel.h"
#include "Utils.h"
#include <QApplication>
#include <QScrollBar>
#include <QSettings>
#include <QPointer>
#include <QPaintEngine>
#include <QMouseEvent>
#include <QApplication>
#include <QGLWidget>
#include <QtWidgets/QMainWindow>
#include <QtWidgets/QStatusBar>
Expand Down Expand Up @@ -595,8 +594,8 @@ void ImageViewBase::showEvent(QShowEvent* event) {
QWidget::showEvent(event);

if (auto* mainWindow = dynamic_cast<QMainWindow*>(window())) {
if (auto* statusBarPanel = mainWindow->statusBar()->findChild<StatusBarPanel*>()) {
statusBarPanel->setInfoProvider(&infoProvider());
if (auto* infoObserver = Utils::castOrFindChild<ImageViewInfoObserver*>(mainWindow->statusBar())) {
infoObserver->setInfoProvider(&infoProvider());
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions ImageViewInfoObserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <QtCore/QPointF>
#include <QtCore/QSizeF>

class ImageViewInfoProvider;
class Dpi;

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

virtual void clearImageViewInfo() = 0;

virtual void setInfoProvider(ImageViewInfoProvider* infoProvider) {
}
};


Expand Down
2 changes: 1 addition & 1 deletion StatusBarPanel.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Q_OBJECT

void updateUnits(Units) override;

void setInfoProvider(ImageViewInfoProvider* infoProvider);
void setInfoProvider(ImageViewInfoProvider* infoProvider) override;

private:
void mousePosChanged();
Expand Down
12 changes: 11 additions & 1 deletion Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,21 @@ Utils::mapSetValue(std::unordered_map<K, V, Hash, Pred, Alloc>& map, const K& ke

template<typename T>
T Utils::castOrFindChild(QObject* object) {
if (object == nullptr) {
return nullptr;
}

if (auto result = dynamic_cast<T>(object)) {
return result;
} else {
return object->findChild<T>();
for (QObject* child : object->children()) {
if (result = castOrFindChild<T>(child)) {
return result;
}
}
}

return nullptr;
}

#endif // ifndef UTILS_H_

0 comments on commit a5ee350

Please sign in to comment.