void Application::initializeTranslation()
{
    Preferences *const pref = Preferences::instance();
    // Load translation
    QString localeStr = pref->getLocale();

    if (m_qtTranslator.load(QLatin1String("qtbase_") + localeStr, QLibraryInfo::location(QLibraryInfo::TranslationsPath)) ||
        m_qtTranslator.load(QLatin1String("qt_") + localeStr, QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
            qDebug("Qt %s locale recognized, using translation.", qUtf8Printable(localeStr));
    else
        qDebug("Qt %s locale unrecognized, using default (en).", qUtf8Printable(localeStr));

    installTranslator(&m_qtTranslator);

    if (m_translator.load(QLatin1String(":/lang/qbittorrent_") + localeStr))
        qDebug("%s locale recognized, using translation.", qUtf8Printable(localeStr));
    else
        qDebug("%s locale unrecognized, using default (en).", qUtf8Printable(localeStr));
    installTranslator(&m_translator);

#ifndef DISABLE_GUI
    if (localeStr.startsWith("ar") || localeStr.startsWith("he")) {
        qDebug("Right to Left mode");
        setLayoutDirection(Qt::RightToLeft);
    }
    else {
        setLayoutDirection(Qt::LeftToRight);
    }
#endif
}
Beispiel #2
0
Datei: MPF.cpp Projekt: aaly/MPF
int MPF::updateLayout(QString language)
{
    if (language == "ar" )
    {
		setLayoutDirection(Qt::RightToLeft);
		setLocale(QLocale(QLocale::Arabic));
    }
    else
    {
        setLayoutDirection(Qt::LeftToRight);
    }
	listGridLayout->update();
    return 0;

}
Beispiel #3
0
void BookmarksWidget::init()
{
    // The locationbar's direction is direction of its text,
    // it dynamically changes and so, it's not good choice for this widget.
    setLayoutDirection(QApplication::layoutDirection());

    // Init SpeedDial button
    const SpeedDial::Page page = m_speedDial->pageForUrl(m_view->url());
    if (page.url.isEmpty()) {
        ui->speeddialButton->setFlat(true);
        ui->speeddialButton->setText(tr("Add to Speed Dial"));
    }
    else {
        ui->speeddialButton->setFlat(false);
        ui->speeddialButton->setText(tr("Remove from Speed Dial"));
    }

    // Init Bookmarks button
    if (m_bookmark) {
        ui->bookmarksButton->setText(tr("Remove from Bookmarks"));
        ui->bookmarksButton->setFlat(false);

        Q_ASSERT(m_bookmark->parent());
        ui->folderButton->setSelectedFolder(m_bookmark->parent());
        connect(ui->folderButton, SIGNAL(selectedFolderChanged(BookmarkItem*)), SLOT(bookmarkEdited()));
    }

    connect(ui->speeddialButton, SIGNAL(clicked()), this, SLOT(toggleSpeedDial()));
    connect(ui->bookmarksButton, SIGNAL(clicked()), this, SLOT(toggleBookmark()));

}
Beispiel #4
0
Bookmarks::Bookmarks(QWidget* parent)
    : QTreeWidget(parent)
{
    setLayoutDirection(Qt::RightToLeft);
    setTextElideMode(Qt::ElideMiddle);
#ifdef Q_OS_WIN
    setIndentation(10);
#endif
    QStringList labels;
    labels << tr("Title") << tr("Comments");
#if QT_VERSION < 0x050000
    header()->setResizeMode(QHeaderView::Interactive);
#else
    header()->setSectionResizeMode(QHeaderView::Interactive);
#endif
    setHeaderLabels(labels);

    m_folderIcon.addPixmap(style()->standardPixmap(QStyle::SP_DirClosedIcon),
                           QIcon::Normal, QIcon::Off);
    m_folderIcon.addPixmap(style()->standardPixmap(QStyle::SP_DirOpenIcon),
                           QIcon::Normal, QIcon::On);

    m_bookmarkIcon.addPixmap(QPixmap(ICON_PATH + "/bookmark-on.png"));

    setAlternatingRowColors(true);

    connect(this, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)), this, SLOT(doubleClicked(QTreeWidgetItem*,int)));
}
Beispiel #5
0
 FancyPlotterLabel(QWidget *parent) : QLabel(parent) {
     setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
     longHeadingWidth = 0;
     shortHeadingWidth = 0;
     textMargin = 0;
     setLayoutDirection(Qt::LeftToRight); //We do this because we organise the strings ourselves.. is this going to muck it up though for RTL languages?
 }
Beispiel #6
0
ScrollArea::ScrollArea(QWidget *parent, const style::flatScroll &st, bool handleTouch) : QScrollArea(parent),
_disabled(false), _st(st),
hor(this, false, &_st), vert(this, true, &_st), topSh(this, &_st), bottomSh(this, &_st),
_touchEnabled(handleTouch), _touchScroll(false), _touchPress(false), _touchRightButton(false),
_touchScrollState(TouchScrollManual), _touchPrevPosValid(false), _touchWaitingAcceleration(false),
_touchSpeedTime(0), _touchAccelerationTime(0), _touchTime(0), _widgetAcceptsTouch(false), _other(0) {
	setLayoutDirection(cLangDir());

	connect(&vert, SIGNAL(topShadowVisibility(bool)), &topSh, SLOT(changeVisibility(bool)));
	connect(&vert, SIGNAL(bottomShadowVisibility(bool)), &bottomSh, SLOT(changeVisibility(bool)));
	vert.updateBar(true);

	setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);

	setFrameStyle(QFrame::NoFrame | QFrame::Plain);
	viewport()->setAutoFillBackground(false);

	_horValue = horizontalScrollBar()->value();
	_vertValue = verticalScrollBar()->value();

	if (_touchEnabled) {
		viewport()->setAttribute(Qt::WA_AcceptTouchEvents);
		_touchTimer.setSingleShot(true);
		connect(&_touchTimer, SIGNAL(timeout()), this, SLOT(onTouchTimer()));
		connect(&_touchScrollTimer, SIGNAL(timeout()), this, SLOT(onTouchScrollTimer()));
	}
}
Beispiel #7
0
ScrollArea::ScrollArea(QWidget *parent, const style::flatScroll &st, bool handleTouch) : QScrollArea(parent)
, _st(st)
, _horizontalBar(this, false, &_st)
, _verticalBar(this, true, &_st)
, _topShadow(this, &_st)
, _bottomShadow(this, &_st)
, _touchEnabled(handleTouch) {
	setLayoutDirection(cLangDir());

	connect(_verticalBar, SIGNAL(topShadowVisibility(bool)), _topShadow, SLOT(changeVisibility(bool)));
	connect(_verticalBar, SIGNAL(bottomShadowVisibility(bool)), _bottomShadow, SLOT(changeVisibility(bool)));
	_verticalBar->updateBar(true);

	setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);

	setFrameStyle(QFrame::NoFrame | QFrame::Plain);
	viewport()->setAutoFillBackground(false);

	_horizontalValue = horizontalScrollBar()->value();
	_verticalValue = verticalScrollBar()->value();

	if (_touchEnabled) {
		viewport()->setAttribute(Qt::WA_AcceptTouchEvents);
		_touchTimer.setSingleShot(true);
		connect(&_touchTimer, SIGNAL(timeout()), this, SLOT(onTouchTimer()));
		connect(&_touchScrollTimer, SIGNAL(timeout()), this, SLOT(onTouchScrollTimer()));
	}
}
AutoHideWidget::AutoHideWidget(QWidget *parent)
    : QWidget(parent)
    ,turned_on(false)
    ,auto_hide(false)
    ,use_animation(false)
    ,spacing(0)
    ,perc_width(100)
    ,activation_area(Bottom)
    ,internal_widget(0)
    ,timer(0)
{
    setBackgroundRole(QPalette::Window);
    setAutoFillBackground(true);
    setLayoutDirection(Qt::LeftToRight);

    QWidget *widget_to_watch = parent;
    widget_to_watch->installEventFilter(this);
    installFiliter(widget_to_watch);

    timer = new QTimer(this);
    connect(timer,SIGNAL(timeout()),this,SLOT(checkUnderMouse()));
    timer->setInterval(3000);

    QVBoxLayout *layout = new QVBoxLayout;
    layout->setSpacing(0);
    layout->setMargin(0);
    setLayout(layout);
}
Beispiel #9
0
landmarkPoint:: landmarkPoint(QWidget * parent = 0, Qt::WindowFlags f = 0) :QLabel(parent,f)
{

    count++;
     QFont font;
        font.setPointSize(6);
        setFont(font);
        setLayoutDirection(Qt::RightToLeft);
        setTextFormat(Qt::PlainText);
        move=false;
        char name[20];

        sprintf(name,"%d",count);
        if(strlen(name)==2)
        widthVal=12;
        else
        widthVal=6;
        setGeometry(QRect(406, 90, widthVal,12));

        setText(QApplication::translate("landmark", name, 0, QApplication::UnicodeUTF8));
        setStyleSheet(QApplication::translate("landmark", "background-color: rgb(42, 0, 255, 30%);\n"
"color: rgb(255, 255, 255);", 0, QApplication::UnicodeUTF8));
show();


}
Beispiel #10
0
LocationBar::LocationBar(QWidget *parent)
    : LineEdit(parent)
    , m_webView(0)
    , m_siteIcon(0)
{
    // Urls are always LeftToRight
    setLayoutDirection(Qt::LeftToRight);

    setUpdatesEnabled(false);
    // site icon on the left
    m_siteIcon = new LocationBarSiteIcon(this);
    addWidget(m_siteIcon, LeftSide);

    // clear button on the right
    ClearButton *m_clearButton = new ClearButton(this);
    connect(m_clearButton, SIGNAL(clicked()),
            this, SLOT(clear()));
    connect(this, SIGNAL(textChanged(const QString&)),
            m_clearButton, SLOT(textChanged(const QString&)));
    addWidget(m_clearButton, RightSide);
    m_clearButton->hide();
    updateTextMargins();
    setUpdatesEnabled(true);

    m_defaultBaseColor = palette().color(QPalette::Base);

    QPalette p = palette();
    p.setColor(QPalette::Base, QColor(255, 255, 255, 100));
    setPalette(p);
}
Beispiel #11
0
LocationBar::LocationBar(QWidget *parent)
    : LineEdit(parent)
    , m_webView(0)
    , m_siteIcon(0)
    , m_privacyIndicator(0)
{
    // Urls are always LeftToRight
    setLayoutDirection(Qt::LeftToRight);

    setUpdatesEnabled(false);
    // site icon on the left
    m_siteIcon = new LocationBarSiteIcon(this);
    addWidget(m_siteIcon, LeftSide);

    // privacy indicator at rightmost position
    m_privacyIndicator = new PrivacyIndicator(this);
    addWidget(m_privacyIndicator, RightSide);

    // clear button on the right
    ClearButton *m_clearButton = new ClearButton(this);
    connect(m_clearButton, SIGNAL(clicked()),
            this, SLOT(clear()));
    connect(this, SIGNAL(textChanged(const QString&)),
            m_clearButton, SLOT(textChanged(const QString&)));
    addWidget(m_clearButton, RightSide);

    updateTextMargins();
    setUpdatesEnabled(true);
}
Beispiel #12
0
MainWindow::MainWindow()
{
    centralWidget = new QWidget;
    setCentralWidget(centralWidget);

    createGroupBox();

    listWidget = new QListWidget;
    for (int i = 0; listEntries[i]; ++i)
        listWidget->addItem(tr(listEntries[i]));

    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->addWidget(groupBox);
    mainLayout->addWidget(listWidget);
    centralWidget->setLayout(mainLayout);

    exitAction = new QAction(tr("E&xit"), this);
    connect(exitAction, SIGNAL(triggered()), qApp, SLOT(quit()));

    fileMenu = menuBar()->addMenu(tr("&File"));
    fileMenu->setPalette(QPalette(Qt::red));
    fileMenu->addAction(exitAction);

    setWindowTitle(tr("Language: %1").arg(tr("English")));
    statusBar()->showMessage(tr("Internationalization Example"));

    if (tr("LTR") == "RTL")
        setLayoutDirection(Qt::RightToLeft);
}
Beispiel #13
0
ToolBarCalendar::ToolBarCalendar(Ui::MainWindow *ui) : ui(ui)
{
    setIconSize(QSize(20,20));
    setLayoutDirection(Qt::RightToLeft);

    this->addWidget(new ToolButton("Example", ":/icons/img/icons/ic_today_48px.svg"));

}
Beispiel #14
0
FoldersPanel::FoldersPanel(QWidget* parent) :
    Panel(parent),
    m_updateCurrentItem(false),
    m_controller(0),
    m_model(0)
{
    setLayoutDirection(Qt::LeftToRight);
}
void VariablesWidget::changeEvent(QEvent *e)
{
    if (e->type() == QEvent::LanguageChange) {
        setLayoutDirection(Qt::LeftToRight);
        retranslateText();
    }
    else
        QWidget::changeEvent(e);
}
void UserFunctionListWidget::changeEvent(QEvent* event)
{
    if (event->type() == QEvent::LanguageChange) {
        setLayoutDirection(Qt::LeftToRight);
        retranslateText();
        return;
    }
    QWidget::changeEvent(event);
}
Beispiel #17
0
void GenericChatroomWidget::setCompact(bool _compact)
{
    compact = _compact;

    delete textLayout; // has to be first, deleted by layout
    delete layout;

    compact = _compact;

    layout = new QHBoxLayout;
    textLayout = new QVBoxLayout;

    setLayout(layout);
    layout->setSpacing(0);
    layout->setMargin(0);
    textLayout->setSpacing(0);
    textLayout->setMargin(0);
    setLayoutDirection(Qt::LeftToRight); // parent might have set Qt::RightToLeft

    // avatar
    if (compact)
    {
        setFixedHeight(25);
        avatar->setSize(QSize(20,20));
        layout->addSpacing(18);
        layout->addWidget(avatar);
        layout->addSpacing(5);
        layout->addWidget(nameLabel);
        layout->addWidget(statusMessageLabel);
        layout->addSpacing(5);
        layout->addWidget(&statusPic);
        layout->addSpacing(5);
        layout->activate();
        statusMessageLabel->setFont(Style::getFont(Style::Small));
        nameLabel->setFont(Style::getFont(Style::Medium));
    }
    else
    {
        setFixedHeight(55);
        avatar->setSize(QSize(40,40));
        textLayout->addStretch();
        textLayout->addWidget(nameLabel);
        textLayout->addWidget(statusMessageLabel);
        textLayout->addStretch();
        layout->addSpacing(20);
        layout->addWidget(avatar);
        layout->addSpacing(10);
        layout->addLayout(textLayout);
        layout->addSpacing(10);
        layout->addWidget(&statusPic);
        layout->addSpacing(10);
        layout->activate();
        statusMessageLabel->setFont(Style::getFont(Style::Medium));
        nameLabel->setFont(Style::getFont(Style::Big));
    }
}
Beispiel #18
0
QmfSettings::QmfSettings()
    : QMailMessageServiceEditor()
{
    setupUi(this);
    setLayoutDirection(qApp->layoutDirection());

    QList<QPair<QString, QString> >::const_iterator it = locations.begin(), end = locations.end();
    for ( ; it != end; ++it)
        locationSelector->addItem((*it).first);
}
Beispiel #19
0
void LingTextEdit::setWritingSystem(const WritingSystem &ws)
{
    if( mWritingSystem != ws )
    {
        mWritingSystem = ws;
        refreshStyle();
        setLayoutDirection(ws.layoutDirection());
        setToolTip(ws.name());
    }
}
Beispiel #20
0
void ToDoPapers::setText(const QString &text)
{
    if( p->text == text && !text.isEmpty() )
        return;

    p->text = text;
    setLayoutDirection( AsemanTools::directionOf(text) );

    cleanAndRefresh();
    emit textChanged();
}
void GenericChatroomWidget::onCompactChanged(bool _compact)
{
    delete textLayout; // has to be first, deleted by layout
    delete layout;

    setProperty("compact", _compact);

    layout = new QHBoxLayout;
    textLayout = new QVBoxLayout;

    setLayout(layout);
    layout->setSpacing(0);
    layout->setMargin(0);
    textLayout->setSpacing(0);
    textLayout->setMargin(0);
    setLayoutDirection(Qt::LeftToRight); // parent might have set Qt::RightToLeft

    // avatar
    if (property("compact").toBool())
    {
        setFixedHeight(25);
        avatar->setSize(QSize(20,20));
        layout->addSpacing(18);
        layout->addWidget(avatar);
        layout->addSpacing(5);
        layout->addWidget(nameLabel);
        layout->addWidget(statusMessageLabel);
        layout->addSpacing(5);
        layout->addWidget(&statusPic);
        layout->addSpacing(5);
        layout->activate();
    }
    else
    {
        setFixedHeight(55);
        avatar->setSize(QSize(40,40));
        textLayout->addStretch();
        textLayout->addWidget(nameLabel);
        textLayout->addWidget(statusMessageLabel);
        textLayout->addStretch();
        layout->addSpacing(20);
        layout->addWidget(avatar);
        layout->addSpacing(10);
        layout->addLayout(textLayout);
        layout->addSpacing(10);
        layout->addWidget(&statusPic);
        layout->addSpacing(10);
        layout->activate();
    }

    Style::repolish(this);
}
Beispiel #22
0
CompletionWidget::CompletionWidget(QWidget *parent)
        : QFrame(parent, Qt::ToolTip)
        , _parent(parent)
        , _currentIndex(0)
        , _hasSuggestions(false)
{
    setFrameStyle(QFrame::Panel);
    setLayoutDirection(Qt::LeftToRight);
    QVBoxLayout *layout = new QVBoxLayout;
    layout->setMargin(0);
    layout->setSpacing(0);
    setLayout(layout);
}
KrunnerHistoryComboBox::KrunnerHistoryComboBox(bool useCompletion, QWidget * parent)
    : KHistoryComboBox(useCompletion,  parent),
      m_addingToHistory(false)
{
    setPalette(QApplication::palette());
    setDuplicatesEnabled(false);
    setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLengthWithIcon);

    // in theory, the widget should detect the direction from the content
    // but this is not available in Qt4.4/KDE 4.2, so the best default for this widget
    // is LTR: as it's more or less a "command line interface"
    // FIXME remove this code when KLineEdit has automatic direction detection of the "paragraph"
    setLayoutDirection(Qt::LeftToRight);
}
BtTextWindowHeader::BtTextWindowHeader(CSwordModuleInfo::ModuleType modtype,
                                       QStringList modules,
                                       CDisplayWindow *window)
        : QWidget(window),
        BtWindowModuleChooser(modtype, window)
{
    QHBoxLayout* layout = new QHBoxLayout ( this );
    layout->setContentsMargins(0, 0, 0, 0);
    setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
    setLayoutDirection(Qt::LeftToRight);
    setModules(modules);
    connect(window, SIGNAL(sigModuleListSet(QStringList)), SLOT(slotBackendModulesChanged()));
    connect(window, SIGNAL(sigModuleListChanged()), SLOT(slotWindowModulesChanged()));
}
Beispiel #25
0
Keypad::Keypad( char radixChar, QWidget * parent )
  : QWidget( parent ), d( new Keypad::Private )
{
  d->p = this;

  d->radixChar = radixChar;

  d->createButtons();
  d->sizeButtons();
  d->layoutButtons();
  d->setButtonTooltips();
  d->setUpButtonPressedSignal();
  d->disableButtonFocus();
  setLayoutDirection( Qt::LeftToRight );
}
Beispiel #26
0
UrlLineEdit::UrlLineEdit(QWidget *parent)
    : ExLineEdit(parent)
    , m_webView(0)
    , m_iconLabel(0)
{
    // Urls are always LeftToRight
    setLayoutDirection(Qt::LeftToRight);

    // icon
    m_iconLabel = new UrlIconLabel(this);
    m_iconLabel->resize(16, 16);
    setLeftWidget(m_iconLabel);
    m_defaultBaseColor = palette().color(QPalette::Base);

    webViewIconChanged();
}
ResultDisplay::ResultDisplay(QWidget* parent)
    : QPlainTextEdit(parent)
    , m_count(0)
    , m_highlighter(new SyntaxHighlighter(this))
    , m_scrolledLines(0)
    , m_scrollDirection(0)
    , m_isScrollingPageOnly(false)
{
    setViewportMargins(0, 0, 0, 0);
    setBackgroundRole(QPalette::Base);
    setLayoutDirection(Qt::LeftToRight);
    setMinimumWidth(150);
    setReadOnly(true);
    setFocusPolicy(Qt::NoFocus);
    setWordWrapMode(QTextOption::WrapAnywhere);
}
void HeaderedTextEdit::updateTextLeftMargin()
{
    QSizeF labelSize = headerLabel->sizeHint(Qt::PreferredSize, QSizeF(-1, -1));
    QTextCursor cursor(document());
    cursor.setPosition(0);
    QTextBlockFormat tbf = cursor.blockFormat();
    
    // Will not overwrite label if LeftMargin for 
    // text block format is set. Usefuly for only inputs
    // such as emails.
    // tbf.setLeftMargin(labelSize.width());
    tbf.setTextIndent(labelSize.width());
    Qt::LayoutDirection dir = MLocale::directionForText(headerLabel->text());
    setLayoutDirection(dir);
    updateLabelPosition(geometry());
    cursor.setBlockFormat(tbf);    
}
Beispiel #29
0
AdBlockTreeWidget::AdBlockTreeWidget(AdBlockSubscription* subscription, QWidget* parent)
    : TreeWidget(parent)
    , m_subscription(subscription)
    , m_topItem(0)
    , m_itemChangingBlock(false)
{
    setContextMenuPolicy(Qt::CustomContextMenu);
    setDefaultItemShowMode(TreeWidget::ItemsExpanded);
    setHeaderHidden(true);
    setAlternatingRowColors(true);
    setLayoutDirection(Qt::LeftToRight);

    connect(this, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuRequested(QPoint)));
    connect(this, SIGNAL(itemChanged(QTreeWidgetItem*,int)), this, SLOT(itemChanged(QTreeWidgetItem*)));
    connect(m_subscription, SIGNAL(subscriptionUpdated()), this, SLOT(subscriptionUpdated()));
    connect(m_subscription, SIGNAL(subscriptionError(QString)), this, SLOT(subscriptionError(QString)));
}
Beispiel #30
0
HistoryCompletionView::HistoryCompletionView(QWidget *parent)
    : QTableView(parent)
{
    horizontalHeader()->hide();
    verticalHeader()->hide();

    setShowGrid(false);

    setSelectionBehavior(QAbstractItemView::SelectRows);
    setSelectionMode(QAbstractItemView::SingleSelection);
    setTextElideMode(Qt::ElideRight);

    QFontMetrics metrics = fontMetrics();
    verticalHeader()->setDefaultSectionSize(metrics.height());
    
    // As URLs are always LRT, this should be LRT as well
    setLayoutDirection(Qt::LeftToRight);
}