You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tdepowersave/src/infodialog.cpp

125 lines
4.0 KiB

/***************************************************************************
* Copyright (C) 2005 by Danny Kukawka *
* danny.kukawka@web.de, dkukawka@suse.de *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of version 2 of the GNU General Public License *
* as published by the Free Software Foundation. *
* *
* 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., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
/*!
* \file infodialog.cpp
* \brief In this file can be found the "information dialog with checkbox"
* related code.
* \author Danny Kukawka, <dkukawka@suse.de>, <danny.kukawka@web.de>
* \date 2005
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
// own headers
#include "infodialog.h"
// KDE headers:
#include <kiconloader.h>
#include <tdelocale.h>
// QT headers:
#include <tqcheckbox.h>
#include <tqdialog.h>
#include <tqlabel.h>
#include <tqpushbutton.h>
#include <tqstring.h>
#include <tqtooltip.h>
/*! This is the default constructor of class infoDialog . */
infoDialog::infoDialog( TDEConfig *config, TQString captionName, TQString message,
TQString dontShowAgainMsg, TQString settingsEntryName,
TQWidget *parent, const char *name)
:info_Dialog( parent, name, false, TQt::WStyle_StaysOnTop | WDestructiveClose )
{
if ( message.isEmpty() || (!dontShowAgainMsg.isEmpty() && settingsEntryName.isEmpty()) ||
(!dontShowAgainMsg.isEmpty() && (config == 0)))
close();
if (config != 0) {
settings = config;
settings->reparseConfiguration();
if (settings->hasGroup("infoDialog")){
settings->setGroup("infoDialog");
if (settings->readBoolEntry(settingsEntryName, false)) {
dialogDisabled = true;
//close();
}
else
dialogDisabled = false;
}
}
buttonOK->setIconSet(SmallIconSet("ok", TQIconSet::Automatic));
TQPixmap pixmap = 0;
pixmap = TDEGlobal::iconLoader()->loadIcon("messagebox_warning", TDEIcon::NoGroup, TDEIcon::SizeMedium);
iconPixmap->setPixmap( pixmap );
msgText->setText(message);
if (!captionName.isEmpty())
this->setCaption(i18n("TDEPowersave") + " - " + captionName);
else
this->setCaption(i18n("TDEPowersave"));
if (dontShowAgainMsg.isEmpty()) {
dontShowAgain->setHidden(true);
} else {
entryName = settingsEntryName;
dontShowAgain->setText(dontShowAgainMsg);
dontShowAgain->setHidden(false);
}
this->adjustSize();
}
/*! This is the default destructor of class infoDialog . */
infoDialog::~infoDialog()
{
// no need to delete child widgets, TQt does it all for us
}
/*!
* Use this function to get the value of \ref dialogDisabled.
* \return boolean with value of \ref dialogDisabled
* \retval true if disabled by user before
* \retval false if not
*/
bool infoDialog::dialogIsDisabled() {
return dialogDisabled;
}
/*!
* SLOT: called if the 'ok' button clicked. This TQT_SLOT sync the settings
* and close the dialog.
*/
void infoDialog::ButtonOK_clicked() {
if (!entryName.isEmpty() && dontShowAgain->isVisible()) {
settings->setGroup( "infoDialog" );
settings->writeEntry( entryName, dontShowAgain->isChecked());
settings->sync();
}
close();
}
#include "infodialog.moc"