Exemplo n.º 1
0
LocationBar::LocationBar(QupZilla* mainClass)
    : LineEdit(mainClass)
    , p_QupZilla(mainClass)
    , m_webView(0)
    , m_pasteAndGoAction(0)
    , m_clearAction(0)
    , m_rssIconVisible(false)
    , m_holdingAlt(false)
    , m_loadProgress(0)
    , m_progressVisible(false)
    , m_forcePaintEvent(false)
    , m_inlineCompletionVisible(false)
    , m_popupClosed(false)
{
    setObjectName("locationbar");
    setDragEnabled(true);

    m_bookmarkIcon = new BookmarksIcon(this);
    m_goIcon = new GoIcon(this);
    m_rssIcon = new RssIcon(this);
    m_siteIcon = new SiteIcon(p_QupZilla, this);
    m_autofillIcon = new AutoFillIcon(this);
    DownIcon* down = new DownIcon(this);

    // RTL Support
    // if we don't add 'm_siteIcon' by following code, then we should use suitable padding-left value
    // but then, when typing RTL text the layout dynamically changed and within RTL layout direction
    // padding-left is equivalent to padding-right and vice versa, and because style sheet is
    // not changed dynamically this create padding problems.
    addWidget(m_siteIcon, LineEdit::LeftSide);

    addWidget(m_autofillIcon, LineEdit::RightSide);
    addWidget(m_bookmarkIcon, LineEdit::RightSide);
    addWidget(m_rssIcon, LineEdit::RightSide);
    addWidget(m_goIcon, LineEdit::RightSide);
    addWidget(down, LineEdit::RightSide);

    m_completer.setLocationBar(this);
    connect(&m_completer, SIGNAL(showCompletion(QString)), this, SLOT(showCompletion(QString)));
    connect(&m_completer, SIGNAL(completionActivated()), this, SLOT(urlEnter()));
    connect(&m_completer, SIGNAL(popupClosed()), this, SLOT(completionPopupClosed()));

    connect(this, SIGNAL(textEdited(QString)), this, SLOT(textEdit()));
    connect(m_goIcon, SIGNAL(clicked(QPoint)), this, SLOT(urlEnter()));
    connect(down, SIGNAL(clicked(QPoint)), &m_completer, SLOT(showMostVisited()));
    connect(mApp->searchEnginesManager(), SIGNAL(activeEngineChanged()), this, SLOT(updatePlaceHolderText()));
    connect(mApp->searchEnginesManager(), SIGNAL(defaultEngineChanged()), this, SLOT(updatePlaceHolderText()));
    connect(mApp, SIGNAL(message(Qz::AppMessageType,bool)), SLOT(onMessage(Qz::AppMessageType,bool)));

    loadSettings();
    clearIcon();

    // Hide icons by default
    hideGoButton();
    m_rssIcon->hide();
    m_autofillIcon->hide();

    QTimer::singleShot(0, this, SLOT(updatePlaceHolderText()));
}
Exemplo n.º 2
0
LocationBar::LocationBar(QupZilla* mainClass)
    : LineEdit()
    , p_QupZilla(mainClass)
    , m_webView(0)
    , m_menu(new QMenu(this))
    , m_pasteAndGoAction(0)
    , m_clearAction(0)
    , m_holdingAlt(false)
{
    setObjectName("locationbar");

    m_bookmarkIcon = new BookmarkIcon(p_QupZilla);
    m_goIcon = new GoIcon(this);
    m_rssIcon = new RssIcon(this);
    m_rssIcon->setToolTip(tr("Add RSS from this page..."));
    m_siteIcon = new SiteIcon(this);
    DownIcon* down = new DownIcon(this);

    addWidget(down, LineEdit::RightSide);
    addWidget(m_bookmarkIcon, LineEdit::RightSide);
    addWidget(m_goIcon, LineEdit::RightSide);
    addWidget(m_rssIcon, LineEdit::RightSide);

    setWidgetSpacing(0);

    m_locationCompleter = new LocationCompleter();
    setCompleter(m_locationCompleter);

//    LocationPopup* com = new LocationPopup(this);
//    connect(down, SIGNAL(clicked(QPoint)), com, SLOT(show()));

    connect(this, SIGNAL(textEdited(QString)), this, SLOT(textEdit()));
    connect(this, SIGNAL(textEdited(QString)), m_locationCompleter, SLOT(refreshCompleter(QString)));
    connect(m_locationCompleter->popup(), SIGNAL(clicked(QModelIndex)), this, SLOT(urlEnter()));
    connect(m_siteIcon, SIGNAL(clicked()), this, SLOT(showSiteInfo()));
    connect(m_goIcon, SIGNAL(clicked(QPoint)), this, SLOT(urlEnter()));
    connect(m_rssIcon, SIGNAL(clicked(QPoint)), this, SLOT(rssIconClicked()));
    connect(down, SIGNAL(clicked(QPoint)), this, SLOT(showMostVisited()));
    connect(mApp->searchEnginesManager(), SIGNAL(activeEngineChanged()), this, SLOT(updatePlaceHolderText()));

    clearIcon();
    updatePlaceHolderText();
}
Exemplo n.º 3
0
void ChatPanel::changeEvent(QEvent *e)
{
    if (e->type() == QEvent::LanguageChange) {
        ui->retranslateUi(this);
        updatePlaceHolderText();

        auto root = ui->treeWidget->topLevelItem(0);
        if (root)
            updateConnectedUsersTitleString(root->childCount());
    }

    QWidget::changeEvent(e);
}
Exemplo n.º 4
0
void ChatPanel::toggleOnOff()
{
    on = !on;

    setInputsStatus(on);

    if (on)
        emit turnedOn();
    else
        emit turnedOff();

    updatePlaceHolderText();
    updateEmojiIcon();
}
Exemplo n.º 5
0
LocationBar::LocationBar(BrowserWindow* window)
    : LineEdit(window)
    , m_window(window)
    , m_webView(0)
    , m_pasteAndGoAction(0)
    , m_clearAction(0)
    , m_holdingAlt(false)
    , m_loadProgress(0)
    , m_progressVisible(false)
{
    setObjectName("locationbar");
    setDragEnabled(true);

    // Disable Oxygen QLineEdit transitions, it breaks with setText() && home()
    setProperty("_kde_no_animations", QVariant(true));

    m_bookmarkIcon = new BookmarksIcon(this);
    m_goIcon = new GoIcon(this);
    m_rssIcon = new RssIcon(this);
    m_siteIcon = new SiteIcon(m_window, this);
    m_autofillIcon = new AutoFillIcon(this);
    DownIcon* down = new DownIcon(this);

    addWidget(m_siteIcon, LineEdit::LeftSide);
    addWidget(m_autofillIcon, LineEdit::RightSide);
    addWidget(m_bookmarkIcon, LineEdit::RightSide);
    addWidget(m_rssIcon, LineEdit::RightSide);
    addWidget(m_goIcon, LineEdit::RightSide);
    addWidget(down, LineEdit::RightSide);

    m_completer = new LocationCompleter(this);
    m_completer->setMainWindow(m_window);
    m_completer->setLocationBar(this);
    connect(m_completer, SIGNAL(showCompletion(QString)), this, SLOT(showCompletion(QString)));
    connect(m_completer, SIGNAL(showDomainCompletion(QString)), this, SLOT(showDomainCompletion(QString)));
    connect(m_completer, SIGNAL(loadCompletion()), this, SLOT(requestLoadUrl()));
    connect(m_completer, SIGNAL(clearCompletion()), this, SLOT(clearCompletion()));

    m_domainCompleterModel = new QStringListModel(this);
    QCompleter* domainCompleter = new QCompleter(this);
    domainCompleter->setCompletionMode(QCompleter::InlineCompletion);
    domainCompleter->setModel(m_domainCompleterModel);
    setCompleter(domainCompleter);

    connect(this, SIGNAL(textEdited(QString)), this, SLOT(textEditted()));
    connect(m_goIcon, SIGNAL(clicked(QPoint)), this, SLOT(requestLoadUrl()));
    connect(down, SIGNAL(clicked(QPoint)), m_completer, SLOT(showMostVisited()));
    connect(mApp->searchEnginesManager(), SIGNAL(activeEngineChanged()), this, SLOT(updatePlaceHolderText()));
    connect(mApp->searchEnginesManager(), SIGNAL(defaultEngineChanged()), this, SLOT(updatePlaceHolderText()));
    connect(mApp, SIGNAL(settingsReloaded()), SLOT(loadSettings()));

    loadSettings();

    updateSiteIcon();

    // Hide icons by default
    m_goIcon->setVisible(qzSettings->alwaysShowGoIcon);
    m_rssIcon->hide();
    m_autofillIcon->hide();

    QTimer::singleShot(0, this, SLOT(updatePlaceHolderText()));
}
Exemplo n.º 6
0
LocationBar::LocationBar(QWidget *parent)
    : LineEdit(parent)
    , m_window(nullptr)
    , m_webView(0)
    , m_holdingAlt(false)
    , m_oldTextLength(0)
    , m_currentTextLength(0)
    , m_loadProgress(0)
    , m_progressVisible(false)
{
    setObjectName("locationbar");
    setDragEnabled(true);

    // Disable KDE QLineEdit transitions, it breaks with setText() && home()
    setProperty("_kde_no_animations", QVariant(true));

    m_bookmarkIcon = new BookmarksIcon(this);
    m_goIcon = new GoIcon(this);
    m_siteIcon = new SiteIcon(this);
    m_autofillIcon = new AutoFillIcon(this);
    DownIcon* down = new DownIcon(this);

    addWidget(m_siteIcon, LineEdit::LeftSide);
    addWidget(m_autofillIcon, LineEdit::RightSide);
    addWidget(m_bookmarkIcon, LineEdit::RightSide);
    addWidget(m_goIcon, LineEdit::RightSide);
    addWidget(down, LineEdit::RightSide);

    m_completer = new LocationCompleter(this);
    m_completer->setLocationBar(this);
    connect(m_completer, SIGNAL(showCompletion(QString,bool)), this, SLOT(showCompletion(QString,bool)));
    connect(m_completer, SIGNAL(showDomainCompletion(QString)), this, SLOT(showDomainCompletion(QString)));
    connect(m_completer, SIGNAL(clearCompletion()), this, SLOT(clearCompletion()));
    connect(m_completer, &LocationCompleter::loadRequested, this, &LocationBar::loadRequest);
    connect(m_completer, &LocationCompleter::popupClosed, this, &LocationBar::updateSiteIcon);

    m_domainCompleterModel = new QStringListModel(this);
    QCompleter* domainCompleter = new QCompleter(this);
    domainCompleter->setCompletionMode(QCompleter::InlineCompletion);
    domainCompleter->setModel(m_domainCompleterModel);
    setCompleter(domainCompleter);

    m_progressTimer = new QTimer(this);
    m_progressTimer->setInterval(700);
    m_progressTimer->setSingleShot(true);
    connect(m_progressTimer, &QTimer::timeout, this, &LocationBar::hideProgress);

    editAction(PasteAndGo)->setText(tr("Paste And &Go"));
    editAction(PasteAndGo)->setIcon(QIcon::fromTheme(QSL("edit-paste")));
    connect(editAction(PasteAndGo), SIGNAL(triggered()), this, SLOT(pasteAndGo()));

    connect(this, SIGNAL(textEdited(QString)), this, SLOT(textEdited(QString)));
    connect(m_goIcon, SIGNAL(clicked(QPoint)), this, SLOT(requestLoadUrl()));
    connect(down, SIGNAL(clicked(QPoint)), m_completer, SLOT(showMostVisited()));
    connect(mApp->searchEnginesManager(), SIGNAL(activeEngineChanged()), this, SLOT(updatePlaceHolderText()));
    connect(mApp->searchEnginesManager(), SIGNAL(defaultEngineChanged()), this, SLOT(updatePlaceHolderText()));
    connect(mApp, SIGNAL(settingsReloaded()), SLOT(loadSettings()));

    loadSettings();

    updateSiteIcon();

    // Hide icons by default
    m_goIcon->setVisible(qzSettings->alwaysShowGoIcon);
    m_autofillIcon->hide();

    QTimer::singleShot(0, this, SLOT(updatePlaceHolderText()));
}
Exemplo n.º 7
0
ChatPanel::ChatPanel(const QStringList &botNames, UsersColorsPool *colorsPool,
                        TextEditorModifier *chatInputModifier, EmojiManager *emojiManager) :
    QWidget(nullptr),
    ui(new Ui::ChatPanel),
    emojiManager(emojiManager),
    botNames(botNames),
    autoTranslating(false),
    colorsPool(colorsPool),
    unreadedMessages(0),
    on(false)
{
    ui->setupUi(this);
    QVBoxLayout *contentLayout = new QVBoxLayout(ui->scrollContent);
    contentLayout->setContentsMargins(0, 0, 0, 0);
    ui->scrollContent->setLayout(contentLayout);

    ui->topicLabel->setVisible(false);

    // disable blue border when QLineEdit has focus in mac
    ui->chatText->setAttribute(Qt::WA_MacShowFocusRect, 0);

    previousVerticalScrollBarMaxValue = ui->chatScroll->verticalScrollBar()->value();

    emojiWidget = new EmojiWidget(emojiManager, this);
    emojiWidget->setVisible(false);
    qobject_cast<QVBoxLayout *>(layout())->insertWidget(layout()->count()-2, emojiWidget);
    emojiWidget->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::MinimumExpanding);

    auto emojiIcon = IconFactory::createChatEmojiIcon(Qt::black, on);
    emojiAction = ui->chatText->addAction(emojiIcon, QLineEdit::LeadingPosition);

    if (chatInputModifier) {
        bool finishEditorPressingReturnKey = false;
        chatInputModifier->modify(ui->chatText, finishEditorPressingReturnKey);
    }

    ui->scrollContent->installEventFilter(this);

    setupSignals();

    instances.append(this);

    auto root = new QTreeWidgetItem(ui->treeWidget, QStringList());
    root->setFirstColumnSpanned(true); // the root col span
    ui->treeWidget->addTopLevelItem(root);

    connect(ui->treeWidget, &QTreeWidget::collapsed, [=](){
        ui->treeWidget->setMaximumHeight(20);
    });

    connect(ui->treeWidget, &QTreeWidget::expanded, [=](){
        auto root = ui->treeWidget->topLevelItem(0);
        Q_ASSERT(root);
        if (root->childCount() > 0)
            ui->treeWidget->setMaximumHeight(150);
    });

    connect(ui->treeWidget, &QTreeWidget::clicked, [=](QModelIndex index){
        auto root = ui->treeWidget->topLevelItem(0);
        Q_ASSERT(root);
        if (root->isExpanded())
            ui->treeWidget->collapse(index);
        else
            ui->treeWidget->expand(index);
    });

    ui->treeWidget->setMaximumHeight(20);

    ui->treeWidget->setVisible(false);

    ui->treeWidget->setContextMenuPolicy(Qt::CustomContextMenu);

    connect(ui->treeWidget, &QTreeWidget::customContextMenuRequested, this, &ChatPanel::showContextMenu);

    ui->buttonOnOff->setIcon(IconFactory::createChatOnOffIcon(Qt::black));
    ui->buttonOnOff->setChecked(on);
    connect(ui->buttonOnOff, &QPushButton::toggled, this, &ChatPanel::toggleOnOff);

    updatePlaceHolderText();
    updateEmojiIcon();

    showConnectedUsersWidget(false);
}