1 /* Sound Player
2 
3    Copyright (C) 1997 by Jung woo-jae */
4 
5 #ifdef HAVE_CONFIG_H
6 #include "config.h"
7 #endif
8 
9 #include <stdio.h>
10 
11 #include "xsplay.h"
12 #include "optionpanel.h"
13 
14 OptionPanel::OptionPanel(QWidget *parent,char *name)
15   : QDialog(parent,name,TRUE)
16 {
17   setCaption("Options");
18   move(mainwidget_x()+10,mainwidget_y()+10);
19   resize(200,190);
20   setFixedSize(200,190);
21 
22   shuffle_checkbox=new QCheckBox("Shuffle",this);
23   shuffle_checkbox->move(10,10);
24   shuffle_checkbox->setChecked(splay_shuffleflag);
25 
26   half_checkbox=new QCheckBox("Half freq",this);
27   half_checkbox->move(10,30);
28   half_checkbox->setChecked(splay_downfrequency);
29 
30   forcetomono_checkbox=new QCheckBox("Force to mono",this);
31   forcetomono_checkbox->move(10,50);
32   forcetomono_checkbox->setChecked(splay_forcetomonoflag);
33 
34   repeat_checkbox=new QCheckBox("Repeat",this);
35   repeat_checkbox->move(10,70);
36   repeat_checkbox->setChecked(splay_repeatflag);
37 
38   thread_label=new QLabel(this);
39   thread_label->setGeometry(10,100,100,25);
40 
41   thread_num=splay_threadnum;
42   thread_slider=new QSlider(0,999,120,thread_num,QSlider::Horizontal,this);
43   thread_slider->setTickmarks(QSlider::Below);
44   thread_slider->setGeometry(10,120,180,20);
45   connect(thread_slider,SIGNAL(valueChanged(int)),
46 	  this,SLOT(setthread(int)));
47   setthread(thread_num);
48 
49   ok_button=new QPushButton("Ok",this);
50   ok_button->setGeometry(10,height()-40,50,25);
51   connect(ok_button,SIGNAL(clicked()),SLOT(SelectOk()));
52 
53   cancel_button=new QPushButton("Cancel",this);
54   cancel_button->setGeometry(width()-50-10,height()-40,50,25);
55   connect(cancel_button,SIGNAL(clicked()),SLOT(SelectCancel()));
56 }
57 
58 OptionPanel::~OptionPanel()
59 {
60   delete shuffle_checkbox;
61   delete forcetomono_checkbox;
62 
63   delete thread_label;
64   delete thread_slider;
65 
66   delete ok_button;
67   delete cancel_button;
68 }
69 
70 void OptionPanel::SelectOk()
71 {
72   splay_shuffleflag    =shuffle_checkbox->isChecked();
73   splay_forcetomonoflag=forcetomono_checkbox->isChecked();
74   splay_repeatflag     =repeat_checkbox->isChecked();
75   splay_threadnum      =thread_num;
76   splay_downfrequency  =half_checkbox->isChecked();
77 
78   accept();
79 }
80 
81 void OptionPanel::SelectCancel()
82 {
83   reject();
84 }
85 
86 void OptionPanel::setthread(int value)
87 {
88   thread_num=value;
89   sprintf(thread_string,"Buffer: %3d\n",value);
90   thread_label->setText(thread_string);
91 }
92 
93 void RunOptionPanel(QWidget *widget)
94 {
95   OptionPanel op(widget,"Option Panel");
96   op.exec();
97 }
98