+2002-08-25 John Levon <levon@movementarian.org>
+
+ * FileDialog.C:
+ * FileDialog_private.h:
+ * FileDialog_private.C: disable non-sync code due
+ to Qt bug. Add support for buttons
+
+2002-08-25 John Levon <levon@movementarian.org>
+
+ * QLPopupMenu.C: implement optional() support
+
+ * TODO: update
+
2002-08-25 John Levon <levon@movementarian.org>
* Makefile.am:
#include "FileDialog_private.h"
#include "debug.h"
+#include <qapplication.h>
+
using std::make_pair;
using std::pair;
using std::endl;
-FileDialog::FileDialog(LyXView *lv, string const &t, kb_action s, Button b1, Button b2)
- : private_(0), lv_(lv), title_(t), success_(s)
+struct FileDialog::Private {
+ Button b1;
+ Button b2;
+};
+
+FileDialog::FileDialog(LyXView *lv, string const & t, kb_action s, Button b1, Button b2)
+ : private_(new FileDialog::Private()), lv_(lv), title_(t), success_(s)
{
- // FIXME
+ private_->b1 = b1;
+ private_->b2 = b2;
}
FileDialog::~FileDialog()
{
+ delete private_;
}
if (mask.empty())
filter = _("*|All files");
- LyXFileDialog * dlg = new LyXFileDialog(lv_, success_, path, filter, title_);
+ LyXFileDialog dlg(path, filter, title_, private_->b1, private_->b2);
lyxerr[Debug::GUI] << "Select with path \"" << path << "\", mask \"" << filter << "\", suggested \"" << suggested << endl;
if (!suggested.empty())
- dlg->setSelection(suggested.c_str());
+ dlg.setSelection(suggested.c_str());
- if (success_ == LFUN_SELECT_FILE_SYNC) {
- FileDialog::Result result;
- lyxerr[Debug::GUI] << "Synchronous FileDialog : " << endl;
- result.first = FileDialog::Chosen;
- int res = dlg->exec();
- lyxerr[Debug::GUI] << "result " << res << endl;
- if (res == QDialog::Accepted)
- result.second = string(dlg->selectedFile().data());
- delete dlg;
- return result;
- }
+ // This code relies on DestructiveClose which is broken
+ // in Qt < 3.0.5. So we just don't allow it for now.
+ //if (success_ == LFUN_SELECT_FILE_SYNC) {
+
+ FileDialog::Result result;
+ lyxerr[Debug::GUI] << "Synchronous FileDialog : " << endl;
+ result.first = FileDialog::Chosen;
+ int res = dlg.exec();
+ lyxerr[Debug::GUI] << "result " << res << endl;
+ if (res == QDialog::Accepted)
+ result.second = string(dlg.selectedFile().data());
+ dlg.hide();
+ return result;
+#if 0
dlg->show();
return make_pair(FileDialog::Later, string());
+#endif
}
#include <config.h>
#include "LString.h"
+#include "support/lstrings.h"
#include <qapplication.h>
#include <qfiledialog.h>
+#include <qtoolbutton.h>
#include "QtLyXView.h"
#include "debug.h"
#include "FileDialog_private.h"
-LyXFileDialog::LyXFileDialog(LyXView * lv, kb_action a,
- string const & p, string const & m, string const & t)
- : QFileDialog(p.c_str(), m.c_str(), qApp->mainWidget(), t.c_str(),
- a == LFUN_SELECT_FILE_SYNC),
- lv_(lv), action_(a)
+namespace {
+ /// return the Qt form of the label
+ string const getLabel(string const & str) {
+ string label;
+ string sc(split(str, label, '|'));
+ if (sc.length() < 2)
+ return label;
+ string::size_type pos = label.find(sc[1]);
+ if (pos == string::npos)
+ return label;
+ label.insert(pos, "&");
+ return label;
+ }
+}
+
+LyXFileDialog::LyXFileDialog(string const & p, string const & m, string const & t,
+ FileDialog::Button const & b1, FileDialog::Button const & b2)
+ : QFileDialog(p.c_str(), m.c_str(), qApp->mainWidget(), t.c_str(), true),
+ b1_(0), b2_(0)
{
setCaption(t.c_str());
-}
-
-void LyXFileDialog::done(int what)
-{
- lyxerr[Debug::GUI] << "Done FileDialog, value " << what << std::endl;
+ if (!b1.first.empty()) {
+ b1_dir_ = b1.second;
+ b1_ = new QToolButton(this);
+ connect(b1_, SIGNAL(clicked()), this, SLOT(buttonClicked()));
+ b1_->setText(getLabel(b1.first).c_str());
+ addToolButton(b1_, true);
+ }
- if (action_ == LFUN_SELECT_FILE_SYNC) {
- QDialog::done(what);
- return;
+ if (!b2.first.empty()) {
+ b2_dir_ = b2.second;
+ b2_ = new QToolButton(this);
+ connect(b2_, SIGNAL(clicked()), this, SLOT(buttonClicked()));
+ b2_->setText(getLabel(b2.first).c_str());
+ addToolButton(b2_);
}
+}
- if (what == QDialog::Accepted)
- lv_->getLyXFunc().dispatch(FuncRequest(action_, selectedFile().data()));
- delete this;
+void LyXFileDialog::buttonClicked()
+{
+ if (sender() == b1_)
+ setDir(b1_dir_.c_str());
+ else if (sender() == b2_)
+ setDir(b2_dir_.c_str());
}
#include <qfiledialog.h>
-class LyXView;
+class QToolButton;
class LyXFileDialog : public QFileDialog
{
- Q_OBJECT
-
+ Q_OBJECT
public:
- LyXFileDialog(LyXView * lv, kb_action a, string const & p, string const & m, string const & t);
-
- friend class FileDialog;
+ LyXFileDialog(string const & p, string const & m, string const & t,
+ FileDialog::Button const & b1, FileDialog::Button const & b2);
public slots:
- void done(int);
-
+ void buttonClicked();
+
private:
- LyXView * lv_;
- kb_action action_;
+ QToolButton * b1_;
+ string b1_dir_;
+
+ QToolButton * b2_;
+ string b2_dir_;
};
#endif // FILEDIALOG_PRIVATE_H
void QGraphicsDialog::change_adaptor()
{
- lyxerr << "changed" << endl;
form_->changed();
}
int id(createMenu(this, m, owner_));
setItemEnabled(id, !disabled(m->submenuname()));
} else {
- insertItem(getLabel(*m).c_str(), m->action());
FuncStatus const status =
owner_->view()->getLyXFunc().getStatus(m->action());
+ if (status.disabled() && m->optional())
+ continue;
+ insertItem(getLabel(*m).c_str(), m->action());
setItemEnabled(m->action(), !status.disabled());
setItemChecked(m->action(), status.onoff(true));
}
Those with asterisks are what I perceive as being "big jobs"
-FileDialog
-
- - add buttons for Documents, Templates, etc. to the file dialog toolbar
- - work around Qt crash bug with double click
-
lyx_gui (qt)
- move out lyxserver
- - do dpi
+ - do dpi (cannot easily fix)
Menubar_pimpl
- - fix disabling submenu labels when appropriate
- - implement dynamic menus (may need serious backend changes) (*)(*)
- - dynamic last files
- - import/export/view/update
- - navigate
- implement openByName
- - why is note disabled, index enabled with no doc etc. ?
QAbout
QDocument
- - implement me. Need MVC (*)
+ - implement me. Need MVC (Edwin is on this)
qfont_loader
QGraphics
- - UI cleanups and fixes
+ - remaining UI cleanups and fixes
QInclude
- check no load stuff works ?
-qlkey
-
- - finish off the lists
-
QLImage
- get jpeg etc. to work
QLyXKeySym
- - isOK() - meaningful or not ?
- getISOEncoded - get this to work (*)
QPreferences