1
/****************************************************************************
2
* Copyright (C) 2012-2013 by Savoir-Faire Linux *
3
* Author : Emmanuel Lepage Vallee <emmanuel.lepage@savoirfairelinux.com> *
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. *
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. *
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
***************************************************************************/
19
#include "dlgaccessibility.h"
20
#include "klib/configurationskeleton.h"
23
#include <KConfigDialog>
27
#include <klib/macromodel.h>
30
DlgAccessibility::DlgAccessibility(KConfigDialog* parent)
31
: QWidget(parent),m_Changed(false)
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)"));
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()) );
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)) );
55
connect(this , SIGNAL(updateButtons()) , parent,SLOT(updateButtons()) );
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)));
65
DlgAccessibility::~DlgAccessibility()
71
void DlgAccessibility::updateSettings()
73
MacroModel::getInstance()->save();
77
void DlgAccessibility::updateWidgets()
82
void DlgAccessibility::changed()
88
bool DlgAccessibility::hasChanged()
93
void DlgAccessibility::addMacro()
95
Macro* ret = MacroModel::getInstance()->newMacro();
97
m_pMacroFrm->setEnabled(true);
101
void DlgAccessibility::removeMacro()
106
void DlgAccessibility::selectMacro(Macro* 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);
126
void DlgAccessibility::slotNameLE(const QString& newText)
128
Macro* current = MacroModel::getInstance()->getCurrentMacro();
130
current->setName(newText);
134
void DlgAccessibility::slotCategoryCBB(const QString& newText)
136
Macro* current = MacroModel::getInstance()->getCurrentMacro();
138
current->setCategory(newText);
142
void DlgAccessibility::slotDelaySB(int newValue)
144
Macro* current = MacroModel::getInstance()->getCurrentMacro();
146
current->setDelay(newValue);
150
void DlgAccessibility::slotSequenceLE(const QString& newText)
152
Macro* current = MacroModel::getInstance()->getCurrentMacro();
154
current->setSequence(newText);
158
void DlgAccessibility::slotDescriptionLE(const QString& newText)
160
Macro* current = MacroModel::getInstance()->getCurrentMacro();
162
current->setDescription(newText);