Commit 4f6fc6ec authored by Bhushan Shah's avatar Bhushan Shah 📱
Browse files

Port arkpart

parent f6984356
......@@ -20,7 +20,7 @@ set(REQUIRED_QT_VERSION 5.2.0)
set(KF5_MIN_VERSION 5.0.0)
find_package(Qt5 ${REQUIRED_QT_VERSION} CONFIG REQUIRED Core Widgets)
find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS Archive Config Pty KDELibs4Support)
find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS Archive Config Pty KHtml KDELibs4Support)
option(WITH_TEST_COVERAGE "Build with test coverage support" OFF)
if (WITH_TEST_COVERAGE)
......@@ -38,7 +38,7 @@ include_directories(
#add_subdirectory(plugins)
add_subdirectory(kerfuffle)
#add_subdirectory(part)
add_subdirectory(part)
add_subdirectory(app)
#add_subdirectory(doc)
......@@ -38,6 +38,7 @@
#include <KDebug>
#include <KEditToolBar>
#include <KShortcutsDialog>
#include <KService>
#include <KConfigGroup>
#include <QDragEnterEvent>
......@@ -126,17 +127,33 @@ void MainWindow::dragMoveEvent(QDragMoveEvent * event)
bool MainWindow::loadPart()
{
KPluginLoader loader(QLatin1String( "arkpart" ));
KPluginFactory *factory = loader.factory();
if (factory) {
m_part = static_cast<KParts::ReadWritePart*>(factory->create<KParts::ReadWritePart>(this));
// KPluginLoader loader(QLatin1String( "arkpart" ));
// KPluginFactory *factory = loader.factory();
// if (factory) {
// m_part = static_cast<KParts::ReadWritePart*>(factory->create<KParts::ReadWritePart>(this));
// }
// if (!factory || !m_part) {
// KMessageBox::error(this, i18n("Unable to find Ark's KPart component, please check your installation."));
// kWarning() << "Error loading Ark KPart: " << loader.errorString();
// return false;
// }
KPluginFactory *factory = 0;
KService::Ptr service = KService::serviceByDesktopName(QLatin1String("ark_part"));
if (service) {
factory = KPluginLoader(service->library()).factory();
}
if (!factory || !m_part) {
m_part = factory ? static_cast<KParts::ReadWritePart*>(factory->create<KParts::ReadWritePart>(this)) : 0;
if (!m_part) {
KMessageBox::error(this, i18n("Unable to find Ark's KPart component, please check your installation."));
kWarning() << "Error loading Ark KPart: " << loader.errorString();
kWarning() << "Error loading Ark KPart: ";
return false;
}
m_part->setObjectName( QLatin1String("ArkPart" ));
setCentralWidget(m_part->widget());
createGUI(m_part);
......
......@@ -7,24 +7,24 @@ set(arkpart_PART_SRCS
jobtracker.cpp
)
qt4_add_dbus_adaptor(arkpart_PART_SRCS dnddbusinterface.xml part.h Ark::Part)
qt5_add_dbus_adaptor(arkpart_PART_SRCS dnddbusinterface.xml part.h Ark::Part)
kde4_add_ui_files(arkpart_PART_SRCS infopanel.ui )
kde4_add_ui_files(arkpart_PART_SRCS jobtracker.ui )
qt5_wrap_ui(arkpart_PART_SRCS infopanel.ui )
qt5_wrap_ui(arkpart_PART_SRCS jobtracker.ui )
kde4_add_plugin(arkpart ${arkpart_PART_SRCS})
add_library(arkpart MODULE ${arkpart_PART_SRCS})
target_link_libraries(arkpart kerfuffle ${KDE4_KFILE_LIBS} ${KDE4_KPARTS_LIBS} ${KDE4_KHTML_LIBS} ${KDE4_KDEUI_LIBS})
target_link_libraries(arkpart kerfuffle KF5::KHtml )
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/ark_part.desktop.cmake
${CMAKE_CURRENT_BINARY_DIR}/ark_part.desktop
)
install(TARGETS arkpart DESTINATION ${PLUGIN_INSTALL_DIR})
install(TARGETS arkpart DESTINATION ${PLUGIN_INSTALL_DIR})
########### install files ###############
install( FILES ${CMAKE_CURRENT_BINARY_DIR}/ark_part.desktop DESTINATION ${SERVICES_INSTALL_DIR} )
install( FILES ark_part.rc DESTINATION ${DATA_INSTALL_DIR}/ark )
install( FILES ark_part.rc DESTINATION ${DATA_INSTALL_DIR}/ark )
......@@ -25,6 +25,7 @@
#include "kerfuffle/archive.h"
#include "kerfuffle/jobs.h"
#include <KGlobal>
#include <KDebug>
#include <KIconLoader>
#include <KLocale>
......
......@@ -24,6 +24,7 @@
#include <KDebug>
#include <KGlobalSettings>
#include <QMimeData>
#include <QApplication>
#include <QDragEnterEvent>
#include <QDragMoveEvent>
......
......@@ -31,15 +31,17 @@
#include <KVBox>
#include <KMessageBox>
#include <KProgressDialog>
#include <KPushButton>
#include <QPushButton>
#include <KRun>
#include <KIcon>
#include <KIO/NetAccess>
#include <khtml_part.h>
#include <KHtml/khtml_part.h>
#include <QHBoxLayout>
#include <QFile>
#include <QFrame>
#include <QLabel>
#include <QKeyEvent>
ArkViewer::ArkViewer(QWidget * parent, Qt::WFlags flags)
: KDialog(parent, flags)
......@@ -76,7 +78,7 @@ void ArkViewer::dialogClosed()
// the previewed file ourselves when the dialog is closed;
// we used to remove it at the end of ArkViewer::view() when
// QDialog::exec() was called instead of QDialog::show().
const QString previewedFilePath(m_part.data()->url().pathOrUrl());
const QString previewedFilePath(m_part.data()->url().toDisplayString(QUrl::PreferLocalFile));
m_part.data()->closeUrl();
......@@ -92,7 +94,7 @@ void ArkViewer::view(const QString& fileName, QWidget *parent)
kDebug() << "MIME type" << mimeType->name();
KService::Ptr viewer = ArkViewer::getViewer(mimeType);
const bool needsExternalViewer = (!viewer.isNull() &&
const bool needsExternalViewer = (!viewer &&
!viewer->hasServiceType(QLatin1String("KParts/ReadOnlyPart")));
if (needsExternalViewer) {
// We have already resolved the MIME type and the service above.
......@@ -107,7 +109,7 @@ void ArkViewer::view(const QString& fileName, QWidget *parent)
}
bool viewInInternalViewer = true;
if (viewer.isNull()) {
if (!viewer) {
// No internal viewer available for the file. Ask the user if it
// should be previewed as text/plain.
......@@ -168,7 +170,7 @@ void ArkViewer::view(const QString& fileName, QWidget *parent)
void ArkViewer::keyPressEvent(QKeyEvent *event)
{
KPushButton *defButton = button(defaultButton());
QPushButton *defButton = button(defaultButton());
// Only handle the event the usual way if the default button has focus
// Otherwise, pressing enter on KatePart still closes the dialog, for example.
......
......@@ -27,6 +27,7 @@
#include <KParts/BrowserExtension>
#include <KParts/ReadOnlyPart>
#include <KService>
#include <KUrl>
#include <QtCore/QWeakPointer>
......
......@@ -33,8 +33,9 @@
#include "kerfuffle/jobs.h"
#include "kerfuffle/settings.h"
#include <KAboutData>
#include <KAction>
#include <KGlobal>
#include <K4AboutData>
#include <QAction>
#include <KActionCollection>
#include <KApplication>
#include <KConfigGroup>
......@@ -53,6 +54,7 @@
#include <KStandardGuiItem>
#include <KTempDir>
#include <KToggleAction>
#include <KLocalizedString>
#include <QAction>
#include <QCursor>
......@@ -84,7 +86,7 @@ Part::Part(QWidget *parentWidget, QObject *parent, const QVariantList& args)
m_jobTracker(0)
{
Q_UNUSED(args)
setComponentData(Factory::componentData(), false);
//setComponentData(Factory::componentData(), false);
new DndExtractAdaptor(this);
......@@ -367,9 +369,9 @@ void Part::selectionChanged()
m_infoPanel->setIndexes(m_view->selectionModel()->selectedRows());
}
KAboutData* Part::createAboutData()
K4AboutData* Part::createAboutData()
{
return new KAboutData("ark", 0, ki18n("ArkPart"), "3.0");
return new K4AboutData("ark", 0, ki18n("ArkPart"), "3.0");
}
bool Part::openFile()
......@@ -636,7 +638,7 @@ void Part::slotExtractFiles()
options[QLatin1String("FollowExtractionDialogSettings")] = true;
const QString destinationDirectory = dialog.data()->destinationDirectory().pathOrUrl();
const QString destinationDirectory = dialog.data()->destinationDirectory().toDisplayString(QUrl::PreferLocalFile);
ExtractJob *job = m_model->extractFiles(files, destinationDirectory, options);
registerJob(job);
......@@ -902,3 +904,5 @@ void Part::slotSaveAs()
}
} // namespace Ark
#include "part.moc"
......@@ -26,6 +26,7 @@
#include "interface.h"
#include <KParts/Part>
#include <KParts/ReadWritePart>
#include <KParts/StatusBarExtension>
#include <KTempDir>
......@@ -35,8 +36,8 @@ class ArchiveModel;
class InfoPanel;
class KAbstractWidgetJobTracker;
class KAboutData;
class KAction;
class K4AboutData;
class QAction;
class KJob;
class QAction;
......@@ -53,7 +54,7 @@ class Part: public KParts::ReadWritePart, public Interface
public:
Part(QWidget *parentWidget, QObject *parent, const QVariantList &);
~Part();
static KAboutData* createAboutData();
static K4AboutData* createAboutData();
virtual bool openFile();
virtual bool saveFile();
......@@ -106,12 +107,12 @@ private:
ArchiveModel *m_model;
QTreeView *m_view;
KAction *m_previewAction;
KAction *m_extractFilesAction;
KAction *m_addFilesAction;
KAction *m_addDirAction;
KAction *m_deleteFilesAction;
KAction *m_saveAsAction;
QAction *m_previewAction;
QAction *m_extractFilesAction;
QAction *m_addFilesAction;
QAction *m_addDirAction;
QAction *m_deleteFilesAction;
QAction *m_saveAsAction;
InfoPanel *m_infoPanel;
QSplitter *m_splitter;
KTempDir m_previewDir;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment