Buttons functionality
This commit is contained in:
parent
67e63561c4
commit
6b2dacb28f
4 changed files with 50 additions and 0 deletions
|
|
@ -66,6 +66,15 @@ const QList<Line> &GridPreview::getLines() const
|
||||||
return lines;
|
return lines;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GridPreview::clear()
|
||||||
|
{
|
||||||
|
lines.clear();
|
||||||
|
width = 5;
|
||||||
|
height = 5;
|
||||||
|
|
||||||
|
emit updatedContents();
|
||||||
|
}
|
||||||
|
|
||||||
const Line &GridPreview::getLine(int index) const
|
const Line &GridPreview::getLine(int index) const
|
||||||
{
|
{
|
||||||
return lines.at(index);
|
return lines.at(index);
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,8 @@ public:
|
||||||
PointProbe& getCapturedProbe();
|
PointProbe& getCapturedProbe();
|
||||||
const QList<Line>& getLines() const;
|
const QList<Line>& getLines() const;
|
||||||
|
|
||||||
|
void clear();
|
||||||
|
|
||||||
const QString toLuaTable();
|
const QString toLuaTable();
|
||||||
void paintEvent(QPaintEvent* event);
|
void paintEvent(QPaintEvent* event);
|
||||||
const QColor colorFromString(const QString color);
|
const QColor colorFromString(const QString color);
|
||||||
|
|
|
||||||
|
|
@ -90,3 +90,35 @@ bool MainWindow::isSelectedLineCorrect(int line)
|
||||||
return line >= 0 && line < size && size > 0;
|
return line >= 0 && line < size && size > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MainWindow::on_buttonSave_clicked()
|
||||||
|
{
|
||||||
|
QString fileName = QFileDialog::getSaveFileName(this, QString("Save grid"), ".", "Lua source code (*.lua)");
|
||||||
|
QFile file(fileName);
|
||||||
|
if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
|
||||||
|
return;
|
||||||
|
|
||||||
|
QTextStream out(&file);
|
||||||
|
out << ui->gridPreview->toLuaTable();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MainWindow::on_buttonClear_clicked()
|
||||||
|
{
|
||||||
|
ui->gridPreview->clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MainWindow::on_buttonDeleteLine_clicked()
|
||||||
|
{
|
||||||
|
int selected = ui->listLines->currentRow();
|
||||||
|
|
||||||
|
if (!isSelectedLineCorrect(selected))
|
||||||
|
return;
|
||||||
|
|
||||||
|
ui->gridPreview->getCapturedProbe().ownerIndex = -1;
|
||||||
|
ui->gridPreview->removeLine(selected);
|
||||||
|
|
||||||
|
ui->listLines->clearSelection();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
#define MAINWINDOW_H
|
#define MAINWINDOW_H
|
||||||
|
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
|
#include <QFileDialog>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
|
|
@ -29,6 +30,12 @@ private slots:
|
||||||
void on_comboLineColor_currentTextChanged(const QString &arg1);
|
void on_comboLineColor_currentTextChanged(const QString &arg1);
|
||||||
void on_listLines_currentRowChanged(int currentRow);
|
void on_listLines_currentRowChanged(int currentRow);
|
||||||
|
|
||||||
|
void on_buttonSave_clicked();
|
||||||
|
|
||||||
|
void on_buttonClear_clicked();
|
||||||
|
|
||||||
|
void on_buttonDeleteLine_clicked();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::MainWindow *ui;
|
Ui::MainWindow *ui;
|
||||||
int lastEditedLine = -1;
|
int lastEditedLine = -1;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue