mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 05:37:43 +00:00
DisplayProperties: Auto-resolution and graphical fix (#566)
The program will now automatically select the user's currently chosen resolution when it is loaded up, however it is not "visually selected" in the `GListView` Moved the `resolution_list` list to be on the top to keep it consistent with the wallpaper tab.
This commit is contained in:
parent
aa95bd7037
commit
444a4e4d39
1 changed files with 28 additions and 2 deletions
|
@ -39,12 +39,37 @@ void DisplayPropertiesWidget::create_resolution_list()
|
|||
m_resolutions.append({ 800, 600 });
|
||||
m_resolutions.append({ 1024, 768 });
|
||||
m_resolutions.append({ 1280, 1024 });
|
||||
m_resolutions.append({ 1366, 768 });
|
||||
m_resolutions.append({ 1440, 900 });
|
||||
m_resolutions.append({ 1600, 900 });
|
||||
m_resolutions.append({ 1920, 1080 });
|
||||
m_resolutions.append({ 2560, 1080 });
|
||||
|
||||
Size find_size;
|
||||
|
||||
bool okay = false;
|
||||
// Let's attempt to find the current resolution and select it!
|
||||
find_size.set_width(m_wm_config->read_entry("Screen", "Width", "1024").to_int(okay));
|
||||
if (!okay) {
|
||||
fprintf(stderr, "DisplayProperties: failed to convert width to int!");
|
||||
return;
|
||||
}
|
||||
|
||||
find_size.set_height(m_wm_config->read_entry("Screen", "Height", "768").to_int(okay));
|
||||
if (!okay) {
|
||||
fprintf(stderr, "DisplayProperties: failed to convert height to int!");
|
||||
return;
|
||||
}
|
||||
|
||||
int index = 0;
|
||||
for (auto& resolution : m_resolutions) {
|
||||
if (resolution == find_size) {
|
||||
m_selected_resolution = m_resolutions.at(index);
|
||||
return; // We don't need to do anything else
|
||||
}
|
||||
|
||||
index++;
|
||||
}
|
||||
|
||||
m_selected_resolution = m_resolutions.at(0);
|
||||
}
|
||||
|
||||
|
@ -97,7 +122,6 @@ void DisplayPropertiesWidget::create_frame()
|
|||
|
||||
auto* settings_content = new GWidget(settings_splitter);
|
||||
settings_content->set_layout(make<GBoxLayout>(Orientation::Vertical));
|
||||
settings_content->layout()->add_spacer();
|
||||
settings_content->layout()->set_margins({ 4, 4, 4, 4 });
|
||||
|
||||
auto* resolution_list = new GListView(settings_content);
|
||||
|
@ -108,6 +132,8 @@ void DisplayPropertiesWidget::create_frame()
|
|||
m_selected_resolution = m_resolutions.at(index.row());
|
||||
};
|
||||
|
||||
settings_content->layout()->add_spacer();
|
||||
|
||||
// Add the apply and cancel buttons
|
||||
auto* bottom_widget = new GWidget(m_root_widget);
|
||||
bottom_widget->set_layout(make<GBoxLayout>(Orientation::Horizontal));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue