fix: port away from deprecated Qt APIs
This commit is contained in:
		
							
								
								
									
										33
									
								
								caesium.cpp
									
									
									
									
									
								
							
							
						
						
									
										33
									
								
								caesium.cpp
									
									
									
									
									
								
							@ -1,6 +1,7 @@
 | 
			
		||||
/*******************************************************************************
 | 
			
		||||
#
 | 
			
		||||
# Copyright (C) 2010-2013 Matteo Paonessa <matteo.paonessa@gmail.com>
 | 
			
		||||
#               2021      Gary Wang       <wzc782970009@gmail.com>
 | 
			
		||||
#
 | 
			
		||||
# This file is part of the Caesium distribution.
 | 
			
		||||
#
 | 
			
		||||
@ -19,6 +20,7 @@
 | 
			
		||||
# Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301 USA.
 | 
			
		||||
#
 | 
			
		||||
# Author: Matteo Paonessa <matteo.paonessa@gmail.com>
 | 
			
		||||
#         Gary Wang       <wzc782970009@gmail.com>
 | 
			
		||||
#
 | 
			
		||||
# ******************************************************************************/
 | 
			
		||||
 | 
			
		||||
@ -53,7 +55,7 @@
 | 
			
		||||
#include <windows.h>
 | 
			
		||||
#include <tchar.h>
 | 
			
		||||
 | 
			
		||||
QTime t;
 | 
			
		||||
QElapsedTimer t;
 | 
			
		||||
int error_count = 0, iteration_count = 0, skipped_count;
 | 
			
		||||
int current_index = -1;
 | 
			
		||||
double scale_factor = 1.0;
 | 
			
		||||
@ -751,14 +753,14 @@ void Caesium::on_listTreeWidget_itemSelectionChanged()
 | 
			
		||||
 | 
			
		||||
