DecorationSettings provides QVector for decorationButtons
This commit is contained in:
parent
027a7a1646
commit
106e595709
4 changed files with 27 additions and 27 deletions
|
@ -86,7 +86,7 @@ static void initButtons()
|
|||
s_buttonNames[KDecoration2::DecorationButtonType::Shade] = QChar('L');
|
||||
}
|
||||
|
||||
static QString buttonsToString(const QList<KDecoration2::DecorationButtonType> &buttons)
|
||||
static QString buttonsToString(const QVector<KDecoration2::DecorationButtonType> &buttons)
|
||||
{
|
||||
auto buttonToString = [](KDecoration2::DecorationButtonType button) -> QChar {
|
||||
const auto it = s_buttonNames.constFind(button);
|
||||
|
@ -102,13 +102,13 @@ static QString buttonsToString(const QList<KDecoration2::DecorationButtonType> &
|
|||
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<KDecoration2::DecorationButtonType> {
|
||||
QList<KDecoration2::DecorationButtonType> ret;
|
||||
auto buttonsFromString = [](const QString &buttons) -> QVector<KDecoration2::DecorationButtonType> {
|
||||
QVector<KDecoration2::DecorationButtonType> 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<KDecoration2::DecorationButtonType >({
|
||||
m_leftButtons = readDecorationButtons(config, "ButtonsOnLeft", QVector<KDecoration2::DecorationButtonType >({
|
||||
KDecoration2::DecorationButtonType::Menu,
|
||||
KDecoration2::DecorationButtonType::OnAllDesktops
|
||||
}));
|
||||
m_rightButtons = readDecorationButtons(config, "ButtonsOnRight", QList<KDecoration2::DecorationButtonType >({
|
||||
m_rightButtons = readDecorationButtons(config, "ButtonsOnRight", QVector<KDecoration2::DecorationButtonType >({
|
||||
KDecoration2::DecorationButtonType::Minimize,
|
||||
KDecoration2::DecorationButtonType::Maximize,
|
||||
KDecoration2::DecorationButtonType::Close
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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<DecorationButtonType>({
|
||||
: ButtonsModel(QVector<DecorationButtonType>({
|
||||
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<DecorationButtonType>({
|
||||
, m_leftButtons(new ButtonsModel(QVector<DecorationButtonType>({
|
||||
DecorationButtonType::Menu,
|
||||
DecorationButtonType::OnAllDesktops
|
||||
}), this))
|
||||
, m_rightButtons(new ButtonsModel(QList<DecorationButtonType>({
|
||||
, m_rightButtons(new ButtonsModel(QVector<DecorationButtonType>({
|
||||
DecorationButtonType::ContextHelp,
|
||||
DecorationButtonType::Minimize,
|
||||
DecorationButtonType::Maximize,
|
||||
DecorationButtonType::Close
|
||||
}), this))
|
||||
, m_availableButtons(new ButtonsModel(QList<DecorationButtonType>({
|
||||
, m_availableButtons(new ButtonsModel(QVector<DecorationButtonType>({
|
||||
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();
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue