include dialog

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2600 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
John Levon 2001-08-28 01:27:35 +00:00
parent b8beae4a70
commit 3509e5f1ba
10 changed files with 965 additions and 2 deletions

View File

@ -20,6 +20,7 @@
#include "QErrorDialog.h"
#include "QERTDialog.h"
#include "QExternalDialog.h"
#include "QIncludeDialog.h"
#include "QIndexDialog.h"
#include "QRefDialog.h"
#include "QThesaurusDialog.h"
@ -33,6 +34,7 @@
#include "QError.h"
#include "QERT.h"
#include "QExternal.h"
#include "QInclude.h"
#include "QIndex.h"
#include "QParagraph.h"
#include "QPrint.h"
@ -58,6 +60,7 @@
#include "controllers/ControlError.h"
#include "controllers/ControlERT.h"
#include "controllers/ControlExternal.h"
#include "controllers/ControlInclude.h"
#include "controllers/ControlIndex.h"
#include "controllers/ControlRef.h"
#include "controllers/ControlSplash.h"
@ -68,7 +71,6 @@
#include "controllers/ControlCitation.h"
#include "controllers/ControlFloat.h"
#include "controllers/ControlGraphics.h"
#include "controllers/ControlInclude.h"
#include "controllers/ControlLabel.h"
#include "controllers/ControlLog.h"
#include "controllers/ControlMinipage.h"
@ -101,6 +103,7 @@ Dialogs::Dialogs(LyXView * lv)
add(new GUIError<QError, Qt2BC>(*lv, *this));
add(new GUIERT<QERT, Qt2BC>(*lv, *this));
add(new GUIExternal<QExternal, Qt2BC>(*lv, *this));
add(new GUIInclude<QInclude, Qt2BC>(*lv, *this));
add(new GUIIndex<QIndex, Qt2BC>(*lv, *this));
add(new GUIRef<QRef, Qt2BC>(*lv, *this));
add(new GUIThesaurus<QThesaurus, Qt2BC>(*lv, *this));

View File

@ -26,7 +26,6 @@ libqt2_la_OBJADD = \
../xforms/FormBrowser.lo \
../xforms/FormDocument.lo \
../xforms/FormGraphics.lo \
../xforms/FormInclude.lo \
../xforms/FormIndex.lo \
../xforms/FormInset.lo \
../xforms/FormLog.lo \

View File

@ -10,6 +10,7 @@ DIALOGS = \
QError \
QERT \
QExternal \
QInclude \
QIndex \
QParagraph \
QPrint \
@ -40,6 +41,8 @@ DIALOGSOURCES = \
QERT.C QERTDialog.C \
QExternal.h QExternalDialog.h \
QExternal.C QExternalDialog.C \
QInclude.h QIncludeDialog.h \
QInclude.C QIncludeDialog.C \
QIndex.h QIndexDialog.h \
QIndex.C QIndexDialog.C \
QParagraph.h QParagraphDialog.h \
@ -71,6 +74,7 @@ MOCDIALOGS = \
QErrorDialog_moc.C \
QERTDialog_moc.C \
QExternalDialog_moc.C \
QIncludeDialog_moc.C \
QIndexDialog_moc.C \
QParagraphDialog_moc.C \
QPrintDialog_moc.C \
@ -101,6 +105,8 @@ UIDIALOGS = \
QERTDialogBase.h \
QExternalDialogBase.C \
QExternalDialogBase.h \
QIncludeDialogBase.h \
QIncludeDialogBase.C \
QIndexDialogBase.h \
QIndexDialogBase.C \
QParagraphDialogBase.h \
@ -130,6 +136,7 @@ UIMOCDIALOGS = \
QErrorDialogBase_moc.C \
QERTDialogBase_moc.C \
QExternalDialogBase_moc.C \
QIncludeDialogBase_moc.C \
QIndexDialogBase_moc.C \
QParagraphDialogBase_moc.C \
QPrintDialogBase_moc.C \

View File

