Added file and path function files + started working on the lobby
This commit is contained in:
		
							parent
							
								
									78c5e1563d
								
							
						
					
					
						commit
						edf37fba49
					
				@ -13,6 +13,10 @@ TEMPLATE = app
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
SOURCES += main.cpp\
 | 
					SOURCES += main.cpp\
 | 
				
			||||||
        lobby.cpp
 | 
					        lobby.cpp \
 | 
				
			||||||
 | 
					    text_file_functions.cpp \
 | 
				
			||||||
 | 
					    path_functions.cpp
 | 
				
			||||||
 | 
					
 | 
				
			||||||
HEADERS  += lobby.h
 | 
					HEADERS  += lobby.h \
 | 
				
			||||||
 | 
					    text_file_functions.h \
 | 
				
			||||||
 | 
					    path_functions.h
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										16
									
								
								lobby.cpp
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								lobby.cpp
									
									
									
									
									
								
							@ -1,8 +1,22 @@
 | 
				
			|||||||
 | 
					#include <QDebug>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "path_functions.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "lobby.h"
 | 
					#include "lobby.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Lobby::Lobby(QWidget *parent) : QMainWindow(parent)
 | 
					Lobby::Lobby(QWidget *parent) : QMainWindow(parent)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  //this->resize();
 | 
					  this->resize(517, 666);
 | 
				
			||||||
 | 
					  ui_background = new QLabel(this);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void Lobby::set_theme_images()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  QString theme_path = get_theme_path();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  ui_background->move(0, 0);
 | 
				
			||||||
 | 
					  ui_background->resize(517, 666);
 | 
				
			||||||
 | 
					  ui_background->setPixmap(theme_path + "lobbybackground.png");
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Lobby::~Lobby()
 | 
					Lobby::~Lobby()
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										7
									
								
								lobby.h
									
									
									
									
									
								
							
							
						
						
									
										7
									
								
								lobby.h
									
									
									
									
									
								
							@ -2,6 +2,7 @@
 | 
				
			|||||||
#define LOBBY_H
 | 
					#define LOBBY_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <QMainWindow>
 | 
					#include <QMainWindow>
 | 
				
			||||||
 | 
					#include <QLabel>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class Lobby : public QMainWindow
 | 
					class Lobby : public QMainWindow
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@ -9,7 +10,13 @@ class Lobby : public QMainWindow
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
  Lobby(QWidget *parent = nullptr);
 | 
					  Lobby(QWidget *parent = nullptr);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  void set_theme_images();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  ~Lobby();
 | 
					  ~Lobby();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					private:
 | 
				
			||||||
 | 
					  QLabel *ui_background;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif // LOBBY_H
 | 
					#endif // LOBBY_H
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										1
									
								
								main.cpp
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								main.cpp
									
									
									
									
									
								
							@ -6,6 +6,7 @@ int main(int argc, char *argv[])
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
  QApplication a(argc, argv);
 | 
					  QApplication a(argc, argv);
 | 
				
			||||||
  Lobby w;
 | 
					  Lobby w;
 | 
				
			||||||
 | 
					  w.set_theme_images();
 | 
				
			||||||
  w.show();
 | 
					  w.show();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return a.exec();
 | 
					  return a.exec();
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										15
									
								
								path_functions.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								path_functions.cpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,15 @@
 | 
				
			|||||||
 | 
					#include <QDir>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "text_file_functions.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "path_functions.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					QString get_base_path(){
 | 
				
			||||||
 | 
					  return (QDir::currentPath() + "/base/");
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					QString get_theme_path(){
 | 
				
			||||||
 | 
					  return get_base_path() + "themes/" + get_user_theme() + "/";
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
							
								
								
									
										9
									
								
								path_functions.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								path_functions.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,9 @@
 | 
				
			|||||||
 | 
					#ifndef PATH_FUNCTIONS_H
 | 
				
			||||||
 | 
					#define PATH_FUNCTIONS_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <QString>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					QString get_base_path();
 | 
				
			||||||
 | 
					QString get_theme_path();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif // PATH_FUNCTIONS_H
 | 
				
			||||||
							
								
								
									
										29
									
								
								text_file_functions.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								text_file_functions.cpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,29 @@
 | 
				
			|||||||
 | 
					#include <QTextStream>
 | 
				
			||||||
 | 
					#include <QStringList>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "path_functions.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "text_file_functions.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					QString get_user_theme(){
 | 
				
			||||||
 | 
					  QFile config_file(get_base_path() + "config.ini");
 | 
				
			||||||
 | 
					  if (!config_file.open(QIODevice::ReadOnly))
 | 
				
			||||||
 | 
					      return "default";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  QTextStream in(&config_file);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  while(!in.atEnd())
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    QString line = in.readLine();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (line.startsWith("theme"))
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      QStringList line_elements = line.split("=");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      if (line_elements.size() > 1)
 | 
				
			||||||
 | 
					        return line_elements.at(1).trimmed();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  return "default";
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										9
									
								
								text_file_functions.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								text_file_functions.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,9 @@
 | 
				
			|||||||
 | 
					#ifndef TEXT_FILE_FUNCTIONS_H
 | 
				
			||||||
 | 
					#define TEXT_FILE_FUNCTIONS_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <QString>
 | 
				
			||||||
 | 
					#include <QFile>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					QString get_user_theme();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif // TEXT_FILE_FUNCTIONS_H
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user