[kcmdeco] Move KDecorationPreviewOptions into the Model

We need to have it around and not in the Preview widget to be able
to update the options when the buttons change.
This commit is contained in:
Martin Gräßlin 2013-10-09 08:57:00 +02:00
parent aab6037c4a
commit 3ea18be574
4 changed files with 7 additions and 4 deletions

View file

@ -58,6 +58,7 @@ DecorationModel::DecorationModel(KSharedConfigPtr config, QObject* parent)
, m_customButtons(false)
, m_leftButtons(QString())
, m_rightButtons(QString())
, m_options(new KDecorationPreviewOptions)
{
QHash<int, QByteArray> roleNames;
roleNames[Qt::DisplayRole] = "display";
@ -314,6 +315,8 @@ void DecorationModel::changeButtons(const KWin::DecorationButtons *buttons)
m_customButtons = buttons->customPositions();
m_leftButtons = buttons->leftButtons();
m_rightButtons = buttons->rightButtons();
m_options->setCustomTitleButtonsEnabled(m_customButtons);
m_options->setCustomTitleButtons(m_leftButtons, m_rightButtons);
}
void DecorationModel::setButtons(bool custom, const QString& left, const QString& right)
@ -321,6 +324,8 @@ void DecorationModel::setButtons(bool custom, const QString& left, const QString
m_customButtons = custom;
m_leftButtons = left;
m_rightButtons = right;
m_options->setCustomTitleButtonsEnabled(m_customButtons);
m_options->setCustomTitleButtons(m_leftButtons, m_rightButtons);
}
QModelIndex DecorationModel::indexOfLibrary(const QString& libraryName) const

View file

@ -29,6 +29,7 @@ class QWidget;
class KDesktopFile;
class KDecorationPlugins;
class KDecorationPreview;
class KDecorationPreviewOptions;
namespace KWin
{
@ -129,6 +130,7 @@ private:
QString m_leftButtons;
QString m_rightButtons;
KSharedConfigPtr m_config;
QScopedPointer<KDecorationPreviewOptions> m_options;
};
} // namespace KWin

View file

@ -204,8 +204,6 @@ void PreviewItem::updateDecoration(KDecorationPreviewBridge *bridge)
KDecorationPreview::KDecorationPreview(QWidget* parent)
: QWidget(parent)
{
options = new KDecorationPreviewOptions;
bridge[Active] = new KDecorationPreviewBridge(this, true);
bridge[Inactive] = new KDecorationPreviewBridge(this, false);
@ -220,7 +218,6 @@ KDecorationPreview::~KDecorationPreview()
delete deco[i];
delete bridge[i];
}
delete options;
}
void KDecorationPreview::disablePreview()

View file

@ -90,7 +90,6 @@ public:
QRegion unobscuredRegion(bool, const QRegion&) const;
QRect windowGeometry(bool) const;
private:
KDecorationPreviewOptions* options;
KDecorationPreviewBridge* bridge[NumWindows];
KDecoration* deco[NumWindows];
};