/*!
  Constructs a QtColorPicker widget. The popup will display a grid
  with \a cols columns, or if \a cols is -1, the number of columns
  will be calculated automatically.

  If \a enableColorDialog is true, the popup will also have a "More"
  button (signified by an ellipsis "...") that presents a
  QColorDialog when clicked.

  After constructing a QtColorPicker, call insertColor() to add
  individual colors to the popup grid, or call setStandardColors()
  to add all the standard colors in one go.

  The \a parent argument is passed to QFrame's constructor.

  \sa QFrame
*/
QtColorPicker::QtColorPicker(QWidget *parent,
                             int cols, bool enableColorDialog)
    :  QPushButton(parent), popup(0), withColorDialog(enableColorDialog), _labels(false)
{
    setFocusPolicy(Qt::StrongFocus);
    setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
    setAutoDefault(false);
    setAutoFillBackground(true);
    setCheckable(true);

    // Set text
    setText(tr("Black"));
    firstInserted = false;

    // Create and set icon
    col = Qt::black;
    dirty = true;

    // Create color grid popup and connect to it.
    popup = new ColorPickerPopup(this, cols, withColorDialog, this);
    connect(popup, SIGNAL(selected(const QColor &)),
            SLOT(setCurrentColor(const QColor &)));
    connect(popup, SIGNAL(hid()), SLOT(popupClosed()));

    // Connect this push button's pressed() signal.
    connect(this, SIGNAL(toggled(bool)), SLOT(buttonPressed(bool)));
}
示例#2
0
 // ---------------------------------------------------------------------------------
 void KTasksComboBox::hidePopup()
 {
   if(not view()->isVisible()){return;}
   QComboBox::hidePopup();
   setCurrentIndex(view()->currentIndex().row());
   emit popupClosed();
 }
示例#3
0
void lcQColorPicker::buttonPressed(bool toggled)
{
	if (!toggled)
		return;

	lcQColorPickerPopup *popup = new lcQColorPickerPopup(this, currentColorIndex);
	connect(popup, SIGNAL(changed(int)), SLOT(changed(int)));
	connect(popup, SIGNAL(selected(int)), SLOT(selected(int)));
	connect(popup, SIGNAL(hid()), SLOT(popupClosed()));
	popup->setMinimumSize(300, 200);

	const QRect desktop = QApplication::desktop()->geometry();

	QPoint pos = mapToGlobal(rect().bottomLeft());
	if (pos.x() < desktop.left())
		pos.setX(desktop.left());
	if (pos.y() < desktop.top())
		pos.setY(desktop.top());

	if ((pos.x() + popup->width()) > desktop.width())
		pos.setX(desktop.width() - popup->width());
	if ((pos.y() + popup->height()) > desktop.bottom())
		pos.setY(desktop.bottom() - popup->height());
	popup->move(pos);

	clearFocus();
	update();

	popup->setFocus();
	popup->show();
}
示例#4
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()));
}
示例#5
0
void LocationCompleter::slotPopupClosed()
{
    disconnect(s_view, SIGNAL(closed()), this, SLOT(slotPopupClosed()));
    disconnect(s_view, SIGNAL(indexActivated(QModelIndex)), this, SLOT(indexActivated(QModelIndex)));
    disconnect(s_view, SIGNAL(indexCtrlActivated(QModelIndex)), this, SLOT(indexCtrlActivated(QModelIndex)));
    disconnect(s_view, SIGNAL(indexShiftActivated(QModelIndex)), this, SLOT(indexShiftActivated(QModelIndex)));
    disconnect(s_view, SIGNAL(indexDeleteRequested(QModelIndex)), this, SLOT(indexDeleteRequested(QModelIndex)));
    disconnect(s_view->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, SLOT(currentChanged(QModelIndex)));

    emit popupClosed();
}
示例#6
0
void LocationCompleter::slotPopupClosed()
{
    m_popupClosed = true;
    m_oldSuggestions.clear();

    disconnect(s_view, SIGNAL(closed()), this, SLOT(slotPopupClosed()));
    disconnect(s_view, SIGNAL(indexActivated(QModelIndex)), this, SLOT(indexActivated(QModelIndex)));
    disconnect(s_view, SIGNAL(indexCtrlActivated(QModelIndex)), this, SLOT(indexCtrlActivated(QModelIndex)));
    disconnect(s_view, SIGNAL(indexShiftActivated(QModelIndex)), this, SLOT(indexShiftActivated(QModelIndex)));
    disconnect(s_view, SIGNAL(indexDeleteRequested(QModelIndex)), this, SLOT(indexDeleteRequested(QModelIndex)));
    disconnect(s_view, &LocationCompleterView::loadRequested, this, &LocationCompleter::loadRequested);
    disconnect(s_view, &LocationCompleterView::searchEnginesDialogRequested, this, &LocationCompleter::openSearchEnginesDialog);
    disconnect(s_view->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, SLOT(currentChanged(QModelIndex)));

    emit popupClosed();
}
示例#7
0
bool SiteIcon::showPopup()
{
    if (!m_view || !m_window) {
        return false;
    }

    QUrl url = m_view->url();

    if (!SiteInfo::canShowSiteInfo(url))
        return false;

    setDown(true);

    SiteInfoWidget* info = new SiteInfoWidget(m_window);
    info->showAt(parentWidget());

    connect(info, SIGNAL(destroyed()), this, SLOT(popupClosed()));

    return true;
}
示例#8
0
文件: WDatePicker.C 项目: LifeGo/wt
void WDatePicker::onPopupHidden()
{
  forEdit_->setFocus(true);
  popupClosed();
}