Changeset View
Changeset View
Standalone View
Standalone View
kcmkwin/kwindecoration/declarative-plugin/previewbridge.cpp
Show First 20 Lines • Show All 91 Lines • ▼ Show 20 Line(s) | |||||
92 | } | 92 | } | ||
93 | 93 | | |||
94 | void PreviewBridge::setPlugin(const QString &plugin) | 94 | void PreviewBridge::setPlugin(const QString &plugin) | ||
95 | { | 95 | { | ||
96 | if (m_plugin == plugin) { | 96 | if (m_plugin == plugin) { | ||
97 | return; | 97 | return; | ||
98 | } | 98 | } | ||
99 | m_plugin = plugin; | 99 | m_plugin = plugin; | ||
100 | qDebug() << "Plugin changed to: " << m_plugin; | | |||
101 | emit pluginChanged(); | 100 | emit pluginChanged(); | ||
102 | } | 101 | } | ||
103 | 102 | | |||
104 | QString PreviewBridge::theme() const | 103 | QString PreviewBridge::theme() const | ||
105 | { | 104 | { | ||
106 | return m_theme; | 105 | return m_theme; | ||
107 | } | 106 | } | ||
108 | 107 | | |||
Show All 9 Lines | |||||
118 | QString PreviewBridge::plugin() const | 117 | QString PreviewBridge::plugin() const | ||
119 | { | 118 | { | ||
120 | return m_plugin; | 119 | return m_plugin; | ||
121 | } | 120 | } | ||
122 | 121 | | |||
123 | void PreviewBridge::createFactory() | 122 | void PreviewBridge::createFactory() | ||
124 | { | 123 | { | ||
125 | m_factory.clear(); | 124 | m_factory.clear(); | ||
125 | | ||||
126 | if (m_plugin.isNull()) { | 126 | if (m_plugin.isNull()) { | ||
127 | setValid(false); | 127 | setValid(false); | ||
128 | qDebug() <<"Plugin not set"; | 128 | qWarning() << "Plugin not set"; | ||
129 | return; | | |||
130 | } | | |||
131 | const auto offers = KPluginTrader::self()->query(s_pluginName, | | |||
132 | s_pluginName, | | |||
133 | QStringLiteral("[X-KDE-PluginInfo-Name] == '%1'").arg(m_plugin)); | | |||
134 | if (offers.isEmpty()) { | | |||
135 | setValid(false); | | |||
136 | qDebug() << "no offers"; | | |||
137 | return; | 129 | return; | ||
138 | } | 130 | } | ||
139 | KPluginLoader loader(offers.first().libraryPath()); | 131 | | ||
132 | const auto offers = KPluginTrader::self()->query(s_pluginName, s_pluginName); | ||||
133 | auto item = std::find_if(offers.constBegin(), offers.constEnd(), [this](const auto &plugin) { return plugin.pluginName() == m_plugin; }); | ||||
zzag: In KWin, we tend to use constBegin/constEnd. | |||||
zzag: This isn't done, below `cend` is used. | |||||
134 | if (item != offers.cend()) { | ||||
135 | KPluginLoader loader(item->libraryPath()); | ||||
140 | m_factory = loader.factory(); | 136 | m_factory = loader.factory(); | ||
141 | qDebug() << "Factory: " << !m_factory.isNull(); | 137 | } | ||
138 | | ||||
142 | setValid(!m_factory.isNull()); | 139 | setValid(!m_factory.isNull()); | ||
143 | } | 140 | } | ||
144 | 141 | | |||
145 | bool PreviewBridge::isValid() const | 142 | bool PreviewBridge::isValid() const | ||
146 | { | 143 | { | ||
147 | return m_valid; | 144 | return m_valid; | ||
148 | } | 145 | } | ||
149 | 146 | | |||
▲ Show 20 Lines • Show All 57 Lines • ▼ Show 20 Line(s) | 203 | QDBusMessage message = QDBusMessage::createSignal(QStringLiteral("/KWin"), | |||
207 | QStringLiteral("org.kde.KWin"), | 204 | QStringLiteral("org.kde.KWin"), | ||
208 | QStringLiteral("reloadConfig")); | 205 | QStringLiteral("reloadConfig")); | ||
209 | QDBusConnection::sessionBus().send(message); | 206 | QDBusConnection::sessionBus().send(message); | ||
210 | }; | 207 | }; | ||
211 | connect(&dialog, &QDialog::accepted, this, save); | 208 | connect(&dialog, &QDialog::accepted, this, save); | ||
212 | 209 | | |||
213 | QDialogButtonBox *buttons = new QDialogButtonBox(QDialogButtonBox::Ok | | 210 | QDialogButtonBox *buttons = new QDialogButtonBox(QDialogButtonBox::Ok | | ||
214 | QDialogButtonBox::Cancel | | 211 | QDialogButtonBox::Cancel | | ||
215 | QDialogButtonBox::Apply | | | |||
216 | QDialogButtonBox::RestoreDefaults | | 212 | QDialogButtonBox::RestoreDefaults | | ||
217 | QDialogButtonBox::Reset, | 213 | QDialogButtonBox::Reset, | ||
218 | &dialog); | 214 | &dialog); | ||
219 | 215 | | |||
220 | QPushButton *apply = buttons->button(QDialogButtonBox::Apply); | | |||
221 | QPushButton *reset = buttons->button(QDialogButtonBox::Reset); | 216 | QPushButton *reset = buttons->button(QDialogButtonBox::Reset); | ||
222 | apply->setEnabled(false); | | |||
223 | reset->setEnabled(false); | 217 | reset->setEnabled(false); | ||
224 | // Here we connect our buttons with the dialog | 218 | // Here we connect our buttons with the dialog | ||
225 | connect(buttons, &QDialogButtonBox::accepted, &dialog, &QDialog::accept); | 219 | connect(buttons, &QDialogButtonBox::accepted, &dialog, &QDialog::accept); | ||
226 | connect(buttons, &QDialogButtonBox::rejected, &dialog, &QDialog::reject); | 220 | connect(buttons, &QDialogButtonBox::rejected, &dialog, &QDialog::reject); | ||
227 | connect(apply, &QPushButton::clicked, this, save); | | |||
228 | connect(reset, &QPushButton::clicked, kcm, &KCModule::load); | 221 | connect(reset, &QPushButton::clicked, kcm, &KCModule::load); | ||
229 | auto changedSignal = static_cast<void(KCModule::*)(bool)>(&KCModule::changed); | 222 | auto changedSignal = static_cast<void(KCModule::*)(bool)>(&KCModule::changed); | ||
230 | connect(kcm, changedSignal, apply, &QPushButton::setEnabled); | | |||
231 | connect(kcm, changedSignal, reset, &QPushButton::setEnabled); | 223 | connect(kcm, changedSignal, reset, &QPushButton::setEnabled); | ||
232 | connect(buttons->button(QDialogButtonBox::RestoreDefaults), &QPushButton::clicked, kcm, &KCModule::defaults); | 224 | connect(buttons->button(QDialogButtonBox::RestoreDefaults), &QPushButton::clicked, kcm, &KCModule::defaults); | ||
233 | 225 | | |||
234 | QVBoxLayout *layout = new QVBoxLayout(&dialog); | 226 | QVBoxLayout *layout = new QVBoxLayout(&dialog); | ||
235 | layout->addWidget(kcm); | 227 | layout->addWidget(kcm); | ||
236 | layout->addWidget(buttons); | 228 | layout->addWidget(buttons); | ||
237 | dialog.exec(); | 229 | dialog.exec(); | ||
238 | } | 230 | } | ||
Show All 17 Lines |
In KWin, we tend to use constBegin/constEnd.