Exemplo n.º 1
0
RetrieveUrlsDialog::RetrieveUrlsDialog(QWidget *parent) :
    QDialog(parent),
    m_serviceModel(new ServiceSelectionModel(this)),
    m_scrollArea(new QScrollArea(this)),
    m_container(new QWidget(m_scrollArea)),
    m_edit(new QTextEdit(m_container)),
    m_serviceSelector(new ValueSelector(tr("Service"), m_container)),
    m_button(new QPushButton(QIcon::fromTheme("general_add"), tr("Add"), m_container)),
    m_progressBar(new QProgressBar(m_container)),
    m_statusLabel(new QLabel(m_container)),
    m_buttonBox(new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Vertical, this)),
    m_vbox(new QVBoxLayout(m_container)),
    m_layout(new QHBoxLayout(this))
{
    setWindowTitle(tr("Retrieve URLs"));
    setMinimumHeight(360);

    m_scrollArea->setWidget(m_container);
    m_scrollArea->setWidgetResizable(true);
    
    m_edit->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding);
    m_edit->setFocus(Qt::OtherFocusReason);
    
    m_serviceSelector->setModel(m_serviceModel);
    m_serviceSelector->setValue(Settings::defaultServicePlugin());
    
    m_button->setEnabled(false);

    m_progressBar->setRange(0, 100);
    m_progressBar->setValue(UrlRetrievalModel::instance()->progress());
    
    m_vbox->addWidget(m_edit);
    m_vbox->addWidget(m_serviceSelector);
    m_vbox->addWidget(m_button);
    m_vbox->addWidget(m_progressBar);
    m_vbox->addWidget(m_statusLabel);
    m_vbox->addWidget(m_buttonBox);
    m_vbox->setContentsMargins(0, 0, 0, 0);

    m_layout->addWidget(m_scrollArea);
    m_layout->addWidget(m_buttonBox);

    connect(UrlRetrievalModel::instance(), SIGNAL(progressChanged(int)), m_progressBar, SLOT(setValue(int)));
    connect(UrlRetrievalModel::instance(), SIGNAL(statusChanged(UrlRetrievalModel::Status)),
            this, SLOT(onStatusChanged(UrlRetrievalModel::Status)));
    connect(m_edit, SIGNAL(textChanged()), this, SLOT(onTextChanged()));
    connect(m_button, SIGNAL(clicked()), this, SLOT(addUrls()));
    connect(m_buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
    connect(m_buttonBox, SIGNAL(rejected()), this, SLOT(reject()));    

    onStatusChanged(UrlRetrievalModel::instance()->status());
}
Exemplo n.º 2
0
DownloadRequestDialog::DownloadRequestDialog(QWidget *parent) :
    QDialog(parent),
    m_view(new QTreeView(this)),
    m_progressBar(new QProgressBar(this)),
    m_statusLabel(new QLabel(this)),
    m_buttonBox(new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this)),
    m_layout(new QVBoxLayout(this))
{
    setWindowTitle(tr("Download requests"));

    m_view->setModel(DownloadRequestModel::instance());
    m_view->setAlternatingRowColors(true);
    m_view->setSelectionBehavior(QTreeView::SelectRows);
    m_view->setContextMenuPolicy(Qt::CustomContextMenu);
    m_view->setEditTriggers(QTreeView::NoEditTriggers);
    m_view->setItemsExpandable(false);
    m_view->setUniformRowHeights(true);
    m_view->setAllColumnsShowFocus(true);
    m_view->setRootIsDecorated(false);
    m_view->header()->setStretchLastSection(false);
    m_view->header()->resizeSection(1, 32);
#if QT_VERSION >= 0x050000
    m_view->header()->setSectionResizeMode(0, QHeaderView::Stretch);
#else
    m_view->header()->setResizeMode(0, QHeaderView::Stretch);
#endif

    m_progressBar->setRange(0, 100);
    m_progressBar->setValue(DownloadRequestModel::instance()->progress());

    m_layout->addWidget(m_view);
    m_layout->addWidget(m_progressBar);
    m_layout->addWidget(m_statusLabel);
    m_layout->addWidget(m_buttonBox);

    connect(DownloadRequestModel::instance(), SIGNAL(progressChanged(int)), m_progressBar, SLOT(setValue(int)));
    connect(DownloadRequestModel::instance(), SIGNAL(captchaRequest(int, QByteArray)),
            this, SLOT(showCaptchaDialog(int, QByteArray)));
    connect(DownloadRequestModel::instance(), SIGNAL(captchaTimeoutChanged(int)), this, SLOT(updateStatusLabel()));
    connect(DownloadRequestModel::instance(), SIGNAL(requestedSettingsTimeoutChanged(int)),
            this, SLOT(updateStatusLabel()));
    connect(DownloadRequestModel::instance(), SIGNAL(settingsRequest(QString, QVariantList)),
            this, SLOT(showPluginSettingsDialog(QString, QVariantList)));
    connect(DownloadRequestModel::instance(), SIGNAL(statusChanged(DownloadRequestModel::Status)),
            this, SLOT(onStatusChanged(DownloadRequestModel::Status)));
    connect(DownloadRequestModel::instance(), SIGNAL(waitTimeChanged(int)), this, SLOT(updateStatusLabel()));
    connect(m_view, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showContextMenu(QPoint)));
    connect(m_buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
    connect(m_buttonBox, SIGNAL(rejected()), this, SLOT(reject()));

    onStatusChanged(DownloadRequestModel::instance()->status());
}
void
CServerTaskBarReceiver::updateStatus(CServer* server, const CString& errorMsg)
{
	{
		// update our status
		m_errorMessage = errorMsg;
		if (server == NULL) {
			if (m_errorMessage.empty()) {
				m_state = kNotRunning;
			}
			else {
				m_state = kNotWorking;
			}
		}
		else {
			m_clients.clear();
			server->getClients(m_clients);
			if (m_clients.size() <= 1) {
				m_state = kNotConnected;
			}
			else {
				m_state = kConnected;
			}
		}

		// let subclasses have a go
		onStatusChanged(server);
	}

	// tell task bar
	ARCH->updateReceiver(this);
}
MToolFlashlight::MToolFlashlight(QGraphicsItem *parent):
    MWidget(parent),
    poskey(new GConfItem("/apps/system-ui-extensions/tools/flashlight/index")),
    statuskey(new GConfItem("/apps/system-ui-extensions/tools/flashlight/working"))
{
    setMaximumSize(64,64);
    setMinimumSize(64,64);

    icon_flash_on =  QImage("/usr/share/themes/blanco/meegotouch/icons/icon-extensions-flashlight-on.png");
    icon_flash_off = QImage("/usr/share/themes/blanco/meegotouch/icons/icon-extensions-flashlight-off.png");

    m_toggleicon = new MImageWidget(&icon_flash_off, this);
    m_toggleicon->setAspectRatioMode(Qt::KeepAspectRatio);
    m_toggleicon->setMaximumSize(64,64);
    m_toggleicon->setMinimumSize(64,64);

    fd = open("/dev/v4l-subdev10", O_RDWR | O_NONBLOCK, 0);

    flash_active = false;

    MFeedback* feedback1 = new MFeedback("priority2_static_press", this);
    connect(this, SIGNAL(pressed()), feedback1, SLOT(play()));
    MFeedback* feedback2 = new MFeedback("priority2_static_release", this);
    connect(this, SIGNAL(released()), feedback2, SLOT(play()));

    connect(poskey,
            SIGNAL(valueChanged()),
            SLOT(onIndexChanged()));
    connect(statuskey,
            SIGNAL(valueChanged()),
            SLOT(onStatusChanged()));
    index = poskey->value().toInt();
    status = statuskey->value().toBool();
}
Exemplo n.º 5
0
void
ClientTaskBarReceiver::updateStatus(Client* client, const String& errorMsg)
{
    {
        // update our status
        m_errorMessage = errorMsg;
        if (client == NULL) {
            if (m_errorMessage.empty()) {
                m_state = kNotRunning;
            }
            else {
                m_state = kNotWorking;
            }
        }
        else {
            m_server = client->getServerAddress().getHostname();

            if (client->isConnected()) {
                m_state = kConnected;
            }
            else if (client->isConnecting()) {
                m_state = kConnecting;
            }
            else {
                m_state = kNotConnected;
            }
        }

        // let subclasses have a go
        onStatusChanged(client);
    }

    // tell task bar
    ARCH->updateReceiver(this);
}
Exemplo n.º 6
0
void
PortableTaskBarReceiver::updateStatus(INode* node, const String& errorMsg)
{
    {
        // update our status
        m_errorMessage = errorMsg;
        if (node == NULL) {
            if (m_errorMessage.empty()) {
                m_state = kNotRunning;
            }
            else {
                m_state = kNotWorking;
            }
        }
        else {
            m_state = kNotConnected;
        }

        // let subclasses have a go
        onStatusChanged(node);
    }

    // tell task bar
    ARCH->updateReceiver(this);
}
Exemplo n.º 7
0
void SimpleList::do_connections()
{
    connect(ui->tableViewFM, SIGNAL(clicked(QModelIndex)),
            this,          SLOT(onRowClicked(QModelIndex)));

    connect(ui->tableViewFM, SIGNAL(doubleClicked(QModelIndex)),
            this,          SLOT(onOpenItem(QModelIndex)));

    connect(m_model, SIGNAL(pathChanged(QString)),
            this,    SLOT(onPathChanged(QString)));

    connect(ui->toolButtonUp,     SIGNAL(clicked()),    m_model, SLOT(cdUp()));
    connect(ui->toolButtonBack,   SIGNAL(clicked()),    m_model, SLOT(goBack()));
    connect(ui->actionCopy,       SIGNAL(triggered()),  m_model, SLOT(copySelection()));
    connect(ui->actionCut,        SIGNAL(triggered()),  m_model, SLOT(cutSelection()));
    connect(ui->actionDelete,     SIGNAL(triggered()),  m_model, SLOT(removeSelection()));
    connect(ui->actionPaste,      SIGNAL(triggered()),  m_model, SLOT(paste()));
    connect(ui->actionMoveToTrash,SIGNAL(triggered()),  m_model, SLOT(moveSelectionToTrash()));
    connect(ui->actionTerminnal,  SIGNAL(triggered()),  this,    SLOT(onOpenTerminal()));

    connect(ui->actionRestoreFromTrash, SIGNAL(triggered()),
            m_model,              SLOT(restoreSelectionFromTrash()));

    connect(ui->checkBoxShowDirs,     SIGNAL(clicked(bool)), m_model, SLOT(setShowDirectories(bool)));
    connect(ui->checkBoxShowHidden,   SIGNAL(clicked(bool)), m_model, SLOT(setShowHiddenFiles(bool)));
    connect(ui->checkBoxExtFsWatcher, SIGNAL(clicked(bool)), m_model, SLOT(setEnabledExternalFSWatcher(bool)));
    connect(ui->checkBoxShowMediaInfo, SIGNAL(clicked(bool)),m_model, SLOT(setReadsMediaMetadata(bool)));
    connect(ui->checkBoxMultiSelection,SIGNAL(clicked(bool)), m_selection, SLOT(setMultiSelection(bool)));

    connect(ui->comboBoxPath,     SIGNAL(activated(int)),
            this, SLOT(onPathChoosedFromList(int)));

    connect(ui->comboBoxPath->lineEdit(),    SIGNAL(returnPressed()),
            this,    SLOT(onPathComboEdited()));

    connect(ui->tableViewFM->horizontalHeader(), SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)),
            this,                              SLOT(onSetSort(int,Qt::SortOrder)));

    connect(m_model, SIGNAL(progress(int,int,int)),
            this,    SLOT(onProgress(int,int,int)));

    connect(m_model, SIGNAL(clipboardChanged()),
            this,    SLOT(onClipboardChanged()));

    connect(m_model, SIGNAL(error(QString,QString)),
            this,    SLOT(onError(QString,QString)));

    connect(m_model, SIGNAL(awaitingResultsChanged()),
            this,    SLOT(onStatusChanged()));

    connect(m_selection,   SIGNAL(selectionChanged(int)),
            this,          SLOT(onSelectionChanged(int)));

    connect(ui->listViewPlaces,  SIGNAL(clicked(QModelIndex)),
            this,                SLOT(onPlacesClicked(QModelIndex)));

    connect(m_pbar,  SIGNAL(cancel()), this, SLOT(onCancelAction()));
}
Exemplo n.º 8
0
void DownloadListModel::addDownload(QUrl url, QString outFileName) {
    AbstractDownload *d = createDownload(url);
    beginInsertRows(QModelIndex(), 0, 0);
    downloads.prepend(d);
    d->downloadToFile(outFileName);
    endInsertRows();
    connect(d, SIGNAL(progress()), this, SLOT(onProgress()));
    connect(d, SIGNAL(statusChanged()), this, SLOT(onStatusChanged()));
}
Exemplo n.º 9
0
/*----------------------------------------------------------------------------*/
void MeasureWindow::onOptions()
{
  OptionsDialog dlg;
  if(dlg.exec() == QDialog::Accepted)
  {
    ui->retranslateUi(this);
    disconnect(database, SIGNAL(dbError(QString)));
    connect(database, SIGNAL(dbError(QString)), this, SLOT(onDatabaseError()));
    onProfileChanged(ui->profileCombo->currentIndex());
    onStatusChanged(controller->status());
  }
}
Exemplo n.º 10
0
BirthdayUpdater::BirthdayUpdater(Account *account, InfoRequestFactory *factory, QObject *parent) :
	QObject(parent),
	m_account(account),
	m_factory(factory),
	m_updateFails(0)
{
	m_factory = account->infoRequestFactory();
	m_updateTimer.setInterval(30000);
	connect(&m_updateTimer, SIGNAL(timeout()), SLOT(onUpdateNext()));
	connect(account, SIGNAL(statusChanged(qutim_sdk_0_3::Status,qutim_sdk_0_3::Status)),
			SLOT(onStatusChanged(qutim_sdk_0_3::Status,qutim_sdk_0_3::Status)));
}
Exemplo n.º 11
0
ProxyAccount::ProxyAccount(Account *account) :
    Account(account->id(), account->protocol()), m_account(account)
{
    connect(account, SIGNAL(statusChanged(qutim_sdk_0_3::Status,qutim_sdk_0_3::Status)),
            SLOT(onStatusChanged(qutim_sdk_0_3::Status,qutim_sdk_0_3::Status)));
    connect(account, SIGNAL(contactCreated(qutim_sdk_0_3::Contact*)),
            SIGNAL(contactCreated(qutim_sdk_0_3::Contact*)));
    connect(account, SIGNAL(conferenceCreated(qutim_sdk_0_3::Conference*)),
            SIGNAL(conferenceCreated(qutim_sdk_0_3::Conference*)));
    connect(account, SIGNAL(nameChanged(QString,QString)),
            SIGNAL(nameChanged(QString,QString)));

    setStatus(m_account->status());
}
Exemplo n.º 12
0
void Application::status( status::type st ) {
	//	Try change status	
	if (_status != st) {
		//	Notify status changed
		onStatusChanged( _status, st );
		
		//	Change status
		_status = st;

		//	Notificate ctrl that status was changed
		if (_extension) {
			ctrl()->onApplicationChanged( this );
		}
	}
}
Exemplo n.º 13
0
	void MprisPlayer::onPropertiesChanged(const QDBusMessage &msg)
	{
		QDBusArgument arg = msg.arguments().at(1).value<QDBusArgument>();
		QVariantMap map = qdbus_cast<QVariantMap>(arg);
		QVariantMap::const_iterator it = map.find(QLatin1String("Metadata"));
		if (it != map.end()) {
			arg = it.value().value<QDBusArgument>();
			onTrackChanged(qdbus_cast<QVariantMap>(arg));
		}
		it = map.find(QLatin1String("PlaybackStatus"));
		if (it != map.end()) {
			DBusMprisPlayerStatus status;
			status.Play = it.value().toString() == QLatin1String("Playing") ? 0 : 1;
			onStatusChanged(status);
		}
	}
