2006-03-05 17:24:44 +00:00
|
|
|
/**
|
|
|
|
* \file BulletsModule.C
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* \author Edwin Leuven
|
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include "BulletsModule.h"
|
|
|
|
#include "qt_helpers.h"
|
|
|
|
|
|
|
|
#include "support/filetools.h"
|
|
|
|
|
2006-05-08 11:44:37 +00:00
|
|
|
#include <QPixmap>
|
2006-08-15 14:55:34 +00:00
|
|
|
#include <QPainter>
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
#include <boost/assert.hpp>
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
namespace lyx {
|
|
|
|
|
2006-04-09 08:42:58 +00:00
|
|
|
using lyx::support::libFileSearch;
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
using std::string;
|
|
|
|
|
2006-08-13 15:44:05 +00:00
|
|
|
BulletsModule::BulletsModule(QWidget * , char const * , Qt::WFlags)
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
|
|
|
setupUi(this);
|
|
|
|
|
|
|
|
for (int iter = 0; iter < 4; ++iter) {
|
|
|
|
bullets_[iter] = ITEMIZE_DEFAULTS[iter];
|
|
|
|
}
|
2006-08-14 15:07:13 +00:00
|
|
|
current_font_ = -1;
|
|
|
|
current_char_ = 0;
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2006-08-13 15:44:05 +00:00
|
|
|
// add levels
|
|
|
|
levelLW->addItem("1");
|
|
|
|
levelLW->addItem("2");
|
|
|
|
levelLW->addItem("3");
|
|
|
|
levelLW->addItem("4");
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
// insert pixmaps
|
2006-08-13 15:44:05 +00:00
|
|
|
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");
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2006-08-13 15:44:05 +00:00
|
|
|
connect(levelLW, SIGNAL(currentRowChanged(int)), this, SLOT(showLevel(int)));
|
|
|
|
connect(bulletpaneCO, SIGNAL(activated(int)), bulletpaneSW, SLOT(setCurrentIndex(int)));
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
BulletsModule::~BulletsModule()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-08-13 15:44:05 +00:00
|
|
|
void BulletsModule::setupPanel(QListWidget * lw, QString panelname, std::string fname)
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
2006-08-13 15:44:05 +00:00
|
|
|
connect(lw, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)),
|
|
|
|
this, SLOT(bulletSelected(QListWidgetItem *, QListWidgetItem*)));
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2006-08-13 15:44:05 +00:00
|
|
|
// add panelname to combox
|
|
|
|
bulletpaneCO->addItem(panelname);
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2006-08-13 15:44:05 +00:00
|
|
|
// get pixmap with bullets
|
|
|
|
QPixmap pixmap = QPixmap(toqstr(libFileSearch("images", fname, "xpm")));
|
|
|
|
int const w = pixmap.width() / 6;
|
|
|
|
int const h = pixmap.height() / 6;
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2006-08-13 15:44:05 +00:00
|
|
|
// 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) );
|
2006-11-10 17:00:21 +00:00
|
|
|
lw->resize( 6 * w + 6 , 6 * h);
|
2006-08-13 15:44:05 +00:00
|
|
|
bulletpaneSW->setMinimumSize( 6 * w + 6 , 6 * h);
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2006-08-13 15:44:05 +00:00
|
|
|
// get individual bullets from pixmap
|
|
|
|
for (int row = 0; row < 6; ++row) {
|
|
|
|
for (int col = 0; col < 6; ++col) {
|
2006-11-10 17:00:21 +00:00
|
|
|
QPixmap small(w, h);
|
2006-08-14 15:07:13 +00:00
|
|
|
small.fill();
|
2006-08-15 14:55:34 +00:00
|
|
|
QPainter painter(&small);
|
|
|
|
painter.drawPixmap(small.rect(), pixmap, QRect(col * w, row * h, w, h));
|
2006-11-10 17:00:21 +00:00
|
|
|
new QListWidgetItem(QIcon(small), "" , lw, (6 * row + col));
|
2006-08-13 15:44:05 +00:00
|
|
|
}
|
|
|
|
}
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2006-08-13 15:44:05 +00:00
|
|
|
// add bulletpanel to stackedwidget
|
|
|
|
bulletpaneSW->addWidget(lw);
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-08-13 15:44:05 +00:00
|
|
|
void BulletsModule::showLevel(int level)
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
2006-08-14 15:07:13 +00:00
|
|
|
// unselect previous item
|
|
|
|
selectItem(current_font_, current_char_, false);
|
|
|
|
|
2006-08-13 15:44:05 +00:00
|
|
|
current_font_ = bullets_[level].getFont();
|
|
|
|
|
2006-11-10 17:00:21 +00:00
|
|
|
if (bullets_[level].getFont() < 0) {
|
2006-08-13 15:44:05 +00:00
|
|
|
customCB->setCheckState(Qt::Checked);
|
|
|
|
customLE->setText(toqstr(bullets_[level].getText()));
|
|
|
|
} else {
|
|
|
|
customCB->setCheckState(Qt::Unchecked);
|
|
|
|
customLE->clear();
|
2006-08-14 15:07:13 +00:00
|
|
|
current_char_ = bullets_[level].getCharacter();
|
|
|
|
selectItem(current_font_, current_char_, true);
|
2006-08-13 15:44:05 +00:00
|
|
|
bulletpaneCO->setCurrentIndex(current_font_);
|
|
|
|
bulletpaneSW->setCurrentIndex(current_font_);
|
|
|
|
}
|
|
|
|
bulletsizeCO->setCurrentIndex(bullets_[level].getSize() + 1);
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-08-13 15:44:05 +00:00
|
|
|
void BulletsModule::init()
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
2006-08-13 15:44:05 +00:00
|
|
|
levelLW->setCurrentRow(0);
|
|
|
|
showLevel(0);
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-08-13 15:44:05 +00:00
|
|
|
void BulletsModule::bulletSelected(QListWidgetItem * item, QListWidgetItem *)
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
2006-08-14 15:07:13 +00:00
|
|
|
// unselect previous item
|
|
|
|
selectItem(current_font_, current_char_, false);
|
|
|
|
|
2006-08-13 15:44:05 +00:00
|
|
|
int const level = levelLW->currentRow();
|
|
|
|
bullets_[level].setCharacter(item->type());
|
|
|
|
bullets_[level].setFont(bulletpaneCO->currentIndex());
|
|
|
|
current_font_ = bulletpaneCO->currentIndex();
|
2006-08-14 15:07:13 +00:00
|
|
|
current_char_ = item->type();
|
2006-06-30 14:11:50 +00:00
|
|
|
changed();
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-08-13 15:44:05 +00:00
|
|
|
void BulletsModule::on_customCB_toggled(bool custom)
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
2006-08-13 15:44:05 +00:00
|
|
|
if (!custom) {
|
2006-11-10 17:00:21 +00:00
|
|
|
if (current_font_ < 0)
|
2006-08-13 15:44:05 +00:00
|
|
|
current_font_ = bulletpaneCO->currentIndex();
|
2006-03-05 17:24:44 +00:00
|
|
|
return;
|
2006-08-13 15:44:05 +00:00
|
|
|
}
|
|
|
|
|
2006-08-14 15:07:13 +00:00
|
|
|
// unselect previous item
|
|
|
|
selectItem(current_font_, current_char_, false);
|
2006-08-13 15:44:05 +00:00
|
|
|
current_font_ = -1;
|
2006-06-30 14:11:50 +00:00
|
|
|
changed();
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-08-14 15:07:13 +00:00
|
|
|
void BulletsModule::selectItem(int font, int character, bool select)
|
|
|
|
{
|
2006-11-10 17:00:21 +00:00
|
|
|
if (font < 0)
|
2006-08-14 15:07:13 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
QListWidget * lw = static_cast<QListWidget *>(bulletpaneSW->widget(font));
|
|
|
|
lw->setItemSelected(lw->item(character), select);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-08-13 15:44:05 +00:00
|
|
|
void BulletsModule::on_customLE_textEdited(const QString & text)
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
2006-08-13 15:44:05 +00:00
|
|
|
if (customCB->checkState() == Qt::Unchecked)
|
|
|
|
return;
|
|
|
|
|
|
|
|
bullets_[levelLW->currentRow()].setFont(current_font_);
|
2006-10-20 19:26:23 +00:00
|
|
|
bullets_[levelLW->currentRow()].setText(qstring_to_ucs4(text));
|
2006-08-13 15:44:05 +00:00
|
|
|
changed();
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-08-13 15:44:05 +00:00
|
|
|
void BulletsModule::on_bulletsizeCO_activated(int size)
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
2006-08-13 15:44:05 +00:00
|
|
|
// -1 apparently means default...
|
|
|
|
bullets_[levelLW->currentRow()].setSize(size - 1);
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-08-13 15:44:05 +00:00
|
|
|
void BulletsModule::setBullet(int level, Bullet const & bullet)
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
|
|
|
bullets_[level] = bullet;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Bullet const & BulletsModule::getBullet(int level) const
|
|
|
|
{
|
|
|
|
return bullets_[level];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
} // namespace lyx
|
|
|
|
|
|
|
|
|
2006-05-18 08:51:12 +00:00
|
|
|
#include "BulletsModule_moc.cpp"
|
2006-10-21 00:16:43 +00:00
|
|
|
|