-rw-r--r-- | core/pim/today/plugins/datebook/datebookevent.cpp | 4 | ||||
-rw-r--r-- | core/pim/today/plugins/datebook/datebookpluginwidget.cpp | 6 | ||||
-rw-r--r-- | core/pim/today/today.cpp | 58 | ||||
-rw-r--r-- | core/pim/today/today.h | 9 | ||||
-rw-r--r-- | core/pim/today/todaybase.cpp | 16 | ||||
-rw-r--r-- | core/pim/today/todayconfig.cpp | 4 |
6 files changed, 40 insertions, 57 deletions
diff --git a/core/pim/today/plugins/datebook/datebookevent.cpp b/core/pim/today/plugins/datebook/datebookevent.cpp index 1caf061..d4e8e1e 100644 --- a/core/pim/today/plugins/datebook/datebookevent.cpp +++ b/core/pim/today/plugins/datebook/datebookevent.cpp @@ -17,32 +17,34 @@ #include "datebookevent.h" #include <qpe/config.h> #include <qpe/timestring.h> #include <qpe/qcopenvelope_qws.h> #include <qpe/qpeapplication.h> DateBookEvent::DateBookEvent(const EffectiveEvent &ev, QWidget* parent, int show_location, int show_notes, // int onlyLater, int maxCharClip, const char* name, WFlags fl) : OClickableLabel(parent,name,fl), event(ev) { + setAlignment( AlignTop ); + QString msg; Config config( "qpe" ); config.setGroup( "Time" ); // if 24 h format ampm = config.readBoolEntry( "AMPM", TRUE ); msg += "<B>" + (ev).description() + "</B>"; if ( (ev).event().hasAlarm() ) { msg += " <b>[with alarm]</b>"; } // include location or not if ( show_location == 1) { msg += "<BR><i>" + (ev).location() + "</i>"; } @@ -77,34 +79,32 @@ QString DateBookEvent::ampmTime( QTime tm ) { hour = 12; } if ( hour > 12 ) { hour -= 12; } s.sprintf( "%2d:%02d %s", hour, tm.minute(), (tm.hour() >= 12) ? "PM" : "AM" ); return s; } else { s.sprintf( "%2d:%02d", tm.hour(), tm.minute() ); return s; } } -//extern QPEApplication *todayApp; - /* * starts the edit dialog as known from datebook */ void DateBookEvent::editEventSlot( const Event &e ) { startDatebook(); while( !QCopChannel::isRegistered( "QPE/Datebook" ) ) qApp->processEvents(); QCopEnvelope env( "QPE/Datebook", "editEvent(int)" ); env << e.uid(); } /** * launches datebook */ void DateBookEvent::startDatebook() { diff --git a/core/pim/today/plugins/datebook/datebookpluginwidget.cpp b/core/pim/today/plugins/datebook/datebookpluginwidget.cpp index e4667ae..7948656 100644 --- a/core/pim/today/plugins/datebook/datebookpluginwidget.cpp +++ b/core/pim/today/plugins/datebook/datebookpluginwidget.cpp @@ -46,32 +46,34 @@ void DatebookPluginWidget::readConfig() { m_max_lines_meet = cfg.readNumEntry( "maxlinesmeet", 5 ); m_show_location = cfg.readNumEntry( "showlocation", 1 ); m_show_notes = cfg.readNumEntry( "shownotes", 0 ); m_onlyLater = cfg.readNumEntry( "onlylater", 1 ); } /** * Get all events that are in the datebook xml file for today */ void DatebookPluginWidget::getDates() { QDate date = QDate::currentDate(); QVBoxLayout* layoutDates = new QVBoxLayout( this ); + layoutDates->setSpacing( 1 ); + layoutDates->setMargin( 1 ); if ( db ) { delete db; } db = new DateBookDB; QValueList<EffectiveEvent> list = db->getEffectiveEvents( date, date ); qBubbleSort( list ); Config config( "qpe" ); int count=0; if ( list.count() > 0 ) { @@ -92,23 +94,23 @@ void DatebookPluginWidget::getDates() { DateBookEvent *l = new DateBookEvent( *it, this, m_show_location, m_show_notes ); layoutDates->addWidget( l ); QObject::connect ( l, SIGNAL( editEvent( const Event &) ), l, SLOT( editEventSlot( const Event &) ) ); } } } if ( m_onlyLater && count == 0 ) { QLabel* noMoreEvents = new QLabel( this ); noMoreEvents->setText( QObject::tr( "No more appointments today" ) ); layoutDates->addWidget( noMoreEvents ); } } else { QLabel* noEvents = new QLabel( this ); noEvents->setText( QObject::tr( "No appointments today" ) ); layoutDates->addWidget( noEvents ); } - - layoutDates->addItem( new QSpacerItem( 1,1, QSizePolicy::Minimum, QSizePolicy::Expanding ) ); + //layoutDates->addStretch(0); +// layoutDates->addItem( new QSpacerItem( 1,1, QSizePolicy::Minimum, QSizePolicy::Expanding ) ); // how often refresh - later have qcop update calls in *db //QTimer::singleShot( 20*1000, this , SLOT( getDates() ) ); } diff --git a/core/pim/today/today.cpp b/core/pim/today/today.cpp index f052a9f..7537631 100644 --- a/core/pim/today/today.cpp +++ b/core/pim/today/today.cpp @@ -51,35 +51,33 @@ static QValueList<TodayPlugin> pluginList; Today::Today( QWidget* parent, const char* name, WFlags fl ) : TodayBase( parent, name, fl ) { QObject::connect( (QObject*)ConfigButton, SIGNAL( clicked() ), this, SLOT( startConfig() ) ); QObject::connect( (QObject*)OwnerField, SIGNAL( clicked() ), this, SLOT( editCard() ) ); #if defined(Q_WS_QWS) #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 #endif setOwnerField(); - init(); - loadPlugins(); - draw(); + refresh(); showMaximized(); } /** * 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 ); } } /** @@ -105,105 +103,103 @@ void Today::setOwnerField( QString &message ) { } } /** * Init stuff needed for today. Reads the config file. */ void Today::init() { QDate date = QDate::currentDate(); QString time = ( tr( date.toString() ) ); DateLabel->setText( QString( "<font color=#FFFFFF>" + time + "</font>" ) ); // read config Config cfg( "today" ); - cfg.setGroup( "Applets" ); m_excludeApplets = cfg.readListEntry( "ExcludeApplets", ',' ); } /** * Load the plugins */ void Today::loadPlugins() { QValueList<TodayPlugin>::Iterator tit; for ( tit = pluginList.begin(); tit != pluginList.end(); ++tit ) { (*tit).library->unload(); delete (*tit).library; } pluginList.clear(); + QString path = QPEApplication::qpeDir() + "/plugins/today"; QDir dir( path, "lib*.so" ); QStringList list = dir.entryList(); QStringList::Iterator it; - uint count = 0; for ( it = list.begin(); it != list.end(); ++it ) { TodayPluginInterface *iface = 0; QLibrary *lib = new QLibrary( path + "/" + *it ); qDebug( "querying: %s", QString( path + "/" + *it ).latin1() ); if ( lib->queryInterface( IID_TodayPluginInterface, (QUnknownInterface**)&iface ) == QS_OK ) { qDebug( "loading: %s", QString( path + "/" + *it ).latin1() ); qDebug( QString(*it) ); TodayPlugin plugin; plugin.library = lib; plugin.iface = iface; plugin.name = QString(*it); + // find out if plugins should be shown if ( m_excludeApplets.grep( *it ).isEmpty() ) { plugin.active = true; } else { plugin.active = false; } plugin.guiPart = plugin.iface->guiPart(); // package the whole thing into a qwidget so it can be shown and hidden plugin.guiBox = new QWidget( this ); QHBoxLayout *boxLayout = new QHBoxLayout( plugin.guiBox ); QPixmap plugPix; plugPix.convertFromImage( Resource::loadImage( plugin.guiPart->pixmapNameWidget() ).smoothScale( 18, 18 ), 0 ); OClickableLabel* plugIcon = new OClickableLabel( plugin.guiBox ); plugIcon->setPixmap( plugPix ); // a scrollview for each plugin QScrollView* sv = new QScrollView( plugin.guiBox ); QWidget *plugWidget = plugin.guiPart->widget( sv->viewport() ); sv->setMinimumHeight( plugin.guiPart->minHeight() ); - //sv->setMaximumHeight( plugin.guiPart->maxHeight() ); sv->setResizePolicy( QScrollView::AutoOneFit ); sv->setHScrollBarMode( QScrollView::AlwaysOff ); sv->setFrameShape( QFrame::NoFrame ); sv->addChild( plugWidget ); // make sure the icon is on the top alligned boxLayout->addWidget( plugIcon, 0, AlignTop ); boxLayout->addWidget( sv, 0, AlignTop ); boxLayout->setStretchFactor( plugIcon, 1 ); boxLayout->setStretchFactor( sv, 9 ); layout->addWidget( plugin.guiBox ); pluginList.append( plugin ); - count++; } else { qDebug( "could not recognize %s", QString( path + "/" + *it ).latin1() ); delete lib; } } } /** * Repaint method. Reread all fields. */ void Today::draw() { if ( pluginList.count() == 0 ) { QLabel *noPlugins = new QLabel( this ); noPlugins->setText( tr( "No plugins found" ) ); @@ -218,104 +214,94 @@ void Today::draw() { if ( plugin.active ) { qDebug( plugin.name + " is ACTIVE " ); plugin.guiBox->show(); } else { qDebug( plugin.name + " is INACTIVE" ); plugin.guiBox->hide(); } count++; } if ( count == 0 ) { QLabel *noPluginsActive = new QLabel( this ); noPluginsActive->setText( tr( "No plugins activated" ) ); layout->addWidget( noPluginsActive ); } - - layout->addItem( new QSpacerItem( 1,1, QSizePolicy::Minimum, QSizePolicy::Expanding ) ); + //layout->addStretch(0); + //layout->addItem( new QSpacerItem( 1,1, QSizePolicy::Minimum, QSizePolicy::Expanding ) ); } /** * The method for the configuration dialog. */ void Today::startConfig() { TodayConfig conf( this, "dialog", true ); TodayPlugin plugin; - QList<ConfigWidget> configWidgetList; for ( uint i = 0; i < pluginList.count(); i++ ) { plugin = pluginList[i]; // load the config widgets in the tabs if ( plugin.guiPart->configWidget( this ) != 0l ) { ConfigWidget* widget = plugin.guiPart->configWidget( this ); configWidgetList.append( widget ); conf.TabWidget3->insertTab( widget, plugin.guiPart->appName() ); } // set the order/activate tab conf.pluginManagement( plugin.name, plugin.guiPart->pluginName(), Resource::loadPixmap( plugin.guiPart->pixmapNameWidget() ) ); } if ( conf.exec() == QDialog::Accepted ) { conf.writeConfig(); ConfigWidget *confWidget; for ( confWidget = configWidgetList.first(); confWidget != 0; confWidget = configWidgetList.next() ) { confWidget->writeConfig(); } + refresh(); + } +} - init(); - - TodayPlugin plugin; - QValueList<TodayPlugin> plugList; - for ( uint i = 0; i < pluginList.count(); i++ ) { - plugin = pluginList[i]; - if ( m_excludeApplets.grep( plugin.name ).isEmpty() ) { - qDebug("CONFIG " + plugin.name + " ACTIVE"); - plugin.active = true; - } else { - qDebug("CONFIG " + plugin.name + " INACTIVE"); - plugin.active = false; - } - plugList.append( plugin ); - } - pluginList = plugList; +/** + * Refresh for the view. Reload all applets + * + */ +void Today::refresh() { + init(); - draw(); + if ( layout ) { + delete layout; } -} + layout = new QVBoxLayout( this ); + layout->addWidget( Frame ); + layout->addWidget( OwnerField ); + loadPlugins(); + draw(); +} void Today::startAddressbook() { QCopEnvelope e( "QPE/System", "execute(QString)" ); e << QString( "addressbook" ); } /** * launch addressbook (personal card) */ void Today::editCard() { startAddressbook(); while( !QCopChannel::isRegistered( "QPE/Addressbook" ) ) { qApp->processEvents(); } QCopEnvelope v( "QPE/Addressbook", "editPersonalAndClose()" ); } -/* - * launches an App - */ -void Today::launchApp( QString appName ) { - QCopEnvelope e( "QPE/System", "execute(QString)" ); - e << QString( appName ); -} - Today::~Today() { } diff --git a/core/pim/today/today.h b/core/pim/today/today.h index 0a9a705..672adc4 100644 --- a/core/pim/today/today.h +++ b/core/pim/today/today.h @@ -29,45 +29,44 @@ #include "todayconfig.h" #include "todaybase.h" #include "todayplugininterface.h" class QVBoxLayout; class Today : public TodayBase { Q_OBJECT public: Today( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); ~Today(); - private slots: +private slots: void startConfig(); void startAddressbook(); - void launchApp( QString appName ); void editCard(); - void draw(); + void refresh(); private: void init(); void setOwnerField(); void setOwnerField(QString &string); void loadPlugins(); + void draw(); + private slots: void channelReceived(const QCString &msg, const QByteArray & data); private: TodayConfig *conf; QStringList m_excludeApplets; - QVBoxLayout *pluginLayout; - // QString m_autoStartTimer; int m_newStart; // int m_autoStart; int m_maxCharClip; }; #endif diff --git a/core/pim/today/todaybase.cpp b/core/pim/today/todaybase.cpp index 74f4fa0..800ca5d 100644 --- a/core/pim/today/todaybase.cpp +++ b/core/pim/today/todaybase.cpp @@ -21,32 +21,34 @@ #include <qimage.h> #include <qpixmap.h> #include <qapplication.h> #include <qpe/resource.h> TodayBase::TodayBase( QWidget* parent, const char* name, WFlags fl ) : QWidget( parent, name, fl ) { QPixmap logo = Resource::loadPixmap( "today/today_logo"); // logo QPixmap opiezilla = Resource::loadPixmap("today/opiezilla" ); //the opiezilla QPixmap config = Resource::loadPixmap( "today/config" ); // config icon layout = new QVBoxLayout( this ); + QVBoxLayout *mainLayout = new QVBoxLayout( this ); + 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" ); @@ -64,44 +66,40 @@ TodayBase::TodayBase( QWidget* parent, const char* name, WFlags fl ) 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( Frame, "TextLabel1" ); DateLabel->setGeometry( QRect( 10, 35, 168, 12 ) ); QFont DateLabel_font( DateLabel->font() ); DateLabel_font.setBold( TRUE ); DateLabel->setFont( DateLabel_font ); DateLabel->setBackgroundOrigin( QLabel::ParentOrigin ); DateLabel->setTextFormat( RichText ); // Opiezilla - QLabel* Opiezilla = new QLabel( Frame, "OpieZilla"); + QLabel* Opiezilla = new QLabel( Frame, "OpieZilla" ); Opiezilla->setPixmap( opiezilla ); - Opiezilla->setGeometry( QApplication::desktop()->width()-50 ,1, 45, 47); + Opiezilla->setGeometry( QApplication::desktop()->width()-50 ,1, 45, 47 ); Opiezilla->setBackgroundOrigin( QLabel::ParentOrigin ); // Ownerfield OwnerField = new OClickableLabel( this , "Owner" ); - OwnerField->setGeometry( QRect( 0,0, this->width(), 12 )); + OwnerField->setGeometry( QRect( 0, 0, this->width(), 12 ) ); OwnerField->setAlignment( int (QLabel::AlignTop | QLabel::AlignLeft ) ); OwnerField->setMaximumHeight(12); // config ConfigButton = new OClickableLabel ( Frame, "PushButton1" ); - ConfigButton->setGeometry( QRect( QApplication::desktop()->width()-80, 30, 25, 21 ) ); - ConfigButton->setPixmap( config ); + ConfigButton->setGeometry( QRect( QApplication::desktop()->width()-80, 30, 25, 21 ) ); + ConfigButton->setPixmap( config ); ConfigButton->setBackgroundOrigin( QLabel::ParentOrigin ); - - // -- layout -- - layout->addWidget( Frame ); - layout->addWidget( OwnerField ); } /** * D' tor */ TodayBase::~TodayBase() { } diff --git a/core/pim/today/todayconfig.cpp b/core/pim/today/todayconfig.cpp index 79c4d1f..4f23471 100644 --- a/core/pim/today/todayconfig.cpp +++ b/core/pim/today/todayconfig.cpp @@ -44,34 +44,32 @@ public: } }; /** * 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, WFlags fl ) : QDialog( parent, name, modal, fl ) { setCaption( tr( "Today config" ) ); QVBoxLayout *layout = new QVBoxLayout( this ); TabWidget3 = new QTabWidget( this, "TabWidget3" ); - // TabWidget3->setFrameShape( QFrame::NoFrame ); - //TabWidget3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)7, TabWidget3->sizePolicy().hasHeightForWidth() ) ); TabWidget3->setAutoMask( FALSE ); TabWidget3->setTabShape( QTabWidget::Rounded ); 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(); QVBox *vbox1 = new QVBox( hbox1 ); new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", this , SLOT( moveSelectedUp() ) ); new ToolButton( vbox1, tr( "Move Down" ),"opieplayer/down", this , SLOT( moveSelectedDown() ) ); tab2Layout->addWidget( hbox1 ); @@ -109,33 +107,33 @@ TodayConfig::TodayConfig( QWidget* parent, const char* name, bool modal, WFlags /** * 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() { Config cfg( "today" ); cfg.setGroup( "Autostart" ); int autostart = cfg.readNumEntry( "autostart", 1); if ( autostart ) { QCopEnvelope e( "QPE/System", "autoStart(QString,QString,QString)" ); e << QString( "add" ); e << QString( "today" ); e << m_autoStartTimer; } else { QCopEnvelope e( "QPE/System", "autoStart(QString,QString)" ); - e << QString( "remove"); + e << QString( "remove" ); e << QString( "today" ); } } /** * Read the config part */ void TodayConfig::readConfig() { Config cfg( "today" ); cfg.setGroup( "Autostart" ); m_autoStart = cfg.readNumEntry( "autostart", 1 ); CheckBoxAuto->setChecked( m_autoStart ); m_autoStartTimer = cfg.readEntry( "autostartdelay", "0" ); SpinBoxTime->setValue( m_autoStartTimer.toInt() ); cfg.setGroup( "Applets" ); |