UI: Show tooltip in edit fields

This commit is contained in:
Nodir Temirkhodjaev 2024-03-31 16:24:14 +03:00
parent 5c02c43277
commit 638bd32823
13 changed files with 61 additions and 27 deletions

View File

@ -47,6 +47,7 @@ SOURCES += \
form/controls/labeldoublespin.cpp \ form/controls/labeldoublespin.cpp \
form/controls/labelspin.cpp \ form/controls/labelspin.cpp \
form/controls/labelspincombo.cpp \ form/controls/labelspincombo.cpp \
form/controls/lineedit.cpp \
form/controls/listview.cpp \ form/controls/listview.cpp \
form/controls/mainwindow.cpp \ form/controls/mainwindow.cpp \
form/controls/menuwidget.cpp \ form/controls/menuwidget.cpp \
@ -258,6 +259,7 @@ HEADERS += \
form/controls/labeldoublespin.h \ form/controls/labeldoublespin.h \
form/controls/labelspin.h \ form/controls/labelspin.h \
form/controls/labelspincombo.h \ form/controls/labelspincombo.h \
form/controls/lineedit.h \
form/controls/listview.h \ form/controls/listview.h \
form/controls/mainwindow.h \ form/controls/mainwindow.h \
form/controls/menuwidget.h \ form/controls/menuwidget.h \

View File