@ -0,0 +1,137 @@
/**
* \file QInclude.C
* Copyright 2001 the LyX Team
* Read the file COPYING
*
* \author John Levon <moz@compsoc.man.ac.uk>
*/
#include <config.h>
#ifdef __GNUG__
#pragma implementation
#endif
#include "QIncludeDialog.h"
#include "ControlInclude.h"
#include "QInclude.h"
#include "Qt2BC.h"
#include "gettext.h"
#include "debug.h"
#include <qlineedit.h>
#include <qpushbutton.h>
#include <qcheckbox.h>
#include <qradiobutton.h>
typedef Qt2CB<ControlInclude, Qt2DB<QIncludeDialog> > base_class;
QInclude::QInclude(ControlInclude & c)
: base_class(c, _("Include"))
{
}
void QInclude::build_dialog()
{
dialog_.reset(new QIncludeDialog(this));
bc().setOK(dialog_->okPB);
bc().setCancel(dialog_->closePB);
bc().addReadOnly(dialog_->filenameED);
bc().addReadOnly(dialog_->browsePB);
bc().addReadOnly(dialog_->typesetCB);
bc().addReadOnly(dialog_->visiblespaceCB);
bc().addReadOnly(dialog_->includeRB);
bc().addReadOnly(dialog_->inputRB);
bc().addReadOnly(dialog_->verbatimRB);
}
void QInclude::update_contents()
{
if (controller().params().noload) {
dialog_->filenameED->setText("");
dialog_->typesetCB->setChecked(false);
dialog_->visiblespaceCB->setChecked(false);
dialog_->visiblespaceCB->setEnabled(false);
dialog_->includeRB->setChecked(true);
return;
}
dialog_->filenameED->setText(controller().params().cparams.getContents().c_str());
string const cmdname = controller().params().cparams.getCmdName();
// FIXME: ??
dialog_->typesetCB->setChecked(controller().params().noload);
dialog_->visiblespaceCB->setChecked(false);
dialog_->visiblespaceCB->setEnabled(false);
if (cmdname == "input")
dialog_->inputRB->setChecked(true);
else if (cmdname == "include")
dialog_->includeRB->setChecked(true);
else if (!cmdname.empty()) {
dialog_->verbatimRB->setChecked(true);
dialog_->visiblespaceCB->setChecked(cmdname == "verbatiminput*");
dialog_->visiblespaceCB->setEnabled(true);
}
if (cmdname.empty())
dialog_->includeRB->setChecked(true);
}
void QInclude::apply()
{
controller().params().noload = dialog_->typesetCB->isChecked();
controller().params().cparams.
setContents(dialog_->filenameED->text().latin1());
if (dialog_->inputRB->isChecked())
controller().params().flag = InsetInclude::INPUT;
else if (dialog_->includeRB->isChecked())
controller().params().flag = InsetInclude::INCLUDE;
else {
if (dialog_->visiblespaceCB->isChecked())
controller().params().flag = InsetInclude::VERBAST;
else
controller().params().flag = InsetInclude::VERB;
}
}
void QInclude::browse()
{
ControlInclude::Type type;
if (dialog_->includeRB->isChecked())
type = ControlInclude::INCLUDE;
else if (dialog_->inputRB->isChecked())
type = ControlInclude::INPUT;
else
type = ControlInclude::VERBATIM;
string const & name = controller().Browse(dialog_->filenameED->text().latin1(), type);
if (!name.empty())
dialog_->filenameED->setText(name.c_str());
}
void QInclude::load()
{
if (isValid()) {
string const file(dialog_->filenameED->text().latin1());
slotOK();
controller().load(file);
}
}
bool QInclude::isValid()
{
return !string(dialog_->filenameED->text().latin1()).empty();
}

View File

@ -0,0 +1,50 @@
// -*- C++ -*-
/**
* \file QInclude.h
* Copyright 2001 the LyX Team
* Read the file COPYING
*
* \author John Levon <moz@compsoc.man.ac.uk>
*/
#ifndef QINCLUDE_H
#define QINCLUDE_H
#ifdef __GNUG__
#pragma interface
#endif
#include "Qt2Base.h"
class ControlInclude;
class QIncludeDialog;
///
class QInclude
: public Qt2CB<ControlInclude, Qt2DB<QIncludeDialog> >
{
public:
///
friend class QIncludeDialog;
///
QInclude(ControlInclude &);
protected:
virtual bool isValid();
private:
/// Apply changes
virtual void apply();
/// update
virtual void update_contents();
/// build the dialog
virtual void build_dialog();
/// load the file
void load();
/// browse for a file
void browse();
};
#endif // QINCLUDE_H

View File

@ -0,0 +1,72 @@
/**
* \file QIncludeDialog.C
* Copyright 2001 the LyX Team
* Read the file COPYING
*
* \author John Levon <moz@compsoc.man.ac.uk>
*/
#include <config.h>
#include <vector>
#include <qwidget.h>
#include <qpushbutton.h>
#include <qcheckbox.h>
#include "LString.h"
#include "QIncludeDialog.h"
#include "ControlInclude.h"
#include "Dialogs.h"
#include "QInclude.h"
#include "debug.h"
QIncludeDialog::QIncludeDialog(QInclude * form)
: QIncludeDialogBase(0, 0, false, 0),
form_(form)
{
connect(okPB, SIGNAL(clicked()),
form, SLOT(slotOK()));
connect(closePB, SIGNAL(clicked()),
form, SLOT(slotClose()));
}
void QIncludeDialog::change_adaptor()
{
form_->changed();
}
void QIncludeDialog::closeEvent(QCloseEvent * e)
{
form_->slotWMHide();
e->accept();
}
void QIncludeDialog::typeChanged(int v)
{
switch (v) {
case 0:
case 1:
visiblespaceCB->setEnabled(false);
visiblespaceCB->setChecked(false);
break;
default:
visiblespaceCB->setEnabled(true);
break;
}
}
void QIncludeDialog::loadClicked()
{
form_->load();
}
void QIncludeDialog::browseClicked()
{
form_->browse();
}

View File

@ -0,0 +1,39 @@
/**
* \file QIncludeDialog.h
* Copyright 2001 the LyX Team
* Read the file COPYING
*
* \author John Levon <moz@compsoc.man.ac.uk>
*/
#ifndef QINCLUDEDIALOG_H
#define QINCLUDEDIALOG_H
#include <config.h>
#include "ui/QIncludeDialogBase.h"
class QInclude;
class QIncludeDialog : public QIncludeDialogBase
{ Q_OBJECT
public:
QIncludeDialog(QInclude * form);
void updateLists();
protected slots:
virtual void change_adaptor();
virtual void loadClicked();
virtual void browseClicked();
virtual void typeChanged(int v);
protected:
virtual void closeEvent(QCloseEvent * e);
private:
QInclude * form_;
};
#endif // QINCLUDEDIALOG_H

View File

@ -44,6 +44,7 @@ void QThesaurus::build_dialog()
void QThesaurus::update_contents()
{
dialog_->entryED->setText(controller().text().c_str());
dialog_->replaceED->setText("");
dialog_->updateLists();
}

View File

@ -1,5 +1,11 @@
This file contains some do's and dont's for the Qt2 frontend.
Random crashes
--------------
Both xforms and Qt use X error handlers which collide - if you get
crashes, try lyx -sync, which seems to help.
General rules
-------------

View File

