add graphics dialog - not quite working

the controllers really do make this piss easy to do :))


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2602 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
John Levon 2001-08-28 03:35:17 +00:00
parent 9c793ce3fc
commit db7cd3524d
11 changed files with 1370 additions and 6 deletions

View File

@ -1,3 +1,15 @@
2001-08-28 John Levon <moz@compsoc.man.ac.uk>
* ui/QCharacterDialog.ui:
* ui/QThesaurusDialog.ui: fix tab order
* QGraphics.[Ch]:
* QGraphicsDialog.[Ch]:
* ui/QGraphicsDialog.ui:
* Makefile.am:
* Makefile.dialogs:
* Dialogs.C: add graphics dialog
2001-08-28 John Levon <moz@compsoc.man.ac.uk>
* QThesaurus.C: clear selection on update

View File

@ -20,6 +20,7 @@
#include "QErrorDialog.h"
#include "QERTDialog.h"
#include "QExternalDialog.h"
#include "QGraphicsDialog.h"
#include "QIncludeDialog.h"
#include "QIndexDialog.h"
#include "QRefDialog.h"
@ -34,6 +35,7 @@
#include "QError.h"
#include "QERT.h"
#include "QExternal.h"
#include "QGraphics.h"
#include "QInclude.h"
#include "QIndex.h"
#include "QParagraph.h"
@ -60,6 +62,7 @@
#include "controllers/ControlError.h"
#include "controllers/ControlERT.h"
#include "controllers/ControlExternal.h"
#include "controllers/ControlGraphics.h"
#include "controllers/ControlInclude.h"
#include "controllers/ControlIndex.h"
#include "controllers/ControlRef.h"
@ -70,7 +73,6 @@
#include "controllers/ControlButtons.h"
#include "controllers/ControlCitation.h"
#include "controllers/ControlFloat.h"
#include "controllers/ControlGraphics.h"
#include "controllers/ControlLabel.h"
#include "controllers/ControlLog.h"
#include "controllers/ControlMinipage.h"
@ -103,6 +105,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 GUIGraphics<QGraphics, Qt2BC>(*lv, *this));
add(new GUIInclude<QInclude, Qt2BC>(*lv, *this));
add(new GUIIndex<QIndex, Qt2BC>(*lv, *this));
add(new GUIRef<QRef, Qt2BC>(*lv, *this));

View File

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

View File

@ -10,6 +10,7 @@ DIALOGS = \
QError \
QERT \
QExternal \
QGraphics \
QInclude \
QIndex \
QParagraph \
@ -41,6 +42,8 @@ DIALOGSOURCES = \
QERT.C QERTDialog.C \
QExternal.h QExternalDialog.h \
QExternal.C QExternalDialog.C \
QGraphics.h QGraphicsDialog.h \
QGraphics.C QGraphicsDialog.C \
QInclude.h QIncludeDialog.h \
QInclude.C QIncludeDialog.C \
QIndex.h QIndexDialog.h \
@ -74,6 +77,7 @@ MOCDIALOGS = \
QErrorDialog_moc.C \
QERTDialog_moc.C \
QExternalDialog_moc.C \
QGraphicsDialog_moc.C \
QIncludeDialog_moc.C \
QIndexDialog_moc.C \
QParagraphDialog_moc.C \
@ -105,6 +109,8 @@ UIDIALOGS = \
QERTDialogBase.h \
QExternalDialogBase.C \
QExternalDialogBase.h \
QGraphicsDialogBase.C \
QGraphicsDialogBase.h \
QIncludeDialogBase.h \
QIncludeDialogBase.C \
QIndexDialogBase.h \
@ -136,6 +142,7 @@ UIMOCDIALOGS = \
QErrorDialogBase_moc.C \
QERTDialogBase_moc.C \
QExternalDialogBase_moc.C \
QGraphicsDialogBase_moc.C \
QIncludeDialogBase_moc.C \
QIndexDialogBase_moc.C \
QParagraphDialogBase_moc.C \

View File

