1
0
forked from blue/squawk

highlight in directory now is optional runtime plugin to KIO, several more file managers to fallback, refactor, 2 new icons

This commit is contained in:
Blue 2021-05-06 17:44:43 +03:00
parent d514db9c4a
commit ebf0c64ffb
23 changed files with 289 additions and 51 deletions

View File

@ -6,10 +6,14 @@
- requesting the history of the current chat after reconnection
- global availability (in drop down list) gets restored after reconnection
- status icon in active chat changes when presence of the pen pal changes
- infinite progress when open the dialogue with something that has no history to show
### Improvements
- slightly reduced the traffic on the startup by not requesting history of all MUCs
- completely rewritten message feed, now it works way faster
- OPTIONAL RUNTIME dependency: "KIO Widgets" that is supposed to allow you to open a file in your default file manager
- show in folder now is supposed to try it's best to show file in folder, even you don't have KIO installed
- once uploaded local files don't get second time uploaded - the remote URL is reused
## Squawk 0.1.5 (Jul 29, 2020)
### Bug fixes

View File

@ -67,6 +67,7 @@ qt5_add_resources(RCC resources/resources.qrc)
option(SYSTEM_QXMPP "Use system qxmpp lib" ON)
option(WITH_KWALLET "Build KWallet support module" ON)
option(WITH_KIO "Build KIO support module" ON)
if (SYSTEM_QXMPP)
find_package(QXmpp CONFIG)
@ -98,8 +99,21 @@ endif()
add_executable(squawk ${squawk_SRC} ${squawk_HEAD} ${RCC})
target_link_libraries(squawk Qt5::Widgets)
if (WITH_KIO)
find_package(KF5KIO CONFIG)
if (NOT KF5KIO_FOUND)
set(WITH_KIO OFF)
message("KIO package wasn't found, KIO support modules wouldn't be built")
else()
add_definitions(-DWITH_KIO)
message("Building with support of KIO")
endif()
endif()
add_subdirectory(ui)
add_subdirectory(core)
add_subdirectory(plugins)
add_subdirectory(external/simpleCrypt)
@ -107,6 +121,8 @@ target_link_libraries(squawk squawkUI)
target_link_libraries(squawk squawkCORE)
target_link_libraries(squawk uuid)
add_dependencies(${CMAKE_PROJECT_NAME} translations)
# Install the executable

View File

@ -67,6 +67,7 @@ Here is the list of keys you can pass to configuration phase of `cmake ..`.
- `CMAKE_BUILD_TYPE` - `Debug` just builds showing all warnings, `Release` builds with no warnings and applies optimizations (default is `Debug`)
- `SYSTEM_QXMPP` - `True` tries to link against `qxmpp` installed in the system, `False` builds bundled `qxmpp` library (default is `True`)
- `WITH_KWALLET` - `True` builds the `KWallet` capability module if `KWallet` is installed and if not goes to `False`. `False` disables `KWallet` support (default is `True`)
- `WITH_KIO` - `True` builds the `KIO` capability module if `KIO` is installed and if not goes to `False`. `False` disables `KIO` support (default is `True`)
## License

View File

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 3.3)
project(pse)
if (WITH_KWALLET)

26
plugins/CMakeLists.txt Normal file
View File

