diff --git a/qml/libdap-qt-ui-qml.qrc b/qml/libdap-qt-ui-qml.qrc index 7dc91852e91c09883218c92734224122b0290ef2..6bd42a7198815ecf93233fa6db8be793c4650616 100644 --- a/qml/libdap-qt-ui-qml.qrc +++ b/qml/libdap-qt-ui-qml.qrc @@ -4,8 +4,6 @@ <file>widgets/DapButtonForm.ui.qml</file> <file>widgets/DapComboBox.qml</file> <file>widgets/DapComboBoxForm.ui.qml</file> - <file>widgets/DapMainWindow.qml</file> - <file>widgets/DapMainWindowForm.ui.qml</file> <file>widgets/DapMenuTabWidget.qml</file> <file>widgets/DapMenuTabWidgetForm.ui.qml</file> <file>widgets/DapPanelForm.ui.qml</file> diff --git a/qml/widgets/DapMainWindow.qml b/qml/widgets/DapMainWindow.qml deleted file mode 100644 index 2a97151942703fd00f16d3f2f99c5211577051e4..0000000000000000000000000000000000000000 --- a/qml/widgets/DapMainWindow.qml +++ /dev/null @@ -1,6 +0,0 @@ -import QtQuick 2.4 - -DapMainWindowForm -{ - -} diff --git a/qml/widgets/DapMainWindowForm.ui.qml b/qml/widgets/DapMainWindowForm.ui.qml deleted file mode 100644 index 6453a234decfb67e4f54b069ace2bdec03561fc4..0000000000000000000000000000000000000000 --- a/qml/widgets/DapMainWindowForm.ui.qml +++ /dev/null @@ -1,60 +0,0 @@ -//**************************************************************************** -// Implements the main application window. -//**************************************************************************** - -import QtQuick 2.4 -import QtQuick.Controls 2.0 - -Rectangle -{ - id: mainWindow - - ///@detalis Logotype. - property Item dapLogotype - ///@detalis Menu bar widget. - property Item dapMenuWidget - ///@detalis screen downloader widget. - property Item dabScreensWidget - - anchors.fill: parent - - // The horizontal location of the virtual menu column and tab view loader - Row - { - id: rowMainWindow - - anchors.fill: parent - - // Virtual logo column frame and menu bar - Column - { - id: columnMenuTab - height: rowMainWindow.height - // Logotype widget - Item - { - id: logotype - data: dapLogotype - width: columnMenuTab.width - height: dapLogotype.height - } - // Menu bar widget - Item - { - id: menuWidget - data: dapMenuWidget - width: dapMenuWidget.width - height: columnMenuTab.height - logotype.height - } - } - - // Screen downloader widget - Item - { - id: screens - data: dabScreensWidget - height: rowMainWindow.height - width: rowMainWindow.width - columnMenuTab.width - } - } -} diff --git a/ui/controls/SerialKeyField.cpp b/ui/controls/SerialKeyField.cpp index 47c52cdd1efed0154a6218b83e5d75e8bb500836..9367a623abbb4ac5eeb5815ad51255d5c839b347 100644 --- a/ui/controls/SerialKeyField.cpp +++ b/ui/controls/SerialKeyField.cpp @@ -3,13 +3,15 @@ SerialKeyField::SerialKeyField(QWidget *parent) :CustomLineEdit(parent) { +#if defined(Q_OS_MAC) + this->setAttribute(Qt::WA_MacShowFocusRect,false); +#endif m_regExp=QRegExp("[a-z"+QString(VALIDATOR)+"]" "{0,"+QString::number(MAX_COUNT_CHAR)+"}"); QValidator* validator=new QRegExpValidator(m_regExp); setValidator(validator); setMaxLength(MAX_COUNT_CHAR); setInputMethodHints(Qt::ImhLatinOnly|Qt::ImhNoPredictiveText|Qt::ImhPreferUppercase|Qt::ImhUppercaseOnly); - connect(this, &SerialKeyField::pasteTextCaused,&SerialKeyField::pasteEvent); connect(this, &SerialKeyField::textChanged,[this](QString text) { if (this->text().count()==MAX_COUNT_CHAR) @@ -36,6 +38,25 @@ bool SerialKeyField::isFilledOut() void SerialKeyField::paste() { emit pasteTextCaused(QApplication::clipboard()->text()); + QString clipboardText{QApplication::clipboard()->text()}; + clipboardText.replace("-",""); + clipboardText.replace(" ",""); + clipboardText = clipboardText.toUpper(); + if (clipboardText.count() == MAX_COUNT_CHAR) + pasteEvent(clipboardText); + else + { + int cursorPosition{}; + this->hasSelectedText() ? cursorPosition = this->selectionStart() + : cursorPosition = this->cursorPosition(); + QString text{this->text()}; + QLineEdit::paste(); + if (this->text() != text) + { + setText(this->text().toUpper()); + setCursorPosition(cursorPosition + clipboardText.count()); + } + } } void SerialKeyField::replaceNextCharacter(const QString &text) @@ -121,8 +142,39 @@ void SerialKeyField::keyPressEvent(QKeyEvent *e) if(e==QKeySequence::Paste) { emit pasteTextCaused(QApplication::clipboard()->text()); + QString clipboardText{QApplication::clipboard()->text()}; + clipboardText.replace("-",""); + clipboardText.replace(" ",""); + clipboardText = clipboardText.toUpper(); + if (clipboardText.count() == MAX_COUNT_CHAR) + pasteEvent(clipboardText); + else + { + int cursorPosition{}; + this->hasSelectedText() ? cursorPosition = this->selectionStart() + : cursorPosition = this->cursorPosition(); + QString text{this->text()}; + QLineEdit::keyPressEvent(e); + if (this->text() != text) + { + setText(this->text().toUpper()); + setCursorPosition(cursorPosition + clipboardText.count()); + } + } + return; } + if(e==QKeySequence::Copy) + { + QLineEdit::keyPressEvent(e); + return; + } + if(e==QKeySequence::Cut) + { + QLineEdit::keyPressEvent(e); + return; + } + #ifdef Q_OS_ANDROID if(m_keys.contains(e->key()) && this->text().count()>this->cursorPosition()) @@ -151,7 +203,7 @@ void SerialKeyField::keyPressEvent(QKeyEvent *e) #else if(e->text().isEmpty()) { - CustomLineEdit::keyPressEvent(e); + QLineEdit::keyPressEvent(e); return; } @@ -163,7 +215,7 @@ void SerialKeyField::keyPressEvent(QKeyEvent *e) || e->key()==Qt::Key_Delete) { int newCursorPosition{this->cursorPosition()}; - CustomLineEdit::keyPressEvent(e); + QLineEdit::keyPressEvent(e); e->key()==Qt::Key_Backspace ? this->setCursorPosition(newCursorPosition-1) : this->setCursorPosition(newCursorPosition); } @@ -176,7 +228,7 @@ void SerialKeyField::keyPressEvent(QKeyEvent *e) if(e->key()==Qt::Key_Backspace || e->key()==Qt::Key_Delete) { - CustomLineEdit::keyPressEvent(e); + QLineEdit::keyPressEvent(e); this->setCursorPosition(newCursorPosition); } else @@ -184,7 +236,7 @@ void SerialKeyField::keyPressEvent(QKeyEvent *e) QKeyEvent upperEvent(e->type(), e->key(), e->modifiers(), e->text().toUpper(), e->isAutoRepeat(), e->count()); - CustomLineEdit::keyPressEvent(&upperEvent); + QLineEdit::keyPressEvent(&upperEvent); this->setCursorPosition(newCursorPosition+1); } } @@ -195,41 +247,13 @@ void SerialKeyField::keyPressEvent(QKeyEvent *e) QKeyEvent upperEvent(e->type(), e->key(), e->modifiers(), e->text().toUpper(), e->isAutoRepeat(), e->count()); - CustomLineEdit::keyPressEvent(&upperEvent); + QLineEdit::keyPressEvent(&upperEvent); } #endif } void SerialKeyField::pasteEvent(QString clipboardText) { - clipboardText=clipboardText.toUpper(); - clipboardText.replace("-",""); - clipboardText.replace(" ",""); - if (clipboardText.count()>MAX_COUNT_CHAR) - clipboardText=clipboardText.left(MAX_COUNT_CHAR); - if(m_regExp.exactMatch(clipboardText)) - { - if(clipboardText.count()==MAX_COUNT_CHAR) - this->setText(clipboardText); - - /*if paste to middle/start/end of text*/ - else - { - /*safe text before cursor and after*/ - QString before{this->text().left(this->cursorPosition())}; - QString after{this->text().right(this->text().count() - this->cursorPosition())}; - - /*if clipboard text equals count of symbols to end, then next symbols will be edited*/ - if(clipboardText.count() == MAX_COUNT_CHAR - before.count()) - this->setText(before + clipboardText); - - /*paste principle: before cursor text + clipboard text + after cursor text*/ - else - { - this->setText(before + clipboardText.left(MAX_COUNT_CHAR - before.count() - after.count()) + after); - this->setCursorPosition(before.count() + clipboardText.count()); - } - } - emit textEdited(clipboardText); - } + setText(clipboardText); + emit textEdited(clipboardText); } diff --git a/vpn/ui/controls/ComboBoxListView.cpp b/vpn/ui/controls/ComboBoxListView.cpp index 19f6539a000bb301f80fb50ab5210ae387b91599..be909efda00bbf5f6a664ac0c49c37e409884a9e 100644 --- a/vpn/ui/controls/ComboBoxListView.cpp +++ b/vpn/ui/controls/ComboBoxListView.cpp @@ -8,7 +8,12 @@ ComboBoxListView::ComboBoxListView(QWidget *a_parent /*= nullptr*/) { #ifdef ANDROID this->setFocusPolicy(Qt::NoFocus); - QScroller::grabGesture(this, QScroller::LeftMouseButtonGesture); + QScroller* scroller = QScroller::scroller(this); + QScrollerProperties sp; + sp.setScrollMetric(QScrollerProperties::VerticalOvershootPolicy, QScrollerProperties::OvershootAlwaysOff); + scroller->setScrollerProperties(sp); + scroller->grabGesture(this, QScroller::LeftMouseButtonGesture); + this->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); #endif this->setWidgetDelegateFactory(&CustomButtonDelegate::create); // Add creating item widgets diff --git a/vpn/ui/dialogs/BugReportScreen.ui b/vpn/ui/dialogs/BugReportScreen.ui index 33f75e70ea05b2152f1767e7492a54693f24cd7a..0916804c48533270f746fa6168f7361334500aa6 100644 --- a/vpn/ui/dialogs/BugReportScreen.ui +++ b/vpn/ui/dialogs/BugReportScreen.ui @@ -89,25 +89,64 @@ <widget class="QWidget" name="wgtMessageTopMargin" native="true"/> </item> <item> - <widget class="CustomTextEdit" name="edtMessage"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="inputMethodHints"> - <set>Qt::ImhMultiLine</set> - </property> - <property name="verticalScrollBarPolicy"> - <enum>Qt::ScrollBarAlwaysOff</enum> - </property> - <property name="horizontalScrollBarPolicy"> - <enum>Qt::ScrollBarAlwaysOff</enum> - </property> - <property name="placeholderText"> - <string>Please describe the details of problem you faced. What actions did you take and what happened.</string> - </property> + <widget class="QFrame" name="frmEditMessage"> + <property name="frameShape"> + <enum>QFrame::StyledPanel</enum> + </property> + <property name="frameShadow"> + <enum>QFrame::Raised</enum> + </property> + <layout class="QGridLayout" name="gridLayout"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <property name="spacing"> + <number>0</number> + </property> + <item row="1" column="1"> + <widget class="CustomTextEdit" name="edtMessage"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="inputMethodHints"> + <set>Qt::ImhMultiLine</set> + </property> + <property name="verticalScrollBarPolicy"> + <enum>Qt::ScrollBarAlwaysOff</enum> + </property> + <property name="horizontalScrollBarPolicy"> + <enum>Qt::ScrollBarAlwaysOff</enum> + </property> + <property name="placeholderText"> + <string>Please describe the details of problem you faced. What actions did you take and what happened.</string> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QWidget" name="wgtLeftMargin" native="true"/> + </item> + <item row="1" column="2"> + <widget class="QWidget" name="wgtRightMargin" native="true"/> + </item> + <item row="0" column="0" colspan="3"> + <widget class="QWidget" name="wgtTopMargin" native="true"/> + </item> + <item row="2" column="0" colspan="3"> + <widget class="QWidget" name="wgtBottomMargin" native="true"/> + </item> + </layout> </widget> </item> <item alignment="Qt::AlignRight"> diff --git a/vpn/ui/dialogs/SignInScreenSerialNumberBase.cpp b/vpn/ui/dialogs/SignInScreenSerialNumberBase.cpp index 7f484734db29e0908ca567049d3ba85bfaaf04f5..512f4d5b5f8a79ccf69ae948184aa89666fe9042 100644 --- a/vpn/ui/dialogs/SignInScreenSerialNumberBase.cpp +++ b/vpn/ui/dialogs/SignInScreenSerialNumberBase.cpp @@ -53,7 +53,9 @@ void SignInScreenSerialNumberBase::initVariantUi(QWidget *a_widget) m_ui->cbbServer->setPositionPopup(PositionPopup::overlappingPosition); #endif //*************************Serial field*************************************** - +#ifdef Q_OS_MAC + m_ui->ledSerialKey->setAttribute(Qt::WA_MacShowFocusRect,false); +#endif connect(m_ui->btnConnect, &QPushButton::clicked, [this]{ if (m_ui->ledSerialKey->text().isEmpty())