reformating (no functional change)

This commit is contained in:
Albert S. 2019-08-24 09:19:49 +02:00
bovenliggende 7379cff7db
commit 6c67c11481
10 gewijzigde bestanden met toevoegingen van 139 en 141 verwijderingen

Bestand weergeven

@ -18,11 +18,12 @@
CalculationEngine::CalculationEngine()
{
if (!CALCULATOR) {
new Calculator();
CALCULATOR->terminateThreads();
CALCULATOR->setPrecision(16);
}
if (!CALCULATOR)
{
new Calculator();
CALCULATOR->terminateThreads();
CALCULATOR->setPrecision(16);
}
//stolen from krunner's qalculate engine
/*eo.auto_post_conversion = POST_CONVERSION_BEST;
@ -50,8 +51,6 @@ QString CalculationEngine::evaluate(const QString &expression)
QByteArray ba = expression.toLatin1();
const char *ctext = ba.data();
MathStructure result = CALCULATOR->calculate(ctext, this->eo);
result.format(po);
result.format(po);
return result.print(po).c_str();
}

Bestand weergeven

@ -26,12 +26,12 @@
class CalculationEngine
{
private:
EvaluationOptions eo;
PrintOptions po;
EvaluationOptions eo;
PrintOptions po;
public:
CalculationEngine();
QString evaluate(const QString &expression);
CalculationEngine();
QString evaluate(const QString &expression);
};
#endif // CALCULATIONENGINE_H

Bestand weergeven

@ -157,7 +157,7 @@ EntryConfig ConfigReader::readFromFile(const QString &path)
}
if(key == "row")
{
result.row = splitted[1].toInt();
result.row = splitted[1].toInt();
}
if(key == "col")
{

Bestand weergeven

@ -24,14 +24,14 @@
#include <QKeySequence>
class EntryConfig
{
public:
QString key;
QString name;
QString command;
QStringList arguments;
QIcon icon;
int row=0;
int col=0;
public:
QString key;
QString name;
QString command;
QStringList arguments;
QIcon icon;
int row=0;
int col=0;
@ -39,21 +39,21 @@ class EntryConfig
class ConfigReader
{
private:
QStringList configPaths;
EntryConfig readFromFile(const QString &path);
EntryConfig readFromDesktopFile(const QString &path);
QStringList desktopIgnoreArgs;
public:
ConfigReader(QStringList paths);
QVector<EntryConfig> readConfig();
private:
QStringList configPaths;
EntryConfig readFromFile(const QString &path);
EntryConfig readFromDesktopFile(const QString &path);
QStringList desktopIgnoreArgs;
public:
ConfigReader(QStringList paths);
QVector<EntryConfig> readConfig();
};
class ConfigFormatException : public std::runtime_error
{
public:
ConfigFormatException() : std::runtime_error("Error in configuration file, misformated line?") {};
ConfigFormatException(const std::string &str) : std::runtime_error(str) {};
ConfigFormatException() : std::runtime_error("Error in configuration file, misformated line?") {};
ConfigFormatException(const std::string &str) : std::runtime_error(str) {};
};
#endif

Bestand weergeven

@ -6,13 +6,13 @@
class ConfigProvider
{
private:
QSettings *settings;
QString configDirPath;
QSettings *settings;
QString configDirPath;
public:
ConfigProvider(QString configDirPath, QSettings &settings);
QVector<EntryConfig> getUserEntries();
QVector<EntryConfig> getSystemEntries();
bool singleInstanceMode();
ConfigProvider(QString configDirPath, QSettings &settings);
QVector<EntryConfig> getUserEntries();
QVector<EntryConfig> getSystemEntries();
bool singleInstanceMode();
};
#endif // CONFIGPROVIDER_H

Bestand weergeven

@ -21,29 +21,29 @@
#include "config.h"
class EntryPushButton : public QPushButton
{
Q_OBJECT
Q_OBJECT
private:
EntryConfig config;
EntryConfig config;
private slots:
void emitOwnClicked();
void emitOwnClicked();
signals:
void clicked(const EntryConfig &config);
void clicked(const EntryConfig &config);
public:
EntryPushButton(const EntryConfig &config);
const EntryConfig &getEntryConfig();
void setEntryConfig(const EntryConfig &config);
void showShortcut();
void showName();
int getRow() const;
int getCol() const;
QString getName() const;
QString getShortcutKey() const;
QStringList getArguments() const;
QString getCommand() const;
void setRow(int row);
void setCol(int col);
void setShortcutKey(QString key);
EntryPushButton(const EntryConfig &config);
const EntryConfig &getEntryConfig();
void setEntryConfig(const EntryConfig &config);
void showShortcut();
void showName();
int getRow() const;
int getCol() const;
QString getName() const;
QString getShortcutKey() const;
QStringList getArguments() const;
QString getCommand() const;
void setRow(int row);
void setCol(int col);
void setShortcutKey(QString key);
};

Bestand weergeven

@ -72,14 +72,14 @@ int main(int argc, char *argv[])
}
Window *w = new Window { configProvider };
QObject::connect(&server, &SingleInstanceServer::receivedMaximizationRequest, [&w]{
if(w != nullptr)
{
qInfo() << "maximizing as requested by other instance";
w->showMaximized();
w->activateWindow();
w->raise();
}
});
if(w != nullptr)
{
qInfo() << "maximizing as requested by other instance";
w->showMaximized();
w->activateWindow();
w->raise();
}
});
w->showMaximized();
}

Bestand weergeven

@ -6,16 +6,16 @@
class SingleInstanceServer : public QObject
{
Q_OBJECT
Q_OBJECT
private:
QLocalServer server;
QLocalServer server;
private slots:
void handleNewConnection();
void handleNewConnection();
public:
SingleInstanceServer();
bool listen(QString socketPath);
signals:
void receivedMaximizationRequest();
SingleInstanceServer();
bool listen(QString socketPath);
signals:
void receivedMaximizationRequest();
};
#endif // SINGLEINSTANCESERVER_H

Bestand weergeven

@ -1,18 +1,18 @@
/*
* Copyright (c) 2018 Albert S. <mail at quitesimple dot org>
*
* 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.
*/
* Copyright (c) 2018 Albert S. <mail at quitesimple dot org>
*
* 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.
*/
#include <QProcess>
#include <QProcessEnvironment>
#include <QDirIterator>
@ -94,20 +94,20 @@ QVector<EntryPushButton*> Window::generateEntryButtons(const QVector<EntryConfig
void Window::createGui()
{
QVBoxLayout *vbox = new QVBoxLayout(this);
QScrollArea *sa = new QScrollArea;
grid = new QGridLayout();
lineEdit = new QLineEdit();
QWidget *w = new QWidget(this);
w->setLayout(grid);
sa->setWidget(w);
sa->setWidgetResizable(true);
vbox->setAlignment(Qt::AlignTop);
vbox->addWidget(lineEdit);
vbox->addWidget(sa);
QVBoxLayout *vbox = new QVBoxLayout(this);
QScrollArea *sa = new QScrollArea;
grid = new QGridLayout();
lineEdit = new QLineEdit();
QWidget *w = new QWidget(this);
w->setLayout(grid);
sa->setWidget(w);
sa->setWidgetResizable(true);
vbox->setAlignment(Qt::AlignTop);
vbox->addWidget(lineEdit);
vbox->addWidget(sa);
connect(lineEdit, &QLineEdit::textChanged, this, [this](QString newtext) { this->lineEditTextChanged(newtext); });
connect(lineEdit, &QLineEdit::returnPressed, this, &Window::lineEditReturnPressed);
connect(lineEdit, &QLineEdit::textChanged, this, [this](QString newtext) { this->lineEditTextChanged(newtext); });
connect(lineEdit, &QLineEdit::returnPressed, this, &Window::lineEditReturnPressed);
}
void Window::populateGrid(const QVector<EntryPushButton *> &list)
@ -151,7 +151,6 @@ QStringList Window::generatePATHSuggestions(const QString &text)
QString entry = info.baseName();
if(entry.startsWith(text))
{
results.append(entry);
}
}
@ -242,7 +241,7 @@ void Window::lineEditTextChanged(QString text)
addPATHSuggestion(text);
if(this->grid->count() == 0)
{
QStringList arguments = text.split(" ");
EntryConfig e;
e.name = "Execute: " + text;
@ -252,7 +251,7 @@ void Window::lineEditTextChanged(QString text)
}
e.command = arguments[0];
e.icon = QIcon::fromTheme("utilities-terminal");
EntryPushButton *button = createEntryButton(e);
clearGrid();
grid->addWidget(button, 0, 0);
@ -281,7 +280,7 @@ void Window::keyPressEvent(QKeyEvent *event)
{
qApp->quit();
}
if(event->modifiers() & Qt::ControlModifier && buttonsInGrid.count() > 0)
{
@ -300,7 +299,7 @@ void Window::keyPressEvent(QKeyEvent *event)
QKeySequence seq(event->key());
QString key = seq.toString().toLower();
auto it = std::find_if(buttonsInGrid.begin(), buttonsInGrid.end(), [&key](const EntryPushButton *y) { return y->getShortcutKey() == key; });
if(it != buttonsInGrid.end())
{
@ -349,8 +348,8 @@ void Window::filterGridFor(QString filter)
}
}
}
}
}
}
@ -358,7 +357,7 @@ void Window::filterGridFor(QString filter)
{
populateGrid(this->userEntryButtons);
}
}
EntryPushButton * Window::createEntryButton(const EntryConfig &entry)

Bestand weergeven

@ -38,42 +38,42 @@
class Window : public QWidget
{
Q_OBJECT
private:
ConfigProvider *configProvider;
CalculationEngine calcEngine;
QString calculationresult;
QVector<EntryPushButton*> userEntryButtons;
QVector<EntryPushButton*> systemEntryButtons;
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);
void buttonClick(const EntryPushButton &config);
QLineEdit *lineEdit;
QGridLayout *grid;
EntryPushButton *createEntryButton(const EntryConfig &config);
void lineEditTextChanged(QString text);
void addPATHSuggestion(const QString &text);
void clearGrid();
void addCalcResult(const QString & expression);
void initTreeWidgets();
QStringList generatePATHSuggestions(const QString &text);
private slots:
void lineEditReturnPressed();
void showCalculationResultContextMenu(const QPoint &point);
public:
Window(ConfigProvider &configProvider);
void setSystemConfig(const QVector<EntryConfig> &config);
bool eventFilter(QObject *obj, QEvent *event);
~Window();
private:
ConfigProvider *configProvider;
CalculationEngine calcEngine;
QString calculationresult;
QVector<EntryPushButton*> userEntryButtons;
QVector<EntryPushButton*> systemEntryButtons;
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);
void buttonClick(const EntryPushButton &config);
QLineEdit *lineEdit;
QGridLayout *grid;
EntryPushButton *createEntryButton(const EntryConfig &config);
void lineEditTextChanged(QString text);
void addPATHSuggestion(const QString &text);
void clearGrid();
void addCalcResult(const QString & expression);
void initTreeWidgets();
QStringList generatePATHSuggestions(const QString &text);
private slots:
void lineEditReturnPressed();
void showCalculationResultContextMenu(const QPoint &point);
public:
Window(ConfigProvider &configProvider);
void setSystemConfig(const QVector<EntryConfig> &config);
bool eventFilter(QObject *obj, QEvent *event);
~Window();
};