void Caesium::on_actionSave_List_As_triggered()
 | 
			
		||||
{
 | 
			
		||||
    QString fileName = QFileDialog::getSaveFileName(this, tr("Save as..."), QString::null, tr("Caesium List (*.clf)"));
 | 
			
		||||
    QString fileName = QFileDialog::getSaveFileName(this, tr("Save as..."), QString(), tr("Caesium List (*.clf)"));
 | 
			
		||||
    Caesium::saveList(fileName);
 | 
			
		||||
    opened_list = fileName;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void Caesium::on_actionOpen_List_triggered()
 | 
			
		||||
{
 | 
			
		||||
    QString listName = QFileDialog::getOpenFileName(this, tr("Open a list file..."), QString::null, tr("Caesium List (*.clf)"));
 | 
			
		||||
    QString listName = QFileDialog::getOpenFileName(this, tr("Open a list file..."), QString(), tr("Caesium List (*.clf)"));
 | 
			
		||||
    Caesium::openList(listName);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -970,11 +972,11 @@ void Caesium::updateUI(int i, int newSize, QString ratio)
 | 
			
		||||
    chopped_ratio.chop(1);
 | 
			
		||||
    if (chopped_ratio.toInt() > 0)
 | 
			
		||||
    {
 | 
			
		||||
        ui->listTreeWidget->topLevelItem(i - 1)->setTextColor(3, QColor::fromRgb(255, 0, 0, 255));
 | 
			
		||||
        ui->listTreeWidget->topLevelItem(i - 1)->setForeground(3, QColor::fromRgb(255, 0, 0, 255));
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
        ui->listTreeWidget->topLevelItem(i - 1)->setTextColor(3, QColor::fromRgb(0, 0, 0, 255));
 | 
			
		||||
        ui->listTreeWidget->topLevelItem(i - 1)->setForeground(3, QColor::fromRgb(0, 0, 0, 255));
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -1192,7 +1194,7 @@ void Caesium::openList()
 | 
			
		||||
        ui->listTreeWidget->clear();
 | 
			
		||||
        QTextStream stream(&list);
 | 
			
		||||
        QString line = stream.readLine(0);
 | 
			
		||||
        while (line != QString::null)
 | 
			
		||||
        while (!line.isNull())
 | 
			
		||||
        {
 | 
			
		||||
            QStringList splittedLine = line.split("|");
 | 
			
		||||
            if (splittedLine.count() != 7)
 | 
			
		||||
@ -1217,11 +1219,11 @@ void Caesium::lstSave()
 | 
			
		||||
        QTextStream stream(&file);
 | 
			
		||||
        if (ui->rememberDirectoryCheckBox->isChecked())
 | 
			
		||||
        {
 | 
			
		||||
            stream << "1|" << ui->outputLineEdit->text() << endl;
 | 
			
		||||
            stream << "1|" << ui->outputLineEdit->text() << Qt::endl;
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
            stream << "0|" << ui->outputLineEdit->text() << endl;
 | 
			
		||||
            stream << "0|" << ui->outputLineEdit->text() << Qt::endl;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    QString tempFolder = QDir::tempPath();
 | 
			
		||||
@ -1356,13 +1358,14 @@ void Caesium::adjustPreviewView()
 | 
			
		||||
{
 | 
			
		||||
    if (!deleting)
 | 
			
		||||
    {
 | 
			
		||||
        img_ratio = (double) imageLabel1->pixmap()->width() / imageLabel1->pixmap()->height();
 | 
			
		||||
        QPixmap imgLabel1Pixmap = imageLabel1->pixmap(Qt::ReturnByValue);
 | 
			
		||||
        img_ratio = (double) imgLabel1Pixmap.width() / imgLabel1Pixmap.height();
 | 
			
		||||
        if (ui->listTreeWidget->selectedItems().at(0)->text(6) == "")
 | 
			
		||||
        {
 | 
			
		||||
            if (ui->methodComboBox->currentIndex() == 0)
 | 
			
		||||
            {
 | 
			
		||||
                ui->widthSpinBox->setValue(imageLabel1->pixmap()->width());
 | 
			
		||||
                ui->heightSpinBox->setValue(imageLabel1->pixmap()->height());
 | 
			
		||||
                ui->widthSpinBox->setValue(imgLabel1Pixmap.width());
 | 
			
		||||
                ui->heightSpinBox->setValue(imgLabel1Pixmap.height());
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
@ -1379,8 +1382,8 @@ void Caesium::adjustPreviewView()
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
            QList<int> wh = resolutionToInt(ui->listTreeWidget->selectedItems().at(0)->text(6));
 | 
			
		||||
            ui->widthSpinBox->setValue(100 * wh.at(0) / imageLabel1->pixmap()->width());
 | 
			
		||||
            ui->heightSpinBox->setValue(100 * wh.at(1) / imageLabel1->pixmap()->height());
 | 
			
		||||
            ui->widthSpinBox->setValue(100 * wh.at(0) / imgLabel1Pixmap.width());
 | 
			
		||||
            ui->heightSpinBox->setValue(100 * wh.at(1) / imgLabel1Pixmap.height());
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    if(settings.value("Preferences/imageview").value<QString>() == "fit")
 | 
			
		||||
@ -1698,7 +1701,7 @@ void Caesium::saveList(QString path)
 | 
			
		||||
                    << ui->listTreeWidget->topLevelItem(i)->text(5) + "|"
 | 
			
		||||
                    << ui->listTreeWidget->topLevelItem(i)->text(6) + "|"
 | 
			
		||||
                    << ui->listTreeWidget->topLevelItem(i)->text(7) + "|"
 | 
			
		||||
                    << endl;
 | 
			
		||||
                    << Qt::endl;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@ -1711,7 +1714,7 @@ void Caesium::openList(QString path)
 | 
			
		||||
        ui->listTreeWidget->clear();
 | 
			
		||||
        QTextStream stream(&list);
 | 
			
		||||
        QString line = stream.readLine(0);
 | 
			
		||||
        while (line != QString::null)
 | 
			
		||||
        while (!line.isNull())
 | 
			
		||||
        {
 | 
			
		||||
            QStringList splittedLine = line.split("|");
 | 
			
		||||
            QTreeWidgetItem *item = new QTreeWidgetItem(splittedLine, 0);
 | 
			
		||||
 | 
			
		||||
@ -1,6 +1,7 @@
 | 
			
		||||
/*******************************************************************************
 | 
			
		||||
#
 | 
			
		||||
# Copyright (C) 2010-2013 Matteo Paonessa <matteo.paonessa@gmail.com>
 | 
			
		||||
#               2021      Gary Wang       <wzc782970009@gmail.com>
 | 
			
		||||
#
 | 
			
		||||
# This file is part of the Caesium distribution.
 | 
			
		||||
#
 | 
			
		||||
@ -19,6 +20,7 @@
 | 
			
		||||
# Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301 USA.
 | 
			
		||||
#
 | 
			
		||||
# Author: Matteo Paonessa <matteo.paonessa@gmail.com>
 | 
			
		||||
#         Gary Wang       <wzc782970009@gmail.com>
 | 
			
		||||
#
 | 
			
		||||
# ******************************************************************************/
 | 
			
		||||
 | 
			
		||||
@ -196,8 +198,7 @@ void Updater::closeEvent(QCloseEvent *event)
 | 
			
		||||
{
 | 
			
		||||
    if (downFinished)
 | 
			
		||||
    {
 | 
			
		||||
        QProcess *process;
 | 
			
		||||
        process->startDetached(QDir::tempPath() + "/" + fileName);
 | 
			
		||||
        QProcess::startDetached(QDir::tempPath() + "/" + fileName, {});
 | 
			
		||||
        u_parent->close();
 | 
			
		||||
    }
 | 
			
		||||
    else if (start_pressed)
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user