[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: kdereview/plasma/applets/devicenotifier-refactor
From: Giulio Camuffo <giuliocamuffo () gmail ! com>
Date: 2009-10-04 19:48:54
Message-ID: 1254685734.793219.15957.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 1031364 by camuffo:
removed option to set the time the popup will stay opened
using a combobox to set if show (non) removable devices
M +38 -48 configurationpage.ui
M +22 -20 devicenotifier.cpp
M +8 -7 devicenotifier.h
--- trunk/kdereview/plasma/applets/devicenotifier-refactor/configurationpage.ui #1031363:1031364
@@ -11,66 +11,56 @@
</rect>
</property>
<layout class="QGridLayout" name="gridLayout">
- <item row="3" column="0">
- <layout class="QGridLayout" name="gridLayout_2">
- <item row="1" column="1">
- <widget class="KIntSpinBox" name="hidePopupAfter">
- <property name="maximumSize">
- <size>
- <width>60</width>
- <height>16777215</height>
- </size>
+ <item row="1" column="0">
+ <widget class="QCheckBox" name="showPopupOnInsert">
+ <property name="text">
+ <string>Show the popup when a device is inserted</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="0">
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QLabel" name="label_2">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
</property>
- <property name="specialValueText">
- <string>never</string>
+ <property name="text">
+ <string>Show </string>
</property>
</widget>
</item>
- <item row="1" column="0">
- <widget class="QLabel" name="label">
- <property name="minimumSize">
- <size>
- <width>0</width>
- <height>0</height>
- </size>
- </property>
- <property name="sizeIncrement">
- <size>
- <width>7</width>
- <height>0</height>
- </size>
- </property>
- <property name="text">
- <string>When inserting a device close the popup after</string>
- </property>
- <property name="wordWrap">
- <bool>true</bool>
- </property>
+ <item>
+ <widget class="KComboBox" name="showDevices">
+ <item>
+ <property name="text">
+ <string>Removable devices only</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Non-removable devices only</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>All devices</string>
+ </property>
+ </item>
</widget>
</item>
</layout>
</item>
- <item row="1" column="0">
- <widget class="QCheckBox" name="showOnlyRemovable">
- <property name="text">
- <string>Show removable devices only</string>
- </property>
- </widget>
- </item>
- <item row="2" column="0">
- <widget class="QCheckBox" name="showPopupOnInsert">
- <property name="text">
- <string>Show the popup when a device is inserted</string>
- </property>
- </widget>
- </item>
</layout>
</widget>
<customwidgets>
<customwidget>
- <class>KIntSpinBox</class>
- <extends>QSpinBox</extends>
- <header>knuminput.h</header>
+ <class>KComboBox</class>
+ <extends>QComboBox</extends>
+ <header>kcombobox.h</header>
</customwidget>
</customwidgets>
<resources/>
--- trunk/kdereview/plasma/applets/devicenotifier-refactor/devicenotifier.cpp #1031363:1031364
@@ -77,8 +77,7 @@
KConfigGroup cg = config();
m_numberItems = cg.readEntry("NumberItems", 4);
m_itemsValidity = cg.readEntry("ItemsValidity", 5);
- m_hidePopupAfter = cg.readEntry("hidePopupAfter", 5);
- m_showOnlyRemovable = cg.readEntry("showOnlyRemovable", false);
+ m_showDevices = cg.readEntry("ShowDevices", RemovableOnly).toInt();
m_showPopupOnInsert = cg.readEntry("showPopupOnInsert", true);
m_solidEngine = dataEngine("hotplug");
@@ -127,16 +126,7 @@
{
m_fillingPreviousDevices = true;
foreach (const QString &udi, m_solidEngine->sources()) {
- if (m_showOnlyRemovable) {
- Solid::Device device = Solid::Device(udi);
- Solid::Device parentDevice = device.parent();
- Solid::StorageDrive *drive = parentDevice.as<Solid::StorageDrive>();
- if (drive && (drive->isHotpluggable() || drive->isRemovable())) {
- onSourceAdded(udi);
- }
- } else {
- onSourceAdded(udi);
- }
+ onSourceAdded(udi);
}
m_fillingPreviousDevices = false;
}
@@ -234,7 +224,7 @@
if (!m_fillingPreviousDevices) {
if (m_showPopupOnInsert) {
- showPopup(m_hidePopupAfter * 1000);
+ showPopup(5);
}
changeNotifierIcon("preferences-desktop-notification");
update();
@@ -271,6 +261,22 @@
void DeviceNotifier::onSourceAdded(const QString &udi)
{
+ if (m_showDevices == NonRemovableOnly) {
+ Solid::Device device = Solid::Device(udi);
+ Solid::Device parentDevice = device.parent();
+ Solid::StorageDrive *drive = parentDevice.as<Solid::StorageDrive>();
+ if (drive && (drive->isHotpluggable() || drive->isRemovable())) {
+ return;
+ }
+ } else if (m_showDevices == RemovableOnly) {
+ Solid::Device device = Solid::Device(udi);
+ Solid::Device parentDevice = device.parent();
+ Solid::StorageDrive *drive = parentDevice.as<Solid::StorageDrive>();
+ if (drive && (!drive->isHotpluggable() && !drive->isRemovable())) {
+ return;
+ }
+ }
+
kDebug() << "DeviceNotifier:: source added" << udi;
KConfigGroup cg = config();
@@ -328,23 +334,19 @@
parent->setButtons( KDialog::Ok | KDialog::Cancel);
connect(parent, SIGNAL(okClicked()), this, SLOT(configAccepted()));
- m_configurationUi.hidePopupAfter->setValue(m_hidePopupAfter);
- m_configurationUi.hidePopupAfter->setSuffix(ki18np(" second", " seconds"));
m_configurationUi.showPopupOnInsert->setChecked(m_showPopupOnInsert);
- m_configurationUi.showOnlyRemovable->setChecked(m_showOnlyRemovable);
+ m_configurationUi.showDevices->setCurrentIndex(m_showDevices);
}
void DeviceNotifier::configAccepted()
{
KConfigGroup cg = config();
- m_hidePopupAfter = m_configurationUi.hidePopupAfter->value();
m_showPopupOnInsert = m_configurationUi.showPopupOnInsert->isChecked();
- m_showOnlyRemovable = m_configurationUi.showOnlyRemovable->isChecked();
+ m_showDevices = m_configurationUi.showDevices->currentIndex();
- cg.writeEntry("hidePopupAfter", m_hidePopupAfter);
cg.writeEntry("showPopupOnInsert", m_showPopupOnInsert);
- cg.writeEntry("showOnlyRemovable", m_showOnlyRemovable);
+ cg.writeEntry("ShowDevices", m_showDevices);
emit configNeedsSaving();
--- trunk/kdereview/plasma/applets/devicenotifier-refactor/devicenotifier.h #1031363:1031364
@@ -32,8 +32,6 @@
///Ui includes
#include "ui_configurationpage.h"
-
-
namespace Notifier
{
class NotifierDialog;
@@ -54,6 +52,12 @@
Q_OBJECT
public:
+ enum {
+ RemovableOnly = 0,
+ NonRemovableOnly = 1,
+ AllDevices = 2
+ };
+
/**
* Constructor of the applet
* @param parent the parent of this object
@@ -223,12 +227,9 @@
///configuration page
Ui::configurationPage m_configurationUi;
- ///hide the popup after a while
- int m_hidePopupAfter;
+ ///tells which devices to show
+ int m_showDevices;
- ///if true do not show the not removable devices
- bool m_showOnlyRemovable;
-
///if false do not show the popup on insertion of a new device
bool m_showPopupOnInsert;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic