Changed central widget to be a stacked widget that will contain multiple widget which can be travered through a combobox

This commit is contained in:
amazing-username
2019-05-12 13:53:38 -04:00
parent bab490f714
commit b6e91d0c18
5 changed files with 150 additions and 17 deletions
+53 -13
View File
@@ -5,6 +5,7 @@
#include"Models/UploadForm.h"
#include"Syncers/Upload.h"
#include"Utilities/Conversions.h"
using std::cout;
using std::endl;
@@ -32,21 +33,21 @@ namespace UI
urlQt = unique_ptr<QTextEdit>{new QTextEdit()};
sourceFilePathQt = unique_ptr<QTextEdit>{new QTextEdit()};
urlLabel = unique_ptr<QLabel>{new QLabel(tr("URL"))};
songPath = unique_ptr<QLabel>{new QLabel(tr("Song Path"))};
urlLabel = unique_ptr<QLabel>{new QLabel(tr("URL"))};
songPath = unique_ptr<QLabel>{new QLabel(tr("Song Path"))};
urlPortion = unique_ptr<QHBoxLayout>{new QHBoxLayout};
songPathPortion = unique_ptr<QHBoxLayout>{new QHBoxLayout};
urlPortion = unique_ptr<QHBoxLayout>{new QHBoxLayout};
songPathPortion = unique_ptr<QHBoxLayout>{new QHBoxLayout};
urlPortion.get()->addWidget(urlLabel.get());
urlPortion.get()->addWidget(urlQt.get());
urlPortion.get()->addWidget(urlLabel.get());
urlPortion.get()->addWidget(urlQt.get());
songPathPortion->addWidget(songPath.get());
songPathPortion->addWidget(sourceFilePathQt.get());
songPathPortion->addWidget(songPath.get());
songPathPortion->addWidget(sourceFilePathQt.get());
subLayoutOneQt = unique_ptr<QVBoxLayout>{new QVBoxLayout};
subLayoutOneQt.get()->addLayout(urlPortion.get());
subLayoutOneQt->addLayout(songPathPortion.get());
subLayoutOneQt.get()->addLayout(urlPortion.get());
subLayoutOneQt->addLayout(songPathPortion.get());
mainLayoutQt.get()->addLayout(subLayoutOneQt.get());
}
void MainWindow::configureWindowDimensions()
@@ -67,6 +68,8 @@ namespace UI
SLOT(exitApplication()));
QObject::connect(aboutApplicationQt.get(), SIGNAL(triggered()), this,
SLOT(displaySoftwareInformation()));
QObject::connect(windowComboBox.get(), SIGNAL(activated(int)),
this, SLOT(setCurrentIndex(int)));
}
void MainWindow::createMenus()
{
@@ -84,20 +87,42 @@ namespace UI
helpMenuQt->addAction(aboutApplicationQt.get());
}
void MainWindow::setupMainWidget()
{
mainWidgetQt = unique_ptr<QWidget>{new QWidget};
windowComboBox = unique_ptr<QComboBox>{new QComboBox};
setupWindowLists();
stackLayout = unique_ptr<QVBoxLayout>{new QVBoxLayout};
stackLayout->addWidget(windowComboBox.get());
uploadSongWidgetQt = unique_ptr<QWidget>{new QWidget};
uploadSongWidgetQt->setLayout(mainLayoutQt.get());
stackLayout->addWidget(uploadSongWidgetQt.get());
mainWidgetQt->setLayout(stackLayout.get());
}
void MainWindow::setupMainWindow()
{
configureWindowDimensions();
mainLayoutQt = unique_ptr<QVBoxLayout>{new QVBoxLayout};
widgetStack = unique_ptr<QStackedWidget>{new QStackedWidget};
configureUploadSection();
mainWidgetQt = unique_ptr<QWidget>{new QWidget};
mainWidgetQt.get()->setLayout(mainLayoutQt.get());
setupMainWidget();
widgetStack->addWidget(mainWidgetQt.get());
MainDockWidgetQt = unique_ptr<QDockWidget>{new QDockWidget};
MainDockWidgetQt.get()->setWindowTitle(tr("Music Manager"));
MainDockWidgetQt.get()->setWidget(mainWidgetQt.get());
MainDockWidgetQt->setWidget(widgetStack.get());
MainDockWidgetQt.get()->setFeatures(QDockWidget::NoDockWidgetFeatures);
setCentralWidget(MainDockWidgetQt.get());
createMenus();
@@ -106,6 +131,13 @@ namespace UI
connections();
}
void MainWindow::setupWindowLists()
{
windowComboBox->addItem(tr("Upload song"));
windowComboBox->addItem(tr("Download song"));
windowComboBox->addItem(tr("Display all songs"));
windowComboBox->addItem(tr("Display songs"));
}
void MainWindow::exitApplication()
@@ -116,6 +148,14 @@ namespace UI
{
aboutWindow->show();
}
void MainWindow::setCurrentIndex(int index)
{
cout<<"index "<<index<<endl;
QString qText = windowComboBox->itemText(index);
auto cnvert = Utilities::Conversions(qText);
auto convertedStr = cnvert.convertQStringToString();
cout<<"item text"<<endl;
}
void MainWindow::uploadSong()
{
uploadSongQt->setEnabled(false);
+16 -4
View File
@@ -5,6 +5,7 @@
#include<memory>
#include<QAction>
#include<QComboBox>
#include<QDialog>
#include<QDockWidget>
#include<QLabel>
@@ -12,6 +13,7 @@
#include<QMenuBar>
#include<QMainWindow>
#include<QPushButton>
#include<QStackedWidget>
#include<QTextEdit>
#include<QWidget>
@@ -33,23 +35,32 @@ namespace UI
void configureWindowProperties();
void connections();
void createMenus();
void setupMainWidget();
void setupMainWindow();
void setupWindowLists();
std::unique_ptr<QHBoxLayout> urlPortion;
std::unique_ptr<QHBoxLayout> songPathPortion;
std::unique_ptr<QStackedWidget> widgetStack;
std::unique_ptr<QVBoxLayout> stackLayout;
std::unique_ptr<QHBoxLayout> urlPortion;
std::unique_ptr<QHBoxLayout> songPathPortion;
std::unique_ptr<QWidget> mainWidgetQt;
std::unique_ptr<QWidget> uploadSongWidgetQt;
std::unique_ptr<QDockWidget> MainDockWidgetQt;
std::unique_ptr<QComboBox> windowComboBox;
std::unique_ptr<QPushButton> uploadSongQt;
std::unique_ptr<QTextEdit> urlQt;
std::unique_ptr<QTextEdit> sourceFilePathQt;
std::unique_ptr<QLabel> urlLabel;
std::unique_ptr<QLabel> songPath;
std::unique_ptr<QLabel> urlLabel;
std::unique_ptr<QLabel> songPath;
std::unique_ptr<QMenu> fileMenuQt;
std::unique_ptr<QMenu> editMenuQt;
@@ -64,6 +75,7 @@ namespace UI
void uploadSong();
void exitApplication();
void displaySoftwareInformation();
void setCurrentIndex(int);
};
}