Commit d988ee77 authored by Fabian Kosmale's avatar Fabian Kosmale
Browse files

some work on the CPP route

parent ef6e88f8
......@@ -10,9 +10,10 @@ class KapudanMainWindow : public QWidget
Q_OBJECT
public:
explicit KapudanMainWindow(QWidget *parent = 0);
~KapudanMainWindow() {};
~KapudanMainWindow() {}
private:
Ui_kapudan ui;
void forward();
void back();
};
......@@ -17,11 +17,11 @@ class Screen {
this->help = help;
this->icon = icon;
}
virtual void shown(){};
virtual void execute(){};
virtual void backCheck(){};
virtual void shown(){}
virtual void execute(){}
virtual void backCheck(){}
virtual ~Screen() {};
virtual ~Screen() {}
};
......
#include "scrFolder.h"
#include <QStandardPaths>
#include <QFileInfo>
#include <QPushButton>
FolderScreen::FolderScreen(QWidget *parent) :QWidget(parent),
Screen("Folders", "Create folders in the home directory", ":help:", QIcon {}) {
ui.setupUi(this);
folderSelected[Download] = true;
folderSelected[Documents] = true;
folderSelected[Video] = true;
folderSelected[Music] = true;
folderSelected[Picture] = true;
folder2location[Download] = QStandardPaths::standardLocations(QStandardPaths::DownloadLocation).first();
folder2location[Documents] = QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation).first();
folder2location[Video] = QStandardPaths::standardLocations(QStandardPaths::MoviesLocation).first();
folder2location[Music] = QStandardPaths::standardLocations(QStandardPaths::MusicLocation).first();
folder2location[Picture] = QStandardPaths::standardLocations(QStandardPaths::PicturesLocation).first();
QObject::connect(ui.documentsFolderButton, &QPushButton::toggled, [this](bool newState){
folderSelected[Documents] = newState;
updateText();
});
}
void FolderScreen::updateText() {
static QString header {
"<html><head><meta name=\"qrichtext\" content=\"1\" />"
"<style type=\"text/css\">p, li { white-space: pre-wrap; }</style></head>"
"<body style=\" font-family:'DejaVu Sans'; font-size:9pt; font-weight:400; font-style:normal;\">"
"<p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px;"
"-qt-block-indent:0; text-indent:0px;\"><span style=\" font-weight:600;\">"
};
static QString footer {
"</span></p></body></html>"
};
auto text = header;
auto any_selected = false;
for (auto folder_selection: folderSelected) {
any_selected |= folder_selection.second;
if (folder_selection.second) {
text += QFileInfo(folder2location[folder_selection.first]).baseName();
}
}
if (!any_selected) {
text += "None";
}
text += footer;
ui.textEdit->setText(text);
}
......@@ -5,12 +5,29 @@
#include "../screen.h"
#include <QWidget>
#include <QString>
#include <map>
class FolderScreen : public QWidget, public Screen {
public:
FolderScreen(QWidget * parent = nullptr);
private:
Ui_folderWidget ui;
enum FolderType {
Download,
Documents,
Video,
Music,
Picture
};
std::map<FolderType, bool> folderSelected {};
std::map<FolderType, QString> folder2location {};
void updateText();
};
#endif /* end of include guard: SCRFOLDER_H_1V3KFXNB */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment