-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhomepage.cpp
95 lines (86 loc) · 2.25 KB
/
homepage.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
#include "homepage.h"
#include "ui_homepage.h"
#include "login.h" // Make sure to include the header for Login
#include"myprofile.h"
#include"newsbasedon.h"
#include"news.h"
#include<qpixmap>
HomePage::HomePage(QWidget *parent)
: QDialog(parent)
, ui(new Ui::HomePage)
{
ui->setupUi(this);
QPixmap pix("C:/Users/asus/Desktop/Qt Apps/NewManagementSystem/build/Desktop_Qt_6_7_0_MinGW_64_bit-Debug\image_2024-05-15_23-28-12");
ui->label_Image->setPixmap(pix.scaled(100,100,Qt::KeepAspectRatio));
ui->comboBox_favNews->hide();
ui->pushButton_showNew->hide();
}
void HomePage::setUserId(int userId){
this->userId = userId;
}
void HomePage::show_window(){
show();
}
void HomePage::close_window(){
close();
}
HomePage::~HomePage()
{
delete ui;
}
void HomePage::on_pushButton_back_clicked()
{
hide();
Login *log=new Login(this);
log->show();
}
void HomePage::on_pushButton_clicked()
{
hide();
MyProfile*profile=new MyProfile(this);
profile->show();
profile->DisplayData();
}
void HomePage::on_pushButton_2_clicked()
{
Adminx::backbuttons[0]=true;
Adminx::backbuttons[1]=false;
Adminx::backbuttons[2]=false;
Newsbasedon *newsbasedon=new Newsbasedon(this) ;\
hide() ;
newsbasedon->show() ;
}
void HomePage::on_pushButton_favNews_clicked()
{
Adminx::backbuttons[1]=true;
Adminx::backbuttons[0]=false;
Adminx::backbuttons[2]=false;
ui->pushButton_showNew->show();
ui->comboBox_favNews->clear();
ui->comboBox_favNews->show();
for(auto it:News::favNews)
if(it.first==Login::UserID){
for(int i=0;i<it.second.size();i++){
ui->comboBox_favNews->addItem(it.second[i].c_str());
}
}
}
void HomePage::on_pushButton_showNew_clicked()
{
News*n=new News(this);
string title=ui->comboBox_favNews->currentText().toStdString();
for(int i=0;i<Adminx::news.size();i++){
if(title==Adminx::news[i].getTitle()){
Newsbasedon::currentNew=i;
}
}
hide();
n->show();
n->displayNew();
}
void HomePage::on_pushButton_search_clicked()
{
hide();
Search *search = new Search(this);
search->show();
}