1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 10:46:35 +01:00

[RTL Layout] Set layoutDirection of widgets with LTR contents to LTR, for having a better look.

- closes #971
This commit is contained in:
S. Razi Alavizadeh 2013-07-11 20:48:32 +04:30
parent 4848def230
commit d3cb32247a
10 changed files with 42 additions and 11 deletions

View File

@ -39,6 +39,14 @@ CookieManager::CookieManager(QWidget* parent)
ui->setupUi(this); ui->setupUi(this);
QzTools::centerWidgetOnScreen(this); QzTools::centerWidgetOnScreen(this);
if (isRightToLeft()) {
ui->cookieTree->headerItem()->setTextAlignment(0, Qt::AlignRight | Qt::AlignVCenter);
ui->cookieTree->headerItem()->setTextAlignment(1, Qt::AlignRight | Qt::AlignVCenter);
ui->cookieTree->setLayoutDirection(Qt::LeftToRight);
ui->whiteList->setLayoutDirection(Qt::LeftToRight);
ui->blackList->setLayoutDirection(Qt::LeftToRight);
}
// Stored Cookies // Stored Cookies
connect(ui->cookieTree, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), this, SLOT(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*))); connect(ui->cookieTree, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), this, SLOT(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)));
connect(ui->removeAll, SIGNAL(clicked()), this, SLOT(removeAll())); connect(ui->removeAll, SIGNAL(clicked()), this, SLOT(removeAll()));

View File

