Compare commits

..

No commits in common. "776cbe4d3096ff0b2278682d1149e01b581c07b8" and "b588fd07be537f2db7d1c97966b50d2f71bba872" have entirely different histories.

6 changed files with 79 additions and 442 deletions

View File

@ -56,7 +56,7 @@ EntryConfig EntryProvider::readFromDesktopFile(const QString &path)
} }
if(key == "icon") if(key == "icon")
{ {
result.iconPath = args; result.icon = QIcon::fromTheme(args);
} }
if(key == "exec") if(key == "exec")
{ {
@ -80,7 +80,6 @@ EntryConfig EntryProvider::readFromDesktopFile(const QString &path)
result.hidden = args == "true"; result.hidden = args == "true";
} }
} }
result.type = EntryType::SYSTEM;
return result; return result;
} }
@ -113,71 +112,19 @@ EntryConfig EntryProvider::readqsrunFile(const QString &path)
// TODO: better exception class // TODO: better exception class
throw new std::runtime_error("Failed to open file"); throw new std::runtime_error("Failed to open file");
} }
QHash<QString, QString> map;
QTextStream stream(&file); QTextStream stream(&file);
while(!stream.atEnd()) while(!stream.atEnd())
{ {
QString line = stream.readLine(); QString line = stream.readLine();
QStringList splitted = line.split(" ");
int spacePos = line.indexOf(' '); if(splitted.length() < 2)
if(spacePos == -1)
{ {
throw new ConfigFormatException("misformated line in .qsrun config file " + path.toStdString()); throw new ConfigFormatException("misformated line in .qsrun config file " + path.toStdString());
} }
QString key = splitted[0];
QString key = line.mid(0, spacePos); if(key == "arguments")
QString value = line.mid(spacePos + 1);
if(key == "" || value == "")
{ {
throw new ConfigFormatException("empty key or value in .qsrun config file " + path.toStdString()); auto args = splitted.mid(1);
}
map[key] = value;
}
if(map.contains("inherit"))
{
auto entry = readEntryFromPath(map["inherit"]);
if(entry)
{
result = entry.value();
result.inherit = map["inherit"];
}
else
{
throw new ConfigFormatException("Error attempting to read inherited entry");
}
}
QString type = map["type"];
if(!type.isEmpty())
{
if(type == "system")
{
throw new ConfigFormatException(".qsrun files cannot be designated as system entries " +
path.toStdString());
}
else if(type == "inherit")
{
result.type = EntryType::INHERIT;
}
else if(type == "user")
{
result.type = EntryType::USER;
}
else
{
throw new ConfigFormatException("Invalid value for type provided in file: " + path.toStdString());
}
}
else
{
result.type = EntryType::USER;
}
if(result.type != EntryType::INHERIT)
{
if(map.contains("arguments"))
{
auto args = map["arguments"].split(' ');
QString merged; QString merged;
for(QString &str : args) for(QString &str : args)
{ {
@ -206,20 +153,42 @@ EntryConfig EntryProvider::readqsrunFile(const QString &path)
throw ConfigFormatException("non-closed \" in config file " + path.toStdString()); throw ConfigFormatException("non-closed \" in config file " + path.toStdString());
} }
} }
auto assignIfSourceNotEmpty = [](QString source, QString &val) { if(key == "name")
if(!source.isEmpty())
{ {
val = source; result.name = splitted.mid(1).join(' ');
} }
}; if(key == "icon")
assignIfSourceNotEmpty(map["key"].toLower(), result.key); {
assignIfSourceNotEmpty(map["command"], result.command); result.icon = QIcon(splitted[1]);
assignIfSourceNotEmpty(map["icon"], result.iconPath);
assignIfSourceNotEmpty(map["name"], result.name);
} }
result.col = map["col"].toInt(); if(key == "row")
result.row = map["row"].toInt(); {
return result; result.row = splitted[1].toInt();
}
if(key == "col")
{
result.col = splitted[1].toInt();
}
if(key == "command")
{
result.command = splitted[1];
}
if(key == "key")
{
// QKeySequence sequence(splitted[1]);
// result.keySequence = sequence;
result.key = splitted[1].toLower();
}
if(key == "inherit")
{
auto entry = readEntryFromPath(resolveEntryPath(splitted[1]));
if(entry)
{
inheritedConfig = *entry;
}
}
}
return result.update(inheritedConfig);
} }
QString EntryProvider::resolveEntryPath(QString path) QString EntryProvider::resolveEntryPath(QString path)
@ -259,7 +228,6 @@ QVector<EntryConfig> EntryProvider::readConfig(QStringList paths)
{ {
if(!entry->hidden) if(!entry->hidden)
{ {
entry->entryPath = path;
result.append(*entry); result.append(*entry);
} }
} }
@ -278,70 +246,6 @@ QVector<EntryConfig> EntryProvider::getSystemEntries()
return readConfig(this->systemEntriesDirsPaths); return readConfig(this->systemEntriesDirsPaths);
} }
void EntryProvider::saveUserEntry(const EntryConfig &config)
{
if(config.type == EntryType::SYSTEM || config.entryPath.isEmpty())
{
throw std::runtime_error("Only user/inherited entries can be saved");
}
QString transitPath = config.entryPath + ".transit";
QFile file{transitPath};
if(!file.open(QIODevice::WriteOnly))
{
throw std::runtime_error("Error: Can not open file for writing");
}
QTextStream outStream(&file);
outStream << "type" << " " << ((config.type == EntryType::USER) ? "user" : "inherit") << endl;
if(!config.inherit.isEmpty())
{
outStream << "inherit" << " " << config.inherit << endl;
}
outStream << "row" << " " << config.row << endl;
outStream << "col" << " " << config.col << endl;
outStream << "hidden" << " " << config.hidden << endl;
outStream << "key" << " " << config.key << endl;
if(config.type == EntryType::USER)
{
if(!config.name.isEmpty())
{
outStream << "name" << " " << config.name << endl;
}
if(!config.command.isEmpty())
{
outStream << "command" << " " << config.command << endl;
}
if(!config.iconPath.isEmpty())
{
outStream << "icon" << " " << config.iconPath << endl;
}
if(!config.arguments.empty())
{
outStream << "arguments" << " " << config.arguments.join(' ') << endl;
}
}
outStream.flush();
file.close();
// Qts don't work if file already exists and c++17... don't want to pull in the fs lib yet
int ret = rename(transitPath.toStdString().c_str(), config.entryPath.toStdString().c_str());
if(ret != 0)
{
qDebug() << strerror(errno);
throw std::runtime_error("Failed to save entry file: Error during rename");
}
}
bool EntryProvider::deleteUserEntry(const EntryConfig &config)
{
if(config.type == EntryType::SYSTEM || config.entryPath.isEmpty())
{
throw std::runtime_error("Only user/inherited entries can be deleted");
}
QFile file{config.entryPath};
return file.remove();
}
template <class T> void assignIfDestDefault(T &dest, const T &source) template <class T> void assignIfDestDefault(T &dest, const T &source)
{ {
if(dest == T()) if(dest == T())
@ -355,16 +259,12 @@ EntryConfig &EntryConfig::update(const EntryConfig &o)
assignIfDestDefault(this->arguments, o.arguments); assignIfDestDefault(this->arguments, o.arguments);
assignIfDestDefault(this->col, o.col); assignIfDestDefault(this->col, o.col);
assignIfDestDefault(this->command, o.command); assignIfDestDefault(this->command, o.command);
if(this->iconPath.isEmpty()) if(this->icon.isNull())
{ {
this->iconPath = o.iconPath; this->icon = o.icon;
} }
assignIfDestDefault(this->key, o.key); assignIfDestDefault(this->key, o.key);
assignIfDestDefault(this->name, o.name); assignIfDestDefault(this->name, o.name);
assignIfDestDefault(this->row, o.row); assignIfDestDefault(this->row, o.row);
assignIfDestDefault(this->hidden, o.hidden);
assignIfDestDefault(this->inherit, o.inherit);
assignIfDestDefault(this->entryPath, o.entryPath);
assignIfDestDefault(this->type, o.type);
return *this; return *this;
} }

