Permalink
Browse files

Add setting to hide the tray icon if there are no connected devices.

  • Loading branch information...
1 parent baf33e8 commit c1e76033b99ab8a9e14bff3c843bd46200416ce0 Mike Limansky committed May 11, 2012
Showing with 61 additions and 30 deletions.
  1. +3 −0 ChangeLog
  2. +4 −0 src/settings.cpp
  3. +1 −0 src/settings.h
  4. +2 −0 src/settingsdialog.cpp
  5. +11 −1 src/settingsdialog.ui
  6. +2 −2 src/src.pro
  7. +7 −1 src/tinymounttray.cpp
  8. +31 −26 src/translations/tinymount_ru.ts
View
@@ -1,3 +1,6 @@
+TinyMount-0.2.4
+ - Add setting to hide the tray icon if there are no connected devices.
+
TinyMount-0.2.2
---------------
- Add libnotify support.
View
@@ -21,6 +21,7 @@
#include <QSettings>
static const char* SHOW_SYSTEM_DISKS = "ShowSystemDisks";
+static const char* HIDE_ICON = "HideIcon";
static const char* MOUNT_AUTOMATICALY = "MountAutomaticaly";
static const char* ITEM_FORMAT = "ItemFormat";
@@ -49,6 +50,7 @@ void SettingsManager::readSettings()
{
QSettings s("tinymount", "tinymount");
settings.showSystemDisks = s.value(SHOW_SYSTEM_DISKS, true).toBool();
+ settings.hideIcon = s.value(HIDE_ICON, false).toBool();
settings.mountAutomaticaly = s.value(MOUNT_AUTOMATICALY, false).toBool();
settings.itemFormat = s.value(ITEM_FORMAT, DEFAULT_ITEM_FORMAT).toString();
@@ -66,8 +68,10 @@ void SettingsManager::save(const Settings& newSettings)
QSettings s("tinymount", "tinymount");
s.setValue(SHOW_SYSTEM_DISKS, settings.showSystemDisks);
+ s.setValue(HIDE_ICON, settings.hideIcon);
s.setValue(MOUNT_AUTOMATICALY, settings.mountAutomaticaly);
s.setValue(ITEM_FORMAT, settings.itemFormat);
+
s.beginGroup(NOTIFICATIONS);
s.setValue(NTF_DEVICES, settings.deviceNotifications);
s.setValue(NTF_MOUNT, settings.mountNotifications);
View
@@ -25,6 +25,7 @@
struct Settings
{
bool showSystemDisks;
+ bool hideIcon;
bool deviceNotifications;
bool mountNotifications;
bool mountAutomaticaly;
View
@@ -8,6 +8,7 @@ SettingsDialog::SettingsDialog(const Settings& settings, QWidget *parent) :
{
ui->setupUi(this);
ui->systemDisks->setChecked(settings.showSystemDisks);
+ ui->hideIcon->setChecked(settings.hideIcon);
ui->autoMount->setChecked(settings.mountAutomaticaly);
ui->deviceNotify->setChecked(settings.deviceNotifications);
@@ -30,6 +31,7 @@ Settings SettingsDialog::getSettings()
{
Settings settings;
settings.showSystemDisks = ui->systemDisks->isChecked();
+ settings.hideIcon = ui->hideIcon->isChecked();
settings.mountAutomaticaly = ui->autoMount->isChecked();
settings.deviceNotifications = ui->deviceNotify->isChecked();
View
@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>419</width>
- <height>265</height>
+ <height>267</height>
</rect>
</property>
<property name="windowTitle">
@@ -27,6 +27,13 @@
</property>
</widget>
</item>
+ <item>
+ <widget class="QCheckBox" name="hideIcon">
+ <property name="text">
+ <string>Hide icon if there are no devices</string>
+ </property>
+ </widget>
+ </item>
<item>
<widget class="QCheckBox" name="autoMount">
<property name="enabled">
@@ -112,7 +119,10 @@ p, li { white-space: pre-wrap; }
</widget>
<tabstops>
<tabstop>systemDisks</tabstop>
+ <tabstop>hideIcon</tabstop>
<tabstop>autoMount</tabstop>
+ <tabstop>itemFormat</tabstop>
+ <tabstop>resetFormatButton</tabstop>
<tabstop>deviceNotify</tabstop>
<tabstop>mountNotify</tabstop>
<tabstop>buttonBox</tabstop>
View
@@ -19,7 +19,7 @@
TEMPLATE = app
TARGET = tinymount
-VERSION = 0.2.2
+VERSION = 0.2.4
DEPENDPATH += .
INCLUDEPATH += .
@@ -63,7 +63,7 @@ RESOURCES += tinymount.qrc
TRANSLATIONS = translations/tinymount_ru.ts
-# CONFIG += with_libnotify
+CONFIG += with_libnotify
with_libnotify {
DEFINES += WITH_LIBNOTIFY
View
@@ -140,11 +140,14 @@ void TinyMountTray::reloadDevices()
trayMenu->clear();
bool showSystem = SettingsManager::instance().getSettings().showSystemDisks;
+ bool hasDevices = false;
foreach (const DeviceInfoPtr d, manager->devices())
{
if (!showSystem && d->isSystem) continue;
+ hasDevices = true;
+
QIcon icon;
QString text = SettingsManager::instance().getSettings().itemFormat;
text.replace("%name%", d->name).replace("%fs%", d->fileSystem).replace("%size%", formatFileSize(d->size));
@@ -179,6 +182,8 @@ void TinyMountTray::reloadDevices()
trayMenu->addAction(tr("Settings"), this, SLOT(showSettings()));
trayMenu->addAction(tr("About..."), this, SLOT(showAbout()));
trayMenu->addAction(tr("Quit"), qApp, SLOT(quit()));
+
+ if (SettingsManager::instance().getSettings().hideIcon) tray->setVisible(hasDevices);
}
void TinyMountTray::onDeviceAdded(const DeviceInfo &device)
@@ -282,7 +287,8 @@ void TinyMountTray::showSettings()
const Settings& settings = dlg.getSettings();
const Settings& oldSettings = SettingsManager::instance().getSettings();
bool refreshList = settings.showSystemDisks != oldSettings.showSystemDisks
- || settings.itemFormat != oldSettings.itemFormat;
+ || settings.itemFormat != oldSettings.itemFormat
+ || settings.hideIcon != oldSettings.hideIcon;
SettingsManager::instance().save(settings);
if (refreshList)
@@ -75,17 +75,22 @@
<translation>Показывать системные диски</translation>
</message>
<message>
- <location filename="../settingsdialog.ui" line="36"/>
+ <location filename="../settingsdialog.ui" line="33"/>
+ <source>Hide icon if there are no devices</source>
+ <translation>Скрывать иконку если нет устройств</translation>
+ </message>
+ <message>
+ <location filename="../settingsdialog.ui" line="43"/>
<source>Mount devices automaticaly</source>
<translation>Монтировать диски автоматически</translation>
</message>
<message>
- <location filename="../settingsdialog.ui" line="45"/>
+ <location filename="../settingsdialog.ui" line="52"/>
<source>Item format:</source>
<translation>Формат элемента:</translation>
</message>
<message>
- <location filename="../settingsdialog.ui" line="52"/>
+ <location filename="../settingsdialog.ui" line="59"/>
<source>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
@@ -104,32 +109,32 @@ p, li { white-space: pre-wrap; }
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;%mounted%&lt;/span&gt; - точка монтирования&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</translation>
</message>
<message>
- <location filename="../settingsdialog.ui" line="66"/>
+ <location filename="../settingsdialog.ui" line="73"/>
<source>Reset format to default</source>
<translation>Сбросить формат к исходному</translation>
</message>
<message>
- <location filename="../settingsdialog.ui" line="69"/>
+ <location filename="../settingsdialog.ui" line="76"/>
<source>X</source>
<translation>X</translation>
</message>
<message>
- <location filename="../settingsdialog.ui" line="81"/>
+ <location filename="../settingsdialog.ui" line="88"/>
<source>Notifications</source>
<translation>Уведомления</translation>
</message>
<message>
- <location filename="../settingsdialog.ui" line="87"/>
+ <location filename="../settingsdialog.ui" line="94"/>
<source>Notify when device added/removed</source>
<translation>Уведомлять о добавлении устройства</translation>
</message>
<message>
- <location filename="../settingsdialog.ui" line="94"/>
+ <location filename="../settingsdialog.ui" line="101"/>
<source>Notify when device mounted/unmounted</source>
<translation>Уведомлять о монтировании устройства</translation>
</message>
<message>
- <location filename="../settingsdialog.cpp" line="18"/>
+ <location filename="../settingsdialog.cpp" line="19"/>
<source>Use system notifications</source>
<translation>Использовать системные уведомления</translation>
</message>
@@ -138,87 +143,87 @@ p, li { white-space: pre-wrap; }
<name>TinyMountTray</name>
<message>
<location filename="../main.cpp" line="156"/>
- <location filename="../tinymounttray.cpp" line="271"/>
+ <location filename="../tinymounttray.cpp" line="276"/>
<source>TinyMount, version %1</source>
<translation>TinyMount, версия %1</translation>
</message>
<message>
- <location filename="../tinymounttray.cpp" line="180"/>
+ <location filename="../tinymounttray.cpp" line="183"/>
<source>About...</source>
<translation>О программе...</translation>
</message>
<message>
- <location filename="../tinymounttray.cpp" line="181"/>
+ <location filename="../tinymounttray.cpp" line="184"/>
<source>Quit</source>
<translation>Выход</translation>
</message>
<message>
- <location filename="../tinymounttray.cpp" line="189"/>
+ <location filename="../tinymounttray.cpp" line="194"/>
<source>Device is added</source>
<translation>Устройство добавлено</translation>
</message>
<message>
- <location filename="../tinymounttray.cpp" line="190"/>
+ <location filename="../tinymounttray.cpp" line="195"/>
<source>Device %1 is added</source>
<translation>Добавлено устройство %1</translation>
</message>
<message>
- <location filename="../tinymounttray.cpp" line="204"/>
+ <location filename="../tinymounttray.cpp" line="209"/>
<source>Device is removed</source>
<translation>Устройство удалено</translation>
</message>
<message>
- <location filename="../tinymounttray.cpp" line="205"/>
+ <location filename="../tinymounttray.cpp" line="210"/>
<source>Device %1 is removed</source>
<translation>Устройство %1 удалено</translation>
</message>
<message>
- <location filename="../tinymounttray.cpp" line="238"/>
+ <location filename="../tinymounttray.cpp" line="243"/>
<source>Device is mounted</source>
<translation>Устройство смонтировано</translation>
</message>
<message>
- <location filename="../tinymounttray.cpp" line="239"/>
+ <location filename="../tinymounttray.cpp" line="244"/>
<source>%1 is mounted to %2.</source>
<translation>%1 смонтирован в %2.</translation>
</message>
<message>
- <location filename="../tinymounttray.cpp" line="245"/>
+ <location filename="../tinymounttray.cpp" line="250"/>
<source>%1 mounting error. %2.</source>
<translation>Не могу смонтировать %1. %2.</translation>
</message>
<message>
- <location filename="../tinymounttray.cpp" line="258"/>
+ <location filename="../tinymounttray.cpp" line="263"/>
<source>%1 is unmounted successfuly.</source>
<translation>%1 успешно отмонтирован.</translation>
</message>
<message>
- <location filename="../tinymounttray.cpp" line="264"/>
+ <location filename="../tinymounttray.cpp" line="269"/>
<source>Failed to unmount %1. %2.</source>
<translation>Не могу отмонтировать %1. %2.</translation>
</message>
<message>
- <location filename="../tinymounttray.cpp" line="244"/>
+ <location filename="../tinymounttray.cpp" line="249"/>
<source>Mount failed</source>
<translation>Ошибка монтирования</translation>
</message>
<message>
- <location filename="../tinymounttray.cpp" line="179"/>
+ <location filename="../tinymounttray.cpp" line="182"/>
<source>Settings</source>
<translation>Настройки</translation>
</message>
<message>
- <location filename="../tinymounttray.cpp" line="257"/>
+ <location filename="../tinymounttray.cpp" line="262"/>
<source>Device is unmounted</source>
<translation>Устройство отмонтировано</translation>
</message>
<message>
- <location filename="../tinymounttray.cpp" line="263"/>
+ <location filename="../tinymounttray.cpp" line="268"/>
<source>Unmount failed</source>
<translation>Ошибка размонтирования</translation>
</message>
<message>
- <location filename="../tinymounttray.cpp" line="272"/>
+ <location filename="../tinymounttray.cpp" line="277"/>
<source>Copyright (c) 2012 Mike Limansky
Use and redistribute under terms of the GNU General Public License Version 2.</source>

0 comments on commit c1e7603

Please sign in to comment.