refine interfaces

This commit is contained in:
Le Tan 2018-03-28 19:36:35 +08:00
parent b09320e666
commit 4727d0aa98
16 changed files with 65 additions and 42 deletions

View File

@ -6,7 +6,7 @@ qss_file=v_material.qss
mdhl_file=v_material.mdhl
css_file=v_material.css
codeblock_css_file=v_material_codeblock.css
vsersion=1
version=2
[phony]
; Abstract color attributes.

View File

@ -10,11 +10,6 @@ QWidget
{
color: @widget_fg;
}
QWidget[NotebookPanel="true"] {
padding-left: 3px;
}
/* End QWidget */
/* QMainWindow */

View File

@ -7,7 +7,7 @@ mdhl_file=v_moonlight.mdhl
css_file=v_moonlight.css
codeblock_css_file=v_moonlight_codeblock.css
mermaid_css_file=v_moonlight_mermaid.css
version=6
version=7
; This mapping will be used to translate colors when the content of HTML is copied
; without background. You could just specify the foreground colors mapping here.

View File

@ -6,10 +6,6 @@ QToolTip
}
/* QWidget */
QWidget[NotebookPanel="true"] {
padding-left: 3px;
}
QWidget#FindReplaceTitleWidget {
background: @title_bg;
}

View File

@ -7,7 +7,7 @@ mdhl_file=v_native.mdhl
css_file=v_native.css
codeblock_css_file=v_native_codeblock.css
mermaid_css_file=v_native_mermaid.css
version=6
version=7
[phony]
; Abstract color attributes.

View File

@ -4,10 +4,6 @@ QWidget
color: @widget_fg;
font-family: "Hiragino Sans GB", "冬青黑体", "Microsoft YaHei", "微软雅黑", "Microsoft YaHei UI", "WenQuanYi Micro Hei", "文泉驿雅黑", "Dengxian", "等线体", "STXihei", "华文细黑", "Liberation Sans", "Droid Sans", "NSimSun", "新宋体", "SimSun", "宋体", "Helvetica", "sans-serif", "Tahoma", "Arial", "Verdana", "Geneva", "Georgia", "Times New Roman";
}
QWidget[NotebookPanel="true"] {
padding-left: 3px;
}
/* End QWidget */
/* QMenuBar */

View File

@ -7,7 +7,7 @@ mdhl_file=v_pure.mdhl
css_file=v_pure.css
codeblock_css_file=v_pure_codeblock.css
mermaid_css_file=v_pure_mermaid.css
version=6
version=7
[phony]
; Abstract color attributes.

View File

@ -6,10 +6,6 @@ QToolTip
}
/* QWidget */
QWidget[NotebookPanel="true"] {
padding-left: 3px;
}
QWidget#FindReplaceTitleWidget {
background: @title_bg;
}

View File

@ -19,6 +19,8 @@ VCart::VCart(QWidget *p_parent)
{
setupUI();
updateNumberLabel();
initActions();
}
@ -40,6 +42,7 @@ void VCart::setupUI()
MessageBoxType::Danger);
if (ret == QMessageBox::Ok) {
m_itemList->clear();
updateNumberLabel();
}
}
});
@ -158,14 +161,7 @@ void VCart::addItem(const QString &p_path)
item->setData(Qt::UserRole, p_path);
m_itemList->addItem(item);
int cnt = m_itemList->count();
if (cnt > 0) {
m_numLabel->setText(tr("%1 %2").arg(cnt)
.arg(cnt > 1 ? tr("Items") : tr("Item")));
} else {
m_numLabel->setText("");
}
updateNumberLabel();
}
void VCart::deleteSelectedItems()
@ -263,3 +259,10 @@ void VCart::sortItems()
VListWidget::sortListWidget(m_itemList, sortedIdx);
}
}
void VCart::updateNumberLabel() const
{
int cnt = m_itemList->count();
m_numLabel->setText(tr("%1 %2").arg(cnt)
.arg(cnt > 1 ? tr("Items") : tr("Item")));
}

View File

@ -51,6 +51,8 @@ private:
QString getFilePath(const QListWidgetItem *p_item) const;
void updateNumberLabel() const;
QPushButton *m_clearBtn;
QLabel *m_numLabel;
QListWidget *m_itemList;

View File