View File

@ -15,25 +15,15 @@ class ConfigFormatException : public std::runtime_error
} }
}; };
enum EntryType
{
USER,
INHERIT,
SYSTEM
};
class EntryConfig class EntryConfig
{ {
public: public:
EntryType type = SYSTEM;
bool hidden = false; bool hidden = false;
QString entryPath;
QString key; QString key;
QString name; QString name;
QString command; QString command;
QString iconPath;
QStringList arguments; QStringList arguments;
QString inherit; QIcon icon;
int row = 0; int row = 0;
int col = 0; int col = 0;
@ -56,8 +46,6 @@ class EntryProvider
EntryProvider(QStringList userEntriesDirsPaths, QStringList systemEntriesDirsPaths); EntryProvider(QStringList userEntriesDirsPaths, QStringList systemEntriesDirsPaths);
QVector<EntryConfig> getUserEntries(); QVector<EntryConfig> getUserEntries();
QVector<EntryConfig> getSystemEntries(); QVector<EntryConfig> getSystemEntries();
void saveUserEntry(const EntryConfig &config);
bool deleteUserEntry(const EntryConfig &config);
}; };
#endif // ENTRYPROVIDER_H #endif // ENTRYPROVIDER_H

View File

@ -13,21 +13,16 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */
#include <QDrag>
#include <QMimeData>
#include <QApplication>
#include "entrypushbutton.h" #include "entrypushbutton.h"
EntryPushButton::EntryPushButton(const EntryConfig &config) : QPushButton() EntryPushButton::EntryPushButton(const EntryConfig &config) : QPushButton()
{ {
this->setText(config.name); this->setText(config.name);
this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
QIcon icon = resolveIcon(config.iconPath); this->setIcon(config.icon);
this->setIcon(icon); if(!config.icon.availableSizes().isEmpty())
if(!icon.availableSizes().isEmpty())
{ {
auto sizes = icon.availableSizes(); auto sizes = config.icon.availableSizes();
QSize maxSize = sizes.first(); QSize maxSize = sizes.first();
for(QSize &current : sizes) for(QSize &current : sizes)
{ {
@ -40,33 +35,17 @@ EntryPushButton::EntryPushButton(const EntryConfig &config) : QPushButton()
} }
this->config = config; this->config = config;
connect(this, SIGNAL(clicked()), this, SLOT(emitOwnClicked())); connect(this, SIGNAL(clicked()), this, SLOT(emitOwnClicked()));
systemEntryMenu.addAction("Add to favorites", [&] { emit addToFavourites(this->config); });
userEntryMenu.addAction("Delete", [&] { emit deleteRequested(this->config); });
} }
QIcon EntryPushButton::resolveIcon(QString path)
{
if(!path.isEmpty())
{
if(path[0] == '/')
{
return QIcon(path);
}
else
{
return QIcon::fromTheme(path);
}
}
return QIcon();
}
void EntryPushButton::emitOwnClicked() void EntryPushButton::emitOwnClicked()
{ {
emit clicked(this->config); emit clicked(this->config);
} }
const EntryConfig &EntryPushButton::getEntryConfig() const const EntryConfig &EntryPushButton::getEntryConfig()
{ {
return this->config; return this->config;
} }
@ -86,82 +65,12 @@ void EntryPushButton::showName()
this->setText(this->config.name); this->setText(this->config.name);
} }
void EntryPushButton::mousePressEvent(QMouseEvent *event) int EntryPushButton::getRow() const { return config.row; }
{ int EntryPushButton::getCol() const { return config.col; }
if(event->button() == Qt::LeftButton) QString EntryPushButton::getName() const { return config.name; }
{ QString EntryPushButton::getShortcutKey() const { return config.key; }
dragStartPosition = event->pos(); void EntryPushButton::setShortcutKey(QString key) { this->config.key = key; }
} void EntryPushButton::setRow(int row) { this->config.row = row; }
if(event->button() == Qt::RightButton) void EntryPushButton::setCol(int col) { this->config.col = col; }
{ QStringList EntryPushButton::getArguments() const { return this->config.arguments; }
if(this->config.type == EntryType::USER || this->config.type == EntryType::INHERIT) QString EntryPushButton::getCommand() const { return this->config.command; }
{
this->userEntryMenu.exec(QCursor::pos());
}
else
{
this->systemEntryMenu.exec(QCursor::pos());
}
}
return QPushButton::mousePressEvent(event);
}
void EntryPushButton::mouseMoveEvent(QMouseEvent *event)
{
if(this->config.type == EntryType::SYSTEM)
{
return;
}
if(!(event->buttons() & Qt::LeftButton))
{
return;
}
if((event->pos() - dragStartPosition).manhattanLength() < QApplication::startDragDistance())
{
return;
}
QDrag *drag = new QDrag(this);
QMimeData *mimeData = new QMimeData();
QByteArray data;
mimeData->setData(ENTRYBUTTON_MIME_TYPE_STR, data);
drag->setMimeData(mimeData);
Qt::DropAction dropAction = drag->exec(Qt::MoveAction);
}
int EntryPushButton::getRow() const
{
return config.row;
}
int EntryPushButton::getCol() const
{
return config.col;
}
QString EntryPushButton::getName() const
{
return config.name;
}
QString EntryPushButton::getShortcutKey() const
{
return config.key;
}
void EntryPushButton::setShortcutKey(QString key)
{
this->config.key = key;
}
void EntryPushButton::setRow(int row)
{
this->config.row = row;
}
void EntryPushButton::setCol(int col)
{
this->config.col = col;
}
QStringList EntryPushButton::getArguments() const
{
return this->config.arguments;
}
QString EntryPushButton::getCommand() const
{
return this->config.command;
}

View File

@ -18,38 +18,20 @@
#include <QWidget> #include <QWidget>
#include <QPushButton> #include <QPushButton>
#include <QMouseEvent>
#include <QMenu>
#include "entryprovider.h" #include "entryprovider.h"
#define ENTRYBUTTON_MIME_TYPE_STR "application/x-qsrun-entrypushbutton"
class EntryPushButton : public QPushButton class EntryPushButton : public QPushButton
{ {
Q_OBJECT Q_OBJECT
private: private:
QMenu systemEntryMenu;
QMenu userEntryMenu;
EntryConfig config; EntryConfig config;
QPoint dragStartPosition; private slots:
private slots:
void emitOwnClicked(); void emitOwnClicked();
signals: signals:
void clicked(const EntryConfig &config); void clicked(const EntryConfig &config);
void deleteRequested(EntryConfig &config); public:
void addToFavourites(const EntryConfig &config);
protected:
void mousePressEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
QIcon resolveIcon(QString path);
public:
EntryPushButton(const EntryConfig &config); EntryPushButton(const EntryConfig &config);
const EntryConfig &getEntryConfig() const; const EntryConfig &getEntryConfig();
void setEntryConfig(const EntryConfig &config); void setEntryConfig(const EntryConfig &config);
void showShortcut(); void showShortcut();
void showName(); void showName();
@ -64,4 +46,6 @@ class EntryPushButton : public QPushButton
void setShortcutKey(QString key); void setShortcutKey(QString key);
}; };
#endif // ENTRYPUSHBUTTON_H #endif // ENTRYPUSHBUTTON_H

View File

@ -37,7 +37,6 @@ Window::Window(EntryProvider &entryProvider, SettingsProvider &configProvider)
createGui(); createGui();
initFromConfig(); initFromConfig();
this->lineEdit->installEventFilter(this); this->lineEdit->installEventFilter(this);
this->setAcceptDrops(true);
QFont font; QFont font;
font.setPointSize(48); font.setPointSize(48);
font.setBold(true); font.setBold(true);
@ -118,54 +117,12 @@ void Window::populateGrid(const QVector<EntryPushButton *> &list)
} }
} }
void Window::executeConfig(const EntryConfig &config) void Window::buttonClick(const EntryPushButton &config)
{ {
QProcess::startDetached(config.command, config.arguments); QProcess::startDetached(config.getCommand(), config.getArguments());
this->closeWindow(); this->closeWindow();
} }
void Window::addToFavourites(const EntryConfig &config)
{
std::pair<int, int> cell = getNextFreeCell();
EntryConfig userConfig;
userConfig.type = EntryType::INHERIT;
userConfig.row = cell.first;
userConfig.col = cell.second;
userConfig.inherit = config.entryPath;
QFileInfo fi{config.entryPath};
QString entryName = fi.completeBaseName() + ".qsrun";
QString entryPath;
if(config.type == EntryType::SYSTEM)
{
entryPath = this->settingsProvider->userEntriesPaths()[0] + "/" + entryName;
}
else
{
entryPath = fi.absoluteDir().absoluteFilePath(entryName);
}
userConfig.entryPath = entryPath;
try
{
entryProvider->saveUserEntry(userConfig);
}
catch(std::exception &e)
{
QMessageBox::critical(this, "Failed to save item to favourites", e.what());
return;
}
/*we only want to save a minimal, inherited config. but it should be a "complete" button
when we add it to the favourites. the alternative would be to reload the whole config,
but that's probably overkill. */
userConfig.update(config);
userEntryButtons.append(createEntryButton(userConfig));
}
void Window::deleteEntry(EntryConfig &config)
{
this->entryProvider->deleteUserEntry(config);
initFromConfig();
}
void Window::closeWindow() void Window::closeWindow()
{ {
if(settingsProvider->singleInstanceMode()) if(settingsProvider->singleInstanceMode())
@ -179,48 +136,6 @@ void Window::closeWindow()
} }
} }
std::pair<int, int> Window::getNextFreeCell()
{
/* Not the most efficient way perhaps but for now it'll do */
std::sort(userEntryButtons.begin(), userEntryButtons.end(), [](EntryPushButton *a, EntryPushButton *b) {
const EntryConfig &config_a = a->getEntryConfig();
const EntryConfig &config_b = b->getEntryConfig();
if(config_a.row < config_b.row)
{
return true;
}
if(config_a.row > config_b.row)
{
return false;
}
return config_a.col < config_b.col;
});
int expectedRow = 1;
int expectedCol = 1;
int maxCols = this->settingsProvider->getMaxCols();
for(EntryPushButton *current : userEntryButtons)
{
int currentRow = current->getEntryConfig().row;
int currentCol = current->getEntryConfig().col;
if(currentRow != expectedRow || currentCol != expectedCol)
{
return {expectedRow, expectedCol};
}
if(expectedCol == maxCols)
{
expectedCol = 1;
++expectedRow;
}
else
{
++expectedCol;
}
}
return {expectedRow, expectedCol};
}
QStringList Window::generatePATHSuggestions(const QString &text) QStringList Window::generatePATHSuggestions(const QString &text)
{ {
QStringList results; QStringList results;
@ -255,7 +170,7 @@ void Window::addPATHSuggestion(const QString &text)
e.col = 0; e.col = 0;
e.row = 0; e.row = 0;
e.command = suggestions[0]; e.command = suggestions[0];
e.iconPath = suggestions[0]; e.icon = QIcon::fromTheme(suggestions[0]);
EntryPushButton *button = createEntryButton(e); EntryPushButton *button = createEntryButton(e);
clearGrid(); clearGrid();
grid->addWidget(button, 0, 0); grid->addWidget(button, 0, 0);
@ -332,7 +247,7 @@ void Window::lineEditTextChanged(QString text)
e.arguments = arguments.mid(1); e.arguments = arguments.mid(1);
} }
e.command = arguments[0]; e.command = arguments[0];
e.iconPath = "utilities-terminal"; e.icon = QIcon::fromTheme("utilities-terminal");
EntryPushButton *button = createEntryButton(e); EntryPushButton *button = createEntryButton(e);
clearGrid(); clearGrid();
@ -382,7 +297,7 @@ void Window::keyPressEvent(QKeyEvent *event)
[&key](const EntryPushButton *y) { return y->getShortcutKey() == key; }); [&key](const EntryPushButton *y) { return y->getShortcutKey() == key; });
if(it != buttonsInGrid.end()) if(it != buttonsInGrid.end())
{ {
executeConfig((*it)->getEntryConfig()); buttonClick(**it);
} }
} }
QWidget::keyPressEvent(event); QWidget::keyPressEvent(event);
@ -439,9 +354,7 @@ void Window::filterGridFor(QString filter)
EntryPushButton *Window::createEntryButton(const EntryConfig &entry) EntryPushButton *Window::createEntryButton(const EntryConfig &entry)
{ {
EntryPushButton *button = new EntryPushButton(entry); EntryPushButton *button = new EntryPushButton(entry);
connect(button, &EntryPushButton::clicked, this, &Window::executeConfig); connect(button, &EntryPushButton::clicked, this, &Window::buttonClick);
connect(button, &EntryPushButton::addToFavourites, this, &Window::addToFavourites);
connect(button, &EntryPushButton::deleteRequested, this, &Window::deleteEntry);
return button; return button;
} }
@ -456,7 +369,7 @@ void Window::lineEditReturnPressed()
if(buttonsInGrid.length() > 0 && this->lineEdit->text().length() > 0) if(buttonsInGrid.length() > 0 && this->lineEdit->text().length() > 0)
{ {
executeConfig(buttonsInGrid[0]->getEntryConfig()); buttonClick(*buttonsInGrid[0]);
return; return;
} }
} }
@ -492,49 +405,3 @@ void Window::focusInput()
{ {
this->lineEdit->setFocus(); this->lineEdit->setFocus();
} }
void Window::dragEnterEvent(QDragEnterEvent *event)
{
if(event->mimeData()->hasFormat(ENTRYBUTTON_MIME_TYPE_STR))
{
event->acceptProposedAction();
}
}
void Window::dropEvent(QDropEvent *event)
{
int count = grid->count();
for(int i = 0; i < count; i++)
{
QLayoutItem *current = grid->itemAt(i);
if(current->geometry().contains(event->pos()))
{
EntryPushButton *buttonAtDrop = (EntryPushButton *)current->widget();
EntryPushButton *buttonAtSource = (EntryPushButton *)event->source();
int tmp_row = buttonAtSource->getRow();
int tmp_col = buttonAtSource->getCol();
grid->addWidget(buttonAtSource, buttonAtDrop->getRow(), buttonAtDrop->getCol());
buttonAtSource->setRow(buttonAtDrop->getRow());
buttonAtSource->setCol(buttonAtDrop->getCol());
grid->addWidget(buttonAtDrop, tmp_row, tmp_col);
buttonAtDrop->setRow(tmp_row);
buttonAtDrop->setCol(tmp_col);
try
{
this->entryProvider->saveUserEntry(buttonAtDrop->getEntryConfig());
this->entryProvider->saveUserEntry(buttonAtSource->getEntryConfig());
}
catch(std::exception &e)
{
QMessageBox::critical(this, "Failed to rearrange items", e.what());
}
break;
}
}
event->acceptProposedAction();
}

