Skip to content

Commit cc0aee4

Browse files
committedFeb 20, 2019
(*)fix preview stone picture
1 parent 4280258 commit cc0aee4

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed
 

‎src/imagehandler.cpp

+4-6
Original file line numberDiff line numberDiff line change
@@ -281,23 +281,21 @@ void ImageHandler::paint_stone_new (QImage &wi, int d, const QColor &col, double
281281

282282
void ImageHandler::paint_white_stone_picture(QImage &img, int size)
283283
{
284-
QString path = setting->readEntry("STONES_WPICTURE");
285-
QImage image(path);
284+
QImage image(m_whiteStonePicturePath);
286285
QPainter painter;
287286
painter.begin (&img);
288287
img.fill(Qt::transparent);
289-
painter.drawImage(QRect(0,0,size*9/10,size*9/10), image, image.rect());
288+
painter.drawImage(QRect(0,0,size*95/100,size*95/100), image, image.rect());
290289
painter.end ();
291290
}
292291

293292
void ImageHandler::paint_black_stone_picture(QImage &img, int size)
294293
{
295-
QString path = setting->readEntry("STONES_BPICTURE");
296-
QImage image(path);
294+
QImage image(m_blackStonePicturePath);
297295
QPainter painter;
298296
painter.begin (&img);
299297
img.fill(Qt::transparent);
300-
painter.drawImage(QRect(0,0,size*9/10,size*9/10), image, image.rect());
298+
painter.drawImage(QRect(0,0,size*95/100,size*95/100), image, image.rect());
301299
painter.end ();
302300
}
303301

‎src/imagehandler.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class ImageHandler
2424
double m_ambient { 0.2 };
2525
bool m_clamshell;
2626
int m_look;
27+
QString m_whiteStonePicturePath, m_blackStonePicturePath;
2728

2829
/* We want the appearance to stay the same across resizes, so we generate
2930
some random numbers in the constructor. */
@@ -39,7 +40,8 @@ class ImageHandler
3940

4041
void set_stone_params (double w_hard, double b_hard, double w_spec, double b_spec,
4142
double w_radius, double b_radius, int w_flat, int b_flat,
42-
double ambient, int look, bool clamshell)
43+
double ambient, int look, bool clamshell,
44+
const QString& whiteStonePicturePath, const QString& blackStonePicturePath)
4345
{
4446
m_w_hard = w_hard;
4547
m_b_hard = b_hard;
@@ -52,6 +54,8 @@ class ImageHandler
5254
m_ambient = ambient;
5355
m_clamshell = clamshell;
5456
m_look = look;
57+
m_whiteStonePicturePath = whiteStonePicturePath;
58+
m_blackStonePicturePath = blackStonePicturePath;
5559
}
5660

5761
void paint_one_stone (QImage &, bool white, int size, int idx = 0);

‎src/preferences.cpp

+6-4
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ PreferencesDialog::PreferencesDialog(QWidget* parent)
7979

8080
connect (radioButtonStones_2D, &QRadioButton::toggled, this, &PreferencesDialog::select_stone_look);
8181
connect (radioButtonStones_3D, &QRadioButton::toggled, this, &PreferencesDialog::select_stone_look);
82-
connect (radioButtonStone_picture, &QRadioButton::toggled, this, &PreferencesDialog::select_stone_look);
83-
connect (blackStonePicturePathEdit, &QLineEdit::textChanged, [=] () { update_b_stones (); });
84-
connect (whiteStonePicturePathEdit, &QLineEdit::textChanged, [=] () { update_w_stones (); });
82+
connect (radioButtonStone_picture, &QRadioButton::toggled, this, &PreferencesDialog::select_stone_look);
83+
connect (blackStonePicturePathEdit, &QLineEdit::textChanged, [=] () { update_b_stones (); });
84+
connect (whiteStonePicturePathEdit, &QLineEdit::textChanged, [=] () { update_w_stones (); });
8585

8686
connect (whiteColorButton, &QToolButton::clicked, this, &PreferencesDialog::select_white_color);
8787
connect (blackColorButton, &QToolButton::clicked, this, &PreferencesDialog::select_black_color);
@@ -297,6 +297,8 @@ void PreferencesDialog::select_black_color (bool)
297297

298298
void PreferencesDialog::update_stone_params ()
299299
{
300+
QString whiteStonePicturePath = whiteStonePicturePathEdit->text();
301+
QString blackStonePicturePath = blackStonePicturePathEdit->text();
300302
double br = 2.05 + (100 - blackRoundSlider->value ()) / 30.0;
301303
double wr = 2.05 + (100 - whiteRoundSlider->value ()) / 30.0;
302304
double bs = blackSpecSlider->value () / 100.0;
@@ -316,7 +318,7 @@ void PreferencesDialog::update_stone_params ()
316318
look = 4;
317319
blackGroupBox->setEnabled (look == 3);
318320
whiteGroupBox->setEnabled (look == 3);
319-
m_ih->set_stone_params (wh, bh, ws, bs, wr, br, wf, bf, ambient, look, clamshell);
321+
m_ih->set_stone_params (wh, bh, ws, bs, wr, br, wf, bf, ambient, look, clamshell, whiteStonePicturePath, blackStonePicturePath);
320322
}
321323

322324
void PreferencesDialog::update_w_stones ()

0 commit comments

Comments
 (0)