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:
@@ -38,6 +38,7 @@ set(CMAKE_AUTOUIC ON)
|
|||||||
|
|
||||||
|
|
||||||
find_package(Qt5Widgets CONFIG REQUIRED)
|
find_package(Qt5Widgets CONFIG REQUIRED)
|
||||||
|
find_package(nlohmann_json 3.6.1 REQUIRED)
|
||||||
|
|
||||||
add_subdirectory(cpr)
|
add_subdirectory(cpr)
|
||||||
|
|
||||||
@@ -48,6 +49,7 @@ set(SOURCES
|
|||||||
src/Syncers/Upload.cpp
|
src/Syncers/Upload.cpp
|
||||||
src/UI/MainWindow.cpp
|
src/UI/MainWindow.cpp
|
||||||
src/UI/AboutWindow.cpp
|
src/UI/AboutWindow.cpp
|
||||||
|
src/Utilities/Conversions.cpp
|
||||||
)
|
)
|
||||||
set(HEADERS
|
set(HEADERS
|
||||||
src/Managers/FileManager.h
|
src/Managers/FileManager.h
|
||||||
@@ -58,6 +60,7 @@ set(HEADERS
|
|||||||
src/UI/CommonWindow.h
|
src/UI/CommonWindow.h
|
||||||
src/UI/MainWindow.h
|
src/UI/MainWindow.h
|
||||||
src/UI/AboutWindow.h
|
src/UI/AboutWindow.h
|
||||||
|
src/Utilities/Conversions.h
|
||||||
)
|
)
|
||||||
|
|
||||||
add_executable(icd ${SOURCES} ${HEADERS})
|
add_executable(icd ${SOURCES} ${HEADERS})
|
||||||
|
|||||||
+53
-13
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
#include"Models/UploadForm.h"
|
#include"Models/UploadForm.h"
|
||||||
#include"Syncers/Upload.h"
|
#include"Syncers/Upload.h"
|
||||||
|
#include"Utilities/Conversions.h"
|
||||||
|
|
||||||
using std::cout;
|
using std::cout;
|
||||||
using std::endl;
|
using std::endl;
|
||||||
@@ -32,21 +33,21 @@ namespace UI
|
|||||||
urlQt = unique_ptr<QTextEdit>{new QTextEdit()};
|
urlQt = unique_ptr<QTextEdit>{new QTextEdit()};
|
||||||
sourceFilePathQt = unique_ptr<QTextEdit>{new QTextEdit()};
|
sourceFilePathQt = unique_ptr<QTextEdit>{new QTextEdit()};
|
||||||
|
|
||||||
urlLabel = unique_ptr<QLabel>{new QLabel(tr("URL"))};
|
urlLabel = unique_ptr<QLabel>{new QLabel(tr("URL"))};
|
||||||
songPath = unique_ptr<QLabel>{new QLabel(tr("Song Path"))};
|
songPath = unique_ptr<QLabel>{new QLabel(tr("Song Path"))};
|
||||||
|
|
||||||
urlPortion = unique_ptr<QHBoxLayout>{new QHBoxLayout};
|
urlPortion = unique_ptr<QHBoxLayout>{new QHBoxLayout};
|
||||||
songPathPortion = unique_ptr<QHBoxLayout>{new QHBoxLayout};
|
songPathPortion = unique_ptr<QHBoxLayout>{new QHBoxLayout};
|
||||||
|
|
||||||
urlPortion.get()->addWidget(urlLabel.get());
|
urlPortion.get()->addWidget(urlLabel.get());
|
||||||
urlPortion.get()->addWidget(urlQt.get());
|
urlPortion.get()->addWidget(urlQt.get());
|
||||||
|
|
||||||
songPathPortion->addWidget(songPath.get());
|
songPathPortion->addWidget(songPath.get());
|
||||||
songPathPortion->addWidget(sourceFilePathQt.get());
|
songPathPortion->addWidget(sourceFilePathQt.get());
|
||||||
|
|
||||||
subLayoutOneQt = unique_ptr<QVBoxLayout>{new QVBoxLayout};
|
subLayoutOneQt = unique_ptr<QVBoxLayout>{new QVBoxLayout};
|
||||||
subLayoutOneQt.get()->addLayout(urlPortion.get());
|
subLayoutOneQt.get()->addLayout(urlPortion.get());
|
||||||
subLayoutOneQt->addLayout(songPathPortion.get());
|
subLayoutOneQt->addLayout(songPathPortion.get());
|
||||||
mainLayoutQt.get()->addLayout(subLayoutOneQt.get());
|
mainLayoutQt.get()->addLayout(subLayoutOneQt.get());
|
||||||
}
|
}
|
||||||
void MainWindow::configureWindowDimensions()
|
void MainWindow::configureWindowDimensions()
|
||||||
@@ -67,6 +68,8 @@ namespace UI
|
|||||||
SLOT(exitApplication()));
|
SLOT(exitApplication()));
|
||||||
QObject::connect(aboutApplicationQt.get(), SIGNAL(triggered()), this,
|
QObject::connect(aboutApplicationQt.get(), SIGNAL(triggered()), this,
|
||||||
SLOT(displaySoftwareInformation()));
|
SLOT(displaySoftwareInformation()));
|
||||||
|
QObject::connect(windowComboBox.get(), SIGNAL(activated(int)),
|
||||||
|
this, SLOT(setCurrentIndex(int)));
|
||||||
}
|
}
|
||||||
void MainWindow::createMenus()
|
void MainWindow::createMenus()
|
||||||
{
|
{
|
||||||
@@ -84,20 +87,42 @@ namespace UI
|
|||||||
helpMenuQt->addAction(aboutApplicationQt.get());
|
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()
|
void MainWindow::setupMainWindow()
|
||||||
{
|
{
|
||||||
configureWindowDimensions();
|
configureWindowDimensions();
|
||||||
|
|
||||||
mainLayoutQt = unique_ptr<QVBoxLayout>{new QVBoxLayout};
|
mainLayoutQt = unique_ptr<QVBoxLayout>{new QVBoxLayout};
|
||||||
|
widgetStack = unique_ptr<QStackedWidget>{new QStackedWidget};
|
||||||
|
|
||||||
configureUploadSection();
|
configureUploadSection();
|
||||||
|
|
||||||
mainWidgetQt = unique_ptr<QWidget>{new QWidget};
|
setupMainWidget();
|
||||||
mainWidgetQt.get()->setLayout(mainLayoutQt.get());
|
|
||||||
|
widgetStack->addWidget(mainWidgetQt.get());
|
||||||
|
|
||||||
MainDockWidgetQt = unique_ptr<QDockWidget>{new QDockWidget};
|
MainDockWidgetQt = unique_ptr<QDockWidget>{new QDockWidget};
|
||||||
MainDockWidgetQt.get()->setWindowTitle(tr("Music Manager"));
|
MainDockWidgetQt.get()->setWindowTitle(tr("Music Manager"));
|
||||||
MainDockWidgetQt.get()->setWidget(mainWidgetQt.get());
|
MainDockWidgetQt->setWidget(widgetStack.get());
|
||||||
MainDockWidgetQt.get()->setFeatures(QDockWidget::NoDockWidgetFeatures);
|
MainDockWidgetQt.get()->setFeatures(QDockWidget::NoDockWidgetFeatures);
|
||||||
|
|
||||||
setCentralWidget(MainDockWidgetQt.get());
|
setCentralWidget(MainDockWidgetQt.get());
|
||||||
|
|
||||||
createMenus();
|
createMenus();
|
||||||
@@ -106,6 +131,13 @@ namespace UI
|
|||||||
|
|
||||||
connections();
|
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()
|
void MainWindow::exitApplication()
|
||||||
@@ -116,6 +148,14 @@ namespace UI
|
|||||||
{
|
{
|
||||||
aboutWindow->show();
|
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()
|
void MainWindow::uploadSong()
|
||||||
{
|
{
|
||||||
uploadSongQt->setEnabled(false);
|
uploadSongQt->setEnabled(false);
|
||||||
|
|||||||
+16
-4
@@ -5,6 +5,7 @@
|
|||||||
#include<memory>
|
#include<memory>
|
||||||
|
|
||||||
#include<QAction>
|
#include<QAction>
|
||||||
|
#include<QComboBox>
|
||||||
#include<QDialog>
|
#include<QDialog>
|
||||||
#include<QDockWidget>
|
#include<QDockWidget>
|
||||||
#include<QLabel>
|
#include<QLabel>
|
||||||
@@ -12,6 +13,7 @@
|
|||||||
#include<QMenuBar>
|
#include<QMenuBar>
|
||||||
#include<QMainWindow>
|
#include<QMainWindow>
|
||||||
#include<QPushButton>
|
#include<QPushButton>
|
||||||
|
#include<QStackedWidget>
|
||||||
#include<QTextEdit>
|
#include<QTextEdit>
|
||||||
#include<QWidget>
|
#include<QWidget>
|
||||||
|
|
||||||
@@ -33,23 +35,32 @@ namespace UI
|
|||||||
void configureWindowProperties();
|
void configureWindowProperties();
|
||||||
void connections();
|
void connections();
|
||||||
void createMenus();
|
void createMenus();
|
||||||
|
void setupMainWidget();
|
||||||
void setupMainWindow();
|
void setupMainWindow();
|
||||||
|
void setupWindowLists();
|
||||||
|
|
||||||
|
|
||||||
std::unique_ptr<QHBoxLayout> urlPortion;
|
std::unique_ptr<QStackedWidget> widgetStack;
|
||||||
std::unique_ptr<QHBoxLayout> songPathPortion;
|
|
||||||
|
std::unique_ptr<QVBoxLayout> stackLayout;
|
||||||
|
|
||||||
|
std::unique_ptr<QHBoxLayout> urlPortion;
|
||||||
|
std::unique_ptr<QHBoxLayout> songPathPortion;
|
||||||
|
|
||||||
std::unique_ptr<QWidget> mainWidgetQt;
|
std::unique_ptr<QWidget> mainWidgetQt;
|
||||||
|
std::unique_ptr<QWidget> uploadSongWidgetQt;
|
||||||
|
|
||||||
std::unique_ptr<QDockWidget> MainDockWidgetQt;
|
std::unique_ptr<QDockWidget> MainDockWidgetQt;
|
||||||
|
|
||||||
|
std::unique_ptr<QComboBox> windowComboBox;
|
||||||
|
|
||||||
std::unique_ptr<QPushButton> uploadSongQt;
|
std::unique_ptr<QPushButton> uploadSongQt;
|
||||||
|
|
||||||
std::unique_ptr<QTextEdit> urlQt;
|
std::unique_ptr<QTextEdit> urlQt;
|
||||||
std::unique_ptr<QTextEdit> sourceFilePathQt;
|
std::unique_ptr<QTextEdit> sourceFilePathQt;
|
||||||
|
|
||||||
std::unique_ptr<QLabel> urlLabel;
|
std::unique_ptr<QLabel> urlLabel;
|
||||||
std::unique_ptr<QLabel> songPath;
|
std::unique_ptr<QLabel> songPath;
|
||||||
|
|
||||||
std::unique_ptr<QMenu> fileMenuQt;
|
std::unique_ptr<QMenu> fileMenuQt;
|
||||||
std::unique_ptr<QMenu> editMenuQt;
|
std::unique_ptr<QMenu> editMenuQt;
|
||||||
@@ -64,6 +75,7 @@ namespace UI
|
|||||||
void uploadSong();
|
void uploadSong();
|
||||||
void exitApplication();
|
void exitApplication();
|
||||||
void displaySoftwareInformation();
|
void displaySoftwareInformation();
|
||||||
|
void setCurrentIndex(int);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,48 @@
|
|||||||
|
#include"Conversions.h"
|
||||||
|
|
||||||
|
#include<iostream>
|
||||||
|
|
||||||
|
using std::string;
|
||||||
|
using std::unique_ptr;
|
||||||
|
|
||||||
|
namespace Utilities
|
||||||
|
{
|
||||||
|
Conversions::Conversions()
|
||||||
|
{
|
||||||
|
initializeValues();
|
||||||
|
}
|
||||||
|
Conversions::Conversions(QString val)
|
||||||
|
{
|
||||||
|
// TODO: assign QString to unique pointer
|
||||||
|
// The line below is causing the build to fail
|
||||||
|
qStrVal = unique_ptr<QString>(std::copy(val)};
|
||||||
|
}
|
||||||
|
Conversions::Conversions(QString* val)
|
||||||
|
{
|
||||||
|
qStrVal = unique_ptr<QString>{std::move(val)};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Conversions::initializeValues()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
template <typename T>
|
||||||
|
void Conversions::printValue(T val)
|
||||||
|
{
|
||||||
|
std::cout<<"going to print value"<<std::endl;
|
||||||
|
std::cout<<val<<std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
string Conversions::convertQStringToString()
|
||||||
|
{
|
||||||
|
auto val = qStrVal->toUtf8().constData();
|
||||||
|
|
||||||
|
printValue(val);
|
||||||
|
|
||||||
|
return qStrVal->toUtf8().constData();
|
||||||
|
}
|
||||||
|
string Conversions::convertQStringToString(QString* val)
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
#ifndef CONVERSIONS_H_
|
||||||
|
#define CONVERSIONS_H_
|
||||||
|
|
||||||
|
#include<memory>
|
||||||
|
#include<string>
|
||||||
|
|
||||||
|
#include<QString>
|
||||||
|
|
||||||
|
namespace Utilities
|
||||||
|
{
|
||||||
|
class Conversions
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Conversions();
|
||||||
|
Conversions(QString);
|
||||||
|
Conversions(QString*);
|
||||||
|
|
||||||
|
void initializeValues();
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
void printValue(T);
|
||||||
|
|
||||||
|
std::string convertQStringToString();
|
||||||
|
std::string convertQStringToString(QString*);
|
||||||
|
private:
|
||||||
|
std::unique_ptr<QString> qStrVal;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
Reference in New Issue
Block a user