View File

@ -30,9 +30,6 @@
#include <QThread> #include <QThread>
#include <QTreeWidget> #include <QTreeWidget>
#include <QLabel> #include <QLabel>
#include <QMimeData>
#include <QDebug>
#include <QRect>
#include "entrypushbutton.h" #include "entrypushbutton.h"
#include "calculationengine.h" #include "calculationengine.h"
#include "settingsprovider.h" #include "settingsprovider.h"
@ -40,17 +37,13 @@
class Window : public QWidget class Window : public QWidget
{ {
Q_OBJECT Q_OBJECT
protected: private:
void dragEnterEvent(QDragEnterEvent *event);
void dropEvent(QDropEvent *event);
private:
EntryProvider *entryProvider; EntryProvider *entryProvider;
SettingsProvider *settingsProvider; SettingsProvider *settingsProvider;
CalculationEngine calcEngine; CalculationEngine calcEngine;
QString calculationresult; QString calculationresult;
QVector<EntryPushButton *> userEntryButtons; QVector<EntryPushButton*> userEntryButtons;
QVector<EntryPushButton *> systemEntryButtons; QVector<EntryPushButton*> systemEntryButtons;
QVector<EntryPushButton *> buttonsInGrid; QVector<EntryPushButton *> buttonsInGrid;
QLabel calculationResultLabel; QLabel calculationResultLabel;
QString currentCalculationResult; QString currentCalculationResult;
@ -63,31 +56,27 @@ class Window : public QWidget
void keyReleaseEvent(QKeyEvent *event); void keyReleaseEvent(QKeyEvent *event);
QVector<EntryPushButton *> generateEntryButtons(const QVector<EntryConfig> &userEntryButtons); QVector<EntryPushButton *> generateEntryButtons(const QVector<EntryConfig> &userEntryButtons);
void keyPressEvent(QKeyEvent *event); void keyPressEvent(QKeyEvent *event);
void executeConfig(const EntryConfig &button); void buttonClick(const EntryPushButton &config);
void addToFavourites(const EntryConfig &button);
void deleteEntry(EntryConfig &config);
QLineEdit *lineEdit; QLineEdit *lineEdit;
QGridLayout *grid; QGridLayout *grid;
EntryPushButton *createEntryButton(const EntryConfig &config); EntryPushButton *createEntryButton(const EntryConfig &config);
void lineEditTextChanged(QString text); void lineEditTextChanged(QString text);
void addPATHSuggestion(const QString &text); void addPATHSuggestion(const QString &text);
void clearGrid(); void clearGrid();
void addCalcResult(const QString &expression); void addCalcResult(const QString & expression);
void initTreeWidgets(); void initTreeWidgets();
QStringList generatePATHSuggestions(const QString &text); QStringList generatePATHSuggestions(const QString &text);
void closeWindow(); void closeWindow();
std::pair<int, int> getNextFreeCell(); private slots:
private slots:
void lineEditReturnPressed(); void lineEditReturnPressed();
void showCalculationResultContextMenu(const QPoint &point); void showCalculationResultContextMenu(const QPoint &point);
public:
public:
Window(EntryProvider &entryProvider, SettingsProvider &settingsProvider); Window(EntryProvider &entryProvider, SettingsProvider &settingsProvider);
void setSystemConfig(const QVector<EntryConfig> &config); void setSystemConfig(const QVector<EntryConfig> &config);
bool eventFilter(QObject *obj, QEvent *event); bool eventFilter(QObject *obj, QEvent *event);
void focusInput(); void focusInput();
~Window(); ~Window();
}; };
#endif #endif