1
mirror of https://invent.kde.org/network/falkon.git synced 2024-11-11 01:22:10 +01:00

PageScreen: Fixed out-of-sync format combobox and filename input on Qt5

See #1454
This commit is contained in:
David Rosca 2014-09-16 20:06:25 +02:00
parent e3a8e9edc9
commit 357c5baec3
2 changed files with 13 additions and 16 deletions

View File

@ -48,20 +48,17 @@ PageScreen::PageScreen(WebView* view, QWidget* parent)
setAttribute(Qt::WA_DeleteOnClose);
ui->setupUi(this);
m_formats[0] = QLatin1String("PNG");
m_formats[1] = QLatin1String("BMP");
m_formats[2] = QLatin1String("JPG");
m_formats[3] = QLatin1String("PPM");
m_formats[4] = QLatin1String("TIFF");
m_formats[5] = QLatin1String("PDF");
m_formats.append(QSL("PNG"));
m_formats.append(QSL("BMP"));
m_formats.append(QSL("JPG"));
m_formats.append(QSL("PPM"));
m_formats.append(QSL("TIFF"));
m_formats.append(QSL("PDF"));
QHashIterator<int, QString> i(m_formats);
while (i.hasNext()) {
i.next();
ui->formats->addItem(tr("Save as %1").arg(i.value()));
foreach (const QString &format, m_formats) {
ui->formats->addItem(tr("Save as %1").arg(format));
}
// Set png as a default format
m_pageTitle = m_view->title();
Settings settings;
@ -87,10 +84,10 @@ void PageScreen::formatChanged()
int pos = text.lastIndexOf(QLatin1Char('.'));
if (pos > -1) {
text = text.left(pos + 1) + m_formats[ui->formats->currentIndex()].toLower();
text = text.left(pos + 1) + m_formats.at(ui->formats->currentIndex()).toLower();
}
else {
text.append(QLatin1Char('.') + m_formats[ui->formats->currentIndex()].toLower());
text.append(QLatin1Char('.') + m_formats.at(ui->formats->currentIndex()).toLower());
}
ui->location->setText(text);
@ -99,7 +96,7 @@ void PageScreen::formatChanged()
void PageScreen::changeLocation()
{
const QString name = QzTools::filterCharsFromFilename(m_pageTitle).replace(QLatin1Char(' '), QLatin1Char('_'));
const QString suggestedPath = QString("%1/%2.%3").arg(QDir::homePath(), name, m_formats[ui->formats->currentIndex()].toLower());
const QString suggestedPath = QString("%1/%2.%3").arg(QDir::homePath(), name, m_formats.at(ui->formats->currentIndex()).toLower());
const QString path = QzTools::getSaveFileName("PageScreen-Location", this, tr("Choose location..."), suggestedPath);
@ -123,7 +120,7 @@ void PageScreen::dialogAccepted()
QApplication::setOverrideCursor(Qt::WaitCursor);
const QString format = m_formats[ui->formats->currentIndex()];
const QString format = m_formats.at(ui->formats->currentIndex());
if (format == QLatin1String("PDF")) {
saveAsDocument(format);
}

View File

@ -60,7 +60,7 @@ private:
QFutureWatcher<QImage>* m_imageScaling;
QVector<QImage> m_pageImages;
QHash<int, QString> m_formats;
QStringList m_formats;
};
#endif // PAGESCREEN_H