summaryrefslogtreecommitdiffstats
path: root/ksquirrel/sidebar/sq_previewwidget.h
blob: c79ce1f8d57585676d8b2a8241625eeb66a3e28f (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
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
/***************************************************************************
                          sq_previewwidget.h  -  description
                             -------------------
    begin                : ??? Mar 13 2007
    copyright            : (C) 2007 by Baryshev Dmitry
    email                : ksquirrel.iv@gmail.com
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   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.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef SQ_PREVIEWWIDGET_H
#define SQ_PREVIEWWIDGET_H

#include <tqwidget.h>
#include <tqpixmap.h>
#include <tqcolor.h>
#include <tqwmatrix.h>
#include <tqimage.h>

#include <kurl.h>

class KPopupMenu;

class SQ_Downloader;

/**
  *@author Baryshev Dmitry
  */

class SQ_PreviewWidget : public TQWidget
{
    Q_OBJECT
  TQ_OBJECT

    public: 
        SQ_PreviewWidget(TQWidget *tqparent = 0, const char *name = 0);
        ~SQ_PreviewWidget();

        void rereadColor();

        void load(const KURL &url);

        void ignore(bool ign);

        void loadPending();

        static SQ_PreviewWidget* instance() { return m_inst; }

        int delay() const;

        bool cancel() const;

        KURL url() const;

    private:
        void saveValues();

    signals:
        void next();
        void previous();
        void execute();
        void first();
        void last();

    private slots:
        void slotBackground();
        void slotText();
        void slotDownloadResult(const KURL &);
        void slotDownloadPercents(int);

    protected:
        virtual void resizeEvent(TQResizeEvent *);
        virtual void paintEvent(TQPaintEvent *);
        virtual void mousePressEvent(TQMouseEvent *e);
        virtual void keyPressEvent(TQKeyEvent *e);
        virtual void wheelEvent(TQWheelEvent *e);
        virtual void mouseDoubleClickEvent(TQMouseEvent *e);

    private:
        bool fit();
        void fitAndConvert();

    private:
        TQImage *all, *small;
        TQPixmap pixmap;
        bool m_ignore, m_forceignore, m_cancel;
        TQColor color, colorText;
        KPopupMenu *popup;
        KURL pending, m_url;
        int m_delay;
        TQWMatrix matrix;
        SQ_Downloader *down;
        bool multi;
        TQPixmap multi_pix;
        TQString dimstring, percentString;
        bool dim;

        static SQ_PreviewWidget *m_inst;
};

inline
void SQ_PreviewWidget::ignore(bool ign)
{
    m_ignore = ign;
}

inline
int SQ_PreviewWidget::delay() const
{
    return m_delay;
}

inline
bool SQ_PreviewWidget::cancel() const
{
    return m_cancel;
}

inline
KURL SQ_PreviewWidget::url() const
{
    return m_url;
}

#endif