summaryrefslogtreecommitdiff
path: root/src/modinfodialogimages.h
blob: 6603660a2ee5858ef94cdf3412a552317aa3fa99 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#ifndef MODINFODIALOGIMAGES_H
#define MODINFODIALOGIMAGES_H

#include "modinfodialogtab.h"

class ScalableImage : public QWidget
{
  Q_OBJECT;

public:
  ScalableImage(QImage image={});

  void setImage(QImage image);
  const QImage& image() const;

  bool hasHeightForWidth() const;
  int heightForWidth(int w) const;

signals:
    void clicked(const QImage& image);

protected:
  void paintEvent(QPaintEvent* e) override;
  void mousePressEvent(QMouseEvent* e) override;

private:
  QImage m_original, m_scaled;
  int m_border;
};


class ImagesTab : public ModInfoDialogTab
{
  Q_OBJECT;

public:
  ImagesTab(
    OrganizerCore& oc, PluginContainer& plugin,
    QWidget* parent, Ui::ModInfoDialog* ui, int id);

  void clear() override;
  bool feedFile(const QString& rootPath, const QString& fullPath) override;

private:
  ScalableImage* m_image;

  bool add(const QString& fullPath);
  void onClicked(const QImage& image);
};

#endif // MODINFODIALOGIMAGES_H