Skip to content

Commit

Permalink
Merge pull request #57 from rodlie/master
Browse files Browse the repository at this point in the history
tray fixes
  • Loading branch information
rodlie authored Aug 3, 2018
2 parents 41913c1 + 4b000dd commit f80b5bf
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
[![GitHub release](https://img.shields.io/github/release/rodlie/qtfm.svg)](https://github.com/rodlie/qtfm/releases)
[![Github commits (since latest release)](https://img.shields.io/github/commits-since/rodlie/qtfm/latest.svg)](https://github.com/rodlie/qtfm)
[![Build Status](https://travis-ci.org/rodlie/qtfm.svg?branch=master)](https://travis-ci.org/rodlie/qtfm)
[![Github All Releases](https://img.shields.io/github/downloads/rodlie/qtfm/total.svg)](https://github.com/rodlie/qtfm/releases)

![screenshot1](fm/images/screenshot.png)

Expand Down Expand Up @@ -73,14 +72,15 @@ Download the latest [release](https://github.com/rodlie/qtfm/releases), then mak

Download and extract:
```
tar xvf qtfm-VERSION.tar.gz
tar xvf qtfm-6.1.x.tar.gz
cd qtfm-VERSION
```

Or use git:
```
git clone https://github.com/rodlie/qtfm
cd qtfm
git checkout 6.1
```

Now you just need to build it:
Expand Down
20 changes: 16 additions & 4 deletions tray/systray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ void SysTray::disktrayActivated(QSystemTrayIcon::ActivationReason reason)
case QSystemTrayIcon::Context:
case QSystemTrayIcon::Trigger:
if (menu->actions().size()>0) { menu->popup(QCursor::pos()); }
break;
default:;
}
}
Expand Down Expand Up @@ -172,31 +173,38 @@ void SysTray::handleDeviceMediaChanged(QString path, bool media)
else if (isAudio) { opticalType = QObject::tr("audio"); }
showMessage(QObject::tr("%1 has media").arg(man->devices[path]->name), QObject::tr("Detected %1 media in %2").arg(opticalType).arg(man->devices[path]->name));

bool openMedia = false;
// auto mount if enabled
if (Common::readSetting("trayAutoMount").toBool() && isData) {
qDebug() << "auto mount optical";
man->devices[path]->mount();
openMountpoint(man->devices[path]->mountpoint);
generateContextMenu();
openMedia = true;
}
// auto play CD if enabled
if (Common::readSetting("autoPlayAudioCD").toBool() && isAudio) {
openMedia = false;
QStringList apps = mimeUtilsPtr->getDefault("x-content/audio-cdda");
QString desktop = Common::findApplication(qApp->applicationFilePath(), apps.at(0));
if (desktop.isEmpty()) { return; }
DesktopFile df(desktop);
QString app = df.getExec().split(" ").takeFirst();
if (app.isEmpty()) { return; }
QProcess::startDetached(QString("%1 cdda://%2").arg(app).arg(man->devices[path]->name));
QProcess::startDetached(QString("%1 cdda://%2").arg(app).arg(man->devices[path]->mountpoint));
}
// auto play DVD if enabled
if (Common::readSetting("autoPlayDVD").toBool() && isData) {
if (man->devices[path]->mountpoint.isEmpty()) {
man->devices[path]->mount();
}
openMedia = false;
QDir tsVideo(QString("%1/video_ts").arg(man->devices[path]->mountpoint));
QDir tsAudio(QString("%1/audio_ts").arg(man->devices[path]->mountpoint));

if (!tsVideo.exists()) {
tsVideo.setPath(QString("%1/VIDEO_TS").arg(man->devices[path]->mountpoint));
}
if (!tsAudio.exists()) {
tsAudio.setPath(QString("%1/AUDIO_TS").arg(man->devices[path]->mountpoint));
}
QString desktop;
if (tsVideo.exists()) {
QStringList apps = mimeUtilsPtr->getDefault("x-content/video-dvd");
Expand All @@ -218,6 +226,10 @@ void SysTray::handleDeviceMediaChanged(QString path, bool media)
QProcess::startDetached(QString("%1 dvd://%2").arg(app).arg(man->devices[path]->mountpoint));
}
}
if (openMedia) {
openMountpoint(man->devices[path]->mountpoint);
}
generateContextMenu();
}
}

Expand Down

0 comments on commit f80b5bf

Please sign in to comment.