window: get number of columns from config

This commit is contained in:
Albert S. 2020-09-07 23:29:10 +02:00
父節點 416bfa6314
當前提交 5eb09540c6
共有 3 個文件被更改,包括 16 次插入10 次删除

查看文件

@ -1,6 +1,6 @@
#include "settingsprovider.h"
#include <QFileInfo>
#include <QDir>
#include <QFileInfo>
SettingsProvider::SettingsProvider(QSettings &settings)
{
@ -9,9 +9,9 @@ SettingsProvider::SettingsProvider(QSettings &settings)
QStringList SettingsProvider::userEntriesPaths() const
{
//TODO: make it configurable, but we stick with this for now.
// TODO: make it configurable, but we stick with this for now.
QFileInfo fi(this->settings->fileName());
return { fi.absoluteDir().absolutePath() };
return {fi.absoluteDir().absolutePath()};
}
QStringList SettingsProvider::systemApplicationsEntriesPaths() const
@ -19,9 +19,12 @@ QStringList SettingsProvider::systemApplicationsEntriesPaths() const
return settings->value("sysAppsPaths", "/usr/share/applications/").toStringList();
}
int SettingsProvider::getMaxCols() const
{
return settings->value("maxColumns", 3).toInt();
}
bool SettingsProvider::singleInstanceMode() const
{
return settings->value("singleInstance", true).toBool();
}

查看文件

@ -1,17 +1,19 @@
#ifndef SETTINGSPROVIDER_H
#define SETTINGSPROVIDER_H
#include <stdexcept>
#include <QSettings>
#include <stdexcept>
class SettingsProvider
{
private:
private:
QSettings *settings;
public:
public:
SettingsProvider(QSettings &settings);
virtual QStringList userEntriesPaths() const;
virtual QStringList systemApplicationsEntriesPaths() const;
virtual int getMaxCols() const;
virtual bool singleInstanceMode() const;
};

查看文件

@ -28,8 +28,8 @@
#include <QProcessEnvironment>
#include <QScrollArea>
#include "window.h"
#include "entryprovider.h"
#include "window.h"
Window::Window(EntryProvider &entryProvider, SettingsProvider &configProvider)
{
this->entryProvider = &entryProvider;
@ -324,6 +324,7 @@ void Window::filterGridFor(QString filter)
int currow = 0;
int curcol = 0;
int i = 1;
const int MAX_COLS = this->settingsProvider->getMaxCols();
for(EntryPushButton *button : this->systemEntryButtons)
{
if(button->getName().contains(filter, Qt::CaseInsensitive))
@ -335,7 +336,7 @@ void Window::filterGridFor(QString filter)
}
grid->addWidget(button, currow, curcol++);
this->buttonsInGrid.append(button);
if(curcol == 3)
if(curcol == MAX_COLS)
{
curcol = 0;
++currow;