00001 #include "settingsdlg.h"
00002 #include "advsettingsdlg.h"
00003 #include "selectremotedlg.h"
00004 #include "aboutdlg.h"
00005
00006 #include <QHBoxLayout>
00007 #include <QVBoxLayout>
00008 #include <QWidget>
00009 #include <QDialog>
00010 #include <QPushButton>
00011 #include <QSettings>
00012 #include <QLabel>
00013
00014 SettingsDlg::SettingsDlg(QWidget *parent)
00015 : QDialog(parent)
00016 {
00017 layout = new QVBoxLayout(this);
00018 btnLayout = new QHBoxLayout(this);
00019 remoteNameLayout = new QHBoxLayout(this);
00020
00021 QSettings settings(this);
00022 advSettingsBtn = new QPushButton(tr("Advanced"), this);
00023 selectRemoteBtn = new QPushButton(tr("Select remote"), this);
00024 aboutBtn = new QPushButton(tr("About"), this);
00025
00026 btnLayout->addWidget(advSettingsBtn);
00027 btnLayout->addWidget(selectRemoteBtn);
00028 btnLayout->addWidget(aboutBtn);
00029
00030 connect(advSettingsBtn, SIGNAL(clicked()),
00031 this, SLOT(showAdvSettingsDlg()));
00032 connect(selectRemoteBtn, SIGNAL(clicked()),
00033 this, SLOT(showSelectRemoteDlg()));
00034 connect(aboutBtn, SIGNAL(clicked()),
00035 this, SLOT(showAboutDlg()));
00036
00037 remoteNameLabel = new QLabel(
00038 settings.value("remoteName",
00039 tr("<no remote selected>")).toString(), this);
00040 remoteNameLayout->addWidget(new QLabel(tr("Remote name: "), this));
00041 remoteNameLayout->addWidget(remoteNameLabel);
00042
00043 layout->addLayout(remoteNameLayout);
00044 layout->addLayout(btnLayout);
00045 this->setLayout(layout);
00046
00047 updateRemoteName();
00048 }
00049
00050 SettingsDlg::~SettingsDlg()
00051 {
00052 delete advSettingsBtn;
00053 delete selectRemoteBtn;
00054 delete aboutBtn;
00055 delete remoteNameLabel;
00056 delete remoteNameLayout;
00057 delete btnLayout;
00058 delete layout;
00059 }
00060
00061 void SettingsDlg::showAdvSettingsDlg()
00062 {
00063 AdvSettingsDlg dlg(this);
00064 dlg.exec();
00065 }
00066
00067 void SettingsDlg::showSelectRemoteDlg()
00068 {
00069 SelectRemoteDlg dlg(this);
00070 connect(&dlg, SIGNAL(remoteDownloaded()),
00071 this, SLOT(updateRemoteName()));
00072 dlg.exec();
00073 }
00074
00075 void SettingsDlg::showAboutDlg()
00076 {
00077 AboutDlg dlg(this);
00078 dlg.exec();
00079 }
00080
00081 void SettingsDlg::updateRemoteName()
00082 {
00083 QSettings settings(this);
00084 remoteNameLabel->setText(settings.value("remoteName",
00085 tr("Select remote")).toString());
00086 }
00087
00088