-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmainwindow.cpp
129 lines (109 loc) · 4.3 KB
/
mainwindow.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
prevXgammaPosi=50; //Jen je teste
SysGammaR=SysGammaG=SysGammaB=50; //Iniz
rgbgammaconf = new QSettings("xgammagui.conf",QSettings::IniFormat); //Gamma value te save path
// Inzi gammac value calla file.
SysGammaR=rgbgammaconf->value("rgamma").toInt();
SysGammaG=rgbgammaconf->value("ggamma").toInt();
SysGammaB=rgbgammaconf->value("bgamma").toInt();
// Inzi UIc gammac value
if(SysGammaR==SysGammaB&&SysGammaR==SysGammaG&&SysGammaB==SysGammaG)
{
ui->hsbXgamma->setValue(5);
ui->hsbXgamma->setValue(SysGammaR);
}
else
{
ui->hsbXgammaR->setValue(SysGammaR);
ui->hsbXgammaG->setValue(SysGammaG);
ui->hsbXgammaB->setValue(SysGammaB);
}
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_hsbXgamma_valueChanged(int value)
{
// RGB Gamma te Echi chage.
ui->hsbXgammaR->setValue(ui->hsbXgammaR->value()-(prevXgammaPosi-value));
ui->hsbXgammaB->setValue(ui->hsbXgammaB->value()-(prevXgammaPosi-value));
ui->hsbXgammaG->setValue(ui->hsbXgammaG->value()-(prevXgammaPosi-value));
// RGB Gammac value te chage to show.
ui->lblXgamma->setText(QString::number(value*0.02));
ui->lblXgammaR->setText(QString::number(ui->hsbXgammaR->value()*0.02));
ui->lblXgammaG->setText(QString::number(ui->hsbXgammaG->value()*0.02));
ui->lblXgammaB->setText(QString::number(ui->hsbXgammaB->value()*0.02));
// Kortimec Xgamma position hi previous te stor.
prevXgammaPosi=value;
}
void MainWindow::on_hsbXgammaR_valueChanged(int value)
{
// Kif R to G to Bc value hi eyo no, Xgamma te enable no.
// User hi sometime te zenbooc RBG value te chage, Sou kor code te notere.
/*if((value!=ui->hsbXgammaG->value())||(value!=ui->hsbXgammaB->value()))
{
ui->hsbXgamma->setEnabled(false);
ui->lblXgamma->setEnabled(false);
}
else
{
ui->hsbXgamma->setEnabled(true);
ui->lblXgamma->setEnabled(true);
}*/
// Rc value te show.
ui->lblXgammaR->setText(QString::number(value*0.02));
// Korvalue hi system te chage to save je kortime.
QProcess::execute("xgamma -rgamma "+QString::number(value*0.02));
// Korvalue hi userc dir te save.
rgbgammaconf->setValue("rgamma",QString::number(value));
}
void MainWindow::on_hsbXgammaB_valueChanged(int value)
{
// Bc value te show.
ui->lblXgammaB->setText(QString::number(value*0.02));
// Korvalue hi system te chage to save je kortime.
QProcess::execute("xgamma -bgamma "+QString::number(value*0.02));
// Korvalue hi userc dir te save.
rgbgammaconf->setValue("bgamma",QString::number(value));
}
void MainWindow::on_hsbXgammaG_valueChanged(int value)
{
// Gc value te show.
ui->lblXgammaG->setText(QString::number(value*0.02));
// Korvalue hi system te chage to save je kortime.
QProcess::execute("xgamma -ggamma "+QString::number(value*0.02));
// Korvalue hi userc dir te save.
rgbgammaconf->setValue("ggamma",QString::number(value));
}
void MainWindow::on_pbRestor_clicked()
{
// RGB Gamma te Echi chage.
ui->hsbXgamma->setValue(5);
ui->hsbXgamma->setValue(50);
string path(getenv("HOME"));
path += "/.config/autostart/xgammaset.desktop";
string syscmd="rm -rf ";
syscmd += path;
system(syscmd.c_str());
QMessageBox::information(NULL,"Systemc Mesegi","Antac systemc Gamma hi zenkon restorre!");
}
void MainWindow::on_pbSave_clicked()
{
ofstream file1;
string path(getenv("HOME"));
path += "/.config/autostart/xgammaset.desktop";
file1.open(path.c_str());
file1<<"[Desktop Entry]\nType=Application\nEncoding=UTF-8\nVersion=1.0\nName=XGammaSet\nComment=XGammaSet\nExec=sh -c \"sleep 10 && xgamma -rgamma "+QString::number(ui->hsbXgammaR->value()*0.02).toStdString()+" -ggamma "+QString::number(ui->hsbXgammaG->value()*0.02).toStdString()+" -bgamma "+QString::number(ui->hsbXgammaB->value()*0.02).toStdString()+"\"\nX-GNOME-Autostart-enabled=true";
file1.close();
string syscmd="chmod +x ";
syscmd += path;
system(syscmd.c_str());
QMessageBox::information(NULL,"Systemc Mesegi","Antac systemc Gamma hi zenkon savere, Hatsu system te login hi chage!");
}