there were some complaints about the bulletpanel in Status.15x:
* The UI for bullet selection in the documents settings looks weird
(Joost 4/11/06):
There is a big listbox just to select one of the four levels.
Isn't this supposed to be a drop-down list or something like that?
* The bullet selection widget shows the bullets in 5 columns (instead of 6)
for me, and hence does not fit into the window.
(JSpitzm 2006-11-06)
...
i hope the attached improves on the current situation
perhaps someone who sees the above (jurgen?) can give the patch a try?
thanks, ed.
Index: src/frontends/qt4/BulletsModule.C
===================================================================
--- src/frontends/qt4/BulletsModule.C (revision 16186)
+++ src/frontends/qt4/BulletsModule.C (working copy)
@@ -12,11 +12,13 @@
#include "BulletsModule.h"
#include "qt_helpers.h"
+#include "debug.h"
#include "support/filetools.h"
#include <QPixmap>
#include <QPainter>
+#include <QToolButton>
#include <boost/assert.hpp>
@@ -26,6 +28,7 @@
using std::string;
+
BulletsModule::BulletsModule(QWidget * , char const * , Qt::WFlags)
{
setupUi(this);
@@ -33,25 +36,29 @@
for (int iter = 0; iter < 4; ++iter) {
bullets_[iter] = ITEMIZE_DEFAULTS[iter];
}
- current_font_ = -1;
- current_char_ = 0;
// add levels
+ levelLW->blockSignals(true);
levelLW->addItem("1");
levelLW->addItem("2");
levelLW->addItem("3");
levelLW->addItem("4");
+ levelLW->blockSignals(false);
+ buttongroup_ = new QButtonGroup(this);
+ // not nice but the first widget gets wrong sizehint
+ QWidget * dummy = new QWidget;
+ bulletpaneSW->addWidget(dummy);
// insert pixmaps
- setupPanel(new QListWidget(bulletpaneSW), qt_("Standard"), "standard");
- setupPanel(new QListWidget(bulletpaneSW), qt_("Maths"), "amssymb");
- setupPanel(new QListWidget(bulletpaneSW), qt_("Dings 1"), "psnfss1");
- setupPanel(new QListWidget(bulletpaneSW), qt_("Dings 2"), "psnfss2");
- setupPanel(new QListWidget(bulletpaneSW), qt_("Dings 3"), "psnfss3");
- setupPanel(new QListWidget(bulletpaneSW), qt_("Dings 4"), "psnfss4");
+ setupPanel(qt_("Standard"), "standard");
+ setupPanel(qt_("Maths"), "amssymb");
+ setupPanel(qt_("Dings 1"), "psnfss1");
+ setupPanel(qt_("Dings 2"), "psnfss2");
+ setupPanel(qt_("Dings 3"), "psnfss3");
+ setupPanel(qt_("Dings 4"), "psnfss4");
+ connect(buttongroup_, SIGNAL(buttonClicked(int)), this,
SLOT(updateBullet(int)));
connect(levelLW, SIGNAL(currentRowChanged(int)), this,
SLOT(showLevel(int)));
- connect(bulletpaneCO, SIGNAL(activated(int)), bulletpaneSW,
SLOT(setCurrentIndex(int)));
}
@@ -60,63 +67,68 @@
}
-void BulletsModule::setupPanel(QListWidget * lw, QString panelname,
std::string fname)
+void BulletsModule::on_bulletpaneCO_activated(int level)
{
- connect(lw, SIGNAL(currentItemChanged(QListWidgetItem*,
QListWidgetItem*)),
- this, SLOT(bulletSelected(QListWidgetItem *,
QListWidgetItem*)));
+ // + 1 to avoid dummy widget:
+ bulletpaneSW->setCurrentIndex(level + 1);
+}
+void BulletsModule::setupPanel(QString panelname, std::string fname)
+{
// add panelname to combox
bulletpaneCO->addItem(panelname);
- // get pixmap with bullets
+ //
+ QWidget * widget = new QWidget;
+ QGridLayout * layout_ = new QGridLayout(widget);
+ layout_->setSizeConstraint(QLayout::SetFixedSize);
+ layout_->setSpacing(0);
+ layout_->setMargin(0);
+
+ // get pixmap with 6 x 6 = 36 bullets
QPixmap pixmap = QPixmap(toqstr(libFileSearch("images", fname,
"xpm").absFilename()));
int const w = pixmap.width() / 6;
int const h = pixmap.height() / 6;
- // apply setting to listwidget
- lw->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
- lw->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
- lw->setViewMode(QListView::IconMode);
- lw->setFlow(QListView::LeftToRight);
- lw->setMovement(QListView::Static);
- lw->setUniformItemSizes(true);
- lw->setGridSize( QSize(w , h) );
- lw->resize( 6 * w + 6 , 6 * h);
- bulletpaneSW->setMinimumSize( 6 * w + 6 , 6 * h);
-
// get individual bullets from pixmap
for (int row = 0; row < 6; ++row) {
for (int col = 0; col < 6; ++col) {
- QPixmap small(w, h);
+ QPixmap small(h, h);
small.fill();
QPainter painter(&small);
- painter.drawPixmap(small.rect(), pixmap, QRect(col * w,
row * h, w, h));
- new QListWidgetItem(QIcon(small), "" , lw, (6 * row +
col));
+ painter.drawPixmap(small.rect(), pixmap, QRect(col * w
+ 6, row * h , h, h));
+ QPushButton * pb = new QPushButton;
+ pb->setPalette(QPalette(Qt::white));
+ pb->setIcon(QIcon(small));
+ pb->setIconSize(small.size());
+ pb->setFlat(true);
+ pb->setCheckable(true);
+ layout_->addWidget(pb, row, col);
+ buttongroup_->addButton(pb, row * 6 + col);
+ buttons_.push_back(pb);
}
}
// add bulletpanel to stackedwidget
- bulletpaneSW->addWidget(lw);
+ bulletpaneSW->addWidget(widget);
}
void BulletsModule::showLevel(int level)
{
- // unselect previous item
- selectItem(current_font_, current_char_, false);
-
- current_font_ = bullets_[level].getFont();
-
if (bullets_[level].getFont() < 0) {
customCB->setCheckState(Qt::Checked);
customLE->setText(toqstr(bullets_[level].getText()));
} else {
+ int const c = bullets_[level].getCharacter();
+ int const f = bullets_[level].getFont();
+ bulletpaneCO->setCurrentIndex(f);
+ // + 1 to avoid dummy widget:
+ bulletpaneSW->setCurrentIndex(f + 1);
customCB->setCheckState(Qt::Unchecked);
customLE->clear();
- current_char_ = bullets_[level].getCharacter();
- selectItem(current_font_, current_char_, true);
- bulletpaneCO->setCurrentIndex(current_font_);
- bulletpaneSW->setCurrentIndex(current_font_);
+ // 36 bullets per font
+ buttons_[f * 6 * 6 + c]->setChecked(true);
}
bulletsizeCO->setCurrentIndex(bullets_[level].getSize() + 1);
}
@@ -125,20 +137,15 @@
void BulletsModule::init()
{
levelLW->setCurrentRow(0);
- showLevel(0);
}
-void BulletsModule::bulletSelected(QListWidgetItem * item, QListWidgetItem *)
+void BulletsModule::updateBullet(int id)
{
- // unselect previous item
- selectItem(current_font_, current_char_, false);
-
int const level = levelLW->currentRow();
- bullets_[level].setCharacter(item->type());
- bullets_[level].setFont(bulletpaneCO->currentIndex());
- current_font_ = bulletpaneCO->currentIndex();
- current_char_ = item->type();
+ int const new_font = bulletpaneCO->currentIndex();
+ bullets_[level].setFont(new_font);
+ bullets_[level].setCharacter(id);
changed();
}
@@ -146,35 +153,23 @@
void BulletsModule::on_customCB_toggled(bool custom)
{
if (!custom) {
- if (current_font_ < 0)
- current_font_ = bulletpaneCO->currentIndex();
- return;
+ int const level = levelLW->currentRow();
+ if (bullets_[level].getFont() < 0)
+ bullets_[level] = ITEMIZE_DEFAULTS[level];
}
- // unselect previous item
- selectItem(current_font_, current_char_, false);
- current_font_ = -1;
changed();
}
-void BulletsModule::selectItem(int font, int character, bool select)
-{
- if (font < 0)
- return;
-
- QListWidget * lw = static_cast<QListWidget
*>(bulletpaneSW->widget(font));
- lw->setItemSelected(lw->item(character), select);
-}
-
-
void BulletsModule::on_customLE_textEdited(const QString & text)
{
if (customCB->checkState() == Qt::Unchecked)
return;
- bullets_[levelLW->currentRow()].setFont(current_font_);
- bullets_[levelLW->currentRow()].setText(qstring_to_ucs4(text));
+ int const level = levelLW->currentRow();
+ bullets_[level].setFont(bullets_[level].getFont());
+ bullets_[level].setText(qstring_to_ucs4(text));
changed();
}
Index: src/frontends/qt4/BulletsModule.h
===================================================================
--- src/frontends/qt4/BulletsModule.h (revision 16186)
+++ src/frontends/qt4/BulletsModule.h (working copy)
@@ -12,14 +12,12 @@
#ifndef QBULLETSMODULE_H
#define QBULLETSMODULE_H
-
#include "ui/BulletsUi.h"
#include "Bullet.h"
#include <boost/array.hpp>
#include <QWidget>
-
namespace lyx {
class BulletsModule : public QWidget, public Ui::BulletsUi {
@@ -27,7 +25,6 @@
public:
BulletsModule(QWidget * parent = 0, const char * name = 0, Qt::WFlags
fl = 0);
-
~BulletsModule();
/// set a bullet
@@ -42,20 +39,22 @@
protected Q_SLOTS:
+ void on_bulletpaneCO_activated(int level);
void on_bulletsizeCO_activated(int level);
void on_customCB_toggled(bool);
void on_customLE_textEdited(const QString &);
- void bulletSelected(QListWidgetItem *, QListWidgetItem*);
+ void updateBullet(int);
void showLevel(int);
private:
- void selectItem(int font, int character, bool select);
- void setupPanel(QListWidget * lw, QString panelname, std::string fname);
+ void setupPanel(QString panelname, std::string fname);
- /// store results
+ // store results
boost::array<Bullet, 4> bullets_;
- int current_font_;
- int current_char_;
+ // manage the buttons
+ QButtonGroup * buttongroup_;
+ // we want these to toggle
+ std::vector<QPushButton *> buttons_;
};
Index: src/frontends/qt4/ui/BulletsUi.ui
===================================================================
--- src/frontends/qt4/ui/BulletsUi.ui (revision 16186)
+++ src/frontends/qt4/ui/BulletsUi.ui (working copy)
@@ -8,8 +8,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>415</width>
- <height>321</height>
+ <width>363</width>
+ <height>368</height>
</rect>
</property>
<layout class="QGridLayout" >
@@ -19,109 +19,20 @@
<property name="spacing" >
<number>6</number>
</property>
- <item row="1" column="2" colspan="2" >
- <widget class="QComboBox" name="bulletpaneCO" >
- <property name="sizePolicy" >
- <sizepolicy>
- <hsizetype>7</hsizetype>
- <vsizetype>0</vsizetype>
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
+ <item rowspan="3" row="0" column="2" >
+ <spacer>
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
</property>
- </widget>
- </item>
- <item row="1" column="1" >
- <widget class="QLabel" name="label_2" >
- <property name="text" >
- <string>&Font:</string>
+ <property name="sizeHint" >
+ <size>
+ <width>40</width>
+ <height>231</height>
+ </size>
</property>
- <property name="buddy" >
- <cstring>bulletpaneCO</cstring>
- </property>
- </widget>
+ </spacer>
</item>
- <item row="4" column="1" colspan="2" >
- <widget class="QLabel" name="sizeL" >
- <property name="text" >
- <string>Si&ze:</string>
- </property>
- <property name="alignment" >
- <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
- </property>
- <property name="buddy" >
- <cstring>bulletsizeCO</cstring>
- </property>
- </widget>
- </item>
- <item row="4" column="3" >
- <widget class="QComboBox" name="bulletsizeCO" >
- <property name="sizePolicy" >
- <sizepolicy>
- <hsizetype>7</hsizetype>
- <vsizetype>0</vsizetype>
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <item>
- <property name="text" >
- <string>Default</string>
- </property>
- </item>
- <item>
- <property name="text" >
- <string>Tiny</string>
- </property>
- </item>
- <item>
- <property name="text" >
- <string>Smallest</string>
- </property>
- </item>
- <item>
- <property name="text" >
- <string>Smaller</string>
- </property>
- </item>
- <item>
- <property name="text" >
- <string>Small</string>
- </property>
- </item>
- <item>
- <property name="text" >
- <string>Normal</string>
- </property>
- </item>
- <item>
- <property name="text" >
- <string>Large</string>
- </property>
- </item>
- <item>
- <property name="text" >
- <string>Larger</string>
- </property>
- </item>
- <item>
- <property name="text" >
- <string>Largest</string>
- </property>
- </item>
- <item>
- <property name="text" >
- <string>Huge</string>
- </property>
- </item>
- <item>
- <property name="text" >
- <string>Huger</string>
- </property>
- </item>
- </widget>
- </item>
- <item row="5" column="3" >
+ <item row="3" column="1" >
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
@@ -134,22 +45,162 @@
</property>
</spacer>
</item>
- <item row="3" column="3" >
- <widget class="QLineEdit" name="customLE" >
- <property name="enabled" >
- <bool>false</bool>
+ <item row="0" column="1" >
+ <layout class="QHBoxLayout" >
+ <property name="margin" >
+ <number>0</number>
</property>
- </widget>
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <item>
+ <widget class="QLabel" name="label_2" >
+ <property name="text" >
+ <string>&Font:</string>
+ </property>
+ <property name="buddy" >
+ <cstring>bulletpaneCO</cstring>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QComboBox" name="bulletpaneCO" >
+ <property name="sizePolicy" >
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </item>
+ </layout>
</item>
- <item row="3" column="1" colspan="2" >
- <widget class="QCheckBox" name="customCB" >
- <property name="text" >
- <string>&Custom Bullet:</string>
+ <item row="1" column="1" >
+ <widget class="QStackedWidget" name="bulletpaneSW" >
+ <property name="frameShape" >
+ <enum>QFrame::WinPanel</enum>
</property>
+ <property name="frameShadow" >
+ <enum>QFrame::Sunken</enum>
+ </property>
</widget>
</item>
- <item rowspan="5" row="1" column="0" >
+ <item row="2" column="1" >
+ <layout class="QGridLayout" >
+ <property name="margin" >
+ <number>0</number>
+ </property>
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <item row="1" column="1" >
+ <widget class="QComboBox" name="bulletsizeCO" >
+ <property name="sizePolicy" >
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <item>
+ <property name="text" >
+ <string>Default</string>
+ </property>
+ </item>
+ <item>
+ <property name="text" >
+ <string>Tiny</string>
+ </property>
+ </item>
+ <item>
+ <property name="text" >
+ <string>Smallest</string>
+ </property>
+ </item>
+ <item>
+ <property name="text" >
+ <string>Smaller</string>
+ </property>
+ </item>
+ <item>
+ <property name="text" >
+ <string>Small</string>
+ </property>
+ </item>
+ <item>
+ <property name="text" >
+ <string>Normal</string>
+ </property>
+ </item>
+ <item>
+ <property name="text" >
+ <string>Large</string>
+ </property>
+ </item>
+ <item>
+ <property name="text" >
+ <string>Larger</string>
+ </property>
+ </item>
+ <item>
+ <property name="text" >
+ <string>Largest</string>
+ </property>
+ </item>
+ <item>
+ <property name="text" >
+ <string>Huge</string>
+ </property>
+ </item>
+ <item>
+ <property name="text" >
+ <string>Huger</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item row="1" column="0" >
+ <widget class="QLabel" name="sizeL" >
+ <property name="text" >
+ <string>Si&ze:</string>
+ </property>
+ <property name="alignment" >
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ <property name="buddy" >
+ <cstring>bulletsizeCO</cstring>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1" >
+ <widget class="QLineEdit" name="customLE" >
+ <property name="enabled" >
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="0" >
+ <widget class="QCheckBox" name="customCB" >
+ <property name="text" >
+ <string>&Custom Bullet:</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item row="1" column="0" >
<widget class="QListWidget" name="levelLW" >
+ <property name="sizePolicy" >
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>7</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
<property name="maximumSize" >
<size>
<width>96</width>
@@ -158,19 +209,6 @@
</property>
</widget>
</item>
- <item rowspan="5" row="1" column="4" >
- <spacer>
- <property name="orientation" >
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" >
- <size>
- <width>16</width>
- <height>271</height>
- </size>
- </property>
- </spacer>
- </item>
<item row="0" column="0" >
<widget class="QLabel" name="label" >
<property name="text" >
@@ -181,9 +219,6 @@
</property>
</widget>
</item>
- <item row="2" column="1" colspan="3" >
- <widget class="QStackedWidget" name="bulletpaneSW" />
- </item>
</layout>
</widget>
<pixmapfunction></pixmapfunction>