change: change code style to Linux style except indent.

This commit is contained in:
Mike Solar
2025-08-03 03:09:40 +08:00
parent 65ab76edc8
commit 74f73ab3be
789 changed files with 77113 additions and 68888 deletions
@@ -29,94 +29,105 @@
#include "common/filefunctions.h"
namespace olive {
namespace olive
{
PreferencesDiskTab::PreferencesDiskTab()
{
// Get default disk cache folder
default_disk_cache_folder_ = DiskManager::instance()->GetDefaultCacheFolder();
// Get default disk cache folder
default_disk_cache_folder_ =
DiskManager::instance()->GetDefaultCacheFolder();
QVBoxLayout* outer_layout = new QVBoxLayout(this);
QVBoxLayout *outer_layout = new QVBoxLayout(this);
QGroupBox* disk_management_group = new QGroupBox(tr("Disk Management"));
outer_layout->addWidget(disk_management_group);
QGroupBox *disk_management_group = new QGroupBox(tr("Disk Management"));
outer_layout->addWidget(disk_management_group);
QGridLayout* disk_management_layout = new QGridLayout(disk_management_group);
QGridLayout *disk_management_layout =
new QGridLayout(disk_management_group);
int row = 0;
int row = 0;
disk_management_layout->addWidget(new QLabel(tr("Disk Cache Location:")), row, 0);
disk_management_layout->addWidget(new QLabel(tr("Disk Cache Location:")),
row, 0);
disk_cache_location_ = new PathWidget(default_disk_cache_folder_->GetPath());
disk_management_layout->addWidget(disk_cache_location_, row, 1);
disk_cache_location_ =
new PathWidget(default_disk_cache_folder_->GetPath());
disk_management_layout->addWidget(disk_cache_location_, row, 1);
row++;
row++;
QPushButton* disk_cache_settings_btn = new QPushButton(tr("Disk Cache Settings"));
connect(disk_cache_settings_btn, &QPushButton::clicked, this, [this](){
DiskManager::instance()->ShowDiskCacheSettingsDialog(disk_cache_location_->text(), this);
});
disk_management_layout->addWidget(disk_cache_settings_btn, row, 1);
QPushButton *disk_cache_settings_btn =
new QPushButton(tr("Disk Cache Settings"));
connect(disk_cache_settings_btn, &QPushButton::clicked, this, [this]() {
DiskManager::instance()->ShowDiskCacheSettingsDialog(
disk_cache_location_->text(), this);
});
disk_management_layout->addWidget(disk_cache_settings_btn, row, 1);
row++;
row++;
QGroupBox* cache_behavior = new QGroupBox(tr("Cache Behavior"));
outer_layout->addWidget(cache_behavior);
QGridLayout* cache_behavior_layout = new QGridLayout(cache_behavior);
QGroupBox *cache_behavior = new QGroupBox(tr("Cache Behavior"));
outer_layout->addWidget(cache_behavior);
QGridLayout *cache_behavior_layout = new QGridLayout(cache_behavior);
row = 0;
row = 0;
cache_behavior_layout->addWidget(new QLabel(tr("Cache Ahead:")), row, 0);
cache_behavior_layout->addWidget(new QLabel(tr("Cache Ahead:")), row, 0);
cache_ahead_slider_ = new FloatSlider();
cache_ahead_slider_->SetFormat(tr("%1 seconds"));
cache_ahead_slider_->SetMinimum(0);
cache_ahead_slider_->SetValue(OLIVE_CONFIG("DiskCacheAhead").value<rational>().toDouble());
cache_behavior_layout->addWidget(cache_ahead_slider_, row, 1);
cache_ahead_slider_ = new FloatSlider();
cache_ahead_slider_->SetFormat(tr("%1 seconds"));
cache_ahead_slider_->SetMinimum(0);
cache_ahead_slider_->SetValue(
OLIVE_CONFIG("DiskCacheAhead").value<rational>().toDouble());
cache_behavior_layout->addWidget(cache_ahead_slider_, row, 1);
cache_behavior_layout->addWidget(new QLabel(tr("Cache Behind:")), row, 2);
cache_behavior_layout->addWidget(new QLabel(tr("Cache Behind:")), row, 2);
cache_behind_slider_ = new FloatSlider();
cache_behind_slider_->SetMinimum(0);
cache_behind_slider_->SetFormat(tr("%1 seconds"));
cache_behind_slider_->SetValue(OLIVE_CONFIG("DiskCacheBehind").value<rational>().toDouble());
cache_behavior_layout->addWidget(cache_behind_slider_, row, 3);
cache_behind_slider_ = new FloatSlider();
cache_behind_slider_->SetMinimum(0);
cache_behind_slider_->SetFormat(tr("%1 seconds"));
cache_behind_slider_->SetValue(
OLIVE_CONFIG("DiskCacheBehind").value<rational>().toDouble());
cache_behavior_layout->addWidget(cache_behind_slider_, row, 3);
outer_layout->addStretch();
outer_layout->addStretch();
}
bool PreferencesDiskTab::Validate()
{
if (disk_cache_location_->text() != default_disk_cache_folder_->GetPath()) {
// Disk cache location is changing
if (disk_cache_location_->text() != default_disk_cache_folder_->GetPath()) {
// Disk cache location is changing
// Check if the user is okay with invalidating the current cache
if (!DiskManager::ShowDiskCacheChangeConfirmationDialog(this)) {
return false;
}
// Check if the user is okay with invalidating the current cache
if (!DiskManager::ShowDiskCacheChangeConfirmationDialog(this)) {
return false;
}
// Check validity of the new path
if (!FileFunctions::DirectoryIsValid(disk_cache_location_->text())) {
QMessageBox::critical(this,
tr("Disk Cache"),
tr("Failed to set disk cache location. Access was denied."));
return false;
}
}
// Check validity of the new path
if (!FileFunctions::DirectoryIsValid(disk_cache_location_->text())) {
QMessageBox::critical(
this, tr("Disk Cache"),
tr("Failed to set disk cache location. Access was denied."));
return false;
}
}
return true;
return true;
}
void PreferencesDiskTab::Accept(MultiUndoCommand *command)
{
Q_UNUSED(command)
Q_UNUSED(command)
if (disk_cache_location_->text() != default_disk_cache_folder_->GetPath()) {
default_disk_cache_folder_->SetPath(disk_cache_location_->text());
}
if (disk_cache_location_->text() != default_disk_cache_folder_->GetPath()) {
default_disk_cache_folder_->SetPath(disk_cache_location_->text());
}
OLIVE_CONFIG("DiskCacheBehind") = QVariant::fromValue(rational::fromDouble(cache_behind_slider_->GetValue()));
OLIVE_CONFIG("DiskCacheAhead") = QVariant::fromValue(rational::fromDouble(cache_ahead_slider_->GetValue()));
OLIVE_CONFIG("DiskCacheBehind") = QVariant::fromValue(
rational::fromDouble(cache_behind_slider_->GetValue()));
OLIVE_CONFIG("DiskCacheAhead") = QVariant::fromValue(
rational::fromDouble(cache_ahead_slider_->GetValue()));
}
}