Skip to content

Commit

Permalink
Added properties window and worked on GUI
Browse files Browse the repository at this point in the history
  • Loading branch information
nametable committed Feb 28, 2018
1 parent 00b8267 commit 503fef6
Show file tree
Hide file tree
Showing 9 changed files with 217 additions and 9 deletions.
9 changes: 6 additions & 3 deletions ScoringEngine.pro
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ SOURCES += \
checker.cpp \
emptyscorechecker.cpp \
valuescorechecker.cpp \
scriptscorechecker.cpp
scriptscorechecker.cpp \
configpropertieswindow.cpp

HEADERS += \
mainwindow.h \
Expand All @@ -48,10 +49,12 @@ HEADERS += \
checker.h \
emptyscorechecker.h \
valuescorechecker.h \
scriptscorechecker.h
scriptscorechecker.h \
configpropertieswindow.h

FORMS += \
mainwindow.ui
mainwindow.ui \
configpropertieswindow.ui

!debug {
INCLUDEPATH += /home/logan/Documents/Libraries/boost_1_65_1
Expand Down
26 changes: 26 additions & 0 deletions configpropertieswindow.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include "configpropertieswindow.h"
#include "ui_configpropertieswindow.h"

ConfigPropertiesWindow::ConfigPropertiesWindow(QWidget *parent) :
QDialog(parent),
ui(new Ui::ConfigPropertiesWindow)
{
ui->setupUi(this);
}
ConfigPropertiesWindow::ConfigPropertiesWindow(QWidget *parent, ScoreCheckingConfig *config) :
QDialog(parent),
ui(new Ui::ConfigPropertiesWindow)
{
this->config=config;
ui->setupUi(this);
}

ConfigPropertiesWindow::~ConfigPropertiesWindow()
{
delete ui;
}

void ConfigPropertiesWindow::on_buttonBox_accepted()
{

}
27 changes: 27 additions & 0 deletions configpropertieswindow.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#ifndef CONFIGPROPERTIESWINDOW_H
#define CONFIGPROPERTIESWINDOW_H

#include <QDialog>
#include "scorecheckingconfig.h"
namespace Ui {
class ConfigPropertiesWindow;
}

class ConfigPropertiesWindow : public QDialog
{
Q_OBJECT

public:
explicit ConfigPropertiesWindow(QWidget *parent = 0);
explicit ConfigPropertiesWindow(QWidget *parent = 0, ScoreCheckingConfig *config=0);
~ConfigPropertiesWindow();

private slots:
void on_buttonBox_accepted();

private:
Ui::ConfigPropertiesWindow *ui;
ScoreCheckingConfig *config;
};

#endif // CONFIGPROPERTIESWINDOW_H
137 changes: 137 additions & 0 deletions configpropertieswindow.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ConfigPropertiesWindow</class>
<widget class="QDialog" name="ConfigPropertiesWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>389</width>
<height>285</height>
</rect>
</property>
<property name="windowTitle">
<string>Edit Config Properties</string>
</property>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="geometry">
<rect>
<x>30</x>
<y>240</y>
<width>341</width>
<height>32</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>20</x>
<y>100</y>
<width>101</width>
<height>17</height>
</rect>
</property>
<property name="text">
<string>Refresh Time</string>
</property>
</widget>
<widget class="QSpinBox" name="spinSeconds">
<property name="geometry">
<rect>
<x>130</x>
<y>90</y>
<width>51</width>
<height>26</height>
</rect>
</property>
</widget>
<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
<x>20</x>
<y>20</y>
<width>101</width>
<height>17</height>
</rect>
</property>
<property name="text">
<string>Name</string>
</property>
</widget>
<widget class="QLineEdit" name="txtName">
<property name="geometry">
<rect>
<x>130</x>
<y>10</y>
<width>211</width>
<height>25</height>
</rect>
</property>
</widget>
<widget class="QLineEdit" name="txtPassphrase">
<property name="geometry">
<rect>
<x>130</x>
<y>50</y>
<width>211</width>
<height>25</height>
</rect>
</property>
</widget>
<widget class="QLabel" name="label_3">
<property name="geometry">
<rect>
<x>20</x>
<y>60</y>
<width>101</width>
<height>17</height>
</rect>
</property>
<property name="text">
<string>Passphrase</string>
</property>
</widget>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>ConfigPropertiesWindow</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>ConfigPropertiesWindow</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>
9 changes: 9 additions & 0 deletions mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@
#include <QFileDialog>
#include "runcommandscorechecker.h"
#include "emptyscorechecker.h"
#include "configpropertieswindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);

//confmen
statusBar()->showMessage("Program loaded.");
//RunCommandScoreChecker testcheck;
//testcheck.setCommand("ls");
Expand Down Expand Up @@ -105,3 +108,9 @@ void MainWindow::TestScoreCheckers() //This is all a test. Not for production...
std::cout << "SCript" << std::endl << static_cast<ScriptScoreChecker*>(config->vecScoreCheckers->at(3))->getScript() << std::endl;

}

