fixed bugs with dataengine settings saving

This commit is contained in:
arcan1s 2015-05-02 01:40:20 +03:00
parent fd8f2127d9
commit 9a6b883905
6 changed files with 1508 additions and 6 deletions

View File

@ -8,7 +8,7 @@ ProjectRootRelative=./
[CMake][CMake Build Directory 0] [CMake][CMake Build Directory 0]
Build Directory Path=file:///home/arcanis/Documents/github/awesome-widgets/build Build Directory Path=file:///home/arcanis/Documents/github/awesome-widgets/build
Build Type=Debug Build Type=Release
CMake Binary=file:///usr/bin/cmake CMake Binary=file:///usr/bin/cmake
Environment Profile= Environment Profile=
Extra Arguments= Extra Arguments=

View File

@ -105,7 +105,7 @@ Item {
id: gpuDev id: gpuDev
width: parent.width * 3 / 5 width: parent.width * 3 / 5
model: ["auto", "disable", "ati", "nvidia"] model: ["auto", "disable", "ati", "nvidia"]
onCurrentIndexChanged: cfg_dataengine["GPUDEV"] = gpuDev.currentText onCurrentIndexChanged: cfg_dataengine["GPUDEV"] = model[currentIndex]
Component.onCompleted: { Component.onCompleted: {
for (var i=0; i<model.length; i++) { for (var i=0; i<model.length; i++) {
if (model[i] == cfg_dataengine["GPUDEV"]) { if (model[i] == cfg_dataengine["GPUDEV"]) {
@ -130,7 +130,7 @@ Item {
id: hdd id: hdd
width: parent.width * 3 / 5 width: parent.width * 3 / 5
model: AWKeys.getHddDevices(true) model: AWKeys.getHddDevices(true)
onCurrentIndexChanged: cfg_dataengine["HDDDEV"] = hdd.currentText onCurrentIndexChanged: cfg_dataengine["HDDDEV"] = model[currentIndex]
Component.onCompleted: { Component.onCompleted: {
for (var i=0; i<model.length; i++) { for (var i=0; i<model.length; i++) {
if (model[i] == cfg_dataengine["HDDDEV"]) { if (model[i] == cfg_dataengine["HDDDEV"]) {

View File

@ -50,7 +50,11 @@ AWKeys::AWKeys(QObject *parent)
QString debugEnv = environment.value(QString("DEBUG"), QString("no")); QString debugEnv = environment.value(QString("DEBUG"), QString("no"));
debug = (debugEnv == QString("yes")); debug = (debugEnv == QString("yes"));
dialog = new QDialog(0); // signals
connect(this, SIGNAL(sourceAdded(QString)), this, SLOT(addSource(QString)));
// init dialog
dialog = new QDialog(nullptr);
widgetDialog = new QListWidget(dialog); widgetDialog = new QListWidget(dialog);
dialogButtons = new QDialogButtonBox(QDialogButtonBox::Open | QDialogButtonBox::Close, dialogButtons = new QDialogButtonBox(QDialogButtonBox::Open | QDialogButtonBox::Close,
Qt::Vertical, dialog); Qt::Vertical, dialog);
@ -91,6 +95,7 @@ void AWKeys::initKeys(const QString pattern,
if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG;
// clear // clear
extQuotes.clear();
extScripts.clear(); extScripts.clear();
extUpgrade.clear(); extUpgrade.clear();
graphicalItems.clear(); graphicalItems.clear();
@ -213,9 +218,10 @@ bool AWKeys::addDevice(const QString source)
(source == QString("pkg")) || (source == QString("pkg")) ||
(source == QString("player")) || (source == QString("player")) ||
(source == QString("ps")) || (source == QString("ps")) ||
(source == QString("update"))) (source == QString("update"))) {
return true; return true;
else { } else {
if (debug) qDebug() << PDEBUG << ":" << "Source" << source << "not found"; if (debug) qDebug() << PDEBUG << ":" << "Source" << source << "not found";
return false; return false;
} }
@ -846,6 +852,14 @@ void AWKeys::editItem(const QString type)
} }
void AWKeys::addSource()
{
if (debug) qDebug() << PDEBUG;
}
void AWKeys::editItemButtonPressed(QAbstractButton *button) void AWKeys::editItemButtonPressed(QAbstractButton *button)
{ {
if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG;

View File

@ -77,7 +77,12 @@ public:
// configuration // configuration
Q_INVOKABLE void editItem(const QString type); Q_INVOKABLE void editItem(const QString type);
signals:
void sourceAdded(const QString source);
private slots: private slots:
void addSource(const QString source);
// editor
void editItemButtonPressed(QAbstractButton *button); void editItemButtonPressed(QAbstractButton *button);
void copyBar(const QString original); void copyBar(const QString original);
void copyQuotes(const QString original); void copyQuotes(const QString original);

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,126 @@
/***************************************************************************
* This file is part of awesome-widgets *
* *
* awesome-widgets is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* awesome-widgets is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef AWKEYS_H
#define AWKEYS_H
#include <QDialog>
#include <QDialogButtonBox>
#include <QListWidget>
#include <QMap>
#include <QObject>
#include <QStringList>
#include <QPushButton>
#include <QVariant>
class ExtQuotes;
class ExtScript;
class ExtUpgrade;
class GraphicalItem;
class AWKeysOperations : public QObject
{
Q_OBJECT
enum RequestedItem {
Nothing,
RequestedGraphicalItem,
RequestedExtQuotes,
RequestedExtScript,
RequestedExtUpgrade
};
typedef struct {
QString key = QString();
QString value = QString();
} AWStruct;
public:
AWKeysOperations(QObject *parent = 0);
~AWKeysOperations();
// keys
AWStruct addDevice(const QString source);
Q_INVOKABLE QStringList dictKeys();
Q_INVOKABLE QStringList getDiskDevices();
Q_INVOKABLE QStringList getFanDevices();
Q_INVOKABLE QStringList getHddDevices(const bool needAbstract = false);
Q_INVOKABLE QStringList getMountDevices();
Q_INVOKABLE QStringList getNetworkDevices();
Q_INVOKABLE QStringList getTempDevices();
Q_INVOKABLE bool setDataBySource(const QString sourceName,
const QMap<QString, QVariant> data,
const QMap<QString, QVariant> params);
// values
Q_INVOKABLE void graphicalValueByKey();
Q_INVOKABLE QString infoByKey(QString key);
Q_INVOKABLE QString valueByKey(QString key);
// configuration
Q_INVOKABLE void editItem(const QString type);
signals:
void sourceAdded(const QString source);
private slots:
void addSource(const QString source);
// editor
void editItemButtonPressed(QAbstractButton *button);
void copyBar(const QString original);
void copyQuotes(const QString original);
void copyScript(const QString original);
void copyUpgrade(const QString original);
private:
// methods
bool checkKeys(const QMap<QString, QVariant> data);
QString networkDevice();
int numberCpus();
float temperature(const float temp, const QString units = QString("Celsius"));
// find methods
QStringList findGraphicalItems(const QString pattern);
QStringList findKeys(const QString pattern);
// get methods
QList<ExtQuotes *> getExtQuotes();
QList<ExtScript *> getExtScripts();
QList<ExtUpgrade *> getExtUpgrade();
QList<GraphicalItem *> getGraphicalItems();
GraphicalItem *getItemByTag(const QString tag);
QStringList getTimeKeys();
// graphical elements
QDialog *dialog = nullptr;
QListWidget *widgetDialog = nullptr;
QDialogButtonBox *dialogButtons = nullptr;
QPushButton *copyButton = nullptr;
QPushButton *createButton = nullptr;
QPushButton *deleteButton = nullptr;
RequestedItem requestedItem = Nothing;
// variables
bool debug = false;
bool enablePopup = false;
bool ready = false;
QList<GraphicalItem *> graphicalItems;
QList<ExtQuotes *> extQuotes;
QList<ExtScript *> extScripts;
QList<ExtUpgrade *> extUpgrade;
QStringList foundBars, foundKeys, keys;
QMap<QString, QString> values;
QStringList diskDevices, fanDevices, mountDevices, tempDevices;
};
#endif /* AWKEYS_H */