00001 #ifndef GUISETTINGS_H 00002 #define GUISETTINGS_H 00003 00004 #include <QDialog> 00005 #include <QString> 00006 #include <QHostAddress> 00007 #include <QColor> 00008 #include <QLabel> 00009 #include <QLineEdit> 00010 #include <QPushButton> 00011 #include <QSettings> 00012 #include <QGroupBox> 00013 #include <QVBoxLayout> 00014 #include <QHBoxLayout> 00015 #include <QFileDialog> 00016 #include <QDoubleSpinBox> 00017 #include <QSettings> 00018 #include <QColorDialog> 00019 00025 class GUISettings : public QDialog 00026 { 00027 Q_OBJECT 00028 public: 00033 GUISettings(QWidget *parent); 00038 ~GUISettings(); 00039 00044 QString getNick(); 00045 00050 QHostAddress getBroadcast(); 00051 00056 unsigned int getPort(); 00057 00062 QString getFileStoragePath(); 00068 QColor getBackgroundColor(); 00069 00075 QColor getFontColor(); 00081 QColor getFontColorSystemMsg(); 00087 QColor getFontColorSystemUserMsg(); 00093 qreal getOpacity(); 00098 bool getOpacityEnabled(); 00102 void defaultSettings(); 00107 void saveToFile(); 00113 void readSettings(); 00114 00115 private: 00116 QString user_nick; 00117 QHostAddress broadcast; 00118 unsigned int port; 00119 QString file_storage_path; 00120 QColor background_color; 00121 QColor font_color; 00122 QColor font_color_system_msg; 00123 QColor font_color_system_user_msg; 00124 qreal opacity; 00125 bool opacity_enabled; 00126 QSettings *settings; 00133 QColor getColor(const QPushButton *button); 00134 00140 bool isValidIp(QString ip); 00141 00147 bool isValidNick(QString nick); 00148 00154 void printErrorMsg(const QString &errorMsg); 00155 00156 // elementy okna 00157 QLabel *nick_label; 00158 QLineEdit *nick_line_edit; 00159 00160 QLabel *broadcast_label; 00161 QLineEdit *broadcast_line_edit; 00162 00163 QLineEdit *directory_line_edit; 00164 QLabel *directory_label; 00165 QPushButton *directory_button; 00166 00167 QLabel *font_color_label; 00168 QLabel *font_system_color_msg_label; 00169 QLabel *font_system_color_user_msg_label; 00170 QLabel *background_label; 00171 QLabel *opacity_label; 00172 QPushButton *font_color_button; 00173 QPushButton *font_system_color_msg_button; 00174 QPushButton *font_system_color_user_msg_button; 00175 QPushButton *background_button; 00176 QDoubleSpinBox *opacity_box; 00177 00178 QPushButton *okButton; 00179 QPushButton *defaultButton; 00180 QPushButton *cancelButton; 00181 00182 QHBoxLayout *opticBoxLayout; 00183 QGroupBox *opticGroup; 00184 private slots: 00189 void setExistingDirectory(); 00196 void setButtonBackground(QPushButton *button, QColor col); 00202 void setDefaultSettings(); 00203 00209 void setBackgroundColor(); 00215 void setFontColor(); 00221 void setFontColorSystemMsg(); 00228 void setFontColorSystemUserMsg(); 00234 void saveSettings(); 00240 void setOpacityEnabled(bool on); 00246 void opacityChanged(double op); 00247 00248 signals: 00253 void settingsChanged(); 00254 00255 00256 00257 }; 00258 00259 00260 00261 #endif