示例#1
0
FlatInput::FlatInput(QWidget *parent, const style::flatInput &st, const QString &pholder, const QString &v) : QLineEdit(v, parent),
_fullph(pholder), _oldtext(v), _fastph(false), _kev(0), _customUpDown(false), _phVisible(!v.length()),
	a_phLeft(_phVisible ? 0 : st.phShift), a_phAlpha(_phVisible ? 1 : 0), a_phColor(st.phColor->c),
    a_borderColor(st.borderColor->c), a_bgColor(st.bgColor->c), _notingBene(0), _st(st) {
	resize(_st.width, _st.height);
	
	setFont(_st.font->f);
	setAlignment(_st.align);

	QPalette p(palette());
	p.setColor(QPalette::Text, _st.textColor->c);
	setPalette(p);

	connect(this, SIGNAL(textChanged(const QString &)), this, SLOT(onTextChange(const QString &)));
	connect(this, SIGNAL(textEdited(const QString &)), this, SLOT(onTextEdited()));
	if (App::wnd()) connect(this, SIGNAL(selectionChanged()), App::wnd(), SLOT(updateGlobalMenu()));

	setStyle(&_flatInputStyle);
	setTextMargins(0, 0, 0, 0);
	setContentsMargins(0, 0, 0, 0);

	setAttribute(Qt::WA_AcceptTouchEvents);
	_touchTimer.setSingleShot(true);
	connect(&_touchTimer, SIGNAL(timeout()), this, SLOT(onTouchTimer()));
}
示例#2
0
void Window::clearWidgets() {
	layerHidden();
	if (_passcode) {
		_passcode->hide();
		_passcode->deleteLater();
		_passcode = 0;
	}
	if (settings) {
		anim::stop(settings);
		settings->hide();
		settings->deleteLater();
		settings->rpcInvalidate();
		settings = 0;
	}
	if (main) {
		anim::stop(main);
		main->hide();
		main->deleteLater();
		main->rpcInvalidate();
		main = 0;
	}
	if (intro) {
		anim::stop(intro);
		intro->hide();
		intro->deleteLater();
		intro->rpcInvalidate();
		intro = 0;
	}
	title->updateBackButton();
	updateGlobalMenu();
}
示例#3
0
void Window::showFromTray(QSystemTrayIcon::ActivationReason reason) {
	if (reason != QSystemTrayIcon::Context) {
        activate();
		psUpdateCounter();
		if (App::main()) App::main()->setOnline(windowState());
		QTimer::singleShot(1, this, SLOT(updateTrayMenu()));
		QTimer::singleShot(1, this, SLOT(updateGlobalMenu()));
	}
}
示例#4
0
bool MainWindow::minimizeToTray() {
	if (App::quitting() || !hasTrayIcon()) return false;

	closeWithoutDestroy();
	updateIsActive(Global::OfflineBlurTimeout());
	updateTrayMenu();
	updateGlobalMenu();
	showTrayTooltip();
	return true;
}
示例#5
0
FlatTextarea::FlatTextarea(QWidget *parent, const style::flatTextarea &st, const QString &pholder, const QString &v) : QTextEdit(parent),
    _minHeight(-1), _maxHeight(-1), _maxLength(-1), _ctrlEnterSubmit(true),
    _oldtext(v), _phVisible(!v.length()),
    a_phLeft(_phVisible ? 0 : st.phShift), a_phAlpha(_phVisible ? 1 : 0), a_phColor(st.phColor->c),
    _st(st), _undoAvailable(false), _redoAvailable(false), _inDrop(false), _inHeightCheck(false), _fakeMargin(0),
    _touchPress(false), _touchRightButton(false), _touchMove(false), _correcting(false) {
    setAcceptRichText(false);
    resize(_st.width, _st.font->height);

    setFont(_st.font->f);
    setAlignment(_st.align);

    setPlaceholder(pholder);

    QPalette p(palette());
    p.setColor(QPalette::Text, _st.textColor->c);
    setPalette(p);

    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);

    setFrameStyle(QFrame::NoFrame | QFrame::Plain);
    viewport()->setAutoFillBackground(false);

    setContentsMargins(0, 0, 0, 0);

    switch (cScale()) {
    case dbisOneAndQuarter:
        _fakeMargin = 1;
        break;
    case dbisOneAndHalf:
        _fakeMargin = 2;
        break;
    case dbisTwo:
        _fakeMargin = 4;
        break;
    }
    setStyleSheet(qsl("QTextEdit { margin: %1px; }").arg(_fakeMargin));

    viewport()->setAttribute(Qt::WA_AcceptTouchEvents);
    _touchTimer.setSingleShot(true);
    connect(&_touchTimer, SIGNAL(timeout()), this, SLOT(onTouchTimer()));

    connect(document(), SIGNAL(contentsChange(int, int, int)), this, SLOT(onDocumentContentsChange(int, int, int)));
    connect(document(), SIGNAL(contentsChanged()), this, SLOT(onDocumentContentsChanged()));
    connect(this, SIGNAL(undoAvailable(bool)), this, SLOT(onUndoAvailable(bool)));
    connect(this, SIGNAL(redoAvailable(bool)), this, SLOT(onRedoAvailable(bool)));
    if (App::wnd()) connect(this, SIGNAL(selectionChanged()), App::wnd(), SLOT(updateGlobalMenu()));

    if (!v.isEmpty()) {
        setPlainText(v);
    }
}
示例#6
0
bool Window::minimizeToTray() {
	if (App::quiting() || !trayIcon) return false;

	hide();
	if (cPlatform() != dbipMac && !cSeenTrayTooltip()) {
		trayIcon->showMessage(QString::fromStdWString(AppName), lang(lng_tray_icon_text), QSystemTrayIcon::Information, 10000);
		cSetSeenTrayTooltip(true);
		App::writeConfig();
	}
	if (App::main()) App::main()->setOnline(windowState());
	updateTrayMenu();
	updateGlobalMenu();
	return true;
}
示例#7
0
bool Window::minimizeToTray() {
    if (App::quiting() || !psHasTrayIcon()) return false;

	hide();
    if (cPlatform() == dbipWindows && trayIcon && !cSeenTrayTooltip()) {
		trayIcon->showMessage(QString::fromStdWString(AppName), lang(lng_tray_icon_text), QSystemTrayIcon::Information, 10000);
		cSetSeenTrayTooltip(true);
		Local::writeSettings();
	}
	updateIsActive(cOfflineBlurTimeout());
	updateTrayMenu();
	updateGlobalMenu();
	return true;
}
示例#8
0
bool MainWindow::hideNoQuit() {
	if (App::quitting()) {
		return false;
	}
	if (Global::WorkMode().value() == dbiwmTrayOnly || Global::WorkMode().value() == dbiwmWindowAndTray) {
		if (minimizeToTray()) {
			Ui::showChatsList();
			return true;
		}
	} else if (cPlatform() == dbipMac || cPlatform() == dbipMacOld) {
		closeWithoutDestroy();
		updateIsActive(Global::OfflineBlurTimeout());
		updateGlobalMenu();
		Ui::showChatsList();
		return true;
	}
	return false;
}
示例#9
0
void Window::clearPasscode() {
	if (!_passcode) return;

	QPixmap bg = myGrab(this, QRect(0, st::titleHeight, width(), height() - st::titleHeight));

	anim::stop(_passcode);
	_passcode->hide();
	_passcode->deleteLater();
	_passcode = 0;
	if (intro) {
		intro->animShow(bg, true);
	} else if (settings) {
		settings->animShow(bg, true);
	} else {
		main->animShow(bg, true);
	}
	notifyUpdateAll();
	title->updateBackButton();
	updateGlobalMenu();
}
示例#10
0
void Window::setupPasscode(bool anim) {
	QPixmap bg = myGrab(this, QRect(0, st::titleHeight, width(), height() - st::titleHeight));
	if (_passcode) {
		anim::stop(_passcode);
		_passcode->hide();
		_passcode->deleteLater();
	}
	_passcode = new PasscodeWidget(this);
	_passcode->move(0, st::titleHeight);
	if (main) main->hide();
	if (settings) settings->hide();
	if (intro) intro->hide();
	if (anim) {
		_passcode->animShow(bg);
	} else {
		_passcode->setInnerFocus();
	}
	_shouldLockAt = 0;
	notifyUpdateAll();
	title->updateBackButton();
	updateGlobalMenu();
}
示例#11
0
InputField::InputField(QWidget *parent, const style::InputField &st, const QString &ph, const QString &val) : TWidget(parent),
_inner(this, val),
_oldtext(val),
_keyEvent(0),

