summaryrefslogtreecommitdiff
path: root/libopie2
authordrw <drw>2005-04-05 22:38:32 (UTC)
committer drw <drw>2005-04-05 22:38:32 (UTC)
commit0f7b159f0a4972b6ffdc292f5eb4d2169c7fa75d (patch) (side-by-side diff)
tree27fb276e59b1eab586d029feaf21f45ddf1cb96a /libopie2
parent327e938f58125a52482b9a6543dd1aa4243bb5d3 (diff)
downloadopie-0f7b159f0a4972b6ffdc292f5eb4d2169c7fa75d.zip
opie-0f7b159f0a4972b6ffdc292f5eb4d2169c7fa75d.tar.gz
opie-0f7b159f0a4972b6ffdc292f5eb4d2169c7fa75d.tar.bz2
Use OResource for loading images
Diffstat (limited to 'libopie2') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opieui/fileselector/ofileselector.cpp81
-rw-r--r--libopie2/opieui/fileselector/ofileselector.h46
-rw-r--r--libopie2/opieui/otabwidget.cpp66
-rw-r--r--libopie2/opieui/otabwidget.h52
-rw-r--r--libopie2/opieui/owait.cpp50
-rw-r--r--libopie2/opieui/owait.h47
6 files changed, 163 insertions, 179 deletions
diff --git a/libopie2/opieui/fileselector/ofileselector.cpp b/libopie2/opieui/fileselector/ofileselector.cpp
index 8b53038..f3e7501 100644
--- a/libopie2/opieui/fileselector/ofileselector.cpp
+++ b/libopie2/opieui/fileselector/ofileselector.cpp
@@ -1,91 +1,92 @@
-
/*
-               =. This file is part of the OPIE Project
-             .=l. Copyright (C) 2002,2003 Holger Freyther <zecke@handhelds.org>
-           .>+-=
- _;:,     .>    :=|. This library is free software; you can
-.> <`_,   >  .   <= redistribute it and/or modify it under
-:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
-.="- .-=="i,     .._ License as published by the Free Software
- - .   .-<_>     .<> Foundation; either version 2 of the License,
-     ._= =}       : or (at your option) any later version.
-    .%`+i>       _;_.
-    .i_,=:_.      -<s. This library is distributed in the hope that
-     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
-    : ..    .:,     . . . without even the implied warranty of
-    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
-  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
-..}^=.=       =       ; Library General Public License for more
-++=   -.     .`     .: details.
- :     =  ...= . :.=-
- -.   .:....=;==+<; You should have received a copy of the GNU
-  -_. . .   )=.  = Library General Public License along with
-    --        :-=` this library; see the file COPYING.LIB.
+                 This file is part of the Opie Project
+
+ Copyright (C) 2002,2003 Holger Freyther <zecke@handhelds.org>
+ =.
+ .=l.
+           .>+-=
+ _;:,     .>    :=|. This program is free software; you can
+.> <`_,   >  .   <= redistribute it and/or modify it under
+:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
+.="- .-=="i,     .._ License as published by the Free Software
+ - .   .-<_>     .<> Foundation; either version 2 of the License,
+     ._= =}       : or (at your option) any later version.
+    .%`+i>       _;_.
+    .i_,=:_.      -<s. This program is distributed in the hope that
+     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
+ : ..    .:,     . . . without even the implied warranty of
+    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
+  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
+..}^=.=       =       ; Library General Public License for more
+++=   -.     .`     .: details.
+ :     =  ...= . :.=-
+ -.   .:....=;==+<; You should have received a copy of the GNU
+  -_. . .   )=.  = Library General Public License along with
+    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
-
*/
/* hacky but we need to get FileSelector::filter */
#define private public
#include <qpe/fileselector.h>
#undef private
#include "ofileselector_p.h"
/* OPIE */
-#include <opie2/ofileselector.h>
#include <opie2/odebug.h>
+#include <opie2/ofileselector.h>
+#include <opie2/oresource.h>
#include <qpe/qpeapplication.h>
#include <qpe/mimetype.h>
-#include <qpe/resource.h>
#include <qpe/storage.h>
/* QT */
#include <qcombobox.h>
#include <qdir.h>
#include <qhbox.h>
#include <qheader.h>
#include <qlabel.h>
#include <qlayout.h>
#include <qlineedit.h>
#include <qlistview.h>
#include <qpopupmenu.h>
#include <qwidgetstack.h>
#include <qregexp.h>
#include <qobjectlist.h>
using namespace Opie::Ui::Internal;
namespace Opie {
namespace Ui {
namespace Internal {
/*
* Create a path by adding a '/'/QDir::seperator in between
* base and ending, but only if base is not empty
*/
static inline QString createNewPath(const QString& base, const QString &ending) {
return base == QString::fromLatin1("/") ?
base + ending : base + "/" + ending;
}
OFileViewInterface::OFileViewInterface( OFileSelector* _selector )
: m_selector( _selector )
{
selector()->registerView( this );
}
OFileViewInterface::~OFileViewInterface()
{}
QString OFileViewInterface::name()const
{
return m_name;
}
void OFileViewInterface::setName( const QString& name )
{
m_name = name;
@@ -289,137 +290,130 @@ QString OFileSelectorItem::key( int id, bool )const
{
QString ke;
/*
* id = 0 ||id == 1 : Sort By Name but Directories at Top
* id = 2 : Sort By Size: Prepend '0' to the key
*/
if( id == 0 || id == 1 )
{ // name
if( m_isDir )
{
ke.append("0" );
ke.append( text(1) );
}
else
{
ke.append("1" );
ke.append( text(1) );
}
return ke;
}else if(id == 2) {
return text(2).rightJustify(20, '0');
}else
return text( id );
}
OFileViewFileListView::OFileViewFileListView( QWidget* parent, const QString& startDir, OFileSelector* sel)
:QWidget( parent ), m_sel( sel )
{
m_all = false;
QVBoxLayout* lay = new QVBoxLayout( this );
m_currentDir = startDir;
/*
* now we add a special bar
* One Button For Up
* Home
* Doc
* And a dropdown menu with FileSystems
* FUTURE: one to change dir with lineedit
* Bookmarks
* Create Dir
*/
QHBox* box = new QHBox(this );
box->setBackgroundMode( PaletteButton );
box->setSpacing( 0 );
- QPixmap pic;
QToolButton *btn = new QToolButton( box );
btn->setUsesBigPixmap( true );
- pic.convertFromImage( Resource::loadImage( "up" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) );
- btn->setPixmap( pic );
+ btn->setPixmap( Opie::Core::OResource::loadPixmap( "up", Opie::Core::OResource::SmallIcon ) );
connect(btn, SIGNAL(clicked() ),
this, SLOT( cdUP() ) );
btn = new QToolButton( box );
btn->setUsesBigPixmap( true );
- pic.convertFromImage( Resource::loadImage( "home" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) );
- btn->setPixmap( pic );
+ btn->setPixmap( Opie::Core::OResource::loadPixmap( "home", Opie::Core::OResource::SmallIcon ) );
connect(btn, SIGNAL(clicked() ),
this, SLOT( cdHome() ) );
btn = new QToolButton( box );
btn->setUsesBigPixmap( true );
- pic.convertFromImage( Resource::loadImage( "DocsIcon" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) );
- btn->setPixmap( pic );
+ btn->setPixmap( Opie::Core::OResource::loadPixmap( "DocsIcon", Opie::Core::OResource::SmallIcon ) );
connect(btn, SIGNAL(clicked() ),
this, SLOT(cdDoc() ) );
m_btnNew = new QToolButton( box );
m_btnNew->setUsesBigPixmap( true );
- pic.convertFromImage( Resource::loadImage( "new" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) );
- m_btnNew->setPixmap( pic );
+ m_btnNew->setPixmap( Opie::Core::OResource::loadPixmap( "new", Opie::Core::OResource::SmallIcon ) );
connect(m_btnNew, SIGNAL(clicked() ),
this, SLOT(slotNew() ) );
m_btnClose = new QToolButton( box );
m_btnClose->setUsesBigPixmap( true );
- pic.convertFromImage( Resource::loadImage( "close" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) );
- m_btnClose->setPixmap( pic );
+ m_btnClose->setPixmap( Opie::Core::OResource::loadPixmap( "close", Opie::Core::OResource::SmallIcon ) );
connect(m_btnClose, SIGNAL(clicked() ),
selector(), SIGNAL(closeMe() ) );
btn = new QToolButton( box );
btn->setUsesBigPixmap( true );
- pic.convertFromImage( Resource::loadImage( "cardmon/pcmcia" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) );
- btn->setPixmap( pic );
+ btn->setPixmap( Opie::Core::OResource::loadPixmap( "cardmon/pcmcia", Opie::Core::OResource::SmallIcon ) );
m_fsButton = btn;
/* let's fill device parts */
QPopupMenu* pop = new QPopupMenu(this);
connect(pop, SIGNAL( activated(int) ),
this, SLOT(slotFSActivated(int) ) );
StorageInfo storage;
const QList<FileSystem> &fs = storage.fileSystems();
QListIterator<FileSystem> it(fs);
for ( ; it.current(); ++it )
{
const QString disk = (*it)->name();
const QString path = (*it)->path();
m_dev.insert( disk, path );
pop->insertItem( disk );
}
m_fsPop = pop;
connect(btn,SIGNAL(pressed()),this,SLOT(slotFSpressed()));
lay->addWidget( box );
m_view = new QListView( this );
m_view->installEventFilter(this);
QPEApplication::setStylusOperation( m_view->viewport(),
QPEApplication::RightOnHold);
m_view->addColumn(" " );
m_view->addColumn(tr("Name"), 135 );
m_view->addColumn(tr("Size"), -1 );
m_view->addColumn(tr("Date"), 60 );
m_view->addColumn(tr("Mime Type"), -1 );
m_view->setSorting( 1 );
m_view->setAllColumnsShowFocus( TRUE );
lay->addWidget( m_view, 1000 );
connectSlots();
}
void OFileViewFileListView::slotFSpressed()
{
m_fsPop->exec(QPoint( QCursor::pos().x(), QCursor::pos().y()));
m_fsButton->setDown(false);
}
@@ -594,133 +588,134 @@ void OFileViewFileListView::slotCurrentChanged( QListViewItem* item)
QStringList str = QStringList::split("->", sel->text(1) );
QString path = createNewPath(sel->directory(),str[0].stripWhiteSpace());
emit selector()->fileSelected( path );
DocLnk lnk( path );
emit selector()->fileSelected( lnk );
}
}
#endif
}
void OFileViewFileListView::slotClicked(int button , QListViewItem* item, const QPoint&, int )
{
if (!item || ( button != Qt::LeftButton) )
return;
OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item);
if (!sel->isLocked() )
{
QStringList str = QStringList::split("->", sel->text(1) );
if (sel->isDir() )
{
m_currentDir = createNewPath(sel->directory(),str[0].stripWhiteSpace());
emit selector()->dirSelected( m_currentDir );
reread( m_all );
}
else
{ // file
odebug << "slot Clicked" << oendl;
selector()->m_lneEdit->setText( str[0].stripWhiteSpace() );
QString path = createNewPath(sel->directory(),str[0].stripWhiteSpace());
emit selector()->fileSelected( path );
DocLnk lnk( path );
emit selector()->fileSelected( lnk );
}
} // not locked
}
void OFileViewFileListView::addFile( QFileInfo* info, bool symlink )
{
MimeType type( info->absFilePath() );
if (!compliesMime( type.id() ) )
return;
QPixmap pix = type.pixmap();
QString dir, name; bool locked;
if ( pix.isNull() )
{
QWMatrix matrix;
- QPixmap pixer(Resource::loadPixmap("UnknownDocument") );
+ QPixmap pixer( Opie::Core::OResource::loadPixmap( "UnknownDocument" ) );
matrix.scale( .4, .4 );
pix = pixer.xForm( matrix );
}
dir = info->dirPath( true );
locked = false;
if ( symlink )
name = info->fileName() + " -> " + createNewPath(info->dirPath(),info->readLink());
else
{
name = info->fileName();
if ( ( (selector()->mode() == OFileSelector::Open)&& !info->isReadable() ) ||
( (selector()->mode() == OFileSelector::Save)&& !info->isWritable() ) )
{
- locked = true; pix = Resource::loadPixmap("locked");
+ locked = true;
+ pix = Opie::Core::OResource::loadPixmap( "locked" );
}
}
(void)new OFileSelectorItem( m_view, pix, name,
info->lastModified().toString(), QString::number( info->size() ),
dir, locked );
}
void OFileViewFileListView::addDir( QFileInfo* info, bool symlink )
{
bool locked = false; QString name; QPixmap pix;
if ( ( ( selector()->mode() == OFileSelector::Open ) && !info->isReadable() ) ||
( ( selector()->mode() == OFileSelector::Save ) && !info->isWritable() ) )
{
locked = true;
if ( symlink )
- pix = Resource::loadPixmap( "opie/symlink" );
+ pix = Opie::Core::OResource::loadPixmap( "opie/symlink" );
else
- pix = Resource::loadPixmap( "lockedfolder" );
+ pix = Opie::Core::OResource::loadPixmap( "lockedfolder" );
}
else
- pix = symlink ? Resource::loadPixmap( "opie/symlink") : Resource::loadPixmap("folder");
+ pix = symlink ? Opie::Core::OResource::loadPixmap( "opie/symlink" ) : Opie::Core::OResource::loadPixmap( "folder" );
name = symlink ? info->fileName() + " -> " + createNewPath(info->dirPath(true),info->readLink()) :
info->fileName();
(void)new OFileSelectorItem( m_view, pix, name,
info->lastModified().toString(),
QString::number( info->size() ),
info->dirPath( true ), locked, true );
}
void OFileViewFileListView::addSymlink( QFileInfo* , bool )
{
}
void OFileViewFileListView::cdUP()
{
QDir dir( m_currentDir );
dir.cdUp();
if (!dir.exists() )
m_currentDir = "/";
else
m_currentDir = dir.absPath();
emit selector()->dirSelected( m_currentDir );
reread( m_all );
}
void OFileViewFileListView::cdHome()
{
m_currentDir = QDir::homeDirPath();
emit selector()->dirSelected( m_currentDir );
reread( m_all );
}
void OFileViewFileListView::cdDoc()
{
m_currentDir = QPEApplication::documentDir();
emit selector()->dirSelected( m_currentDir );
reread( m_all );
}
void OFileViewFileListView::changeDir( const QString& dir )
{
m_currentDir = dir;
emit selector()->dirSelected( m_currentDir );
diff --git a/libopie2/opieui/fileselector/ofileselector.h b/libopie2/opieui/fileselector/ofileselector.h
index d166afd..f32e3ed 100644
--- a/libopie2/opieui/fileselector/ofileselector.h
+++ b/libopie2/opieui/fileselector/ofileselector.h
@@ -1,74 +1,76 @@
/*
-               =. This file is part of the OPIE Project
-             .=l. Copyright (C) 2002,2003 Holger Freyther <zecke@handhelds.org>
-           .>+-=
- _;:,     .>    :=|. This library is free software; you can
-.> <`_,   >  .   <= redistribute it and/or modify it under
-:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
-.="- .-=="i,     .._ License as published by the Free Software
- - .   .-<_>     .<> Foundation; either version 2 of the License,
-     ._= =}       : or (at your option) any later version.
-    .%`+i>       _;_.
-    .i_,=:_.      -<s. This library is distributed in the hope that
-     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
-    : ..    .:,     . . . without even the implied warranty of
-    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
-  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
-..}^=.=       =       ; Library General Public License for more
-++=   -.     .`     .: details.
- :     =  ...= . :.=-
- -.   .:....=;==+<; You should have received a copy of the GNU
-  -_. . .   )=.  = Library General Public License along with
-    --        :-=` this library; see the file COPYING.LIB.
+                 This file is part of the Opie Project
+
+ Copyright (C) 2002,2003 Holger Freyther <zecke@handhelds.org>
+ =.
+ .=l.
+           .>+-=
+ _;:,     .>    :=|. This program is free software; you can
+.> <`_,   >  .   <= redistribute it and/or modify it under
+:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
+.="- .-=="i,     .._ License as published by the Free Software
+ - .   .-<_>     .<> Foundation; either version 2 of the License,
+     ._= =}       : or (at your option) any later version.
+    .%`+i>       _;_.
+    .i_,=:_.      -<s. This program is distributed in the hope that
+     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
+ : ..    .:,     . . . without even the implied warranty of
+    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
+  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
+..}^=.=       =       ; Library General Public License for more
+++=   -.     .`     .: details.
+ :     =  ...= . :.=-
+ -.   .:....=;==+<; You should have received a copy of the GNU
+  -_. . .   )=.  = Library General Public License along with
+    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
-
*/
/*
This is based on code and ideas of
L. J. Potter ljp@llornkcor.com
Thanks a lot
*/
#ifndef OFILESELECTOR_H
#define OFILESELECTOR_H
/* OPIE */
#include <qpe/applnk.h>
/* QT */
#include <qlist.h>
#include <qwidget.h>
#include <qmap.h>
#include <qvaluelist.h>
#include <qstringlist.h>
#include <qlist.h>
class QLineEdit;
class QComboBox;
class QWidgetStack;
class QHBox;
typedef QMap<QString, QStringList> MimeTypes;
namespace Opie {
namespace Ui {
namespace Internal {
class OFileViewInterface;
class OFileViewFileListView;
}
/**
* @short a dropin replacement for the FileSelector
*
* This class is first used insert the OFileDialog.
* It supports multiple view and mimetype filtering for now.
*
* @see OFileDialog
* @see FileSelector
* @author zecke
* @version 0.1
diff --git a/libopie2/opieui/otabwidget.cpp b/libopie2/opieui/otabwidget.cpp
index 8d7806c..7333f5e 100644
--- a/libopie2/opieui/otabwidget.cpp
+++ b/libopie2/opieui/otabwidget.cpp
@@ -1,231 +1,231 @@
/*
- This file is part of the Opie Project
+                 This file is part of the Opie Project
- Copyright (c) 2002, 2005 Dan Williams <drw@handhelds.org>
+ Copyright (C) 2002, 2005 Dan Williams <drw@handhelds.org>
=.
.=l.
- .>+-=
-_;:, .> :=|. This program is free software; you can
-.> <`_, > . <= redistribute it and/or modify it under
-:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
-.="- .-=="i, .._ License as published by the Free Software
-- . .-<_> .<> Foundation; either version 2 of the License,
- ._= =} : or (at your option) any later version.
- .%`+i> _;_.
- .i_,=:_. -<s. This program is distributed in the hope that
- + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
- : .. .:, . . . without even the implied warranty of
- =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
- _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
-..}^=.= = ; Library General Public License for more
-++= -. .` .: details.
-: = ...= . :.=-
--. .:....=;==+<; You should have received a copy of the GNU
- -_. . . )=. = Library General Public License along with
- -- :-=` this library; see the file COPYING.LIB.
+           .>+-=
+ _;:,     .>    :=|. This program is free software; you can
+.> <`_,   >  .   <= redistribute it and/or modify it under
+:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
+.="- .-=="i,     .._ License as published by the Free Software
+ - .   .-<_>     .<> Foundation; either version 2 of the License,
+     ._= =}       : or (at your option) any later version.
+    .%`+i>       _;_.
+    .i_,=:_.      -<s. This program is distributed in the hope that
+     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
+ : ..    .:,     . . . without even the implied warranty of
+    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
+  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
+..}^=.=       =       ; Library General Public License for more
+++=   -.     .`     .: details.
+ :     =  ...= . :.=-
+ -.   .:....=;==+<; You should have received a copy of the GNU
+  -_. . .   )=.  = Library General Public License along with
+    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
-
*/
#include <opie2/otabwidget.h>
/* OPIE */
+#include <opie2/oresource.h>
+#include <opie2/otabbar.h>
+
#include <qpe/applnk.h>
#include <qpe/config.h>
-#include <qpe/resource.h>
-#include <opie2/otabbar.h>
/* QT */
#include <qcombobox.h>
#include <qwidgetstack.h>
using namespace Opie::Ui;
OTabWidget::OTabWidget( QWidget *parent, const char *name, TabStyle s, TabPosition p )
: QWidget( parent, name )
, m_currTab( 0l )
, m_tabBarStyle( Global )
, m_tabBarPosition( Top )
, m_usingTabs( true )
, m_tabBar( 0l )
, m_tabList( 0l )
{
if ( s == Global )
{
// Read Opie global settings for style and position
Config config( "qpe" );
config.setGroup( "Appearance" );
// Style
s = ( TabStyle ) config.readNumEntry( "TabStyle", (int) IconTab );
if ( s <= Global || s > IconList)
s = IconTab;
// Position
( config.readEntry( "TabPosition", "Top" ) == "Bottom" ) ? p = Bottom
: p = Top;
}
// Initialize widget stack for tab widgets
m_widgetStack = new QWidgetStack( this );
m_widgetStack->setFrameStyle( QFrame::NoFrame );
m_widgetStack->setLineWidth( style().defaultFrameWidth() );
// Set initial selector control style and position
setTabStyle( s );
setTabPosition( p );
}
OTabWidget::~OTabWidget()
{
m_tabs.setAutoDelete( true );
m_tabs.clear();
}
void OTabWidget::addTab( QWidget *child, const QString &icon, const QString &label )
{
int tabid = -1;
if ( m_usingTabs )
{
// Create new tab in tab bar
QTab *tab = new QTab();
// Set label (and icon if necessary)
if ( m_tabBarStyle == IconTab )
{
tab->label = QString::null;
- tab->iconset = new QIconSet( loadSmooth( icon ) );
+ tab->iconset = new QIconSet( Opie::Core::OResource::loadPixmap( icon, Opie::Core::OResource::SmallIcon ) );
}
else
tab->label = label;
tabid = m_tabBar->addTab( tab );
}
else
{
// Insert entry (with icon if necessary) into drop down list
if ( m_tabBarStyle == IconList )
- m_tabList->insertItem( loadSmooth( icon ), label, -1 );
+ m_tabList->insertItem( Opie::Core::OResource::loadPixmap( icon, Opie::Core::OResource::SmallIcon ), label, -1 );
else
m_tabList->insertItem( label );
}
// Add widget to stack
m_widgetStack->addWidget( child, tabid );
m_widgetStack->raiseWidget( child );
m_widgetStack->setFrameStyle( QFrame::StyledPanel | QFrame::Raised );
// Keep track of tab information
OTabInfo *tabinfo = new OTabInfo( tabid, child, icon, label );
m_tabs.append( tabinfo );
// Make newly added tab the current one displayed
selectTab( tabinfo );
}
void OTabWidget::removePage( QWidget *childwidget )
{
if ( childwidget )
{
// Find tab information for desired widget
OTabInfo *tab = m_tabs.first();
while ( tab && tab->control() != childwidget )
tab = m_tabs.next();
if ( tab && tab->control() == childwidget )
{
if ( m_usingTabs )
{
// Remove tab from tab bar
m_tabBar->setTabEnabled( tab->id(), false );
m_tabBar->removeTab( m_tabBar->tab( tab->id() ) );
}
else
{
// Remove entry from drop down list
int i = 0;
while ( i < m_tabList->count() && m_tabList->text( i ) != tab->label() )
i++;
if ( m_tabList->text( i ) == tab->label() )
m_tabList->removeItem( i );
}
// Remove widget from stack
m_widgetStack->removeWidget( childwidget );
// Get rid of tab information
m_tabs.remove( tab );
delete tab;
// Reset current tab
m_currTab = m_tabs.current();
if ( !m_currTab )
m_widgetStack->setFrameStyle( QFrame::NoFrame );
// Redraw widget
setUpLayout();
}
}
}
void OTabWidget::changeTab( QWidget *widget, const QString &iconset, const QString &label)
{
// Find tab information for desired widget
OTabInfo *currtab = m_tabs.first();
while ( currtab && currtab->control() != widget )
currtab = m_tabs.next();
if ( currtab && currtab->control() == widget )
{
- QPixmap icon( loadSmooth( iconset ) );
+ QPixmap icon( Opie::Core::OResource::loadPixmap( iconset, Opie::Core::OResource::SmallIcon ) );
if ( m_usingTabs )
{
// Update tab label and icon (if necessary)
QTab *tab = m_tabBar->tab( currtab->id() );
tab->setText( label );
if ( m_tabBarStyle == IconTab )
tab->setIconSet( icon );
}
else
{
// Update entry label and icon (if necessary)
int i = 0;
while ( i < m_tabList->count() && m_tabList->text( i ) != currtab->label() )
i++;
if ( i < m_tabList->count() && m_tabList->text( i ) == currtab->label() )
{
if ( m_tabBarStyle == IconList )
m_tabList->changeItem( icon, label, i );
else
m_tabList->changeItem( label, i );
}
}
// Update tab information
currtab->setLabel( label );
currtab->setIcon( iconset );
// Redraw widget
setUpLayout();
}
}
void OTabWidget::setCurrentTab( QWidget *childwidget )
{
OTabInfo *currtab = m_tabs.first();
while ( currtab && currtab->control() != childwidget )
{
currtab = m_tabs.next();
}
if ( currtab && currtab->control() == childwidget )
{
selectTab( currtab );
}
}
void OTabWidget::setCurrentTab( const QString &tabname )
{
@@ -253,170 +253,164 @@ void OTabWidget::setCurrentTab(int tabindex)
}
}
OTabWidget::TabStyle OTabWidget::tabStyle() const
{
return m_tabBarStyle;
}
void OTabWidget::setTabStyle( TabStyle s )
{
// Get out if new and current styles are the same
if ( s == m_tabBarStyle )
return;
// Delete current selector control
if ( m_usingTabs )
{
delete m_tabBar;
m_tabBar = 0l;
}
else
{
delete m_tabList;
m_tabList = 0l;
}
// Set new style information
m_tabBarStyle = s;
m_usingTabs = ( m_tabBarStyle == TextTab || m_tabBarStyle == IconTab );
// Create new selector control and populate with tab information
if ( m_usingTabs )
{
// Create new tab bar selector
m_tabBar = new OTabBar( this );
connect( m_tabBar, SIGNAL(selected(int)), this, SLOT(slotTabBarSelected(int)) );
// Add all current tabs to tab bar
for ( OTabInfo *tabinfo = m_tabs.first(); tabinfo; tabinfo = m_tabs.next() )
{
// Create new tab in tab bar
QTab *tab = new QTab();
// Set label (and icon if necessary)
if ( m_tabBarStyle == IconTab )
{
tab->label = QString::null;
- tab->iconset = new QIconSet( loadSmooth( tabinfo->icon() ) );
+ tab->iconset = new QIconSet( Opie::Core::OResource::loadPixmap( tabinfo->icon(), Opie::Core::OResource::SmallIcon ) );
}
else
tab->label = tabinfo->label();
// Add tab and save its Id
int tabid = m_tabBar->addTab( tab );
tabinfo->setId( tabid );
}
}
else
{
// Create new drop down list selector
m_tabList = new QComboBox( false, this );
connect( m_tabList, SIGNAL(activated(int)), this, SLOT(slotTabListSelected(int)) );
// Add all current tabs to drop down list
for ( OTabInfo *tabinfo = m_tabs.first(); tabinfo; tabinfo = m_tabs.next() )
{
if ( m_tabBarStyle == IconList )
- m_tabList->insertItem( loadSmooth( tabinfo->icon() ), tabinfo->label() );
+ m_tabList->insertItem( Opie::Core::OResource::loadPixmap( tabinfo->icon(), Opie::Core::OResource::SmallIcon ),
+ tabinfo->label() );
else
m_tabList->insertItem( tabinfo->label() );
}
}
// Redraw widget
setUpLayout();
}
OTabWidget::TabPosition OTabWidget::tabPosition() const
{
return m_tabBarPosition;
}
void OTabWidget::setTabPosition( TabPosition p )
{
m_tabBarPosition = p;
// If using the tab bar selector, set its shape
if ( m_usingTabs )
{
( m_tabBarPosition == Top ) ? m_tabBar->setShape( QTabBar::RoundedAbove )
: m_tabBar->setShape( QTabBar::RoundedBelow );
}
// Redraw widget
setUpLayout();
}
void OTabWidget::slotTabBarSelected( int id )
{
OTabInfo *newtab = m_tabs.first();
while ( newtab && newtab->id() != id )
newtab = m_tabs.next();
if ( newtab && newtab->id() == id )
selectTab( newtab );
}
void OTabWidget::slotTabListSelected( int index )
{
OTabInfo *newtab = m_tabs.at( index );
if ( newtab )
selectTab( newtab );
}
-QPixmap OTabWidget::loadSmooth( const QString &name )
-{
- QPixmap p;
- p.convertFromImage( Resource::loadImage( name ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) );
- return p;
-}
-
void OTabWidget::selectTab( OTabInfo *tab )
{
if ( m_tabBarStyle == IconTab )
{
// Remove text label from currently selected tab
if ( m_currTab )
{
m_tabBar->tab( m_currTab->id() )->setText( QString::null );
//setUpLayout();
}
// Set text label for newly selected tab
m_tabBar->tab( tab->id() )->setText( tab->label() );
m_tabBar->setCurrentTab( tab->id() );
setUpLayout();
QSize t;
t = m_tabBar->sizeHint();
if ( t.width() > width() )
t.setWidth( width() );
int lw = m_widgetStack->lineWidth();
if ( m_tabBarPosition == Bottom )
m_tabBar->setGeometry( QMAX(0, lw-2), height() - t.height() - lw, t.width(), t.height() );
else
m_tabBar->setGeometry( QMAX(0, lw-2), 0, t.width(), t.height() );
}
else if ( m_tabBarStyle == TextTab )
{
m_tabBar->setCurrentTab( tab->id() );
}
m_widgetStack->raiseWidget( tab->control() );
emit currentChanged( tab->control() );
m_currTab = tab;
}
void OTabWidget::setUpLayout()
{
if ( m_usingTabs )
{
m_tabBar->update();
m_tabBar->layoutTabs();
}
}
diff --git a/libopie2/opieui/otabwidget.h b/libopie2/opieui/otabwidget.h
index e925592..3af8fac 100644
--- a/libopie2/opieui/otabwidget.h
+++ b/libopie2/opieui/otabwidget.h
@@ -1,76 +1,76 @@
/*
- This file is part of the Opie Project
- Copyright (C) 2002, 2005 Dan Williams <drw@handhelds.org>
+                 This file is part of the Opie Project
+
+ Copyright (C) 2002, 2005 Dan Williams <drw@handhelds.org>
=.
.=l.
- .>+-=
-_;:, .> :=|. This program is free software; you can
-.> <`_, > . <= redistribute it and/or modify it under
-:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
-.="- .-=="i, .._ License as published by the Free Software
-- . .-<_> .<> Foundation; either version 2 of the License,
- ._= =} : or (at your option) any later version.
- .%`+i> _;_.
- .i_,=:_. -<s. This program is distributed in the hope that
- + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
- : .. .:, . . . without even the implied warranty of
- =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
- _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
-..}^=.= = ; Library General Public License for more
-++= -. .` .: details.
-: = ...= . :.=-
--. .:....=;==+<; You should have received a copy of the GNU
- -_. . . )=. = Library General Public License along with
- -- :-=` this library; see the file COPYING.LIB.
+           .>+-=
+ _;:,     .>    :=|. This program is free software; you can
+.> <`_,   >  .   <= redistribute it and/or modify it under
+:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
+.="- .-=="i,     .._ License as published by the Free Software
+ - .   .-<_>     .<> Foundation; either version 2 of the License,
+     ._= =}       : or (at your option) any later version.
+    .%`+i>       _;_.
+    .i_,=:_.      -<s. This program is distributed in the hope that
+     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
+ : ..    .:,     . . . without even the implied warranty of
+    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
+  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
+..}^=.=       =       ; Library General Public License for more
+++=   -.     .`     .: details.
+ :     =  ...= . :.=-
+ -.   .:....=;==+<; You should have received a copy of the GNU
+  -_. . .   )=.  = Library General Public License along with
+    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
-
*/
#ifndef OTABWIDGET_H
#define OTABWIDGET_H
/* OPIE */
#include <opie2/otabinfo.h>
/* QT */
#include <qwidget.h>
#include <qlist.h>
class QComboBox;
class QPixmap;
class QTabBar;
class QWidgetStack;
namespace Opie {
namespace Ui {
class OTabBar;
/**
* @class OTabWidget
* @brief The OTabWidget class provides a stack of widgets.
*
* OTabWidget is a derivation of TrollTech's QTabWidget which provides
* a stack of widgets. Widgets can be selected using either a tab bar or
* drop down list box.
*
* The normal way to use OTabWidget is to do the following in the
* constructor:
* - Create a OTabWidget.
* - Create a QWidget for each of the pages in the control, insert
* children into it, set up geometry management for it, and use addTab()
* to add the widget.
*/
class OTabWidget : public QWidget
{
Q_OBJECT
public:
/**
* @enum TabStyle
* @brief Defines how the widget selection control is displayed.
*
* Valid values:
@@ -186,102 +186,94 @@ class OTabWidget : public QWidget
void setCurrentTab( const QString & );
/**
* @fn setCurrentTab( int )
* @brief Selects and brings to top the desired widget, by using id.
*
* @param tab id for widget to select.
*/
void setCurrentTab(int);
/**
* @fn currentTab( )
* @brief returns current tab id.
*/
// ### make const
int currentTab()/* const */;
/**
* @brief returns the current page of the active tab
*
* @since 1.2
*/
QWidget* currentWidget()const;
protected:
/**
* @fn resizeEvent( QResizeEvent * )
* @brief Reimplemented for internal purposes.
*/
void resizeEvent( QResizeEvent * );
private:
OTabInfoList m_tabs; // List of information for tabs
OTabInfo *m_currTab; // Current tab displayed
TabStyle m_tabBarStyle; // Current style of control
TabPosition m_tabBarPosition; // Position of selector control
bool m_usingTabs; // Indicates whether style is either TextTab or IconTab
// (saves from having to always check for these 2 values)
// UI components
OTabBar *m_tabBar;
QComboBox *m_tabList;
QWidgetStack *m_widgetStack;
class Private;
Private* d;
/**
- * @fn loadSmooth( const QString &name )
- * @brief Loads icon for widget.
- *
- * @param name Name of icon image file.
- */
- QPixmap loadSmooth( const QString & );
-
-/**
* @fn selectTab( OTabInfo *tab )
* @brief Internal function to select desired widget.
*
* @param tab Pointer to data for widget.
*/
void selectTab( OTabInfo * );
/**
* @fn setUpLayout()
* @brief Internal function to adjust layout.
*/
void setUpLayout();
signals:
/**
* @fn currentChanged( QWidget *widget )
* @brief This signal is emitted whenever the widget has changed.
*
* @param widget Pointer to new current widget.
*/
void currentChanged( QWidget * );
private slots:
/**
* @fn slotTabBarSelected( int id )
* @brief Slot which is called when a tab is selected.
*
* @param id ID of widget selected.
*/
void slotTabBarSelected( int );
/**
* @fn slotTabListSelected( int index )
* @brief Slot which is called when a drop down selection is made.
*
* @param id Index of widget selected.
*/
void slotTabListSelected( int );
};
}
}
#endif
diff --git a/libopie2/opieui/owait.cpp b/libopie2/opieui/owait.cpp
index ec1f25a..5f89ad2 100644
--- a/libopie2/opieui/owait.cpp
+++ b/libopie2/opieui/owait.cpp
@@ -1,113 +1,115 @@
/*
-                This file is part of the Opie Project
-              Copyright (C) 2003 Maximilian Reiss <harlekin@handhelds.org>
+                 This file is part of the Opie Project
+
+ Copyright (C) 2003 Maximilian Reiss <harlekin@handhelds.org>
=.
.=l.
-           .>+-=
- _;:,     .>    :=|. This program is free software; you can
-.> <`_,   >  .   <= redistribute it and/or modify it under
-:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
-.="- .-=="i,     .._ License as published by the Free Software
- - .   .-<_>     .<> Foundation; either version 2 of the License,
-     ._= =}       : or (at your option) any later version.
-    .%`+i>       _;_.
-    .i_,=:_.      -<s. This program is distributed in the hope that
-     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
-    : ..    .:,     . . . without even the implied warranty of
-    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
-  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
-..}^=.=       =       ; Library General Public License for more
-++=   -.     .`     .: details.
- :     =  ...= . :.=-
- -.   .:....=;==+<; You should have received a copy of the GNU
-  -_. . .   )=.  = Library General Public License along with
-    --        :-=` this library; see the file COPYING.LIB.
+           .>+-=
+ _;:,     .>    :=|. This program is free software; you can
+.> <`_,   >  .   <= redistribute it and/or modify it under
+:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
+.="- .-=="i,     .._ License as published by the Free Software
+ - .   .-<_>     .<> Foundation; either version 2 of the License,
+     ._= =}       : or (at your option) any later version.
+    .%`+i>       _;_.
+    .i_,=:_.      -<s. This program is distributed in the hope that
+     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
+    : ..    .:,     . . . without even the implied warranty of
+    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
+  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
+..}^=.=       =       ; Library General Public License for more
+++=   -.     .`     .: details.
+ :     =  ...= . :.=-
+ -.   .:....=;==+<; You should have received a copy of the GNU
+  -_. . .   )=.  = Library General Public License along with
+    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
-
*/
#include "owait.h"
/* OPIE */
+#include <opie2/oresource.h>
+
+
#include <qpe/qpeapplication.h>
-#include <qpe/resource.h>
/* QT */
#include <qlayout.h>
#include <qpainter.h>
using namespace Opie::Ui;
static int frame = 0;
/**
* This will construct a modal dialog.
*
* The default timer length is 10.
*
* @param parent The parent of the widget
* @param msg The name of the object
* @param dispIcon Display Icon?
*/
OWait::OWait( QWidget *parent, const char* msg, bool dispIcon )
:QDialog( parent, msg, TRUE, WStyle_Customize )
{
Q_UNUSED( dispIcon )
QHBoxLayout * hbox = new QHBoxLayout( this );
m_lb = new QLabel( this );
m_lb->setBackgroundMode ( NoBackground );
hbox->addWidget( m_lb );
hbox->activate();
- m_pix = Resource::loadPixmap( "BigBusy" );
+ m_pix = Opie::Core::OResource::loadPixmap( "BigBusy" );
m_aniSize = m_pix.height();
resize( m_aniSize, m_aniSize );
m_timerLength = 10;
m_waitTimer = new QTimer( this );
connect( m_waitTimer, SIGNAL( timeout() ), this, SLOT( hide() ) );
}
void OWait::timerEvent( QTimerEvent * )
{
frame = ( ++frame ) % 4;
repaint();
}
void OWait::paintEvent( QPaintEvent * )
{
QPainter p( m_lb );
p.drawPixmap( 0, 0, m_pix, m_aniSize * frame, 0, m_aniSize, m_aniSize );
}
void OWait::show()
{
move( ( ( qApp->desktop() ->width() ) / 2 ) - ( m_aniSize / 2 ), ( ( qApp->desktop() ->height() ) / 2 ) - ( m_aniSize / 2 ) );
startTimer( 300 );
m_waitTimer->start( m_timerLength * 1000, true );
QDialog::show();
}
void OWait::hide()
{
killTimers();
m_waitTimer->stop();
frame = 0;
QDialog::hide();
}
void OWait::setTimerLength( int length )
{
m_timerLength = length;
}
OWait::~OWait()
{}
diff --git a/libopie2/opieui/owait.h b/libopie2/opieui/owait.h
index 03c33e4..0036bb1 100644
--- a/libopie2/opieui/owait.h
+++ b/libopie2/opieui/owait.h
@@ -1,90 +1,89 @@
/*
-                This file is part of the Opie Project
-              Copyright (C) 2003 Maximilian Reiss <harlekin@handhelds.org>
+                 This file is part of the Opie Project
+
+ Copyright (C) 2003 Maximilian Reiss <harlekin@handhelds.org>
=.
.=l.
-           .>+-=
- _;:,     .>    :=|. This program is free software; you can
-.> <`_,   >  .   <= redistribute it and/or modify it under
-:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
-.="- .-=="i,     .._ License as published by the Free Software
- - .   .-<_>     .<> Foundation; either version 2 of the License,
-     ._= =}       : or (at your option) any later version.
-    .%`+i>       _;_.
-    .i_,=:_.      -<s. This program is distributed in the hope that
-     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
-    : ..    .:,     . . . without even the implied warranty of
-    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
-  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
-..}^=.=       =       ; Library General Public License for more
-++=   -.     .`     .: details.
- :     =  ...= . :.=-
- -.   .:....=;==+<; You should have received a copy of the GNU
-  -_. . .   )=.  = Library General Public License along with
-    --        :-=` this library; see the file COPYING.LIB.
+           .>+-=
+ _;:,     .>    :=|. This program is free software; you can
+.> <`_,   >  .   <= redistribute it and/or modify it under
+:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
+.="- .-=="i,     .._ License as published by the Free Software
+ - .   .-<_>     .<> Foundation; either version 2 of the License,
+     ._= =}       : or (at your option) any later version.
+    .%`+i>       _;_.
+    .i_,=:_.      -<s. This program is distributed in the hope that
+     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
+ : ..    .:,     . . . without even the implied warranty of
+    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
+  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
+..}^=.=       =       ; Library General Public License for more
+++=   -.     .`     .: details.
+ :     =  ...= . :.=-
+ -.   .:....=;==+<; You should have received a copy of the GNU
+  -_. . .   )=.  = Library General Public License along with
+    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
-
*/
#ifndef OWAIT_H
#define OWAIT_H
/* QT */
#include <qdialog.h>
#include <qlabel.h>
#include <qpixmap.h>
#include <qtimer.h>
namespace Opie {
namespace Ui {
/**
* This class displays a animated waiting icon in the middle of the screen.
*
* @short modal hour glass dialog
* @see QDialog
- * @author Maximilian Reiß
- */
+ * @author Maximilian Rei� */
class OWait : public QDialog
{
Q_OBJECT
public:
OWait( QWidget *parent = 0, const char* name = 0, bool dispIcon = TRUE );
~OWait();
/**
* reimplemented for control reasons
*/
void show();
/**
* Set the time before the icon will be automaticly hidden
* The timer will be started once the widget will be shown.
* @param length - time in seconds
*/
void setTimerLength( int length );
public slots:
/**
* reimplemented for control reasons
*/
void hide();
private:
void timerEvent( QTimerEvent * );
void paintEvent( QPaintEvent * );
QPixmap m_pix;
QLabel *m_lb;
QTimer *m_waitTimer;
int m_timerLength;
int m_aniSize;
class Private;
Private *d;
};
}
}
#endif