Skip to content

Commit

Permalink
Merge pull request #6 from Swistusmen/qt
Browse files Browse the repository at this point in the history
Qt
  • Loading branch information
Swistusmen authored Apr 27, 2021
2 parents a07f881 + 23ab986 commit 80fc5ea
Show file tree
Hide file tree
Showing 4 changed files with 153 additions and 80 deletions.
9 changes: 9 additions & 0 deletions src/ButtonStates.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
Library with whole the buttons used in my interfaces
*/

enum class AppButton {
None,
SwitchToAlgorithms,
SwitchToData
};
45 changes: 39 additions & 6 deletions src/QMainInterface.cpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,50 @@
#include "QMainInterface.h"
#include <qpushbutton.h>
#include <iostream>

QMainInterface::QMainInterface(QWidget* parent) : QWidget(parent)
{
//setFixedSize(366, 300);

ui.setupUi(this);
ui.label->setParent(this);
ui.algoInterface->setParent(this);
connect(this, SIGNAL(algoWasClicked()),
this, SLOT(changeTitle(QString)));
connect(this, SIGNAL(this->dataWasClicked()),
this, SLOT(changeTitle(QString)));
ui.algoInterface->setCheckable(true);
ui.creativInterface->setCheckable(true);
//connect(this, SIGNAL(QMainInterface::algoWasClicked()),
// this, SLOT(QMainInterface::changeTitle(QString)));
connect(ui.algoInterface, &QPushButton::pressed,
this, &QMainInterface::changeTitle);
connect(ui.creativInterface, &QPushButton::pressed,
this, &QMainInterface::changeTitle);

//initializing main image

}

//very temporarly- when ui will be finished there will be no need to use such a circus solution, it's for test
//and until all the ui will be created
AppButton QMainInterface::WhichButton() {
auto buttons = ui.interfaceButtons->buttons();
const int noButtons = buttons.size();
int destination = -1;
for (int i = 0; i < noButtons; i++)
{
if (buttons.at(i)->isChecked() == true)
{
destination = i;
break;
}
buttons.at(i)->setChecked(false);
}
for (int i = 0; i < noButtons; i++)
{
buttons.at(i)->setChecked(false);
}
if (destination == -1)
return AppButton::None;
if (buttons.at(destination)->text() == "Data")
return AppButton::SwitchToData;
else if (buttons.at(destination)->text() == "algorithms")
return AppButton::SwitchToAlgorithms;
else
return AppButton::None;
}
33 changes: 19 additions & 14 deletions src/QMainInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <qwidget.h>
#include "../build/src/ui_QMainInterface.h"
#include <qstringbuilder.h>

#include "ButtonStates.h"

class QPushButton;
class QMainInterface : public QWidget {
Expand All @@ -14,25 +14,30 @@ class QMainInterface : public QWidget {
explicit QMainInterface(QWidget* parent=0);

signals:
void algoWasClicked() {
emit(test_1);
};
void dataWasClicked() {
emit(test_2);
}

public slots:
void changeTitle(QString display) {
ui.label->setText(display);
void changeTitle() {
auto text = this->WhichButton();
switch (text) {
case AppButton::None : {

}break;
case AppButton::SwitchToAlgorithms: {
ui.label->setText("Algorithms");
ui.stackedWidget->setCurrentIndex(1);
}break;
case AppButton::SwitchToData: {
ui.label->setText("Data");
ui.stackedWidget->setCurrentIndex(0);
}break;
}
}
private: //variables
Ui::Form ui;

QString test_1="Geometrical Algorithms";
QString test_2="Data";
QString to_display = "Geometrical Algorithms";

std::vector<std::tuple<QString, bool>> buttons{ {"Algorithms",0},{"Data",0} };
private: //methods

AppButton WhichButton();
};

#endif
146 changes: 86 additions & 60 deletions src/QMainInterface.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,18 @@
<rect>
<x>0</x>
<y>0</y>
<width>482</width>
<height>418</height>
<width>597</width>
<height>462</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>150</x>
<y>370</y>
<width>166</width>
<height>25</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<layout class="QVBoxLayout" name="verticalLayout"/>
</item>
</layout>
</widget>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>170</x>
<y>20</y>
<x>230</x>
<y>10</y>
<width>131</width>
<height>21</height>
</rect>
Expand All @@ -41,56 +26,97 @@
<string>Geometrical Algorithms</string>
</property>
</widget>
<widget class="QLabel" name="welcom_picture">
<property name="geometry">
<rect>
<x>0</x>
<y>50</y>
<width>481</width>
<height>301</height>
</rect>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap>../assets/russel.jpg</pixmap>
</property>
</widget>
<widget class="QPushButton" name="creativInterface">
<widget class="QWidget" name="">
<property name="geometry">
<rect>
<x>150</x>
<y>370</y>
<width>75</width>
<height>23</height>
<x>220</x>
<y>400</y>
<width>164</width>
<height>54</height>
</rect>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string>Data</string>
</property>
<attribute name="buttonGroup">
<string notr="true">interfaceButtons</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="creativInterface">
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string>Data</string>
</property>
<attribute name="buttonGroup">
<string notr="true">interfaceButtons</string>
</attribute>
</widget>
</item>
<item>
<widget class="QPushButton" name="algoInterface">
<property name="text">
<string>algorithms</string>
</property>
<attribute name="buttonGroup">
<string notr="true">interfaceButtons</string>
</attribute>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QPushButton" name="algoInterface">
<widget class="QStackedWidget" name="stackedWidget">
<property name="geometry">
<rect>
<x>230</x>
<y>370</y>
<width>79</width>
<height>23</height>
<x>10</x>
<y>50</y>
<width>581</width>
<height>331</height>
</rect>
</property>
<property name="text">
<string>algorithms</string>
</property>
<attribute name="buttonGroup">
<string notr="true">interfaceButtons</string>
</attribute>
<widget class="QWidget" name="page">
<widget class="QLabel" name="welcom_picture">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>71</width>
<height>51</height>
</rect>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap>../assets/russel.jpg</pixmap>
</property>
</widget>
<widget class="QCalendarWidget" name="calendarWidget">
<property name="geometry">
<rect>
<x>270</x>
<y>20</y>
<width>304</width>
<height>190</height>
</rect>
</property>
</widget>
</widget>
<widget class="QWidget" name="page_2">
<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
<x>270</x>
<y>130</y>
<width>111</width>
<height>71</height>
</rect>
</property>
<property name="text">
<string>Siemka</string>
</property>
</widget>
</widget>
</widget>
</widget>
<resources/>
Expand Down

0 comments on commit 80fc5ea

Please sign in to comment.