mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +08:00
attachment_list: fix editor style
This commit is contained in:
parent
a2849ed577
commit
1a62ca15e7
45
src/lineeditdelegate.cpp
Normal file
45
src/lineeditdelegate.cpp
Normal file
@ -0,0 +1,45 @@
|
||||
#include "lineeditdelegate.h"
|
||||
|
||||
#include <QLineEdit>
|
||||
|
||||
|
||||
LineEditDelegate::LineEditDelegate(QObject *p_parent)
|
||||
: QStyledItemDelegate(p_parent)
|
||||
{
|
||||
}
|
||||
|
||||
QWidget *LineEditDelegate::createEditor(QWidget *p_parent,
|
||||
const QStyleOptionViewItem &p_option,
|
||||
const QModelIndex &p_index) const
|
||||
{
|
||||
Q_UNUSED(p_option);
|
||||
Q_UNUSED(p_index);
|
||||
|
||||
QLineEdit *edit = new QLineEdit(p_parent);
|
||||
return edit;
|
||||
}
|
||||
|
||||
void LineEditDelegate::setEditorData(QWidget *p_editor, const QModelIndex &p_index) const
|
||||
{
|
||||
QString text = p_index.model()->data(p_index, Qt::EditRole).toString();
|
||||
|
||||
QLineEdit *edit = static_cast<QLineEdit *>(p_editor);
|
||||
edit->setText(text);
|
||||
}
|
||||
|
||||
void LineEditDelegate::setModelData(QWidget *p_editor,
|
||||
QAbstractItemModel *p_model,
|
||||
const QModelIndex &p_index) const
|
||||
{
|
||||
QLineEdit *edit = static_cast<QLineEdit *>(p_editor);
|
||||
|
||||
p_model->setData(p_index, edit->text(), Qt::EditRole);
|
||||
}
|
||||
|
||||
void LineEditDelegate::updateEditorGeometry(QWidget *p_editor,
|
||||
const QStyleOptionViewItem &p_option,
|
||||
const QModelIndex &p_index) const
|
||||
{
|
||||
Q_UNUSED(p_index);
|
||||
p_editor->setGeometry(p_option.rect);
|
||||
}
|
28
src/lineeditdelegate.h
Normal file
28
src/lineeditdelegate.h
Normal file
@ -0,0 +1,28 @@
|
||||
#ifndef LINEEDITDELEGATE_H
|
||||
#define LINEEDITDELEGATE_H
|
||||
|
||||
#include <QStyledItemDelegate>
|
||||
|
||||
|
||||
class LineEditDelegate : public QStyledItemDelegate
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
LineEditDelegate(QObject *p_parent = nullptr);
|
||||
|
||||
QWidget *createEditor(QWidget *p_parent,
|
||||
const QStyleOptionViewItem &p_option,
|
||||
const QModelIndex &p_index) const Q_DECL_OVERRIDE;
|
||||
|
||||
void setEditorData(QWidget *p_editor, const QModelIndex &p_index) const Q_DECL_OVERRIDE;
|
||||
|
||||
void setModelData(QWidget *p_editor,
|
||||
QAbstractItemModel *p_model,
|
||||
const QModelIndex &p_index) const Q_DECL_OVERRIDE;
|
||||
|
||||
void updateEditorGeometry(QWidget *p_editor,
|
||||
const QStyleOptionViewItem &p_option,
|
||||
const QModelIndex &p_index) const Q_DECL_OVERRIDE;
|
||||
};
|
||||
|
||||
#endif // LINEEDITDELEGATE_H
|
@ -214,7 +214,7 @@ combobox_focus_bg=@edit_focus_bg
|
||||
combobox_focus_border=@edit_focus_border
|
||||
combobox_item_icon_fg=@item_icon_fg
|
||||
|
||||
combobox_notebookselector_fg=@master_bg
|
||||
combobox_notebookselector_fg=@master_pressed_bg
|
||||
combobox_notebookselector_bg=@combobox_bg
|
||||
combobox_notebookselector_border=@master_bg
|
||||
combobox_notebookselector_hover_fg=@master_bg
|
||||
|
@ -671,11 +671,6 @@ QLineEdit[VimCommandLine="true"] {
|
||||
color: @lineedit_fg;
|
||||
background: @lineedit_bg;
|
||||
}
|
||||
|
||||
QAbstractItemView QLineEdit {
|
||||
padding: 0px;
|
||||
margin: 0px;
|
||||
}
|
||||
/* End QLineEdit */
|
||||
|
||||
/* QPlainTextEdit QTextEdit */
|
||||
|
@ -258,7 +258,6 @@ listview_item_selected_inactive_bg=@inactive_bg
|
||||
|
||||
; Splitter.
|
||||
splitter_handle_bg=@title_bg
|
||||
splitter_mainsplitter_border=@title_bg
|
||||
|
||||
; StatusBar.
|
||||
statusbar_fg=@main_fg
|
||||
|
@ -583,11 +583,6 @@ QLineEdit[VimCommandLine="true"] {
|
||||
color: @lineedit_fg;
|
||||
background: @lineedit_bg;
|
||||
}
|
||||
|
||||
QAbstractItemView QLineEdit {
|
||||
padding: 0px;
|
||||
margin: 0px;
|
||||
}
|
||||
/* End QLineEdit */
|
||||
|
||||
/* QTabWidget */
|
||||
@ -605,27 +600,23 @@ QTabWidget::pane {
|
||||
QTabBar::tab {
|
||||
color: @tabbar_fg;
|
||||
background: @tabbar_bg;
|
||||
border: 1px solid @tabbar_border;
|
||||
border-bottom: none;
|
||||
border: none;
|
||||
border-right: 1px solid @tabbar_border;
|
||||
padding: 2px;
|
||||
}
|
||||
|
||||
QTabBar::tab:selected {
|
||||
color: @tabbar_selected_fg;
|
||||
background: @tabbar_selected_bg;
|
||||
border: 1px solid @tabbar_selected_border;
|
||||
border-bottom: none;
|
||||
border: none;
|
||||
border-right: 1px solid @tabbar_border;
|
||||
}
|
||||
|
||||
QTabBar::tab:hover {
|
||||
color: @tabbar_hover_fg;
|
||||
background: @tabbar_hover_bg;
|
||||
border: 1px solid @tabbar_hover_border;
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
QTabBar::tab:!selected {
|
||||
margin-top: 2px; /* make non-selected tabs look smaller */
|
||||
border: none;
|
||||
border-right: 1px solid @tabbar_border;
|
||||
}
|
||||
|
||||
QTabBar::close-button {
|
||||
@ -793,10 +784,6 @@ QSplitter::handle:vertical {
|
||||
QSplitter::handle:horizontal {
|
||||
width: 2px;
|
||||
}
|
||||
|
||||
QSplitter#MainSplitter {
|
||||
border-top: 2px solid @splitter_mainsplitter_border;
|
||||
}
|
||||
/* End QSplitter */
|
||||
|
||||
/* QStatusBar */
|
||||
|
@ -101,7 +101,8 @@ SOURCES += main.cpp\
|
||||
utils/vclipboardutils.cpp \
|
||||
vpalette.cpp \
|
||||
vbuttonmenuitem.cpp \
|
||||
utils/viconutils.cpp
|
||||
utils/viconutils.cpp \
|
||||
lineeditdelegate.cpp
|
||||
|
||||
HEADERS += vmainwindow.h \
|
||||
vdirectorytree.h \
|
||||
@ -189,7 +190,8 @@ HEADERS += vmainwindow.h \
|
||||
utils/vclipboardutils.h \
|
||||
vpalette.h \
|
||||
vbuttonmenuitem.h \
|
||||
utils/viconutils.h
|
||||
utils/viconutils.h \
|
||||
lineeditdelegate.h
|
||||
|
||||
RESOURCES += \
|
||||
vnote.qrc \
|
||||
|
@ -102,6 +102,7 @@ void VAttachmentList::setupUI()
|
||||
m_attachmentList->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||
m_attachmentList->setEditTriggers(QAbstractItemView::SelectedClicked);
|
||||
m_attachmentList->setAttribute(Qt::WA_MacShowFocusRect, false);
|
||||
m_attachmentList->setItemDelegate(&m_listDelegate);
|
||||
connect(m_attachmentList, &QListWidget::customContextMenuRequested,
|
||||
this, &VAttachmentList::handleContextMenuRequested);
|
||||
connect(m_attachmentList, &QListWidget::itemActivated,
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include <QStringList>
|
||||
#include "vnotefile.h"
|
||||
#include "vbuttonwithwidget.h"
|
||||
#include "lineeditdelegate.h"
|
||||
|
||||
class QPushButton;
|
||||
class QListWidget;
|
||||
@ -14,6 +15,7 @@ class QLabel;
|
||||
class VNoteFile;
|
||||
class QAction;
|
||||
|
||||
|
||||
class VAttachmentList : public QWidget, public VButtonPopupWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -70,6 +72,7 @@ private:
|
||||
QPushButton *m_locateBtn;
|
||||
QLabel *m_numLabel;
|
||||
|
||||
LineEditDelegate m_listDelegate;
|
||||
QListWidget *m_attachmentList;
|
||||
|
||||
QAction *m_openAct;
|
||||
|
Loading…
x
Reference in New Issue
Block a user