Ejemplo n.º 1
0
void KToolBar::Private::init(bool readConfig, bool _isMainToolBar)
{
  isMainToolBar = _isMainToolBar;
  loadKDESettings();

  // also read in our configurable settings (for non-xmlgui toolbars)
  // KDE5: we can probably remove this, if people save settings then they load them too, e.g. using KMainWindow's autosave.
  if (readConfig) {
      KConfigGroup cg(KGlobal::config(), QString());
      q->applySettings(cg);
  }

  if (q->mainWindow()) {
    // Get notified when settings change
    connect(q, SIGNAL(allowedAreasChanged(Qt::ToolBarAreas)),
             q->mainWindow(), SLOT(setSettingsDirty()));
    connect(q, SIGNAL(iconSizeChanged(QSize)),
             q->mainWindow(), SLOT(setSettingsDirty()));
    connect(q, SIGNAL(toolButtonStyleChanged(Qt::ToolButtonStyle)),
             q->mainWindow(), SLOT(setSettingsDirty()));
    connect(q, SIGNAL(movableChanged(bool)),
             q->mainWindow(), SLOT(setSettingsDirty()));
    connect(q, SIGNAL(orientationChanged(Qt::Orientation)),
             q->mainWindow(), SLOT(setSettingsDirty()));
  }
Ejemplo n.º 2
0
void QDockWidget::setAllowedAreas(Qt::DockWidgetAreas areas)
{
    Q_D(QDockWidget);
    areas &= Qt::DockWidgetArea_Mask;
    if (areas == d->allowedAreas)
        return;
    d->allowedAreas = areas;
    emit allowedAreasChanged(d->allowedAreas);
}
void QToolBar::setAllowedAreas(Qt::ToolBarAreas areas)
{
    Q_D(QToolBar);
    areas &= Qt::ToolBarArea_Mask;
    if (areas == d->allowedAreas)
        return;
    d->allowedAreas = areas;
    emit allowedAreasChanged(d->allowedAreas);
}
Ejemplo n.º 4
0
BaseDockWidget::BaseDockWidget(char* title, QSize size, bool isNeed)
{
	this->title = FontChina::G2U(title);
	widget = new QWidget();
	this->setFeatures(QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable);
	this->setAllowedAreas(Qt::AllDockWidgetAreas);
	this->size = size;
	this->setMinimumSize(size);
	this->setMaximumSize(size);
	this->setWindowTitle(FontChina::G2U(title));
	this->setWidget(widget);
	widget->setStyleSheet("background-color: rgb(191, 191, 191);");
	connect(this, SIGNAL(featuresChanged(QDockWidget::DockWidgetFeatures)), this, SLOT(featuresChanged(QDockWidget::DockWidgetFeatures)));
	connect(this, SIGNAL(topLevelChanged(bool)), this, SLOT(topLevelChanged(bool)));
	connect(this, SIGNAL(allowedAreasChanged(Qt::DockWidgetAreas)), this, SLOT(allowedAreasChanged(Qt::DockWidgetAreas)));
	connect(this, SIGNAL(visibilityChanged(bool)), this, SLOT(visibilityChanged(bool)));
	connect(this, SIGNAL(dockLocationChanged(Qt::DockWidgetArea)), this, SLOT(dockLocationChanged(Qt::DockWidgetArea)));
	if (isNeed){
		NeedMinOrMaxToolButton();
	}
}
Ejemplo n.º 5
0
void KToolBar::Private::init(bool readConfig, bool _isMainToolBar)
{
    isMainToolBar = _isMainToolBar;
    loadKDESettings();

    // also read in our configurable settings (for non-xmlgui toolbars)
    if (readConfig) {
        KConfigGroup cg(KSharedConfig::openConfig(), QString());
        q->applySettings(cg);
    }

    if (q->mainWindow()) {
        // Get notified when settings change
        connect(q, SIGNAL(allowedAreasChanged(Qt::ToolBarAreas)),
                q->mainWindow(), SLOT(setSettingsDirty()));
        connect(q, SIGNAL(iconSizeChanged(QSize)),
                q->mainWindow(), SLOT(setSettingsDirty()));
        connect(q, SIGNAL(toolButtonStyleChanged(Qt::ToolButtonStyle)),
                q->mainWindow(), SLOT(setSettingsDirty()));
        connect(q, SIGNAL(movableChanged(bool)),
                q->mainWindow(), SLOT(setSettingsDirty()));
        connect(q, SIGNAL(orientationChanged(Qt::Orientation)),
                q->mainWindow(), SLOT(setSettingsDirty()));
    }
Ejemplo n.º 6
0
void tst_QToolBar::allowedAreas()
{
    QToolBar tb;

    QSignalSpy spy(&tb, SIGNAL(allowedAreasChanged(Qt::ToolBarAreas)));

    // default
    QCOMPARE((int)tb.allowedAreas(), (int)Qt::AllToolBarAreas);
    QVERIFY(tb.isAreaAllowed(Qt::LeftToolBarArea));
    QVERIFY(tb.isAreaAllowed(Qt::RightToolBarArea));
    QVERIFY(tb.isAreaAllowed(Qt::TopToolBarArea));
    QVERIFY(tb.isAreaAllowed(Qt::BottomToolBarArea));

    // a single dock window area
    tb.setAllowedAreas(Qt::LeftToolBarArea);
    QCOMPARE((int)tb.allowedAreas(), (int)Qt::LeftToolBarArea);
    QVERIFY(tb.isAreaAllowed(Qt::LeftToolBarArea));
    QVERIFY(!tb.isAreaAllowed(Qt::RightToolBarArea));
    QVERIFY(!tb.isAreaAllowed(Qt::TopToolBarArea));
    QVERIFY(!tb.isAreaAllowed(Qt::BottomToolBarArea));
    QCOMPARE(spy.count(), 1);
    QCOMPARE(*static_cast<const Qt::ToolBarAreas *>(spy.at(0).value(0).constData()),
             tb.allowedAreas());
    spy.clear();
    tb.setAllowedAreas(tb.allowedAreas());
    QCOMPARE(spy.count(), 0);

    tb.setAllowedAreas(Qt::RightToolBarArea);
    QCOMPARE((int)tb.allowedAreas(), (int)Qt::RightToolBarArea);
    QVERIFY(!tb.isAreaAllowed(Qt::LeftToolBarArea));
    QVERIFY(tb.isAreaAllowed(Qt::RightToolBarArea));
    QVERIFY(!tb.isAreaAllowed(Qt::TopToolBarArea));
    QVERIFY(!tb.isAreaAllowed(Qt::BottomToolBarArea));
    QCOMPARE(spy.count(), 1);
    QCOMPARE(*static_cast<const Qt::ToolBarAreas *>(spy.at(0).value(0).constData()),
             tb.allowedAreas());
    spy.clear();
    tb.setAllowedAreas(tb.allowedAreas());
    QCOMPARE(spy.count(), 0);

    tb.setAllowedAreas(Qt::TopToolBarArea);
    QCOMPARE((int)tb.allowedAreas(), (int)Qt::TopToolBarArea);
    QVERIFY(!tb.isAreaAllowed(Qt::LeftToolBarArea));
    QVERIFY(!tb.isAreaAllowed(Qt::RightToolBarArea));
    QVERIFY(tb.isAreaAllowed(Qt::TopToolBarArea));
    QVERIFY(!tb.isAreaAllowed(Qt::BottomToolBarArea));
    QCOMPARE(spy.count(), 1);
    QCOMPARE(*static_cast<const Qt::ToolBarAreas *>(spy.at(0).value(0).constData()),
             tb.allowedAreas());
    spy.clear();
    tb.setAllowedAreas(tb.allowedAreas());
    QCOMPARE(spy.count(), 0);

    tb.setAllowedAreas(Qt::BottomToolBarArea);
    QCOMPARE((int)tb.allowedAreas(), (int)Qt::BottomToolBarArea);
    QVERIFY(!tb.isAreaAllowed(Qt::LeftToolBarArea));
    QVERIFY(!tb.isAreaAllowed(Qt::RightToolBarArea));
    QVERIFY(!tb.isAreaAllowed(Qt::TopToolBarArea));
    QVERIFY(tb.isAreaAllowed(Qt::BottomToolBarArea));
    QCOMPARE(spy.count(), 1);
    QCOMPARE(*static_cast<const Qt::ToolBarAreas *>(spy.at(0).value(0).constData()),
             tb.allowedAreas());
    spy.clear();
    tb.setAllowedAreas(tb.allowedAreas());
    QCOMPARE(spy.count(), 0);

    // multiple dock window areas
    tb.setAllowedAreas(Qt::TopToolBarArea | Qt::BottomToolBarArea);
    QCOMPARE(tb.allowedAreas(), Qt::TopToolBarArea | Qt::BottomToolBarArea);
    QVERIFY(!tb.isAreaAllowed(Qt::LeftToolBarArea));
    QVERIFY(!tb.isAreaAllowed(Qt::RightToolBarArea));
    QVERIFY(tb.isAreaAllowed(Qt::TopToolBarArea));
    QVERIFY(tb.isAreaAllowed(Qt::BottomToolBarArea));
    QCOMPARE(spy.count(), 1);
    QCOMPARE(*static_cast<const Qt::ToolBarAreas *>(spy.at(0).value(0).constData()),
             tb.allowedAreas());
    spy.clear();
    tb.setAllowedAreas(tb.allowedAreas());
    QCOMPARE(spy.count(), 0);

    tb.setAllowedAreas(Qt::LeftToolBarArea | Qt::RightToolBarArea);
    QCOMPARE(tb.allowedAreas(), Qt::LeftToolBarArea | Qt::RightToolBarArea);
    QVERIFY(tb.isAreaAllowed(Qt::LeftToolBarArea));
    QVERIFY(tb.isAreaAllowed(Qt::RightToolBarArea));
    QVERIFY(!tb.isAreaAllowed(Qt::TopToolBarArea));
    QVERIFY(!tb.isAreaAllowed(Qt::BottomToolBarArea));
    QCOMPARE(spy.count(), 1);
    QCOMPARE(*static_cast<const Qt::ToolBarAreas *>(spy.at(0).value(0).constData()),
             tb.allowedAreas());
    spy.clear();
    tb.setAllowedAreas(tb.allowedAreas());
    QCOMPARE(spy.count(), 0);

    tb.setAllowedAreas(Qt::TopToolBarArea | Qt::LeftToolBarArea);
    QCOMPARE(tb.allowedAreas(), Qt::TopToolBarArea | Qt::LeftToolBarArea);
    QVERIFY(tb.isAreaAllowed(Qt::LeftToolBarArea));
    QVERIFY(!tb.isAreaAllowed(Qt::RightToolBarArea));
    QVERIFY(tb.isAreaAllowed(Qt::TopToolBarArea));
    QVERIFY(!tb.isAreaAllowed(Qt::BottomToolBarArea));
    QCOMPARE(spy.count(), 1);
    QCOMPARE(*static_cast<const Qt::ToolBarAreas *>(spy.at(0).value(0).constData()),
             tb.allowedAreas());
    spy.clear();
    tb.setAllowedAreas(tb.allowedAreas());
    QCOMPARE(spy.count(), 0);

    tb.setAllowedAreas(Qt::BottomToolBarArea | Qt::RightToolBarArea);
    QCOMPARE(tb.allowedAreas(), Qt::BottomToolBarArea | Qt::RightToolBarArea);
    QVERIFY(!tb.isAreaAllowed(Qt::LeftToolBarArea));
    QVERIFY(tb.isAreaAllowed(Qt::RightToolBarArea));
    QVERIFY(!tb.isAreaAllowed(Qt::TopToolBarArea));
    QVERIFY(tb.isAreaAllowed(Qt::BottomToolBarArea));
    QCOMPARE(spy.count(), 1);
    QCOMPARE(*static_cast<const Qt::ToolBarAreas *>(spy.at(0).value(0).constData()),
             tb.allowedAreas());
    spy.clear();
    tb.setAllowedAreas(tb.allowedAreas());
    QCOMPARE(spy.count(), 0);
}
Ejemplo n.º 7
0
void tst_QDockWidget::allowedAreas()
{
    QDockWidget dw;

    QSignalSpy spy(&dw, SIGNAL(allowedAreasChanged(Qt::DockWidgetAreas)));

    // default
    QCOMPARE(dw.allowedAreas(), Qt::AllDockWidgetAreas);
    QVERIFY(dw.isAreaAllowed(Qt::LeftDockWidgetArea));
    QVERIFY(dw.isAreaAllowed(Qt::RightDockWidgetArea));
    QVERIFY(dw.isAreaAllowed(Qt::TopDockWidgetArea));
    QVERIFY(dw.isAreaAllowed(Qt::BottomDockWidgetArea));

    // a single dock window area
    dw.setAllowedAreas(Qt::LeftDockWidgetArea);
    QCOMPARE(dw.allowedAreas(), Qt::LeftDockWidgetArea);
    QVERIFY(dw.isAreaAllowed(Qt::LeftDockWidgetArea));
    QVERIFY(!dw.isAreaAllowed(Qt::RightDockWidgetArea));
    QVERIFY(!dw.isAreaAllowed(Qt::TopDockWidgetArea));
    QVERIFY(!dw.isAreaAllowed(Qt::BottomDockWidgetArea));
    QCOMPARE(spy.count(), 1);
    QCOMPARE(*static_cast<const Qt::DockWidgetAreas *>(spy.at(0).value(0).constData()),
            dw.allowedAreas());
    spy.clear();
    dw.setAllowedAreas(dw.allowedAreas());
    QCOMPARE(spy.count(), 0);

    dw.setAllowedAreas(Qt::RightDockWidgetArea);
    QCOMPARE(dw.allowedAreas(), Qt::RightDockWidgetArea);
    QVERIFY(!dw.isAreaAllowed(Qt::LeftDockWidgetArea));
    QVERIFY(dw.isAreaAllowed(Qt::RightDockWidgetArea));
    QVERIFY(!dw.isAreaAllowed(Qt::TopDockWidgetArea));
    QVERIFY(!dw.isAreaAllowed(Qt::BottomDockWidgetArea));
    QCOMPARE(spy.count(), 1);
    QCOMPARE(*static_cast<const Qt::DockWidgetAreas *>(spy.at(0).value(0).constData()),
            dw.allowedAreas());
    spy.clear();
    dw.setAllowedAreas(dw.allowedAreas());
    QCOMPARE(spy.count(), 0);

    dw.setAllowedAreas(Qt::TopDockWidgetArea);
    QCOMPARE(dw.allowedAreas(), Qt::TopDockWidgetArea);
    QVERIFY(!dw.isAreaAllowed(Qt::LeftDockWidgetArea));
    QVERIFY(!dw.isAreaAllowed(Qt::RightDockWidgetArea));
    QVERIFY(dw.isAreaAllowed(Qt::TopDockWidgetArea));
    QVERIFY(!dw.isAreaAllowed(Qt::BottomDockWidgetArea));
    QCOMPARE(spy.count(), 1);
    QCOMPARE(*static_cast<const Qt::DockWidgetAreas *>(spy.at(0).value(0).constData()),
            dw.allowedAreas());
    spy.clear();
    dw.setAllowedAreas(dw.allowedAreas());
    QCOMPARE(spy.count(), 0);

    dw.setAllowedAreas(Qt::BottomDockWidgetArea);
    QCOMPARE(dw.allowedAreas(), Qt::BottomDockWidgetArea);
    QVERIFY(!dw.isAreaAllowed(Qt::LeftDockWidgetArea));
    QVERIFY(!dw.isAreaAllowed(Qt::RightDockWidgetArea));
    QVERIFY(!dw.isAreaAllowed(Qt::TopDockWidgetArea));
    QVERIFY(dw.isAreaAllowed(Qt::BottomDockWidgetArea));
    QCOMPARE(spy.count(), 1);
    QCOMPARE(*static_cast<const Qt::DockWidgetAreas *>(spy.at(0).value(0).constData()),
            dw.allowedAreas());
    spy.clear();
    dw.setAllowedAreas(dw.allowedAreas());
    QCOMPARE(spy.count(), 0);

    // multiple dock window areas
    dw.setAllowedAreas(Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea);
    QCOMPARE(dw.allowedAreas(), Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea);
    QVERIFY(!dw.isAreaAllowed(Qt::LeftDockWidgetArea));
    QVERIFY(!dw.isAreaAllowed(Qt::RightDockWidgetArea));
    QVERIFY(dw.isAreaAllowed(Qt::TopDockWidgetArea));
    QVERIFY(dw.isAreaAllowed(Qt::BottomDockWidgetArea));
    QCOMPARE(spy.count(), 1);
    QCOMPARE(*static_cast<const Qt::DockWidgetAreas *>(spy.at(0).value(0).constData()),
            dw.allowedAreas());
    spy.clear();
    dw.setAllowedAreas(dw.allowedAreas());
    QCOMPARE(spy.count(), 0);

    dw.setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
    QCOMPARE(dw.allowedAreas(), Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
    QVERIFY(dw.isAreaAllowed(Qt::LeftDockWidgetArea));
    QVERIFY(dw.isAreaAllowed(Qt::RightDockWidgetArea));
    QVERIFY(!dw.isAreaAllowed(Qt::TopDockWidgetArea));
    QVERIFY(!dw.isAreaAllowed(Qt::BottomDockWidgetArea));
    QCOMPARE(spy.count(), 1);
    QCOMPARE(*static_cast<const Qt::DockWidgetAreas *>(spy.at(0).value(0).constData()),
            dw.allowedAreas());
    spy.clear();
    dw.setAllowedAreas(dw.allowedAreas());
    QCOMPARE(spy.count(), 0);

    dw.setAllowedAreas(Qt::TopDockWidgetArea | Qt::LeftDockWidgetArea);
    QCOMPARE(dw.allowedAreas(), Qt::TopDockWidgetArea | Qt::LeftDockWidgetArea);
    QVERIFY(dw.isAreaAllowed(Qt::LeftDockWidgetArea));
    QVERIFY(!dw.isAreaAllowed(Qt::RightDockWidgetArea));
    QVERIFY(dw.isAreaAllowed(Qt::TopDockWidgetArea));
    QVERIFY(!dw.isAreaAllowed(Qt::BottomDockWidgetArea));
    QCOMPARE(spy.count(), 1);
    QCOMPARE(*static_cast<const Qt::DockWidgetAreas *>(spy.at(0).value(0).constData()),
            dw.allowedAreas());
    spy.clear();
    dw.setAllowedAreas(dw.allowedAreas());
    QCOMPARE(spy.count(), 0);

    dw.setAllowedAreas(Qt::BottomDockWidgetArea | Qt::RightDockWidgetArea);
    QCOMPARE(dw.allowedAreas(), Qt::BottomDockWidgetArea | Qt::RightDockWidgetArea);
    QVERIFY(!dw.isAreaAllowed(Qt::LeftDockWidgetArea));
    QVERIFY(dw.isAreaAllowed(Qt::RightDockWidgetArea));
    QVERIFY(!dw.isAreaAllowed(Qt::TopDockWidgetArea));
    QVERIFY(dw.isAreaAllowed(Qt::BottomDockWidgetArea));
    QCOMPARE(spy.count(), 1);
    QCOMPARE(*static_cast<const Qt::DockWidgetAreas *>(spy.at(0).value(0).constData()),
            dw.allowedAreas());
    spy.clear();
    dw.setAllowedAreas(dw.allowedAreas());
    QCOMPARE(spy.count(), 0);
}
Ejemplo n.º 8
0
int QToolBar::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QWidget::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: actionTriggered((*reinterpret_cast< QAction*(*)>(_a[1]))); break;
        case 1: movableChanged((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 2: allowedAreasChanged((*reinterpret_cast< Qt::ToolBarAreas(*)>(_a[1]))); break;
        case 3: orientationChanged((*reinterpret_cast< Qt::Orientation(*)>(_a[1]))); break;
        case 4: iconSizeChanged((*reinterpret_cast< const QSize(*)>(_a[1]))); break;
        case 5: toolButtonStyleChanged((*reinterpret_cast< Qt::ToolButtonStyle(*)>(_a[1]))); break;
        case 6: topLevelChanged((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 7: setIconSize((*reinterpret_cast< const QSize(*)>(_a[1]))); break;
        case 8: setToolButtonStyle((*reinterpret_cast< Qt::ToolButtonStyle(*)>(_a[1]))); break;
        case 9: d_func()->_q_toggleView((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 10: d_func()->_q_updateIconSize((*reinterpret_cast< const QSize(*)>(_a[1]))); break;
        case 11: d_func()->_q_updateToolButtonStyle((*reinterpret_cast< Qt::ToolButtonStyle(*)>(_a[1]))); break;
        default: ;
        }
        _id -= 12;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< bool*>(_v) = isMovable(); break;
        case 1: *reinterpret_cast< Qt::ToolBarAreas*>(_v) = allowedAreas(); break;
        case 2: *reinterpret_cast< Qt::Orientation*>(_v) = orientation(); break;
        case 3: *reinterpret_cast< QSize*>(_v) = iconSize(); break;
        case 4: *reinterpret_cast< Qt::ToolButtonStyle*>(_v) = toolButtonStyle(); break;
        case 5: *reinterpret_cast< bool*>(_v) = isFloating(); break;
        case 6: *reinterpret_cast< bool*>(_v) = isFloatable(); break;
        }
        _id -= 7;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setMovable(*reinterpret_cast< bool*>(_v)); break;
        case 1: setAllowedAreas(*reinterpret_cast< Qt::ToolBarAreas*>(_v)); break;
        case 2: setOrientation(*reinterpret_cast< Qt::Orientation*>(_v)); break;
        case 3: setIconSize(*reinterpret_cast< QSize*>(_v)); break;
        case 4: setToolButtonStyle(*reinterpret_cast< Qt::ToolButtonStyle*>(_v)); break;
        case 6: setFloatable(*reinterpret_cast< bool*>(_v)); break;
        }
        _id -= 7;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        bool *_b = reinterpret_cast<bool*>(_a[0]);
        switch (_id) {
        case 0: *_b = (qobject_cast<QMainWindow*>(parentWidget())!=0); break;
        case 1: *_b = (qobject_cast<QMainWindow*>(parentWidget())!=0); break;
        case 2: *_b = (qobject_cast<QMainWindow*>(parentWidget())==0); break;
        }
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 7;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}