@ -0,0 +1,26 @@
cmake_minimum_required(VERSION 3.3)
project(plugins)
if (WITH_KIO)
set(CMAKE_AUTOMOC ON)
find_package(Qt5Core CONFIG REQUIRED)
set(openFileManagerWindowJob_SRC
openfilemanagerwindowjob.cpp
)
add_library(openFileManagerWindowJob SHARED ${openFileManagerWindowJob_SRC})
get_target_property(Qt5CORE_INTERFACE_INCLUDE_DIRECTORIES Qt5::Core INTERFACE_INCLUDE_DIRECTORIES)
get_target_property(KIO_WIDGETS_INTERFACE_INCLUDE_DIRECTORIES KF5::KIOWidgets INTERFACE_INCLUDE_DIRECTORIES)
get_target_property(CORE_ADDONS_INTERFACE_INCLUDE_DIRECTORIES KF5::CoreAddons INTERFACE_INCLUDE_DIRECTORIES)
target_include_directories(openFileManagerWindowJob PUBLIC ${KIO_WIDGETS_INTERFACE_INCLUDE_DIRECTORIES})
target_include_directories(openFileManagerWindowJob PUBLIC ${CORE_ADDONS_INTERFACE_INCLUDE_DIRECTORIES})
target_include_directories(openFileManagerWindowJob PUBLIC ${Qt5CORE_INTERFACE_INCLUDE_DIRECTORIES})
target_link_libraries(openFileManagerWindowJob KF5::KIOWidgets)
target_link_libraries(openFileManagerWindowJob Qt5::Core)
install(TARGETS openFileManagerWindowJob DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()

View File

@ -0,0 +1,8 @@
#include <QUrl>
#include <QObject>
#include <KIO/OpenFileManagerWindowJob>
extern "C" void highlightInFileManager(const QUrl& url) {
KIO::OpenFileManagerWindowJob* job = KIO::highlightInFileManager({url});
QObject::connect(job, &KIO::OpenFileManagerWindowJob::result, job, &KIO::OpenFileManagerWindowJob::deleteLater);
}

View File

@ -0,0 +1,11 @@
<!DOCTYPE svg>
<svg viewBox="0 0 22 22" version="1.1" xmlns="http://www.w3.org/2000/svg">
<defs>
<style type="text/css" id="current-color-scheme">
.ColorScheme-Text {
color:#232629;
}
</style>
</defs>
<path class="ColorScheme-Text" style="fill:currentColor; fill-opacity:1; stroke:none" d="M 4 3 L 4 19 L 15 19 L 15 18 L 5 18 L 5 4 L 13 4 L 13 8 L 17 8 L 17 16 L 18 16 L 18 7 L 14 3 L 4 3 Z M 13 11 C 11.338 11 10 12.338 10 14 C 10 15.662 11.338 17 13 17 C 13.6494 17 14.2464 16.7914 14.7363 16.4434 L 17.293 19 L 18 18.293 L 15.4434 15.7363 C 15.7914 15.2464 16 14.6494 16 14 C 16 12.338 14.662 11 13 11 Z M 13 12 C 14.108 12 15 12.892 15 14 C 15 15.108 14.108 16 13 16 C 11.892 16 11 15.108 11 14 C 11 12.892 11.892 12 13 12 Z"/>
</svg>

After

Width:  |  Height:  |  Size: 807 B

View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg width="32" version="1.1" xmlns="http://www.w3.org/2000/svg" height="32" viewBox="0 0 32 32" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape">
<defs id="defs5455">
<linearGradient inkscape:collect="always" id="linearGradient4172-5">
<stop style="stop-color:#3daee9" id="stop4174-6"/>
<stop offset="1" style="stop-color:#6cc1ef" id="stop4176-6"/>
</linearGradient>
<linearGradient inkscape:collect="always" xlink:href="#linearGradient4172-5" id="linearGradient4342" y1="29" y2="8" x2="0" gradientUnits="userSpaceOnUse"/>
</defs>
<metadata id="metadata5458"/>
<g inkscape:label="Capa 1" inkscape:groupmode="layer" id="layer1" transform="matrix(1 0 0 1 -384.57143 -515.798)">
<path inkscape:connector-curvature="0" style="fill:#147eb8;fill-rule:evenodd" id="path4308" d="m 386.57144,518.798 0,7 0,1 28,0 0,-6 -14.00001,0 -2,-2 z"/>
<path inkscape:connector-curvature="0" style="fill-opacity:0.235294;fill-rule:evenodd" id="path4306" d="m 397.57143,523.798 -1.99999,1 -9,0 0,1 6.99999,0 3,0 z"/>
<path style="fill:url(#linearGradient4342)" id="rect4294" d="M 13 8 L 11 10 L 2 10 L 1 10 L 1 29 L 12 29 L 13 29 L 31 29 L 31 8 L 13 8 z " transform="matrix(1 0 0 1 384.57143 515.798)"/>
<path inkscape:connector-curvature="0" style="fill:#ffffff;fill-opacity:0.235294;fill-rule:evenodd" id="path4304" d="m 397.57143,523.798 -2,2 -10,0 0,1 11,0 z"/>
<path inkscape:connector-curvature="0" style="fill:#ffffff;fill-opacity:0.235294;fill-rule:evenodd" id="path4310" d="m 398.57143,518.798 1,3 15.00001,0 0,-1 -14.00001,0 z"/>
<rect width="30" x="385.57144" y="543.79797" height="1" style="fill-opacity:0.235294" id="rect4292"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -0,0 +1,12 @@
<!DOCTYPE svg>
<svg viewBox="0 0 16 16" version="1.1" xmlns="http://www.w3.org/2000/svg">
<defs>
<style type="text/css" id="current-color-scheme">
.ColorScheme-Text {
color:#232629;
}
</style>
</defs>
<path class="ColorScheme-Text" style="fill:currentColor; fill-opacity:1; stroke:none" d="M 3 2 L 3 14 L 10 14 L 10 13 L 4 13 L 4 3 L 9 3 L 9 6 L 12 6 L 12 11 L 13 11 L 13 5 L 10 2 L 3 2 Z"/>
<path class="ColorScheme-Text" style="fill:currentColor; fill-opacity:1; stroke:none" d="M 8.48828 7 C 7.10757 7 5.98828 8.11929 5.98828 9.5 C 5.98828 10.8807 7.10757 12 8.48828 12 C 8.97811 11.9992 9.45691 11.8546 9.86523 11.584 L 12.2813 14 L 12.9883 13.293 L 10.5723 10.877 C 10.8428 10.4686 10.9875 9.98983 10.9883 9.5 C 10.9883 8.11929 9.86899 7 8.48828 7 Z M 8.48828 8 C 9.31671 8 9.98828 8.67157 9.98828 9.5 C 9.98828 10.3284 9.31671 11 8.48828 11 C 7.65985 11 6.98828 10.3284 6.98828 9.5 C 6.98828 8.67157 7.65985 8 8.48828 8 Z"/>
</svg>

After

Width:  |  Height:  |  Size: 1010 B

View File

@ -0,0 +1,13 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16">
<defs id="defs3051">
<style type="text/css" id="current-color-scheme">
.ColorScheme-Text {
color:#232629;
}
</style>
</defs>
<path style="fill:currentColor;fill-opacity:1;stroke:none"
d="M 2 2 L 2 3 L 2 6 L 2 7 L 2 13 L 2 14 L 14 14 L 14 13 L 14 6 L 14 5 L 14 4 L 9.0078125 4 L 7.0078125 2 L 7 2.0078125 L 7 2 L 3 2 L 2 2 z M 3 3 L 6.5917969 3 L 7.59375 4 L 7 4 L 7 4.0078125 L 6.9921875 4 L 4.9921875 6 L 3 6 L 3 3 z M 3 7 L 13 7 L 13 13 L 3 13 L 3 7 z "
class="ColorScheme-Text"
/>
</svg>

After

Width:  |  Height:  |  Size: 609 B

View File

@ -0,0 +1,11 @@
<!DOCTYPE svg>
<svg viewBox="0 0 22 22" version="1.1" xmlns="http://www.w3.org/2000/svg">
<defs>
<style type="text/css" id="current-color-scheme">
.ColorScheme-Text {
color:#eff0f1;
}
</style>
</defs>
<path class="ColorScheme-Text" style="fill:currentColor; fill-opacity:1; stroke:none" d="M 4 3 L 4 19 L 15 19 L 15 18 L 5 18 L 5 4 L 13 4 L 13 8 L 17 8 L 17 16 L 18 16 L 18 7 L 14 3 L 4 3 Z M 13 11 C 11.338 11 10 12.338 10 14 C 10 15.662 11.338 17 13 17 C 13.6494 17 14.2464 16.7914 14.7363 16.4434 L 17.293 19 L 18 18.293 L 15.4434 15.7363 C 15.7914 15.2464 16 14.6494 16 14 C 16 12.338 14.662 11 13 11 Z M 13 12 C 14.108 12 15 12.892 15 14 C 15 15.108 14.108 16 13 16 C 11.892 16 11 15.108 11 14 C 11 12.892 11.892 12 13 12 Z"/>
</svg>

After

Width:  |  Height:  |  Size: 807 B

View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg width="32" version="1.1" xmlns="http://www.w3.org/2000/svg" height="32" viewBox="0 0 32 32" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape">
<defs id="defs5455">
<linearGradient inkscape:collect="always" id="linearGradient4172-5">
<stop style="stop-color:#3daee9" id="stop4174-6"/>
<stop offset="1" style="stop-color:#6cc1ef" id="stop4176-6"/>
</linearGradient>
<linearGradient inkscape:collect="always" xlink:href="#linearGradient4172-5" id="linearGradient4342" y1="29" y2="8" x2="0" gradientUnits="userSpaceOnUse"/>
</defs>
<metadata id="metadata5458"/>
<g inkscape:label="Capa 1" inkscape:groupmode="layer" id="layer1" transform="matrix(1 0 0 1 -384.57143 -515.798)">
<path inkscape:connector-curvature="0" style="fill:#147eb8;fill-rule:evenodd" id="path4308" d="m 386.57144,518.798 0,7 0,1 28,0 0,-6 -14.00001,0 -2,-2 z"/>
<path inkscape:connector-curvature="0" style="fill-opacity:0.235294;fill-rule:evenodd" id="path4306" d="m 397.57143,523.798 -1.99999,1 -9,0 0,1 6.99999,0 3,0 z"/>
<path style="fill:url(#linearGradient4342)" id="rect4294" d="M 13 8 L 11 10 L 2 10 L 1 10 L 1 29 L 12 29 L 13 29 L 31 29 L 31 8 L 13 8 z " transform="matrix(1 0 0 1 384.57143 515.798)"/>
<path inkscape:connector-curvature="0" style="fill:#ffffff;fill-opacity:0.235294;fill-rule:evenodd" id="path4304" d="m 397.57143,523.798 -2,2 -10,0 0,1 11,0 z"/>
<path inkscape:connector-curvature="0" style="fill:#ffffff;fill-opacity:0.235294;fill-rule:evenodd" id="path4310" d="m 398.57143,518.798 1,3 15.00001,0 0,-1 -14.00001,0 z"/>
<rect width="30" x="385.57144" y="543.79797" height="1" style="fill-opacity:0.235294" id="rect4292"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -0,0 +1,12 @@
<!DOCTYPE svg>
<svg viewBox="0 0 16 16" version="1.1" xmlns="http://www.w3.org/2000/svg">
<defs>
<style type="text/css" id="current-color-scheme">
.ColorScheme-Text {
color:#eff0f1;
}
</style>
</defs>
<path class="ColorScheme-Text" style="fill:currentColor; fill-opacity:1; stroke:none" d="M 3 2 L 3 14 L 10 14 L 10 13 L 4 13 L 4 3 L 9 3 L 9 6 L 12 6 L 12 11 L 13 11 L 13 5 L 10 2 L 3 2 Z"/>
<path class="ColorScheme-Text" style="fill:currentColor; fill-opacity:1; stroke:none" d="M 8.48828 7 C 7.10757 7 5.98828 8.11929 5.98828 9.5 C 5.98828 10.8807 7.10757 12 8.48828 12 C 8.97811 11.9992 9.45691 11.8546 9.86523 11.584 L 12.2813 14 L 12.9883 13.293 L 10.5723 10.877 C 10.8428 10.4686 10.9875 9.98983 10.9883 9.5 C 10.9883 8.11929 9.86899 7 8.48828 7 Z M 8.48828 8 C 9.31671 8 9.98828 8.67157 9.98828 9.5 C 9.98828 10.3284 9.31671 11 8.48828 11 C 7.65985 11 6.98828 10.3284 6.98828 9.5 C 6.98828 8.67157 7.65985 8 8.48828 8 Z"/>
</svg>

After

Width:  |  Height:  |  Size: 1010 B

View File

@ -0,0 +1,13 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16">
<defs id="defs3051">
<style type="text/css" id="current-color-scheme">
.ColorScheme-Text {
color:#eff0f1;
}
</style>
</defs>
<path style="fill:currentColor;fill-opacity:1;stroke:none"
d="M 2 2 L 2 3 L 2 6 L 2 7 L 2 13 L 2 14 L 14 14 L 14 13 L 14 6 L 14 5 L 14 4 L 9.0078125 4 L 7.0078125 2 L 7 2.0078125 L 7 2 L 3 2 L 2 2 z M 3 3 L 6.5917969 3 L 7.59375 4 L 7 4 L 7 4.0078125 L 6.9921875 4 L 4.9921875 6 L 3 6 L 3 3 z M 3 7 L 13 7 L 13 13 L 3 13 L 3 7 z "
class="ColorScheme-Text"
/>
</svg>

After

Width:  |  Height:  |  Size: 609 B

View File

@ -40,6 +40,8 @@
<file>images/fallback/dark/big/favorite.svg</file>
<file>images/fallback/dark/big/unfavorite.svg</file>
<file>images/fallback/dark/big/add.svg</file>
<file>images/fallback/dark/big/folder.svg</file>
<file>images/fallback/dark/big/document-preview.svg</file>
<file>images/fallback/dark/small/absent.svg</file>
@ -80,6 +82,8 @@
<file>images/fallback/dark/small/favorite.svg</file>
<file>images/fallback/dark/small/unfavorite.svg</file>
<file>images/fallback/dark/small/add.svg</file>
<file>images/fallback/dark/small/folder.svg</file>
<file>images/fallback/dark/small/document-preview.svg</file>
<file>images/fallback/light/big/absent.svg</file>
@ -120,6 +124,8 @@
<file>images/fallback/light/big/favorite.svg</file>
<file>images/fallback/light/big/unfavorite.svg</file>
<file>images/fallback/light/big/add.svg</file>
<file>images/fallback/light/big/folder.svg</file>
<file>images/fallback/light/big/document-preview.svg</file>
<file>images/fallback/light/small/absent.svg</file>
@ -160,5 +166,7 @@
<file>images/fallback/light/small/favorite.svg</file>
<file>images/fallback/light/small/unfavorite.svg</file>
<file>images/fallback/light/small/add.svg</file>
<file>images/fallback/light/small/folder.svg</file>
<file>images/fallback/light/small/document-preview.svg</file>
</qresource>
</RCC>

View File

@ -23,6 +23,11 @@
Shared::Global* Shared::Global::instance = 0;
const std::set<QString> Shared::Global::supportedImagesExts = {"png", "jpg", "webp", "jpeg", "gif", "svg"};
#ifdef WITH_KIO
QLibrary Shared::Global::openFileManagerWindowJob("openFileManagerWindowJob");
Shared::Global::HighlightInFileManager Shared::Global::hfm = 0;
#endif
Shared::Global::Global():
availability({
tr("Online", "Availability"),
@ -80,7 +85,8 @@ Shared::Global::Global():
tr("Your password is going to be stored in KDE wallet storage (KWallet). You're going to be queried for permissions", "AccountPasswordDescription")
}),
pluginSupport({
{"KWallet", false}
{"KWallet", false},
{"openFileManagerWindowJob", false}
}),
fileCache()
{
@ -89,6 +95,21 @@ Shared::Global::Global():
}
instance = this;
#ifdef WITH_KIO
openFileManagerWindowJob.load();
if (openFileManagerWindowJob.isLoaded()) {
hfm = (HighlightInFileManager) openFileManagerWindowJob.resolve("highlightInFileManager");
if (hfm) {
setSupported("openFileManagerWindowJob", true);
qDebug() << "KIO::OpenFileManagerWindow support enabled";
} else {
qDebug() << "KIO::OpenFileManagerWindow support disabled: couldn't resolve required methods in the library";
}
} else {
qDebug() << "KIO::OpenFileManagerWindow support disabled: couldn't load the library" << openFileManagerWindowJob.errorString();
}
#endif
}
Shared::Global::FileInfo Shared::Global::getFileInfo(const QString& path)
@ -181,6 +202,69 @@ QString Shared::Global::getDescription(Shared::AccountPassword ap)
return instance->accountPasswordDescription[static_cast<int>(ap)];
}
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");
static const QRegularExpression pcmanfmQtReg("pcmanfm-qt");
static const QRegularExpression pcmanfmReg("pcmanfm");
static const QRegularExpression thunarReg("thunar");
void Shared::Global::highlightInFileManager(const QString& path)
{
#ifdef WITH_KIO
if (supported("openFileManagerWindowJob")) {
hfm(path);
return;
} else {
qDebug() << "requested to highlight in file manager url" << path << "but it's not supported: KIO plugin isn't loaded, trying fallback";
}
#else
qDebug() << "requested to highlight in file manager url" << path << "but it's not supported: squawk wasn't compiled to support it, trying fallback";
#endif
QFileInfo info = path;
if (info.exists()) {
QProcess proc;
proc.start("xdg-mime", query);
proc.waitForFinished();
QString output = proc.readLine().simplified();
QString folder;
if (info.isDir()) {
folder = info.canonicalFilePath();
} else {
folder = info.canonicalPath();
}
if (output.contains(dolphinReg)) {
//there is a bug on current (21.04.0) dolphin, it works correct only if you already have dolphin launched
proc.startDetached("dolphin", QStringList() << "--select" << info.canonicalFilePath());
//KIO::highlightInFileManager({QUrl(info.canonicalFilePath())});
} else if (output.contains(nautilusReg)) {
proc.startDetached("nautilus", QStringList() << "--select" << info.canonicalFilePath()); //this worked on nautilus
} else if (output.contains(cajaReg)) {
proc.startDetached("caja", QStringList() << folder); //caja doesn't seem to support file selection command line, gonna just open directory
} else if (output.contains(nemoReg)) {
proc.startDetached("nemo", QStringList() << info.canonicalFilePath()); //nemo supports selecting files without keys
} else if (output.contains(konquerorReg)) {
proc.startDetached("konqueror", QStringList() << "--select" << info.canonicalFilePath()); //this worked on konqueror
} else if (output.contains(pcmanfmQtReg)) {
proc.startDetached("pcmanfm-qt", QStringList() << folder); //pcmanfm-qt doesn't seem to support open with selection, gonna just open directory
} else if (output.contains(pcmanfmReg)) {
proc.startDetached("pcmanfm", QStringList() << folder); //pcmanfm also doesn't seem to support open with selection, gonna just open directory
} else if (output.contains(thunarReg)) {
proc.startDetached("thunar", QStringList() << folder); //thunar doesn't seem to support open with selection, gonna just open directory
} else {
QDesktopServices::openUrl(QUrl::fromLocalFile(folder));
}
}
}
#define FROM_INT_INPL(Enum) \
template<> \
Enum Shared::Global::fromInt(int src) \