@ -0,0 +1,649 @@
<!DOCTYPE UI><UI>
<class>QIncludeDialogBase</class>
<include location="global">config.h</include>
<include location="local">gettext.h</include>
<widget>
<class>QDialog</class>
<property stdset="1">
<name>name</name>
<cstring>QIncludeDialogBase</cstring>
</property>
<property stdset="1">
<name>geometry</name>
<rect>
<x>0</x>
<y>0</y>
<width>428</width>
<height>328</height>
</rect>
</property>
<property stdset="1">
<name>caption</name>
<string>Include File</string>
</property>
<vbox>
<property stdset="1">
<name>margin</name>
<number>11</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>6</number>
</property>
<widget>
<class>QLayoutWidget</class>
<property stdset="1">
<name>name</name>
<cstring>Layout10</cstring>
</property>
<hbox>
<property stdset="1">
<name>margin</name>
<number>0</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>6</number>
</property>
<widget>
<class>QLayoutWidget</class>
<property stdset="1">
<name>name</name>
<cstring>Layout7</cstring>
</property>
<vbox>
<property stdset="1">
<name>margin</name>
<number>0</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>6</number>
</property>
<widget>
<class>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>filenameLA</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>&amp;Filename</string>
</property>
<property>
<name>buddy</name>
<cstring>filenameED</cstring>
</property>
<property>
<name>toolTip</name>
<string></string>
</property>
</widget>
<widget>
<class>QLineEdit</class>
<property stdset="1">
<name>name</name>
<cstring>filenameED</cstring>
</property>
<property>
<name>toolTip</name>
<string>File name to include</string>
</property>
</widget>
<spacer>
<property>
<name>name</name>
<cstring>Spacer10</cstring>
</property>
<property stdset="1">
<name>orientation</name>
<enum>Vertical</enum>
</property>
<property stdset="1">
<name>sizeType</name>
<enum>MinimumExpanding</enum>
</property>
<property>
<name>sizeHint</name>
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</vbox>
</widget>
<widget>
<class>QLayoutWidget</class>
<property stdset="1">
<name>name</name>
<cstring>Layout9</cstring>
</property>
<vbox>
<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>browsePB</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>&amp;Browse ...</string>
</property>
<property>
<name>toolTip</name>
<string>Select a file</string>
</property>
</widget>
<spacer>
<property>
<name>name</name>
<cstring>Spacer2</cstring>
</property>
<property stdset="1">
<name>orientation</name>
<enum>Vertical</enum>
</property>
<property stdset="1">
<name>sizeType</name>
<enum>MinimumExpanding</enum>
</property>
<property>
<name>sizeHint</name>
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
<widget>
<class>QPushButton</class>
<property stdset="1">
<name>name</name>
<cstring>loadPB</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>&amp;Load</string>
</property>
<property>
<name>toolTip</name>
<string>Load the file</string>
</property>
</widget>
<spacer>
<property>
<name>name</name>
<cstring>Spacer11</cstring>
</property>
<property stdset="1">
<name>orientation</name>
<enum>Vertical</enum>
</property>
<property stdset="1">
<name>sizeType</name>
<enum>Expanding</enum>
</property>
<property>
<name>sizeHint</name>
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</vbox>
</widget>
</hbox>
</widget>
<spacer>
<property>
<name>name</name>
<cstring>Spacer12</cstring>
</property>
<property stdset="1">
<name>orientation</name>
<enum>Vertical</enum>
</property>
<property stdset="1">
<name>sizeType</name>
<enum>Expanding</enum>
</property>
<property>
<name>sizeHint</name>
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
<widget>
<class>QLayoutWidget</class>
<property stdset="1">
<name>name</name>
<cstring>Layout3</cstring>
</property>
<hbox>
<property stdset="1">
<name>margin</name>
<number>0</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>6</number>
</property>
<widget>
<class>QButtonGroup</class>
<property stdset="1">
<name>name</name>
<cstring>includeBG</cstring>
</property>
<property stdset="1">
<name>title</name>
<string>Include type</string>
</property>
<property stdset="1">
<name>sizePolicy</name>
<sizepolicy>
<hsizetype>5</hsizetype>
<vsizetype>7</vsizetype>
</sizepolicy>
</property>
<vbox>
<property stdset="1">
<name>margin</name>
<number>11</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>6</number>
</property>
<spacer>
<property>
<name>name</name>
<cstring>Spacer7</cstring>
</property>
<property stdset="1">
<name>orientation</name>
<enum>Vertical</enum>
</property>
<property stdset="1">
<name>sizeType</name>
<enum>Expanding</enum>
</property>
<property>
<name>sizeHint</name>
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
<widget>
<class>QRadioButton</class>
<property stdset="1">
<name>name</name>
<cstring>includeRB</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>&amp;Include</string>
</property>
<property>
<name>toolTip</name>
<string>FIXME</string>
</property>
</widget>
<spacer>
<property>
<name>name</name>
<cstring>Spacer4</cstring>
</property>
<property stdset="1">
<name>orientation</name>
<enum>Vertical</enum>
</property>
<property stdset="1">
<name>sizeType</name>
<enum>Expanding</enum>
</property>
<property>
<name>sizeHint</name>
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
<widget>
<class>QRadioButton</class>
<property stdset="1">
<name>name</name>
<cstring>inputRB</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>I&amp;nput</string>
</property>
<property>
<name>toolTip</name>
<string>FIXME</string>
</property>
</widget>
<spacer>
<property>
<name>name</name>
<cstring>Spacer5</cstring>
</property>
<property stdset="1">
<name>orientation</name>
<enum>Vertical</enum>
</property>
<property stdset="1">
<name>sizeType</name>
<enum>Expanding</enum>
</property>
<property>
<name>sizeHint</name>
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
<widget>
<class>QRadioButton</class>
<property stdset="1">
<name>name</name>
<cstring>verbatimRB</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>&amp;Verbatim</string>
</property>
<property>
<name>toolTip</name>
<string>FIXME</string>
</property>
</widget>
<spacer>
<property>
<name>name</name>
<cstring>Spacer6</cstring>
</property>
<property stdset="1">
<name>orientation</name>
<enum>Vertical</enum>
</property>
<property stdset="1">
<name>sizeType</name>
<enum>Expanding</enum>
</property>
<property>
<name>sizeHint</name>
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</vbox>
</widget>
<widget>
<class>QButtonGroup</class>
<property stdset="1">
<name>name</name>
<cstring>optionsBG</cstring>
</property>
<property stdset="1">
<name>title</name>
<string>Options</string>
</property>
<property stdset="1">
<name>sizePolicy</name>
<sizepolicy>
<hsizetype>5</hsizetype>
<vsizetype>7</vsizetype>
</sizepolicy>
</property>
<vbox>
<property stdset="1">
<name>margin</name>
<number>11</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>6</number>
</property>
<spacer>
<property>
<name>name</name>
<cstring>Spacer8</cstring>
</property>
<property stdset="1">
<name>orientation</name>
<enum>Vertical</enum>
</property>
<property stdset="1">
<name>sizeType</name>
<enum>Expanding</enum>
</property>
<property>
<name>sizeHint</name>
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
<widget>
<class>QCheckBox</class>
<property stdset="1">
<name>name</name>
<cstring>typesetCB</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>&amp;Don't typeset</string>
</property>
<property>
<name>toolTip</name>
<string>FIXME</string>
</property>
</widget>
<spacer>
<property>
<name>name</name>
<cstring>Spacer3_2</cstring>
</property>
<property stdset="1">
<name>orientation</name>
<enum>Vertical</enum>
</property>
<property stdset="1">
<name>sizeType</name>
<enum>Expanding</enum>
</property>
<property>
<name>sizeHint</name>
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
<widget>
<class>QCheckBox</class>
<property stdset="1">
<name>name</name>
<cstring>visiblespaceCB</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>Visible &amp;Space</string>
</property>
<property>
<name>toolTip</name>
<string>FIXME</string>
</property>
</widget>
<spacer>
<property>
<name>name</name>
<cstring>Spacer9</cstring>
</property>
<property stdset="1">
<name>orientation</name>
<enum>Vertical</enum>
</property>
<property stdset="1">
<name>sizeType</name>
<enum>Expanding</enum>
</property>
<property>
<name>sizeHint</name>
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</vbox>
</widget>
</hbox>
</widget>
<widget>
<class>QLayoutWidget</class>
<property stdset="1">
<name>name</name>
<cstring>Layout27</cstring>
</property>
<hbox>
<property stdset="1">
<name>margin</name>
<number>0</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>6</number>
</property>
<spacer>
<property>
<name>name</name>
<cstring>Spacer3</cstring>
</property>
<property stdset="1">
<name>orientation</name>
<enum>Horizontal</enum>
</property>
<property stdset="1">
<name>sizeType</name>
<enum>Expanding</enum>
</property>
<property>
<name>sizeHint</name>
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
<widget>
<class>QPushButton</class>
<property stdset="1">
<name>name</name>
<cstring>okPB</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>&amp;OK</string>
</property>
<property stdset="1">
<name>default</name>
<bool>true</bool>
</property>
</widget>
<widget>
<class>QPushButton</class>
<property stdset="1">
<name>name</name>
<cstring>closePB</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>&amp;Close</string>
</property>
</widget>
</hbox>
</widget>
</vbox>
</widget>
<connections>
<connection>
<sender>includeRB</sender>
<signal>toggled(bool)</signal>
<receiver>QIncludeDialogBase</receiver>
<slot>change_adaptor()</slot>
</connection>
<connection>
<sender>inputRB</sender>
<signal>toggled(bool)</signal>
<receiver>QIncludeDialogBase</receiver>
<slot>change_adaptor()</slot>
</connection>
<connection>
<sender>verbatimRB</sender>
<signal>toggled(bool)</signal>
<receiver>QIncludeDialogBase</receiver>
<slot>change_adaptor()</slot>
</connection>
<connection>
<sender>typesetCB</sender>
<signal>toggled(bool)</signal>
<receiver>QIncludeDialogBase</receiver>
<slot>change_adaptor()</slot>
</connection>
<connection>
<sender>visiblespaceCB</sender>
<signal>toggled(bool)</signal>
<receiver>QIncludeDialogBase</receiver>
<slot>change_adaptor()</slot>
</connection>
<connection>
<sender>filenameED</sender>
<signal>textChanged(const QString&amp;)</signal>
<receiver>QIncludeDialogBase</receiver>
<slot>change_adaptor()</slot>
</connection>
<connection>
<sender>loadPB</sender>
<signal>clicked()</signal>
<receiver>QIncludeDialogBase</receiver>
<slot>loadClicked()</slot>
</connection>
<connection>
<sender>browsePB</sender>
<signal>clicked()</signal>
<receiver>QIncludeDialogBase</receiver>
<slot>browseClicked()</slot>
</connection>
<connection>
<sender>includeBG</sender>
<signal>clicked(int)</signal>
<receiver>QIncludeDialogBase</receiver>
<slot>typeChanged(int)</slot>
</connection>
<slot access="public">browseClicked()</slot>
<slot access="public">change_adaptor()</slot>
<slot access="public">loadClicked()</slot>
<slot access="public">typeChanged(int)</slot>
</connections>
</UI>