Exemplo n.º 14
0
View::View(const QCommandLineParser &parser, QWindow *parent)
    : QQuickView(parent),
    m_settingsRoot(0)
{
    Plasma::Theme theme(this);
    theme.setUseGlobalSettings(true);

    const QString package = parser.value("layout");
    const QString module = parser.value("module");
    const QString formFactor = parser.value("formfactor");

    setResizeMode(QQuickView::SizeRootObjectToView);
    QQuickWindow::setDefaultAlphaBuffer(true);

    setIcon(QIcon::fromTheme("preferences-desktop"));
    setTitle(i18n("Active Settings"));

    KDeclarative::KDeclarative kdeclarative;
    kdeclarative.setDeclarativeEngine(engine());
    kdeclarative.initialize();
    //binds things like kconfig and icons
    kdeclarative.setupBindings();

    m_package = Plasma::PluginLoader::self()->loadPackage("Plasma/Generic");
    if (!package.isEmpty()) {
        m_package.setPath(package);
    } else {
        m_package.setPath("org.kde.active.settings");
    }
    setIcon(QIcon::fromTheme(m_package.metadata().icon()));
    setTitle(m_package.metadata().name());

    rootContext()->setContextProperty("startModule", module);
    rootContext()->setContextProperty("startFormFactor", formFactor);

    const QString qmlFile = m_package.filePath("mainscript");
    //qDebug() << "mainscript: " << QUrl::fromLocalFile(m_package.filePath("mainscript"));
    setSource(QUrl::fromLocalFile(m_package.filePath("mainscript")));
    show();

    onStatusChanged(status());

    connect(this, &QQuickView::statusChanged,
            this, &View::onStatusChanged);
}
Exemplo n.º 15
0
MToolReboot::MToolReboot(QGraphicsItem *parent):
    MWidget(parent),
    poskey(new GConfItem("/apps/system-ui-extensions/tools/reboot/index")),
    statuskey(new GConfItem("/apps/system-ui-extensions/tools/reboot/working"))
{
    setMaximumSize(64,64);
    setMinimumSize(64,64);

    icon_power_unloaded =  QImage("/usr/share/themes/blanco/meegotouch/icons/c.png");
    icon_power =  QImage("/usr/share/themes/blanco/meegotouch/icons/icon-extensions-power.png");

    m_toggleicon = new MImageWidget(&icon_power_unloaded, this);
    m_toggleicon->setAspectRatioMode(Qt::KeepAspectRatio);
    m_toggleicon->setMaximumSize(64,64);
    m_toggleicon->setMinimumSize(64,64);

    MFeedback* feedback1 = new MFeedback("priority2_static_press", this);
    connect(this, SIGNAL(pressed()), feedback1, SLOT(play()));
    MFeedback* feedback2 = new MFeedback("priority2_static_release", this);
    connect(this, SIGNAL(released()), feedback2, SLOT(play()));

    m_timer = new QTimer(this);
    m_timer->setInterval(500);
    connect(m_timer,
            SIGNAL(timeout()),
            SLOT(onTimer()));

    service = new GConfItem("/apps/system-ui-extensions/daemon/service");
//    connect(service,
//            SIGNAL(valueChanged()),
//            SLOT(onGConf()));
    onGConf();
    connect(poskey,
            SIGNAL(valueChanged()),
            SLOT(onIndexChanged()));
    connect(statuskey,
            SIGNAL(valueChanged()),
            SLOT(onStatusChanged()));
    index = poskey->value().toInt();
    status = statuskey->value().toBool();
}
Exemplo n.º 16
0
MToolCellular::MToolCellular(QGraphicsItem *parent):
    MWidget(parent),
    m_radio(new Cellular::RadioAccess(this)),
    poskey(new GConfItem("/apps/system-ui-extensions/tools/cellular/index")),
    statuskey(new GConfItem("/apps/system-ui-extensions/tools/cellular/working"))
{
    setMaximumSize(64,64);
    setMinimumSize(64,64);

    icon_2g =   QImage("/usr/share/themes/blanco/meegotouch/icons/icon-extensions-cellular-2g.png");
    icon_3g =   QImage("/usr/share/themes/blanco/meegotouch/icons/icon-extensions-cellular-3g.png");
    icon_dual = QImage("/usr/share/themes/blanco/meegotouch/icons/icon-extensions-cellular-dual.png");

    m_toggleicon = new MImageWidget(&icon_2g, this);
    m_toggleicon->setAspectRatioMode(Qt::KeepAspectRatio);
    m_toggleicon->setMaximumSize(64,64);
    m_toggleicon->setMinimumSize(64,64);

    MFeedback* feedback1 = new MFeedback("priority2_static_press", this);
    connect(this, SIGNAL(pressed()), feedback1, SLOT(play()));
    MFeedback* feedback2 = new MFeedback("priority2_static_release", this);
    connect(this, SIGNAL(released()), feedback2, SLOT(play()));


//    connect(m_radio,
//            SIGNAL(modeChanged(int)),
//            SLOT(onModeChanged(int)));

    onModeChanged(m_radio->mode());
    connect(poskey,
            SIGNAL(valueChanged()),
            SLOT(onIndexChanged()));
    connect(statuskey,
            SIGNAL(valueChanged()),
            SLOT(onStatusChanged()));
    index = poskey->value().toInt();
    status = statuskey->value().toBool();
}
Exemplo n.º 17
0
void CScreenShotManager::startScreenShot()
{
    if(m_isRunning)
    {
        return;
    }
    clearAll();
    QList<QScreen *> screens = QApplication::screens();
    int index = 0;
    QList<QRect> rectList = getWindownRectList();
    C_SCREENSHOTSHARED_LOG(QString("all rect count %1").arg(rectList.count()));

    foreach (QScreen *d, screens)
    {
        index++;
        CScreenShotView *view = new CScreenShotView(rectList,d);
        m_viewList.append(view);
        connect(view,SIGNAL(sigStatusChanged(CScreenShotStatus)),
                this,SLOT(onStatusChanged(CScreenShotStatus)));
        connect(view,SIGNAL(sigPreviewItemShow()),
                this,SLOT(onPreviewItemShow()));
        view->startSCreenShot();
        view->raise();
    }
Exemplo n.º 18
0
ClientTransfer::ClientTransfer(const QUuid &uuid, QObject *parent)
    : Transfer(uuid, parent),
    _file(0)
{
    connect(this, SIGNAL(statusChanged(Transfer::Status)), SLOT(onStatusChanged(Transfer::Status)));
}
Exemplo n.º 19
0
void CUploader::SetStatus(StatusType status, int param1, std::string param)
{
	m_CurrentStatus = status;
	if (onStatusChanged)
		onStatusChanged(status, param1,  param);
}
Exemplo n.º 20
0
void View::updateStatus()
{
    onStatusChanged(status());
}
/*!

*/
HsTitleResolver::HsTitleResolver(QObject *parent)
    : QObject(parent),
      mCurrentStatus(HsDeviceInfoListener::NoService)
{
    mDeviceInfoListener = new HsDeviceInfoListener(this);
    mOperatorName = mDeviceInfoListener->operatorName();
    mOfflineText = hbTrId(hsLocTextId_Title_Offline);
    mNoServiceText = hbTrId(hsLocTextId_Title_NoService);
    
    connect(mDeviceInfoListener, SIGNAL(networkNameChanged(QString)), SLOT(onNetworkNameChanged(QString)));
    connect(mDeviceInfoListener, SIGNAL(statusChanged(HsDeviceInfoListener::HsDeviceInfoStatus)), SLOT(onStatusChanged(HsDeviceInfoListener::HsDeviceInfoStatus)));
    mCurrentStatus = mDeviceInfoListener->status();
}
Exemplo n.º 22
0
void AccessController::initStatus()
{
    RETURN_IF_NO_NETWORK(doCheckNetworkConnectivity());
    auto status = getStatus();
    onStatusChanged(status);
}
Exemplo n.º 23
0
bool SimpleAudioRecorder::setupRecorder()
{
    //inputs
    QStringList inputs = m_recorder.audioInputs();
    if(inputs.size() == 0) return false;
    qDebug() << "inputs: " << inputs;
    m_recorder.setAudioInput("default");

    //audio codecs;
    QStringList codecs = m_recorder.supportedAudioCodecs();
    if(codecs.size() == 0) return false;
    qDebug() << "codecs: " << codecs;
    int sampleRate = 16000;
    if(codecs.contains("aac"))
    {
        m_settings.setCodec("aac");
    }
    else if(codecs.contains("amr-wb"))
    {
        m_settings.setCodec("amr-wb");
    }
    else
    {
        m_settings.setCodec(codecs.at(0));
        sampleRate = 8000;
    }
    qDebug() << "set codec: " << m_settings.codec();

    //containers
    QStringList containers = m_recorder.supportedContainers();
    if(containers.size() == 0) return false;
    qDebug() << "containers: " << containers;
    if(containers.contains("3gp"))
    {
        m_container = "3gp";
    }
    else if(containers.contains("mp4"))
    {
        m_container = "mp4";
    }
    else
    {
        m_container = containers.at(0);
    }

    //sample rate
    QList<int> sampleRates = m_recorder.supportedAudioSampleRates();
    if(sampleRates.size() == 0) return false;
    qDebug() << "samplerates: " << sampleRates;
    if(sampleRates.size() && !sampleRates.contains(sampleRate))
    {
        sampleRate = sampleRates.at(0);
    }

    m_settings.setChannelCount(2);
    m_settings.setSampleRate(sampleRate);
    m_settings.setQuality(QMultimedia::NormalQuality);
    m_settings.setBitRate(64000);
    m_settings.setEncodingMode(QMultimedia::AverageBitRateEncoding);
    m_recorder.setEncodingSettings(m_settings
                                   , QVideoEncoderSettings()
                                   , m_container);

    connect(&m_recorder, SIGNAL(durationChanged(qint64)), this,
            SLOT(onDurationChanged(qint64)));
    connect(&m_recorder, SIGNAL(statusChanged(QMediaRecorder::Status)), this,
            SLOT(onStatusChanged(QMediaRecorder::Status)));
    connect(&m_recorder, SIGNAL(error(QMediaRecorder::Error)), this,
            SLOT(onError(QMediaRecorder::Error)));

    return true;
}