reformating (no functional change)

This commit is contained in:
Albert S. 2019-08-24 09:19:49 +02:00
parent 7379cff7db
commit 6c67c11481
10 changed files with 139 additions and 141 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,18 +1,18 @@
/* /*
* Copyright (c) 2018 Albert S. <mail at quitesimple dot org> * Copyright (c) 2018 Albert S. <mail at quitesimple dot org>
* *
* Permission to use, copy, modify, and distribute this software for any * Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above * purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies. * copyright notice and this permission notice appear in all copies.
* *
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* 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 <QProcess> #include <QProcess>
#include <QProcessEnvironment> #include <QProcessEnvironment>
#include <QDirIterator> #include <QDirIterator>
@ -94,20 +94,20 @@ QVector<EntryPushButton*> Window::generateEntryButtons(const QVector<EntryConfig
void Window::createGui() void Window::createGui()
{ {
QVBoxLayout *vbox = new QVBoxLayout(this); QVBoxLayout *vbox = new QVBoxLayout(this);
QScrollArea *sa = new QScrollArea; QScrollArea *sa = new QScrollArea;
grid = new QGridLayout(); grid = new QGridLayout();
lineEdit = new QLineEdit(); lineEdit = new QLineEdit();
QWidget *w = new QWidget(this); QWidget *w = new QWidget(this);
w->setLayout(grid); w->setLayout(grid);
sa->setWidget(w); sa->setWidget(w);
sa->setWidgetResizable(true); sa->setWidgetResizable(true);
vbox->setAlignment(Qt::AlignTop); vbox->setAlignment(Qt::AlignTop);
vbox->addWidget(lineEdit); vbox->addWidget(lineEdit);
vbox->addWidget(sa); vbox->addWidget(sa);
connect(lineEdit, &QLineEdit::textChanged, this, [this](QString newtext) { this->lineEditTextChanged(newtext); }); connect(lineEdit, &QLineEdit::textChanged, this, [this](QString newtext) { this->lineEditTextChanged(newtext); });
connect(lineEdit, &QLineEdit::returnPressed, this, &Window::lineEditReturnPressed); connect(lineEdit, &QLineEdit::returnPressed, this, &Window::lineEditReturnPressed);
} }
void Window::populateGrid(const QVector<EntryPushButton *> &list) void Window::populateGrid(const QVector<EntryPushButton *> &list)
@ -151,7 +151,6 @@ QStringList Window::generatePATHSuggestions(const QString &text)
QString entry = info.baseName(); QString entry = info.baseName();
if(entry.startsWith(text)) if(entry.startsWith(text))
{ {
results.append(entry); results.append(entry);
} }
} }
@ -349,7 +348,7 @@ void Window::filterGridFor(QString filter)
} }
} }
} }
} }

View File

@ -38,42 +38,42 @@
class Window : public QWidget class Window : public QWidget
{ {
Q_OBJECT Q_OBJECT
private: private:
ConfigProvider *configProvider; ConfigProvider *configProvider;
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;
QString queuedFileSearch; QString queuedFileSearch;
QString queuedContentSearch; QString queuedContentSearch;
void initFromConfig(); void initFromConfig();
void createGui(); void createGui();
void filterGridFor(QString filter); void filterGridFor(QString filter);
void populateGrid(const QVector<EntryPushButton *> &list); void populateGrid(const QVector<EntryPushButton *> &list);
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 buttonClick(const EntryPushButton &config); void buttonClick(const EntryPushButton &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);
private slots: private slots:
void lineEditReturnPressed(); void lineEditReturnPressed();
void showCalculationResultContextMenu(const QPoint &point); void showCalculationResultContextMenu(const QPoint &point);
public: public:
Window(ConfigProvider &configProvider); Window(ConfigProvider &configProvider);
void setSystemConfig(const QVector<EntryConfig> &config); void setSystemConfig(const QVector<EntryConfig> &config);
bool eventFilter(QObject *obj, QEvent *event); bool eventFilter(QObject *obj, QEvent *event);
~Window(); ~Window();
}; };