<commit_before>/*
    KDE Panel docking window for KDE Alarm Daemon GUI.

    This file is part of the GUI interface for the KDE alarm daemon.
    Copyright (c) 2001 <NAME> <<EMAIL>>
    Based on the original, (c) 1998, 1999 <NAME>

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

    As a special exception, permission is given to link this program
    with any edition of Qt, and distribute the resulting executable,
    without including the source code for Qt in the source distribution.
*/

#include <stdlib.h>

#include <qtooltip.h>
#include <qfile.h>

#include <kapplication.h>
#include <kdebug.h>
#include <klocale.h>
#include <kiconloader.h>
#include <kprocess.h>
#include <kconfig.h>
#include <kmessagebox.h>
#include <kurl.h>
#include <kstandarddirs.h>
#include <dcopclient.h>

#include "koalarmclient.h"
#include "alarmdaemoniface_stub.h"

#include "alarmdockwindow.h"
#include "alarmdockwindow.moc"


AlarmDockWindow::AlarmDockWindow(KOAlarmClient *client, QWidget *parent,
                                 const char *name)
  : KSystemTray(parent, name),
    mAlarmGui(client)
{
  // Read the GUI autostart status from the config file
  KConfig* config = kapp->config();
  config->setGroup("General");
  bool autostartGui = config->readBoolEntry( "Autostart", true );
  bool alarmsEnabled = config->readBoolEntry( "Enabled", true );

  // Set up GUI icons
  KGlobal::iconLoader()->addAppDir( "kalarmdgui" );
  mPixmapEnabled  = BarIcon( "kalarmdgui" );
  mPixmapDisabled = BarIcon( "kalarmdgui_disabled" );

  setPixmap( alarmsEnabled ? mPixmapEnabled : mPixmapDisabled );

  // Set up the context menu
  mAlarmsEnabledId = contextMenu()->insertItem(i18n("Alarms Enabled"),
                                              this, SLOT(toggleAlarmsEnabled()));
  mAutostartGuiId = contextMenu()->insertItem(i18n("Start Alarm Client at Login"),
                                              this, SLOT(toggleGuiAutostart()));
  contextMenu()->insertItem( i18n("Configure Alarm Client..."), this,
                             SLOT( configureAlarmDaemon() ) );
  
  contextMenu()->setItemChecked(mAutostartGuiId, autostartGui);
  contextMenu()->setItemChecked(mAlarmsEnabledId, alarmsEnabled);
}

AlarmDockWindow::~AlarmDockWindow()
{
}


/*
 * Called when the Alarms Enabled context menu item is selected.
 */
void AlarmDockWindow::toggleAlarmsEnabled()
{
  kdDebug() << "AlarmDockWindow::toggleAlarmsEnabled()" << endl;

  KConfig* config = kapp->config();
  config->setGroup("General");

  bool enabled = !contextMenu()->isItemChecked( mAlarmsEnabledId );
  contextMenu()->setItemChecked( mAlarmsEnabledId, enabled );
  setPixmap( enabled ? mPixmapEnabled : mPixmapDisabled );

  config->writeEntry( "Enabled", enabled );  
  config->sync();
}


/*
 * Set GUI autostart at login on or off, and set the context menu accordingly.
 */
void AlarmDockWindow::setGuiAutostart(bool on)
{
  kdDebug() << "setGuiAutostart()=" << int(on) << endl;

  KConfig* config = kapp->config();
  config->setGroup("General");
  config->writeEntry("Autostart", on);
  config->sync();

  contextMenu()->setItemChecked(mAutostartGuiId, on);
}


/*
 * Called when the mouse is clicked over the panel icon.
 */
void AlarmDockWindow::mousePressEvent(QMouseEvent* e)
{
  if ( e->button() == LeftButton ) {
    kapp->startServiceByDesktopName( "korganizer", QString::null );
  } else {
    KSystemTray::mousePressEvent( e );
  }
}


void AlarmDockWindow::closeEvent(QCloseEvent*)
{
  kapp->quit();
}

void AlarmDockWindow::configureAlarmDaemon()
{
  kapp->startServiceByDesktopName( "alarmdaemonctrl", QString::null );
}<commit_msg>Use kcmkded KControl module to control alarm daemon<commit_after>/*
    KDE Panel docking window for KDE Alarm Daemon GUI.

    This file is part of the GUI interface for the KDE alarm daemon.
    Copyright (c) 2001 <NAME> <<EMAIL>>
    Based on the original, (c) 1998, 1999 <NAME>

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

    As a special exception, permission is given to link this program
    with any edition of Qt, and distribute the resulting executable,
    without including the source code for Qt in the source distribution.
*/

#include <stdlib.h>

#include <qtooltip.h>
#include <qfile.h>

#include <kapplication.h>
#include <kdebug.h>
#include <klocale.h>
#include <kiconloader.h>
#include <kprocess.h>
#include <kconfig.h>
#include <kmessagebox.h>
#include <kurl.h>
#include <kstandarddirs.h>
#include <dcopclient.h>

#include "koalarmclient.h"
#include "alarmdaemoniface_stub.h"

#include "alarmdockwindow.h"
#include "alarmdockwindow.moc"


AlarmDockWindow::AlarmDockWindow(KOAlarmClient *client, QWidget *parent,
                                 const char *name)
  : KSystemTray(parent, name),
    mAlarmGui(client)
{
  // Read the GUI autostart status from the config file
  KConfig* config = kapp->config();
  config->setGroup("General");
  bool autostartGui = config->readBoolEntry( "Autostart", true );
  bool alarmsEnabled = config->readBoolEntry( "Enabled", true );

  // Set up GUI icons
  KGlobal::iconLoader()->addAppDir( "kalarmdgui" );
  mPixmapEnabled  = BarIcon( "kalarmdgui" );
  mPixmapDisabled = BarIcon( "kalarmdgui_disabled" );

  setPixmap( alarmsEnabled ? mPixmapEnabled : mPixmapDisabled );

  // Set up the context menu
  mAlarmsEnabledId = contextMenu()->insertItem(i18n("Alarms Enabled"),
                                              this, SLOT(toggleAlarmsEnabled()));
  mAutostartGuiId = contextMenu()->insertItem(i18n("Start Alarm Client at Login"),
                                              this, SLOT(toggleGuiAutostart()));
  contextMenu()->insertItem( i18n("Configure Alarm Client..."), this,
                             SLOT( configureAlarmDaemon() ) );
  
  contextMenu()->setItemChecked(mAutostartGuiId, autostartGui);
  contextMenu()->setItemChecked(mAlarmsEnabledId, alarmsEnabled);
}

AlarmDockWindow::~AlarmDockWindow()
{
}


/*
 * Called when the Alarms Enabled context menu item is selected.
 */
void AlarmDockWindow::toggleAlarmsEnabled()
{
  kdDebug() << "AlarmDockWindow::toggleAlarmsEnabled()" << endl;

  KConfig* config = kapp->config();
  config->setGroup("General");

  bool enabled = !contextMenu()->isItemChecked( mAlarmsEnabledId );
  contextMenu()->setItemChecked( mAlarmsEnabledId, enabled );
  setPixmap( enabled ? mPixmapEnabled : mPixmapDisabled );

  config->writeEntry( "Enabled", enabled );  
  config->sync();
}


/*
 * Set GUI autostart at login on or off, and set the context menu accordingly.
 */
void AlarmDockWindow::setGuiAutostart(bool on)
{
  kdDebug() << "setGuiAutostart()=" << int(on) << endl;

  KConfig* config = kapp->config();
  config->setGroup("General");
  config->writeEntry("Autostart", on);
  config->sync();

  contextMenu()->setItemChecked(mAutostartGuiId, on);
}


/*
 * Called when the mouse is clicked over the panel icon.
 */
void AlarmDockWindow::mousePressEvent(QMouseEvent* e)
{
  if ( e->button() == LeftButton ) {
    kapp->startServiceByDesktopName( "korganizer", QString::null );
  } else {
    KSystemTray::mousePressEvent( e );
  }
}


void AlarmDockWindow::closeEvent(QCloseEvent*)
{
  kapp->quit();
}

void AlarmDockWindow::configureAlarmDaemon()
{
  kapp->startServiceByDesktopName( "kcmkded", QString::null );
}
{'fraction_non_alphanumeric': 0.11300490310530002, 'fraction_numerical': 0.006303992528601448, 'mean_word_length': 3.862088535754824, 'pattern_counts': {'":': 0, '<': 57, '<?xml version=': 0, '>': 87, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2104689', 'n_tokens_mistral': 2702, 'n_tokens_neox': 2566, 'n_words': 779}