@ -0,0 +1,177 @@
/**
* \file QGraphics.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 "QGraphicsDialog.h"
#include "ControlGraphics.h"
#include "QGraphics.h"
#include "Qt2BC.h"
#include "gettext.h"
#include "debug.h"
#include "support/lstrings.h"
#include <qlineedit.h>
#include <qpushbutton.h>
#include <qcheckbox.h>
#include <qradiobutton.h>
#include <qcombobox.h>
typedef Qt2CB<ControlGraphics, Qt2DB<QGraphicsDialog> > base_class;
QGraphics::QGraphics(ControlGraphics & c)
: base_class(c, _("Graphics"))
{
}
void QGraphics::build_dialog()
{
dialog_.reset(new QGraphicsDialog(this));
bc().setOK(dialog_->okPB);
bc().setApply(dialog_->applyPB);
bc().setCancel(dialog_->closePB);
bc().addReadOnly(dialog_->filenameED);
bc().addReadOnly(dialog_->browsePB);
bc().addReadOnly(dialog_->widthED);
bc().addReadOnly(dialog_->widthCO);
bc().addReadOnly(dialog_->heightED);
bc().addReadOnly(dialog_->heightCO);
bc().addReadOnly(dialog_->scaleCB);
bc().addReadOnly(dialog_->rotateED);
bc().addReadOnly(dialog_->monochromeRB);
bc().addReadOnly(dialog_->grayscaleRB);
bc().addReadOnly(dialog_->colorRB);
bc().addReadOnly(dialog_->dontRB);
bc().addReadOnly(dialog_->subcaptionED);
}
namespace {
string const numtostr(double val) {
string a(tostr(val));
if (a == "0")
a = "";
return a;
}
} // namespace anon
void QGraphics::update_contents()
{
InsetGraphicsParams & igp = controller().params();
dialog_->filenameED->setText(igp.filename.c_str());
QRadioButton * button;
switch (igp.display) {
case InsetGraphicsParams::COLOR: button = dialog_->colorRB; break;
case InsetGraphicsParams::GRAYSCALE: button = dialog_->grayscaleRB; break;
case InsetGraphicsParams::MONOCHROME: button = dialog_->monochromeRB; break;
case InsetGraphicsParams::NONE: button = dialog_->dontRB; break;
}
button->setChecked(true);
int item = 0;
switch (igp.widthResize) {
case InsetGraphicsParams::INCH: item = 1; break;
case InsetGraphicsParams::PERCENT_PAGE: item = 2; break;
case InsetGraphicsParams::PERCENT_COLUMN: item = 3; break;
default: break;
}
dialog_->widthCO->setCurrentItem(item);
item = 0;
switch (igp.heightResize) {
case InsetGraphicsParams::INCH: item = 1; break;
case InsetGraphicsParams::PERCENT_PAGE: item = 2; break;
default: break;
}
dialog_->heightCO->setCurrentItem(item);
// FIXME: scale ???
dialog_->widthED->setText(numtostr(igp.widthSize).c_str());
dialog_->heightED->setText(numtostr(igp.heightSize).c_str());
dialog_->rotateED->setText(numtostr(igp.rotateAngle).c_str());
dialog_->subcaptionED->setText(igp.subcaptionText.c_str());
}
void QGraphics::apply()
{
InsetGraphicsParams & igp = controller().params();
if (dialog_->colorRB->isChecked())
igp.display = InsetGraphicsParams::COLOR;
else if (dialog_->grayscaleRB->isChecked())
igp.display = InsetGraphicsParams::GRAYSCALE;
else if (dialog_->monochromeRB->isChecked())
igp.display = InsetGraphicsParams::MONOCHROME;
else
igp.display = InsetGraphicsParams::NONE;
igp.subcaptionText = dialog_->subcaptionED->text().latin1();
igp.subcaption = !igp.subcaptionText.empty();
switch (dialog_->widthCO->currentItem()) {
case 0: igp.widthResize = InsetGraphicsParams::CM; break;
case 1: igp.widthResize = InsetGraphicsParams::INCH; break;
case 2: igp.widthResize = InsetGraphicsParams::PERCENT_PAGE; break;
case 3: igp.widthResize = InsetGraphicsParams::PERCENT_COLUMN; break;
default:;
}
if (string(dialog_->widthED->text().latin1()).empty()) {
igp.widthResize = InsetGraphicsParams::DEFAULT_SIZE;
igp.widthSize = 0.0;
} else {
igp.widthSize = strToDbl(dialog_->widthED->text().latin1());
}
switch (dialog_->heightCO->currentItem()) {
case 0: igp.heightResize = InsetGraphicsParams::CM; break;
case 1: igp.heightResize = InsetGraphicsParams::INCH; break;
case 2: igp.heightResize = InsetGraphicsParams::PERCENT_PAGE; break;
default:;
}
if (string(dialog_->heightED->text().latin1()).empty()) {
igp.heightResize = InsetGraphicsParams::DEFAULT_SIZE;
igp.heightSize = 0.0;
} else {
igp.heightSize = strToDbl(dialog_->heightED->text().latin1());
}
// FIXME: scale ???
igp.rotateAngle = strToDbl(dialog_->rotateED->text().latin1());
igp.filename = dialog_->filenameED->text().latin1();
}
void QGraphics::browse()
{
string const & name = controller().Browse(dialog_->filenameED->text().latin1());
if (!name.empty())
dialog_->filenameED->setText(name.c_str());
}
bool QGraphics::isValid()
{
return !string(dialog_->filenameED->text().latin1()).empty();
}

View File

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

View File

@ -0,0 +1,53 @@
/**
* \file QGraphicsDialog.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 "QGraphicsDialog.h"
#include "ControlGraphics.h"
#include "Dialogs.h"
#include "QGraphics.h"
#include "debug.h"
QGraphicsDialog::QGraphicsDialog(QGraphics * form)
: QGraphicsDialogBase(0, 0, false, 0),
form_(form)
{
connect(okPB, SIGNAL(clicked()),
form, SLOT(slotOK()));
connect(applyPB, SIGNAL(clicked()),
form, SLOT(slotOK()));
connect(closePB, SIGNAL(clicked()),
form, SLOT(slotClose()));
}
void QGraphicsDialog::change_adaptor()
{
form_->changed();
}
void QGraphicsDialog::closeEvent(QCloseEvent * e)
{
form_->slotWMHide();
e->accept();
}
void QGraphicsDialog::browseClicked()
{
form_->browse();
}

View File

@ -0,0 +1,35 @@
/**
* \file QGraphicsDialog.h
* Copyright 2001 the LyX Team
* Read the file COPYING
*
* \author John Levon <moz@compsoc.man.ac.uk>
*/
#ifndef QGRAPHICSDIALOG_H
#define QGRAPHICSDIALOG_H
#include <config.h>
#include "ui/QGraphicsDialogBase.h"
class QGraphics;
class QGraphicsDialog : public QGraphicsDialogBase
{ Q_OBJECT
public:
QGraphicsDialog(QGraphics * form);
protected slots:
virtual void change_adaptor();
virtual void browseClicked();
protected:
virtual void closeEvent(QCloseEvent * e);
private:
QGraphics * form_;
};
#endif // QGRAPHICSDIALOG_H

