Skip to content

Commit

Permalink
libDraco+libQtFM #43
Browse files Browse the repository at this point in the history
  • Loading branch information
rodlie committed May 11, 2020
1 parent 9390ec2 commit dae14c5
Show file tree
Hide file tree
Showing 18 changed files with 181 additions and 119 deletions.
62 changes: 62 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ set(
STRING
"group that have access to powerd service, this should be all desktop users."
)
set(ENABLE_MAGICK false CACHE BOOL "Enable support for ImageMagick")
set(ENABLE_FFMPEG false CACHE BOOL "Enable support for FFmpeg v3")

add_definitions(-DDESKTOP_APP="${PROJECT_NAME}")
add_definitions(-DDESKTOP_APP_NAME="${LIB_NAME}")
Expand All @@ -76,6 +78,22 @@ else()
endif()
add_compile_options(-Wall -Wextra)

# magick
if(ENABLE_MAGICK)
add_definitions(-DWITH_MAGICK)
find_package(PkgConfig REQUIRED)
pkg_check_modules(MAGICK REQUIRED Magick++)
# ffmpeg
if(ENABLE_FFMPEG)
pkg_check_modules(AVDEVICE REQUIRED libavdevice)
pkg_check_modules(SWSCALE REQUIRED libswscale)
pkg_check_modules(AVFORMAT REQUIRED libavformat)
pkg_check_modules(AVCODEC REQUIRED libavcodec)
pkg_check_modules(AVUTIL REQUIRED libavutil)
add_definitions(-DWITH_FFMPEG)
endif()
endif()

# qt
find_package(Qt5 REQUIRED Core DBus Gui Widgets Concurrent X11Extras)

Expand Down Expand Up @@ -143,6 +161,29 @@ add_library(
src/lib/qtcopydialog/qtcopydialog.ui
src/lib/qtcopydialog/qtoverwritedialog.ui
src/lib/qtcopydialog/qtotherdialog.ui
src/files/qtfm/libfm/disks.cpp
src/files/qtfm/libfm/service.h
src/files/qtfm/libfm/udisks2.cpp
src/files/qtfm/libfm/applicationdialog.cpp
src/files/qtfm/libfm/bookmarkmodel.cpp
src/files/qtfm/libfm/common.cpp
src/files/qtfm/libfm/completer.cpp
src/files/qtfm/libfm/customactionsmanager.cpp
src/files/qtfm/libfm/desktopfile.cpp
src/files/qtfm/libfm/fileutils.cpp
src/files/qtfm/libfm/fm.cpp
src/files/qtfm/libfm/icondlg.cpp
src/files/qtfm/libfm/iconlist.cpp
src/files/qtfm/libfm/iconview.cpp
src/files/qtfm/libfm/mimeutils.cpp
src/files/qtfm/libfm/mymodel.cpp
src/files/qtfm/libfm/mymodelitem.cpp
src/files/qtfm/libfm/processdialog.cpp
src/files/qtfm/libfm/properties.cpp
src/files/qtfm/libfm/propertiesdlg.cpp
src/files/qtfm/libfm/sortmodel.cpp
src/files/qtfm/libfm/dfmqtreeview.cpp
src/files/qtfm/libfm/dfmqstyleditemdelegate.cpp
share/share.qrc
)
set_target_properties(
Expand All @@ -164,6 +205,7 @@ target_include_directories(
src/lib/lumina
src/lib/qtcopydialog
src/lib/hotkey
src/files/qtfm/libfm
)
if(${CMAKE_VERSION} VERSION_LESS "3.14.3")
set(XSS_INCLUDE ${X11_Xscreensaver_INCLUDE_PATH})
Expand Down Expand Up @@ -198,6 +240,24 @@ target_link_libraries(
Qt5::Concurrent
Qt5::X11Extras
)

if(ENABLE_MAGICK)
target_compile_definitions(${LIB_NAME} PRIVATE ${MAGICK_CFLAGS_OTHER})
target_link_libraries(${LIB_NAME} ${MAGICK_LIBRARIES})
if(ENABLE_FFMPEG)
target_include_directories(${LIB_NAME
PRIVATE
${MAGICK_INCLUDEDIR}
${AVUTIL_INCLUDEDIR})
target_link_libraries(${LIB_NAME
${AVDEVICE_LIBRARIES}
${SWSCALE_LIBRARIES}
${AVFORMAT_LIBRARIES}
${AVCODEC_LIBRARIES}
${AVUTIL_LIBRARIES})
endif()
endif()

if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(LIB_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR})
else()
Expand Down Expand Up @@ -247,6 +307,7 @@ target_include_directories(
src/lib/lumina
src/lib/hotkey
src/lib/qtcopydialog
src/files/qtfm/libfm
)
target_link_libraries(
${DESKTOP_SERVICE_NAME}
Expand Down Expand Up @@ -311,6 +372,7 @@ target_include_directories(
PRIVATE
src/lib
src/lib/lumina
src/files/qtfm/libfm
)
target_link_libraries(
${STORAGE_SERVICE_NAME}
Expand Down
4 changes: 2 additions & 2 deletions src/desktop/LDesktop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ void LDesktop::UpdateMenu(bool fast)
}
}
XDGDesktop xdgf(df);
if (xdgf.type!=XDGDesktop::BAD) {
if (xdgf.type!=XDGDesktop::XDG_BAD) {
for (int x = 0; x < xdgf.actions.size(); ++x) {
XDGDesktopAction act = xdgf.actions.at(x);
if (act.ID == setting) {
Expand All @@ -470,7 +470,7 @@ void LDesktop::UpdateMenu(bool fast)
// Custom *.desktop application
QString file = items[i].section("::::",1,1).simplified();
XDGDesktop xdgf(file); // = LXDG::loadDesktopFile(file, ok);
if (xdgf.type!=XDGDesktop::BAD) {
if (xdgf.type!=XDGDesktop::XDG_BAD) {
deskMenu->addAction(LXDG::findIcon(xdgf.icon,""),
xdgf.name)->setWhatsThis(file);
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/lumina/LFileInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void LFileInfo::loadExtraInfo(){
}else if( this->suffix()=="desktop"){
mime = "application/x-desktop";
desk = new XDGDesktop(this->absoluteFilePath(), 0);
if(desk->type!=XDGDesktop::BAD){
if(desk->type!=XDGDesktop::XDG_BAD){
//use the specific desktop file info (if possible)
if(!desk->icon.isEmpty()){ iconList << desk->icon; }
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/lumina/LUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ QString LUtils::GenerateOpenTerminalExec(QString term, QString dirpath){
if(term.endsWith(".desktop")){
//Pull the binary name out of the shortcut
XDGDesktop DF(term);
if(DF.type == XDGDesktop::BAD){ term = "xterm"; }
if(DF.type == XDGDesktop::XDG_BAD){ term = "xterm"; }
else{ term= DF.exec.section(" ",0,0); } //only take the binary name - not any other flags
}else{
term = "xterm"; //fallback
Expand Down
36 changes: 18 additions & 18 deletions src/lib/lumina/LuminaXDG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ XDGDesktop::XDGDesktop(QString file, QObject *parent) : QObject(parent){
useTerminal=false;
startupNotify=false;
useVGL = false;
type = XDGDesktop::BAD;
type = XDGDesktop::XDG_BAD;
filePath = file;
exec = tryexec = ""; // just to make sure this is initialized
if(!filePath.isEmpty()){ sync(); } //if an input file is given - go ahead and sync now
Expand All @@ -90,15 +90,15 @@ void XDGDesktop::sync(){
isHidden=false;
useTerminal=false;
startupNotify=false;
type = XDGDesktop::BAD;
type = XDGDesktop::XDG_BAD;
exec = tryexec = "";
//Read in the File
if(!filePath.endsWith(".desktop")){ return; }
lastRead = QDateTime::currentDateTime();
QStringList file = LUtils::readFile(filePath);
if(file.isEmpty()){ return; } //done with init right here - nothing to load
//Get the current localization code
type = XDGDesktop::APP; //assume this initially if we read the file properly
type = XDGDesktop::XDG_APP; //assume this initially if we read the file properly
QString lang = QLocale::system().name(); //lang code
QString slang = lang.section("_",0,0); //short lang code
//Now start looping over the information
Expand Down Expand Up @@ -186,10 +186,10 @@ void XDGDesktop::sync(){
else if(var=="StartupWMClass" && insection){ startupWM = val; }
else if(var=="URL" && insection){ url = val;}
else if(var=="Type" && insection){
if(val.toLower()=="application"){ type = XDGDesktop::APP; }
else if(val.toLower()=="link"){ type = XDGDesktop::LINK; }
else if(val.toLower().startsWith("dir")){ type = XDGDesktop::DIR; } //older specs are "Dir", newer specs are "Directory"
else{ type = XDGDesktop::BAD; } //Unknown type
if(val.toLower()=="application"){ type = XDGDesktop::XDG_APP; }
else if(val.toLower()=="link"){ type = XDGDesktop::XDG_LINK; }
else if(val.toLower().startsWith("dir")){ type = XDGDesktop::XDG_DIR; } //older specs are "Dir", newer specs are "Directory"
else{ type = XDGDesktop::XDG_BAD; } //Unknown type
}
} //end reading file
if(!CDA.ID.isEmpty()){ actions << CDA; CDA = XDGDesktopAction(); } //if an action was still being read, add that to the list now
Expand Down Expand Up @@ -226,7 +226,7 @@ void XDGDesktop::sync(){
}
if (Draco::isBlacklistedApplication(exec)) {
isHidden = true;
type = XDGDesktop::BAD;
type = XDGDesktop::XDG_BAD;
}
}

Expand All @@ -236,20 +236,20 @@ bool XDGDesktop::isValid(bool showAll){
//bool DEBUG = false;
//qDebug() << "[LXDG] Check File validity:" << dFile.name << dFile.filePath;
switch (type){
case XDGDesktop::BAD:
case XDGDesktop::XDG_BAD:
ok=false;
qDebug() << " - Bad file type";
break;
case XDGDesktop::APP:
case XDGDesktop::XDG_APP:
if(!tryexec.isEmpty() && !LXDG::checkExec(tryexec)){ ok=false; }//if(DEBUG){ qDebug() << " - tryexec does not exist";} }
else if(exec.isEmpty() || name.isEmpty()){ ok=false; }//if(DEBUG){ qDebug() << " - exec or name is empty";} }
else if(!LXDG::checkExec(exec.section(" ",0,0,QString::SectionSkipEmpty)) ){ ok=false; }//if(DEBUG){ qDebug() << " - first exec binary does not exist";} }
break;
case XDGDesktop::LINK:
case XDGDesktop::XDG_LINK:
ok = !url.isEmpty();
qDebug() << " - Link with missing URL";
break;
case XDGDesktop::DIR:
case XDGDesktop::XDG_DIR:
ok = !path.isEmpty() && QFile::exists(path);
qDebug() << " - Dir with missing path";
break;
Expand Down Expand Up @@ -430,9 +430,9 @@ bool XDGDesktop::saveDesktopFile(bool merge){
// (pre-set some values here which are always required)
info << "[Desktop Entry]";
info << "Version=1.0";
if(type==XDGDesktop::APP){ info << "Type=Application"; }
else if(type==XDGDesktop::LINK){ info << "Type=Link"; }
else if(type==XDGDesktop::DIR){ info << "Type=Dir"; }
if(type==XDGDesktop::XDG_APP){ info << "Type=Application"; }
else if(type==XDGDesktop::XDG_LINK){ info << "Type=Link"; }
else if(type==XDGDesktop::XDG_DIR){ info << "Type=Dir"; }
}

if(insertloc<0){ insertloc = info.size(); }//put it at the end
Expand Down Expand Up @@ -495,7 +495,7 @@ bool XDGDesktop::setAutoStarted(bool autostart){
if(name.isEmpty()){ name = filePath.section("/",-1); }
if(icon.isEmpty()){ icon = LXDG::findAppMimeForFile(filePath); icon.replace("/","-"); }
filePath = upath+filePath.section("/",-1)+".desktop";
type = XDGDesktop::APP;
type = XDGDesktop::XDG_APP;
}else{
//Some other *.desktop file on the system (keep almost all the existing settings/values)
// - setup a redirect to the other file
Expand Down Expand Up @@ -611,7 +611,7 @@ void XDGDesktopList::updateList(){
}else{
if(files.contains(path)){ appschanged = true; files.take(path)->deleteLater(); }
XDGDesktop *dFile = new XDGDesktop(path, this);
if(dFile->type!=XDGDesktop::BAD){
if(dFile->type!=XDGDesktop::XDG_BAD){
appschanged = true; //flag that something changed - needed to load a file
if(!oldkeys.contains(path)){ newfiles << path; } //brand new file (not an update to a previously-read file)
files.insert(path, dFile);
Expand Down Expand Up @@ -1542,7 +1542,7 @@ QList<XDGDesktop*> LXDG::findAutoStartFiles(bool includeInvalid)
for(int t=0; t<tmp.length(); t++){
qDebug() << "AUTOSTART DESKTOP?" << tmp[t] << dir.absoluteFilePath(tmp[t]);
XDGDesktop *desk = new XDGDesktop(dir.absoluteFilePath(tmp[t]));
if(desk->type == XDGDesktop::BAD){
if(desk->type == XDGDesktop::XDG_BAD){
qDebug() << "bad desktop" << dir.absoluteFilePath(tmp[t]);
continue;
} //could not read file
Expand Down
2 changes: 1 addition & 1 deletion src/lib/lumina/LuminaXDG.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ struct XDGDesktopAction{
class XDGDesktop : public QObject{
Q_OBJECT
public:
enum XDGDesktopType { BAD, APP, LINK, DIR };
enum XDGDesktopType { XDG_BAD, XDG_APP, XDG_LINK, XDG_DIR };

//Admin variables
QString filePath; //which file this structure contains the information for (absolute path)
Expand Down
Loading

0 comments on commit dae14c5

Please sign in to comment.