mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-05 13:26:21 +00:00
use qlistbox for command buffer
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5150 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
7523a83784
commit
8d9743fe7e
@ -1,3 +1,9 @@
|
||||
2002-08-29 John Levon <levon@movementarian.org>
|
||||
|
||||
* QCommandBuffer.h:
|
||||
* QCommandBuffer.C: use a QListView not combo box.
|
||||
Qt Sucks.
|
||||
|
||||
2002-08-29 John Levon <levon@movementarian.org>
|
||||
|
||||
* ui/*: use size grippie consistently
|
||||
|
@ -11,12 +11,14 @@
|
||||
#include "support/filetools.h"
|
||||
#include "controllers/ControlCommandBuffer.h"
|
||||
#include "gettext.h"
|
||||
#include "debug.h"
|
||||
|
||||
#include "QtView.h"
|
||||
#include "QCommandBuffer.h"
|
||||
#include "QCommandEdit.h"
|
||||
|
||||
#include <qcombobox.h>
|
||||
#include <qlistbox.h>
|
||||
#include <qtoolbutton.h>
|
||||
#include <qpixmap.h>
|
||||
|
||||
@ -24,13 +26,22 @@ using std::vector;
|
||||
|
||||
namespace {
|
||||
|
||||
class QTempComboBox : public QComboBox {
|
||||
class QTempListBox : public QListBox {
|
||||
public:
|
||||
QTempComboBox(QWidget * parent) : QComboBox(parent) {
|
||||
setWFlags(WDestructiveClose);
|
||||
QTempListBox()
|
||||
: QListBox(0, 0,
|
||||
WType_Popup | WDestructiveClose) {
|
||||
setHScrollBarMode(AlwaysOff);
|
||||
}
|
||||
|
||||
protected:
|
||||
void keyPressEvent(QKeyEvent * e) {
|
||||
if (e->key() == Key_Escape) {
|
||||
hide();
|
||||
return;
|
||||
}
|
||||
QListBox::keyPressEvent(e);
|
||||
}
|
||||
|
||||
void popup() { QComboBox::popup(); }
|
||||
};
|
||||
|
||||
}
|
||||
@ -104,33 +115,45 @@ void QCommandBuffer::complete()
|
||||
|
||||
edit_->setText(new_input.c_str());
|
||||
|
||||
QTempComboBox * combo = new QTempComboBox(view_);
|
||||
combo->move(edit_->x() + x(), edit_->y() + y());
|
||||
|
||||
QTempListBox * list = new QTempListBox();
|
||||
vector<string>::const_iterator cit = comp.begin();
|
||||
vector<string>::const_iterator end = comp.end();
|
||||
for (; cit != end; ++cit) {
|
||||
combo->insertItem(cit->c_str());
|
||||
list->insertItem(cit->c_str());
|
||||
}
|
||||
|
||||
combo->setMinimumWidth(combo->sizeHint().width());
|
||||
combo->resize(combo->width(), edit_->height());
|
||||
// For some reason we get lots of empty entries and the
|
||||
// scrollbar is wrong as a result. No fix. Qt Sucks.
|
||||
|
||||
connect(combo, SIGNAL(activated(const QString &)),
|
||||
// width() is not big enough by a few pixels. Qt Sucks.
|
||||
list->setMinimumWidth(list->sizeHint().width() + 10);
|
||||
|
||||
list->resize(list->sizeHint());
|
||||
QPoint pos(edit_->mapToGlobal(QPoint(0, 0)));
|
||||
int y = pos.y() - list->height();
|
||||
if (y < 0)
|
||||
y = 0;
|
||||
list->move(pos.x(), y);
|
||||
|
||||
connect(list, SIGNAL(selected(const QString &)),
|
||||
this, SLOT(complete_selected(const QString &)));
|
||||
|
||||
combo->show();
|
||||
combo->setFocus();
|
||||
combo->popup();
|
||||
// Note we *cannot* make a single click popup, because
|
||||
// events get generated for outside the popup on Qt 2.3.1
|
||||
// and even gives valid QListBoxItem *'s. We have no way
|
||||
// to work past this. Qt Sucks.
|
||||
//connect(list, SIGNAL(clicked(QListBoxItem *)),
|
||||
// this, SLOT(complete_selected2(QListBoxItem *)));
|
||||
|
||||
list->show();
|
||||
list->setFocus();
|
||||
}
|
||||
|
||||
|
||||
void QCommandBuffer::complete_selected(const QString & str)
|
||||
{
|
||||
edit_->setText(str + " ");
|
||||
// FIXME
|
||||
QWidget const * widget = static_cast<QWidget const *>(sender());
|
||||
edit_->setFocus();
|
||||
const_cast<QWidget *>(widget)->hide();
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
class QtView;
|
||||
class QCommandEdit;
|
||||
class QListBoxItem;
|
||||
class ControlCommandBuffer;
|
||||
|
||||
class QCommandBuffer : public QToolBar {
|
||||
|
@ -193,7 +193,6 @@ bool QLImage::setPixmap(Params const & params)
|
||||
|
||||
void QLImage::clip(Params const & params)
|
||||
{
|
||||
lyxerr << "clip isNull " << pixmap_.isNull() << ", " <<xformed_pixmap_.isNull() << endl;
|
||||
if (xformed_pixmap_.isNull())
|
||||
return;
|
||||
|
||||
@ -228,7 +227,6 @@ void QLImage::clip(Params const & params)
|
||||
|
||||
void QLImage::rotate(Params const & params)
|
||||
{
|
||||
lyxerr << "rotate isNull " << pixmap_.isNull() << ", " <<xformed_pixmap_.isNull() << endl;
|
||||
if (xformed_pixmap_.isNull())
|
||||
return;
|
||||
|
||||
@ -248,7 +246,6 @@ void QLImage::rotate(Params const & params)
|
||||
|
||||
void QLImage::scale(Params const & params)
|
||||
{
|
||||
lyxerr << "scale isNull " << pixmap_.isNull() << ", " <<xformed_pixmap_.isNull() << endl;
|
||||
if (xformed_pixmap_.isNull())
|
||||
return;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user