@ -293,8 +293,15 @@ void ClickToFlash::showInfo()
widg->setAttribute(Qt::WA_DeleteOnClose); widg->setAttribute(Qt::WA_DeleteOnClose);
widg->setWindowTitle(tr("Flash Object")); widg->setWindowTitle(tr("Flash Object"));
QFormLayout* lay = new QFormLayout(widg); QFormLayout* lay = new QFormLayout(widg);
QLabel* attrib = new QLabel(tr("<b>Attribute Name</b>"));
QLabel* value = new QLabel(tr("<b>Value</b>"));
if (isRightToLeft()) {
widg->setLayoutDirection(Qt::LeftToRight);
attrib->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
value->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
}
lay->addRow(new QLabel(tr("<b>Attribute Name</b>")), new QLabel(tr("<b>Value</b>"))); lay->addRow(attrib, value);
int i = 0; int i = 0;
foreach (const QString &name, m_argumentNames) { foreach (const QString &name, m_argumentNames) {

View File

@ -73,6 +73,7 @@ AcceptLanguage::AcceptLanguage(QWidget* parent)
, ui(new Ui::AcceptLanguage) , ui(new Ui::AcceptLanguage)
{ {
ui->setupUi(this); ui->setupUi(this);
ui->listWidget->setLayoutDirection(Qt::LeftToRight);
Settings settings; Settings settings;
settings.beginGroup("Language"); settings.beginGroup("Language");
@ -130,6 +131,7 @@ void AcceptLanguage::addLanguage()
Ui_AddAcceptLanguage acceptLangUi; Ui_AddAcceptLanguage acceptLangUi;
QDialog dialog(this); QDialog dialog(this);
acceptLangUi.setupUi(&dialog); acceptLangUi.setupUi(&dialog);
acceptLangUi.listWidget->setLayoutDirection(Qt::LeftToRight);
QStringList allLanguages; QStringList allLanguages;
for (int i = 1 + (int)QLocale::C; i <= (int)QLocale::LastLanguage; ++i) { for (int i = 1 + (int)QLocale::C; i <= (int)QLocale::LastLanguage; ++i) {

View File

@ -38,6 +38,13 @@ AutoFillManager::AutoFillManager(QWidget* parent)
, m_passwordsShown(false) , m_passwordsShown(false)
{ {
ui->setupUi(this); ui->setupUi(this);
if (isRightToLeft()) {
ui->treePass->headerItem()->setTextAlignment(0, Qt::AlignRight | Qt::AlignVCenter);
ui->treePass->headerItem()->setTextAlignment(1, Qt::AlignRight | Qt::AlignVCenter);
ui->treePass->headerItem()->setTextAlignment(2, Qt::AlignRight | Qt::AlignVCenter);
ui->treePass->setLayoutDirection(Qt::LeftToRight);
ui->treeExcept->setLayoutDirection(Qt::LeftToRight);
}
connect(ui->removePass, SIGNAL(clicked()), this, SLOT(removePass())); connect(ui->removePass, SIGNAL(clicked()), this, SLOT(removePass()));
connect(ui->removeAllPass, SIGNAL(clicked()), this, SLOT(removeAllPass())); connect(ui->removeAllPass, SIGNAL(clicked()), this, SLOT(removeAllPass()));

View File

@ -35,10 +35,11 @@ void PluginListDelegate::paint(QPainter* painter, const QStyleOptionViewItem &op
const QWidget* w = opt.widget; const QWidget* w = opt.widget;
const QStyle* style = w ? w->style() : QApplication::style(); const QStyle* style = w ? w->style() : QApplication::style();
const Qt::LayoutDirection direction = w ? w->layoutDirection() : QApplication::layoutDirection();
const int height = opt.rect.height(); const int height = opt.rect.height();
const int center = height / 2 + opt.rect.top(); const int center = height / 2 + opt.rect.top();
painter->setLayoutDirection(Qt::LeftToRight);
// Prepare title font // Prepare title font
QFont titleFont = opt.font; QFont titleFont = opt.font;
titleFont.setBold(true); titleFont.setBold(true);
@ -63,19 +64,16 @@ void PluginListDelegate::paint(QPainter* painter, const QStyleOptionViewItem &op
QStyleOptionViewItemV4 opt2 = opt; QStyleOptionViewItemV4 opt2 = opt;
opt2.checkState == Qt::Checked ? opt2.state |= QStyle::State_On : opt2.state |= QStyle::State_Off; opt2.checkState == Qt::Checked ? opt2.state |= QStyle::State_On : opt2.state |= QStyle::State_Off;
QRect styleCheckBoxRect = style->subElementRect(QStyle::SE_ViewItemCheckIndicator, &opt2, w); QRect styleCheckBoxRect = style->subElementRect(QStyle::SE_ViewItemCheckIndicator, &opt2, w);
styleCheckBoxRect.setRect(leftPosition, checkboxYPos, styleCheckBoxRect.width(), styleCheckBoxRect.height()); opt2.rect = QRect(leftPosition, checkboxYPos, styleCheckBoxRect.width(), styleCheckBoxRect.height());
QRect visualCheckBoxRect = style->visualRect(direction, opt.rect, styleCheckBoxRect);
opt2.rect = visualCheckBoxRect;
style->drawPrimitive(QStyle::PE_IndicatorViewItemCheck, &opt2, painter, w); style->drawPrimitive(QStyle::PE_IndicatorViewItemCheck, &opt2, painter, w);
leftPosition = styleCheckBoxRect.right() + m_padding; leftPosition = opt2.rect.right() + m_padding;
// Draw icon // Draw icon
const int iconSize = 32; const int iconSize = 32;
const int iconYPos = center - (iconSize / 2); const int iconYPos = center - (iconSize / 2);
QRect iconRect(leftPosition, iconYPos, iconSize, iconSize); QRect iconRect(leftPosition, iconYPos, iconSize, iconSize);
QRect visualIconRect = style->visualRect(direction, opt.rect, iconRect);
QPixmap pixmap = index.data(Qt::DecorationRole).value<QIcon>().pixmap(iconSize); QPixmap pixmap = index.data(Qt::DecorationRole).value<QIcon>().pixmap(iconSize);
painter->drawPixmap(visualIconRect, pixmap); painter->drawPixmap(iconRect, pixmap);
leftPosition = iconRect.right() + m_padding; leftPosition = iconRect.right() + m_padding;
// Draw plugin name // Draw plugin name
@ -84,9 +82,8 @@ void PluginListDelegate::paint(QPainter* painter, const QStyleOptionViewItem &op
const int rightTitleEdge = rightPosition - m_padding; const int rightTitleEdge = rightPosition - m_padding;
const int leftPosForVersion = titleMetrics.width(name) + m_padding; const int leftPosForVersion = titleMetrics.width(name) + m_padding;
QRect nameRect(leftTitleEdge, opt.rect.top() + m_padding, rightTitleEdge - leftTitleEdge, titleMetrics.height()); QRect nameRect(leftTitleEdge, opt.rect.top() + m_padding, rightTitleEdge - leftTitleEdge, titleMetrics.height());
QRect visualNameRect = style->visualRect(direction, opt.rect, nameRect);
painter->setFont(titleFont); painter->setFont(titleFont);
style->drawItemText(painter, visualNameRect, Qt::AlignLeft, opt.palette, true, name, colorRole); style->drawItemText(painter, nameRect, Qt::AlignLeft, opt.palette, true, name, colorRole);
// Draw version // Draw version
const QString &version = index.data(Qt::UserRole).toString(); const QString &version = index.data(Qt::UserRole).toString();
@ -98,7 +95,7 @@ void PluginListDelegate::paint(QPainter* painter, const QStyleOptionViewItem &op
// Draw info // Draw info
const int infoYPos = nameRect.bottom() + opt.fontMetrics.leading(); const int infoYPos = nameRect.bottom() + opt.fontMetrics.leading();
QRect infoRect(visualNameRect.x(), infoYPos, nameRect.width(), opt.fontMetrics.height()); QRect infoRect(nameRect.x(), infoYPos, nameRect.width(), opt.fontMetrics.height());
const QString &info = opt.fontMetrics.elidedText(index.data(Qt::UserRole + 1).toString(), Qt::ElideRight, infoRect.width()); const QString &info = opt.fontMetrics.elidedText(index.data(Qt::UserRole + 1).toString(), Qt::ElideRight, infoRect.width());
painter->setFont(opt.font); painter->setFont(opt.font);
style->drawItemText(painter, infoRect, Qt::TextSingleLine | Qt::AlignLeft, opt.palette, true, info, colorRole); style->drawItemText(painter, infoRect, Qt::TextSingleLine | Qt::AlignLeft, opt.palette, true, info, colorRole);

View File

@ -34,6 +34,8 @@ PluginsManager::PluginsManager(QWidget* parent)
, m_loaded(false) , m_loaded(false)
{ {
ui->setupUi(this); ui->setupUi(this);
ui->list->setLayoutDirection(Qt::LeftToRight);
ui->whitelist->setLayoutDirection(Qt::LeftToRight);
//Application Extensions //Application Extensions
Settings settings; Settings settings;

View File

@ -64,6 +64,7 @@ Preferences::Preferences(QupZilla* mainClass, QWidget* parent)
{ {
setAttribute(Qt::WA_DeleteOnClose); setAttribute(Qt::WA_DeleteOnClose);
ui->setupUi(this); ui->setupUi(this);
ui->languages->setLayoutDirection(Qt::LeftToRight);
m_themesManager = new ThemeManager(ui->themesWidget, this); m_themesManager = new ThemeManager(ui->themesWidget, this);
m_autoFillManager = new AutoFillManager(this); m_autoFillManager = new AutoFillManager(this);

View File

@ -31,6 +31,9 @@ SSLManager::SSLManager(QWidget* parent)
{ {
setAttribute(Qt::WA_DeleteOnClose); setAttribute(Qt::WA_DeleteOnClose);
ui->setupUi(this); ui->setupUi(this);
ui->caList->setLayoutDirection(Qt::LeftToRight);
ui->localList->setLayoutDirection(Qt::LeftToRight);
ui->pathList->setLayoutDirection(Qt::LeftToRight);
refreshLocalList(); refreshLocalList();
refreshCAList(); refreshCAList();

View File

@ -33,6 +33,7 @@ ThemeManager::ThemeManager(QWidget* parent, Preferences* preferences)
, m_preferences(preferences) , m_preferences(preferences)
{ {
ui->setupUi(parent); ui->setupUi(parent);
ui->listWidget->setLayoutDirection(Qt::LeftToRight);
ui->license->hide(); ui->license->hide();
Settings settings; Settings settings;

View File

@ -32,6 +32,8 @@ UserAgentDialog::UserAgentDialog(QWidget* parent)
, m_manager(mApp->uaManager()) , m_manager(mApp->uaManager())
{ {
ui->setupUi(this); ui->setupUi(this);
ui->globalComboBox->setLayoutDirection(Qt::LeftToRight);
ui->table->setLayoutDirection(Qt::LeftToRight);
const QString &os = QzTools::operatingSystem(); const QString &os = QzTools::operatingSystem();
m_knownUserAgents << QString("Opera/9.80 (%1) Presto/2.10.229 Version/11.61").arg(os) m_knownUserAgents << QString("Opera/9.80 (%1) Presto/2.10.229 Version/11.61").arg(os)
@ -182,6 +184,7 @@ bool UserAgentDialog::showEditDialog(const QString &title, QString* rSite, QStri
QFormLayout* layout = new QFormLayout(dialog); QFormLayout* layout = new QFormLayout(dialog);
QLineEdit* editSite = new QLineEdit(dialog); QLineEdit* editSite = new QLineEdit(dialog);
QComboBox* editAgent = new QComboBox(dialog); QComboBox* editAgent = new QComboBox(dialog);
editAgent->setLayoutDirection(Qt::LeftToRight);
editAgent->setEditable(true); editAgent->setEditable(true);
editAgent->addItems(m_knownUserAgents); editAgent->addItems(m_knownUserAgents);