message context menu began, open and show in folder features
This commit is contained in:
parent
f34289399e
commit
d514db9c4a
7 changed files with 108 additions and 6 deletions
|
@ -46,3 +46,40 @@ QString Shared::processMessageBody(const QString& msg)
|
|||
processed.replace(urlReg, "<a href=\"\\1\">\\1</a>");
|
||||
return "<p style=\"white-space: pre-wrap;\">" + processed + "</p>";
|
||||
}
|
||||
|
||||
static const QStringList query = {"query", "default", "inode/directory"};
|
||||
static const QRegularExpression dolphinReg("[Dd]olphin");
|
||||
static const QRegularExpression nautilusReg("[Nn]autilus");
|
||||
static const QRegularExpression cajaReg("[Cc]aja");
|
||||
static const QRegularExpression nemoReg("[Nn]emo");
|
||||
static const QRegularExpression konquerorReg("kfmclient");
|
||||
|
||||
void Shared::showInDirectory(const QString& path)
|
||||
{
|
||||
QFileInfo info = path;
|
||||
if (info.exists()) {
|
||||
QProcess proc;
|
||||
proc.start("xdg-mime", query);
|
||||
proc.waitForFinished();
|
||||
QString output = proc.readLine().simplified();
|
||||
if (output.contains(dolphinReg)) {
|
||||
proc.startDetached("dolphin", QStringList() << "--select" << info.canonicalFilePath());
|
||||
} else if (output.contains(nautilusReg)) {
|
||||
proc.startDetached("nautilus", QStringList() << "--no-desktop" << info.canonicalFilePath());
|
||||
} else if (output.contains(cajaReg)) {
|
||||
proc.startDetached("caja", QStringList() << "--no-desktop" << info.canonicalFilePath());
|
||||
} else if (output.contains(nemoReg)) {
|
||||
proc.startDetached("nemo", QStringList() << "--no-desktop" << info.canonicalFilePath());
|
||||
} else if (output.contains(konquerorReg)) {
|
||||
proc.startDetached("konqueror", QStringList() << "--select" << info.canonicalFilePath());
|
||||
} else {
|
||||
QString folder;
|
||||
if (info.isDir()) {
|
||||
folder = info.canonicalFilePath();
|
||||
} else {
|
||||
folder = info.canonicalPath();
|
||||
}
|
||||
QDesktopServices::openUrl(QUrl::fromLocalFile(folder));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,8 +20,13 @@
|
|||
#define SHARED_UTILS_H
|
||||
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include <QColor>
|
||||
#include <QRegularExpression>
|
||||
#include <QFileInfo>
|
||||
#include <QProcess>
|
||||
#include <QDesktopServices>
|
||||
#include <QUrl>
|
||||
|
||||
#include <uuid/uuid.h>
|
||||
#include <vector>
|
||||
|
@ -30,6 +35,7 @@ namespace Shared {
|
|||
|
||||
QString generateUUID();
|
||||
QString processMessageBody(const QString& msg);
|
||||
void showInDirectory(const QString& path);
|
||||
|
||||
static const std::vector<QColor> colorPalette = {
|
||||
QColor(244, 27, 63),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue