[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: KPrayertime



On Saturday 22 November 2003 09:02, abdulhaq wrote:
> assalaamu `alaykum
>
> alHamdulillaah KPrayertime v 0.99, a prayer time applet for KDE 3.x,  is
> complete and I've also packaged some RPMs for Mandrake/RedHat.
>
> It has been arabised in that labels and numbers can be shown in arabic.
>
> Screenshots and download here: http://kprayertime.sourceforge.net
>
> I'm announcing it here before announcing it to the general public as I'd
> really appreciate it if some of the brothers who use KDE could test if for
> me on their machine, particularly the RPM.
>

 Good work, it works great!
 God bless you.

 However I thought it would be even better if it shows notifications
 and plays Azan sound files at each salah time.
 Well, I couldn't resist patching it :-)
 The patch is atttached, but the notifications is not on by default,
 you have to enable it first from the Applet preferences.
 and yeah, you need two sound files (one for fajr and one for the rest),
 and they need to be in the applet share directory ($KDEDIR/share/apps/
 kprayertime/sound)

-- 
Mohammed Yousif
We _will_ restore OUR Jerusalem.
diff -U 3 -H -d -r -N -a -- kprayertime/kpraytime/kpraytime.cpp.orig kprayertime/kpraytime/kpraytime.cpp
--- kprayertime/kpraytime/kpraytime.orig 2002-10-23 02:45:05.000000000 +0200
+++ kprayertime/kpraytime/kpraytime.cpp  2003-11-27 10:16:52.000000000 +0200
@@ -2,8 +2,8 @@
                           kpraytime.cpp  -  description
                              -------------------
     begin                : Wed Mar 21 07:43:21 /etc/localtime 2001
-    copyright            : (C) 2001 by 
-    email                : 
+    copyright            : (C) 2001 by
+    email                :
  ***************************************************************************/
 
 /***************************************************************************
@@ -33,6 +33,7 @@
 #include <qbuttongroup.h>
 #include <kaboutdialog.h>
 #include <kpanelapplet.h>
+#include <kaudioplayer.h>
 
 #include <time.h>
 #include <stdio.h>
@@ -196,7 +197,7 @@
 	registerPreferences();
 
 	timerEvent();
-	myTimer->start( 60000, FALSE );	
+	myTimer->start( 1000, FALSE );	
 	KApplication::kApplication()->setFont(sysFont);
 }
 
@@ -489,6 +490,52 @@
 	} else {
 		displayAllTimes();
 	}
+
+  if (!(prefDialog->getAzanSoundNotification() || prefDialog->getAzanTextNotification()))
+    return;
+  float now_hours = now->tm_hour + (static_cast<float>(now->tm_min))/60 + static_cast<float>(now->tm_sec)/(60*60);
+  static float last_check = now_hours;
+
+  static int last_salah = -1;
+  
+  if (last_salah < 0) {
+    int current_salah = 0;
+    while (now_hours > ptime[current_salah]) {
+      current_salah++;
+    }
+    switch (current_salah) {
+    case 0:  // fajr
+      last_salah = 6;
+      break;
+    case 1:  // shorok
+    case 2:  // zuhr
+      last_salah = 0;
+      break;
+    default:
+      last_salah = current_salah - 1;
+    }
+  }
+
+  for (int i=0; i<6; i++) {
+    if (i == 1)  // we don't want azan for shorouk, do we? ;-)
+      continue;
+    if ( (last_salah != i) && (ptime[i]<=now_hours) && (ptime[i]>=last_check) ) {
+      last_salah = i;
+      if (prefDialog->getAzanSoundNotification()) {
+        KStandardDirs dirs;
+        QString azan("");
+        if (i==0)  // Al-Fajr
+          azan = dirs.findResource("data","kprayertime/azan/fajr.ogg");
+        else  // the rest
+          azan = dirs.findResource("data","kprayertime/azan/azan.ogg");
+        KAudioPlayer::play(azan);
+      }
+      if (prefDialog->getAzanTextNotification())
+        KMessageBox::information(this, QString("It is salat ") + salatNames[i] + " time!", salatNames[i]);
+    }
+  }
+  last_check = now_hours;
+
 }
 
 
diff -U 3 -H -d -r -N -a -- kprayertime/kpraytime/prayprefimpl.cpp.orig kprayertime/kpraytime/prayprefimpl.cpp
--- kprayertime/kpraytime/prayprefimpl.cpp.orig	2002-09-28 23:32:25.000000000 +0200
+++ kprayertime/kpraytime/prayprefimpl.cpp	2003-11-27 10:16:52.000000000 +0200
@@ -147,6 +147,10 @@
   // Bold next for default
 	if (! config->hasKey("nextBold")) config->writeEntry("nextBold", "false");
 
+  if (!config->hasKey("notifyAzan"))
+    config->writeEntry("notifyAzan", "false");
+  if (!config->hasKey("soundAzan"))
+    config->writeEntry("soundAzan", "false");
 
   // read in config
 	if (config->readEntry("Layout") == QString::number(LAYOUT_ALL)) rbAllTimes->setChecked(true);
@@ -179,6 +183,12 @@
 	nextResalted->setChecked(true);
 	nextBold = true;
 	}
+
+  if (config->readEntry("notifyAzan") == "true")
+    notifyAzan->setChecked(true);
+
+  if (config->readEntry("soundAzan") == "true")
+    soundAzan->setChecked(true);
 }
 
 void prayPrefImpl::writeToConfig(){
@@ -197,7 +207,7 @@
 	config->writeEntry("TimeZone",cmbTimeZone->currentText());
 	if (cbDST->isChecked()) config->writeEntry("DST", "true");
 	else config->writeEntry("DST", "false");
-	
+
 	config->writeEntry("TZR", QString::number(cmbTimeZoneRegion->currentItem()));
 
   // fonts
@@ -218,6 +228,16 @@
   if (nextResalted->isChecked()) config->writeEntry("nextBold", "true");
 	else config->writeEntry("nextBold", "false");
 
+  if (notifyAzan->isChecked())
+    config->writeEntry("notifyAzan", "true");
+  else
+    config->writeEntry("notifyAzan", "false");
+
+  if (soundAzan->isChecked())
+    config->writeEntry("soundAzan", "true");
+  else
+    config->writeEntry("soundAzan", "false");
+
 	config->sync();
 
 }
@@ -283,6 +303,15 @@
 bool prayPrefImpl::getNextBold() {
   return nextBold;
 }
+
+bool prayPrefImpl::getAzanTextNotification() {
+  return notifyAzan->isChecked();
+}
+
+bool prayPrefImpl::getAzanSoundNotification() {
+  return soundAzan->isChecked();
+}
+
 void prayPrefImpl::setDisplayStyle(int m, int o) {
   mode = m;
   orient = o;
diff -U 3 -H -d -r -N -a -- kprayertime/kpraytime/prayprefimpl.h.orig kprayertime/kpraytime/prayprefimpl.h
--- kprayertime/kpraytime/prayprefimpl.h.orig	2002-09-28 23:32:25.000000000 +0200
+++ kprayertime/kpraytime/prayprefimpl.h	2003-11-27 10:16:52.000000000 +0200
@@ -68,6 +68,8 @@
   QColor getLabelColor();
   QColor getTimeColor();
   bool getNextBold();
+  bool getAzanTextNotification();
+  bool getAzanSoundNotification();
 
 	public slots:
 	   virtual void finish();
diff -U 3 -H -d -r -N -a -- kprayertime/kpraytime/pref.ui.orig kprayertime/kpraytime/pref.ui
--- kprayertime/kpraytime/pref.ui.orig	2002-10-07 15:11:25.000000000 +0200
+++ kprayertime/kpraytime/pref.ui	2003-11-27 10:16:52.000000000 +0200
@@ -10,7 +10,7 @@
             <x>0</x>
             <y>0</y>
             <width>400</width>
-            <height>411</height>
+            <height>475</height>
         </rect>
     </property>
     <property name="font">
@@ -412,14 +412,62 @@
             </widget>
         </widget>
     </widget>
+    <widget class="QGroupBox">
+        <property name="name">
+            <cstring>gbMethod_2</cstring>
+        </property>
+        <property name="geometry">
+            <rect>
+                <x>10</x>
+                <y>330</y>
+                <width>201</width>
+                <height>80</height>
+            </rect>
+        </property>
+        <property name="title">
+            <string>Azan</string>
+        </property>
+        <widget class="QCheckBox">
+            <property name="name">
+                <cstring>notifyAzan</cstring>
+            </property>
+            <property name="geometry">
+                <rect>
+                    <x>20</x>
+                    <y>20</y>
+                    <width>152</width>
+                    <height>21</height>
+                </rect>
+            </property>
+            <property name="text">
+                <string>Notify me at azan time</string>
+            </property>
+        </widget>
+        <widget class="QCheckBox">
+            <property name="name">
+                <cstring>soundAzan</cstring>
+            </property>
+            <property name="geometry">
+                <rect>
+                    <x>20</x>
+                    <y>40</y>
+                    <width>118</width>
+                    <height>21</height>
+                </rect>
+            </property>
+            <property name="text">
+                <string>Play Azan Sound</string>
+            </property>
+        </widget>
+    </widget>
     <widget class="QPushButton">
         <property name="name">
             <cstring>pbCancel</cstring>
         </property>
         <property name="geometry">
             <rect>
-                <x>110</x>
-                <y>350</y>
+                <x>210</x>
+                <y>430</y>
                 <width>80</width>
                 <height>30</height>
             </rect>
@@ -681,8 +729,8 @@
         </property>
         <property name="geometry">
             <rect>
-                <x>20</x>
-                <y>350</y>
+                <x>120</x>
+                <y>430</y>
                 <width>80</width>
                 <height>30</height>
             </rect>