Added main color configuration option, not implemented yet

Tue, 19 Mar 2013 17:21:51 +0200

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Tue, 19 Mar 2013 17:21:51 +0200
changeset 34
d99006de6261
parent 33
3e0cca764fd6
child 35
2b0569fee5ad

Added main color configuration option, not implemented yet

cfgdef.h file | annotate | diff | comparison | revisions
zz_configDialog.cpp file | annotate | diff | comparison | revisions
zz_configDialog.h file | annotate | diff | comparison | revisions
--- a/cfgdef.h	Tue Mar 19 17:09:07 2013 +0200
+++ b/cfgdef.h	Tue Mar 19 17:21:51 2013 +0200
@@ -24,4 +24,5 @@
 CFG (str, io, ldpath, "LDraw path", "")
 
 SECT (gl, GLRenderer)
-CFG (str, gl, bgcolor, "Background color", "#CCCCD9")
\ No newline at end of file
+CFG (str, gl, bgcolor, "Background color", "#CCCCD9")
+CFG (str, gl, maincolor, "Main color", "#707078")
\ No newline at end of file
--- a/zz_configDialog.cpp	Tue Mar 19 17:09:07 2013 +0200
+++ b/zz_configDialog.cpp	Tue Mar 19 17:21:51 2013 +0200
@@ -43,25 +43,31 @@
 	
 	qGLBackgroundLabel = new QLabel ("Background color:");
 	qGLBackgroundButton = new QPushButton;
-	qGLBackgroundButton->setIcon (QIcon ("icons/colorselect.png"));
-	qGLBackgroundButton->setAutoFillBackground (true);
 	setButtonBackground (qGLBackgroundButton, gl_bgcolor.value);
-	connect (qGLBackgroundButton, SIGNAL (clicked()),
+	connect (qGLBackgroundButton, SIGNAL (clicked ()),
 		this, SLOT (slot_setGLBackground ()));
 	
+	qGLForegroundLabel = new QLabel ("Foreground color:");
+	qGLForegroundButton = new QPushButton;
+	setButtonBackground (qGLForegroundButton, gl_maincolor.value);
+	connect (qGLForegroundButton, SIGNAL (clicked ()),
+		this, SLOT (slot_setGLForeground ()));
+	
 	qButtons = new QDialogButtonBox (QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
 	connect (qButtons, SIGNAL (accepted ()), this, SLOT (accept ()));
 	connect (qButtons, SIGNAL (rejected ()), this, SLOT (reject ()));
 	
 	QGridLayout* layout = new QGridLayout;
 	layout->addWidget (qLDrawPathLabel, 0, 0);
-	layout->addWidget (qLDrawPath, 0, 1);
-	layout->addWidget (qLDrawPathFindButton, 0, 2);
+	layout->addWidget (qLDrawPath, 0, 1, 1, 2);
+	layout->addWidget (qLDrawPathFindButton, 0, 3);
 	
 	layout->addWidget (qGLBackgroundLabel, 1, 0);
 	layout->addWidget (qGLBackgroundButton, 1, 1);
+	layout->addWidget (qGLForegroundLabel, 1, 2);
+	layout->addWidget (qGLForegroundButton, 1, 3);
 	
-	layout->addWidget (qButtons, 2, 1, 1, 2);
+	layout->addWidget (qButtons, 2, 2, 1, 2);
 	setLayout (layout);
 	
 	setWindowTitle (APPNAME_DISPLAY " - editing settings");
@@ -89,23 +95,33 @@
 // =============================================================================
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 // =============================================================================
-void ConfigDialog::slot_setGLBackground () {
-	QColorDialog dlg (QColor (gl_bgcolor.value.chars()));
+void ConfigDialog::pickColor (strconfig& cfg, QPushButton* qButton) {
+	QColorDialog dlg (QColor (cfg.value.chars()));
 	dlg.setWindowIcon (QIcon ("icons/colorselect.png"));
 	
 	if (dlg.exec ()) {
 		uchar r = dlg.currentColor ().red (),
 			g = dlg.currentColor ().green (),
 			b = dlg.currentColor ().blue ();
-		gl_bgcolor.value.format ("#%.2X%.2X%.2X", r, g, b);
-		setButtonBackground (qGLBackgroundButton, gl_bgcolor.value);
+		cfg.value.format ("#%.2X%.2X%.2X", r, g, b);
+		setButtonBackground (qButton, cfg.value);
 	}
 }
 
+void ConfigDialog::slot_setGLBackground () {
+	pickColor (gl_bgcolor, qGLBackgroundButton);
+}
+
+void ConfigDialog::slot_setGLForeground () {
+	pickColor (gl_maincolor, qGLForegroundButton);
+}
+
 // =============================================================================
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 // =============================================================================
 void ConfigDialog::setButtonBackground (QPushButton* qButton, str zValue) {
+	qButton->setIcon (QIcon ("icons/colorselect.png"));
+	qButton->setAutoFillBackground (true);
 	qButton->setStyleSheet (
 		str::mkfmt ("background-color: %s", zValue.chars()).chars()
 	);
--- a/zz_configDialog.h	Tue Mar 19 17:09:07 2013 +0200
+++ b/zz_configDialog.h	Tue Mar 19 17:21:51 2013 +0200
@@ -27,10 +27,10 @@
 	Q_OBJECT
 	
 public:
-	QLabel* qLDrawPathLabel, *qGLBackgroundLabel;
+	QLabel* qLDrawPathLabel, *qGLBackgroundLabel, *qGLForegroundLabel;
 	QLineEdit* qLDrawPath;
 	QPushButton* qLDrawPathFindButton;
-	QPushButton* qGLBackgroundButton;
+	QPushButton* qGLBackgroundButton, *qGLForegroundButton;
 	
 	QDialogButtonBox* qButtons;
 	
@@ -40,8 +40,10 @@
 	
 private:
     void setButtonBackground (QPushButton* qButton, str zValue);
+    void pickColor (strconfig& cfg, QPushButton* qButton);
 	
 private slots:
 	void slot_findLDrawPath ();
 	void slot_setGLBackground ();
+	void slot_setGLForeground ();
 };
\ No newline at end of file

mercurial