Skip to content

Commit

Permalink
2 inner theme, 1 custom theme
Browse files Browse the repository at this point in the history
  • Loading branch information
sonichy committed Jan 7, 2019
1 parent b02749c commit a5099cb
Show file tree
Hide file tree
Showing 41 changed files with 100 additions and 39 deletions.
36 changes: 22 additions & 14 deletions forcastwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,17 @@ ForcastWidget::ForcastWidget(QWidget *parent)
QGridLayout *layout = new QGridLayout;
for (int i=0; i<6; i++) {
labelWImg[i] = new QLabel;
QString icon_path = ":icon/na.png";
QString sicon_path = m_settings.value("icon_path","").toString();
if(sicon_path != ""){
icon_path = sicon_path + "/" + "na.png";
QFile file(icon_path);
if(!file.exists()){
icon_path = ":icon/na.png";
QString icon_path = ":icon/Default/na.png";
QString iconTheme = m_settings.value("IconTheme","").toString();
if(iconTheme != ""){
if(!iconTheme.startsWith("/")){
icon_path = ":icon/" + iconTheme + "/" + "na.png";
}else{
icon_path = iconTheme + "/" + "na.png";
QFile file(icon_path);
if(!file.exists()){
icon_path = ":icon/Default/na.png";
}
}
}
labelWImg[i]->setPixmap(QPixmap(icon_path).scaled(50,50,Qt::KeepAspectRatio,Qt::SmoothTransformation));
Expand Down Expand Up @@ -90,13 +94,17 @@ void ForcastWidget::updateWeather()
QString humidity = "RH: " + QString::number(list[i].toObject().value("main").toObject().value("humidity").toInt()) + "%";
QString weather = list[i].toObject().value("weather").toArray().at(0).toObject().value("main").toString();
QString icon_name = list[i].toObject().value("weather").toArray().at(0).toObject().value("icon").toString() + ".png";
QString icon_path = ":icon/" + icon_name;
QString sicon_path = m_settings.value("icon_path","").toString();
if(sicon_path != ""){
icon_path = sicon_path + "/" + icon_name;
QFile file(icon_path);
if(!file.exists()){
icon_path = ":icon/" + icon_name;
QString icon_path = ":icon/Default/" + icon_name;
QString iconTheme = m_settings.value("IconTheme","").toString();
if(iconTheme != ""){
if(!iconTheme.startsWith("/")){
icon_path = ":icon/" + iconTheme + "/" + icon_name;
}else{
icon_path = iconTheme + "/" + icon_name;
QFile file(icon_path);
if(!file.exists()){
icon_path = ":icon/Default/" + icon_name;
}
}
}
QString wind = "Wind: " + QString::number(list[i].toObject().value("wind").toObject().value("speed").toDouble()) + "m/s, " + QString::number(qRound(list[i].toObject().value("wind").toObject().value("deg").toDouble())) + "°";
Expand Down
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Binary file added icon/Simple/01d.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icon/Simple/01n.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icon/Simple/02d.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icon/Simple/02n.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icon/Simple/03d.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icon/Simple/03n.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icon/Simple/04d.png
Binary file added icon/Simple/04n.png
Binary file added icon/Simple/09d.png
Binary file added icon/Simple/09n.png
Binary file added icon/Simple/10d.png
Binary file added icon/Simple/10n.png
Binary file added icon/Simple/11d.png
Binary file added icon/Simple/11n.png
Binary file added icon/Simple/13d.png
Binary file added icon/Simple/13n.png
Binary file added icon/Simple/50d.png
Binary file added icon/Simple/50n.png
Binary file added icon/Simple/na.png
57 changes: 38 additions & 19 deletions res.qrc
Original file line number Diff line number Diff line change
@@ -1,23 +1,42 @@
<RCC>
<qresource prefix="/">
<file>icon/01d.png</file>
<file>icon/02n.png</file>
<file>icon/50d.png</file>
<file>icon/50n.png</file>
<file>icon/04n.png</file>
<file>icon/13d.png</file>
<file>icon/11n.png</file>
<file>icon/09n.png</file>
<file>icon/02d.png</file>
<file>icon/11d.png</file>
<file>icon/10d.png</file>
<file>icon/13n.png</file>
<file>icon/04d.png</file>
<file>icon/03n.png</file>
<file>icon/09d.png</file>
<file>icon/01n.png</file>
<file>icon/10n.png</file>
<file>icon/03d.png</file>
<file>icon/na.png</file>
<file>icon/Simple/10n.png</file>
<file>icon/Simple/03n.png</file>
<file>icon/Simple/09d.png</file>
<file>icon/Simple/10d.png</file>
<file>icon/Simple/na.png</file>
<file>icon/Simple/13n.png</file>
<file>icon/Simple/01d.png</file>
<file>icon/Simple/04n.png</file>
<file>icon/Simple/50n.png</file>
<file>icon/Simple/50d.png</file>
<file>icon/Simple/04d.png</file>
<file>icon/Simple/01n.png</file>
<file>icon/Simple/13d.png</file>
<file>icon/Simple/02n.png</file>
<file>icon/Simple/11d.png</file>
<file>icon/Simple/03d.png</file>
<file>icon/Simple/09n.png</file>
<file>icon/Simple/11n.png</file>
<file>icon/Simple/02d.png</file>
<file>icon/Default/01d.png</file>
<file>icon/Default/02d.png</file>
<file>icon/Default/03n.png</file>
<file>icon/Default/11d.png</file>
<file>icon/Default/10d.png</file>
<file>icon/Default/50n.png</file>
<file>icon/Default/50d.png</file>
<file>icon/Default/04d.png</file>
<file>icon/Default/01n.png</file>
<file>icon/Default/na.png</file>
<file>icon/Default/11n.png</file>
<file>icon/Default/13n.png</file>
<file>icon/Default/13d.png</file>
<file>icon/Default/04n.png</file>
<file>icon/Default/09n.png</file>
<file>icon/Default/10n.png</file>
<file>icon/Default/03d.png</file>
<file>icon/Default/09d.png</file>
<file>icon/Default/02n.png</file>
</qresource>
</RCC>
46 changes: 40 additions & 6 deletions weatherplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ void WeatherPlugin::invokedMenuItem(const QString &itemKey, const QString &menuI

void WeatherPlugin::MBAbout()
{
QMessageBox aboutMB(QMessageBox::NoIcon, "HTYWeather 5.2", "About\n\nDeepin Linux Dock Weather Plugin.\nAuthor: 黄颖\nE-mail: [email protected]\nSource: https://github.com/sonichy/WEATHER_DDE_DOCK\nAPI: https://openweathermap.org/forecast5");
aboutMB.setIconPixmap(QPixmap(":/icon/01d.png"));
QMessageBox aboutMB(QMessageBox::NoIcon, "HTYWeather 5.3", "About\n\nDeepin Linux Dock Weather Plugin.\nAuthor: 黄颖\nE-mail: [email protected]\nSource: https://github.com/sonichy/WEATHER_DDE_DOCK\nAPI: https://openweathermap.org/forecast5");
aboutMB.setIconPixmap(QPixmap(":/icon/Default/01d.png"));
aboutMB.exec();
}

Expand Down Expand Up @@ -246,23 +246,56 @@ void WeatherPlugin::set()
hbox = new QHBoxLayout;
label = new QLabel("Search your city and country in openweathermap.org");
hbox->addWidget(label);
/*
hbox = new QHBoxLayout;
label = new QLabel("IconPath");
hbox->addWidget(label);
lineEdit_iconPath = new QLineEdit;
lineEdit_iconPath->setText(m_settings.value("icon_path","").toString());
lineEdit_iconPath->setText(m_settings.value("IconPath","").toString());
QAction *action = new QAction(this);
action->setIcon(QIcon::fromTheme("folder"));
lineEdit_iconPath->addAction(action, QLineEdit::TrailingPosition);
//connect(action, SIGNAL(triggered(bool)), this, SLOT(BrowserIconPath()));
connect(action, &QAction::triggered, this, [=](){
QString iconPath = QFileDialog::getExistingDirectory(dialog, "Icon Path", m_settings.value("icon_path","").toString());
QString iconPath = QFileDialog::getExistingDirectory(dialog, "Icon Path", m_settings.value("IconPath","").toString());
if (iconPath != "") {
lineEdit_iconPath->setText(iconPath);
}
});
hbox->addWidget(lineEdit_iconPath);
vbox->addLayout(hbox);
*/
hbox = new QHBoxLayout;
label = new QLabel("Icon Theme (PNG only)");
hbox->addWidget(label);
QComboBox *comboBox_iconTheme = new QComboBox;
comboBox_iconTheme->addItem(QIcon(":icon/Default/01d.png"), "Default");
comboBox_iconTheme->addItem(QIcon(":icon/Simple/01d.png"), "Simple");
QString iconTheme = m_settings.value("IconTheme","").toString();
if(iconTheme == "" || !iconTheme.startsWith("/")){
comboBox_iconTheme->addItem("Custom");
}else{
comboBox_iconTheme->addItem(QIcon(iconTheme + "/01d.png"), iconTheme);
}
comboBox_iconTheme->setCurrentText(iconTheme);
//connect(comboBox_iconTheme, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), [=](int index){
connect(comboBox_iconTheme, static_cast<void(QComboBox::*)(int)>(&QComboBox::activated), [=](int index){
if(index == 2){
QString siconTheme = QFileDialog::getExistingDirectory(dialog, "Icon Theme", iconTheme);
if(siconTheme != ""){
QString icon_path = siconTheme + "/01d.png";
QFile file(icon_path);
if(file.exists()){
comboBox_iconTheme->setItemText(index, siconTheme);
comboBox_iconTheme->setItemIcon(index, QIcon(icon_path));
}else{
QMessageBox MB(QMessageBox::Critical, "Error", icon_path + " does not exists !");
MB.exec();
}
}
}
});
hbox->addWidget(comboBox_iconTheme);
vbox->addLayout(hbox);
QPushButton *pushButton_confirm = new QPushButton("Confirm");
QPushButton *pushButton_cancel = new QPushButton("Cancel");
connect(pushButton_confirm, SIGNAL(clicked()), dialog, SLOT(accept()));
Expand All @@ -275,7 +308,8 @@ void WeatherPlugin::set()
if(dialog->exec() == QDialog::Accepted){
m_settings.setValue("city", lineEdit_city->text());
m_settings.setValue("country", comboBox->currentText());
m_settings.setValue("icon_path", lineEdit_iconPath->text());
//m_settings.setValue("IconPath", lineEdit_iconPath->text());
m_settings.setValue("IconTheme", comboBox_iconTheme->currentText());
forcastApplet->updateWeather();
}
dialog->close();
Expand Down

0 comments on commit a5099cb

Please sign in to comment.