Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Leap:42.3:Staging:C:DVD
ark
0001-Make-ArkViewer-a-KPart-mainwindow.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0001-Make-ArkViewer-a-KPart-mainwindow.patch of Package ark
From 15d53106e184d7cb0fa08a8cf3588fea10715647 Mon Sep 17 00:00:00 2001 From: Elvis Angelaccio <elvis.angelaccio@kde.org> Date: Sun, 4 Jun 2017 17:23:51 +0200 Subject: [PATCH] Make ArkViewer a KPart mainwindow Summary: This allows us to call createGUI() on the KPart we are embedding. As a side effect, we are now able to show the popup menu of the ArkPart, which is a stand-alone popup menu created by kxmlgui, when previewing a nested archive in the ArkViewer. By using a KMainWindow (instead of a QDialog) we also gain some features, for example we get size restoring for free (thanks to setAutoSaveSettings()), without the need of manually using KWindowConfig. BUG: 380439 FIXED-IN: 17.07.80 Reviewers: #ark, fvogt Subscribers: kde-utils-devel Tags: #ark Differential Revision: https://phabricator.kde.org/D6075 --- part/CMakeLists.txt | 1 + part/ark_viewer.rc | 6 +++ part/arkviewer.cpp | 43 ++++++--------- part/arkviewer.h | 10 ++-- part/arkviewer.ui | 153 +++++++++++++++++++++------------------------------- part/part.cpp | 1 + 6 files changed, 89 insertions(+), 125 deletions(-) create mode 100644 part/ark_viewer.rc diff --git a/part/CMakeLists.txt b/part/CMakeLists.txt index 47c33489..efa5cb3a 100644 --- a/part/CMakeLists.txt +++ b/part/CMakeLists.txt @@ -38,3 +38,4 @@ install(TARGETS arkpart DESTINATION ${KDE_INSTALL_PLUGINDIR}) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/ark_part.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR}) install(FILES ark_part.rc DESTINATION ${KDE_INSTALL_KXMLGUI5DIR}/ark) +install(FILES ark_viewer.rc DESTINATION ${KDE_INSTALL_KXMLGUI5DIR}/ark) diff --git a/part/ark_viewer.rc b/part/ark_viewer.rc new file mode 100644 index 00000000..e439a3a9 --- /dev/null +++ b/part/ark_viewer.rc @@ -0,0 +1,6 @@ +<!DOCTYPE gui SYSTEM "kpartgui.dtd"> +<gui name="ark_viewer" version="1"> +<MenuBar> + <Merge/> +</MenuBar> +</gui> diff --git a/part/arkviewer.cpp b/part/arkviewer.cpp index 89a198d5..9155fc32 100644 --- a/part/arkviewer.cpp +++ b/part/arkviewer.cpp @@ -26,42 +26,34 @@ #include <KMimeTypeTrader> #include <KIconLoader> #include <KMessageBox> +#include <KParts/ReadOnlyPart> +#include <KParts/OpenUrlArguments> #include <KRun> -#include <KSharedConfig> -#include <KWindowConfig> +#include <KXMLGUIFactory> -#include <QDebug> #include <QFile> #include <QMimeDatabase> #include <QProgressDialog> #include <QPushButton> ArkViewer::ArkViewer() - : QDialog() + : KParts::MainWindow() { qCDebug(ARK) << "ArkViewer opened"; - setAttribute(Qt::WA_DeleteOnClose); - setupUi(this); - // Bug 369390: This prevents the Enter key from closing the dialog. + // Bug 369390: This prevents the Enter key from closing the window. m_buttonBox->button(QDialogButtonBox::Close)->setAutoDefault(false); - connect(m_buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); - connect(this, &ArkViewer::finished, this, &ArkViewer::dialogClosed); -} + connect(m_buttonBox, &QDialogButtonBox::rejected, this, &QMainWindow::close); -ArkViewer::~ArkViewer() -{ + setXMLFile(QStringLiteral("ark_viewer.rc")); + setupGUI(ToolBar); } -void ArkViewer::dialogClosed() +ArkViewer::~ArkViewer() { - // Save viewer dialog window size - KConfigGroup group(KSharedConfig::openConfig(), "Viewer"); - KWindowConfig::saveWindowSize(windowHandle(), group, KConfigBase::Persistent); - if (m_part) { QProgressDialog progressDialog(this); progressDialog.setWindowTitle(i18n("Closing preview")); @@ -74,8 +66,6 @@ void ArkViewer::dialogClosed() // #261785: this preview dialog is not modal, so we need to delete // 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().toDisplayString(QUrl::PreferLocalFile)); m_part.data()->closeUrl(); @@ -84,6 +74,9 @@ void ArkViewer::dialogClosed() QFile::remove(previewedFilePath); } } + + guiFactory()->removeClient(m_part); + delete m_part; } void ArkViewer::view(const QString& fileName) @@ -157,7 +150,7 @@ void ArkViewer::view(const QString& fileName) internalViewer->show(); if (internalViewer->viewInInternalViewer(fileName, mimeType)) { // The internal viewer is showing the file, and will - // remove the temporary file in dialogClosed(). So there + // remove the temporary file in its destructor. So there // is no more to do here. return; } @@ -178,11 +171,6 @@ bool ArkViewer::viewInInternalViewer(const QString& fileName, const QMimeType &m { setWindowFilePath(fileName); - // Load viewer dialog window size from config file - KConfigGroup group(KSharedConfig::openConfig(), "Viewer"); - KWindowConfig::restoreWindowSize(windowHandle(), group); - - // Set icon and comment for the mimetype. m_iconLabel->setPixmap(QIcon::fromTheme(mimeType.iconName()).pixmap(IconSize(KIconLoader::Desktop), IconSize(KIconLoader::Desktop))); m_commentLabel->setText(mimeType.comment()); @@ -205,7 +193,10 @@ bool ArkViewer::viewInInternalViewer(const QString& fileName, const QMimeType &m } // Insert the KPart into its placeholder. - layout()->replaceWidget(m_partPlaceholder, m_part.data()->widget()); + centralWidget()->layout()->replaceWidget(m_partPlaceholder, m_part.data()->widget()); + + createGUI(m_part.data()); + setAutoSaveSettings(QStringLiteral("Viewer"), true); m_part.data()->openUrl(QUrl::fromLocalFile(fileName)); m_part.data()->widget()->setFocus(); diff --git a/part/arkviewer.h b/part/arkviewer.h index dc01a76d..8d29f5e4 100644 --- a/part/arkviewer.h +++ b/part/arkviewer.h @@ -24,15 +24,14 @@ #include "ui_arkviewer.h" -#include <KParts/BrowserExtension> +#include <KParts/MainWindow> #include <KParts/ReadOnlyPart> #include <KService> -#include <QDialog> -#include <QWeakPointer> #include <QMimeType> +#include <QPointer> -class ArkViewer : public QDialog, public Ui::ArkViewer +class ArkViewer : public KParts::MainWindow, public Ui::ArkViewer { Q_OBJECT @@ -41,9 +40,6 @@ public: static void view(const QString& fileName); -private slots: - void dialogClosed(); - private: explicit ArkViewer(); diff --git a/part/arkviewer.ui b/part/arkviewer.ui index 4476ad6b..eea8248d 100644 --- a/part/arkviewer.ui +++ b/part/arkviewer.ui @@ -1,106 +1,75 @@ <?xml version="1.0" encoding="UTF-8"?> <ui version="4.0"> <class>ArkViewer</class> - <widget class="QDialog" name="ArkViewer"> + <widget class="QMainWindow" name="ArkViewer"> <property name="geometry"> <rect> <x>0</x> <y>0</y> - <width>640</width> - <height>480</height> + <width>800</width> + <height>600</height> </rect> </property> <property name="windowTitle"> - <string notr="true"/> + <string notr="true">MainWindow</string> </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <widget class="QWidget" name="m_mimeWidget" native="true"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Maximum"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <layout class="QHBoxLayout" name="horizontalLayout"> - <item> - <widget class="QLabel" name="m_iconLabel"> - <property name="text"> - <string notr="true">mime icon</string> - </property> - </widget> - </item> - <item> - <widget class="QLabel" name="m_commentLabel"> - <property name="text"> - <string notr="true">mime comment</string> - </property> - </widget> - </item> - <item> - <spacer name="horizontalSpacer"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QWidget" name="m_partPlaceholder" native="true"/> - </item> - <item> - <widget class="QDialogButtonBox" name="m_buttonBox"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="standardButtons"> - <set>QDialogButtonBox::Close</set> - </property> - </widget> - </item> - </layout> + <widget class="QWidget" name="centralwidget"> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QWidget" name="m_mimeWidget" native="true"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Maximum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QLabel" name="m_iconLabel"> + <property name="text"> + <string notr="true">mime icon</string> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="m_commentLabel"> + <property name="text"> + <string notr="true">mime comment</string> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QWidget" name="m_partPlaceholder" native="true"/> + </item> + <item> + <widget class="QDialogButtonBox" name="m_buttonBox"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="standardButtons"> + <set>QDialogButtonBox::Close</set> + </property> + </widget> + </item> + </layout> + </widget> </widget> <resources/> - <connections> - <connection> - <sender>m_buttonBox</sender> - <signal>accepted()</signal> - <receiver>ArkViewer</receiver> - <slot>accept()</slot> - <hints> - <hint type="sourcelabel"> - <x>248</x> - <y>254</y> - </hint> - <hint type="destinationlabel"> - <x>157</x> - <y>274</y> - </hint> - </hints> - </connection> - <connection> - <sender>m_buttonBox</sender> - <signal>rejected()</signal> - <receiver>ArkViewer</receiver> - <slot>reject()</slot> - <hints> - <hint type="sourcelabel"> - <x>316</x> - <y>260</y> - </hint> - <hint type="destinationlabel"> - <x>286</x> - <y>274</y> - </hint> - </hints> - </connection> - </connections> + <connections/> </ui> diff --git a/part/part.cpp b/part/part.cpp index 4b9d0aeb..041312dc 100644 --- a/part/part.cpp +++ b/part/part.cpp @@ -52,6 +52,7 @@ #include <KJobWidgets> #include <KIO/StatJob> #include <KMessageBox> +#include <KParts/OpenUrlArguments> #include <KPluginFactory> #include <KRun> #include <KSelectAction> -- 2.13.0
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor