diff options
| author | David Skoland <davidskoland@gmail.com> | 2016-12-29 02:48:02 +0100 |
|---|---|---|
| committer | David Skoland <davidskoland@gmail.com> | 2016-12-29 02:48:02 +0100 |
| commit | edf37fba4949ec902644c5e5937fa62e66c323c9 (patch) | |
| tree | e1a42603231ad14245a958c6a72099f9f932c455 | |
| parent | 78c5e1563d32a19470c595769598167e6a38dcb4 (diff) | |
Added file and path function files + started working on the lobby
| -rw-r--r-- | Attorney_Online_remake.pro | 8 | ||||
| -rw-r--r-- | lobby.cpp | 16 | ||||
| -rw-r--r-- | lobby.h | 7 | ||||
| -rw-r--r-- | main.cpp | 1 | ||||
| -rw-r--r-- | path_functions.cpp | 15 | ||||
| -rw-r--r-- | path_functions.h | 9 | ||||
| -rw-r--r-- | text_file_functions.cpp | 29 | ||||
| -rw-r--r-- | text_file_functions.h | 9 |
8 files changed, 91 insertions, 3 deletions
diff --git a/Attorney_Online_remake.pro b/Attorney_Online_remake.pro index a88a0516..176ebb57 100644 --- a/Attorney_Online_remake.pro +++ b/Attorney_Online_remake.pro @@ -13,6 +13,10 @@ TEMPLATE = app 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 @@ -1,8 +1,22 @@ +#include <QDebug> + +#include "path_functions.h" + #include "lobby.h" 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() @@ -2,6 +2,7 @@ #define LOBBY_H #include <QMainWindow> +#include <QLabel> class Lobby : public QMainWindow { @@ -9,7 +10,13 @@ class Lobby : public QMainWindow public: Lobby(QWidget *parent = nullptr); + + void set_theme_images(); + ~Lobby(); + +private: + QLabel *ui_background; }; #endif // LOBBY_H @@ -6,6 +6,7 @@ int main(int argc, char *argv[]) { QApplication a(argc, argv); Lobby w; + w.set_theme_images(); w.show(); return a.exec(); diff --git a/path_functions.cpp b/path_functions.cpp new file mode 100644 index 00000000..8766656b --- /dev/null +++ b/path_functions.cpp @@ -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() + "/"; +} + + diff --git a/path_functions.h b/path_functions.h new file mode 100644 index 00000000..3912c17a --- /dev/null +++ b/path_functions.h @@ -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 diff --git a/text_file_functions.cpp b/text_file_functions.cpp new file mode 100644 index 00000000..336b76c4 --- /dev/null +++ b/text_file_functions.cpp @@ -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"; +} diff --git a/text_file_functions.h b/text_file_functions.h new file mode 100644 index 00000000..99abe089 --- /dev/null +++ b/text_file_functions.h @@ -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 |
