Allow specifying a fixed geometry for the results list viewport by setting RECOLL_RESULTS_GEOMETRY=widthxheight

This commit is contained in:
Jean-Francois Dockes 2022-08-20 17:13:10 +02:00
parent 64a72be069
commit a7d86cb64c
2 changed files with 41 additions and 0 deletions

View File

@ -45,6 +45,7 @@
#include <QToolTip>
#include <QStandardItemModel>
#include <QActionGroup>
#include <QScrollArea>
#include "recoll.h"
#include "log.h"
@ -132,6 +133,10 @@ void RclMain::init()
buildMenus();
if (getenv("RECOLL_RESULTS_GEOMETRY")) {
resultsSetFixedGeometry();
}
periodictimer = new QTimer(this);
// idxstatus file. Make sure it exists before trying to watch it
@ -1305,3 +1310,38 @@ void RclMain::applyStyleSheet()
resetSearch();
}
}
void RclMain::resultsSetFixedGeometry()
{
const char *cp = getenv("RECOLL_RESULTS_GEOMETRY");
if (nullptr == cp)
return;
std::vector<std::string> swh;
stringToTokens(cp, swh, "xX");
if (swh.size() != 2) {
LOGERR("Bad RECOLL_RESULTS_GEOMETRY: " << cp);
return;
}
int w = atoi(swh[0].c_str());
int h = atoi(swh[1].c_str());
if (w <= 0 || h <= 0) {
LOGERR("Bad RECOLL_RESULTS_GEOMETRY: " << cp);
return;
}
resultsLayoutWidget->setParent(nullptr);
auto scrollArea = new QScrollArea(sideFiltersSPLT);
scrollArea->setObjectName(QString::fromUtf8("scrollArea"));
scrollArea->setWidgetResizable(true);
reslist->setGeometry(QRect(0, 0, w, h));
QSizePolicy sizePolicy2(QSizePolicy::Fixed, QSizePolicy::Fixed);
sizePolicy2.setHorizontalStretch(0);
sizePolicy2.setVerticalStretch(0);
sizePolicy2.setHeightForWidth(reslist->sizePolicy().hasHeightForWidth());
reslist->setSizePolicy(sizePolicy2);
reslist->setMinimumSize(QSize(w, h));
reslist->setMaximumSize(QSize(w, h));
scrollArea->setWidget(resultsLayoutWidget);
sideFiltersSPLT->replaceWidget(1, scrollArea);
}

View File

@ -298,6 +298,7 @@ private:
virtual bool containerUpToDate(Rcl::Doc& doc);
virtual bool checkIdxPaths();
virtual std::vector<std::string> idxTreeGetDirs();
virtual void resultsSetFixedGeometry();
};
#endif // RCLMAIN_W_H