Commit 630269a4 authored by Olivier CHURLAUD's avatar Olivier CHURLAUD

More ports out of KDialog

parent 3d7bea0f
......@@ -314,6 +314,7 @@ target_link_libraries(okularpart okularcore
KF5::Archive
KF5::Bookmarks
KF5::IconThemes
KF5::ItemViews
KF5::KDELibs4Support
KF5::Parts
KF5::Solid
......
......@@ -141,7 +141,7 @@
</widget>
</item>
<item>
<widget class="KButtonGroup" name="groupbox">
<widget class="QGroupBox" name="groupbox">
<property name="title">
<string>Memory Usage</string>
</property>
......@@ -344,14 +344,6 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>KButtonGroup</class>
<extends>QGroupBox</extends>
<header>kbuttongroup.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<includes>
<include location="global">kiconloader.h</include>
</includes>
......
......@@ -16,12 +16,12 @@
#include <qlayout.h>
#include <qtoolbar.h>
#include <qtreewidget.h>
#include <QMenu>
#include <QtCore/QDebug>
#include <QIcon>
#include <KLocalizedString>
#include <qmenu.h>
#include <ktreewidgetsearchline.h>
#include <KTreeWidgetSearchLine>
#include "pageitemdelegate.h"
#include "core/action.h"
......
......@@ -14,11 +14,13 @@
#include <QFile>
#include <QSize>
#include <QtCore/QFile>
#include <QtWidgets/QLabel>
#include <QtWidgets/QPushButton>
#include <QtGui/QShowEvent>
#include <QDialogButtonBox>
#include <QLabel>
#include <QPushButton>
#include <QShowEvent>
#include <QVBoxLayout>
#include <KWindowConfig>
#include <klocalizedstring.h>
#include <kmimetypetrader.h>
#include <kparts/readonlypart.h>
......@@ -44,6 +46,9 @@ public:
, config(KSharedConfig::openConfig(QStringLiteral("okularrc")))
{
mainlayout = new QVBoxLayout(q);
buttonBox = new QDialogButtonBox(QDialogButtonBox::Close, q);
mainlayout->addWidget(buttonBox);
filename = _filename;
}
......@@ -55,6 +60,10 @@ public:
QWidget *mainWidget;
QDialogButtonBox *buttonBox;
QVBoxLayout *mainlayout;
QString filename;
KParts::ReadOnlyPart *previewPart;
......@@ -111,7 +120,7 @@ bool FilePrinterPreviewPrivate::doPreview()
fail();
return false;
} else {
q->setMainWidget(previewPart->widget());
mainlayout->insertWidget(0, previewPart->widget());
return previewPart->openUrl(QUrl::fromLocalFile(filename));
}
}
......@@ -121,30 +130,30 @@ void FilePrinterPreviewPrivate::fail()
if (!failMessage) {
failMessage = new QLabel(i18n("Could not load print preview part"), q);
}
q->setMainWidget(failMessage);
mainlayout->insertWidget(0, failMessage);
}
FilePrinterPreview::FilePrinterPreview( const QString &filename, QWidget *parent )
: KDialog( parent )
: QDialog( parent )
, d( new FilePrinterPreviewPrivate( this, filename ) )
{
qCDebug(OkularUiDebug) << "kdeprint: creating preview dialog";
// Set up the dialog
setCaption(i18n("Print Preview"));
setButtons(KDialog::Close);
button(KDialog::Close)->setAutoDefault(false);
setWindowTitle(i18n("Print Preview"));
connect(d->buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
restoreDialogSize(d->config->group("Print Preview"));
KWindowConfig::restoreWindowSize(windowHandle(), d->config->group("Print Preview"));
}
FilePrinterPreview::~FilePrinterPreview()
{
KConfigGroup group(d->config->group("Print Preview"));
saveDialogSize(group);
KWindowConfig::saveWindowSize(windowHandle(), group);
delete d;
}
......@@ -164,7 +173,7 @@ void FilePrinterPreview::showEvent(QShowEvent *event)
return;
}
}
KDialog::showEvent(event);
QDialog::showEvent(event);
}
#include "moc_fileprinterpreview.cpp"
......@@ -13,7 +13,7 @@
#ifndef FILEPRINTERPREVIEW_H
#define FILEPRINTERPREVIEW_H
#include <kdialog.h>
#include <QDialog>
namespace Okular {
......@@ -21,7 +21,7 @@ namespace Okular {
class FilePrinterPreviewPrivate;
class FilePrinterPreview : public KDialog
class FilePrinterPreview : public QDialog
{
Q_OBJECT
......
......@@ -35,18 +35,16 @@
#include <QInputDialog>
#include <qdesktopwidget.h>
#include <QMimeDatabase>
#include <QMimeData>
#include <qaction.h>
#include <kactionmenu.h>
#include <kstandardaction.h>
#include <kactioncollection.h>
#include <KLocalizedString>
#include <kfiledialog.h>
#include <kglobal.h>
#include <kselectaction.h>
#include <ktoggleaction.h>
#include <QtCore/QDebug>
#include <kdeversion.h>
#include <kmessagebox.h>
#include <QIcon>
#include <kurifilter.h>
......@@ -659,7 +657,7 @@ void PageView::setupActions( KActionCollection * ac )
ac->addAction( QStringLiteral("speak_document"), d->aSpeakDoc );
d->aSpeakDoc->setEnabled( false );
connect( d->aSpeakDoc, &QAction::triggered, this, &PageView::slotSpeakDocument );
d->aSpeakPage = new QAction( QIcon::fromTheme( QStringLiteral("text-speak") ), i18n( "Speak Current Page" ), this );
ac->addAction( QStringLiteral("speak_current_page"), d->aSpeakPage );
d->aSpeakPage->setEnabled( false );
......@@ -2765,8 +2763,7 @@ void PageView::mouseReleaseEvent( QMouseEvent * e )
else if ( choice == imageToFile )
{
// [3] save pixmap to file
QString fileName = KFileDialog::getSaveFileName( QUrl(), QStringLiteral("image/png image/jpeg"), this, QString(),
KFileDialog::ConfirmOverwrite );
QString fileName = QFileDialog::getSaveFileName(this, i18n("Save file"), QString(), i18n("Images (*.png .jpeg"));
if ( fileName.isEmpty() )
d->messageWindow->display( i18n( "File not saved." ), QString(), PageViewMessage::Warning );
else
......@@ -4206,58 +4203,7 @@ void PageView::updatePageStep() {
void PageView::addWebShortcutsMenu( QMenu * menu, const QString & text )
{
#if KDE_IS_VERSION(4,5,70)
if ( text.isEmpty() )
{
return;
}
QString searchText = text;
searchText = searchText.replace( QLatin1Char('\n'), QLatin1Char(' ') ).replace(QLatin1Char( '\r'), QLatin1Char(' ') ).simplified();
if ( searchText.isEmpty() )
{
return;
}
KUriFilterData filterData( searchText );
filterData.setSearchFilteringOptions( KUriFilterData::RetrievePreferredSearchProvidersOnly );
if ( KUriFilter::self()->filterSearchUri( filterData, KUriFilter::NormalTextFilter ) )
{
const QStringList searchProviders = filterData.preferredSearchProviders();
if ( !searchProviders.isEmpty() )
{
QMenu *webShortcutsMenu = new QMenu( menu );
webShortcutsMenu->setIcon( QIcon::fromTheme( QStringLiteral("preferences-web-browser-shortcuts") ) );
const QString squeezedText = KStringHandler::rsqueeze( searchText, 21 );
webShortcutsMenu->setTitle( i18n( "Search for '%1' with", squeezedText ) );
QAction *action = 0;
foreach( const QString &searchProvider, searchProviders )
{
action = new QAction( searchProvider, webShortcutsMenu );
action->setIcon( QIcon::fromTheme( filterData.iconNameForPreferredSearchProvider( searchProvider ) ) );
action->setData( filterData.queryForPreferredSearchProvider( searchProvider ) );
connect( action, &QAction::triggered, this, &PageView::slotHandleWebShortcutAction );
webShortcutsMenu->addAction( action );
}
webShortcutsMenu->addSeparator();
action = new QAction( i18n( "Configure Web Shortcuts..." ), webShortcutsMenu );
action->setIcon( QIcon::fromTheme( QStringLiteral("configure") ) );
connect( action, &QAction::triggered, this, &PageView::slotConfigureWebShortcuts );
webShortcutsMenu->addAction( action );
menu->addMenu(webShortcutsMenu);
}
}
#endif
}
//BEGIN private SLOTS
......@@ -4752,19 +4698,7 @@ void PageView::slotShowSizeAllCursor()
void PageView::slotHandleWebShortcutAction()
{
#if KDE_IS_VERSION(4,5,70)
QAction *action = qobject_cast<QAction*>( sender() );
if (action)
{
KUriFilterData filterData( action->data().toString() );
if ( KUriFilter::self()->filterSearchUri( filterData, KUriFilter::WebShortcutFilter ) )
{
KToolInvocation::invokeBrowser( filterData.uri().url() );
}
}
#endif
}
void PageView::slotConfigureWebShortcuts()
......
......@@ -39,7 +39,7 @@
#include <kiconloader.h>
#include <kmessagebox.h>
#include <kselectaction.h>
#include <kdialog.h>
#include <QDialog>
#include <Solid/PowerManagement>
......@@ -149,7 +149,8 @@ PresentationWidget::PresentationWidget( QWidget * parent, Okular::Document * doc
if ( caption.trimmed().isEmpty() )
caption = doc->currentDocument().fileName();
caption = i18nc( "[document title/filename] – Presentation", "%1 – Presentation", caption );
setWindowTitle( KDialog::makeStandardCaption( caption ) );
setWindowTitle( caption );
#pragma message("KF5: Here was a makeStandardCaption, lost in KF5 port")
m_width = -1;
m_screen = -2;
......@@ -235,7 +236,7 @@ PresentationWidget::PresentationWidget( QWidget * parent, Okular::Document * doc
m_overlayHideTimer = new QTimer( this );
m_overlayHideTimer->setSingleShot( true );
connect(m_overlayHideTimer, &QTimer::timeout, this, &PresentationWidget::slotHideOverlay);
m_nextPageTimer = new QTimer( this );
m_nextPageTimer = new QTimer( this );
m_nextPageTimer->setSingleShot( true );
connect(m_nextPageTimer, &QTimer::timeout, this, &PresentationWidget::slotNextPage);
......
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