author | drw <drw> | 2005-04-06 22:25:21 (UTC) |
---|---|---|
committer | drw <drw> | 2005-04-06 22:25:21 (UTC) |
commit | cd1b15147d372d8786c855764d397553651c358d (patch) (side-by-side diff) | |
tree | 643479f1a84698f79227d7c8243921eacc3fe818 | |
parent | 678c792dd69e42a15d8ac5eaaa9228dfd413ed4c (diff) | |
download | opie-cd1b15147d372d8786c855764d397553651c358d.zip opie-cd1b15147d372d8786c855764d397553651c358d.tar.gz opie-cd1b15147d372d8786c855764d397553651c358d.tar.bz2 |
Use OResource for loading images and fix headers
-rw-r--r-- | core/pim/today/main.cpp | 43 | ||||
-rw-r--r-- | core/pim/today/today.cpp | 44 | ||||
-rw-r--r-- | core/pim/today/today.h | 41 | ||||
-rw-r--r-- | core/pim/today/todaybase.cpp | 52 | ||||
-rw-r--r-- | core/pim/today/todaybase.h | 40 | ||||
-rw-r--r-- | core/pim/today/todayconfig.cpp | 47 | ||||
-rw-r--r-- | core/pim/today/todayconfig.h | 40 |
7 files changed, 202 insertions, 105 deletions
diff --git a/core/pim/today/main.cpp b/core/pim/today/main.cpp index d63bc30..44b845c 100644 --- a/core/pim/today/main.cpp +++ b/core/pim/today/main.cpp @@ -1,25 +1,36 @@ /* - * main.cpp - * - * --------------------- - * - * begin : Sun 10 17:20:00 CEST 2002 - * copyright : (c) 2002, 2003, 2004 by Maximilian Reiß - * email : max.reiss@gmx.de - * +         This file is part of the Opie Project + + Copyright (C) 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. + If not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ -/*************************************************************************** - * * - * 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. * - * * - ***************************************************************************/ #include "today.h" #include <opie2/oapplicationfactory.h> using namespace Opie::Core; OPIE_EXPORT_APP( OApplicationFactory<Today> ) diff --git a/core/pim/today/today.cpp b/core/pim/today/today.cpp index 3e895a4..67b23e1 100644 --- a/core/pim/today/today.cpp +++ b/core/pim/today/today.cpp @@ -1,316 +1,330 @@ /* - * today.cpp - * - * copyright : (c) 2002,2003,2004 by Maximilian Reiß - * email : harlekin@handhelds.org - * +         This file is part of the Opie Project + + Copyright (C) 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. + If not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ -/*************************************************************************** - * * - * 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. * - * * - ***************************************************************************/ #include "today.h" #include <opie2/odebug.h> #include <opie2/opluginloader.h> #include <opie2/oconfig.h> +#include <opie2/oresource.h> #include <qpe/qcopenvelope_qws.h> -#include <qpe/resource.h> #include <qpe/qpeapplication.h> #include <qpe/contact.h> #include <qdir.h> #include <qtimer.h> #include <qwhatsthis.h> #include <qmessagebox.h> using namespace Opie::Ui; using Opie::Core::OPluginItem; using Opie::Core::OPluginLoader; using Opie::Core::OPluginManager; using Opie::Core::OConfig; struct TodayPlugin { TodayPlugin() : iface( 0 ), guiPart( 0 ), guiBox( 0 ) {} QInterfacePtr<TodayPluginInterface> iface; TodayPluginObject *guiPart; OPluginItem oplugin; QWidget *guiBox; QString name; bool excludeRefresh; }; static QMap<QString, TodayPlugin> pluginList; Today::Today( QWidget* parent, const char* name, WFlags fl ) : TodayBase( parent, name, fl | WStyle_ContextHelp) { setCaption( tr("Today") ); connect( (QObject*)ConfigButton, SIGNAL( clicked() ), this, SLOT( startConfig() ) ); connect( (QObject*)OwnerField, SIGNAL( clicked() ), this, SLOT( editCard() ) ); #if !defined(QT_NO_COP) QCopChannel *todayChannel = new QCopChannel( "QPE/Today" , this ); connect ( todayChannel, SIGNAL( received(const QCString&,const QByteArray&) ), this, SLOT ( channelReceived(const QCString&,const QByteArray&) ) ); #endif setOwnerField(); m_big_box = 0l; m_bblayout = 0l; layout = new QVBoxLayout( this ); layout->addWidget( Frame ); layout->addWidget( OwnerField ); m_informationLabel = new QLabel( tr("No plugins activated"), this ); layout->addWidget( m_informationLabel ); m_sv = new QScrollView( this ); m_sv->setResizePolicy( QScrollView::AutoOneFit ); m_sv->setHScrollBarMode( QScrollView::AlwaysOff ); m_sv->setFrameShape( QFrame::NoFrame ); layout->addWidget( m_sv ); layout->setStretchFactor( m_sv,4 ); m_refreshTimer = new QTimer( this ); connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); loadPlugins(); loadShellContent(); loadPluginWidgets(); } /** * Qcop receive method. */ void Today::channelReceived( const QCString &msg, const QByteArray & data ) { QDataStream stream( data, IO_ReadOnly ); if ( msg == "message(QString)" ) { QString message; stream >> message; setOwnerField( message ); } } void Today::setRefreshTimer( int interval ) { disconnect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); // 0 is "never" case if ( !interval == 0 ) { connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); m_refreshTimer->changeInterval( interval ); } } /** * Initialises the owner field with the default value, the username */ void Today::setOwnerField() { QString file = Global::applicationFileName( "addressbook", "businesscard.vcf" ); if ( QFile::exists( file ) ) { Contact cont = Contact::readVCard( file )[0]; QString returnString = cont.fullName(); OwnerField->setText( "<b>" + tr ( "Owned by " ) + returnString + "</b>" ); } else { OwnerField->setText( "<b>" + tr ( "Please fill out the business card" ) + " </b>" ); } } /** * Set the owner field with a given QString, for example per qcop. */ void Today::setOwnerField( QString &message ) { if ( !message.isEmpty() ) { OwnerField->setText( "<b>" + message + "</b>" ); } } /** * Load the plugins */ void Today::loadPlugins() { m_pluginLoader = new OPluginLoader( "today", true ); m_pluginLoader->setAutoDelete( true ); m_manager = new OPluginManager( m_pluginLoader ); m_manager->load(); } void Today::loadShellContent() { Config cfg( "today" ); cfg.setGroup( "Plugins" ); cfg.setGroup( "General" ); m_iconSize = cfg.readNumEntry( "IconSize", 18 ); m_hideBanner = cfg.readNumEntry( "HideBanner", 0 ); setRefreshTimer( cfg.readNumEntry( "checkinterval", 15000 ) ); // set the date in top label QDate date = QDate::currentDate(); DateLabel->setText( QString( "<font color=#FFFFFF>" + TimeString::longDateString( date ) + "</font>" ) ); if ( m_hideBanner ) { Opiezilla->hide(); TodayLabel->hide(); } else { Opiezilla->show(); TodayLabel->show(); } } void Today::loadPluginWidgets() { /* * check if loading of Plugins crashed */ if( m_pluginLoader->isInSafeMode() ) { QMessageBox::information(this, tr("Today Error"), tr("<qt>The plugin '%1' caused Today to crash." " It could be that the plugin is not properly" " installed.<br>Today tries to continue loading" " plugins.</qt>") .arg( m_manager->crashedPlugin().name())); } OPluginItem::List lst = m_pluginLoader->filtered( true ); /* * Show or Hide the information of no plugin installed */ if ( lst.isEmpty() ) m_informationLabel->show(); else m_informationLabel->hide(); /* * Now let us add the plugins */ m_big_box = new QWidget( m_sv->viewport() ); m_sv->addChild( m_big_box ); m_bblayout = new QVBoxLayout( m_big_box ); for ( OPluginItem::List::Iterator it = lst.begin(); it != lst.end(); ++it ) { TodayPluginInterface* iface = m_pluginLoader->load<TodayPluginInterface>( *it, IID_TodayPluginInterface ); TodayPlugin plugin; plugin.iface = iface; plugin.name = (*it).name(); plugin.oplugin = (*it); plugin.guiPart = plugin.iface->guiPart(); plugin.excludeRefresh = plugin.guiPart->excludeFromRefresh(); // package the whole thing into a qwidget so it can be shown and hidden plugin.guiBox = new QWidget( m_big_box ); QHBoxLayout *boxLayout = new QHBoxLayout( plugin.guiBox ); QPixmap plugPix; - plugPix.convertFromImage( Resource::loadImage( plugin.guiPart->pixmapNameWidget() ).smoothScale( m_iconSize, m_iconSize ), 0 ); + plugPix.convertFromImage( Opie::Core::OResource::loadImage( plugin.guiPart->pixmapNameWidget() ).smoothScale( m_iconSize, m_iconSize ), 0 ); OClickableLabel* plugIcon = new OClickableLabel( plugin.guiBox ); plugIcon->setPixmap( plugPix ); QWhatsThis::add ( plugIcon, tr("Click here to launch the associated app") ); plugIcon->setName( plugin.guiPart->appName() ); connect( plugIcon, SIGNAL( clicked() ), this, SLOT( startApplication() ) ); QWidget *plugWidget = plugin.guiPart->widget( plugin.guiBox ); boxLayout->addWidget( plugIcon, 0, AlignTop ); boxLayout->addWidget( plugWidget, 0, AlignTop ); boxLayout->setStretchFactor( plugIcon, 1 ); boxLayout->setStretchFactor( plugWidget, 9 ); pluginList.insert( plugin.name, plugin ); m_bblayout->addWidget(plugin.guiBox); } m_bblayout->addStretch( 1 ); m_big_box->show(); } /** * The method for the configuration dialog. */ void Today::startConfig() { // disconnect timer to prevent problems while being on config dialog disconnect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); m_refreshTimer->stop( ); TodayConfig conf( this, "dialog", true ); conf.setUpPlugins( m_manager, m_pluginLoader ); if ( QPEApplication::execDialog(&conf) == QDialog::Accepted ) { conf.writeConfig(); clearPluginWidgets(); loadShellContent(); loadPluginWidgets(); } else { // since reinitialize is not called in that case , reconnect the signal m_refreshTimer->start( 15000 ); // get the config value in here later connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); } } /** * Refresh for the view. Reload all applets * */ void Today::refresh() { for ( QMap<QString, TodayPlugin>::Iterator it = pluginList.begin(); it != pluginList.end(); ++it ) it.data().guiPart->refresh(); DateLabel->setText( QString( "<font color=#FFFFFF>" + TimeString::longDateString( QDate::currentDate() ) + "</font>" ) ); updateGeometry(); repaint(); } void Today::startApplication() { QCopEnvelope e( "QPE/System", "execute(QString)" ); e << QString( sender()->name() ); } /** * launch addressbook (personal card) */ void Today::editCard() { QCopEnvelope env( "QPE/Application/addressbook", "editPersonalAndClose()" ); } Today::~Today() { clearPluginWidgets(); delete m_pluginLoader; delete m_manager; } void Today::clearPluginWidgets() { for(QMap<QString, TodayPlugin>::Iterator it = pluginList.begin(); it != pluginList.end(); ++it ) { delete it.data().guiBox; it.data().guiBox = 0; } pluginList.clear(); delete m_bblayout; delete m_big_box; m_bblayout = 0; m_big_box = 0; } diff --git a/core/pim/today/today.h b/core/pim/today/today.h index 8dbe9aa..dd828ac 100644 --- a/core/pim/today/today.h +++ b/core/pim/today/today.h @@ -1,94 +1,109 @@ /* - * today.h - * - * copyright : (c) 2002,2003,2004 by Maximilian Reiß - * email : harlekin@handhelds.org - * +         This file is part of the Opie Project + + Copyright (C) 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. + If not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ -/*************************************************************************** - * * - * 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 TODAY_H #define TODAY_H #include "todayconfig.h" #include "todaybase.h" #include <opie2/todayplugininterface.h> #include <opie2/oclickablelabel.h> #include <opie2/opluginloader.h> #include <qpe/qlibrary.h> #include <qscrollview.h> #include <qvbox.h> class QVBoxLayout; namespace Opie { namespace Core { class OPluginManager; class OPluginLoader; } } class Today : public TodayBase { Q_OBJECT public: Today( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); ~Today(); static QString appName() { return QString::fromLatin1("today"); } private slots: void startConfig(); void startApplication(); void editCard(); void refresh(); private: void setOwnerField(); void setOwnerField(QString &string); void setRefreshTimer( int ); void clearPluginWidgets(); void loadPluginWidgets(); void loadShellContent(); private slots: void channelReceived(const QCString &msg, const QByteArray & data); void loadPlugins(); private: TodayConfig *conf; QStringList m_excludeApplets; QStringList m_allApplets; QScrollView *m_sv; QWidget* m_big_box; QVBoxLayout *m_bblayout; QLabel *m_informationLabel; Opie::Core::OPluginLoader *m_pluginLoader; Opie::Core::OPluginManager *m_manager; QTimer *m_refreshTimer; bool m_refreshTimerEnabled; int m_newStart; int m_iconSize; int m_maxCharClip; int m_hideBanner; }; #endif diff --git a/core/pim/today/todaybase.cpp b/core/pim/today/todaybase.cpp index a89f454..931f45a 100644 --- a/core/pim/today/todaybase.cpp +++ b/core/pim/today/todaybase.cpp @@ -1,110 +1,124 @@ /* - * todaybase.cpp - * - * copyright : (c) 2002, 2003, 2004 by Maximilian Reiß - * email : harlekin@handhelds.org - * +         This file is part of the Opie Project + + Copyright (C) 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. + If not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ -/*************************************************************************** - * * - * 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. * - * * - ***************************************************************************/ #include "todaybase.h" +#include <opie2/oresource.h> + #include <qpe/applnk.h> -#include <qpe/resource.h> #include <qvbox.h> #include <qwhatsthis.h> using namespace Opie::Ui; TodayBase::TodayBase( QWidget* parent, const char* name, WFlags ) : QWidget( parent, name, WStyle_ContextHelp ) { - QPixmap logo = Resource::loadPixmap( "today/today_logo"); // logo - QImage opiezillaimage = QImage( Resource::loadImage("logo/opielogo" ) ); + QPixmap logo = Opie::Core::OResource::loadPixmap( "today/today_logo" ); // logo + QImage opiezillaimage = QImage( Opie::Core::OResource::loadImage( "logo/opielogo" ) ); opiezillaimage = opiezillaimage.smoothScale( 45, 45 ); QPixmap opiezilla; //the opiezilla opiezilla.convertFromImage( opiezillaimage ); - QPixmap config; - config.convertFromImage( Resource::loadImage( "SettingsIcon" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); + QPixmap config = Opie::Core::OResource::loadPixmap( "SettingsIcon", Opie::Core::OResource::SmallIcon ); layout = 0L; QPalette pal = this->palette(); QColor col = pal.color( QPalette::Active, QColorGroup::Background ); pal.setColor( QPalette::Active, QColorGroup::Button, col ); pal.setColor( QPalette::Inactive, QColorGroup::Button, col ); pal.setColor( QPalette::Normal, QColorGroup::Button, col ); pal.setColor( QPalette::Disabled, QColorGroup::Button, col ); this->setPalette( pal ); // --- logo Section --- QPalette pal2; QColorGroup cg; cg.setColor( QColorGroup::Text, white ); cg.setBrush( QColorGroup::Background, QBrush( QColor( 238, 238, 230 ), logo ) ); pal2.setActive( cg ); // today logo Frame = new QLabel( this, "Frame" ); Frame->setPalette( pal2 ); Frame->setFrameShape( QFrame::StyledPanel ); Frame->setFrameShadow( QFrame::Raised ); Frame->setLineWidth( 0 ); QHBoxLayout *frameLayout = new QHBoxLayout( Frame ); QVBox *box1 = new QVBox( Frame ); // Today text TodayLabel = new QLabel( box1, "TodayText" ); QFont TodayLabel_font( TodayLabel->font() ); TodayLabel_font.setBold( TRUE ); TodayLabel_font.setPointSize( 40 ); TodayLabel->setFont( TodayLabel_font ); TodayLabel->setBackgroundOrigin( QLabel::ParentOrigin ); TodayLabel->setText( "<font color=#FFFFFF>" + tr("Today") +"</font>" ); // date DateLabel = new QLabel( box1, "TextLabel1" ); QFont DateLabel_font( DateLabel->font() ); DateLabel_font.setBold( TRUE ); DateLabel->setFont( DateLabel_font ); DateLabel->setBackgroundOrigin( QLabel::ParentOrigin ); DateLabel->setTextFormat( RichText ); // Opiezilla Opiezilla = new QLabel( Frame, "OpieZilla" ); Opiezilla->setPixmap( opiezilla ); - QWhatsThis::add( Opiezilla , tr( "Today by Maximilian Reiß" ) ); + QWhatsThis::add( Opiezilla , tr( "Today by Maximilian Rei�" ) ); Opiezilla->setBackgroundOrigin( QLabel::ParentOrigin ); // Ownerfield OwnerField = new OClickableLabel( this , "Owner" ); OwnerField->setAlignment( int (QLabel::AlignTop | QLabel::AlignLeft ) ); // config ConfigButton = new OClickableLabel ( Frame, "PushButton1" ); ConfigButton->setPixmap( config ); QWhatsThis::add( ConfigButton, tr( "Click here to get to the config dialog" ) ); ConfigButton->setBackgroundOrigin( QLabel::ParentOrigin ); frameLayout->addWidget( box1, 1 ); frameLayout->addStretch( 1 ); frameLayout->addWidget( ConfigButton, 0, AlignBottom ); frameLayout->addWidget( Opiezilla ); } /** * D' tor */ TodayBase::~TodayBase() { } diff --git a/core/pim/today/todaybase.h b/core/pim/today/todaybase.h index 6ee9bb2..5b34234 100644 --- a/core/pim/today/todaybase.h +++ b/core/pim/today/todaybase.h @@ -1,55 +1,69 @@ /* - * todaybase.h - * - * copyright : (c) 2002, 2003, 2004 by Maximilian Reiß - * email : harlekin@handhelds.org - * +         This file is part of the Opie Project + + Copyright (C) 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. + If not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ -/*************************************************************************** - * * - * 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 TODAYBASE_H #define TODAYBASE_H #include <opie2/oclickablelabel.h> #include <qlayout.h> class QVBox; class QGridLayout; class QFrame; class QLabel; class QPushButton; class QBoxLayout; class TodayBase : public QWidget { Q_OBJECT public: TodayBase( QWidget* parent = 0, const char* name = 0, WFlags = 0 ); ~TodayBase(); QFrame* Frame4; QPushButton* DatesButton; QVBoxLayout* layout; Opie::Ui::OClickableLabel* OwnerField; QLabel* Frame; QLabel* DateLabel; QFrame* Frame15; QLabel* Opiezilla; QLabel* TodayLabel; Opie::Ui::OClickableLabel* ConfigButton; }; #endif diff --git a/core/pim/today/todayconfig.cpp b/core/pim/today/todayconfig.cpp index 864c708..04a16e1 100644 --- a/core/pim/today/todayconfig.cpp +++ b/core/pim/today/todayconfig.cpp @@ -1,255 +1,270 @@ /* - * todayconfig.cpp - * - * copyright : (c) 2002, 2003, 2004 by Maximilian Reiß - * email : harlekin@handhelds.org - * +         This file is part of the Opie Project + + Copyright (C) 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. + If not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ -/*************************************************************************** - * * - * 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. * - * * - ***************************************************************************/ #include "todayconfig.h" #include <opie2/oconfig.h> #include <opie2/opluginloader.h> +#include <opie2/oresource.h> #include <opie2/todayplugininterface.h> -#include <qpe/resource.h> #include <qpe/qcopenvelope_qws.h> #include <qpe/qpeapplication.h> #include <qcheckbox.h> #include <qlabel.h> #include <qspinbox.h> #include <qlayout.h> #include <qheader.h> #include <qvbox.h> #include <qtoolbutton.h> #include <qwhatsthis.h> using namespace Opie::Ui; using Opie::Core::OConfig; using Opie::Core::OPluginManager; using Opie::Core::OPluginLoader; using Opie::Core::OPluginItem; class ToolButton : public QToolButton { public: ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) : QToolButton( parent, name ) { - setPixmap( Resource::loadPixmap( icon ) ); + setUsesBigPixmap( true ); + setPixmap( Opie::Core::OResource::loadPixmap( icon, Opie::Core::OResource::SmallIcon ) ); setAutoRaise( TRUE ); setFocusPolicy( QWidget::NoFocus ); setToggleButton( t ); connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); } }; /** * The class has currently quite some duplicate code. * By that way it would be real easy to have it as seperate app in settings tab * */ TodayConfig::TodayConfig( QWidget* parent, const char* name, bool modal ) : QDialog( parent, name, modal, WStyle_ContextHelp ) { setCaption( tr( "Today Config" ) ); QVBoxLayout *layout = new QVBoxLayout( this ); TabWidget3 = new OTabWidget ( this, "tabwidget", OTabWidget::Global, OTabWidget::Bottom ); layout->addWidget( TabWidget3 ); tab_2 = new QWidget( TabWidget3, "tab_2" ); QVBoxLayout *tab2Layout = new QVBoxLayout( tab_2, 4 ,4 ); QLabel *l = new QLabel( tr( "Load which plugins in what order:" ), tab_2 ); tab2Layout->addWidget( l ); QHBox *hbox1 = new QHBox( tab_2 ); m_appletListView = new QListView( hbox1 ); m_appletListView->addColumn( "PluginList" ); m_appletListView->header()->hide(); m_appletListView->setSorting( -1 ); QWhatsThis::add ( m_appletListView, tr( "Check a checkbox to activate/deactivate a plugin or use the arrow buttons on the right to change the appearance order" ) ); QVBox *vbox1 = new QVBox( hbox1 ); new ToolButton( vbox1, tr( "Move Up" ), "up", this , SLOT( moveSelectedUp() ) ); new ToolButton( vbox1, tr( "Move Down" ), "down", this , SLOT( moveSelectedDown() ) ); tab2Layout->addWidget( hbox1 ); TabWidget3->addTab( tab_2, "pass", tr( "active/order" ) ); // Misc tab tab_3 = new QWidget( TabWidget3, "tab_3" ); QVBoxLayout *tab3Layout = new QVBoxLayout( tab_3 ); m_guiMisc = new TodayConfigMiscBase( tab_3 ); tab3Layout->addWidget( m_guiMisc ); TabWidget3->addTab( tab_3, "SettingsIcon", tr( "Misc" ) ); previousItem = 0l; readConfig(); } void TodayConfig::setUpPlugins( OPluginManager * plugManager, OPluginLoader *plugLoader ) { m_configMap.clear(); m_pluginManager = plugManager; m_pluginLoader = plugLoader; OPluginItem::List inLst = m_pluginLoader->allAvailable( true ); OPluginItem::List lst; for ( OPluginItem::List::Iterator it = inLst.begin(); it != inLst.end(); ++it ) { lst.prepend((*it)); TodayPluginInterface* iface = m_pluginLoader->load<TodayPluginInterface>( *it, IID_TodayPluginInterface ); TodayConfigWidget *widget = iface->guiPart()->configWidget( TabWidget3 ); if (!widget ) continue; m_configMap.insert( iface, widget ); TabWidget3->addTab( widget, iface->guiPart()->pixmapNameConfig() , iface->guiPart()->appName() ); } for ( OPluginItem::List::Iterator it = lst.begin(); it != lst.end(); ++it ) pluginManagement( (*it) ); TabWidget3->setCurrentTab( tab_2 ); } /** * Autostart, uses the new (opie only) autostart method in the launcher code. * If registered against that today ist started on each resume. */ void TodayConfig::setAutoStart() { OConfig cfg( "today" ); cfg.setGroup( "Autostart" ); if ( m_autoStart ) { QCopEnvelope e( "QPE/System", "autoStart(QString,QString,QString)" ); e << QString( "add" ); e << QString( "today" ); e << QString( "%1" ).arg( m_autoStartTimer ); } else { QCopEnvelope e( "QPE/System", "autoStart(QString,QString)" ); e << QString( "remove" ); e << QString( "today" ); } } /** * Read the config part */ void TodayConfig::readConfig() { OConfig cfg( "today" ); cfg.setGroup( "Autostart" ); m_autoStart = cfg.readNumEntry( "autostart", 1 ); m_guiMisc->CheckBoxAuto->setChecked( m_autoStart ); m_autoStartTimer = cfg.readNumEntry( "autostartdelay", 0 ); m_guiMisc->SpinBoxTime->setValue( m_autoStartTimer ); cfg.setGroup( "General" ); m_iconSize = cfg.readNumEntry( "IconSize", 18 ); m_guiMisc->SpinBoxIconSize->setValue( m_iconSize ); m_guiMisc->SpinRefresh->setValue( cfg.readNumEntry( "checkinterval", 15000 ) / 1000 ); m_guiMisc->CheckBoxHide->setChecked( cfg.readNumEntry( "HideBanner", 0 ) ); } /** * Write the config part */ void TodayConfig::writeConfig() { OConfig cfg( "today" ); int position = m_appletListView->childCount(); QListViewItemIterator list_it( m_appletListView ); OPluginItem::List lst = m_pluginLoader->allAvailable( true ); // this makes sure the names get saved in the order selected for ( ; list_it.current(); ++list_it ) { for ( OPluginItem::List::Iterator it = lst.begin(); it != lst.end(); ++it ) { if ( QString::compare( (*it).name() , list_it.current()->text(0) ) == 0 ) { qWarning( "Enabling %d and make it %d", position-1, ((QCheckListItem*)list_it.current())->isOn() ); (*it).setPosition(position--); m_pluginManager->setEnabled( (*it),((QCheckListItem*)list_it.current())->isOn() ); } } } /* * save and get the changes back */ m_pluginManager->save(); cfg.setGroup( "Autostart" ); m_autoStart = m_guiMisc->CheckBoxAuto->isChecked(); cfg.writeEntry( "autostart", m_autoStart ); m_autoStartTimer = m_guiMisc->SpinBoxTime->value(); cfg.writeEntry( "autostartdelay", m_autoStartTimer ); m_iconSize = m_guiMisc->SpinBoxIconSize->value(); cfg.setGroup( "General" ); cfg.writeEntry( "IconSize", m_iconSize ); cfg.writeEntry( "HideBanner", m_guiMisc->CheckBoxHide->isChecked() ); cfg.writeEntry( "checkinterval", m_guiMisc->SpinRefresh->value()*1000 ); // set autostart settings setAutoStart(); OPluginItem::List managedLst = m_pluginManager->managedPlugins(); for ( OPluginItem::List::Iterator it = managedLst.begin(); it != managedLst.end(); ++it ) { TodayPluginInterface* iface = m_pluginLoader->load<TodayPluginInterface>( *it, IID_TodayPluginInterface ); if ( m_configMap.contains( iface ) ) m_configMap[iface]->writeConfig(); } } void TodayConfig::moveSelectedUp() { QListViewItem *item = m_appletListView->selectedItem(); if ( item && item->itemAbove() ) { item->itemAbove()->moveItem( item ); } } void TodayConfig::moveSelectedDown() { QListViewItem *item = m_appletListView->selectedItem(); if ( item && item->itemBelow() ) { item->moveItem( item->itemBelow() ); } } /** * Set up the icons in the order/active tab */ void TodayConfig::pluginManagement( OPluginItem plugItem ) { QCheckListItem *item = new QCheckListItem( m_appletListView, plugItem.name(), QCheckListItem::CheckBox ); TodayPluginInterface* iface = m_pluginLoader->load<TodayPluginInterface>( plugItem, IID_TodayPluginInterface ); - QPixmap icon = Resource::loadPixmap( iface->guiPart()->pixmapNameWidget() ); + QPixmap icon = Opie::Core::OResource::loadPixmap( iface->guiPart()->pixmapNameWidget(), Opie::Core::OResource::SmallIcon ); if ( !icon.isNull() ) { item->setPixmap( 0, icon ); } item->setOn( plugItem.isEnabled() ); previousItem = item; } TodayConfig::~TodayConfig() {} diff --git a/core/pim/today/todayconfig.h b/core/pim/today/todayconfig.h index 81120d3..d467996 100644 --- a/core/pim/today/todayconfig.h +++ b/core/pim/today/todayconfig.h @@ -1,89 +1,103 @@ /* - * todayconfig.h - * - * copyright : (c) 2002,2003, 2004 by Maximilian Reiß - * email : harlekin@handhelds.org - * +         This file is part of the Opie Project + + Copyright (C) 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. + If not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ -/*************************************************************************** - * * - * 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 TODAYCONFIG_H #define TODAYCONFIG_H #include "todayconfigmiscbase.h" #include <opie2/otabwidget.h> #include <opie2/opluginloader.h> #include <qvariant.h> #include <qdialog.h> #include <qlistview.h> class QCheckBox; class QLabel; class QSpinBox; class QTabWidget; class TodayConfigWidget; class TodayPluginInterface; namespace Opie { namespace Core { class OPluginManager; class OPluginLoader; class OPluginItem; } } class TodayConfig : public QDialog { Q_OBJECT public: TodayConfig( QWidget* parent = 0, const char* name = 0, bool modal = FALSE ); ~TodayConfig(); Opie::Ui::OTabWidget* TabWidget3; void writeConfig(); void setUpPlugins( Opie::Core::OPluginManager * plugManager, Opie::Core::OPluginLoader * plugLoader ); protected slots: void moveSelectedUp(); void moveSelectedDown(); private: void setAutoStart(); void readConfig(); void pluginManagement( Opie::Core::OPluginItem plugItem); QListView* m_appletListView; QMap<QString,QCheckListItem*> m_applets; QMap<TodayPluginInterface*,TodayConfigWidget*> m_configMap; int m_autoStart; int m_autoStartTimer; int m_iconSize; QStringList m_excludeApplets; bool m_applets_changed; QWidget* tab_2; QWidget* tab_3; QLabel* TextLabel1, *TextLabel4; QSpinBox* SpinBox7; Opie::Core::OPluginManager *m_pluginManager; Opie::Core::OPluginLoader *m_pluginLoader; QCheckListItem *previousItem; TodayConfigMiscBase *m_guiMisc; }; #endif |