2002-10-09 08:59:02 +00:00
|
|
|
/**
|
2002-11-12 10:12:06 +00:00
|
|
|
* \file BulletsModule.C
|
2002-10-09 08:59:02 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* \author Edwin Leuven
|
2003-03-29 01:29:20 +00:00
|
|
|
* \author John Levon
|
2002-10-09 08:59:02 +00:00
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* Full author contact details are available in file CREDITS.
|
2002-10-09 08:59:02 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
2003-09-09 17:25:35 +00:00
|
|
|
|
2002-12-17 20:37:13 +00:00
|
|
|
#include "qt_helpers.h"
|
2002-10-09 08:59:02 +00:00
|
|
|
|
2003-03-29 01:29:20 +00:00
|
|
|
#include "support/filetools.h"
|
2002-10-09 08:59:02 +00:00
|
|
|
|
2003-03-29 01:29:20 +00:00
|
|
|
#include "QBrowseBox.h"
|
|
|
|
#include "BulletsModule.h"
|
2002-12-16 22:24:33 +00:00
|
|
|
|
|
|
|
#include <qinputdialog.h>
|
2002-10-09 08:59:02 +00:00
|
|
|
#include <qpopupmenu.h>
|
2003-03-29 01:29:20 +00:00
|
|
|
#include <qpushbutton.h>
|
2002-11-12 10:12:06 +00:00
|
|
|
#include <qcombobox.h>
|
2002-10-20 01:48:28 +00:00
|
|
|
|
2003-09-09 18:19:34 +00:00
|
|
|
#include <boost/assert.hpp>
|
|
|
|
|
|
|
|
using lyx::support::LibFileSearch;
|
|
|
|
|
2003-06-30 23:56:22 +00:00
|
|
|
|
2003-06-28 01:23:11 +00:00
|
|
|
BulletsModule::BulletsModule(QWidget * parent, const char * name, WFlags fl)
|
2003-03-29 01:29:20 +00:00
|
|
|
: BulletsModuleBase(parent, name, fl), tmpbulletset(0)
|
2002-10-09 08:59:02 +00:00
|
|
|
{
|
2002-12-16 22:24:33 +00:00
|
|
|
for (int iter = 0; iter < 4; ++iter) {
|
|
|
|
bullets_[iter] = ITEMIZE_DEFAULTS[iter];
|
|
|
|
}
|
2003-02-25 13:35:26 +00:00
|
|
|
|
2002-11-08 00:09:00 +00:00
|
|
|
QPopupMenu * pm = new QPopupMenu(this);
|
2002-12-01 22:59:25 +00:00
|
|
|
|
2002-10-20 01:48:28 +00:00
|
|
|
QPopupMenu * pm1 = new QPopupMenu(pm);
|
|
|
|
QPopupMenu * pm2 = new QPopupMenu(pm);
|
2002-11-08 00:09:00 +00:00
|
|
|
QPopupMenu * pm3 = new QPopupMenu(pm);
|
|
|
|
QPopupMenu * pm4 = new QPopupMenu(pm);
|
|
|
|
QPopupMenu * pm5 = new QPopupMenu(pm);
|
|
|
|
QPopupMenu * pm6 = new QPopupMenu(pm);
|
|
|
|
|
2002-11-12 10:12:06 +00:00
|
|
|
standard_ = new QBrowseBox(6, 6, pm1);
|
|
|
|
maths_ = new QBrowseBox(6, 6, pm2);
|
|
|
|
ding1_ = new QBrowseBox(6, 6, pm3);
|
|
|
|
ding2_ = new QBrowseBox(6, 6, pm4);
|
|
|
|
ding3_ = new QBrowseBox(6, 6, pm5);
|
|
|
|
ding4_ = new QBrowseBox(6, 6, pm6);
|
2002-11-08 00:09:00 +00:00
|
|
|
|
2002-11-12 10:12:06 +00:00
|
|
|
pm1->insertItem(standard_);
|
|
|
|
pm2->insertItem(maths_);
|
|
|
|
pm3->insertItem(ding1_);
|
|
|
|
pm4->insertItem(ding2_);
|
|
|
|
pm5->insertItem(ding3_);
|
|
|
|
pm6->insertItem(ding4_);
|
2002-10-20 01:48:28 +00:00
|
|
|
|
2003-03-29 01:29:20 +00:00
|
|
|
pm->insertItem(qt_("&Standard"), pm1, 0);
|
|
|
|
pm->insertItem(qt_("&Maths"), pm2, 1);
|
|
|
|
pm->insertItem(qt_("Dings &1"), pm3, 2);
|
|
|
|
pm->insertItem(qt_("Dings &2"), pm4, 3);
|
|
|
|
pm->insertItem(qt_("Dings &3"), pm5, 4);
|
|
|
|
pm->insertItem(qt_("Dings &4"), pm6, 5);
|
|
|
|
pm->insertSeparator();
|
|
|
|
// FIXME: make this checkable
|
|
|
|
pm->insertItem(qt_("&Custom..."), this, SLOT(setCustom()), 0, 6);
|
|
|
|
|
|
|
|
bullet1PB->setPopup(pm);
|
|
|
|
bullet2PB->setPopup(pm);
|
|
|
|
bullet3PB->setPopup(pm);
|
|
|
|
bullet4PB->setPopup(pm);
|
2002-11-08 00:09:00 +00:00
|
|
|
|
|
|
|
// insert pixmaps
|
|
|
|
string bmfile;
|
|
|
|
bmfile = LibFileSearch("images", "standard", "xpm");
|
2002-12-17 20:37:13 +00:00
|
|
|
standard_->insertItem(QPixmap(toqstr(bmfile)));
|
2002-12-01 22:59:25 +00:00
|
|
|
|
2002-11-08 00:09:00 +00:00
|
|
|
bmfile = LibFileSearch("images", "amssymb", "xpm");
|
2002-12-17 20:37:13 +00:00
|
|
|
maths_->insertItem(QPixmap(toqstr(bmfile)));
|
2002-11-08 00:09:00 +00:00
|
|
|
|
|
|
|
bmfile = LibFileSearch("images", "psnfss1", "xpm");
|
2002-12-17 20:37:13 +00:00
|
|
|
ding1_->insertItem(QPixmap(toqstr(bmfile)));
|
2002-11-08 00:09:00 +00:00
|
|
|
|
|
|
|
bmfile = LibFileSearch("images", "psnfss2", "xpm");
|
2002-12-17 20:37:13 +00:00
|
|
|
ding2_->insertItem(QPixmap(toqstr(bmfile)));
|
2002-11-08 00:09:00 +00:00
|
|
|
|
|
|
|
bmfile = LibFileSearch("images", "psnfss3", "xpm");
|
2002-12-17 20:37:13 +00:00
|
|
|
ding3_->insertItem(QPixmap(toqstr(bmfile)));
|
2002-11-08 00:09:00 +00:00
|
|
|
|
|
|
|
bmfile = LibFileSearch("images", "psnfss4", "xpm");
|
2002-12-17 20:37:13 +00:00
|
|
|
ding4_->insertItem(QPixmap(toqstr(bmfile)));
|
2002-10-20 01:48:28 +00:00
|
|
|
|
2002-11-12 10:12:06 +00:00
|
|
|
connect(standard_, SIGNAL(selected(int, int)),
|
|
|
|
this, SLOT(standard(int, int)));
|
2002-10-20 01:48:28 +00:00
|
|
|
|
2002-11-12 10:12:06 +00:00
|
|
|
connect(maths_, SIGNAL(selected(int, int)),
|
|
|
|
this, SLOT(maths(int, int)));
|
2002-12-01 22:59:25 +00:00
|
|
|
|
2002-11-12 10:12:06 +00:00
|
|
|
connect(ding1_, SIGNAL(selected(int, int)),
|
|
|
|
this, SLOT(ding1(int, int)));
|
2002-12-01 22:59:25 +00:00
|
|
|
|
2002-11-12 10:12:06 +00:00
|
|
|
connect(ding2_, SIGNAL(selected(int, int)),
|
|
|
|
this, SLOT(ding2(int, int)));
|
2002-12-01 22:59:25 +00:00
|
|
|
|
2002-11-12 10:12:06 +00:00
|
|
|
connect(ding3_, SIGNAL(selected(int, int)),
|
|
|
|
this, SLOT(ding3(int, int)));
|
2002-12-01 22:59:25 +00:00
|
|
|
|
2002-11-12 10:12:06 +00:00
|
|
|
connect(ding4_, SIGNAL(selected(int, int)),
|
|
|
|
this, SLOT(ding4(int, int)));
|
2002-12-01 22:59:25 +00:00
|
|
|
|
2003-03-29 01:29:20 +00:00
|
|
|
connect(bullet1PB, SIGNAL(pressed()), this, SLOT(pressed1()));
|
|
|
|
connect(bullet2PB, SIGNAL(pressed()), this, SLOT(pressed2()));
|
|
|
|
connect(bullet3PB, SIGNAL(pressed()), this, SLOT(pressed3()));
|
|
|
|
connect(bullet4PB, SIGNAL(pressed()), this, SLOT(pressed4()));
|
|
|
|
connect(bulletsize1CO, SIGNAL(activated(int)), this, SLOT(updateSizes()));
|
|
|
|
connect(bulletsize2CO, SIGNAL(activated(int)), this, SLOT(updateSizes()));
|
|
|
|
connect(bulletsize3CO, SIGNAL(activated(int)), this, SLOT(updateSizes()));
|
|
|
|
connect(bulletsize4CO, SIGNAL(activated(int)), this, SLOT(updateSizes()));
|
|
|
|
|
2002-12-16 22:24:33 +00:00
|
|
|
// update the view
|
2003-03-29 01:29:20 +00:00
|
|
|
for (int i = 0; i < 4; ++i)
|
|
|
|
setBullet(bullet1PB, bulletsize1CO, bullets_[i]);
|
2002-12-16 22:24:33 +00:00
|
|
|
}
|
2002-12-01 22:59:25 +00:00
|
|
|
|
|
|
|
|
2002-12-16 22:24:33 +00:00
|
|
|
BulletsModule::~BulletsModule()
|
|
|
|
{
|
|
|
|
}
|
2002-12-01 22:59:25 +00:00
|
|
|
|
|
|
|
|
2003-03-29 01:29:20 +00:00
|
|
|
void BulletsModule::updateSizes()
|
|
|
|
{
|
|
|
|
emit changed();
|
|
|
|
|
|
|
|
// -1 apparently means default...
|
|
|
|
bullets_[0].setSize(bulletsize1CO->currentItem() - 1);
|
|
|
|
bullets_[1].setSize(bulletsize2CO->currentItem() - 1);
|
|
|
|
bullets_[2].setSize(bulletsize3CO->currentItem() - 1);
|
|
|
|
bullets_[3].setSize(bulletsize4CO->currentItem() - 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// These arrive *after* the menus have done their work
|
|
|
|
void BulletsModule::pressed1()
|
|
|
|
{
|
|
|
|
if (!tmpbulletset)
|
|
|
|
return;
|
|
|
|
tmpbulletset = false;
|
|
|
|
bullets_[0] = tmpbullet;
|
|
|
|
setBullet(bullet1PB, bulletsize1CO, bullets_[0]);
|
|
|
|
emit changed();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BulletsModule::pressed2()
|
|
|
|
{
|
|
|
|
if (!tmpbulletset)
|
|
|
|
return;
|
|
|
|
tmpbulletset = false;
|
|
|
|
bullets_[1] = tmpbullet;
|
|
|
|
setBullet(bullet2PB, bulletsize2CO, bullets_[1]);
|
|
|
|
emit changed();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BulletsModule::pressed3()
|
|
|
|
{
|
|
|
|
if (!tmpbulletset)
|
|
|
|
return;
|
|
|
|
tmpbulletset = false;
|
|
|
|
bullets_[2] = tmpbullet;
|
|
|
|
setBullet(bullet3PB, bulletsize3CO, bullets_[2]);
|
|
|
|
emit changed();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BulletsModule::pressed4()
|
|
|
|
{
|
|
|
|
if (!tmpbulletset)
|
|
|
|
return;
|
|
|
|
tmpbulletset = false;
|
|
|
|
bullets_[3] = tmpbullet;
|
|
|
|
setBullet(bullet4PB, bulletsize4CO, bullets_[3]);
|
|
|
|
emit changed();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-12-16 22:24:33 +00:00
|
|
|
QPixmap BulletsModule::getPixmap(int font, int character)
|
|
|
|
{
|
2003-03-29 01:29:20 +00:00
|
|
|
int col = character % 6;
|
|
|
|
int row = (character - col) / 6;
|
|
|
|
|
|
|
|
switch (font) {
|
2002-12-16 22:24:33 +00:00
|
|
|
case 0:
|
|
|
|
return standard_->pixmap(row,col);
|
|
|
|
case 1:
|
|
|
|
return maths_->pixmap(row,col);
|
|
|
|
case 2:
|
|
|
|
return ding1_->pixmap(row,col);
|
|
|
|
case 3:
|
|
|
|
return ding2_->pixmap(row,col);
|
|
|
|
case 4:
|
|
|
|
return ding3_->pixmap(row,col);
|
|
|
|
case 5:
|
|
|
|
return ding4_->pixmap(row,col);
|
|
|
|
default:
|
|
|
|
return standard_->pixmap(row,col);
|
|
|
|
}
|
2002-10-09 08:59:02 +00:00
|
|
|
}
|
|
|
|
|
2002-10-20 01:48:28 +00:00
|
|
|
|
2003-03-29 01:29:20 +00:00
|
|
|
void BulletsModule::setBullet(QPushButton * pb, QComboBox * co, Bullet const & b)
|
2002-10-09 08:59:02 +00:00
|
|
|
{
|
2003-03-29 01:29:20 +00:00
|
|
|
if (b.getFont() == -1) {
|
|
|
|
pb->setPixmap(QPixmap());
|
|
|
|
pb->setText("...");
|
|
|
|
} else {
|
|
|
|
pb->setPixmap(getPixmap(b.getFont(), b.getCharacter()));
|
2002-12-16 22:24:33 +00:00
|
|
|
}
|
2003-02-25 13:35:26 +00:00
|
|
|
|
2003-03-29 01:29:20 +00:00
|
|
|
pb->setMinimumSize(QSize(50, 50));
|
2003-02-25 13:35:26 +00:00
|
|
|
|
2003-03-29 01:29:20 +00:00
|
|
|
co->setCurrentItem(b.getSize() + 1);
|
2002-10-09 08:59:02 +00:00
|
|
|
}
|
|
|
|
|
2002-12-16 22:24:33 +00:00
|
|
|
|
|
|
|
void BulletsModule::setBullet(int level, const Bullet & bullet)
|
2002-11-12 10:12:06 +00:00
|
|
|
{
|
2002-12-16 22:24:33 +00:00
|
|
|
bullets_[level] = bullet;
|
2003-03-29 01:29:20 +00:00
|
|
|
|
|
|
|
QPushButton * pb;
|
|
|
|
QComboBox * co;
|
|
|
|
|
|
|
|
switch (level) {
|
|
|
|
case 0: pb = bullet1PB; co = bulletsize1CO; break;
|
|
|
|
case 1: pb = bullet2PB; co = bulletsize2CO; break;
|
|
|
|
case 2: pb = bullet3PB; co = bulletsize3CO; break;
|
|
|
|
case 3: pb = bullet4PB; co = bulletsize4CO; break;
|
2003-09-09 17:25:35 +00:00
|
|
|
default: BOOST_ASSERT(false); break;
|
2002-12-16 22:24:33 +00:00
|
|
|
}
|
2003-03-29 01:29:20 +00:00
|
|
|
|
|
|
|
setBullet(pb, co, bullet);
|
2002-11-12 10:12:06 +00:00
|
|
|
}
|
2002-10-20 01:48:28 +00:00
|
|
|
|
2002-12-16 22:24:33 +00:00
|
|
|
|
2003-03-29 01:29:20 +00:00
|
|
|
Bullet const BulletsModule::getBullet(int level)
|
2002-10-09 08:59:02 +00:00
|
|
|
{
|
2002-12-16 22:24:33 +00:00
|
|
|
return bullets_[level];
|
2002-10-09 08:59:02 +00:00
|
|
|
}
|
2002-11-12 10:12:06 +00:00
|
|
|
|
2002-12-16 22:24:33 +00:00
|
|
|
|
2003-03-29 01:29:20 +00:00
|
|
|
void BulletsModule::setCurrentBullet(int font, int character)
|
2002-11-12 10:12:06 +00:00
|
|
|
{
|
2003-03-29 01:29:20 +00:00
|
|
|
tmpbulletset = true;
|
|
|
|
tmpbullet.setFont(font);
|
|
|
|
tmpbullet.setCharacter(character);
|
2002-11-12 10:12:06 +00:00
|
|
|
}
|
|
|
|
|
2002-12-16 22:24:33 +00:00
|
|
|
|
|
|
|
void BulletsModule::standard(int row, int col)
|
2002-11-12 10:12:06 +00:00
|
|
|
{
|
2003-03-29 01:29:20 +00:00
|
|
|
setCurrentBullet(0, 6 * row + col);
|
2002-11-12 10:12:06 +00:00
|
|
|
}
|
|
|
|
|
2003-03-29 01:29:20 +00:00
|
|
|
|
2002-12-16 22:24:33 +00:00
|
|
|
void BulletsModule::maths(int row, int col)
|
|
|
|
{
|
2003-03-29 01:29:20 +00:00
|
|
|
setCurrentBullet(1, 6 * row + col);
|
2002-12-16 22:24:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BulletsModule::ding1(int row, int col)
|
|
|
|
{
|
2003-03-29 01:29:20 +00:00
|
|
|
setCurrentBullet(2, 6 * row + col);
|
2002-12-16 22:24:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BulletsModule::ding2(int row, int col)
|
2002-11-12 10:12:06 +00:00
|
|
|
{
|
2003-03-29 01:29:20 +00:00
|
|
|
setCurrentBullet(3, 6 * row + col);
|
2002-11-12 10:12:06 +00:00
|
|
|
}
|
|
|
|
|
2002-12-16 22:24:33 +00:00
|
|
|
|
|
|
|
void BulletsModule::ding3(int row, int col)
|
|
|
|
{
|
2003-03-29 01:29:20 +00:00
|
|
|
setCurrentBullet(4, 6 * row + col);
|
2003-02-25 13:35:26 +00:00
|
|
|
}
|
2002-12-16 22:24:33 +00:00
|
|
|
|
|
|
|
|
|
|
|
void BulletsModule::ding4(int row, int col)
|
|
|
|
{
|
2003-03-29 01:29:20 +00:00
|
|
|
setCurrentBullet(5, 6 * row + col);
|
2002-12-16 22:24:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BulletsModule::setCustom()
|
2002-11-12 10:12:06 +00:00
|
|
|
{
|
2002-12-16 22:24:33 +00:00
|
|
|
bool ok = FALSE;
|
|
|
|
QString text = QInputDialog::getText(
|
2002-12-17 20:37:13 +00:00
|
|
|
qt_( "Bullets" ),
|
|
|
|
qt_( "Enter a custom bullet" ),
|
2002-12-16 22:24:33 +00:00
|
|
|
QLineEdit::Normal,
|
|
|
|
QString::null, &ok, this );
|
2002-12-18 14:13:16 +00:00
|
|
|
|
2003-03-29 01:29:20 +00:00
|
|
|
if (!ok)
|
|
|
|
return;
|
|
|
|
|
|
|
|
tmpbulletset = true;
|
|
|
|
tmpbullet.setText(fromqstr(text));
|
|
|
|
tmpbullet.setFont(-1);
|
2002-11-12 10:12:06 +00:00
|
|
|
}
|