@ -58,7 +58,6 @@ void AppInfoRow::refreshAppInfoVersion(const QString &appPath, AppInfoCache *app
m_filePath = appInfo.filePath(appPath); m_filePath = appInfo.filePath(appPath);
m_lineAppPath->setText(appPath); m_lineAppPath->setText(appPath);
m_lineAppPath->setToolTip(appPath);
m_labelAppProductName->setVisible(!appInfo.productName.isEmpty()); m_labelAppProductName->setVisible(!appInfo.productName.isEmpty());
m_labelAppProductName->setText(appInfo.productName + ' ' + appInfo.productVersion); m_labelAppProductName->setText(appInfo.productName + ' ' + appInfo.productVersion);

View File

@ -4,7 +4,6 @@
#include <QCheckBox> #include <QCheckBox>
#include <QFormLayout> #include <QFormLayout>
#include <QLabel> #include <QLabel>
#include <QLineEdit>
#include <QMenu> #include <QMenu>
#include <QPushButton> #include <QPushButton>
#include <QScrollArea> #include <QScrollArea>
@ -19,6 +18,7 @@
#include "labeldoublespin.h" #include "labeldoublespin.h"
#include "labelspin.h" #include "labelspin.h"
#include "labelspincombo.h" #include "labelspincombo.h"
#include "lineedit.h"
#include "menuwidget.h" #include "menuwidget.h"
#include "sidebutton.h" #include "sidebutton.h"
#include "spinbox.h" #include "spinbox.h"
@ -188,7 +188,7 @@ QLabel *ControlUtil::createLabel(const QString &text)
QLineEdit *ControlUtil::createLineLabel() QLineEdit *ControlUtil::createLineLabel()
{ {
auto c = new QLineEdit(); auto c = new LineEdit();
c->setReadOnly(true); c->setReadOnly(true);
c->setFrame(false); c->setFrame(false);

View File

@ -0,0 +1,16 @@
#include "lineedit.h"
#include <QEvent>
LineEdit::LineEdit(QWidget *parent) : QLineEdit(parent) { }
bool LineEdit::event(QEvent *event)
{
switch (event->type()) {
case QEvent::ToolTip: {
setToolTip(text());
} break;
}
return QWidget::event(event);
}

View File

@ -0,0 +1,16 @@
#ifndef LINEEDIT_H
#define LINEEDIT_H
#include <QLineEdit>
class LineEdit : public QLineEdit
{
Q_OBJECT
public:
explicit LineEdit(QWidget *parent = nullptr);
bool event(QEvent *event) override;
};
#endif // LINEEDIT_H

View File

@ -3,7 +3,6 @@
#include <QCheckBox> #include <QCheckBox>
#include <QHBoxLayout> #include <QHBoxLayout>
#include <QLabel> #include <QLabel>
#include <QLineEdit>
#include <QMenu> #include <QMenu>
#include <QPlainTextEdit> #include <QPlainTextEdit>
#include <QPushButton> #include <QPushButton>
@ -19,6 +18,7 @@
#include <form/controls/controlutil.h> #include <form/controls/controlutil.h>
#include <form/controls/labeldoublespin.h> #include <form/controls/labeldoublespin.h>
#include <form/controls/labelspin.h> #include <form/controls/labelspin.h>
#include <form/controls/lineedit.h>
#include <form/controls/plaintextedit.h> #include <form/controls/plaintextedit.h>
#include <form/controls/tabbar.h> #include <form/controls/tabbar.h>
#include <form/controls/textarea2splitter.h> #include <form/controls/textarea2splitter.h>
@ -249,7 +249,7 @@ QLayout *ApplicationsPage::setupHeader()
{ {
auto layout = new QHBoxLayout(); auto layout = new QHBoxLayout();
m_editGroupName = new QLineEdit(); m_editGroupName = new LineEdit();
m_editGroupName->setClearButtonEnabled(true); m_editGroupName->setClearButtonEnabled(true);
m_editGroupName->setMaxLength(128); m_editGroupName->setMaxLength(128);
m_editGroupName->setFixedWidth(200); m_editGroupName->setFixedWidth(200);

View File

@ -9,6 +9,7 @@ class CheckSpinCombo;
class CheckTimePeriod; class CheckTimePeriod;
class LabelDoubleSpin; class LabelDoubleSpin;
class LabelSpin; class LabelSpin;
class LineEdit;
class TabBar; class TabBar;
class TextArea2Splitter; class TextArea2Splitter;
@ -71,7 +72,7 @@ private:
private: private:
int m_appGroupIndex = -1; int m_appGroupIndex = -1;
QLineEdit *m_editGroupName = nullptr; LineEdit *m_editGroupName = nullptr;
QToolButton *m_btAddGroup = nullptr; QToolButton *m_btAddGroup = nullptr;
QToolButton *m_btRenameGroup = nullptr; QToolButton *m_btRenameGroup = nullptr;
TabBar *m_tabBar = nullptr; TabBar *m_tabBar = nullptr;

View File

@ -6,7 +6,6 @@
#include <QDateTimeEdit> #include <QDateTimeEdit>
#include <QFormLayout> #include <QFormLayout>
#include <QLabel> #include <QLabel>
#include <QLineEdit>
#include <QPushButton> #include <QPushButton>
#include <QRadioButton> #include <QRadioButton>
#include <QSpinBox> #include <QSpinBox>
@ -17,6 +16,7 @@
#include <conf/confmanager.h> #include <conf/confmanager.h>
#include <conf/firewallconf.h> #include <conf/firewallconf.h>
#include <form/controls/controlutil.h> #include <form/controls/controlutil.h>
#include <form/controls/lineedit.h>
#include <form/controls/plaintextedit.h> #include <form/controls/plaintextedit.h>
#include <form/controls/spincombo.h> #include <form/controls/spincombo.h>
#include <form/controls/zonesselector.h> #include <form/controls/zonesselector.h>
@ -410,7 +410,7 @@ QLayout *ProgramEditDialog::setupFormLayout()
QLayout *ProgramEditDialog::setupPathLayout() QLayout *ProgramEditDialog::setupPathLayout()
{ {
// Path // Path
m_editPath = new QLineEdit(); m_editPath = new LineEdit();
m_editPath->setMaxLength(1024); m_editPath->setMaxLength(1024);
// Wildcard // Wildcard
@ -450,7 +450,7 @@ QLayout *ProgramEditDialog::setupPathLayout()
QLayout *ProgramEditDialog::setupNameLayout() QLayout *ProgramEditDialog::setupNameLayout()
{ {
m_editName = new QLineEdit(); m_editName = new LineEdit();
m_editName->setMaxLength(1024); m_editName->setMaxLength(1024);
m_btGetName = ControlUtil::createIconToolButton( m_btGetName = ControlUtil::createIconToolButton(
@ -592,7 +592,7 @@ QLayout *ProgramEditDialog::setupZonesRuleLayout()
QLayout *ProgramEditDialog::setupRuleLayout() QLayout *ProgramEditDialog::setupRuleLayout()
{ {
m_editRuleName = new QLineEdit(); m_editRuleName = new LineEdit();
m_editRuleName->setFocusPolicy(Qt::NoFocus); m_editRuleName->setFocusPolicy(Qt::NoFocus);
m_editRuleName->setContextMenuPolicy(Qt::PreventContextMenu); m_editRuleName->setContextMenuPolicy(Qt::PreventContextMenu);
m_editRuleName->setMaximumWidth(300); m_editRuleName->setMaximumWidth(300);

View File

@ -10,7 +10,6 @@ QT_FORWARD_DECLARE_CLASS(QComboBox)
QT_FORWARD_DECLARE_CLASS(QDateTimeEdit) QT_FORWARD_DECLARE_CLASS(QDateTimeEdit)
QT_FORWARD_DECLARE_CLASS(QFrame) QT_FORWARD_DECLARE_CLASS(QFrame)
QT_FORWARD_DECLARE_CLASS(QLabel) QT_FORWARD_DECLARE_CLASS(QLabel)
QT_FORWARD_DECLARE_CLASS(QLineEdit)
QT_FORWARD_DECLARE_CLASS(QPushButton) QT_FORWARD_DECLARE_CLASS(QPushButton)
QT_FORWARD_DECLARE_CLASS(QRadioButton) QT_FORWARD_DECLARE_CLASS(QRadioButton)
QT_FORWARD_DECLARE_CLASS(QToolButton) QT_FORWARD_DECLARE_CLASS(QToolButton)
@ -20,11 +19,12 @@ class ConfManager;
class FirewallConf; class FirewallConf;
class FortManager; class FortManager;
class IniUser; class IniUser;
class LineEdit;
class PlainTextEdit; class PlainTextEdit;
class ProgramsController; class ProgramsController;
class SpinCombo; class SpinCombo;
class ZonesSelector;
class WindowManager; class WindowManager;
class ZonesSelector;
class ProgramEditDialog : public WidgetWindow class ProgramEditDialog : public WidgetWindow
{ {
@ -107,11 +107,11 @@ private:
ProgramsController *m_ctrl = nullptr; ProgramsController *m_ctrl = nullptr;
QLabel *m_labelEditPath = nullptr; QLabel *m_labelEditPath = nullptr;
QLineEdit *m_editPath = nullptr; LineEdit *m_editPath = nullptr;
PlainTextEdit *m_editWildcard = nullptr; PlainTextEdit *m_editWildcard = nullptr;
QToolButton *m_btSelectFile = nullptr; QToolButton *m_btSelectFile = nullptr;
QLabel *m_labelEditName = nullptr; QLabel *m_labelEditName = nullptr;
QLineEdit *m_editName = nullptr; LineEdit *m_editName = nullptr;
QToolButton *m_btGetName = nullptr; QToolButton *m_btGetName = nullptr;
QLabel *m_labelEditNotes = nullptr; QLabel *m_labelEditNotes = nullptr;
PlainTextEdit *m_editNotes = nullptr; PlainTextEdit *m_editNotes = nullptr;
@ -129,7 +129,7 @@ private:
QCheckBox *m_cbLogConn = nullptr; QCheckBox *m_cbLogConn = nullptr;
QCheckBox *m_cbLanOnly = nullptr; QCheckBox *m_cbLanOnly = nullptr;
ZonesSelector *m_btZones = nullptr; ZonesSelector *m_btZones = nullptr;
QLineEdit *m_editRuleName = nullptr; LineEdit *m_editRuleName = nullptr;
QToolButton *m_btSelectRule = nullptr; QToolButton *m_btSelectRule = nullptr;
QCheckBox *m_cbSchedule = nullptr; QCheckBox *m_cbSchedule = nullptr;
QComboBox *m_comboScheduleAction = nullptr; QComboBox *m_comboScheduleAction = nullptr;

View File

@ -5,13 +5,13 @@
#include <QFormLayout> #include <QFormLayout>
#include <QFrame> #include <QFrame>
#include <QLabel> #include <QLabel>
#include <QLineEdit>
#include <QPushButton> #include <QPushButton>
#include <QRadioButton> #include <QRadioButton>
#include <QVBoxLayout> #include <QVBoxLayout>
#include <conf/confrulemanager.h> #include <conf/confrulemanager.h>
#include <form/controls/controlutil.h> #include <form/controls/controlutil.h>
#include <form/controls/lineedit.h>
#include <form/controls/plaintextedit.h> #include <form/controls/plaintextedit.h>
#include <form/controls/zonesselector.h> #include <form/controls/zonesselector.h>
#include <manager/windowmanager.h> #include <manager/windowmanager.h>
@ -174,7 +174,7 @@ QLayout *RuleEditDialog::setupFormLayout()
layout->setHorizontalSpacing(10); layout->setHorizontalSpacing(10);
// Name // Name
m_editName = new QLineEdit(); m_editName = new LineEdit();
m_editName->setMaxLength(1024); m_editName->setMaxLength(1024);
layout->addRow("Name:", m_editName); layout->addRow("Name:", m_editName);

View File

@ -8,11 +8,11 @@
QT_FORWARD_DECLARE_CLASS(QCheckBox) QT_FORWARD_DECLARE_CLASS(QCheckBox)
QT_FORWARD_DECLARE_CLASS(QComboBox) QT_FORWARD_DECLARE_CLASS(QComboBox)
QT_FORWARD_DECLARE_CLASS(QLabel) QT_FORWARD_DECLARE_CLASS(QLabel)
QT_FORWARD_DECLARE_CLASS(QLineEdit)
QT_FORWARD_DECLARE_CLASS(QPushButton) QT_FORWARD_DECLARE_CLASS(QPushButton)
QT_FORWARD_DECLARE_CLASS(QRadioButton) QT_FORWARD_DECLARE_CLASS(QRadioButton)
class ConfRuleManager; class ConfRuleManager;
class LineEdit;
class PlainTextEdit; class PlainTextEdit;
class Rule; class Rule;
class RulesController; class RulesController;
@ -59,7 +59,7 @@ private:
RulesController *m_ctrl = nullptr; RulesController *m_ctrl = nullptr;
QLabel *m_labelEditName = nullptr; QLabel *m_labelEditName = nullptr;
QLineEdit *m_editName = nullptr; LineEdit *m_editName = nullptr;
QLabel *m_labelEditNotes = nullptr; QLabel *m_labelEditNotes = nullptr;
PlainTextEdit *m_editNotes = nullptr; PlainTextEdit *m_editNotes = nullptr;
QLabel *m_labelRuleType = nullptr; QLabel *m_labelRuleType = nullptr;

View File

@ -5,11 +5,11 @@
#include <QFormLayout> #include <QFormLayout>
#include <QFrame> #include <QFrame>
#include <QLabel> #include <QLabel>
#include <QLineEdit>
#include <QPushButton> #include <QPushButton>
#include <QVBoxLayout> #include <QVBoxLayout>
#include <form/controls/controlutil.h> #include <form/controls/controlutil.h>
#include <form/controls/lineedit.h>
#include <form/controls/plaintextedit.h> #include <form/controls/plaintextedit.h>
#include <manager/windowmanager.h> #include <manager/windowmanager.h>
#include <model/zonesourcewrapper.h> #include <model/zonesourcewrapper.h>
@ -140,7 +140,7 @@ QLayout *ZoneEditDialog::setupNameLayout()
auto layout = new QFormLayout(); auto layout = new QFormLayout();
// Name // Name
m_editName = new QLineEdit(); m_editName = new LineEdit();
m_editName->setMaxLength(256); m_editName->setMaxLength(256);
layout->addRow("Name:", m_editName); layout->addRow("Name:", m_editName);
@ -196,7 +196,7 @@ QLayout *ZoneEditDialog::setupUrlLayout()
formLayout->addRow(QString(), m_cbCustomUrl); formLayout->addRow(QString(), m_cbCustomUrl);
// URL // URL
m_editUrl = new QLineEdit(); m_editUrl = new LineEdit();
m_editUrl->setEnabled(false); m_editUrl->setEnabled(false);
m_editUrl->setMaxLength(1024); m_editUrl->setMaxLength(1024);
@ -204,7 +204,7 @@ QLayout *ZoneEditDialog::setupUrlLayout()
m_labelUrl = ControlUtil::formRowLabel(formLayout, m_editUrl); m_labelUrl = ControlUtil::formRowLabel(formLayout, m_editUrl);
// Form Data // Form Data
m_editFormData = new QLineEdit(); m_editFormData = new LineEdit();
m_editFormData->setEnabled(false); m_editFormData->setEnabled(false);
formLayout->addRow("Form Data:", m_editFormData); formLayout->addRow("Form Data:", m_editFormData);

View File

@ -9,9 +9,9 @@ QT_FORWARD_DECLARE_CLASS(QCheckBox)
QT_FORWARD_DECLARE_CLASS(QComboBox) QT_FORWARD_DECLARE_CLASS(QComboBox)
QT_FORWARD_DECLARE_CLASS(QFrame) QT_FORWARD_DECLARE_CLASS(QFrame)
QT_FORWARD_DECLARE_CLASS(QLabel) QT_FORWARD_DECLARE_CLASS(QLabel)
QT_FORWARD_DECLARE_CLASS(QLineEdit)
QT_FORWARD_DECLARE_CLASS(QPushButton) QT_FORWARD_DECLARE_CLASS(QPushButton)
class LineEdit;
class PlainTextEdit; class PlainTextEdit;
class Zone; class Zone;
class ZoneListModel; class ZoneListModel;
@ -61,16 +61,16 @@ private:
ZonesController *m_ctrl = nullptr; ZonesController *m_ctrl = nullptr;
QLabel *m_labelName = nullptr; QLabel *m_labelName = nullptr;
QLineEdit *m_editName = nullptr; LineEdit *m_editName = nullptr;
QLabel *m_labelSource = nullptr; QLabel *m_labelSource = nullptr;
QCheckBox *m_cbEnabled = nullptr; QCheckBox *m_cbEnabled = nullptr;
QFrame *m_frameUrl = nullptr; QFrame *m_frameUrl = nullptr;
QCheckBox *m_cbCustomUrl = nullptr; QCheckBox *m_cbCustomUrl = nullptr;
QComboBox *m_comboSources = nullptr; QComboBox *m_comboSources = nullptr;
QLabel *m_labelUrl = nullptr; QLabel *m_labelUrl = nullptr;
QLineEdit *m_editUrl = nullptr; LineEdit *m_editUrl = nullptr;
QLabel *m_labelFormData = nullptr; QLabel *m_labelFormData = nullptr;
QLineEdit *m_editFormData = nullptr; LineEdit *m_editFormData = nullptr;
QFrame *m_frameText = nullptr; QFrame *m_frameText = nullptr;
PlainTextEdit *m_editText = nullptr; PlainTextEdit *m_editText = nullptr;
QPushButton *m_btOk = nullptr; QPushButton *m_btOk = nullptr;