• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

ktimetracker

  • sources
  • kde-4.12
  • kdepim
  • ktimetracker
ktimetrackerutility.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2007 by Thorsten Staerk <dev@staerk.de>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program; if not, write to the
16  * Free Software Foundation, Inc.
17  * 51 Franklin Street, Fifth Floor
18  * Boston, MA 02110-1301 USA.
19  *
20  */
21 
22 #include "ktimetrackerutility.h"
23 
24 #include <KGlobal>
25 #include <KLocale>
26 
27 #include <math.h>
28 #include <stdlib.h>
29 #include <X11/Xlib.h>
30 #include <fixx11h.h>
31 
32 QString getFocusWindow()
33 {
34  return KWindowSystem::windowInfo(KWindowSystem::activeWindow(),NET::WMName, 0).name();
35 }
36 
37 QString formatTime( double minutes, bool decimal )
38 {
39  kDebug(5970) << "Entering function(minutes=" << minutes << ",decimal=" << decimal << ");";
40  QString time;
41  if ( decimal )
42  {
43  time.sprintf( "%.2f", minutes / 60.0 );
44  time.replace( '.', KGlobal::locale()->decimalSymbol() );
45  }
46  else time.sprintf("%s%ld:%02ld",
47  (minutes < 0) ? KGlobal::locale()->negativeSign().toUtf8().data() : "",
48  labs(minutes / 60), labs(((int) round(minutes)) % 60));
49  return time;
50 }
51 
52 int desktopcount()
53 {
54  int result;
55  #ifdef Q_WS_X11
56  result = KWindowSystem::numberOfDesktops();
57  #else
58  #ifdef __GNUC__
59  #warning non-X11 support missing
60  #endif
61  result = -1;
62  #endif
63  return result;
64 }
formatTime
QString formatTime(double minutes, bool decimal)
Format time for output.
Definition: ktimetrackerutility.cpp:37
desktopcount
int desktopcount()
Get the number of virtual desktops Delivers 4 for four virtual desktops, 1 for one virtual desktop...
Definition: ktimetrackerutility.cpp:52
getFocusWindow
QString getFocusWindow()
Get the name of the window that has the focus.
Definition: ktimetrackerutility.cpp:32
data
const unsigned char * data
Definition: toolicons.h:158
ktimetrackerutility.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:55:10 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

ktimetracker

Skip menu "ktimetracker"
  • Main Page
  • Namespace List
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal