Exemplo n.º 1
0
String RenderTheme::fileListNameForWidth(const Vector<String>& filenames, const Font& font, int width)
{
    if (width <= 0)
        return String();

    String string;
    if (filenames.isEmpty())
        string = fileButtonNoFileSelectedLabel();
    else if (filenames.size() == 1)
        string = pathGetFileName(filenames[0]);
    else
        return StringTruncator::rightTruncate(multipleFileUploadText(filenames.size()), width, font, StringTruncator::EnableRoundingHacks);

    return StringTruncator::centerTruncate(string, width, font, StringTruncator::EnableRoundingHacks);
}
Exemplo n.º 2
0
String FileChooser::basenameForWidth(const Font& font, int width) const
{
    if (width <= 0)
        return String();

    String string;
    if (m_filenames.isEmpty())
        string = fileButtonNoFileSelectedLabel();
    else if (m_filenames.size() == 1)
        string = pathGetDisplayFileName(m_filenames[0]);
    else
        return StringTruncator::rightTruncate(multipleFileUploadText(m_filenames.size()), width, font, false);

    return StringTruncator::centerTruncate(string, static_cast<float>(width), font, false);
}
String FileChooser::basenameForWidth(const Font& font, int width) const
{
    if (width <= 0)
        return String();

    String string;
    if (m_filenames.isEmpty())
        string = fileButtonNoFileSelectedLabel();
    else if (m_filenames.size() == 1)
        string = pathGetFileName(m_filenames[0]);
    else
        return StringTruncator::rightTruncate(String::number(m_filenames.size()) + " files", width, font);

    return StringTruncator::centerTruncate(string, width, font);
}
String FileChooser::basenameForWidth(const Font& font, int width) const
{
    if (width <= 0)
        return String();

    String string = fileButtonNoFileSelectedLabel();

    if (m_filenames.size() == 1) {
        CString systemFilename = fileSystemRepresentation(m_filenames[0]);
        gchar* systemBasename = g_path_get_basename(systemFilename.data());
        stringByAdoptingFileSystemRepresentation(systemBasename, string);
    } else if (m_filenames.size() > 1)
        return StringTruncator::rightTruncate(multipleFileUploadText(m_filenames.size()), width, font, false);

    return StringTruncator::centerTruncate(string, width, font, false);
}
Exemplo n.º 5
0
String RenderThemeGtk::fileListNameForWidth(const FileList* fileList, const Font& font, int width, bool multipleFilesAllowed) const
{
    if (width <= 0)
        return String();

    if (fileList->length() > 1)
        return StringTruncator::rightTruncate(multipleFileUploadText(fileList->length()), width, font, StringTruncator::EnableRoundingHacks);

    String string;
    if (fileList->length())
        string = pathGetFileName(fileList->item(0)->path());
    else if (multipleFilesAllowed)
        string = fileButtonNoFilesSelectedLabel();
    else
        string = fileButtonNoFileSelectedLabel();

    return StringTruncator::centerTruncate(string, width, font, StringTruncator::EnableRoundingHacks);
}
Exemplo n.º 6
0
String FileChooser::basenameForWidth(const Font& font, int width) const
{
    if (width <= 0)
        return String();

    String string = fileButtonNoFileSelectedLabel();

    if (!m_filename.isEmpty()) {
        gchar* systemFilename = g_filename_from_utf8(m_filename.utf8().data(), -1, 0, 0, 0);
        if (systemFilename) {
            gchar* systemBasename = g_path_get_basename(systemFilename);
            g_free(systemFilename);

            stringByAdoptingFileSystemRepresentation(systemBasename, string);
        }
    }

    return StringTruncator::centerTruncate(string, width, font, false);
}
Exemplo n.º 7
0
String FileChooser::basenameForWidth(const Font& f, int width) const
{
    if (width <= 0)
        return String();

    String string;
    if (m_filenames.isEmpty())
        string = fileButtonNoFileSelectedLabel();
    else if (m_filenames.size() == 1) {
        String fname = m_filenames[0];
        QFontMetrics fm(f.font());
        string = fm.elidedText(fname, Qt::ElideLeft, width);
    } else {
        int n = m_filenames.size();
        string = QCoreApplication::translate("QWebPage", "%n file(s)",
                                             "number of chosen file",
                                             QCoreApplication::CodecForTr, n);
    }

    return string;
}
Exemplo n.º 8
0
String RenderTheme::fileListDefaultLabel(bool multipleFilesAllowed) const
{
    if (multipleFilesAllowed)
        return fileButtonNoFilesSelectedLabel();
    return fileButtonNoFileSelectedLabel();
}