Port the ChooseEngineDialog to KDialog and Qt4.

Fix a compilation error introduced by my previous commit.

svn path=/branches/work/kde4/playground/graphics/okular/; revision=524596
This commit is contained in:
Pino Toscano 2006-03-30 18:06:18 +00:00
parent 11d5e77ff4
commit cbeaf3298b
6 changed files with 122 additions and 115 deletions

View file

@ -31,6 +31,7 @@ kde4_add_ui_files(oKularconf_SRCS
set(oKularcore_SRCS
${CMAKE_SOURCE_DIR}/okular/core/annotations.cpp
${CMAKE_SOURCE_DIR}/okular/core/area.cpp
${CMAKE_SOURCE_DIR}/okular/core/chooseenginedialog.cpp
${CMAKE_SOURCE_DIR}/okular/core/document.cpp
${CMAKE_SOURCE_DIR}/okular/core/generator.cpp
${CMAKE_SOURCE_DIR}/okular/core/link.cpp
@ -39,8 +40,8 @@ set(oKularcore_SRCS
${CMAKE_SOURCE_DIR}/okular/core/textpage.cpp
)
kde4_add_ui3_files(oKularcore_SRCS
${CMAKE_SOURCE_DIR}/okular/core/chooseenginedialog.ui
kde4_add_ui_files(oKularcore_SRCS
${CMAKE_SOURCE_DIR}/okular/core/chooseenginewidget.ui
)
set(oKularui_SRCS

View file

@ -0,0 +1,36 @@
/***************************************************************************
* Copyright (C) 2006 by Pino Toscano <toscano.pino@tiscali.it> *
* *
* 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. *
***************************************************************************/
#include <qcombobox.h>
#include <qlabel.h>
#include <klocale.h>
#include "chooseenginewidget.h"
#include "chooseenginedialog.h"
ChooseEngineDialog::ChooseEngineDialog( const QStringList &generators, const QString &mime, QWidget * parent )
: KDialog(parent, i18n("Generator Selection"), Ok | Cancel)
{
QWidget *main = new QWidget( this );
setMainWidget( main );
m_widget = new Ui_ChooseEngineWidget();
m_widget->setupUi( main );
m_widget->engineList->addItems(generators);
m_widget->description->setText(
i18n("More than one generator found for mimetype \"%1\", please select which one to use:").arg(mime)
);
}
int ChooseEngineDialog::selectedGenerator() const
{
return m_widget->engineList->currentIndex();
}

30
core/chooseenginedialog.h Normal file
View file

@ -0,0 +1,30 @@
/***************************************************************************
* Copyright (C) 2006 by Pino Toscano <toscano.pino@tiscali.it> *
* *
* 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. *
***************************************************************************/
#ifndef _CHOOSEENGINEDIALOG_H
#define _CHOOSEENGINEDIALOG_H
#include <qstringlist.h>
#include <kdialog.h>
class Ui_ChooseEngineWidget;
class ChooseEngineDialog : public KDialog
{
public:
ChooseEngineDialog( const QStringList &generators, const QString &mime, QWidget * parent = 0 );
int selectedGenerator() const;
protected:
Ui_ChooseEngineWidget * m_widget;
};
#endif

View file

@ -1,103 +0,0 @@
<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
<class>ChooseEngineDialog</class>
<widget class="QDialog">
<property name="name">
<cstring>ChooseEngineDialog</cstring>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>650</width>
<height>128</height>
</rect>
</property>
<property name="caption">
<string>Generator Selection</string>
</property>
<property name="sizeGripEnabled">
<bool>false</bool>
</property>
<grid>
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="QLabel" row="0" column="0" rowspan="1" colspan="3">
<property name="name">
<cstring>description</cstring>
</property>
<property name="text">
<string>More than one generator found for mimetype, please select which one to use:</string>
</property>
</widget>
<widget class="QPushButton" row="2" column="0">
<property name="name">
<cstring>buttonOk</cstring>
</property>
<property name="text">
<string>&amp;OK</string>
</property>
<property name="accel">
<string></string>
</property>
<property name="autoDefault">
<bool>true</bool>
</property>
<property name="default">
<bool>true</bool>
</property>
</widget>
<spacer row="2" column="1">
<property name="name">
<cstring>Horizontal Spacing2</cstring>
</property>
<property name="orientation">
<enum>Horizontal</enum>
</property>
<property name="sizeType">
<enum>Expanding</enum>
</property>
<property name="sizeHint">
<size>
<width>458</width>
<height>20</height>
</size>
</property>
</spacer>
<widget class="QPushButton" row="2" column="2">
<property name="name">
<cstring>buttonCancel</cstring>
</property>
<property name="text">
<string>&amp;Cancel</string>
</property>
<property name="accel">
<string></string>
</property>
<property name="autoDefault">
<bool>true</bool>
</property>
</widget>
<widget class="QComboBox" row="1" column="0" rowspan="1" colspan="3">
<property name="name">
<cstring>engineList</cstring>
</property>
</widget>
</grid>
</widget>
<connections>
<connection>
<sender>buttonOk</sender>
<signal>clicked()</signal>
<receiver>ChooseEngineDialog</receiver>
<slot>accept()</slot>
</connection>
<connection>
<sender>buttonCancel</sender>
<signal>clicked()</signal>
<receiver>ChooseEngineDialog</receiver>
<slot>reject()</slot>
</connection>
</connections>
<layoutdefaults spacing="6" margin="11"/>
</UI>

View file

@ -0,0 +1,43 @@
<ui version="4.0" >
<author></author>
<comment></comment>
<exportmacro></exportmacro>
<class>ChooseEngineWidget</class>
<widget class="QWidget" name="ChooseEngineWidget" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>362</width>
<height>87</height>
</rect>
</property>
<property name="windowTitle" >
<string>Form</string>
</property>
<layout class="QVBoxLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QLabel" name="description" >
<property name="text" >
<string>More than one generator found for mimetype, please select which one to use:</string>
</property>
<property name="wordWrap" >
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="engineList" />
</item>
</layout>
</widget>
<pixmapfunction></pixmapfunction>
<resources/>
<connections/>
</ui>

View file

@ -9,6 +9,7 @@
***************************************************************************/
// qt/kde/system includes
#include <qapplication.h>
#include <qdir.h>
#include <qfile.h>
#include <qfileinfo.h>
@ -166,22 +167,21 @@ bool KPDFDocument::openDocument( const QString & docFile, const KUrl& url, const
// best ranked offer search
if (offers.count() > 1 && KpdfSettings::chooseGenerators() )
{
ChooseEngineDialog * choose = new ChooseEngineDialog (0,0);
QStringList list;
int count=offers.count();
int i;
for (i=0;i<count;i++)
for (int i=0;i<count;++i)
{
choose->engineList->insertItem( i, offers[i]->property("Name").toString() );
list << offers[i]->property("Name").toString();
}
ChooseEngineDialog * choose = new ChooseEngineDialog (list, mime->name(), 0);
choose -> description-> setText(
QString("More then one generator found for %1 mimetype, please select which one to use:").arg(mime->name())
);
switch( choose->exec() )
int retval=choose->exec();
int index=choose->selectedGenerator();
delete choose;
switch( retval )
{
case QDialog::Accepted:
hRank=choose->engineList->currentIndex();
hRank=index;
break;
case QDialog::Rejected:
return false;