Juergen's QSendto.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5429 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
John Levon 2002-10-16 21:26:35 +00:00
parent d009cd4d93
commit 79f1b4a66b
10 changed files with 546 additions and 3 deletions

View File

@ -1,3 +1,13 @@
2002-10-16 Juergen Spitzmueller <j.spitzmueller@gmx.de>
* ui/QSendtoDialog.ui:
* QSendtoDialog.[Ch]:
* QSendto.[Ch]:
* Makefile.dialogs:
* Dialogs.C:
* Dialogs2.C:
* Dialogs_impl.h: Implement Sendto (Custom Export) dialog
2002-10-16 Lars Gullik Bjønnes <larsbj@birdstep.com>
* qfont_loader.C (font_info): correct calculation of font size

View File

@ -65,6 +65,7 @@ Dialogs::Impl::Impl(LyXView & lv, Dialogs & d)
print(lv, d),
ref(lv, d),
search(lv, d),
sendto(lv, d),
spellchecker(lv, d),
tabularcreate(lv, d),
texinfo(lv, d),

View File

@ -204,7 +204,9 @@ void Dialogs::showSearch()
void Dialogs::showSendto()
{}
{
pimpl_->sendto.controller().show();
}
void Dialogs::showSpellchecker()

View File

@ -96,7 +96,8 @@
#include "QRefDialog.h"
#include "QSearch.h"
#include "QSearchDialog.h"
//#include "QSendto.h"
#include "QSendto.h"
#include "QSendtoDialog.h"
#include "QShowFile.h"
#include "QShowFileDialog.h"
#include "QSpellchecker.h"
@ -189,6 +190,9 @@ RefDialog;
typedef GUI<ControlSearch, QSearch, NoRepeatedApplyReadOnlyPolicy, Qt2BC>
SearchDialog;
typedef GUI<ControlSendto, QSendto, OkApplyCancelPolicy, Qt2BC>
SendtoDialog;
typedef GUI<ControlSpellchecker, QSpellchecker, NoRepeatedApplyReadOnlyPolicy, Qt2BC>
SpellcheckerDialog;
@ -240,6 +244,7 @@ struct Dialogs::Impl {
PrintDialog print;
RefDialog ref;
SearchDialog search;
SendtoDialog sendto;
SpellcheckerDialog spellchecker;
TabularCreateDialog tabularcreate;
TexinfoDialog texinfo;

View File

@ -23,6 +23,7 @@ DIALOGS = \
QPrint \
QRef \
QSearch \
QSendto \
QShowFile \
QSpellchecker \
QTabularCreate \
@ -77,6 +78,8 @@ DIALOGSOURCES = \
QRef.C QRefDialog.C \
QSearch.h QSearchDialog.h \
QSearch.C QSearchDialog.C \
QSendto.h QSendtoDialog.h \
QSendto.C QSendtoDialog.C \
QShowFile.h QShowFileDialog.h \
QShowFile.C QShowFileDialog.C \
QSpellchecker.h QSpellcheckerDialog.h \
@ -119,6 +122,7 @@ MOCDIALOGS = \
QPrintDialog_moc.C \
QRefDialog_moc.C \
QSearchDialog_moc.C \
QSendtoDialog_moc.C \
QShowFileDialog_moc.C \
QSpellcheckerDialog_moc.C \
QTabularCreateDialog_moc.C \
@ -176,6 +180,8 @@ UIDIALOGS = \
QRefDialogBase.C \
QSearchDialogBase.h \
QSearchDialogBase.C \
QSendtoDialogBase.h \
QSendtoDialogBase.C \
QShowFileDialogBase.h \
QShowFileDialogBase.C \
QSpellcheckerDialogBase.h \
@ -228,6 +234,7 @@ UIMOCDIALOGS = \
QPrintDialogBase_moc.C \
QRefDialogBase_moc.C \
QSearchDialogBase_moc.C \
QSendtoDialogBase_moc.C \
QShowFileDialogBase_moc.C \
QSpellcheckerDialogBase_moc.C \
QTabularCreateDialogBase_moc.C \

101
src/frontends/qt2/QSendto.C Normal file
View File

@ -0,0 +1,101 @@
/**
* \file QSendto.C
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* \author Juergen Spitzmueller
*
* Full author contact details are available in file CREDITS
*/
#include <config.h>
#ifdef __GNUG__
#pragma implementation
#endif
#include "Qt2BC.h"
#include "ControlSendto.h"
#include "QSendtoDialog.h"
#include "QSendto.h"
#include <qcombobox.h>
#include <qlabel.h>
#include <qlistbox.h>
#include <qpushbutton.h>
#include "debug.h"
#include "gettext.h"
#include "converter.h"
using std::vector;
typedef Qt2CB<ControlSendto, Qt2DB<QSendtoDialog> > base_class;
QSendto::QSendto()
: base_class(_("Send document to command"))
{
}
void QSendto::build_dialog()
{
dialog_.reset(new QSendtoDialog(this));
// Manage the ok, apply, restore and cancel/close buttons
bc().setOK(dialog_->okPB);
bc().setApply(dialog_->applyPB);
bc().setCancel(dialog_->closePB);
}
void QSendto::update_contents()
{
all_formats_ = controller().allFormats();
// Check whether the current contents of the browser will be
// changed by loading the contents of formats
vector<string> keys;
keys.resize(all_formats_.size());
vector<string>::iterator result = keys.begin();
vector<Format const *>::const_iterator it = all_formats_.begin();
vector<Format const *>::const_iterator end = all_formats_.end();
for (; it != end; ++it, ++result) {
*result = (*it)->prettyname();
}
// Reload the browser
dialog_->formatLB->clear();
for (vector<string>::const_iterator it = keys.begin();
it < keys.end(); ++it) {
dialog_->formatLB->insertItem(it->c_str());
}
dialog_->commandCO->insertItem(controller().getCommand().c_str());
}
void QSendto::apply()
{
int const line(dialog_->formatLB->currentItem());
if (line < 0 || line > dialog_->formatLB->count())
return;
string const cmd(dialog_->commandCO->currentText().latin1());
controller().setFormat(all_formats_[line]);
controller().setCommand(cmd);
}
bool QSendto::isValid()
{
int const line(dialog_->formatLB->currentItem());
if (line < 0 || line > dialog_->formatLB->count())
return false;
else return dialog_->formatLB->count() != 0 &&
!string(dialog_->commandCO->currentText()).empty();
}

View File

@ -0,0 +1,51 @@
// -*- C++ -*-
/**
* \file QSendto.h
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* \author Juergen Spitzmueller
*
* Full author contact details are available in file CREDITS
*/
#ifndef QSENDTO_H
#define QSENDTO_H
#ifdef __GNUG__
#pragma interface
#endif
#include "Qt2Base.h"
#include <vector>
class ControlSendto;
class QSendtoDialog;
class Format;
/** This class provides a Qt implementation of the Custom Export Dialog.
*/
class QSendto
: public Qt2CB<ControlSendto, Qt2DB<QSendtoDialog> >
{
public:
///
friend class QSendtoDialog;
///
QSendto();
protected:
virtual bool isValid();
private:
/// Apply from dialog
virtual void apply();
/// Update the dialog
virtual void update_contents();
/// Build the dialog
virtual void build_dialog();
///
std::vector<Format const *> all_formats_;
};
#endif // QSENDTO_H

View File

@ -0,0 +1,57 @@
/**
* \file QSendtoDialog.C
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* \author Juergen Spitzmueller
*
* Full author contact details are available in file CREDITS
*/
#include <config.h>
#ifdef __GNUG__
#pragma implementation
#endif
#include <vector>
#include "ControlSendto.h"
#include "gettext.h"
#include "debug.h"
#include "converter.h"
#include "LString.h"
#include <qcombobox.h>
#include <qlabel.h>
#include <qlistbox.h>
#include <qpushbutton.h>
#include "QSendtoDialog.h"
#include "QSendto.h"
QSendtoDialog::QSendtoDialog(QSendto * form)
: QSendtoDialogBase(0, 0, false, 0),
form_(form)
{
connect(okPB, SIGNAL(clicked()),
form, SLOT(slotOK()));
connect(applyPB, SIGNAL(clicked()),
form, SLOT(slotApply()));
connect(closePB, SIGNAL(clicked()),
form, SLOT(slotClose()));
}
void QSendtoDialog::changed_adaptor()
{
form_->changed();
}
void QSendtoDialog::closeEvent(QCloseEvent * e)
{
form_->slotWMHide();
e->accept();
}

View File

@ -0,0 +1,42 @@
// -*- C++ -*-
/**
* \file QSendtoDialog.h
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* \author Juergen Spitzmueller
*
* Full author contact details are available in file CREDITS
*/
#ifndef QSENDTODIALOG_H
#define QSENDTODIALOG_H
#ifdef __GNUG__
#pragma interface
#endif
#include "ui/QSendtoDialogBase.h"
class QSendto;
class QSendtoDialog : public QSendtoDialogBase
{
Q_OBJECT
public:
QSendtoDialog(QSendto * form);
protected slots:
virtual void changed_adaptor();
virtual void slotFormatHighlighted(const QString&) {};
virtual void slotFormatSelected(const QString&) {};
protected:
virtual void closeEvent(QCloseEvent * e);
private:
QSendto * form_;
};
#endif // QSENDTODIALOG_H

View File

@ -0,0 +1,267 @@
<!DOCTYPE UI><UI>
<class>QSendtoDialogBase</class>
<include location="global">config.h</include>
<include location="local">gettext.h</include>
<widget>
<class>QDialog</class>
<property stdset="1">
<name>name</name>
<cstring>QSendtoDialogBase</cstring>
</property>
<property stdset="1">
<name>geometry</name>
<rect>
<x>0</x>
<y>0</y>
<width>278</width>
<height>262</height>
</rect>
</property>
<property stdset="1">
<name>caption</name>
<string>Custom Export</string>
</property>
<property stdset="1">
<name>sizeGripEnabled</name>
<bool>true</bool>
</property>
<widget>
<class>QComboBox</class>
<property stdset="1">
<name>name</name>
<cstring>commandCO</cstring>
</property>
<property stdset="1">
<name>geometry</name>
<rect>
<x>15</x>
<y>185</y>
<width>245</width>
<height>22</height>
</rect>
</property>
<property stdset="1">
<name>sizePolicy</name>
<sizepolicy>
<hsizetype>3</hsizetype>
<vsizetype>0</vsizetype>
</sizepolicy>
</property>
<property stdset="1">
<name>focusPolicy</name>
<enum>StrongFocus</enum>
</property>
<property stdset="1">
<name>editable</name>
<bool>true</bool>
</property>
<property stdset="1">
<name>sizeLimit</name>
<number>10</number>
</property>
<property stdset="1">
<name>maxCount</name>
<number>666</number>
</property>
<property stdset="1">
<name>insertionPolicy</name>
<enum>AtTop</enum>
</property>
<property stdset="1">
<name>autoCompletion</name>
<bool>true</bool>
</property>
<property stdset="1">
<name>duplicatesEnabled</name>
<bool>false</bool>
</property>
<property>
<name>toolTip</name>
<string>Process the converted file with this command ($$FName = file name)</string>
</property>
</widget>
<widget>
<class>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>commandLA</cstring>
</property>
<property stdset="1">
<name>geometry</name>
<rect>
<x>15</x>
<y>165</y>
<width>126</width>
<height>16</height>
</rect>
</property>
<property stdset="1">
<name>text</name>
<string>&amp;Command:</string>
</property>
<property>
<name>buddy</name>
<cstring>commandCO</cstring>
</property>
</widget>
<widget>
<class>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>formatLA</cstring>
</property>
<property stdset="1">
<name>geometry</name>
<rect>
<x>15</x>
<y>10</y>
<width>115</width>
<height>16</height>
</rect>
</property>
<property stdset="1">
<name>text</name>
<string>&amp;Export formats:</string>
</property>
<property>
<name>buddy</name>
<cstring>formatLB</cstring>
</property>
</widget>
<widget>
<class>QListBox</class>
<item>
<property>
<name>text</name>
<string>New Item</string>
</property>
</item>
<property stdset="1">
<name>name</name>
<cstring>formatLB</cstring>
</property>
<property stdset="1">
<name>geometry</name>
<rect>
<x>15</x>
<y>30</y>
<width>245</width>
<height>125</height>
</rect>
</property>
<property stdset="1">
<name>maximumSize</name>
<size>
<width>32767</width>
<height>32767</height>
</size>
</property>
<property>
<name>toolTip</name>
<string>Available export converters</string>
</property>
</widget>
<widget>
<class>QLayoutWidget</class>
<property stdset="1">
<name>name</name>
<cstring>Layout6</cstring>
</property>
<property stdset="1">
<name>geometry</name>
<rect>
<x>11</x>
<y>225</y>
<width>256</width>
<height>24</height>
</rect>
</property>
<hbox>
<property stdset="1">
<name>margin</name>
<number>0</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>6</number>
</property>
<widget>
<class>QPushButton</class>
<property stdset="1">
<name>name</name>
<cstring>okPB</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>OK</string>
</property>
<property stdset="1">
<name>autoDefault</name>
<bool>true</bool>
</property>
<property stdset="1">
<name>default</name>
<bool>false</bool>
</property>
</widget>
<widget>
<class>QPushButton</class>
<property stdset="1">
<name>name</name>
<cstring>applyPB</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>&amp;Apply</string>
</property>
</widget>
<widget>
<class>QPushButton</class>
<property stdset="1">
<name>name</name>
<cstring>closePB</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>Cancel</string>
</property>
</widget>
</hbox>
</widget>
</widget>
<connections>
<connection>
<sender>formatLB</sender>
<signal>highlighted(const QString&amp;)</signal>
<receiver>QSendtoDialogBase</receiver>
<slot>slotFormatHighlighted(const QString&amp;)</slot>
</connection>
<connection>
<sender>formatLB</sender>
<signal>selected(const QString&amp;)</signal>
<receiver>QSendtoDialogBase</receiver>
<slot>slotFormatSelected(const QString&amp;)</slot>
</connection>
<connection>
<sender>formatLB</sender>
<signal>highlighted(const QString&amp;)</signal>
<receiver>QSendtoDialogBase</receiver>
<slot>changed_adaptor()</slot>
</connection>
<connection>
<sender>commandCO</sender>
<signal>textChanged(const QString&amp;)</signal>
<receiver>QSendtoDialogBase</receiver>
<slot>changed_adaptor()</slot>
</connection>
<slot access="public">changed_adaptor()</slot>
<slot access="public">slotFormatHighlighted(const QString&amp;)</slot>
<slot access="public">slotFormatSelected(const QString&amp;)</slot>
</connections>
<tabstops>
<tabstop>formatLB</tabstop>
<tabstop>okPB</tabstop>
<tabstop>applyPB</tabstop>
<tabstop>closePB</tabstop>
</tabstops>
</UI>