View File

@ -34,6 +34,12 @@
#include <QFileInfo>
#include <QImage>
#include <QSize>
#include <QUrl>
#include <QLibrary>
#include <QFileInfo>
#include <QProcess>
#include <QDesktopServices>
#include <QRegularExpression>
namespace Shared {
@ -83,6 +89,7 @@ namespace Shared {
static const std::set<QString> supportedImagesExts;
static FileInfo getFileInfo(const QString& path);
static void highlightInFileManager(const QString& path);
template<typename T>
static T fromInt(int src);
@ -108,6 +115,14 @@ namespace Shared {
std::map<QString, bool> pluginSupport;
std::map<QString, FileInfo> fileCache;
#ifdef WITH_KIO
static QLibrary openFileManagerWindowJob;
typedef void (*HighlightInFileManager)(const QUrl &);
static HighlightInFileManager hfm;
#endif
};
}

View File

@ -170,6 +170,8 @@ static const std::map<QString, std::pair<QString, QString>> icons = {
{"favorite", {"favorite", "favorite"}},
{"unfavorite", {"draw-star", "unfavorite"}},
{"list-add", {"list-add", "add"}},
{"folder", {"folder", "folder"}},
{"document-preview", {"document-preview", "document-preview"}}
};
}

View File

@ -46,40 +46,3 @@ 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));
}
}
}

