[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: kdereview/kerry/src/kcm
From: Stephan Binner <binner () kde ! org>
Date: 2006-10-18 20:47:58
Message-ID: 1161204478.351607.11532.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 596905 by binner:
copy functionality
M +2 -2 Makefile.am
M +158 -0 status.cpp
M +22 -0 status.h
--- trunk/kdereview/kerry/src/kcm/Makefile.am #596904:596905
@@ -1,4 +1,4 @@
-AM_CPPFLAGS = $(all_includes)
+AM_CPPFLAGS = $(all_includes) $(LIBBEAGLE_CFLAGS) $(GLIB_CFLAGS)
AM_LDFLAGS = $(all_libraries)
METASOURCES = AUTO
@@ -8,7 +8,7 @@
kcm_beagle_la_SOURCES = main.cpp beagle.cpp kerry.cpp indexing.cpp backends.cpp \
status.cpp search.cpp
kcm_beagle_la_LDFLAGS = $(all_libraries) -module -avoid-version -no-undefined
-kcm_beagle_la_LIBADD = $(LIB_KDEUI)
+kcm_beagle_la_LIBADD = $(LIB_KDEUI) $(LIBBEAGLE_LIBADD)
xdg_apps_DATA = kcmbeagle.desktop kcmkerry.desktop
--- trunk/kdereview/kerry/src/kcm/status.cpp #596904:596905
@@ -22,9 +22,60 @@
#include "status.h"
+#include <qdatetime.h>
+#include <qhbox.h>
+#include <qlayout.h>
+#include <qtimer.h>
+#include <kdialog.h>
+#include <klocale.h>
+#include <kpassivepopup.h>
+#include <kprocess.h>
+
+extern "C" {
+#include <glib.h>
+#include <beagle/beagle.h>
+}
+
KCMBeagleStatus::KCMBeagleStatus(QWidget *parent, const char * )
: KCModule(parent, "kcmbeaglestatus")
{
+ QVBoxLayout* general_layout = new QVBoxLayout( this, KDialog::spacingHint() );
+
+ QHBox *control_box = new QHBox (this);
+ control_box->setSpacing (3);
+ general_layout->addWidget(control_box);
+
+ label_control = new QLabel (control_box);
+
+ QWidget *dummy = new QWidget( control_box );
+ control_box->setStretchFactor( dummy, 1 );
+
+ pb_control = new KPushButton (control_box);
+ connect (pb_control, SIGNAL (clicked ()), this, SLOT (controlPressed ()) );
+
+ status_box = new QGroupBox (1, Qt::Horizontal, this);
+ general_layout->addWidget(status_box);
+
+ version_label = new QLabel (status_box);
+
+ status_area = new QTextEdit (status_box);
+ status_area->setReadOnly (true);
+
+ index_info_box = new QTextEdit (status_box);
+ index_info_box->setReadOnly (true);
+
+ QHBox *footer_box = new QHBox (this);
+ general_layout->addWidget(footer_box);
+
+ // Add some spacing to left
+ dummy = new QWidget( footer_box );
+ footer_box->setStretchFactor( dummy, 1 );
+ pb_refresh = new KPushButton (i18n("Refresh Status"), footer_box);
+ connect (pb_refresh, SIGNAL (clicked()), this, SLOT (refreshStatus ()) );
+
+ g_type_init ();
+ refreshStatus ();
+
load();
}
@@ -52,4 +103,111 @@
}
+bool KCMBeagleStatus::refreshDaemonStatus ()
+{
+ gboolean is_running = beagle_util_daemon_is_running ();
+ if (is_running) {
+ label_control->setText (i18n("Beagle service is currently running. Click here to \
stop.")); + pb_control->setText (i18n("Stop"));
+ last_status = true;
+ } else {
+ label_control->setText (i18n("Beagle service is currently stopped. Click here to \
start.")); + pb_control->setText (i18n("Start"));
+ last_status = false;
+ }
+ return is_running;
+}
+
+void KCMBeagleStatus::refreshStatus ()
+{
+ pb_refresh->setDisabled (TRUE);
+ bool is_running = refreshDaemonStatus ();
+
+ status_box->setTitle ( QString ("[%1] ").arg (QDateTime::currentDateTime \
().toString ()) ); + if (! is_running) {
+ version_label->setText (i18n("Service not started."));
+ pb_refresh->setDisabled (FALSE);
+ status_area->clear ();
+ index_info_box->clear ();
+ return;
+ }
+
+ BeagleClient *client = beagle_client_new (NULL);
+ BeagleDaemonInformationRequest *request = beagle_daemon_information_request_new \
(); + BeagleResponse *response = beagle_client_send_request (client, \
BEAGLE_REQUEST (request), NULL); +
+ version_label->setText ( i18n ("Beagle service version: %1\n").arg \
(beagle_daemon_information_response_get_version (BEAGLE_DAEMON_INFORMATION_RESPONSE \
(response)))); +
+ status_area->append (i18n("Current status:\n"));
+ status_area->append (" "); // cheating
+ status_area->append ( \
beagle_daemon_information_response_get_human_readable_status \
(BEAGLE_DAEMON_INFORMATION_RESPONSE (response))); +
+ index_info_box->append (i18n("Index information:"));
+ index_info_box->append (" ");
+ index_info_box->append ( \
beagle_daemon_information_response_get_index_information \
(BEAGLE_DAEMON_INFORMATION_RESPONSE (response))); +
+ g_object_unref (request);
+ g_object_unref (response);
+ //g_print ("%s\n", beagle_daemon_information_response_get_human_readable_status \
(BEAGLE_DAEMON_INFORMATION_RESPONSE (response))); + g_object_unref (client);
+
+ pb_refresh->setDisabled (FALSE);
+}
+
+void KCMBeagleStatus::controlPressed ()
+{
+ pb_control->setDisabled (TRUE);
+ if (last_status) {
+ if (stopBeagle ())
+ QTimer::singleShot (1000, this, SLOT (verifyStatus ()));
+ } else {
+ if (startBeagle ())
+ QTimer::singleShot (5000, this, SLOT (verifyStatus ()));
+ }
+}
+
+void KCMBeagleStatus::verifyStatus ()
+{
+ pb_control->setEnabled (TRUE);
+ refreshDaemonStatus ();
+}
+
+bool KCMBeagleStatus::stopBeagle ()
+{
+ gboolean is_running = beagle_util_daemon_is_running ();
+ if (! is_running) {
+ KPassivePopup::message (i18n("Beagle service was already stopped."), this);
+ return false;
+ }
+
+ BeagleClient *client = beagle_client_new (NULL);
+ BeagleShutdownRequest *request;
+ BeagleResponse *response;
+
+ request = beagle_shutdown_request_new ();
+ response = beagle_client_send_request (client, BEAGLE_REQUEST (request), NULL);
+ g_object_unref (client);
+
+ return true;
+}
+
+bool KCMBeagleStatus::startBeagle ()
+{
+ gboolean is_running = beagle_util_daemon_is_running ();
+ if (is_running) {
+ KPassivePopup::message (i18n("Beagle service already running."), this);
+ return false;
+ }
+
+ KProcess *proc = new KProcess;
+ *proc << "beagled";
+ *proc << "--indexing-delay 2";
+ if (!proc->start()) {
+ KPassivePopup::message (i18n("Could not start beagle service."), this);
+ return false;
+ }
+
+ return true;
+}
+
#include "status.moc"
--- trunk/kdereview/kerry/src/kcm/status.h #596904:596905
@@ -1,6 +1,7 @@
/*****************************************************************
Copyright (c) 2006 Stephan Binner <binner@kde.org>
+ Copyright (C) 2006 Debajyoti Bera <dbera.web@gmail.com>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
@@ -22,7 +23,11 @@
#ifndef __STATUS_H__
#define __STATUS_H__
+#include <qlabel.h>
+#include <qgroupbox.h>
+#include <qtextedit.h>
#include <kcmodule.h>
+#include <kpushbutton.h>
class KCMBeagleStatus : public KCModule
{
@@ -36,6 +41,23 @@
virtual void load( bool useDefaults );
virtual void save();
virtual void defaults();
+
+private slots:
+ void refreshStatus ();
+ void controlPressed ();
+ void verifyStatus ();
+
+private:
+ bool refreshDaemonStatus ();
+ bool stopBeagle ();
+ bool startBeagle ();
+
+ QLabel *label_control;
+ KPushButton *pb_control, *pb_refresh;
+ QLabel *version_label;
+ QTextEdit *status_area, *index_info_box;
+ QGroupBox *status_box;
+ bool last_status;
};
#endif
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic