[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [kremotecontrol] kcmremotecontrol: Correctly disable buttons in case a remote control is not availab
From: Michael Zanetti <michael_zanetti () gmx ! net>
Date: 2012-11-05 14:02:40
Message-ID: 20121105140240.BD129A60C4 () git ! kde ! org
[Download RAW message or body]
Git commit 5d37c4be37b96d9a6281b4c225ff051d42687101 by Michael Zanetti.
Committed on 05/11/2012 at 14:49.
Pushed by mzanetti into branch 'master'.
Correctly disable buttons in case a remote control is not available.
Make it more obvious when a remote is not available.
Fixes some crash reports when people tried to edit a non existent remote:
BUG: 287568
BUG: 284640
BUG: 287568
BUG: 301046
M +6 -4 kcmremotecontrol/kcmremotecontrol.cpp
M +10 -1 kcmremotecontrol/model.cpp
http://commits.kde.org/kremotecontrol/5d37c4be37b96d9a6281b4c225ff051d42687101
diff --git a/kcmremotecontrol/kcmremotecontrol.cpp \
b/kcmremotecontrol/kcmremotecontrol.cpp index de5e111..1a68969 100644
--- a/kcmremotecontrol/kcmremotecontrol.cpp
+++ b/kcmremotecontrol/kcmremotecontrol.cpp
@@ -317,10 +317,12 @@ void KCMRemoteControl::updateActions(Mode *mode) {
void KCMRemoteControl::modeSelectionChanged(const QModelIndex &index) {
if(index.isValid()){
- ui.pbAddMode->setEnabled(true);
- ui.pbEditMode->setEnabled(true);
- ui.pbAddAction->setEnabled(true);
- ui.pbAutoPopulate->setEnabled(true);
+ // Enable Add and Edit buttons only if remote is available
+ bool selectedRemoteAvailable = m_remoteModel->remote(index)->isAvailable();
+ ui.pbAddMode->setEnabled(selectedRemoteAvailable);
+ ui.pbEditMode->setEnabled(selectedRemoteAvailable);
+ ui.pbAddAction->setEnabled(selectedRemoteAvailable);
+ ui.pbAutoPopulate->setEnabled(selectedRemoteAvailable);
// Only enable the remove mode button if a non-Master mode is selected,
// or if the Remote is not available in in the system
diff --git a/kcmremotecontrol/model.cpp b/kcmremotecontrol/model.cpp
index bc65d86..d91ee09 100644
--- a/kcmremotecontrol/model.cpp
+++ b/kcmremotecontrol/model.cpp
@@ -770,7 +770,16 @@ QVariant RemoteItem::data(int role) const {
return remote->name();
}
if(role == Qt::DecorationRole){
- return KIcon(remote->masterMode()->iconName());
+ if(remote->isAvailable()) {
+ return KIcon(remote->masterMode()->iconName());
+ } else {
+ return KIcon(remote->masterMode()->iconName(), 0, QStringList() << \
QLatin1String("emblem-important")); + }
+ }
+ if(role == Qt::ToolTipRole) {
+ if(!remote->isAvailable()) {
+ return i18n("This remote control is currently not available.");
+ }
}
return QStandardItem::data(role);
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic