summaryrefslogtreecommitdiff
path: root/qt/RGBController
diff options
context:
space:
mode:
Diffstat (limited to 'qt/RGBController')
-rw-r--r--qt/RGBController/.controllerwindow.cpp.swobin0 -> 16384 bytes
-rw-r--r--qt/RGBController/.controllerwindow.h.swobin0 -> 12288 bytes
-rwxr-xr-xqt/RGBController/controllerwindow.cpp47
-rwxr-xr-xqt/RGBController/controllerwindow.h5
-rwxr-xr-xqt/RGBController/controllerwindow.ui28
5 files changed, 68 insertions, 12 deletions
diff --git a/qt/RGBController/.controllerwindow.cpp.swo b/qt/RGBController/.controllerwindow.cpp.swo
new file mode 100644
index 0000000..39ed63a
--- /dev/null
+++ b/qt/RGBController/.controllerwindow.cpp.swo
Binary files differ
diff --git a/qt/RGBController/.controllerwindow.h.swo b/qt/RGBController/.controllerwindow.h.swo
new file mode 100644
index 0000000..b273e95
--- /dev/null
+++ b/qt/RGBController/.controllerwindow.h.swo
Binary files differ
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>