summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/opiecore.pro14
-rw-r--r--libopie2/opiecore/oresource.cpp85
-rw-r--r--libopie2/opiecore/oresource.h92
3 files changed, 185 insertions, 6 deletions
diff --git a/libopie2/opiecore/opiecore.pro b/libopie2/opiecore/opiecore.pro
index 8f76c48..84f3343 100644
--- a/libopie2/opiecore/opiecore.pro
+++ b/libopie2/opiecore/opiecore.pro
@@ -1,53 +1,55 @@
1TEMPLATE = lib 1TEMPLATE = lib
2CONFIG += qt warn_on 2CONFIG += qt warn_on
3DESTDIR = $(OPIEDIR)/lib 3DESTDIR = $(OPIEDIR)/lib
4HEADERS = oapplication.h \ 4HEADERS = oapplication.h \
5 oconfig.h \ 5 oconfig.h \
6 odebug.h \ 6 odebug.h \
7 oglobal.h \ 7 oglobal.h \
8 oglobalsettings.h \ 8 oglobalsettings.h \
9 oinputsystem.h \ 9 oinputsystem.h \
10 okeyconfigmanager.h \ 10 okeyconfigmanager.h \
11 okeyfilter.h \ 11 okeyfilter.h \
12 opluginloader.h \ 12 opluginloader.h \
13 oprocess.h \ 13 oprocess.h \
14 oprocctrl.h \ 14 oprocctrl.h \
15 osharedpointer.h \ 15 oresource.h \
16 osharedpointer.h \
16 osmartpointer.h \ 17 osmartpointer.h \
17 ostorageinfo.h \ 18 ostorageinfo.h \
18 xmltree.h 19 xmltree.h
19 20
20SOURCES = oapplication.cpp \ 21SOURCES = oapplication.cpp \
21 oconfig.cpp \ 22 oconfig.cpp \
22 odebug.cpp \ 23 odebug.cpp \
23 oglobal.cpp \ 24 oglobal.cpp \
24 oglobalsettings.cpp \ 25 oglobalsettings.cpp \
25 oinputsystem.cpp \ 26 oinputsystem.cpp \
26 okeyconfigmanager.cpp \ 27 okeyconfigmanager.cpp \
27 okeyfilter.cpp \ 28 okeyfilter.cpp \
28 opluginloader.cpp \ 29 opluginloader.cpp \
29 oprocess.cpp \ 30 oprocess.cpp \
30 oprocctrl.cpp \ 31 oprocctrl.cpp \
31 osmartpointer.cpp \ 32 oresource.cpp \
33 osmartpointer.cpp \
32 ostorageinfo.cpp \ 34 ostorageinfo.cpp \
33 xmltree.cpp 35 xmltree.cpp
34 36
35 37
36# The following files are currently not compileable on mac ! 38# The following files are currently not compileable on mac !
37# Therfore I removed them from the build .. (eilers) 39# Therfore I removed them from the build .. (eilers)
38 40
39CONFTEST = $$system( echo $CONFIG_TARGET_MACOSX ) 41CONFTEST = $$system( echo $CONFIG_TARGET_MACOSX )
40!contains( CONFTEST, y ) { 42!contains( CONFTEST, y ) {
41HEADERS += ofilenotify.h 43HEADERS += ofilenotify.h
42SOURCES += ofilenotify.cpp 44SOURCES += ofilenotify.cpp
43} else { 45} else {
44 message( "ofilenotify is not available in a mac build !" ) 46 message( "ofilenotify is not available in a mac build !" )
45} 47}
46 48
47include( device/device.pro ) 49include( device/device.pro )
48 50
49INTERFACES = 51INTERFACES =
50TARGET = opiecore2 52TARGET = opiecore2
51VERSION = 1.9.3 53VERSION = 1.9.3
52INCLUDEPATH += $(OPIEDIR)/include 54INCLUDEPATH += $(OPIEDIR)/include
53DEPENDPATH += $(OPIEDIR)/include 55DEPENDPATH += $(OPIEDIR)/include
diff --git a/libopie2/opiecore/oresource.cpp b/libopie2/opiecore/oresource.cpp
new file mode 100644
index 0000000..88058d0
--- a/dev/null
+++ b/libopie2/opiecore/oresource.cpp
@@ -0,0 +1,85 @@
1/*
2                 This file is part of the Opie Project
3
4 Copyright (C) 2005 Dan Williams <drw@handhelds.org>
5              Copyright (C) 2003 Patrick S. Vogt <tille@handhelds.org>
6 =.
7 .=l.
8           .>+-=
9 _;:,     .>    :=|. This program is free software; you can
10.> <`_,   >  .   <= redistribute it and/or modify it under
11:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
12.="- .-=="i,     .._ License as published by the Free Software
13 - .   .-<_>     .<> Foundation; either version 2 of the License,
14     ._= =}       : or (at your option) any later version.
15    .%`+i>       _;_.
16    .i_,=:_.      -<s. This program is distributed in the hope that
17     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
18    : ..    .:,     . . . without even the implied warranty of
19    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
20  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
21..}^=.=       =       ; Library General Public License for more
22++=   -.     .`     .: details.
23 :     =  ...= . :.=-
24 -.   .:....=;==+<; You should have received a copy of the GNU
25  -_. . .   )=.  = Library General Public License along with
26    --        :-=` this library; see the file COPYING.LIB.
27 If not, write to the Free Software Foundation,
28 Inc., 59 Temple Place - Suite 330,
29 Boston, MA 02111-1307, USA.
30*/
31
32#include <opie2/oapplication.h>
33#include <opie2/odebug.h>
34
35#include <qpe/applnk.h>
36
37#include "oresource.h"
38
39namespace Opie {
40namespace Core {
41
42QImage OResource::loadImage( const QString &name, Scale scale )
43{
44 // Load image
45 QString filename;
46 filename.sprintf( "%spics/%s.png", (const char*) oApp->qpeDir(), (const char*) name );
47 QImage image( filename );
48 if ( image.isNull() )
49 odebug << "libopie2 OResource: can't find image " << filename << oendl;
50
51 // Scale image (if necessary)
52 if ( scale == SmallIcon )
53 {
54 // Retrieve size of small icons
55 if ( smallIconSize == -1 )
56 smallIconSize = AppLnk::smallIconSize();
57
58 // Scale image
59 return image.smoothScale( smallIconSize, smallIconSize );
60 }
61 else if ( scale == BigIcon )
62 {
63 // Retrieve size of big icons
64 if ( bigIconSize == -1 )
65 bigIconSize = AppLnk::bigIconSize();
66
67 // Scale image
68 return image.smoothScale( bigIconSize, bigIconSize );
69 }
70 else
71 return image;
72}
73
74QPixmap OResource::loadPixmap( const QString &name, Scale scale )
75{
76 QPixmap pixmap;
77 pixmap.convertFromImage( loadImage( name, scale ) );
78 return pixmap;
79}
80
81} // namespace Core
82} // namespace Opie
83
84
85
diff --git a/libopie2/opiecore/oresource.h b/libopie2/opiecore/oresource.h
new file mode 100644
index 0000000..8c67ced
--- a/dev/null
+++ b/libopie2/opiecore/oresource.h
@@ -0,0 +1,92 @@
1/*
2                 This file is part of the Opie Project
3
4 Copyright (C) 2005 Dan Williams <drw@handhelds.org>
5              Copyright (C) 2003 Michael Lauer <mickey@tm.informatik.uni-frankfurt.de>
6              Copyright (C) 2003 Patrick S. Vogt <tille@handhelds.org>
7 =.
8 .=l.
9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details.
24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA.
31*/
32
33#ifndef ORESOURCE_H
34#define ORESOURCE_H
35
36#include <qimage.h>
37#include <qpixmap.h>
38
39namespace Opie {
40namespace Core {
41
42static int smallIconSize = -1; // Size of small icons (width & height)
43static int bigIconSize = -1; // Size of large icons (width & height)
44
45
46class OResource
47{
48 public:
49 /**
50 * Image scaling options.
51 *
52 * NoScale - no scaling of image will be performed
53 * SmallIcon - image will be scaled based using SmallIconSize value
54 * for width and height
55 * BigIcon - image will be scaled based on BigIconSize value for
56 * width and height
57 *
58 * Note: SmallIconSize and BigIconSize are run-time configuration
59 * options defined in qpe.conf (Appearance section)
60 */
61 enum Scale { NoScale = 0, SmallIcon, BigIcon };
62
63 /**
64 * Constructor
65 */
66 OResource() {}
67
68 /**
69 * Load specified image.
70 *
71 * @param name - name of pixmap image to load
72 * @param scale - scaling (if any) to preform on image
73 *
74 * @return QImage containing image loaded (and scaled if appropriate)
75 **/
76 static QImage loadImage( const QString &name, Scale scale = NoScale );
77
78 /**
79 * Load specified image.
80 *
81 * @param name - name of pixmap image to load
82 * @param scale - scaling (if any) to preform on image
83 *
84 * @return QPixmap containing image loaded (and scaled if appropriate)
85 **/
86 static QPixmap loadPixmap( const QString &name, Scale scale = NoScale );
87};
88
89} // namespace Core
90} // namespace Opie
91
92#endif