View File

@ -13,7 +13,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>372</width>
<width>368</width>
<height>256</height>
</rect>
</property>
@ -576,8 +576,9 @@
<tabstop>toggleallCB</tabstop>
<tabstop>sizeCO</tabstop>
<tabstop>miscCO</tabstop>
<tabstop>applyPB</tabstop>
<tabstop>autoapplyCB</tabstop>
<tabstop>okPB</tabstop>
<tabstop>applyPB</tabstop>
<tabstop>closePB</tabstop>
</tabstops>
</UI>

File diff suppressed because it is too large Load Diff

View File

@ -13,7 +13,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>482</width>
<width>478</width>
<height>442</height>
</rect>
</property>
@ -80,6 +80,13 @@
<name>name</name>
<cstring>Spacer2</cstring>
</property>
<property stdset="1">
<name>sizePolicy</name>
<sizepolicy>
<hsizetype>7</hsizetype>
<vsizetype>1</vsizetype>
</sizepolicy>
</property>
<property stdset="1">
<name>orientation</name>
<enum>Horizontal</enum>
@ -474,8 +481,8 @@
<slot access="public">selectionChanged(const QString &amp;)</slot>
</connections>
<tabstops>
<tabstop>TabWidget2</tabstop>
<tabstop>entryED</tabstop>
<tabstop>TabWidget2</tabstop>
<tabstop>nounsLB</tabstop>
<tabstop>verbsLB</tabstop>
<tabstop>adjectivesLB</tabstop>