示例#1
0
SmallDeviceView::SmallDeviceView(const QString &name, const QString &uid, DeviceType type, bool available, QWidget *parent) :
    AbstractDeviceView(name, uid, available, parent),
    ui(new Ui::SmallDeviceView),
    _horizontalSnap(false),
    _verticalSnap(false),
    _wasClosed(false),
    _type(type)
{
    ui->setupUi(this);

    setWindowFlags(Qt::Window | Qt::FramelessWindowHint);
    setWindowOpacity(WIDGET_OPACITY);
    setAttribute(Qt::WA_TranslucentBackground);

    loadStyle(QString::number(WIDGET_OPACITY * 255), SettingsManager::availableDeviceColor());

    // Context menu
    setContextMenuPolicy(Qt::CustomContextMenu);
    connect(this, SIGNAL(customContextMenuRequested(const QPoint&)),
            this, SLOT(onHistoryViewContextMenuRequested(const QPoint&)));

    setAvailable(available);
    setDeviceName(name);

    initAnimation();
    updateWindowFlags();
    createContextMenuActions();
}
void QToolBarPrivate::setWindowState(bool floating, bool unplug, const QRect &rect)
{
    Q_Q(QToolBar);
    bool visible = !q->isHidden();
    bool wasFloating = q->isFloating(); // ...is also currently using popup menus

    q->hide();

    updateWindowFlags(floating, unplug);

    if (floating != wasFloating)
        layout->checkUsePopupMenu();

    if (!rect.isNull())
        q->setGeometry(rect);

    if (visible)
        q->show();

    if (floating != wasFloating)
        emit q->topLevelChanged(floating);
}