CoverWidget::CoverWidget(QWidget *parent, UserData *self) : BlockWidget(parent, self, QString()) , _self(App::self()) , _userpicButton( this, App::wnd()->controller(), _self, Ui::UserpicButton::Role::OpenPhoto, st::settingsPhoto) , _name(this, st::settingsNameLabel) , _editNameInline(this, st::settingsEditButton) , _setPhoto(this, langFactory(lng_settings_upload), st::settingsPrimaryButton) , _editName(this, langFactory(lng_settings_edit), st::settingsSecondaryButton) { if (_self) { _self->updateFull(); } setAcceptDrops(true); _name->setSelectable(true); _name->setContextCopyText(lang(lng_profile_copy_fullname)); _setPhoto->setClickedCallback(App::LambdaDelayed( st::settingsPrimaryButton.ripple.hideDuration, this, [this] { chooseNewPhoto(); })); _editName->addClickHandler([this] { editName(); }); _editNameInline->addClickHandler([this] { editName(); }); auto observeEvents = Notify::PeerUpdate::Flag::NameChanged | Notify::PeerUpdate::Flag::PhotoChanged; subscribe(Notify::PeerUpdated(), Notify::PeerUpdatedHandler(observeEvents, [this](const Notify::PeerUpdate &update) { notifyPeerUpdated(update); })); connect( &Messenger::Instance(), &Messenger::peerPhotoDone, this, &CoverWidget::onPhotoUploadStatusChanged); connect( &Messenger::Instance(), &Messenger::peerPhotoFail, this, &CoverWidget::onPhotoUploadStatusChanged); _userpicButton->addClickHandler([this] { showPhoto(); }); validatePhoto(); refreshNameText(); subscribe(Global::RefConnectionTypeChanged(), [this] { refreshStatusText(); }); refreshStatusText(); }
//********************************************************************************************************************** SimpleTerminal::SimpleTerminal(QSerialPort *port, QObject *parent) : QObject(parent), _statusText(QString()), _port(port), _som(""), _eom("\r"), _inputHistory(), _inputHistoryIdx(-1), _is_msg_open(false), _cmdParser(nullptr) { Q_CHECK_PTR(_port); _cmdParser = new CommandParser(*this); // Restore settings restoreSettings(); refreshStatusText(); QObject::connect(_port, SIGNAL(readyRead()), this, SLOT(read())); QObject::connect(_port, SIGNAL(baudRateChanged(qint32,QSerialPort::Directions)), this, SLOT(settingsChanged())); QObject::connect(_port, SIGNAL(dataBitsChanged(QSerialPort::DataBits)), this, SLOT(settingsChanged())); QObject::connect(_port, SIGNAL(flowControlChanged(QSerialPort::FlowControl)), this, SLOT(settingsChanged())); QObject::connect(_port, SIGNAL(parityChanged(QSerialPort::Parity)), this, SLOT(settingsChanged())); QObject::connect(_port, SIGNAL(stopBitsChanged(QSerialPort::StopBits)), this, SLOT(settingsChanged())); QObject::connect(this, SIGNAL(somChanged()), this, SLOT(settingsChanged())); QObject::connect(this, SIGNAL(eomChanged()), this, SLOT(settingsChanged())); }
CoverWidget::CoverWidget(QWidget *parent, UserData *self) : BlockWidget(parent, self, QString()) , _self(App::self()) , _userpicButton(this, _self) , _name(this, st::settingsNameLabel) , _editNameInline(this, QString(), st::settingsEditButton) , _setPhoto(this, lang(lng_settings_upload), st::settingsPrimaryButton) , _editName(this, lang(lng_settings_edit), st::settingsSecondaryButton) { setAcceptDrops(true); _name->setSelectable(true); _name->setContextCopyText(lang(lng_profile_copy_fullname)); _setPhoto->setTextTransform(Ui::RoundButton::TextTransform::ToUpper); connect(_setPhoto, SIGNAL(clicked()), this, SLOT(onSetPhoto())); _editName->setTextTransform(Ui::RoundButton::TextTransform::ToUpper); connect(_editName, SIGNAL(clicked()), this, SLOT(onEditName())); connect(_editNameInline, SIGNAL(clicked()), this, SLOT(onEditName())); auto observeEvents = Notify::PeerUpdate::Flag::NameChanged; Notify::registerPeerObserver(observeEvents, this, &CoverWidget::notifyPeerUpdated); FileDialog::registerObserver(this, &CoverWidget::notifyFileQueryUpdated); connect(App::app(), SIGNAL(peerPhotoDone(PeerId)), this, SLOT(onPhotoUploadStatusChanged(PeerId))); connect(App::app(), SIGNAL(peerPhotoFail(PeerId)), this, SLOT(onPhotoUploadStatusChanged(PeerId))); connect(_userpicButton, SIGNAL(clicked()), this, SLOT(onPhotoShow())); validatePhoto(); refreshNameText(); refreshStatusText(); }
//********************************************************************************************************************** void SimpleTerminal::disconnect() { _port->close(); refreshStatusText(); emit connStateChanged(); qDebug() << "Disconnected"; }
//********************************************************************************************************************** void SimpleTerminal::connect() { if (_port->open(QIODevice::ReadWrite)) { refreshStatusText(); emit connStateChanged(); qDebug() << "Connected!"; } else { qWarning() << "Could not connect\nError code: " << _port->error() << "\nError description: " << _port->errorString(); setError("Connect attempt failed"); } }
//********************************************************************************************************************** void SimpleTerminal::setPort(QString port) { if (_port->isOpen()) { _port->disconnect(); _port->setPortName(port); connect(); } else { _port->setPortName(port); } qDebug() << "Port set to " << _port->portName(); refreshStatusText(); }
//********************************************************************************************************************** void SimpleTerminal::settingsChanged() { refreshStatusText(); saveSettings(); }
void CoverWidget::onCancelPhotoUpload() { if (auto app = App::app()) { app->cancelPhotoUpdate(_self->id); refreshStatusText(); } }
void CoverWidget::onPhotoUploadStatusChanged(PeerId peerId) { if (!peerId || peerId == _self->id) { refreshStatusText(); } }
void CoverWidget::cancelPhotoUpload() { Messenger::Instance().cancelPhotoUpdate(_self->id); refreshStatusText(); }