• R/O
  • HTTP
  • SSH
  • HTTPS

common_source_project-fm7: Commit

Common Source Code Project for Qt (a.k.a for FM-7).


Commit MetaInfo

Revision66532afe71120b85a93b835f5a2541c406ff7699 (tree)
Time2020-05-23 13:47:51
AuthorK.Ohta <whatisthis.sowhat@gmai...>
CommiterK.Ohta

Log Message

[OOPs][Qt][GUI] I forgot to add a new dialog X-)

Change Summary

Incremental Difference

--- /dev/null
+++ b/source/src/qt/gui/dialog_memory.cpp
@@ -0,0 +1,103 @@
1+/*
2+ * Common Source Project/ Qt
3+ * (C) 2015 K.Ohta <whatisthis.sowhat _at_ gmail.com>
4+ * Qt: Menu->Emulator->Define Strings
5+ * History: Feb 24, 2016 : Initial
6+ */
7+
8+#include "dialog_memory.h"
9+
10+#include <QApplication>
11+#include <QGridLayout>
12+#include <QLabel>
13+#include <QSpinBox>
14+#include <QLabel>
15+#include <QPushButton>
16+
17+#include "config.h"
18+#include "menu_flags.h"
19+
20+CSP_MemoryDialog::CSP_MemoryDialog(USING_FLAGS *p, QWidget *parent) : QWidget(parent)
21+{
22+ p_wid = parent;
23+ using_flags = p;
24+ p_config = NULL;
25+ _min = -1;
26+ _max = -1;
27+ current_val = -1;
28+ layout = new QGridLayout(this);
29+ label_head = new QLabel(QApplication::translate("MemorySetDialog", "<B>Memory Size</B>", 0));
30+ layout->addWidget(label_head);
31+
32+ spin_ram = new QSpinBox(this);
33+ current_val = -1;
34+
35+ if(p != NULL) {
36+ p_config = p->get_config_ptr();
37+ order = p->get_ram_size_order();
38+ _max = p->get_max_ram_size();
39+ _min = p->get_min_ram_size();
40+ current_val = p_config->current_ram_size;
41+ }
42+ QString orderstring;
43+ spin_ram->setEnabled(true);
44+ if((order == 0) || (_max < 0) || (_min < 0)) {
45+ spin_ram->setEnabled(false);
46+ orderstring = QString::fromUtf8("");
47+ } else if(order < 1024) {
48+ orderstring = QString::fromUtf8("x %1Bytes").arg(order);
49+ } else if(order == 1024) {
50+ orderstring = QString::fromUtf8("KBytes");
51+ } else if(order < (1024 * 1024)) {
52+ orderstring = QString::fromUtf8("x %1KBytes").arg(order);
53+ } else if(order == (1024 * 1024)) {
54+ orderstring = QString::fromUtf8("MBytes");
55+ } else {
56+ orderstring = QString::fromUtf8("x %1MBytes").arg(order);
57+ }
58+ order_label = new QLabel(orderstring);
59+ if(_max < _min) _min = _max;
60+ if(current_val > _max) current_val = _max;
61+ if(current_val < _min) current_val = _min;
62+
63+ spin_ram->setMaximum(_max);
64+ spin_ram->setMinimum(_min);
65+ spin_ram->setValue(current_val);
66+
67+ reset_button = new QPushButton(QApplication::translate("MemoryDialog", "Reset", 0));
68+ cancel_button = new QPushButton(QApplication::translate("MemoryDialog", "Cancel", 0));
69+ close_button = new QPushButton(QApplication::translate("MemoryDialog", "Save Options", 0));
70+
71+ connect(close_button, SIGNAL(clicked()), this, SLOT(do_set_value()));
72+ connect(close_button, SIGNAL(clicked()), this, SLOT(do_reset_value()));
73+ connect(cancel_button, SIGNAL(clicked()), this, SLOT(close()));
74+
75+ layout->addWidget(label_head, 0, 0);
76+ layout->addWidget(spin_ram, 1, 0);
77+ layout->addWidget(order_label, 1, 2);
78+ layout->addWidget(reset_button, 3, 0);
79+ layout->addWidget(cancel_button, 3, 2);
80+ layout->addWidget(close_button, 3, 3);
81+ this->setLayout(layout);
82+}
83+
84+CSP_MemoryDialog::~CSP_MemoryDialog()
85+{
86+}
87+void CSP_MemoryDialog::do_set_value()
88+{
89+ if(p_config != NULL) {
90+ int val = spin_ram->value();
91+ if(val < _min) val = _min;
92+ if(val > _max) val = _max;
93+ if(val < 0) val = 0;
94+ p_config->current_ram_size = val;
95+ // Update config?
96+ }
97+ close();
98+}
99+
100+void CSP_MemoryDialog::do_reset_value()
101+{
102+ spin_ram->setValue(current_val);
103+}
--- /dev/null
+++ b/source/src/qt/gui/dialog_memory.h
@@ -0,0 +1,45 @@
1+
2+#pragma once
3+
4+#include <QWidget>
5+
6+class QGridLayout;
7+class QLabel;
8+class QSpinBox;
9+class QLabel;
10+class QPushButton;
11+
12+#include "../../config.h"
13+class USING_FLAGS;
14+
15+QT_BEGIN_NAMESPACE
16+class CSP_MemoryDialog : public QWidget {
17+ Q_OBJECT
18+protected:
19+ config_t* p_config;
20+ USING_FLAGS* using_flags;
21+ QWidget *p_wid;
22+
23+ int _min;
24+ int _max;
25+ int current_val;
26+ uint32_t order;
27+
28+ QGridLayout *layout;
29+ QLabel *label_head;
30+ QSpinBox *spin_ram;
31+ QLabel *order_label;
32+
33+ QPushButton *reset_button;
34+ QPushButton *cancel_button;
35+ QPushButton *close_button;
36+
37+public:
38+ CSP_MemoryDialog(USING_FLAGS *p, QWidget *parent);
39+ ~CSP_MemoryDialog();
40+
41+public slots:
42+ void do_set_value();
43+ void do_reset_value();
44+};
45+QT_END_NAMESPACE
Show on old repository browser