View File

@ -23,10 +23,8 @@
#include <QStringList>
#include <QColor>
#include <QRegularExpression>
#include <QFileInfo>
#include <QProcess>
#include <QDesktopServices>
#include <QUrl>
//#include "KIO/OpenFileManagerWindowJob"
#include <uuid/uuid.h>
#include <vector>
@ -35,7 +33,6 @@ namespace Shared {
QString generateUUID();
QString processMessageBody(const QString& msg);
void showInDirectory(const QString& path);
static const std::vector<QColor> colorPalette = {
QColor(244, 27, 63),

View File

@ -25,7 +25,7 @@ set(squawkUIUtils_SRC
)
# Tell CMake to create the helloworld executable
add_library(squawkUIUtils ${squawkUIUtils_SRC})
add_library(squawkUIUtils STATIC ${squawkUIUtils_SRC})
# Use the Widgets module from Qt 5.
target_link_libraries(squawkUIUtils squawkWidgets)

View File

@ -21,7 +21,7 @@ set(squawkWidgets_SRC
joinconference.cpp
)
add_library(squawkWidgets ${squawkWidgets_SRC})
add_library(squawkWidgets STATIC ${squawkWidgets_SRC})
# Use the Widgets module from Qt 5.
target_link_libraries(squawkWidgets vCardUI)

View File

@ -417,14 +417,14 @@ void Conversation::onFeedContext(const QPoint& pos)
QString path = item->getAttachPath();
if (path.size() > 0) {
showMenu = true;
QAction* open = contextMenu->addAction(Shared::icon("document-new-from-template"), tr("Open"));
QAction* open = contextMenu->addAction(Shared::icon("document-preview"), tr("Open"));
connect(open, &QAction::triggered, [path]() {
QDesktopServices::openUrl(QUrl::fromLocalFile(path));
});
QAction* show = contextMenu->addAction(Shared::icon("document-new-from-template"), tr("Show in folder"));
QAction* show = contextMenu->addAction(Shared::icon("folder"), tr("Show in folder"));
connect(show, &QAction::triggered, [path]() {
Shared::showInDirectory(path);
Shared::Global::highlightInFileManager(path);
});
}