Partial: Add mount list to options dialog

This commit is contained in:
oldmud0 2021-05-29 10:43:53 -05:00
parent bddf6c67c2
commit a023657348
5 changed files with 87 additions and 4 deletions

View File

@ -130,7 +130,6 @@ public:
// implementation in path_functions.cpp
QString get_base_path();
QString get_data_path();
QString get_theme_path(QString p_file, QString p_theme="");
QString get_character_path(QString p_char, QString p_file);
QString get_misc_path(QString p_misc, QString p_file);

View File

@ -23,6 +23,7 @@
#include <QtWidgets/QWidget>
#include <QDirIterator>
#include <QListWidget>
#include <QTextStream>
class Lobby;
@ -170,6 +171,16 @@ private:
QLabel *ui_log_lbl;
QCheckBox *ui_log_cb;
QWidget *ui_assets_tab;
QVBoxLayout *ui_assets_tab_layout;
QGridLayout *ui_mount_buttons_layout;
QLabel *ui_asset_lbl;
QListWidget *ui_mount_list;
QPushButton *ui_mount_add;
QPushButton *ui_mount_remove;
QPushButton *ui_mount_up;
QPushButton *ui_mount_down;
bool needs_default_audiodev();
void update_values();

View File

@ -18,7 +18,7 @@ AOApplication::AOApplication(int &argc, char **argv) : QApplication(argc, argv)
discord = new AttorneyOnline::Discord();
QObject::connect(net_manager, SIGNAL(ms_connect_finished(bool, bool)),
SLOT(ms_connect_finished(bool, bool)));
qApp->setStyleSheet("QFrame {background-color:transparent;} QAbstractItemView {background-color: transparent; color: black;}; QLineEdit {background-color:transparent;}");
// qApp->setStyleSheet("QFrame {background-color:transparent;} QAbstractItemView {background-color: transparent; color: black;}; QLineEdit {background-color:transparent;}");
}
AOApplication::~AOApplication()

View File

@ -4,6 +4,8 @@
#include "lobby.h"
#include "bass.h"
#include <QFileDialog>
AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app)
: QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint)
{
@ -874,7 +876,75 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app)
ui_casing_layout->setWidget(row, QFormLayout::FieldRole, ui_log_cb);
// Assets tab
ui_assets_tab = new QWidget(this);
ui_assets_tab_layout = new QVBoxLayout(ui_assets_tab);
ui_assets_tab->setLayout(ui_assets_tab_layout);
ui_settings_tabs->addTab(ui_assets_tab, tr("Assets"));
ui_asset_lbl = new QLabel(ui_assets_tab);
ui_asset_lbl->setText(
tr("Add or remove base folders for use by assets. "
"Base folders will be searched in the order provided."));
ui_asset_lbl->setWordWrap(true);
ui_assets_tab_layout->addWidget(ui_asset_lbl);
ui_mount_list = new QListWidget(ui_assets_tab);
ui_assets_tab_layout->addWidget(ui_mount_list);
ui_mount_buttons_layout = new QGridLayout(ui_assets_tab);
ui_assets_tab_layout->addLayout(ui_mount_buttons_layout);
QSizePolicy stretch_btns(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
stretch_btns.setHorizontalStretch(4);
ui_mount_add = new QPushButton(tr("Add…"), ui_assets_tab);
ui_mount_add->setSizePolicy(stretch_btns);
ui_mount_buttons_layout->addWidget(ui_mount_add, 0, 0, 1, 1);
connect(ui_mount_add, &QPushButton::clicked, this, [this] {
QString dir = QFileDialog::getExistingDirectory(this, tr("Select a base folder"),
QApplication::applicationDirPath(),
QFileDialog::ShowDirsOnly);
if (dir.isEmpty())
return;
ui_mount_list->addItem(dir);
});
ui_mount_remove = new QPushButton(tr("Remove"), ui_assets_tab);
ui_mount_remove->setSizePolicy(stretch_btns);
ui_mount_remove->setEnabled(false);
ui_mount_buttons_layout->addWidget(ui_mount_remove, 0, 1, 1, 1);
connect(ui_mount_remove, &QPushButton::clicked, this, [=] {
auto selected = ui_mount_list->selectedItems();
if (selected.isEmpty())
return;
ui_mount_list->removeItemWidget(selected[0]);
});
auto *mount_buttons_spacer = new QSpacerItem(40, 20, QSizePolicy::Expanding,
QSizePolicy::Minimum);
ui_mount_buttons_layout->addItem(mount_buttons_spacer, 0, 2, 1, 1);
ui_mount_up = new QPushButton(tr(""), ui_assets_tab);
ui_mount_up->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
ui_mount_up->setMaximumWidth(40);
ui_mount_up->setEnabled(false);
ui_mount_buttons_layout->addWidget(ui_mount_up, 0, 3, 1, 1);
connect(ui_mount_up, &QPushButton::clicked, this, [=] {
auto selected = ui_mount_list->selectedItems();
if (selected.isEmpty())
return;
ui_mount_list->setEditTriggers()
});
ui_mount_down = new QPushButton(tr(""), ui_assets_tab);
ui_mount_down->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
ui_mount_down->setMaximumWidth(40);
ui_mount_down->setEnabled(false);
ui_mount_buttons_layout->addWidget(ui_mount_down, 0, 4, 1, 1);
update_values();
// When we're done, we should continue the updates!
setUpdatesEnabled(true);
}
@ -944,6 +1014,11 @@ void AOOptionsDialog::update_values() {
ui_sfx_volume_spinbox->setValue(ao_app->get_default_sfx());
ui_blips_volume_spinbox->setValue(ao_app->get_default_blip());
ui_bliprate_spinbox->setValue(ao_app->read_blip_rate());
auto *defaultMount = new QListWidgetItem(tr("%1 (default)")
.arg(ao_app->get_base_path()));
defaultMount->setFlags(Qt::ItemFlag::NoItemFlags);
ui_mount_list->addItem(defaultMount);
}
void AOOptionsDialog::save_pressed()

View File

@ -39,8 +39,6 @@ QString AOApplication::get_base_path()
return base_path;
}
QString AOApplication::get_data_path() { return get_base_path() + "data/"; }
QString AOApplication::get_theme_path(QString p_file, QString p_theme)
{
if (p_theme == "")