Initial commit of the ROM Properties Page shell extension.

The initial version adds a blank "ROM Properties" tab to the
file properties dialog in KDE4.

NOTE: KDE4 on my system doesn't seem to look in /usr/local, so the
plugin must be installed in /usr in order to work.
This commit is contained in:
David Korth 2016-07-19 22:17:36 -04:00
commit 3f9a02b05b
7 changed files with 199 additions and 0 deletions

18
.gitignore vendored Normal file
View File

@ -0,0 +1,18 @@
# Filetypes.
*~
*.o
*.a
*.so
.directory
# Build directories.
/build*/
# KDevelop project files.
*.kdev4
# CMake temproary files.
CMakeCache.txt
CMakeFiles/
cmake_install.cmake
git_version.h

7
CMakeLists.txt Normal file
View File

@ -0,0 +1,7 @@
PROJECT(rom-properties)
CMAKE_MINIMUM_REQUIRED(VERSION 2.6.0)
SET(BUILD_KDE4 ON)
# Project subdirectories.
ADD_SUBDIRECTORY(src)

5
src/CMakeLists.txt Normal file
View File

@ -0,0 +1,5 @@
PROJECT(src)
CMAKE_MINIMUM_REQUIRED(VERSION 2.6.0)
# Source Code subdirectories.
ADD_SUBDIRECTORY(kde)

70
src/kde/CMakeLists.txt Normal file
View File

@ -0,0 +1,70 @@
PROJECT(rom-properties-kde)
# CMake 2.8.11 adds Qt4::xxx targets, similar to Qt5.
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.11)
IF(BUILD_KDE4)
# Find Qt4.
FIND_PACKAGE(Qt4 4.6.0 REQUIRED COMPONENTS QtCore QtGui)
# Find KDE4. (TODO: Version?)
FIND_PACKAGE(KDE4 REQUIRED)
ENDIF(BUILD_KDE4)
# TODO: Check for iconv on non-Windows systems.
# NOTE: KDE4_ADD_PLUGIN() uses automoc.
# Sources and headers.
SET(rom-properties-kde_SRCS
RomPropertiesDialogPlugin.cpp
)
SET(rom-properties-kde_H
RomPropertiesDialogPlugin.hpp
)
# UI files.
#SET(rom-properties-kde_UIS
#MegaDrive.ui
# )
#QT4_WRAP_UI(rom-properties-kde4_UIS_H ${rom-properties-kde_UIS})
#####################
# Build the plugin. #
#####################
KDE4_ADD_PLUGIN(rom-properties-kde4
${rom-properties-kde_SRCS}
${rom-properties-kde_H}
#${rom-properties-kde4_UIS_H}
)
TARGET_LINK_LIBRARIES(rom-properties-kde4
${KDE4_KFILE_LIBRARY}
Qt4::QtGui Qt4::QtCore
)
TARGET_INCLUDE_DIRECTORIES(rom-properties-kde4 PUBLIC ${KDE4_INCLUDE_DIR})
# Qt options:
# - Fast QString concatenation. (Qt 4.6+, plus 4.8-specific version)
# - Disable implicit QString ASCII casts.
ADD_DEFINITIONS(-DQT_USE_FAST_CONCATENATION
-DQT_USE_FAST_OPERATOR_PLUS
-DQT_USE_QSTRINGBUILDER
-DQT_NO_CAST_FROM_ASCII
-DQT_NO_CAST_TO_ASCII
)
#######################
# Install the plugin. #
#######################
IF(BUILD_KDE4)
# FIXME: Determine lib, lib64, lib/[triplet]
# For now, assume lib.
INSTALL(TARGETS rom-properties-kde4
LIBRARY DESTINATION "lib/kde4"
COMPONENT "plugin"
)
INSTALL(FILES "${CMAKE_CURRENT_SOURCE_DIR}/rom-properties-kde4.desktop"
DESTINATION "share/kde4/services"
COMPONENT "plugin"
)
# FIXME: Run kbuildsycoca4.
ENDIF(BUILD_KDE4)

View File

@ -0,0 +1,53 @@
/***************************************************************************
* ROM Properties Page extension. (KDE4/KDE5) *
* RomPropertiesDialogPlugin.cpp: KPropertiesDialogPlugin. *
* *
* Copyright (c) 2016 by David Korth. *
* *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
* *
* This program is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License along *
* with this program; if not, write to the Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
/**
* References:
* - https://github.com/KDE/calligra-history/blob/5e323f11f11ec487e1ef801d61bb322944f454a5/libs/main/KoDocumentInfoPropsPage.h
* - https://github.com/KDE/calligra-history/blob/5e323f11f11ec487e1ef801d61bb322944f454a5/libs/main/KoDocumentInfoPropsPage.cpp
* - https://github.com/KDE/calligra-history/blob/master/libs/main/KoDocInfoPropsFactory.cpp
* - https://github.com/KDE/calligra-history/blob/5e323f11f11ec487e1ef801d61bb322944f454a5/libs/main/kodocinfopropspage.desktop
*/
#include "RomPropertiesDialogPlugin.hpp"
#include <kpluginfactory.h>
static QObject *createRomPropertiesPage(QWidget *w, QObject *parent, const QVariantList &args)
{
Q_UNUSED(w)
KPropertiesDialog *props = qobject_cast<KPropertiesDialog*>(parent);
Q_ASSERT(props);
return new RomPropertiesDialogPlugin(props, args);
}
K_PLUGIN_FACTORY(RomPropertiesDialogFactory, registerPlugin<RomPropertiesDialogPlugin>(QString(), createRomPropertiesPage);)
K_EXPORT_PLUGIN(RomPropertiesDialogFactory("rom-properties-kde"))
RomPropertiesDialogPlugin::RomPropertiesDialogPlugin(KPropertiesDialog *props, const QVariantList&)
: KPropertiesDialogPlugin(props)
{
// TODO: Check if a single file is specified,
// and if the file is supported.
props->addPage(new QWidget(props), QLatin1String("ROM Properties"));
}
RomPropertiesDialogPlugin::~RomPropertiesDialogPlugin()
{ }

View File

@ -0,0 +1,36 @@
/***************************************************************************
* ROM Properties Page extension. (KDE4/KDE5) *
* RomPropertiesDialogPlugin.hpp: KPropertiesDialogPlugin. *
* *
* Copyright (c) 2016 by David Korth. *
* *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
* *
* This program is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License along *
* with this program; if not, write to the Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
#ifndef __ROMPROPERTIES_KDE4_ROMPROPERTIESDIALOGPLUGIN_HPP__
#define __ROMPROPERTIES_KDE4_ROMPROPERTIESDIALOGPLUGIN_HPP__
#include <kpropertiesdialog.h>
class Q_DECL_EXPORT RomPropertiesDialogPlugin : public KPropertiesDialogPlugin
{
Q_OBJECT
public:
explicit RomPropertiesDialogPlugin(KPropertiesDialog *props, const QVariantList & = QVariantList());
virtual ~RomPropertiesDialogPlugin();
};
#endif /* __ROMPROPERTIES_KDE4_ROMPROPERTIESDIALOGPLUGIN_HPP__ */

View File

@ -0,0 +1,10 @@
[Desktop Entry]
Type=Service
Name=ROM Properties Page
ServiceTypes=KPropertiesDialog/Plugin
X-KDE-Library=rom-properties-kde4
X-KDE-ServiceTypes=KPropertiesDialog/Plugin
X-KDE-Protocol=file
# NOTE: all/all doesn't work; use application/octet-stream.
# TODO: Add actual MIME types.
MimeType=application/octet-stream;