diff options
-rw-r--r-- | qt/RGBController/.controllerwindow.cpp.swo | bin | 0 -> 16384 bytes | |||
-rw-r--r-- | qt/RGBController/.controllerwindow.h.swo | bin | 0 -> 12288 bytes | |||
-rwxr-xr-x | qt/RGBController/controllerwindow.cpp | 47 | ||||
-rwxr-xr-x | qt/RGBController/controllerwindow.h | 5 | ||||
-rwxr-xr-x | qt/RGBController/controllerwindow.ui | 28 | ||||
-rwxr-xr-x | qt/build/degub/RGBController | bin | 1294552 -> 1300072 bytes | |||
-rw-r--r-- | qt/build/degub/controllerwindow.o | bin | 994448 -> 1007624 bytes | |||
-rw-r--r-- | qt/build/degub/main.o | bin | 872920 -> 872920 bytes | |||
-rwxr-xr-x | qt/build/degub/moc_controllerwindow.cpp | 48 | ||||
-rw-r--r-- | qt/build/degub/moc_controllerwindow.o | bin | 970056 -> 971016 bytes | |||
-rw-r--r-- | qt/build/degub/presets.txt (renamed from qt/build/degub/old.txt) | 1 | ||||
-rw-r--r-- | qt/build/degub/serial_communication.o | bin | 533368 -> 533368 bytes | |||
-rwxr-xr-x | qt/build/degub/ui_controllerwindow.h | 30 |
13 files changed, 116 insertions, 43 deletions
diff --git a/qt/RGBController/.controllerwindow.cpp.swo b/qt/RGBController/.controllerwindow.cpp.swo Binary files differnew file mode 100644 index 0000000..39ed63a --- /dev/null +++ b/qt/RGBController/.controllerwindow.cpp.swo diff --git a/qt/RGBController/.controllerwindow.h.swo b/qt/RGBController/.controllerwindow.h.swo Binary files differnew file mode 100644 index 0000000..b273e95 --- /dev/null +++ b/qt/RGBController/.controllerwindow.h.swo diff --git a/qt/RGBController/controllerwindow.cpp b/qt/RGBController/controllerwindow.cpp index c5a8e4d..250be58 100755 --- a/qt/RGBController/controllerwindow.cpp +++ b/qt/RGBController/controllerwindow.cpp @@ -16,6 +16,8 @@ controllerWindow::controllerWindow(QWidget *parent) : ui->off_button->setEnabled(false); ui->reload_preset_button->setEnabled(false); ui->set_preset_button->setEnabled(false); + ui->preset_save_button->setEnabled(false); + ui->preset_name_textbox->setEnabled(false); ui->presets_dropdown->setEnabled(false); ui->r_slider->setEnabled(false); ui->g_slider->setEnabled(false); @@ -99,7 +101,28 @@ void controllerWindow::load_presets() { show_msgbox("Unable to find the presets fle.\nThis file needs to be named 'presets.txt' and be located in the same directory as the binary."); info_log("Presets file not found."); - } + } +} + +void controllerWindow::save_preset(QString name) +{ + /* this function will save our preset to file */ + QFile file("presets.txt"); + if(!file.open(QIODevice::Append)) { + show_msgbox("Fatal error opening presets for appending text."); + + } else + { + QTextStream stream(&file); + stream << name << "=" << ui->r_slider->value() << "," << ui->g_slider->value() << "," << ui->b_slider->value() << endl; + file.close(); + info_log("Saved preset: " + name); + /* things to fix the presets list */ + ui->presets_dropdown->clear(); + presets.clear(); + preset_index = 0; + load_presets(); + } } void controllerWindow::serial_rgb_change(int r, int g, int b) @@ -141,6 +164,8 @@ void controllerWindow::on_connect_button_clicked() ui->off_button->setEnabled(true); ui->reload_preset_button->setEnabled(true); ui->set_preset_button->setEnabled(true); + ui->preset_save_button->setEnabled(true); + ui->preset_name_textbox->setEnabled(true); ui->presets_dropdown->setEnabled(true); ui->r_slider->setEnabled(true); ui->g_slider->setEnabled(true); @@ -171,6 +196,8 @@ void controllerWindow::on_disconnect_button_clicked() ui->blue_button->setEnabled(false); ui->off_button->setEnabled(false); ui->reload_preset_button->setEnabled(false); + ui->preset_save_button->setEnabled(false); + ui->preset_name_textbox->setEnabled(false); ui->set_preset_button->setEnabled(false); ui->presets_dropdown->setEnabled(false); ui->refresh_port_button->setEnabled(true); @@ -257,10 +284,26 @@ void controllerWindow::on_set_preset_button_clicked() ui->r_slider->setValue(temparray[0].toInt()); ui->g_slider->setValue(temparray[1].toInt()); ui->b_slider->setValue(temparray[2].toInt()); - } + } else + show_msgbox("There are no loaded presets!"); } void controllerWindow::on_presets_dropdown_currentIndexChanged(int index) { preset_index = index; } + +void controllerWindow::on_preset_save_button_clicked() +{ + QString tempname = ui->preset_name_textbox->text(); + if (tempname.contains("=")) + { + show_msgbox("Cannot save a preset with a name that contains an '='."); + } else if (tempname.isEmpty()) + { + show_msgbox("Cannot save a preset without a name."); + } else + { + save_preset(tempname); + } +} diff --git a/qt/RGBController/controllerwindow.h b/qt/RGBController/controllerwindow.h index d8c2403..690b52d 100755 --- a/qt/RGBController/controllerwindow.h +++ b/qt/RGBController/controllerwindow.h @@ -28,6 +28,7 @@ class controllerWindow : public QMainWindow void info_log(QString text); void populate_serial_list(); void load_presets(); + void save_preset(QString name); void serial_rgb_change(int r, int g, int b); void show_msgbox(QString message); /*public variables */ @@ -68,7 +69,9 @@ class controllerWindow : public QMainWindow void on_presets_dropdown_currentIndexChanged(int index); - private: + void on_preset_save_button_clicked(); + +private: Ui::controllerWindow *ui; /* serial communication object */ serial_communication portf; diff --git a/qt/RGBController/controllerwindow.ui b/qt/RGBController/controllerwindow.ui index e96fcf0..8ee839e 100755 --- a/qt/RGBController/controllerwindow.ui +++ b/qt/RGBController/controllerwindow.ui @@ -9,8 +9,8 @@ <rect> <x>0</x> <y>0</y> - <width>229</width> - <height>394</height> + <width>235</width> + <height>402</height> </rect> </property> <property name="windowTitle"> @@ -184,13 +184,6 @@ </property> </widget> </item> - <item row="11" column="1"> - <widget class="QPushButton" name="reload_preset_button"> - <property name="text"> - <string>Reload</string> - </property> - </widget> - </item> <item row="10" column="1"> <widget class="QPushButton" name="set_preset_button"> <property name="text"> @@ -211,6 +204,23 @@ <item row="13" column="0" colspan="2"> <widget class="QTextEdit" name="info_log_textarea"/> </item> + <item row="11" column="0"> + <widget class="QLineEdit" name="preset_name_textbox"/> + </item> + <item row="12" column="1"> + <widget class="QPushButton" name="reload_preset_button"> + <property name="text"> + <string>Reload</string> + </property> + </widget> + </item> + <item row="11" column="1"> + <widget class="QPushButton" name="preset_save_button"> + <property name="text"> + <string>Save</string> + </property> + </widget> + </item> </layout> </widget> </widget> diff --git a/qt/build/degub/RGBController b/qt/build/degub/RGBController Binary files differindex 5697898..fecc4e7 100755 --- a/qt/build/degub/RGBController +++ b/qt/build/degub/RGBController diff --git a/qt/build/degub/controllerwindow.o b/qt/build/degub/controllerwindow.o Binary files differindex 650edf3..c5c9213 100644 --- a/qt/build/degub/controllerwindow.o +++ b/qt/build/degub/controllerwindow.o diff --git a/qt/build/degub/main.o b/qt/build/degub/main.o Binary files differindex 1f486a8..8f14278 100644 --- a/qt/build/degub/main.o +++ b/qt/build/degub/main.o diff --git a/qt/build/degub/moc_controllerwindow.cpp b/qt/build/degub/moc_controllerwindow.cpp index 6541f0e..8d6a754 100755 --- a/qt/build/degub/moc_controllerwindow.cpp +++ b/qt/build/degub/moc_controllerwindow.cpp @@ -19,8 +19,8 @@ QT_BEGIN_MOC_NAMESPACE struct qt_meta_stringdata_controllerWindow_t { - QByteArrayData data[17]; - char stringdata0[383]; + QByteArrayData data[18]; + char stringdata0[413]; }; #define QT_MOC_LITERAL(idx, ofs, len) \ Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \ @@ -45,7 +45,8 @@ QT_MOC_LITERAL(12, 263, 22), // "on_blue_button_clicked" QT_MOC_LITERAL(13, 286, 21), // "on_off_button_clicked" QT_MOC_LITERAL(14, 308, 28), // "on_set_preset_button_clicked" QT_MOC_LITERAL(15, 337, 39), // "on_presets_dropdown_currentIn..." -QT_MOC_LITERAL(16, 377, 5) // "index" +QT_MOC_LITERAL(16, 377, 5), // "index" +QT_MOC_LITERAL(17, 383, 29) // "on_preset_save_button_clicked" }, "controllerWindow\0on_connect_button_clicked\0" @@ -59,7 +60,7 @@ QT_MOC_LITERAL(16, 377, 5) // "index" "on_off_button_clicked\0" "on_set_preset_button_clicked\0" "on_presets_dropdown_currentIndexChanged\0" - "index" + "index\0on_preset_save_button_clicked" }; #undef QT_MOC_LITERAL @@ -69,7 +70,7 @@ static const uint qt_meta_data_controllerWindow[] = { 7, // revision 0, // classname 0, 0, // classinfo - 13, 14, // methods + 14, 14, // methods 0, 0, // properties 0, 0, // enums/sets 0, 0, // constructors @@ -77,19 +78,20 @@ static const uint qt_meta_data_controllerWindow[] = { 0, // signalCount // slots: name, argc, parameters, tag, flags - 1, 0, 79, 2, 0x08 /* Private */, - 3, 0, 80, 2, 0x08 /* Private */, - 4, 0, 81, 2, 0x08 /* Private */, - 5, 0, 82, 2, 0x08 /* Private */, - 6, 1, 83, 2, 0x08 /* Private */, - 8, 1, 86, 2, 0x08 /* Private */, - 9, 1, 89, 2, 0x08 /* Private */, - 10, 0, 92, 2, 0x08 /* Private */, - 11, 0, 93, 2, 0x08 /* Private */, - 12, 0, 94, 2, 0x08 /* Private */, - 13, 0, 95, 2, 0x08 /* Private */, - 14, 0, 96, 2, 0x08 /* Private */, - 15, 1, 97, 2, 0x08 /* Private */, + 1, 0, 84, 2, 0x08 /* Private */, + 3, 0, 85, 2, 0x08 /* Private */, + 4, 0, 86, 2, 0x08 /* Private */, + 5, 0, 87, 2, 0x08 /* Private */, + 6, 1, 88, 2, 0x08 /* Private */, + 8, 1, 91, 2, 0x08 /* Private */, + 9, 1, 94, 2, 0x08 /* Private */, + 10, 0, 97, 2, 0x08 /* Private */, + 11, 0, 98, 2, 0x08 /* Private */, + 12, 0, 99, 2, 0x08 /* Private */, + 13, 0, 100, 2, 0x08 /* Private */, + 14, 0, 101, 2, 0x08 /* Private */, + 15, 1, 102, 2, 0x08 /* Private */, + 17, 0, 105, 2, 0x08 /* Private */, // slots: parameters QMetaType::Void, @@ -105,6 +107,7 @@ static const uint qt_meta_data_controllerWindow[] = { QMetaType::Void, QMetaType::Void, QMetaType::Void, QMetaType::Int, 16, + QMetaType::Void, 0 // eod }; @@ -128,6 +131,7 @@ void controllerWindow::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int case 10: _t->on_off_button_clicked(); break; case 11: _t->on_set_preset_button_clicked(); break; case 12: _t->on_presets_dropdown_currentIndexChanged((*reinterpret_cast< int(*)>(_a[1]))); break; + case 13: _t->on_preset_save_button_clicked(); break; default: ; } } @@ -158,13 +162,13 @@ int controllerWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a) if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { - if (_id < 13) + if (_id < 14) qt_static_metacall(this, _c, _id, _a); - _id -= 13; + _id -= 14; } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) { - if (_id < 13) + if (_id < 14) *reinterpret_cast<int*>(_a[0]) = -1; - _id -= 13; + _id -= 14; } return _id; } diff --git a/qt/build/degub/moc_controllerwindow.o b/qt/build/degub/moc_controllerwindow.o Binary files differindex dd21680..5adbd14 100644 --- a/qt/build/degub/moc_controllerwindow.o +++ b/qt/build/degub/moc_controllerwindow.o diff --git a/qt/build/degub/old.txt b/qt/build/degub/presets.txt index 776a532..7bc9af4 100644 --- a/qt/build/degub/old.txt +++ b/qt/build/degub/presets.txt @@ -9,4 +9,3 @@ purple=255,0,255 light purple=255,55,255 yellow=255,83,0 light blue=0,255,255 - diff --git a/qt/build/degub/serial_communication.o b/qt/build/degub/serial_communication.o Binary files differindex f00df38..dd01faa 100644 --- a/qt/build/degub/serial_communication.o +++ b/qt/build/degub/serial_communication.o diff --git a/qt/build/degub/ui_controllerwindow.h b/qt/build/degub/ui_controllerwindow.h index 1bebf40..f110c61 100755 --- a/qt/build/degub/ui_controllerwindow.h +++ b/qt/build/degub/ui_controllerwindow.h @@ -17,6 +17,7 @@ #include <QtWidgets/QFormLayout> #include <QtWidgets/QHeaderView> #include <QtWidgets/QLabel> +#include <QtWidgets/QLineEdit> #include <QtWidgets/QMainWindow> #include <QtWidgets/QPushButton> #include <QtWidgets/QSlider> @@ -47,17 +48,19 @@ public: QLabel *presets_label; QPushButton *off_button; QLabel *info_log_label; - QPushButton *reload_preset_button; QPushButton *set_preset_button; QComboBox *presets_dropdown; QTextEdit *info_log_textarea; + QLineEdit *preset_name_textbox; + QPushButton *reload_preset_button; + QPushButton *preset_save_button; void setupUi(QMainWindow *controllerWindow) { if (controllerWindow->objectName().isEmpty()) controllerWindow->setObjectName(QStringLiteral("controllerWindow")); controllerWindow->setWindowModality(Qt::WindowModal); - controllerWindow->resize(229, 394); + controllerWindow->resize(235, 402); centralWidget = new QWidget(controllerWindow); centralWidget->setObjectName(QStringLiteral("centralWidget")); formLayout = new QFormLayout(centralWidget); @@ -162,11 +165,6 @@ public: formLayout->setWidget(12, QFormLayout::LabelRole, info_log_label); - reload_preset_button = new QPushButton(centralWidget); - reload_preset_button->setObjectName(QStringLiteral("reload_preset_button")); - - formLayout->setWidget(11, QFormLayout::FieldRole, reload_preset_button); - set_preset_button = new QPushButton(centralWidget); set_preset_button->setObjectName(QStringLiteral("set_preset_button")); @@ -183,6 +181,21 @@ public: formLayout->setWidget(13, QFormLayout::SpanningRole, info_log_textarea); + preset_name_textbox = new QLineEdit(centralWidget); + preset_name_textbox->setObjectName(QStringLiteral("preset_name_textbox")); + + formLayout->setWidget(11, QFormLayout::LabelRole, preset_name_textbox); + + reload_preset_button = new QPushButton(centralWidget); + reload_preset_button->setObjectName(QStringLiteral("reload_preset_button")); + + formLayout->setWidget(12, QFormLayout::FieldRole, reload_preset_button); + + preset_save_button = new QPushButton(centralWidget); + preset_save_button->setObjectName(QStringLiteral("preset_save_button")); + + formLayout->setWidget(11, QFormLayout::FieldRole, preset_save_button); + controllerWindow->setCentralWidget(centralWidget); retranslateUi(controllerWindow); @@ -206,8 +219,9 @@ public: presets_label->setText(QApplication::translate("controllerWindow", "Presets", 0)); off_button->setText(QApplication::translate("controllerWindow", "Off", 0)); info_log_label->setText(QApplication::translate("controllerWindow", "Information log", 0)); - reload_preset_button->setText(QApplication::translate("controllerWindow", "Reload", 0)); set_preset_button->setText(QApplication::translate("controllerWindow", "Set", 0)); + reload_preset_button->setText(QApplication::translate("controllerWindow", "Reload", 0)); + preset_save_button->setText(QApplication::translate("controllerWindow", "Save", 0)); } // retranslateUi }; |