diff --git a/decorations/settings.cpp b/decorations/settings.cpp index a701b21c3d..2e08dcd366 100644 --- a/decorations/settings.cpp +++ b/decorations/settings.cpp @@ -86,7 +86,7 @@ static void initButtons() s_buttonNames[KDecoration2::DecorationButtonType::Shade] = QChar('L'); } -static QString buttonsToString(const QList &buttons) +static QString buttonsToString(const QVector &buttons) { auto buttonToString = [](KDecoration2::DecorationButtonType button) -> QChar { const auto it = s_buttonNames.constFind(button); @@ -102,13 +102,13 @@ static QString buttonsToString(const QList & return ret; } -QList< KDecoration2::DecorationButtonType > SettingsImpl::readDecorationButtons(const KConfigGroup &config, +QVector< KDecoration2::DecorationButtonType > SettingsImpl::readDecorationButtons(const KConfigGroup &config, const char *key, - const QList< KDecoration2::DecorationButtonType > &defaultValue) const + const QVector< KDecoration2::DecorationButtonType > &defaultValue) const { initButtons(); - auto buttonsFromString = [](const QString &buttons) -> QList { - QList ret; + auto buttonsFromString = [](const QString &buttons) -> QVector { + QVector ret; for (auto it = buttons.begin(); it != buttons.end(); ++it) { for (auto it2 = s_buttonNames.constBegin(); it2 != s_buttonNames.constEnd(); ++it2) { if (it2.value() == (*it)) { @@ -124,11 +124,11 @@ QList< KDecoration2::DecorationButtonType > SettingsImpl::readDecorationButtons( void SettingsImpl::readSettings() { KConfigGroup config = KSharedConfig::openConfig(KWIN_CONFIG)->group(QStringLiteral("org.kde.kdecoration2")); - m_leftButtons = readDecorationButtons(config, "ButtonsOnLeft", QList({ + m_leftButtons = readDecorationButtons(config, "ButtonsOnLeft", QVector({ KDecoration2::DecorationButtonType::Menu, KDecoration2::DecorationButtonType::OnAllDesktops })); - m_rightButtons = readDecorationButtons(config, "ButtonsOnRight", QList({ + m_rightButtons = readDecorationButtons(config, "ButtonsOnRight", QVector({ KDecoration2::DecorationButtonType::Minimize, KDecoration2::DecorationButtonType::Maximize, KDecoration2::DecorationButtonType::Close diff --git a/decorations/settings.h b/decorations/settings.h index 5ad0097ce7..6767507ea0 100644 --- a/decorations/settings.h +++ b/decorations/settings.h @@ -43,20 +43,20 @@ public: KDecoration2::BorderSize borderSize() const override { return m_borderSize; } - QList< KDecoration2::DecorationButtonType > decorationButtonsLeft() const override { + QVector< KDecoration2::DecorationButtonType > decorationButtonsLeft() const override { return m_leftButtons; } - QList< KDecoration2::DecorationButtonType > decorationButtonsRight() const override { + QVector< KDecoration2::DecorationButtonType > decorationButtonsRight() const override { return m_rightButtons; } private: void readSettings(); - QList< KDecoration2::DecorationButtonType > readDecorationButtons(const KConfigGroup &config, + QVector< KDecoration2::DecorationButtonType > readDecorationButtons(const KConfigGroup &config, const char *key, - const QList< KDecoration2::DecorationButtonType > &defaultValue) const; - QList< KDecoration2::DecorationButtonType > m_leftButtons; - QList< KDecoration2::DecorationButtonType > m_rightButtons; + const QVector< KDecoration2::DecorationButtonType > &defaultValue) const; + QVector< KDecoration2::DecorationButtonType > m_leftButtons; + QVector< KDecoration2::DecorationButtonType > m_rightButtons; KDecoration2::BorderSize m_borderSize; }; } // Decoration diff --git a/kcmkwin/kwindecoration/declarative-plugin/previewsettings.cpp b/kcmkwin/kwindecoration/declarative-plugin/previewsettings.cpp index d0fc610df0..6216d33147 100644 --- a/kcmkwin/kwindecoration/declarative-plugin/previewsettings.cpp +++ b/kcmkwin/kwindecoration/declarative-plugin/previewsettings.cpp @@ -30,14 +30,14 @@ namespace KDecoration2 namespace Preview { -ButtonsModel::ButtonsModel(const QList< DecorationButtonType > &buttons, QObject *parent) +ButtonsModel::ButtonsModel(const QVector< DecorationButtonType > &buttons, QObject *parent) : QAbstractListModel(parent) , m_buttons(buttons) { } ButtonsModel::ButtonsModel(QObject* parent) - : ButtonsModel(QList({ + : ButtonsModel(QVector({ DecorationButtonType::Menu, DecorationButtonType::ApplicationMenu, DecorationButtonType::OnAllDesktops, @@ -131,7 +131,7 @@ void ButtonsModel::down(int index) return; } beginMoveRows(QModelIndex(), index, index, QModelIndex(), index + 2); - m_buttons.move(index, index + 1); + m_buttons.insert(index +1, m_buttons.takeAt(index)); endMoveRows(); } @@ -141,7 +141,7 @@ void ButtonsModel::up(int index) return; } beginMoveRows(QModelIndex(), index, index, QModelIndex(), index -1); - m_buttons.move(index, index - 1); + m_buttons.insert(index -1, m_buttons.takeAt(index)); endMoveRows(); } @@ -191,17 +191,17 @@ PreviewSettings::PreviewSettings(DecorationSettings *parent) , m_alphaChannelSupported(true) , m_onAllDesktopsAvailable(true) , m_closeOnDoubleClick(false) - , m_leftButtons(new ButtonsModel(QList({ + , m_leftButtons(new ButtonsModel(QVector({ DecorationButtonType::Menu, DecorationButtonType::OnAllDesktops }), this)) - , m_rightButtons(new ButtonsModel(QList({ + , m_rightButtons(new ButtonsModel(QVector({ DecorationButtonType::ContextHelp, DecorationButtonType::Minimize, DecorationButtonType::Maximize, DecorationButtonType::Close }), this)) - , m_availableButtons(new ButtonsModel(QList({ + , m_availableButtons(new ButtonsModel(QVector({ DecorationButtonType::Menu, DecorationButtonType::ApplicationMenu, DecorationButtonType::OnAllDesktops, @@ -274,12 +274,12 @@ void PreviewSettings::setCloseOnDoubleClickOnMenu(bool enabled) emit closeOnDoubleClickOnMenuChanged(enabled); } -QList< DecorationButtonType > PreviewSettings::decorationButtonsLeft() const +QVector< DecorationButtonType > PreviewSettings::decorationButtonsLeft() const { return m_leftButtons->buttons(); } -QList< DecorationButtonType > PreviewSettings::decorationButtonsRight() const +QVector< DecorationButtonType > PreviewSettings::decorationButtonsRight() const { return m_rightButtons->buttons(); } diff --git a/kcmkwin/kwindecoration/declarative-plugin/previewsettings.h b/kcmkwin/kwindecoration/declarative-plugin/previewsettings.h index b3eb2a931d..8430091c6f 100644 --- a/kcmkwin/kwindecoration/declarative-plugin/previewsettings.h +++ b/kcmkwin/kwindecoration/declarative-plugin/previewsettings.h @@ -36,14 +36,14 @@ class ButtonsModel : public QAbstractListModel { Q_OBJECT public: - explicit ButtonsModel(const QList< DecorationButtonType > &buttons, QObject *parent = 0); + explicit ButtonsModel(const QVector< DecorationButtonType > &buttons, QObject *parent = 0); explicit ButtonsModel(QObject *parent = nullptr); virtual ~ButtonsModel(); QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; int rowCount(const QModelIndex& parent = QModelIndex()) const override; QHash< int, QByteArray > roleNames() const override; - QList< DecorationButtonType > buttons() const { + QVector< DecorationButtonType > buttons() const { return m_buttons; } @@ -54,7 +54,7 @@ public: void add(DecorationButtonType type); private: - QList< DecorationButtonType > m_buttons; + QVector< DecorationButtonType > m_buttons; }; class BorderSizesModel : public QAbstractListModel @@ -119,8 +119,8 @@ public: return m_borderSizes; } - QList< DecorationButtonType > decorationButtonsLeft() const override; - QList< DecorationButtonType > decorationButtonsRight() const override; + QVector< DecorationButtonType > decorationButtonsLeft() const override; + QVector< DecorationButtonType > decorationButtonsRight() const override; Q_INVOKABLE void addButtonToLeft(int row); Q_INVOKABLE void addButtonToRight(int row);