window: get number of columns from config
这个提交包含在:
父节点
416bfa6314
当前提交
5eb09540c6
@ -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;
|
||||
|
正在加载...
在新工单中引用
屏蔽一个用户