@@ -73,6 +73,7 @@ void CustomLayoutDialog::showEvent(QShowEvent*)
73
73
connect (ui->mainCols , SIGNAL (valueChanged (int )), this , SLOT (renderPreview ()));
74
74
connect (ui->mainRows , SIGNAL (valueChanged (int )), this , SLOT (renderPreview ()));
75
75
connect (ui->borderEnabled , SIGNAL (toggled (bool )), this , SLOT (renderPreview ()));
76
+ connect (ui->borderScreenEnabled , SIGNAL (toggled (bool )), this , SLOT (renderPreview ()));
76
77
connect (ui->borderWidth , SIGNAL (valueChanged (int )), this , SLOT (renderPreview ()));
77
78
connect (ui->borderColor , SIGNAL (colorChanged (QColor)), this , SLOT (renderPreview ()));
78
79
@@ -109,11 +110,13 @@ void CustomLayoutDialog::setCustLayout(const CustomLayout &_layout)
109
110
ui_mainPosition->setCheckedId (_layout.mainPos );
110
111
111
112
ui->borderEnabled ->setChecked (_layout.borderEnabled );
113
+ ui->borderScreenEnabled ->setChecked (_layout.borderScreenEnabled );
112
114
ui->borderWidth ->setValue (_layout.borderWidth );
113
115
ui->borderColor ->setColor (QColor (_layout.borderColor ));
114
116
115
117
on_rows_valueChanged (_layout.rows );
116
118
on_cols_valueChanged (_layout.cols );
119
+ on_borderWidth_valueChanged (_layout.borderWidth );
117
120
}
118
121
119
122
/* *
@@ -132,6 +135,7 @@ CustomLayout CustomLayoutDialog::getCustLayout() const
132
135
layout.maxCols = ui->tileCols ->upperValue ();
133
136
134
137
layout.mainEnabled = ui->mainEnabled ->isChecked ();
138
+ layout.borderScreenEnabled = ui->borderScreenEnabled ->isChecked ();
135
139
layout.mainRows = ui->mainRows ->value ();
136
140
layout.mainCols = ui->mainCols ->value ();
137
141
layout.mainPos = static_cast <UM::ALIGN>(ui_mainPosition->checkedId ());
@@ -171,6 +175,15 @@ void CustomLayoutDialog::on_cols_valueChanged(int _val)
171
175
ui->mainColsMaxLabel ->setText (QString::number (_val));
172
176
}
173
177
178
+ /* *
179
+ * @brief Update border width label
180
+ * @param _val
181
+ */
182
+ void CustomLayoutDialog::on_borderWidth_valueChanged (int _val)
183
+ {
184
+ ui->borderWidthLabel ->setText (QString::number (_val));
185
+ }
186
+
174
187
/* *
175
188
* @brief Render the preview
176
189
*/
@@ -196,19 +209,25 @@ void CustomLayoutDialog::renderPreview()
196
209
{
197
210
QRect newBlock = UM::scaledRect (block, wRatio, hRatio);
198
211
199
- if (qAbs (newBlock.left () - size.width ()) <= 2 )
212
+ if (qAbs (newBlock.left () - size.width ()) <= 3 )
200
213
{
201
- newBlock.setLeft (size.width ());
214
+ newBlock.setLeft (size.width ()- 1 );
202
215
}
203
216
204
- if (qAbs (newBlock.bottom () - size.height ()) <= 2 )
217
+ if (qAbs (newBlock.bottom () - size.height ()) <= 3 )
205
218
{
206
- newBlock.setBottom (size.height ());
219
+ newBlock.setBottom (size.height ()- 1 );
207
220
}
208
221
209
222
blocks.append (newBlock);
210
223
}
211
224
225
+ // draw background the same color of borders
226
+ if (layout.borderEnabled )
227
+ {
228
+ m_scene->addRect (QRect (QPoint (0 , 0 ), size), Qt::NoPen, QBrush (QColor (layout.borderColor )));
229
+ }
230
+
212
231
// draw blocks
213
232
int i = 0 ;
214
233
foreach (const QRect block, blocks)
@@ -235,6 +254,7 @@ void CustomLayoutDialog::renderPreview()
235
254
236
255
QPen pen;
237
256
pen.setColor (QColor (layout.borderColor ));
257
+ pen.setJoinStyle (Qt::MiterJoin);
238
258
pen.setWidth (qRound ((double ) layout.borderWidth * size.width () / monitorWidth));
239
259
240
260
foreach (const QRect block, blocks)
@@ -256,6 +276,12 @@ void CustomLayoutDialog::renderPreview()
256
276
}
257
277
}
258
278
}
279
+
280
+ if (layout.borderScreenEnabled )
281
+ {
282
+ QRect borderRect (pen.width ()/2 , pen.width ()/2 , size.width ()-pen.width ()-2 , size.height ()-pen.width ()-2 );
283
+ m_scene->addRect (borderRect, pen, Qt::NoBrush);
284
+ }
259
285
}
260
286
261
287
ui->view ->update ();
0 commit comments