[go: up one dir, main page]

File: osd.h

package info (click to toggle)
showimg 0.9.5-1.3
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 21,468 kB
  • ctags: 13,090
  • sloc: ansic: 65,847; cpp: 57,096; sh: 12,726; perl: 2,715; yacc: 2,307; makefile: 549; lex: 286
file content (161 lines) | stat: -rw-r--r-- 4,685 bytes parent folder | download | duplicates (2)
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
/*
  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.
*/

/*
  osd.h   -  Provides an interface to a plain QWidget, which is independent of KDE (bypassed to X11)
  begin:     Fre Sep 26 2003
  copyright: (C) 2003-2005 by Christian Muehlhaeuser
  email:     chris@chris.de
*/

#ifndef AMAROK_OSD_H
#define AMAROK_OSD_H

#include <kpixmap.h>
#include <qimage.h>
#include <qvaluelist.h>
#include <qwidget.h> //baseclass


class OSDWidget : public QWidget
{
    Q_OBJECT

    public:
        enum Alignment { Left, Middle, Center, Right };

        OSDWidget( QWidget *parent, const char *name = "osd" );

        /** resets the colours to defaults */
        void unsetColors();

      public slots:
        /** calls setText() then show() */
        void show( const QString &text ) { setText( text ); show(); }

        /** reimplemented, shows the OSD */
        virtual void show();

        /**
         * For the sake of somplicity, when these settings are
         * changed they do not take effect until the next time
         * the OSD is shown!
         *
         * To force an update call show();
         */
        void setDuration( int ms ) { m_duration = ms; }
        void setTextColor( const QColor &color ) { setPaletteForegroundColor( color ); }
        void setBackgroundColor(const QColor &color ) { setPaletteBackgroundColor( color ); }
        void setOffset( int y ) { m_y = y; }
        void setAlignment( Alignment alignment ) { m_alignment = alignment; }
        void setImage( const QImage &image ) { m_image = image; }
        void setScreen( int screen );
        void setText( const QString &text ) { m_text = text;  determineMetrics();}
        void setDrawShadow( bool b ) { m_drawShadow = b; }

    protected:
        /** determine new size and position */
        void determineMetrics();

        /** call to reposition a new OSD text or when position attributes change */
        void reposition( QSize newSize = QSize() );

        /** reimplemented */
        virtual void mousePressEvent( QMouseEvent* );
        virtual void paintEvent( QPaintEvent* );
        virtual bool event( QEvent* );

        /** distance from screen edge */
        static const int MARGIN = 15;

        /** padding inside the OSD frame */
        static const int HPADDING = 20;
        static const int VPADDING = 10;

        int         m_duration;
        QTimer     *m_timer;
        Alignment   m_alignment;
        int         m_screen;
        uint        m_y;
        bool        m_drawShadow;
        QString     m_text;
        QImage      m_image;
        KPixmap     m_screenshot;
};



class OSDPreviewWidget : public OSDWidget
{
    Q_OBJECT

public:
    OSDPreviewWidget( QWidget *parent );

    int screen()    { return m_screen; }
    int alignment() { return m_alignment; }
    int y()         { return m_y; }

public slots:
    void setTextColor( const QColor &color ) { OSDWidget::setTextColor( color ); doUpdate(); }
    void setBackgroundColor(const QColor &color ) { OSDWidget::setBackgroundColor( color ); doUpdate(); }
    void setDrawShadow( bool b ) { OSDWidget::setDrawShadow( b ); doUpdate(); }
    void setFont( const QFont &font ) { OSDWidget::setFont( font ); doUpdate(); }

private:
    inline void doUpdate() { if( isShown() ) show(); }

signals:
    void positionChanged();

protected:
    void mousePressEvent( QMouseEvent * );
    void mouseReleaseEvent( QMouseEvent * );
    void mouseMoveEvent( QMouseEvent * );

private:
    bool   m_dragging;
    QPoint m_dragOffset;
};


class ShowimgOSD : public OSDWidget
{
	Q_OBJECT

	public:
		ShowimgOSD( QWidget *parent );

		void initOSD(bool dispOSD, bool onTop, const QFont& font, bool sFilename, bool sFullpath, bool sDimensions, bool sComments, bool sDatetime, bool sExif);

		void setTexts(const QString& filename, const QString& fullpath, const QString& dimensions, const QString& comments, const QString& datetime, const QString& exif);

		bool getShowOSD();
		bool getOSDOnTop();
		bool getOSDShowFilename();
		bool getOSDShowFullpath();
		bool getOSDShowDimensions();
		bool getOSDShowComments();
		bool getOSDShowDatetime();
		bool getOSDShowExif();

	public slots:
		/** reimplemented, shows the OSD */
		virtual void show();

	protected:
		bool m_dispOSD, m_onTop, m_sFilename, m_sFullpath, m_sDimensions, m_sComments, m_sDatetime, m_sExif;
		QString m_filename, m_fullpath, m_dimensions, m_comments, m_datetime, m_exif;

		QWidget *m_parent;

};




#endif /*AMAROK_OSD_H*/