VirtualBox

Changeset 81456 in vbox for trunk


Ignore:
Timestamp:
Oct 22, 2019 4:37:21 PM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
134175
Message:

FE/Qt: bugref:6699 Making sure that the layout name is unique during copy.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard/UISoftKeyboard.cpp

    r81447 r81456  
    526526
    527527    void drawTextInRect(const UISoftKeyboardKey &key, QPainter &painter);
     528
     529
    528530
    529531private:
     
    24252427void UISoftKeyboardWidget::copyCurentLayout()
    24262428{
     2429
    24272430    UISoftKeyboardLayout newLayout(*(m_pCurrentKeyboardLayout));
    2428     QString strNewName;
    2429     if (!newLayout.name().isEmpty())
    2430         strNewName= QString("%1-%2").arg(newLayout.name()).arg(UISoftKeyboard::tr("Copy"));
    2431     QString strNewNativeName;
    2432     if (!newLayout.nativeName().isEmpty())
    2433         strNewNativeName= QString("%1-%2").arg(newLayout.nativeName()).arg(UISoftKeyboard::tr("Copy"));
     2431
     2432    QString strNewName = QString("%1-%2").arg(newLayout.name()).arg(UISoftKeyboard::tr("Copy"));
     2433    int iCount = 1;
     2434    while (findLayoutByName(strNewName))
     2435    {
     2436        strNewName = QString("%1-%2-%3").arg(newLayout.name()).arg(UISoftKeyboard::tr("Copy")).arg(QString::number(iCount));
     2437        ++iCount;
     2438    }
     2439
    24342440    newLayout.setName(strNewName);
    24352441    newLayout.setEditedBuNotSaved(true);
    2436     newLayout.setNativeName(strNewNativeName);
    24372442    newLayout.setEditable(true);
    24382443    newLayout.setIsFromResources(false);
     
    29442949    UIKeyboardLayoutReader keyboardLayoutReader;
    29452950
    2946     m_layouts.append(UISoftKeyboardLayout());
    2947     UISoftKeyboardLayout &newLayout = m_layouts.back();
    2948 
     2951    UISoftKeyboardLayout newLayout;
    29492952    if (!keyboardLayoutReader.parseFile(strLayoutFileName, newLayout))
    2950     {
    2951         m_layouts.removeLast();
    29522953        return false;
    2953     }
    29542954
    29552955    UISoftKeyboardPhysicalLayout *pPhysicalLayout = findPhysicalLayout(newLayout.physicalLayoutUuid());
    29562956    /* If no pyhsical layout with the UUID the keyboard layout refers is found then cancel loading the keyboard layout: */
    29572957    if (!pPhysicalLayout)
    2958     {
    2959         m_layouts.removeLast();
    29602958        return false;
    2961     }
    2962     /* Make sure we have unique layout UUIDs: */
     2959
     2960    /* Make sure we have unique lay1out UUIDs: */
    29632961    int iCount = 0;
    29642962    foreach (const UISoftKeyboardLayout &layout, m_layouts)
     
    29682966    }
    29692967    if (iCount > 1)
    2970     {
    2971         m_layouts.removeLast();
    29722968        return false;
    2973     }
     2969
    29742970    newLayout.setSourceFilePath(strLayoutFileName);
     2971    addLayout(newLayout);
    29752972    return true;
    29762973}
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette