2 * Copyright (C) 2005 by Thorsten Staerk <kde@staerk.de>
3 * 2007 the ktimetracker developers
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the
17 * Free Software Foundation, Inc.
18 * 51 Franklin Street, Fifth Floor
19 * Boston, MA 02110-1301 USA.
23 #include "ktimetrackerpart.h"
29 #include <KComponentData>
32 #include <KStandardAction>
33 #include <KStandardDirs>
34 #include <KXMLGUIFactory>
35 #include <KActionCollection>
37 #include <kdemacros.h>
38 #include <kparts/genericfactory.h>
39 #include "mainwindow.h"
40 #include "ktimetrackerutility.h"
42 #include "preferences.h"
45 #include "ktimetracker.h"
46 #include "timetrackerwidget.h"
48 K_PLUGIN_FACTORY(ktimetrackerPartFactory
, registerPlugin
<ktimetrackerpart
>();)
49 K_EXPORT_PLUGIN( ktimetrackerPartFactory("ktimetracker","ktimetracker") )
51 ktimetrackerpart::ktimetrackerpart( QWidget
*parentWidget
, QObject
*parent
, const QVariantList
& )
52 : KParts::ReadWritePart(parent
)
54 KGlobal::locale()->insertCatalog("ktimetracker");
55 KGlobal::locale()->insertCatalog("libkdepim");
56 // we need an instance
57 setComponentData( ktimetrackerPartFactory::componentData() );
58 mMainWidget
= new TimetrackerWidget( parentWidget
);
59 setWidget( mMainWidget
);
60 setXMLFile( "ktimetrackerui.rc" );
64 ktimetrackerpart::~ktimetrackerpart()
68 KAboutData
*ktimetrackerpart::createAboutData()
70 const QByteArray
& appname
=QByteArray("ktimetracker");
71 const QByteArray
& catalogname
=QByteArray("ktimetracker");
72 const KLocalizedString localizedname
=ki18n("ktimetracker");
73 const QByteArray version
=QByteArray(KTIMETRACKER_VERSION
);
74 KAboutData
* aboutData
=new KAboutData( appname
, catalogname
, localizedname
, version
);
78 void ktimetrackerpart::makeMenus()
80 mMainWidget
->setupActions( actionCollection() );
81 KAction
*actionKeyBindings
;
82 actionKeyBindings
= KStandardAction::keyBindings( this, SLOT( keyBindings() ),
84 // Tool tips must be set after the createGUI.
85 actionKeyBindings
->setToolTip( i18n("Configure key bindings") );
86 actionKeyBindings
->setWhatsThis( i18n("This will let you configure key"
87 "bindings which are specific to ktimetracker") );
90 void ktimetrackerpart::setStatusBar(const QString
& qs
)
92 kDebug(5970) << "Entering function";
93 emit
setStatusBarText(qs
);
96 bool ktimetrackerpart::openFile(QString icsfile
)
98 mMainWidget
->openFile(icsfile
);
99 emit
setWindowCaption(icsfile
);
100 if ( KTimeTrackerSettings::trayIcon() ) mTray
= new TrayIcon( this );
101 else mTray
= new TrayIcon( );
104 connect( mMainWidget
, SIGNAL( totalTimesChanged( long, long ) ),
105 this, SLOT( updateTime( long, long ) ) );
106 connect( mMainWidget
, SIGNAL( statusBarTextChangeRequested( QString
) ),
107 this, SLOT( setStatusBar( QString
) ) );
108 connect( mMainWidget
, SIGNAL( setCaption( const QString
& ) ),
109 this, SIGNAL( setWindowCaption( const QString
& ) ) );
110 connect( mTray
, SIGNAL( quitSelected() ), SLOT( quit() ) );
111 connect( mMainWidget
, SIGNAL( timersActive() ), mTray
, SLOT( startClock() ) );
112 connect( mMainWidget
, SIGNAL( timersInactive() ), mTray
, SLOT( stopClock() ) );
113 connect( mMainWidget
, SIGNAL( tasksChanged( const QList
<Task
*>& ) ),
114 mTray
, SLOT( updateToolTip( QList
<Task
*> ) ));
118 bool ktimetrackerpart::openFile()
120 return openFile(KStandardDirs::locateLocal( "data", QString::fromLatin1( "ktimetracker/ktimetracker.ics" ) ));
123 bool ktimetrackerpart::saveFile()
125 mMainWidget
->saveFile();
129 #include "ktimetrackerpart.moc"