~ubuntu-branches/ubuntu/vivid/sflphone/vivid

« back to all changes in this revision

Viewing changes to kde/src/conf/dlgaccessibility.cpp

  • Committer: Package Import Robot
  • Author(s): Mark Purcell
  • Date: 2013-06-30 11:40:56 UTC
  • mfrom: (4.1.18 saucy-proposed)
  • Revision ID: package-import@ubuntu.com-20130630114056-0np50jkyqo6vnmii
Tags: 1.2.3-2
* changeset_r92d62cfc54732bbbcfff2b1d36c096b120b981a5.diff 
  - fixes automatic endian detection 
* Update Vcs: fixes vcs-field-not-canonical

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************
 
2
 *   Copyright (C) 2012-2013 by Savoir-Faire Linux                          *
 
3
 *   Author : Emmanuel Lepage Vallee <emmanuel.lepage@savoirfairelinux.com> *
 
4
 *                                                                          *
 
5
 *   This library is free software; you can redistribute it and/or          *
 
6
 *   modify it under the terms of the GNU Lesser General Public             *
 
7
 *   License as published by the Free Software Foundation; either           *
 
8
 *   version 2.1 of the License, or (at your option) any later version.     *
 
9
 *                                                                          *
 
10
 *   This library is distributed in the hope that it will be useful,        *
 
11
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
 
12
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU      *
 
13
 *   Lesser General Public License for more details.                        *
 
14
 *                                                                          *
 
15
 *   You should have received a copy of the GNU General Public License      *
 
16
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.  *
 
17
 ***************************************************************************/
 
18
 
 
19
#include "dlgaccessibility.h"
 
20
#include "klib/configurationskeleton.h"
 
21
 
 
22
//KDE
 
23
#include <KConfigDialog>
 
24
#include <KLocale>
 
25
 
 
26
//SFLPhone
 
27
#include <klib/macromodel.h>
 
28
 
 
29
///Constructor
 
30
DlgAccessibility::DlgAccessibility(KConfigDialog* parent)
 
31
 : QWidget(parent),m_Changed(false)
 
32
{
 
33
   setupUi(this);
 
34
 
 
35
   m_pAddTB->setIcon    ( KIcon( "list-add"    ) );
 
36
   m_pRemoveTB->setIcon ( KIcon( "list-remove" ) );
 
37
   m_pInfoIconL->setPixmap(KIcon("dialog-information").pixmap(QSize(24,24)));
 
38
   m_pInfoL->setText(i18n("This page allows to create macros that can then be called using keyboard shortcuts or added to the toolbar. To create one, "
 
39
   "assign a name and a character sequence. The sequence can be numeric or any character than can be interpreted as one (ex: \"A\" would be interpreted as 2)"));
 
40
 
 
41
   connect(m_pNameLE        , SIGNAL(textChanged(QString)) , this,SLOT(changed())     );
 
42
   connect(m_pCategoryCBB   , SIGNAL(textChanged(QString)) , this,SLOT(changed())     );
 
43
   connect(m_pDelaySB       , SIGNAL(valueChanged(int))    , this,SLOT(changed())     );
 
44
   connect(m_pSequenceLE    , SIGNAL(textChanged(QString)) , this,SLOT(changed())     );
 
45
   connect(m_pDescriptionLE , SIGNAL(textChanged(QString)) , this,SLOT(changed())     );
 
46
   connect(m_pAddTB         , SIGNAL(clicked())            , this,SLOT(addMacro())    );
 
47
   connect(m_pRemoveTB      , SIGNAL(clicked())            , this,SLOT(removeMacro()) );
 
48
   
 
49
   connect(m_pDelaySB       , SIGNAL(valueChanged(int))    , this,SLOT(slotDelaySB(int))      );
 
50
   connect(m_pNameLE        , SIGNAL(textChanged(QString)) , this,SLOT(slotNameLE(QString))        );
 
51
   connect(m_pCategoryCBB->lineEdit()   , SIGNAL(textChanged(QString)) , this,SLOT(slotCategoryCBB(QString))   );
 
52
   connect(m_pSequenceLE    , SIGNAL(textChanged(QString)) , this,SLOT(slotSequenceLE(QString))    );
 
53
   connect(m_pDescriptionLE , SIGNAL(textChanged(QString)) , this,SLOT(slotDescriptionLE(QString)) );
 
54
 
 
55
   connect(this , SIGNAL(updateButtons()) , parent,SLOT(updateButtons()) );
 
56
   
 
57
   connect(MacroModel::getInstance(),SIGNAL(selectMacro(Macro*)),this,SLOT(selectMacro(Macro*)));
 
58
   connect(MacroModel::getInstance(),SIGNAL(layoutChanged()),m_pMacroListTV,SLOT(expandAll()));
 
59
   m_pMacroListTV->setModel(MacroModel::getInstance());
 
60
   m_pMacroListTV->expandAll();
 
61
   connect(m_pMacroListTV->selectionModel(),SIGNAL(currentChanged(QModelIndex,QModelIndex)),MacroModel::getInstance(),SLOT(setCurrent(QModelIndex,QModelIndex)));
 
62
}
 
63
 
 
64
///Destructor
 
65
DlgAccessibility::~DlgAccessibility()
 
66
{
 
67
   
 
68
}
 
69
 
 
70
///Save
 
71
void DlgAccessibility::updateSettings()
 
72
{
 
73
   MacroModel::getInstance()->save();
 
74
}
 
75
 
 
76
///Load
 
77
void DlgAccessibility::updateWidgets()
 
78
{
 
79
   
 
80
}
 
81
 
 
82
void DlgAccessibility::changed()
 
83
{
 
84
   m_Changed = true;
 
85
   emit updateButtons();
 
86
}
 
87
 
 
88
bool DlgAccessibility::hasChanged()
 
89
{
 
90
   return m_Changed;
 
91
}
 
92
 
 
93
void DlgAccessibility::addMacro()
 
94
{
 
95
   Macro* ret = MacroModel::getInstance()->newMacro();
 
96
   if (ret) {
 
97
      m_pMacroFrm->setEnabled(true);
 
98
   }
 
99
}
 
100
 
 
101
void DlgAccessibility::removeMacro()
 
102
{
 
103
   
 
104
}
 
105
 
 
106
void DlgAccessibility::selectMacro(Macro* macro)
 
107
{
 
108
   if (macro) {
 
109
      m_pMacroListTV->expandAll();
 
110
      m_pNameLE->setText(macro->name());
 
111
      m_pCategoryCBB->lineEdit()->setText(macro->category());
 
112
      m_pDelaySB->setValue(macro->delay());
 
113
      m_pSequenceLE->setText(macro->sequence());
 
114
      m_pDescriptionLE->setText(macro->description());
 
115
      m_pMacroFrm->setEnabled(true);
 
116
      m_pNameLE->selectAll();
 
117
      m_pNameLE->setFocus();
 
118
      QModelIndex newIdx = macro->index();
 
119
      if (newIdx != m_pMacroListTV->selectionModel()->currentIndex()) {
 
120
         m_pMacroListTV->selectionModel()->setCurrentIndex(newIdx,QItemSelectionModel::ClearAndSelect);
 
121
      }
 
122
   }
 
123
}
 
124
 
 
125
//Widget change
 
126
void DlgAccessibility::slotNameLE(const QString& newText)
 
127
{
 
128
   Macro* current = MacroModel::getInstance()->getCurrentMacro();
 
129
   if (current) {
 
130
      current->setName(newText);
 
131
   }
 
132
}
 
133
 
 
134
void DlgAccessibility::slotCategoryCBB(const QString& newText)
 
135
{
 
136
   Macro* current = MacroModel::getInstance()->getCurrentMacro();
 
137
   if (current) {
 
138
      current->setCategory(newText);
 
139
   }
 
140
}
 
141
 
 
142
void DlgAccessibility::slotDelaySB(int newValue)
 
143
{
 
144
   Macro* current = MacroModel::getInstance()->getCurrentMacro();
 
145
   if (current) {
 
146
      current->setDelay(newValue);
 
147
   }
 
148
}
 
149
 
 
150
void DlgAccessibility::slotSequenceLE(const QString& newText)
 
151
{
 
152
   Macro* current = MacroModel::getInstance()->getCurrentMacro();
 
153
   if (current) {
 
154
      current->setSequence(newText);
 
155
   }
 
156
}
 
157
 
 
158
void DlgAccessibility::slotDescriptionLE(const QString& newText)
 
159
{
 
160
   Macro* current = MacroModel::getInstance()->getCurrentMacro();
 
161
   if (current) {
 
162
      current->setDescription(newText);
 
163
   }
 
164
}