refine QFormLayout policy for VSearcher on macOS

This commit is contained in:
Le Tan 2018-05-14 20:39:49 +08:00
parent 4174055574
commit f8717465c3
3 changed files with 19 additions and 2 deletions

View File

@ -26,6 +26,7 @@
#include <QWebEngineView>
#include <QAction>
#include <QTreeWidgetItem>
#include <QFormLayout>
#include "vorphanfile.h"
#include "vnote.h"
@ -1514,3 +1515,15 @@ QPixmap VUtils::pixmapFromFile(const QString &p_filePath)
qDebug() << "pixmapFromFile" << p_filePath << pixmap.isNull();
return pixmap;
}
QFormLayout *VUtils::getFormLayout()
{
QFormLayout *layout = new QFormLayout();
#if defined(Q_OS_MACOS) || defined(Q_OS_MAC)
layout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);
layout->setFormAlignment(Qt::AlignLeft | Qt::AlignTop);
#endif
return layout;
}

View File

@ -20,6 +20,7 @@ class QComboBox;
class QWebEngineView;
class QAction;
class QTreeWidgetItem;
class QFormLayout;
#if !defined(V_ASSERT)
#define V_ASSERT(cond) ((!(cond)) ? qt_assert(#cond, __FILE__, __LINE__) : qt_noop())
@ -327,6 +328,9 @@ public:
static QPixmap pixmapFromFile(const QString &p_filePath);
// Return QFormLayout.
static QFormLayout *getFormLayout();
// Regular expression for image link.
// ![image title]( http://github.com/tamlok/vnote.jpg "alt text" =200x100)
// Captured texts (need to be trimmed):

View File

@ -171,7 +171,7 @@ void VSearcher::setupUI()
m_fuzzyCB->setEnabled(!checked);
});
QFormLayout *advLayout = new QFormLayout();
QFormLayout *advLayout = VUtils::getFormLayout();
advLayout->addRow(tr("File pattern:"), m_filePatternCB);
advLayout->addRow(tr("Engine:"), m_searchEngineCB);
advLayout->addRow(m_caseSensitiveCB);
@ -226,7 +226,7 @@ void VSearcher::setupUI()
updateNumLabel(p_count);
});
QFormLayout *formLayout = new QFormLayout();
QFormLayout *formLayout = VUtils::getFormLayout();
formLayout->addRow(tr("Keywords:"), m_keywordCB);
formLayout->addRow(tr("Scope:"), m_searchScopeCB);
formLayout->addRow(tr("Object:"), m_searchObjectCB);