@ -56,10 +56,24 @@ VFileList::VFileList(QWidget *parent)
fileList->setFocus();
}
});
updateNumberLabel();
}
void VFileList::setupUI()
{
QLabel *titleLabel = new QLabel(tr("Notes"), this);
titleLabel->setProperty("TitleLabel", true);
m_numLabel = new QLabel(this);
QHBoxLayout *titleLayout = new QHBoxLayout();
titleLayout->addWidget(titleLabel);
titleLayout->addStretch();
titleLayout->addWidget(m_numLabel);
titleLayout->setContentsMargins(0, 0, 0, 0);
fileList = new VListWidget(this);
fileList->setContextMenuPolicy(Qt::CustomContextMenu);
fileList->setSelectionMode(QAbstractItemView::ExtendedSelection);
@ -67,6 +81,7 @@ void VFileList::setupUI()
fileList->setAttribute(Qt::WA_MacShowFocusRect, false);
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addLayout(titleLayout);
mainLayout->addWidget(fileList);
mainLayout->setContentsMargins(0, 0, 0, 0);
@ -198,6 +213,7 @@ void VFileList::setDirectory(VDirectory *p_directory)
if (m_directory == p_directory) {
if (!m_directory) {
fileList->clearAll();
updateNumberLabel();
}
return;
@ -206,6 +222,7 @@ void VFileList::setDirectory(VDirectory *p_directory)
m_directory = p_directory;
if (!m_directory) {
fileList->clearAll();
updateNumberLabel();
return;
}
@ -224,6 +241,8 @@ void VFileList::updateFileList()
VNoteFile *file = files[i];
insertFileListItem(file);
}
updateNumberLabel();
}
void VFileList::fileInfo()
@ -1188,3 +1207,10 @@ void VFileList::handleOpenWithActionTriggered()
}
}
}
void VFileList::updateNumberLabel() const
{
int cnt = fileList->count();
m_numLabel->setText(tr("%1 %2").arg(cnt)
.arg(cnt > 1 ? tr("Items") : tr("Item")));
}

View File

@ -166,8 +166,14 @@ private:
void activateItem(QListWidgetItem *p_item, bool p_restoreFocus = false);
void updateNumberLabel() const;
VEditArea *editArea;
VListWidget *fileList;
QLabel *m_numLabel;
QPointer<VDirectory> m_directory;
// Magic number for clipboard operations.

View File

@ -276,22 +276,18 @@ void VMainWindow::setupUI()
QWidget *VMainWindow::setupDirectoryPanel()
{
// Notebook selector.
notebookLabel = new QLabel(tr("Notebooks"));
QLabel *notebookLabel = new QLabel(tr("Notebooks"));
notebookLabel->setProperty("TitleLabel", true);
notebookLabel->setProperty("NotebookPanel", true);
notebookSelector = new VNotebookSelector();
notebookSelector->setObjectName("NotebookSelector");
notebookSelector->setProperty("NotebookPanel", true);
notebookSelector->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLengthWithIcon);
// Navigation panel.
directoryLabel = new QLabel(tr("Folders"));
QLabel *directoryLabel = new QLabel(tr("Folders"));
directoryLabel->setProperty("TitleLabel", true);
directoryLabel->setProperty("NotebookPanel", true);
directoryTree = new VDirectoryTree;
directoryTree->setProperty("NotebookPanel", true);
QVBoxLayout *naviLayout = new QVBoxLayout;
naviLayout->addWidget(directoryLabel);
@ -318,10 +314,9 @@ QWidget *VMainWindow::setupDirectoryPanel()
nbLayout->addWidget(notebookLabel);
nbLayout->addWidget(notebookSelector);
nbLayout->addWidget(m_naviSplitter);
nbLayout->setContentsMargins(0, 0, 0, 0);
nbLayout->setContentsMargins(3, 0, 0, 0);
nbLayout->setSpacing(0);
QWidget *nbContainer = new QWidget();
nbContainer->setObjectName("NotebookPanel");
nbContainer->setLayout(nbLayout);
nbContainer->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Expanding);

View File

@ -315,8 +315,6 @@ private:
VCaptain *m_captain;
QLabel *notebookLabel;
QLabel *directoryLabel;
VNotebookSelector *notebookSelector;
VFileList *m_fileList;
VDirectoryTree *directoryTree;

View File

@ -39,6 +39,8 @@ VSnippetList::VSnippetList(QWidget *p_parent)
}
updateContent();
updateNumberLabel();
}
void VSnippetList::setupUI()
@ -394,13 +396,12 @@ void VSnippetList::updateContent()
int cnt = m_snippetList->count();
if (cnt > 0) {
m_numLabel->setText(tr("%1 %2").arg(cnt)
.arg(cnt > 1 ? tr("Snippets") : tr("Snippet")));
m_snippetList->setFocus();
} else {
m_numLabel->setText("");
m_addBtn->setFocus();
}
updateNumberLabel();
}
bool VSnippetList::addSnippet(const VSnippet &p_snippet, QString *p_errMsg)
@ -623,3 +624,10 @@ void VSnippetList::focusInEvent(QFocusEvent *p_event)
m_snippetList->setFocus();
}
}
void VSnippetList::updateNumberLabel() const
{
int cnt = m_snippetList->count();
m_numLabel->setText(tr("%1 %2").arg(cnt)
.arg(cnt > 1 ? tr("Items") : tr("Item")));
}

View File

@ -87,6 +87,8 @@ private:
bool deleteSnippetFile(const VSnippet &p_snippet, QString *p_errMsg = nullptr);
void updateNumberLabel() const;
QPushButton *m_addBtn;
QPushButton *m_locateBtn;
QLabel *m_numLabel;