mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-13 20:09:59 +00:00
* some cleanups
* some compile fixes on Windows (char_type is not automatically casted to uint) * take care of higher ucs4 characters. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22838 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
d25c1d1066
commit
0d7c79db6d
@ -12,23 +12,19 @@
|
|||||||
|
|
||||||
#include "GuiSymbols.h"
|
#include "GuiSymbols.h"
|
||||||
|
|
||||||
#include "Buffer.h"
|
|
||||||
#include "BufferView.h"
|
|
||||||
|
|
||||||
#include "GuiApplication.h"
|
#include "GuiApplication.h"
|
||||||
#include "GuiView.h"
|
#include "GuiView.h"
|
||||||
|
|
||||||
#include "qt_helpers.h"
|
#include "qt_helpers.h"
|
||||||
|
|
||||||
|
#include "Buffer.h"
|
||||||
|
#include "BufferView.h"
|
||||||
#include "Encoding.h"
|
#include "Encoding.h"
|
||||||
|
|
||||||
#include "support/gettext.h"
|
#include "support/gettext.h"
|
||||||
|
|
||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
#include <QListWidgetItem>
|
#include <QListWidgetItem>
|
||||||
|
|
||||||
// Set to zero if unicode symbols are preferred.
|
|
||||||
#define USE_PIXMAP 1
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
namespace lyx {
|
namespace lyx {
|
||||||
@ -161,18 +157,28 @@ GuiSymbols::GuiSymbols(GuiView & lv)
|
|||||||
int size = font.pointSize() + 3;
|
int size = font.pointSize() + 3;
|
||||||
font.setPointSize(size);
|
font.setPointSize(size);
|
||||||
symbolsLW->setFont(font);
|
symbolsLW->setFont(font);
|
||||||
|
|
||||||
okPB->setEnabled(!chosenLE->text().isEmpty() &&
|
|
||||||
!bufferview()->buffer().isReadonly());
|
|
||||||
applyPB->setEnabled(!chosenLE->text().isEmpty() &&
|
|
||||||
!bufferview()->buffer().isReadonly());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GuiSymbols::updateView()
|
void GuiSymbols::updateView()
|
||||||
{
|
{
|
||||||
chosenLE->clear();
|
chosenLE->clear();
|
||||||
initialiseParams(bufferview()->cursor().getEncoding()->name());
|
|
||||||
|
string const & new_encoding = bufferview()->cursor().getEncoding()->name();
|
||||||
|
if (new_encoding == encoding_)
|
||||||
|
// everything up to date
|
||||||
|
return;
|
||||||
|
if (!new_encoding.empty())
|
||||||
|
encoding_ = new_encoding;
|
||||||
|
updateSymbolList();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GuiSymbols::enableView(bool enable)
|
||||||
|
{
|
||||||
|
chosenLE->setEnabled(enable);
|
||||||
|
okPB->setEnabled(enable);
|
||||||
|
applyPB->setEnabled(enable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -203,8 +209,9 @@ void GuiSymbols::on_symbolsLW_itemActivated(QListWidgetItem *)
|
|||||||
|
|
||||||
void GuiSymbols::on_chosenLE_textChanged(QString const & text)
|
void GuiSymbols::on_chosenLE_textChanged(QString const & text)
|
||||||
{
|
{
|
||||||
okPB->setEnabled(!text.isEmpty() && !bufferview()->buffer().isReadonly());
|
bool const empty_sel = text.isEmpty();
|
||||||
applyPB->setEnabled(!text.isEmpty() && !bufferview()->buffer().isReadonly());
|
okPB->setEnabled(!empty_sel);
|
||||||
|
applyPB->setEnabled(!empty_sel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -245,11 +252,12 @@ void GuiSymbols::updateSymbolList()
|
|||||||
SymbolsList::const_iterator const end = symbols.end();
|
SymbolsList::const_iterator const end = symbols.end();
|
||||||
for (SymbolsList::const_iterator it = symbols.begin(); it != end; ++it) {
|
for (SymbolsList::const_iterator it = symbols.begin(); it != end; ++it) {
|
||||||
char_type c = *it;
|
char_type c = *it;
|
||||||
|
QChar::Category cat = QChar::category((uint) c);
|
||||||
// we do not want control or space characters
|
// we do not want control or space characters
|
||||||
if (QChar(c).category() == QChar::Other_Control ||
|
if (cat == QChar::Other_Control || cat == QChar::Separator_Space)
|
||||||
QChar(c).category() == QChar::Separator_Space)
|
|
||||||
continue;
|
continue;
|
||||||
QListWidgetItem * lwi = new QListWidgetItem(QChar(c));
|
QListWidgetItem * lwi = new QListWidgetItem(
|
||||||
|
QString::fromUcs4((uint const *) &c, 1));
|
||||||
lwi->setTextAlignment(Qt::AlignCenter);
|
lwi->setTextAlignment(Qt::AlignCenter);
|
||||||
symbolsLW->addItem(lwi);
|
symbolsLW->addItem(lwi);
|
||||||
QString block = getBlock(c);
|
QString block = getBlock(c);
|
||||||
@ -275,19 +283,6 @@ QString const GuiSymbols::getBlock(char_type c) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool GuiSymbols::initialiseParams(string const & data)
|
|
||||||
{
|
|
||||||
if (data == encoding_)
|
|
||||||
// everything up to date
|
|
||||||
return true;
|
|
||||||
if (!data.empty())
|
|
||||||
encoding_ = data;
|
|
||||||
updateSymbolList();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void GuiSymbols::dispatchParams()
|
void GuiSymbols::dispatchParams()
|
||||||
{
|
{
|
||||||
dispatch(FuncRequest(LFUN_SELF_INSERT, fromqstr(chosenLE->text())));
|
dispatch(FuncRequest(LFUN_SELF_INSERT, fromqstr(chosenLE->text())));
|
||||||
|
@ -14,10 +14,8 @@
|
|||||||
|
|
||||||
#include "DialogView.h"
|
#include "DialogView.h"
|
||||||
#include "ui_SymbolsUi.h"
|
#include "ui_SymbolsUi.h"
|
||||||
#include "Encoding.h"
|
|
||||||
|
|
||||||
class QListWidgetItem;
|
class QListWidgetItem;
|
||||||
class Encoding;
|
|
||||||
|
|
||||||
namespace lyx {
|
namespace lyx {
|
||||||
namespace frontend {
|
namespace frontend {
|
||||||
@ -33,8 +31,7 @@ public:
|
|||||||
//@{
|
//@{
|
||||||
void updateView();
|
void updateView();
|
||||||
void dispatchParams();
|
void dispatchParams();
|
||||||
bool initialiseParams(std::string const & data);
|
void enableView(bool enable);
|
||||||
void clearParams() {}
|
|
||||||
bool isBufferDependent() const { return true; }
|
bool isBufferDependent() const { return true; }
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user