cfgircsounds.cpp
1 //------------------------------------------------------------------------------
2 // cfgircsounds.cpp
3 //
4 // Copyright (C) 2011 "Zalewa" <zalewapl@gmail.com>
5 //------------------------------------------------------------------------------
6 #include "cfgircsounds.h"
7 #include "ui_cfgircsounds.h"
8 #include "irc/configuration/ircconfig.h"
9 
10 #include <QFileDialog>
11 
12 DClass<CFGIRCSounds> : public Ui::CFGIRCSounds
13 {
14 };
15 
16 DPointered(CFGIRCSounds)
17 
18 CFGIRCSounds::CFGIRCSounds(QWidget* parent)
19 : ConfigurationBaseBox(parent)
20 {
21  d->setupUi(this);
22 
23  this->connect(d->btnBrowseNicknameUsed, SIGNAL( clicked() ), SLOT( btnBrowseNicknameUsedClicked() ) );
24  this->connect(d->btnBrowsePrivateMessage, SIGNAL( clicked() ), SLOT( btnBrowsePrivateMessageClicked() ) );
25 }
26 
27 CFGIRCSounds::~CFGIRCSounds()
28 {
29 }
30 
31 void CFGIRCSounds::btnBrowseNicknameUsedClicked()
32 {
33  setPath(d->leNicknameUsed, getPathToWav());
34 }
35 
36 void CFGIRCSounds::btnBrowsePrivateMessageClicked()
37 {
38  setPath(d->lePrivateMessage, getPathToWav());
39 }
40 
41 QString CFGIRCSounds::getPathToWav()
42 {
43  return QFileDialog::getOpenFileName(this, tr("Pick Sound File"),
44  QString(),
45  tr("WAVE (*.wav)"));
46 }
47 
49 {
50  d->cbNicknameUsed->setChecked(gIRCConfig.sounds.bUseNicknameUsedSound);
51  d->cbPrivateMessage->setChecked(gIRCConfig.sounds.bUsePrivateMessageReceivedSound);
52 
53  d->leNicknameUsed->setText(gIRCConfig.sounds.nicknameUsedSound);
54  d->lePrivateMessage->setText(gIRCConfig.sounds.privateMessageReceivedSound);
55 }
56 
58 {
59  gIRCConfig.sounds.bUseNicknameUsedSound = d->cbNicknameUsed->isChecked();
60  gIRCConfig.sounds.bUsePrivateMessageReceivedSound = d->cbPrivateMessage->isChecked();
61 
62  gIRCConfig.sounds.nicknameUsedSound = d->leNicknameUsed->text();
63  gIRCConfig.sounds.privateMessageReceivedSound = d->lePrivateMessage->text();
64 }
65 
66 void CFGIRCSounds::setPath(QLineEdit* pLineEdit, const QString& path)
67 {
68  QString trimmedPath = path.trimmed();
69  if (!trimmedPath.isEmpty())
70  {
71  pLineEdit->setText(trimmedPath);
72  }
73 }
void saveSettings()
Reimplement this to write settings to config from widgets.
void readSettings()
Reimplement this to read settings from config into widgets.
Base class for configuration pages.