Ejemplo n.º 1
0
/*!
    \overload
    \internal
    Calculates the position at which the ScrollDial will
    be shown.
*/
QPoint QtScrollDial::popupPosition()
{
    // Get information about the users screen size
    QDesktopWidget desktop;
    QRect desktopRect = (desktop.rect());

    const int w = m_popup->sizeHint().width();
    const int h = m_popup->sizeHint().height();

    // 15 pixel is the popup's m_closeButton.height() / 2
    QPoint popupPosition(rect().right(), -15);

    QPoint globalPos = mapToGlobal(popupPosition);

    // if it does not fit on the right, move to the left
    if (globalPos.x() + w > desktopRect.right()) {
        globalPos.setX(globalPos.x() - width() - w);
    }

    if (globalPos.x() + w > desktopRect.right()) {
        globalPos.setX(desktopRect.right() - w);
    }
    if (globalPos.x() < desktopRect.left()) {
        globalPos.setX(desktopRect.left());
    }
    if (globalPos.y() < desktopRect.top()) {
        globalPos.setY(desktopRect.top());
    }
    if (globalPos.y() + h > desktopRect.bottom()) {
        globalPos.setY(desktopRect.bottom() - h);
    }

    return globalPos;
}
Ejemplo n.º 2
0
void SwitchWindow::contextEvent(QGraphicsSceneMouseEvent *event)
{
    makeMenu();
    if (!m_menu->isEmpty()) {
        m_menu->exec(popupPosition(m_menu->size(), event));
    }
}
Ejemplo n.º 3
0
/*!
    \overload
    \internal
    Show the QtScrollDial on mouse press.
    Event \a ev not used.
*/
void QtScrollDial::mousePressEvent(QMouseEvent* ev)
{
    Q_UNUSED(ev);
    m_popup->move(popupPosition());
    m_popup->setRange(minimum(), maximum());
    m_popup->setValue(value());
    m_popup->show();
}
Ejemplo n.º 4
0
void JobViewServer::showPopup() {
  if (!connected) return;
  jobViewContainer->setMinimumWidth(360);
  jobViewContainer->setMaximumWidth(360);
  jobViewContainer->resize(jobViewContainer->effectiveSizeHint(Qt::MinimumSize));
  jobViewContainer->scene()->setSceneRect(jobViewContainer->geometry());
  popup->move(popupPosition(popup->size()));
  popup->animatedShow(Plasma::Direction(0));
}
Ejemplo n.º 5
0
void StackFolder::runViewer(const QString &path, int x, int y, int width, int height)
{
    if (!view()) {
        return;
    }

    QSize margin = QSize(12, 12); //style()->pixelMetric(QStyle::PM_LayoutLeftMargin);

    QSize s = m_graphicsWidget->size().toSize() + margin;
    QPoint pos = popupPosition(s);
    //kDebug() << "runViewer x=" << pos.x() << " y=" << pos.y();

    m_viewer->run(path, x + pos.x(), y + pos.y(), width, height);
}
Ejemplo n.º 6
0
void WindowList::showMenu(bool onlyCurrentDesktop)
{
    QList<WId> windows = KWindowSystem::windows();
    QList<QAction*> actionList;
    QList< QList<QAction*> > windowList;
    int amount = 0;
    int number = 0;

    qDeleteAll(m_listMenu->actions());
    //m_listMenu->clear();

    if (!onlyCurrentDesktop) {
        m_listMenu->addTitle(i18n("Actions"));

        QAction *unclutterAction = m_listMenu->addAction(i18n("Unclutter Windows"));
        QAction *cascadeAction = m_listMenu->addAction(i18n("Cascade Windows"));

        connect(unclutterAction, SIGNAL(triggered()), m_listMenu, SLOT(slotUnclutterWindows()));
        connect(cascadeAction, SIGNAL(triggered()), m_listMenu, SLOT(slotCascadeWindows()));
    }

    for (int i = 0; i <= KWindowSystem::numberOfDesktops(); ++i) {
        windowList.append(QList<QAction*>());
    }

    for (int i = 0; i < windows.count(); ++i) {
        KWindowInfo window = KWindowSystem::windowInfo(windows.at(i), (NET::WMGeometry | NET::WMFrameExtents | NET::WMWindowType | NET::WMDesktop | NET::WMState | NET::XAWMState | NET::WMVisibleName));
        NET::WindowType type = window.windowType(NET::NormalMask | NET::DialogMask | NET::OverrideMask | NET::UtilityMask | NET::DesktopMask | NET::DockMask | NET::TopMenuMask | NET::SplashMask | NET::ToolbarMask | NET::MenuMask);

        if ((onlyCurrentDesktop && !window.isOnDesktop(KWindowSystem::currentDesktop())) || type == NET::Desktop || type == NET::Dock || type == NET::TopMenu || type == NET::Splash || type == NET::Menu || type == NET::Toolbar || window.hasState(NET::SkipPager)) {
            windows.removeAt(i);

            --i;

            continue;
        }

        ++amount;

        QAction *action = new QAction(QIcon(KWindowSystem::icon(windows.at(i))), window.visibleName(), this);
        action->setData((unsigned long long) windows.at(i));

        QString window_title = QString(action->text());
        window_title.truncate(55);
        action->setText(window_title);

        QFont font = QFont(action->font());

        if (window.isMinimized()) {
            font.setItalic(true);
        } else if (KWindowSystem::activeWindow() == windows.at(i)) {
            font.setUnderline(true);
            font.setBold(true);
        }

        action->setFont(font);

        number = ((onlyCurrentDesktop || window.onAllDesktops()) ? 0 : window.desktop());

        QList<QAction*> subList = windowList.value(number);
        subList.append(action);

        windowList.replace(number, subList);
    }

    const bool useSubMenus = (!onlyCurrentDesktop && KWindowSystem::numberOfDesktops() > 1 && (amount / KWindowSystem::numberOfDesktops()) > 5);

    if (amount && useSubMenus) {
        m_listMenu->addTitle(i18n("Desktops"));
    }

    for (int i = 0; i <= KWindowSystem::numberOfDesktops(); ++i) {
        if (windowList.value(i).isEmpty()) {
            continue;
        }

        KMenu *subMenu = NULL;
        QAction *subMenuAction = NULL;
        QString title = (i ? KWindowSystem::desktopName(i) : (onlyCurrentDesktop ? i18n("Current desktop") : i18n("On all desktops")));

        if (useSubMenus) {
            subMenuAction = m_listMenu->addAction(title);

            subMenu = new KMenu(m_listMenu);
            subMenu->installEventFilter(this);
        } else {
            m_listMenu->addTitle(title);
        }

        for (int j = 0; j < windowList.value(i).count(); ++j) {
            if (useSubMenus) {
                subMenu->addAction(windowList.value(i).value(j));
            } else {
                m_listMenu->addAction(windowList.value(i).value(j));
            }
        }

        if (useSubMenus) {
            subMenuAction->setMenu(subMenu);
        }
    }

    if (!amount) {
        qDeleteAll(m_listMenu->actions());

        m_listMenu->clear();

        QAction *noWindows = m_listMenu->addAction(i18n("No windows"));
        noWindows->setEnabled(false);
    }

    if (formFactor() == Plasma::Vertical || formFactor() == Plasma::Horizontal) {
        m_listMenu->popup(popupPosition(m_listMenu->sizeHint()));
    } else {
        m_listMenu->popup(QCursor::pos());
    }
}
Ejemplo n.º 7
0
void WicdApplet::connectionInfoRequested()
{
    InfoDialog *infoDialog = new InfoDialog(m_status);
    infoDialog->move(popupPosition(infoDialog->sizeHint(), Qt::AlignRight));
    infoDialog->animatedShow(locationToDirection(location()));
}
Ejemplo n.º 8
0
void WicdApplet::launchProfileManager()
{
    ProfileDialog *profileDialog = new ProfileDialog(this);
    profileDialog->move(popupPosition(profileDialog->sizeHint()));
    profileDialog->animatedShow(locationToDirection(location()));
}
Ejemplo n.º 9
0
void SpellCheck::toggleDialog(bool pasteText, bool preferSelection)
{
    if (!m_spellingDialog) {
        m_spellingDialog = new Plasma::Dialog();
        KWindowSystem::setState(m_spellingDialog->effectiveWinId(), NET::SkipTaskbar|NET::SkipPager);
        m_spellingDialog->setFocusPolicy(Qt::NoFocus);
        m_spellingDialog->setWindowTitle(i18n("Spell checking"));
        m_spellingDialog->setWindowIcon(KIcon("tools-check-spelling"));
        m_spellingDialog->setResizeHandleCorners(Plasma::Dialog::All);

        m_textEdit = new KTextEdit(m_spellingDialog);
        m_textEdit->enableFindReplace(false);
        m_textEdit->setCheckSpellingEnabled(true);
        m_textEdit->createHighlighter();

        m_dictionaryComboBox = new Sonnet::DictionaryComboBox(m_spellingDialog);
        m_dictionaryComboBox->setToolTip(i18n("Language"));

        KAction *spellingAction = new KAction(KIcon("tools-check-spelling"), i18n("Spell checking"), m_spellingDialog);
        KAction *copyAction = new KAction(KIcon("edit-copy"), i18n("Copy"), m_spellingDialog);
        KAction *closeAction = new KAction(KIcon("dialog-close"), i18n("Close"), m_spellingDialog);

        QToolButton *spellingButton = new QToolButton(m_spellingDialog);
        spellingButton->setDefaultAction(spellingAction);

        QToolButton *copyButton = new QToolButton(m_spellingDialog);
        copyButton->setDefaultAction(copyAction);

        QToolButton *closeButton = new QToolButton(m_spellingDialog);
        closeButton->setDefaultAction(closeAction);

        QHBoxLayout *horizontalLayout = new QHBoxLayout;
        horizontalLayout->addWidget(m_dictionaryComboBox);
        horizontalLayout->addWidget(spellingButton);
        horizontalLayout->addWidget(copyButton);
        horizontalLayout->addWidget(closeButton);

        QVBoxLayout *verticalLayout = new QVBoxLayout(m_spellingDialog);
        verticalLayout->setSpacing(0);
        verticalLayout->setMargin(0);
        verticalLayout->addWidget(m_textEdit);
        verticalLayout->addLayout(horizontalLayout);

        configChanged();

        connect(m_spellingDialog, SIGNAL(dialogResized()), this, SLOT(dialogResized()));
        connect(spellingAction, SIGNAL(triggered()), m_textEdit, SLOT(checkSpelling()));
        connect(copyAction, SIGNAL(triggered()), this, SLOT(copyToClipboard()));
        connect(closeAction, SIGNAL(triggered()), this, SLOT(toggleDialog()));
        connect(m_textEdit, SIGNAL(languageChanged(QString)), this, SLOT(setLanguage(QString)));
        connect(m_dictionaryComboBox, SIGNAL(dictionaryChanged(QString)), this, SLOT(setLanguage(QString)));
    }

    if (m_spellingDialog->isVisible()) {
        m_spellingDialog->animatedHide(Plasma::locationToInverseDirection(location()));

        m_textEdit->clear();
    } else {
        m_spellingDialog->move(popupPosition(m_spellingDialog->sizeHint()));
        m_spellingDialog->animatedShow(Plasma::locationToDirection(location()));

        if (pasteText) {
            m_textEdit->setText((!preferSelection || QApplication::clipboard()->text(QClipboard::Selection).isEmpty()) ? QApplication::clipboard()->text(QClipboard::Clipboard) : QApplication::clipboard()->text(QClipboard::Selection));
        }

        m_textEdit->setFocus();
    }
}
Ejemplo n.º 10
0
void SwitchDesktop::contextEvent(QGraphicsSceneMouseEvent *event)
{
    makeMenu();
    m_menu->exec(popupPosition(m_menu->size(), event));
}