squashing final bugs with resizing
This commit is contained in:
parent
8ac4a072a9
commit
953a537cb8
@ -117,10 +117,7 @@ protected:
|
|||||||
private:
|
private:
|
||||||
void RequestFont()
|
void RequestFont()
|
||||||
{
|
{
|
||||||
QFont font;
|
if (QFont font = QFontDialog::getFont(&ok, ui.display->font(), this, FONT); ok)
|
||||||
// Forced reading of the font from settings otherwise the font window does not have the size set
|
|
||||||
if (!font.fromString(settings.value(FONT, font.toString()).toString())) font = ui.display->font();
|
|
||||||
if (font = QFontDialog::getFont(&ok, font, this, FONT); ok)
|
|
||||||
{
|
{
|
||||||
settings.setValue(FONT, font.toString());
|
settings.setValue(FONT, font.toString());
|
||||||
ui.display->setFont(font);
|
ui.display->setFont(font);
|
||||||
@ -254,32 +251,28 @@ private:
|
|||||||
if (!showOriginal) sentence = sentence.split(u8"\x200b \n")[1];
|
if (!showOriginal) sentence = sentence.split(u8"\x200b \n")[1];
|
||||||
else if (showOriginalAfterTranslation) sentence = sentence.split(u8"\x200b \n")[1] + "\n" + sentence.split(u8"\x200b \n")[0];
|
else if (showOriginalAfterTranslation) sentence = sentence.split(u8"\x200b \n")[1] + "\n" + sentence.split(u8"\x200b \n")[0];
|
||||||
|
|
||||||
if (autoResize)
|
if (sizeLock && !autoResize)
|
||||||
{
|
|
||||||
ui.display->resize(
|
|
||||||
ui.display->width(),
|
|
||||||
QFontMetrics(ui.display->font(), ui.display).boundingRect(0, 0, ui.display->width(), INT_MAX, Qt::TextWordWrap, sentence).height()
|
|
||||||
);
|
|
||||||
//resize(width(), QFontMetrics(ui.display->font(), ui.display).boundingRect(0, 0, ui.display->width(), INT_MAX, Qt::TextWordWrap, sentence).height() + 22);
|
|
||||||
}
|
|
||||||
else if (sizeLock)
|
|
||||||
{
|
{
|
||||||
QFontMetrics fontMetrics(ui.display->font(), ui.display);
|
QFontMetrics fontMetrics(ui.display->font(), ui.display);
|
||||||
int low = 0, high = sentence.size(), last = 0;
|
int low = 0, high = sentence.size(), last = 0;
|
||||||
while (low < high)
|
while (low <= high)
|
||||||
{
|
{
|
||||||
int mid = (low + high) / 2;
|
int mid = (low + high) / 2;
|
||||||
if (fontMetrics.boundingRect(0, 0, ui.display->width(), INT_MAX, Qt::TextWordWrap, sentence.left(mid)).height() < ui.display->height())
|
if (fontMetrics.boundingRect(0, 0, ui.display->width(), INT_MAX, Qt::TextWordWrap, sentence.left(mid)).height() <= ui.display->height())
|
||||||
{
|
{
|
||||||
last = mid;
|
last = mid;
|
||||||
low = mid + 1;
|
low = mid + 1;
|
||||||
}
|
}
|
||||||
else high = mid;
|
else high = mid - 1;
|
||||||
}
|
}
|
||||||
sentence = sentence.left(last);
|
sentence = sentence.left(last);
|
||||||
}
|
}
|
||||||
|
|
||||||
ui.display->setText(sentence);
|
ui.display->setText(sentence);
|
||||||
|
if (autoResize)
|
||||||
|
resize(width(), height() - ui.display->height() +
|
||||||
|
QFontMetrics(ui.display->font(), ui.display).boundingRect(0, 0, ui.display->width(), INT_MAX, Qt::TextWordWrap, sentence).height()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetTopmost(bool topmost)
|
void SetTopmost(bool topmost)
|
||||||
|
Loading…
Reference in New Issue
Block a user