mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 18:08:10 +00:00
shuffle stuff around; minor coding style issues
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20289 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
f53592dd60
commit
6c26624d39
@ -38,7 +38,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef USE_NATIVE_FILEDIALOG
|
#ifdef USE_NATIVE_FILEDIALOG
|
||||||
#include <qapplication.h>
|
#include <QApplication>
|
||||||
#include "support/filetools.h"
|
#include "support/filetools.h"
|
||||||
|
|
||||||
using lyx::support::makeAbsPath;
|
using lyx::support::makeAbsPath;
|
||||||
|
@ -235,6 +235,15 @@ void GuiFontLoader::update()
|
|||||||
/////////////////////////////////////////////////
|
/////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
static QString makeFontName(string const & family, string const & foundry)
|
||||||
|
{
|
||||||
|
QString res = toqstr(family);
|
||||||
|
if (!foundry.empty())
|
||||||
|
res += " [" + toqstr(foundry) + ']';
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QLFontInfo::QLFontInfo(Font const & f)
|
QLFontInfo::QLFontInfo(Font const & f)
|
||||||
{
|
{
|
||||||
font.setKerning(false);
|
font.setKerning(false);
|
||||||
@ -245,8 +254,8 @@ QLFontInfo::QLFontInfo(Font const & f)
|
|||||||
} else {
|
} else {
|
||||||
switch (f.family()) {
|
switch (f.family()) {
|
||||||
case Font::ROMAN_FAMILY: {
|
case Font::ROMAN_FAMILY: {
|
||||||
QString family = toqstr(makeFontName(lyxrc.roman_font_name,
|
QString family = makeFontName(lyxrc.roman_font_name,
|
||||||
lyxrc.roman_font_foundry));
|
lyxrc.roman_font_foundry);
|
||||||
font.setFamily(family);
|
font.setFamily(family);
|
||||||
#ifdef Q_WS_MACX
|
#ifdef Q_WS_MACX
|
||||||
#if QT_VERSION >= 0x040300
|
#if QT_VERSION >= 0x040300
|
||||||
@ -260,12 +269,12 @@ QLFontInfo::QLFontInfo(Font const & f)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Font::SANS_FAMILY:
|
case Font::SANS_FAMILY:
|
||||||
font.setFamily(toqstr(makeFontName(lyxrc.sans_font_name,
|
font.setFamily(makeFontName(lyxrc.sans_font_name,
|
||||||
lyxrc.sans_font_foundry)));
|
lyxrc.sans_font_foundry));
|
||||||
break;
|
break;
|
||||||
case Font::TYPEWRITER_FAMILY:
|
case Font::TYPEWRITER_FAMILY:
|
||||||
font.setFamily(toqstr(makeFontName(lyxrc.typewriter_font_name,
|
font.setFamily(makeFontName(lyxrc.typewriter_font_name,
|
||||||
lyxrc.typewriter_font_foundry)));
|
lyxrc.typewriter_font_foundry));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -41,6 +41,7 @@
|
|||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
using lyx::support::float_equal;
|
using lyx::support::float_equal;
|
||||||
using lyx::support::token;
|
using lyx::support::token;
|
||||||
@ -59,6 +60,34 @@ namespace lyx {
|
|||||||
namespace frontend {
|
namespace frontend {
|
||||||
|
|
||||||
|
|
||||||
|
//FIXME setAutoTextCB should really take an argument, as indicated, that
|
||||||
|
//determines what text is to be written for "auto". But making
|
||||||
|
//that work involves more extensive revisions than we now want
|
||||||
|
//to make, since "auto" also appears in updateContents() (see
|
||||||
|
//GuiGraphics.cpp).
|
||||||
|
//The right way to do this, I think, would be to define a class
|
||||||
|
//checkedLengthSet (and a partnering labeledLengthSete) that encapsulated
|
||||||
|
//the checkbox, line edit, and length combo together, and then made e.g.
|
||||||
|
//lengthToWidgets, widgetsToLength, etc, all public methods of that class.
|
||||||
|
//Perhaps even the validator could be exposed through it.
|
||||||
|
/**
|
||||||
|
* sets a checkbox-line edit-length combo group, using "text" if the
|
||||||
|
* checkbox is unchecked and clearing the line edit if it previously
|
||||||
|
* said "text".
|
||||||
|
*/
|
||||||
|
void setAutoTextCB(QCheckBox * checkBox, QLineEdit * lineEdit,
|
||||||
|
LengthCombo * lengthCombo/*, string text = "auto"*/)
|
||||||
|
{
|
||||||
|
if (!checkBox->isChecked())
|
||||||
|
lengthToWidgets(lineEdit, lengthCombo,
|
||||||
|
"auto", lengthCombo->currentLengthItem());
|
||||||
|
else if (lineEdit->text() == "auto")
|
||||||
|
lengthToWidgets(lineEdit, lengthCombo, string(),
|
||||||
|
lengthCombo->currentLengthItem());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
template<class Pair>
|
template<class Pair>
|
||||||
std::vector<typename Pair::first_type> const
|
std::vector<typename Pair::first_type> const
|
||||||
getFirst(std::vector<Pair> const & pr)
|
getFirst(std::vector<Pair> const & pr)
|
||||||
|
@ -46,6 +46,7 @@
|
|||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
using namespace Ui;
|
using namespace Ui;
|
||||||
|
|
||||||
@ -82,12 +83,25 @@ static size_t findPos_helper(std::vector<A> const & vec, A const & val)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static std::pair<string, string> parseFontName(string const & name)
|
||||||
|
{
|
||||||
|
string::size_type const idx = name.find('[');
|
||||||
|
if (idx == string::npos || idx == 0)
|
||||||
|
return make_pair(name, string());
|
||||||
|
return make_pair(name.substr(0, idx - 1),
|
||||||
|
name.substr(idx + 1, name.size() - idx - 2));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void setComboxFont(QComboBox * cb, string const & family,
|
static void setComboxFont(QComboBox * cb, string const & family,
|
||||||
string const & foundry)
|
string const & foundry)
|
||||||
{
|
{
|
||||||
string const name = makeFontName(family, foundry);
|
QString fontname = toqstr(family);
|
||||||
|
if (!foundry.empty())
|
||||||
|
fontname += " [" + toqstr(foundry) + ']';
|
||||||
|
|
||||||
for (int i = 0; i < cb->count(); ++i) {
|
for (int i = 0; i < cb->count(); ++i) {
|
||||||
if (fromqstr(cb->itemText(i)) == name) {
|
if (cb->itemText(i) == fontname) {
|
||||||
cb->setCurrentIndex(i);
|
cb->setCurrentIndex(i);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -96,7 +110,7 @@ static void setComboxFont(QComboBox * cb, string const & family,
|
|||||||
// Try matching without foundry name
|
// Try matching without foundry name
|
||||||
|
|
||||||
// We count in reverse in order to prefer the Xft foundry
|
// We count in reverse in order to prefer the Xft foundry
|
||||||
for (int i = cb->count() - 1; i >= 0; --i) {
|
for (int i = cb->count(); --i >= 0;) {
|
||||||
pair<string, string> tmp = parseFontName(fromqstr(cb->itemText(i)));
|
pair<string, string> tmp = parseFontName(fromqstr(cb->itemText(i)));
|
||||||
if (compare_ascii_no_case(tmp.first, family) == 0) {
|
if (compare_ascii_no_case(tmp.first, family) == 0) {
|
||||||
cb->setCurrentIndex(i);
|
cb->setCurrentIndex(i);
|
||||||
@ -317,7 +331,6 @@ PrefLatex::PrefLatex(GuiPrefsDialog * form, QWidget * parent)
|
|||||||
#else
|
#else
|
||||||
pathCB->setVisible(false);
|
pathCB->setVisible(false);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -409,26 +422,16 @@ PrefScreenFonts::PrefScreenFonts(GuiPrefsDialog * form, QWidget * parent)
|
|||||||
connect(screenHugerED, SIGNAL(textChanged(const QString&)),
|
connect(screenHugerED, SIGNAL(textChanged(const QString&)),
|
||||||
this, SIGNAL(changed()));
|
this, SIGNAL(changed()));
|
||||||
|
|
||||||
screenTinyED->setValidator(new QDoubleValidator(
|
screenTinyED->setValidator(new QDoubleValidator(screenTinyED));
|
||||||
screenTinyED));
|
screenSmallestED->setValidator(new QDoubleValidator(screenSmallestED));
|
||||||
screenSmallestED->setValidator(new QDoubleValidator(
|
screenSmallerED->setValidator(new QDoubleValidator(screenSmallerED));
|
||||||
screenSmallestED));
|
screenSmallED->setValidator(new QDoubleValidator(screenSmallED));
|
||||||
screenSmallerED->setValidator(new QDoubleValidator(
|
screenNormalED->setValidator(new QDoubleValidator(screenNormalED));
|
||||||
screenSmallerED));
|
screenLargeED->setValidator(new QDoubleValidator(screenLargeED));
|
||||||
screenSmallED->setValidator(new QDoubleValidator(
|
screenLargerED->setValidator(new QDoubleValidator(screenLargerED));
|
||||||
screenSmallED));
|
screenLargestED->setValidator(new QDoubleValidator(screenLargestED));
|
||||||
screenNormalED->setValidator(new QDoubleValidator(
|
screenHugeED->setValidator(new QDoubleValidator(screenHugeED));
|
||||||
screenNormalED));
|
screenHugerED->setValidator(new QDoubleValidator(screenHugerED));
|
||||||
screenLargeED->setValidator(new QDoubleValidator(
|
|
||||||
screenLargeED));
|
|
||||||
screenLargerED->setValidator(new QDoubleValidator(
|
|
||||||
screenLargerED));
|
|
||||||
screenLargestED->setValidator(new QDoubleValidator(
|
|
||||||
screenLargestED));
|
|
||||||
screenHugeED->setValidator(new QDoubleValidator(
|
|
||||||
screenHugeED));
|
|
||||||
screenHugerED->setValidator(new QDoubleValidator(
|
|
||||||
screenHugerED));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -575,12 +578,10 @@ PrefColors::PrefColors(GuiPrefsDialog * form, QWidget * parent)
|
|||||||
|
|
||||||
void PrefColors::apply(LyXRC & /*rc*/) const
|
void PrefColors::apply(LyXRC & /*rc*/) const
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < lcolors_.size(); ++i) {
|
for (unsigned int i = 0; i < lcolors_.size(); ++i)
|
||||||
if (curcolors_[i] != newcolors_[i]) {
|
if (curcolors_[i] != newcolors_[i])
|
||||||
form_->controller().setColor(lcolors_[i], fromqstr(newcolors_[i]));
|
form_->controller().setColor(lcolors_[i], fromqstr(newcolors_[i]));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void PrefColors::update(LyXRC const & /*rc*/)
|
void PrefColors::update(LyXRC const & /*rc*/)
|
||||||
@ -600,10 +601,11 @@ void PrefColors::change_color()
|
|||||||
int const row = lyxObjectsLW->currentRow();
|
int const row = lyxObjectsLW->currentRow();
|
||||||
|
|
||||||
// just to be sure
|
// just to be sure
|
||||||
if (row < 0) return;
|
if (row < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
QString const color = newcolors_[row];
|
QString const color = newcolors_[row];
|
||||||
QColor c(QColorDialog::getColor(QColor(color), qApp->focusWidget()));
|
QColor c = QColorDialog::getColor(QColor(color), qApp->focusWidget());
|
||||||
|
|
||||||
if (c.isValid() && c.name() != color) {
|
if (c.isValid() && c.name() != color) {
|
||||||
newcolors_[row] = c.name();
|
newcolors_[row] = c.name();
|
||||||
@ -1000,7 +1002,7 @@ void PrefConverters::updateGui()
|
|||||||
if (!current.isEmpty()) {
|
if (!current.isEmpty()) {
|
||||||
QList<QListWidgetItem *> const item =
|
QList<QListWidgetItem *> const item =
|
||||||
convertersLW->findItems(current, Qt::MatchExactly);
|
convertersLW->findItems(current, Qt::MatchExactly);
|
||||||
if (item.size()>0)
|
if (!item.isEmpty())
|
||||||
convertersLW->setCurrentItem(item.at(0));
|
convertersLW->setCurrentItem(item.at(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1063,16 +1065,17 @@ void PrefConverters::updateButtons()
|
|||||||
// this is why we can use the same function for both new and modify
|
// this is why we can use the same function for both new and modify
|
||||||
void PrefConverters::update_converter()
|
void PrefConverters::update_converter()
|
||||||
{
|
{
|
||||||
Format const & from(form_->formats().get(converterFromCO->currentIndex()));
|
Format const & from = form_->formats().get(converterFromCO->currentIndex());
|
||||||
Format const & to(form_->formats().get(converterToCO->currentIndex()));
|
Format const & to = form_->formats().get(converterToCO->currentIndex());
|
||||||
string const flags = fromqstr(converterFlagED->text());
|
string const flags = fromqstr(converterFlagED->text());
|
||||||
string const command = fromqstr(converterED->text());
|
string const command = fromqstr(converterED->text());
|
||||||
|
|
||||||
Converter const * old = form_->converters().getConverter(from.name(), to.name());
|
Converter const * old =
|
||||||
|
form_->converters().getConverter(from.name(), to.name());
|
||||||
form_->converters().add(from.name(), to.name(), command, flags);
|
form_->converters().add(from.name(), to.name(), command, flags);
|
||||||
if (!old) {
|
|
||||||
|
if (!old)
|
||||||
form_->converters().updateLast(form_->formats());
|
form_->converters().updateLast(form_->formats());
|
||||||
}
|
|
||||||
|
|
||||||
updateGui();
|
updateGui();
|
||||||
|
|
||||||
@ -1084,8 +1087,8 @@ void PrefConverters::update_converter()
|
|||||||
|
|
||||||
void PrefConverters::remove_converter()
|
void PrefConverters::remove_converter()
|
||||||
{
|
{
|
||||||
Format const & from(form_->formats().get(converterFromCO->currentIndex()));
|
Format const & from = form_->formats().get(converterFromCO->currentIndex());
|
||||||
Format const & to(form_->formats().get(converterToCO->currentIndex()));
|
Format const & to = form_->formats().get(converterToCO->currentIndex());
|
||||||
form_->converters().erase(from.name(), to.name());
|
form_->converters().erase(from.name(), to.name());
|
||||||
|
|
||||||
updateGui();
|
updateGui();
|
||||||
@ -1481,34 +1484,37 @@ void PrefFileformats::updateButtons()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// assure that a gui name cannot be chosen twice
|
// assure that a gui name cannot be chosen twice
|
||||||
bool const known_otherwise = gui_name_known && (where != sel);
|
bool const known_otherwise = gui_name_known && where != sel;
|
||||||
|
|
||||||
bool const known = !(sel < 0);
|
bool const known = sel >= 0;
|
||||||
bool const valid = (!formatED->text().isEmpty()
|
bool const valid = !formatED->text().isEmpty()
|
||||||
&& !guiNameED->text().isEmpty());
|
&& !guiNameED->text().isEmpty();
|
||||||
|
|
||||||
int const ftype = formatsLW->currentItem()->type();
|
int const ftype = formatsLW->currentItem()->type();
|
||||||
Format const & f(form_->formats().get(ftype));
|
Format const & f = form_->formats().get(ftype);
|
||||||
string const old_pretty(f.prettyname());
|
string const old_pretty = f.prettyname();
|
||||||
string const old_shortcut(f.shortcut());
|
string const old_shortcut = f.shortcut();
|
||||||
string const old_extension(f.extension());
|
string const old_extension = f.extension();
|
||||||
string const old_viewer(f.viewer());
|
string const old_viewer = f.viewer();
|
||||||
string const old_editor(f.editor());
|
string const old_editor = f.editor();
|
||||||
bool const old_document(f.documentFormat());
|
bool const old_document = f.documentFormat();
|
||||||
bool const old_vector(f.vectorFormat());
|
bool const old_vector = f.vectorFormat();
|
||||||
|
|
||||||
string const new_pretty(fromqstr(gui_name));
|
string const new_pretty = fromqstr(gui_name);
|
||||||
string const new_shortcut(fromqstr(shortcutED->text()));
|
string const new_shortcut = fromqstr(shortcutED->text());
|
||||||
string const new_extension(fromqstr(extensionED->text()));
|
string const new_extension = fromqstr(extensionED->text());
|
||||||
string const new_viewer(fromqstr(viewerED->text()));
|
string const new_viewer = fromqstr(viewerED->text());
|
||||||
string const new_editor(fromqstr(editorED->text()));
|
string const new_editor = fromqstr(editorED->text());
|
||||||
bool const new_document(documentCB->isChecked());
|
bool const new_document = documentCB->isChecked();
|
||||||
bool const new_vector(vectorCB->isChecked());
|
bool const new_vector = vectorCB->isChecked();
|
||||||
|
|
||||||
bool modified = ((old_pretty != new_pretty) || (old_shortcut != new_shortcut)
|
bool modified = old_pretty != new_pretty
|
||||||
|| (old_extension != new_extension) || (old_viewer != new_viewer)
|
|| old_shortcut != new_shortcut
|
||||||
|| old_editor != new_editor || old_document != new_document
|
|| old_extension != new_extension
|
||||||
|| old_vector != new_vector);
|
|| old_viewer != new_viewer
|
||||||
|
|| old_editor != new_editor
|
||||||
|
|| old_document != new_document
|
||||||
|
|| old_vector != new_vector;
|
||||||
|
|
||||||
formatModifyPB->setEnabled(valid && known && modified && !known_otherwise);
|
formatModifyPB->setEnabled(valid && known && modified && !known_otherwise);
|
||||||
formatNewPB->setEnabled(valid && !known && !gui_name_known);
|
formatNewPB->setEnabled(valid && !known && !gui_name_known);
|
||||||
@ -1843,12 +1849,11 @@ void PrefUserInterface::update(LyXRC const & rc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void PrefUserInterface::select_ui()
|
void PrefUserInterface::select_ui()
|
||||||
{
|
{
|
||||||
docstring const name =
|
docstring const name =
|
||||||
from_utf8(internal_path(fromqstr(uiFileED->text())));
|
from_utf8(internal_path(fromqstr(uiFileED->text())));
|
||||||
docstring file(form_->controller().browseUI(name));
|
docstring file = form_->controller().browseUI(name);
|
||||||
if (!file.empty())
|
if (!file.empty())
|
||||||
uiFileED->setText(toqstr(file));
|
uiFileED->setText(toqstr(file));
|
||||||
}
|
}
|
||||||
@ -1858,7 +1863,7 @@ void PrefUserInterface::select_bind()
|
|||||||
{
|
{
|
||||||
docstring const name =
|
docstring const name =
|
||||||
from_utf8(internal_path(fromqstr(bindFileED->text())));
|
from_utf8(internal_path(fromqstr(bindFileED->text())));
|
||||||
docstring file(form_->controller().browsebind(name));
|
docstring file = form_->controller().browsebind(name);
|
||||||
if (!file.empty())
|
if (!file.empty())
|
||||||
bindFileED->setText(toqstr(file));
|
bindFileED->setText(toqstr(file));
|
||||||
}
|
}
|
||||||
@ -2012,16 +2017,19 @@ Converters & GuiPrefsDialog::converters()
|
|||||||
return controller().converters();
|
return controller().converters();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Formats & GuiPrefsDialog::formats()
|
Formats & GuiPrefsDialog::formats()
|
||||||
{
|
{
|
||||||
return controller().formats();
|
return controller().formats();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Movers & GuiPrefsDialog::movers()
|
Movers & GuiPrefsDialog::movers()
|
||||||
{
|
{
|
||||||
return controller().movers();
|
return controller().movers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GuiPrefsDialog::applyView()
|
void GuiPrefsDialog::applyView()
|
||||||
{
|
{
|
||||||
apply(controller().rc());
|
apply(controller().rc());
|
||||||
|
@ -36,19 +36,64 @@ using lyx::support::bformat;
|
|||||||
|
|
||||||
namespace lyx {
|
namespace lyx {
|
||||||
|
|
||||||
namespace {
|
static docstring const formatted(docstring const & text)
|
||||||
|
{
|
||||||
|
const int w = 80;
|
||||||
|
docstring sout;
|
||||||
|
|
||||||
class MessageBox: public QMessageBox
|
if (text.empty())
|
||||||
{
|
return sout;
|
||||||
public:
|
|
||||||
MessageBox(QWidget * parent = 0) : QMessageBox(parent)
|
docstring::size_type curpos = 0;
|
||||||
{
|
docstring line;
|
||||||
setAttribute(Qt::WA_DeleteOnClose, true);
|
|
||||||
setAttribute(Qt::WA_QuitOnClose, false);
|
for (;;) {
|
||||||
|
docstring::size_type const nxtpos1 = text.find(' ', curpos);
|
||||||
|
docstring::size_type const nxtpos2 = text.find('\n', curpos);
|
||||||
|
docstring::size_type const nxtpos = std::min(nxtpos1, nxtpos2);
|
||||||
|
|
||||||
|
docstring const word =
|
||||||
|
nxtpos == docstring::npos ?
|
||||||
|
text.substr(curpos) :
|
||||||
|
text.substr(curpos, nxtpos - curpos);
|
||||||
|
|
||||||
|
bool const newline = (nxtpos2 != docstring::npos &&
|
||||||
|
nxtpos2 < nxtpos1);
|
||||||
|
|
||||||
|
docstring const line_plus_word =
|
||||||
|
line.empty() ? word : line + char_type(' ') + word;
|
||||||
|
|
||||||
|
// FIXME: make w be size_t
|
||||||
|
if (int(line_plus_word.length()) >= w) {
|
||||||
|
sout += line + char_type('\n');
|
||||||
|
if (newline) {
|
||||||
|
sout += word + char_type('\n');
|
||||||
|
line.erase();
|
||||||
|
} else {
|
||||||
|
line = word;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
} // anonymous namespace
|
} else if (newline) {
|
||||||
|
sout += line_plus_word + char_type('\n');
|
||||||
|
line.erase();
|
||||||
|
|
||||||
|
} else {
|
||||||
|
if (!line.empty())
|
||||||
|
line += char_type(' ');
|
||||||
|
line += word;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nxtpos == docstring::npos) {
|
||||||
|
if (!line.empty())
|
||||||
|
sout += line;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
curpos = nxtpos + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return sout;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int prompt_pimpl(docstring const & tit, docstring const & question,
|
int prompt_pimpl(docstring const & tit, docstring const & question,
|
||||||
@ -57,7 +102,7 @@ int prompt_pimpl(docstring const & tit, docstring const & question,
|
|||||||
{
|
{
|
||||||
docstring const title = bformat(_("LyX: %1$s"), tit);
|
docstring const title = bformat(_("LyX: %1$s"), tit);
|
||||||
|
|
||||||
MessageBox mb;
|
QMessageBox mb;
|
||||||
|
|
||||||
// For some reason, sometimes Qt uses an hourglass or watch cursor when
|
// For some reason, sometimes Qt uses an hourglass or watch cursor when
|
||||||
// displaying the alert. Hence, we ask for the standard cursor shape.
|
// displaying the alert. Hence, we ask for the standard cursor shape.
|
||||||
@ -65,7 +110,7 @@ int prompt_pimpl(docstring const & tit, docstring const & question,
|
|||||||
qApp->changeOverrideCursor(Qt::ArrowCursor);
|
qApp->changeOverrideCursor(Qt::ArrowCursor);
|
||||||
|
|
||||||
// FIXME replace that with theApp->gui()->currentView()
|
// FIXME replace that with theApp->gui()->currentView()
|
||||||
int res = mb.information(qApp->focusWidget(),
|
int res = QMessageBox::information(qApp->focusWidget(),
|
||||||
toqstr(title),
|
toqstr(title),
|
||||||
toqstr(formatted(question)),
|
toqstr(formatted(question)),
|
||||||
toqstr(b1),
|
toqstr(b1),
|
||||||
@ -93,8 +138,7 @@ void warning_pimpl(docstring const & tit, docstring const & message)
|
|||||||
toqstr(formatted(message)));
|
toqstr(formatted(message)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
MessageBox mb;
|
QMessageBox::warning(qApp->focusWidget(),
|
||||||
mb.warning(qApp->focusWidget(),
|
|
||||||
toqstr(title),
|
toqstr(title),
|
||||||
toqstr(formatted(message)));
|
toqstr(formatted(message)));
|
||||||
}
|
}
|
||||||
@ -112,8 +156,7 @@ void error_pimpl(docstring const & tit, docstring const & message)
|
|||||||
toqstr(formatted(message)));
|
toqstr(formatted(message)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
MessageBox mb;
|
QMessageBox::critical(qApp->focusWidget(),
|
||||||
mb.critical(qApp->focusWidget(),
|
|
||||||
toqstr(title),
|
toqstr(title),
|
||||||
toqstr(formatted(message)));
|
toqstr(formatted(message)));
|
||||||
}
|
}
|
||||||
@ -122,8 +165,7 @@ void error_pimpl(docstring const & tit, docstring const & message)
|
|||||||
void information_pimpl(docstring const & tit, docstring const & message)
|
void information_pimpl(docstring const & tit, docstring const & message)
|
||||||
{
|
{
|
||||||
docstring const title = bformat(_("LyX: %1$s"), tit);
|
docstring const title = bformat(_("LyX: %1$s"), tit);
|
||||||
MessageBox mb;
|
QMessageBox::information(qApp->focusWidget(),
|
||||||
mb.information(qApp->focusWidget(),
|
|
||||||
toqstr(title),
|
toqstr(title),
|
||||||
toqstr(formatted(message)));
|
toqstr(formatted(message)));
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
#ifndef QLKEY_H
|
#ifndef QLKEY_H
|
||||||
#define QLKEY_H
|
#define QLKEY_H
|
||||||
|
|
||||||
#include <qnamespace.h>
|
#include <Qt>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
|
||||||
|
@ -26,8 +26,7 @@
|
|||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
#include <QPalette>
|
#include <QPalette>
|
||||||
#include <qlineedit.h>
|
#include <QLineEdit>
|
||||||
#include <qtextcodec.h>
|
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
@ -37,28 +36,7 @@ namespace lyx {
|
|||||||
using support::isStrDbl;
|
using support::isStrDbl;
|
||||||
|
|
||||||
using std::vector;
|
using std::vector;
|
||||||
using std::make_pair;
|
|
||||||
using std::string;
|
using std::string;
|
||||||
using std::pair;
|
|
||||||
using std::endl;
|
|
||||||
|
|
||||||
|
|
||||||
string makeFontName(string const & family, string const & foundry)
|
|
||||||
{
|
|
||||||
if (foundry.empty())
|
|
||||||
return family;
|
|
||||||
return family + " [" + foundry + ']';
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
pair<string, string> parseFontName(string const & name)
|
|
||||||
{
|
|
||||||
string::size_type const idx = name.find('[');
|
|
||||||
if (idx == string::npos || idx == 0)
|
|
||||||
return make_pair(name, string());
|
|
||||||
return make_pair(name.substr(0, idx - 1),
|
|
||||||
name.substr(idx + 1, name.size() - idx - 2));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
string widgetsToLength(QLineEdit const * input, LengthCombo const * combo)
|
string widgetsToLength(QLineEdit const * input, LengthCombo const * combo)
|
||||||
@ -96,7 +74,7 @@ Length widgetsToLength(QLineEdit const * input, QComboBox const * combo)
|
|||||||
void lengthToWidgets(QLineEdit * input, LengthCombo * combo,
|
void lengthToWidgets(QLineEdit * input, LengthCombo * combo,
|
||||||
Length const & len, Length::UNIT /*defaultUnit*/)
|
Length const & len, Length::UNIT /*defaultUnit*/)
|
||||||
{
|
{
|
||||||
combo->setCurrentItem(Length(len).unit());
|
combo->setCurrentItem(len.unit());
|
||||||
input->setText(QString::number(Length(len).value()));
|
input->setText(QString::number(Length(len).value()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,63 +143,4 @@ QString const qt_(string const & str)
|
|||||||
return toqstr(_(str));
|
return toqstr(_(str));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
docstring const formatted(docstring const & text, int w)
|
|
||||||
{
|
|
||||||
docstring sout;
|
|
||||||
|
|
||||||
if (text.empty())
|
|
||||||
return sout;
|
|
||||||
|
|
||||||
docstring::size_type curpos = 0;
|
|
||||||
docstring line;
|
|
||||||
|
|
||||||
for (;;) {
|
|
||||||
docstring::size_type const nxtpos1 = text.find(' ', curpos);
|
|
||||||
docstring::size_type const nxtpos2 = text.find('\n', curpos);
|
|
||||||
docstring::size_type const nxtpos = std::min(nxtpos1, nxtpos2);
|
|
||||||
|
|
||||||
docstring const word =
|
|
||||||
nxtpos == docstring::npos ?
|
|
||||||
text.substr(curpos) :
|
|
||||||
text.substr(curpos, nxtpos - curpos);
|
|
||||||
|
|
||||||
bool const newline = (nxtpos2 != docstring::npos &&
|
|
||||||
nxtpos2 < nxtpos1);
|
|
||||||
|
|
||||||
docstring const line_plus_word =
|
|
||||||
line.empty() ? word : line + char_type(' ') + word;
|
|
||||||
|
|
||||||
// FIXME: make w be size_t
|
|
||||||
if (int(line_plus_word.length()) >= w) {
|
|
||||||
sout += line + char_type('\n');
|
|
||||||
if (newline) {
|
|
||||||
sout += word + char_type('\n');
|
|
||||||
line.erase();
|
|
||||||
} else {
|
|
||||||
line = word;
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if (newline) {
|
|
||||||
sout += line_plus_word + char_type('\n');
|
|
||||||
line.erase();
|
|
||||||
|
|
||||||
} else {
|
|
||||||
if (!line.empty())
|
|
||||||
line += char_type(' ');
|
|
||||||
line += word;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (nxtpos == docstring::npos) {
|
|
||||||
if (!line.empty())
|
|
||||||
sout += line;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
curpos = nxtpos + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return sout;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace lyx
|
} // namespace lyx
|
||||||
|
@ -14,25 +14,20 @@
|
|||||||
#define QTHELPERS_H
|
#define QTHELPERS_H
|
||||||
|
|
||||||
#include "Length.h"
|
#include "Length.h"
|
||||||
#include "support/docstring.h"
|
|
||||||
#include "support/qstring_helpers.h"
|
#include "support/qstring_helpers.h"
|
||||||
|
|
||||||
#include <QString>
|
#include <string>
|
||||||
#include <utility>
|
|
||||||
|
|
||||||
class QComboBox;
|
class QComboBox;
|
||||||
class QLineEdit;
|
class QLineEdit;
|
||||||
class QCheckBox;
|
class QCheckBox;
|
||||||
|
class QString;
|
||||||
class QWidget;
|
class QWidget;
|
||||||
|
|
||||||
class LengthCombo;
|
class LengthCombo;
|
||||||
|
|
||||||
namespace lyx {
|
namespace lyx {
|
||||||
|
|
||||||
std::string makeFontName(std::string const & family, std::string const & foundry);
|
|
||||||
|
|
||||||
std::pair<std::string,std::string> parseFontName(std::string const & name);
|
|
||||||
|
|
||||||
/// method to get a Length from widgets (LengthCombo)
|
/// method to get a Length from widgets (LengthCombo)
|
||||||
std::string widgetsToLength(QLineEdit const * input, LengthCombo const * combo);
|
std::string widgetsToLength(QLineEdit const * input, LengthCombo const * combo);
|
||||||
/// method to get a Length from widgets (QComboBox)
|
/// method to get a Length from widgets (QComboBox)
|
||||||
@ -49,30 +44,9 @@ void lengthToWidgets(QLineEdit * input, LengthCombo * combo,
|
|||||||
void lengthAutoToWidgets(QLineEdit * input, LengthCombo * combo,
|
void lengthAutoToWidgets(QLineEdit * input, LengthCombo * combo,
|
||||||
Length const & len, Length::UNIT defaultUnit);
|
Length const & len, Length::UNIT defaultUnit);
|
||||||
|
|
||||||
//FIXME setAutoTextCB should really take an argument, as indicated, that
|
|
||||||
//determines what text is to be written for "auto". But making
|
|
||||||
//that work involves more extensive revisions than we now want
|
|
||||||
//to make, since "auto" also appears in updateContents() (see
|
|
||||||
//GuiGraphics.cpp).
|
|
||||||
//The right way to do this, I think, would be to define a class
|
|
||||||
//checkedLengthSet (and a partnering labeledLengthSete) that encapsulated
|
|
||||||
//the checkbox, line edit, and length combo together, and then made e.g.
|
|
||||||
//lengthToWidgets, widgetsToLength, etc, all public methods of that class.
|
|
||||||
//Perhaps even the validator could be exposed through it.
|
|
||||||
/**
|
|
||||||
* sets a checkbox-line edit-length combo group, using "text" if the
|
|
||||||
* checkbox is unchecked and clearing the line edit if it previously
|
|
||||||
* said "text".
|
|
||||||
*/
|
|
||||||
void setAutoTextCB(QCheckBox * checkBox, QLineEdit * lineEdit,
|
|
||||||
LengthCombo * lengthCombo/*, string text = "auto"*/);
|
|
||||||
|
|
||||||
/// colors a widget red if invalid
|
/// colors a widget red if invalid
|
||||||
void setValid(QWidget * widget, bool valid);
|
void setValid(QWidget * widget, bool valid);
|
||||||
|
|
||||||
/// format a string to the given width
|
|
||||||
docstring const formatted(docstring const & text, int w = 80);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* qt_ - i18nize string and convert to QString
|
* qt_ - i18nize string and convert to QString
|
||||||
|
@ -15,8 +15,9 @@
|
|||||||
#define SOCKET_CALLBACK_H
|
#define SOCKET_CALLBACK_H
|
||||||
|
|
||||||
|
|
||||||
#include <qobject.h>
|
#include <QObject>
|
||||||
#include <qsocketnotifier.h>
|
#include <QSocketNotifier>
|
||||||
|
|
||||||
#include <boost/scoped_ptr.hpp>
|
#include <boost/scoped_ptr.hpp>
|
||||||
#include <boost/function.hpp>
|
#include <boost/function.hpp>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user