AlbumShaper  1.0a3
alertsWidget.cpp
Go to the documentation of this file.
1 //==============================================
2 // copyright : (C) 2003-2005 by Will Stokes
3 //==============================================
4 // This program is free software; you can redistribute it
5 // and/or modify it under the terms of the GNU General
6 // Public License as published by the Free Software
7 // Foundation; either version 2 of the License, or
8 // (at your option) any later version.
9 //==============================================
10 
11 //Systemwide includes
12 #include <qlayout.h>
13 #include <qlabel.h>
14 #include <qfont.h>
15 #include <qcheckbox.h>
16 #include <q3frame.h>
17 #include <q3vgroupbox.h>
18 #include <qapplication.h>
19 //Added by qt3to4:
20 #include <Q3GridLayout>
21 
22 //Projectwide includes
23 #include "alertsWidget.h"
24 #include "configuration.h"
25 #include "../config.h"
26 #include "../gui/window.h"
27 #include "../gui/statusWidget.h"
28 
29 //==============================================
31  const char* name ) : QWidget( parent, name)
32 {
33  this->config = config;
34 
35  categoryLabel = new QLabel( tr("Alerts:"), this);
36  QFont labelFont = categoryLabel->font();
37  labelFont.setWeight(QFont::Bold);
38  categoryLabel->setFont( labelFont );
39 
40  horizontalLine = new Q3Frame(this);
41  horizontalLine->setLineWidth(2);
42  horizontalLine->setMidLineWidth(1);
43  horizontalLine->setFrameStyle( Q3Frame::HLine | Q3Frame::Raised );
44 
45  behavior = new Q3VGroupBox( tr("Behavior"), this);
46  showDestructiveAlerts = new QCheckBox( tr("Alert me to destructive actions"), behavior);
47  showSoftwareUpdateAlerts = new QCheckBox( tr("Alert me to software updates"), behavior);
48 
49  grid = new Q3GridLayout( this, 4, 1, 0);
50  grid->setSpacing( WIDGET_SPACING );
51 
52  grid->addWidget( categoryLabel, 0, 0, Qt::AlignLeft );
53  grid->addWidget( horizontalLine, 1, 0 );
54  grid->addWidget( behavior, 2, 0 );
55  grid->setRowStretch( 3, 1 );
56 }
57 //==============================================
59 {
60  config->setBool( "alerts", "showDestructiveAlerts", true );
61  config->setBool( "alerts", "showSoftwareUpdateAlerts", true );
62  config->setString( "alerts", "loadSaveDir", QString(ALBUMSHAPER_VERSION) );
63 }
64 //==============================================
66 {
67  showDestructiveAlerts->setChecked( config->getBool( "alerts", "showDestructiveAlerts" ));
68  showSoftwareUpdateAlerts->setChecked( config->getBool( "alerts", "showSoftwareUpdateAlerts" ));
69 }
70 //==============================================
72 {
73  config->setBool( "alerts", "showDestructiveAlerts", showDestructiveAlerts->isChecked() );
74  config->setBool( "alerts", "showSoftwareUpdateAlerts", showSoftwareUpdateAlerts->isChecked() );
75 
76  //either check for and show or remove updates availble icon
77  if(showSoftwareUpdateAlerts->isChecked())
78  ((Window*)qApp->mainWidget())->getStatus()->checkForUpdates();
79  else
80  ((Window*)qApp->mainWidget())->getStatus()->removeUpdatesIcon();
81 }
82 //==============================================
QCheckBox * showSoftwareUpdateAlerts
Definition: alertsWidget.h:55
Configuration * config
Backend config object pointer.
Definition: alertsWidget.h:46
Top level widget, encapsulates the title widget, the layout widget, and the toolbar widget...
Definition: window.h:39
bool getBool(QString group, QString key)
Fetch bool setting.
Q3VGroupBox * behavior
Definition: alertsWidget.h:53
void setString(QString group, QString key, QString value)
Sets a setting value, if group does not exist it is created, if setting does not exist it is also cre...
static void setDefaults(Configuration *config)
void setBool(QString group, QString key, bool val)
Set bool setting.
void loadSettings()
QCheckBox * showDestructiveAlerts
Definition: alertsWidget.h:54
AlertsWidget(Configuration *config, QWidget *parent=0, const char *name=0)
#define WIDGET_SPACING
Definition: config.h:31
QLabel * categoryLabel
Definition: alertsWidget.h:50
Q3Frame * horizontalLine
Definition: alertsWidget.h:51
Configuration object manages all user-specific application settings.
Definition: configuration.h:24
#define ALBUMSHAPER_VERSION
Definition: config.h:21
Q3GridLayout * grid
Definition: alertsWidget.h:48
void saveSettings()