Add version generator
This commit is contained in:
parent
37807b56d2
commit
48285d7866
|
@ -1,5 +1,6 @@
|
|||
#include "branchdialog.h"
|
||||
#include "ui_branchdialog.h"
|
||||
#include <QFileDialog>
|
||||
#include <fstream>
|
||||
|
||||
BranchDialog::BranchDialog(QWidget *parent) :
|
||||
|
@ -17,17 +18,17 @@ void BranchDialog::setup_config(json &json_data)
|
|||
longterm_str = json_data["Longterm"];
|
||||
stable_str = json_data["Stable"];
|
||||
devel_str = json_data["Develop"];
|
||||
darwin_path_str = json_data["Release_Path_Darwin"];
|
||||
unix_path_str = json_data["Release_Path_Unix"];
|
||||
win32_path_str = json_data["Release_Path_Win32"];
|
||||
switch(get_os_type()){
|
||||
case OS_Type::Darwin:
|
||||
darwin_path_str = json_data["Release_Path_Darwin"];
|
||||
path_str = darwin_path_str;
|
||||
break;
|
||||
case OS_Type::Linux:
|
||||
unix_path_str = json_data["Release_Path_Unix"];
|
||||
path_str = unix_path_str;
|
||||
break;
|
||||
case OS_Type::Windows:
|
||||
win32_path_str = json_data["Release_Path_Win32"];
|
||||
path_str = win32_path_str;
|
||||
break;
|
||||
}
|
||||
|
@ -104,3 +105,19 @@ void BranchDialog::on_buttonBox_rejected()
|
|||
{
|
||||
}
|
||||
|
||||
|
||||
void BranchDialog::on_btn_path_clicked()
|
||||
{
|
||||
// Create a dialog to select folders
|
||||
QFileDialog dialog(this, tr("Select Folder"), tr("./"), tr("Any Files(*.*)"));
|
||||
dialog.setFileMode(QFileDialog::Directory);
|
||||
dialog.setViewMode(QFileDialog::ViewMode::Detail);
|
||||
dialog.setOption(QFileDialog::ShowDirsOnly, true);
|
||||
if(dialog.exec()){
|
||||
// Get folder path
|
||||
QStringList path_list = dialog.selectedFiles();
|
||||
QString path_str = path_list[0];
|
||||
ui->line_path->setText(path_str);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,8 @@ private slots:
|
|||
|
||||
void on_buttonBox_rejected();
|
||||
|
||||
void on_btn_path_clicked();
|
||||
|
||||
private:
|
||||
Ui::BranchDialog *ui;
|
||||
|
||||
|
|
|
@ -81,18 +81,55 @@ void MainWindow::update_time(){
|
|||
void MainWindow::on_btn_ver_clicked()
|
||||
{
|
||||
// Get Index of selection
|
||||
char version_longterm[57];
|
||||
char version_stable[57];
|
||||
char version_devel[57];
|
||||
|
||||
int current_index = ui->combo_branch->currentIndex();
|
||||
QString temp_string;
|
||||
switch(current_index)
|
||||
{
|
||||
case 0:
|
||||
// The longterm builds branch
|
||||
longterm(local, longterm_ver.c_str(), version_longterm);
|
||||
temp_string += version_longterm;
|
||||
show_version(temp_string);
|
||||
break;
|
||||
case 1:
|
||||
// The Stable builds branch
|
||||
stable(local, stable_ver.c_str(), version_stable);
|
||||
temp_string += version_stable;
|
||||
show_version(temp_string);
|
||||
break;
|
||||
case 2:
|
||||
// The develop builds branch
|
||||
develop(local, devel_ver.c_str(), version_devel);
|
||||
temp_string += version_devel;
|
||||
show_version(temp_string);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::show_version(QString &info_string){
|
||||
// Create icon
|
||||
QPixmap pixmap = QPixmap(":/xe_res/res/Xe-Release.png");
|
||||
QMessageBox msgbox;
|
||||
// Text of message box
|
||||
QString info_text = "The Version is:";
|
||||
info_text += info_string;
|
||||
msgbox.setText(QString("### Xe Release Qt Version"));
|
||||
msgbox.setInformativeText(info_text);
|
||||
msgbox.setTextFormat(Qt::TextFormat::MarkdownText);
|
||||
|
||||
// Icons
|
||||
msgbox.setIconPixmap(pixmap);
|
||||
msgbox.setWindowIcon(QIcon(pixmap));
|
||||
|
||||
// Only a Button
|
||||
msgbox.setStandardButtons(QMessageBox::Ok);
|
||||
msgbox.setDefaultButton(QMessageBox::Ok);
|
||||
msgbox.exec();
|
||||
}
|
||||
|
||||
void MainWindow::on_actionExit_triggered()
|
||||
{
|
||||
|
@ -142,9 +179,13 @@ void MainWindow::on_actionXeRelease_10_14_triggered()
|
|||
|
||||
void MainWindow::on_actionRelease_branchs_triggered()
|
||||
{
|
||||
// Create a dialog and show
|
||||
BranchDialog dialog(this);
|
||||
dialog.setup_config(json_data);
|
||||
dialog.exec();
|
||||
|
||||
// Refresh config
|
||||
get_config();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -56,7 +56,8 @@ private:
|
|||
// with the Xe Release Gtkmm4 Version
|
||||
bool dark_mode;
|
||||
|
||||
void get_config();
|
||||
void update_time();
|
||||
void show_version(QString &info_string); // A Dialog to show version string
|
||||
void get_config(); // Get configs from json file
|
||||
void update_time(); // Update current time
|
||||
};
|
||||
#endif // MAINWINDOW_H
|
||||
|
|
|
@ -2,10 +2,12 @@
|
|||
#include <ctime>
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
#include <limits.h>
|
||||
#include "xerelease.hh"
|
||||
#include "xeapi.hh"
|
||||
|
||||
static json data1;
|
||||
#define MAX_PATH 260
|
||||
|
||||
// typedef void(*LP)(struct tm *local);//define a pointer function
|
||||
|
||||
|
@ -120,7 +122,7 @@ void dale(struct tm *local)
|
|||
void longterm(struct tm *local, const char *lts, char *str)
|
||||
{
|
||||
// Print Version of longterm release in the file
|
||||
char filename[57];
|
||||
char filename[MAX_PATH];
|
||||
path_translate(filename, lts);
|
||||
// sprintf(filename, "xe-%c.x", lts[0]);
|
||||
int lts_ver = 0; // default release version
|
||||
|
@ -143,7 +145,7 @@ void longterm(struct tm *local, const char *lts, char *str)
|
|||
void stable(struct tm *local, const char *rel, char *str)
|
||||
{
|
||||
// Print Version of stable release in the file
|
||||
char filename[57];
|
||||
char filename[MAX_PATH];
|
||||
path_translate(filename, rel);
|
||||
// sprintf(filename, "xe-%c.x", rel[0]);
|
||||
int devel1; // stable release version
|
||||
|
@ -165,7 +167,7 @@ void stable(struct tm *local, const char *rel, char *str)
|
|||
void develop(struct tm *local, const char *devel, char *str)
|
||||
{
|
||||
// Print Version of develop release in the file
|
||||
char filename[57];
|
||||
char filename[MAX_PATH];
|
||||
path_translate(filename, devel);
|
||||
// sprintf(filename, "xe-%c.x", devel[0]);
|
||||
int devel1; // development version
|
||||
|
|
Loading…
Reference in New Issue