void MainWindow::on_actionConfiguration_Prefs_triggered()
{
ConfigPropertiesWindow *confmenu= new ConfigPropertiesWindow(0,this->config);
confmenu->show();
}
2 changes: 2 additions & 0 deletions mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ private slots:

void on_actionInsert_Blank_triggered();

void on_actionConfiguration_Prefs_triggered();

private:
Ui::MainWindow *ui;
MyScoringModel *scoringmodel;
Expand Down
2 changes: 2 additions & 0 deletions mydelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ void MyDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
model->setData(index,combo->currentIndex());
break;
case 4:
lineedit = static_cast<QLineEdit*>(editor);
model->setData(index,lineedit->text());
break;
case 5: //ScoreChecker point value
spinbox = static_cast<QSpinBox*>(editor);
Expand Down
11 changes: 6 additions & 5 deletions myscoringmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ QVariant MyScoringModel::data(const QModelIndex &index, int role) const
}
break;
case 4: //ScoreChecker Opt3
//return QString("nothing");
if (index.model()->data(index.sibling(index.row(),0), Qt::DisplayRole).toString()=="")break;
value = index.model()->data(index.sibling(index.row(),0), Qt::EditRole).toInt();
switch(value)
Expand All @@ -197,7 +198,7 @@ QVariant MyScoringModel::data(const QModelIndex &index, int role) const
{
case Qt::DisplayRole:
case Qt::EditRole:
return static_cast<RunCommandScoreChecker*>(vecScoreCheckers->at(index.row()))->getSearchString().c_str();
return QString(static_cast<RunCommandScoreChecker*>(vecScoreCheckers->at(index.row()))->getSearchString().c_str());
break;
}
break;
Expand All @@ -206,7 +207,7 @@ QVariant MyScoringModel::data(const QModelIndex &index, int role) const
{
case Qt::DisplayRole:
case Qt::EditRole:
return static_cast<ValueScoreChecker*>(vecScoreCheckers->at(index.row()))->getSearchString().c_str();
return QString(static_cast<ValueScoreChecker*>(vecScoreCheckers->at(index.row()))->getSearchString().c_str());
break;
}
break;
Expand All @@ -215,7 +216,7 @@ QVariant MyScoringModel::data(const QModelIndex &index, int role) const
{
case Qt::DisplayRole:
case Qt::EditRole:
return static_cast<ScriptScoreChecker*>(vecScoreCheckers->at(index.row()))->getSearchString().c_str();
return QString(static_cast<ScriptScoreChecker*>(vecScoreCheckers->at(index.row()))->getSearchString().c_str());
break;
}
break;
Expand Down Expand Up @@ -407,10 +408,10 @@ bool MyScoringModel::setData(const QModelIndex &index, const QVariant &value, in
(static_cast<RunCommandScoreChecker*>(basecheck))->setSearchString(value.toString().toStdString());
break;
case 2: //ValueCheck
static_cast<ValueScoreChecker*>(basecheck)->setSearchString(value.toString().toStdString());
(static_cast<ValueScoreChecker*>(basecheck))->setSearchString(value.toString().toStdString());
break;
case 3: //ScriptCheck
static_cast<ScriptScoreChecker*>(basecheck)->setSearchString(value.toString().toStdString());
(static_cast<ScriptScoreChecker*>(basecheck))->setSearchString(value.toString().toStdString());
break;
case 4: //CompoundCheck
//static_cast<PathExistScoreChecker*>(basecheck)->setSearchString(value.toString());
Expand Down
3 changes: 2 additions & 1 deletion pathexistscorechecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ PathExistScoreChecker::PathExistScoreChecker()
void PathExistScoreChecker::checkState()
{
this->state=(boost::filesystem::exists(filepath) == this->desireExist);
if (this->state){this->soundWin();}else{this->soundLose();}
//if (this->state){this->soundWin();}else{this->soundLose();}
//no need to play sound now
}
void PathExistScoreChecker::setFilepath(std::string newFilepath)
{
Expand Down

0 comments on commit 503fef6

Please sign in to comment.