Codebase list dtkwidget / 32952ef
New upstream version 2.0.9.2 Yanhao Mo 5 years ago
4 changed file(s) with 81 addition(s) and 50 deletion(s). Raw diff Collapse all Expand all
0 <a name="2.0.9.2"></a>
1 ## 2.0.9.2 (2018-08-07)
2
3
4 #### Features
5
6 * use new interface for DPlatformWindowHandle::enableDxcbForWindow ([ab03a058](https://github.com/linuxdeepin/dtkwidget/commit/ab03a058910a3258775bd8b40dc3bf43cf014cc8))
7
8
9
010 <a name="2.0.9.1"></a>
111 ## 2.0.9.1 (2018-07-25)
212
456456
457457 bool DApplication::isDXcbPlatform()
458458 {
459 return qApp && (qApp->platformName() == DXCB_PLUGIN_KEY || qApp->property(DXCB_PLUGIN_SYMBOLIC_PROPERTY).toBool());
459 if (!qApp)
460 return false;
461
462 static bool _is_dxcb = qApp->platformName() == DXCB_PLUGIN_KEY || qApp->property(DXCB_PLUGIN_SYMBOLIC_PROPERTY).toBool();
463
464 return _is_dxcb;
460465 }
461466
462467 int DApplication::buildDtkVersion()
5454 DEFINE_CONST_CHAR(setWindowProperty);
5555 DEFINE_CONST_CHAR(pluginVersion);
5656 DEFINE_CONST_CHAR(disableOverrideCursor);
57 DEFINE_CONST_CHAR(enableDxcb);
58 DEFINE_CONST_CHAR(isEnableDxcb);
5759
5860 static void setWindowProperty(QWindow *window, const char *name, const QVariant &value)
5961 {
110112 return reinterpret_cast<QString(*)()>(pv)();
111113 }
112114
113 void DPlatformWindowHandle::enableDXcbForWindow(QWidget *widget)
114 {
115 if (!DApplication::isDXcbPlatform())
116 return;
117
115 static QWindow *ensureWindowHandle(QWidget *widget)
116 {
118117 QWidget *window = widget->window();
119118 QWindow *handle = window->windowHandle();
120119
126125 window->setAttribute(Qt::WA_NativeWindow, false);
127126
128127 // dxcb version >= 1.1.6
129 if (!pluginVersion().isEmpty()) {
128 if (!DPlatformWindowHandle::pluginVersion().isEmpty()) {
130129 /// TODO: Avoid call parentWidget()->enforceNativeChildren().
131130 qApp->setAttribute(Qt::AA_DontCreateNativeWidgetSiblings, save_flag);
132131 }
133
134 Q_ASSERT_X(handle, "DPlatformWindowHandler:", "widget window handle is NULL.");
135
136 if (Q_UNLIKELY(!handle))
137 return;
138 }
139
140 if (handle->property(_useDxcb).toBool())
141 return;
142
143 Q_ASSERT_X(!handle->handle(), "DPlatformWindowHandler:",
144 "Must be called before window handle has been created. See also QWidget::windowHandle()");
145
146 handle->setProperty(_useDxcb, true);
147 }
148
149 void DPlatformWindowHandle::enableDXcbForWindow(QWindow *window)
132 }
133
134 return handle;
135 }
136
137 void DPlatformWindowHandle::enableDXcbForWindow(QWidget *widget)
150138 {
151139 if (!DApplication::isDXcbPlatform())
152140 return;
153141
154 if (window->handle()) {
142 QWindow *handle = ensureWindowHandle(widget);
143
144 enableDXcbForWindow(handle);
145 }
146
147 void DPlatformWindowHandle::enableDXcbForWindow(QWindow *window)
148 {
149 if (!DApplication::isDXcbPlatform())
150 return;
151
152 QFunctionPointer enable_dxcb = nullptr;
153
154 #if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)
155 enable_dxcb = qApp->platformFunction(_enableDxcb);
156 #endif
157
158 if (enable_dxcb) {
159 (*reinterpret_cast<bool(*)(QWindow*)>(enable_dxcb))(window);
160 } else if (window->handle()) {
155161 Q_ASSERT_X(window->property(_useDxcb).toBool(), "DPlatformWindowHandler:",
156162 "Must be called before window handle has been created. See also QWindow::handle()");
157163 } else {
161167
162168 void DPlatformWindowHandle::enableDXcbForWindow(QWidget *widget, bool redirectContent)
163169 {
164 enableDXcbForWindow(widget);
165
166 if (isEnabledDXcb(widget)) {
167 widget->windowHandle()->setProperty(_redirectContent, redirectContent);
168 }
170 enableDXcbForWindow(ensureWindowHandle(widget), redirectContent);
169171 }
170172
171173 void DPlatformWindowHandle::enableDXcbForWindow(QWindow *window, bool redirectContent)
172174 {
175 window->setProperty(_redirectContent, redirectContent);
176
173177 enableDXcbForWindow(window);
174
175 if (isEnabledDXcb(window)) {
176 window->setProperty(_redirectContent, redirectContent);
177 }
178178 }
179179
180180 bool DPlatformWindowHandle::isEnabledDXcb(const QWidget *widget)
181181 {
182 return widget->windowHandle() && widget->windowHandle()->property(_useDxcb).toBool();
182 if (QWindow *handle = widget->windowHandle()) {
183 return isEnabledDXcb(handle);
184 }
185
186 return false;
183187 }
184188
185189 bool DPlatformWindowHandle::isEnabledDXcb(const QWindow *window)
186190 {
191 QFunctionPointer is_enable_dxcb = nullptr;
192
193 #if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)
194 is_enable_dxcb = qApp->platformFunction(_isEnableDxcb);
195 #endif
196
197 if (is_enable_dxcb) {
198 return (*reinterpret_cast<bool(*)(const QWindow*)>(is_enable_dxcb))(window);
199 }
200
187201 return window->property(_useDxcb).toBool();
188202 }
189203
164164 auto value = option->data("text").toString();
165165 auto trName = DWIDGET_NAMESPACE::tr(translateContext, value.toStdString().c_str());
166166
167 auto checkboxFrame = new QWidget;
168 auto checkboxLayout = new QHBoxLayout(checkboxFrame);
169 checkboxLayout->setSpacing(0);
170 checkboxLayout->setContentsMargins(0, 0, 0, 0);
171 auto rightWidget = new QCheckBox("");
172 auto checkboxLabel = new QLabel(trName);
173 checkboxLabel->setWordWrap(true);
174 checkboxLabel->setMinimumWidth(320);
175 checkboxLayout->addWidget(rightWidget);
176 checkboxLayout->addSpacing(5);
177 checkboxLayout->addWidget(checkboxLabel);
178 checkboxLayout->addStretch();
179
167 // auto checkboxFrame = new QWidget;
168 // auto checkboxLayout = new QHBoxLayout(checkboxFrame);
169 // checkboxLayout->setSpacing(0);
170 // checkboxLayout->setContentsMargins(0, 0, 0, 0);
171 auto rightWidget = new QCheckBox(trName);
172 // auto checkboxLabel = new QLabel(trName);
173 // checkboxLabel->setWordWrap(true);
174 // checkboxLabel->setMinimumWidth(320);
175 // checkboxLayout->addWidget(rightWidget);
176 // checkboxLayout->addSpacing(5);
177 // checkboxLayout->addWidget(checkboxLabel);
178 // checkboxLayout->addStretch();
179
180 rightWidget->setMinimumHeight(30);
180181 rightWidget->setObjectName("OptionCheckbox");
181182 rightWidget->setChecked(option->value().toBool());
182183
183 auto optionWidget = DSettingsWidgetFactory::createTwoColumWidget(translateContext, option, checkboxFrame);
184 // auto optionWidget = DSettingsWidgetFactory::createTwoColumWidget(translateContext, option, checkboxFrame);
184185
185186 option->connect(rightWidget, &QCheckBox::stateChanged,
186187 option, [ = ](int status) {
192193 rightWidget->update();
193194 });
194195
195 return optionWidget;
196 return rightWidget;
197 // return optionWidget;
196198 }
197199
198200 QWidget *createLineEditOptionHandle(QObject *opt)