_undoAvailable(false),
_redoAvailable(false),

_fakeMargin(0),
_customUpDown(false),

_placeholderFull(ph),
_placeholderVisible(val.isEmpty()),
a_placeholderLeft(_placeholderVisible ? 0 : st.placeholderShift),
a_placeholderOpacity(_placeholderVisible ? 1 : 0),
a_placeholderFg(st.placeholderFg->c),
_placeholderFgAnim(animFunc(this, &InputField::placeholderFgStep)),
_placeholderShiftAnim(animFunc(this, &InputField::placeholderShiftStep)),

a_borderOpacityActive(0),
a_borderFg(st.borderFg->c),
_borderAnim(animFunc(this, &InputField::borderStep)),

_focused(false), _error(false),

_st(&st),

_touchPress(false),
_touchRightButton(false),
_touchMove(false),
_replacingEmojis(false) {
	_inner.setAcceptRichText(false);
	resize(_st->width, _st->height);

	_inner.setWordWrapMode(QTextOption::NoWrap);
	_inner.setLineWrapMode(QTextEdit::NoWrap);

	_inner.setFont(_st->font->f);
	_inner.setAlignment(cRtl() ? Qt::AlignRight : Qt::AlignLeft);

	_placeholder = _st->font->m.elidedText(_placeholderFull, Qt::ElideRight, width() - _st->textMargins.left() - _st->textMargins.right() - _st->placeholderMargins.left() - _st->placeholderMargins.right() - 1);

	QPalette p(palette());
	p.setColor(QPalette::Text, _st->textFg->c);
	setPalette(p);

	_inner.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	_inner.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);

	_inner.setFrameStyle(QFrame::NoFrame | QFrame::Plain);
	_inner.viewport()->setAutoFillBackground(false);

	_inner.setContentsMargins(0, 0, 0, 0);
	_inner.document()->setDocumentMargin(0);

	setAttribute(Qt::WA_AcceptTouchEvents);
	_inner.viewport()->setAttribute(Qt::WA_AcceptTouchEvents);
	_touchTimer.setSingleShot(true);
	connect(&_touchTimer, SIGNAL(timeout()), this, SLOT(onTouchTimer()));

	connect(_inner.document(), SIGNAL(contentsChange(int, int, int)), this, SLOT(onDocumentContentsChange(int, int, int)));
	connect(_inner.document(), SIGNAL(contentsChanged()), this, SLOT(onDocumentContentsChanged()));
	connect(&_inner, SIGNAL(undoAvailable(bool)), this, SLOT(onUndoAvailable(bool)));
	connect(&_inner, SIGNAL(redoAvailable(bool)), this, SLOT(onRedoAvailable(bool)));
	if (App::wnd()) connect(&_inner, SIGNAL(selectionChanged()), App::wnd(), SLOT(updateGlobalMenu()));
}
示例#12
0
void MainWindow::clearWidgets() {
	Ui::hideLayer(anim::type::instant);
	clearWidgetsHook();
	updateGlobalMenu();
}