Scale identity combobox and send/cancel buttons according to screen DPI.
[kdepim.git] / ktimetracker / ktimetrackerutility.cpp
blobefeba3abdc94a3725f0e0d6a9b663959a06dcc1f
1 /*
2 * Copyright (C) 2007 by Thorsten Staerk <dev@staerk.de>
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.
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.
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.
22 #include "ktimetrackerutility.h"
24 #include <KGlobal>
25 #include <KLocale>
27 #include <math.h>
28 #include <stdlib.h>
29 #include <X11/Xlib.h>
30 #include <fixx11h.h>
32 QString getFocusWindow()
34 return KWindowSystem::windowInfo(KWindowSystem::activeWindow(),NET::WMName, 0).name();
37 QString formatTime( double minutes, bool decimal )
39 kDebug(5970) << "Entering function(minutes=" << minutes << ",decimal=" << decimal << ");";
40 QString time;
41 if ( decimal )
43 time.sprintf( "%.2f", minutes / 60.0 );
44 time.replace( '.', KGlobal::locale()->decimalSymbol() );
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;
52 int desktopcount()
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;