2018-01-05 15:52:11 +01:00
|
|
|
/*
|
2019-09-30 21:58:11 +02:00
|
|
|
* Copyright (c) 2018-2019 Albert S. <mail at quitesimple dot org>
|
2018-01-05 15:52:11 +01:00
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, and distribute this software for any
|
|
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
|
|
* copyright notice and this permission notice appear in all copies.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
|
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
|
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
|
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
*/
|
2018-01-03 09:52:05 +01:00
|
|
|
#ifndef WINDOW_H
|
|
|
|
#define WINDOW_H
|
|
|
|
#include <QWidget>
|
|
|
|
#include <QList>
|
|
|
|
#include <QLineEdit>
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
#include <QGridLayout>
|
|
|
|
#include <QPushButton>
|
|
|
|
#include <QStyle>
|
|
|
|
#include <QKeyEvent>
|
|
|
|
#include <QMessageBox>
|
|
|
|
#include <QApplication>
|
|
|
|
#include <QHash>
|
|
|
|
#include <QVector>
|
|
|
|
#include <QThread>
|
|
|
|
#include <QTreeWidget>
|
2018-07-04 17:09:21 +02:00
|
|
|
#include <QLabel>
|
2020-09-13 14:33:40 +02:00
|
|
|
#include <QMimeData>
|
|
|
|
#include <QDebug>
|
|
|
|
#include <QRect>
|
2018-01-03 09:52:05 +01:00
|
|
|
#include "entrypushbutton.h"
|
|
|
|
#include "calculationengine.h"
|
2020-09-06 19:43:17 +02:00
|
|
|
#include "settingsprovider.h"
|
2018-01-03 09:52:05 +01:00
|
|
|
|
|
|
|
class Window : public QWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
2020-09-13 14:33:40 +02:00
|
|
|
protected:
|
|
|
|
void dragEnterEvent(QDragEnterEvent *event);
|
|
|
|
void dropEvent(QDropEvent *event);
|
|
|
|
|
|
|
|
private:
|
2020-09-06 19:43:17 +02:00
|
|
|
EntryProvider *entryProvider;
|
|
|
|
SettingsProvider *settingsProvider;
|
2019-08-24 09:19:49 +02:00
|
|
|
CalculationEngine calcEngine;
|
|
|
|
QString calculationresult;
|
2020-09-13 14:33:40 +02:00
|
|
|
QVector<EntryPushButton *> userEntryButtons;
|
|
|
|
QVector<EntryPushButton *> systemEntryButtons;
|
2019-08-24 09:19:49 +02:00
|
|
|
QVector<EntryPushButton *> buttonsInGrid;
|
|
|
|
QLabel calculationResultLabel;
|
|
|
|
QString currentCalculationResult;
|
|
|
|
QString queuedFileSearch;
|
|
|
|
QString queuedContentSearch;
|
|
|
|
void initFromConfig();
|
|
|
|
void createGui();
|
|
|
|
void filterGridFor(QString filter);
|
|
|
|
void populateGrid(const QVector<EntryPushButton *> &list);
|
|
|
|
void keyReleaseEvent(QKeyEvent *event);
|
|
|
|
QVector<EntryPushButton *> generateEntryButtons(const QVector<EntryConfig> &userEntryButtons);
|
|
|
|
void keyPressEvent(QKeyEvent *event);
|
2020-09-28 19:00:47 +02:00
|
|
|
void executeConfig(const EntryConfig &button);
|
2020-09-28 18:59:48 +02:00
|
|
|
void addToFavourites(const EntryConfig &button);
|
2020-09-27 22:28:16 +02:00
|
|
|
void deleteEntry(EntryConfig &config);
|
2019-08-24 09:19:49 +02:00
|
|
|
QLineEdit *lineEdit;
|
|
|
|
QGridLayout *grid;
|
|
|
|
EntryPushButton *createEntryButton(const EntryConfig &config);
|
|
|
|
void lineEditTextChanged(QString text);
|
|
|
|
void addPATHSuggestion(const QString &text);
|
|
|
|
void clearGrid();
|
2020-09-13 14:33:40 +02:00
|
|
|
void addCalcResult(const QString &expression);
|
2019-08-24 09:19:49 +02:00
|
|
|
void initTreeWidgets();
|
|
|
|
QStringList generatePATHSuggestions(const QString &text);
|
2019-09-01 19:46:38 +02:00
|
|
|
void closeWindow();
|
2020-09-27 15:42:53 +02:00
|
|
|
std::pair<int, int> getNextFreeCell();
|
|
|
|
|
2020-09-13 14:33:40 +02:00
|
|
|
private slots:
|
2019-08-24 09:19:49 +02:00
|
|
|
void lineEditReturnPressed();
|
|
|
|
void showCalculationResultContextMenu(const QPoint &point);
|
2020-09-13 14:33:40 +02:00
|
|
|
|
|
|
|
public:
|
2020-09-06 19:43:17 +02:00
|
|
|
Window(EntryProvider &entryProvider, SettingsProvider &settingsProvider);
|
2019-08-24 09:19:49 +02:00
|
|
|
void setSystemConfig(const QVector<EntryConfig> &config);
|
|
|
|
bool eventFilter(QObject *obj, QEvent *event);
|
2019-09-01 20:42:39 +02:00
|
|
|
void focusInput();
|
2019-08-24 09:19:49 +02:00
|
|
|
~Window();
|
2018-01-03 09:52:05 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|