Skip to content

Commit

Permalink
FEAT(client): Profiles frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
Hartmnt committed Jan 3, 2025
1 parent 252a4f7 commit 62e1f8e
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 13 deletions.
28 changes: 26 additions & 2 deletions src/mumble/ConfigDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,19 @@ ConfigDialog::ConfigDialog(QWidget *p) : QDialog(p) {
restoreGeometry(Global::get().s.qbaConfigGeometry);
}

qcbProfiles->addItem(Profiles.s_default_profile_name);

QStringList profiles = Global::get().s.profiles.allProfiles.keys();
profiles.sort();
for (const QString &profile : profiles) {
if (profile == Profiles.s_default_profile_name) {
continue;
}
qcbProfiles->addItem(profile);
}

qcbProfiles->setCurrentIndex(qcbProfiles->findText(Global::get().s.profiles.activeProfileName));

updateTabOrder();
qlwIcons->setFocus();
}
Expand Down Expand Up @@ -205,6 +218,13 @@ void ConfigDialog::on_qlwIcons_currentItemChanged(QListWidgetItem *current, QLis
}
}

void ConfigDialog::on_qcbProfiles_currentIndexChanged() {
QString selectedProfile = qcbProfiles->currentData();
bool isDefault = selectedProfile == Profiles.s_default_profile_name;
qpbProfileRename->setEnabled(!isDefault);
qpbProfileDelete->setEnabled(!isDefault);
}

void ConfigDialog::updateTabOrder() {
QPushButton *okButton = dialogButtonBox->button(QDialogButtonBox::Ok);
QPushButton *cancelButton = dialogButtonBox->button(QDialogButtonBox::Cancel);
Expand All @@ -230,13 +250,17 @@ void ConfigDialog::updateTabOrder() {
setTabOrder(cancelButton, okButton);
setTabOrder(okButton, qlwIcons);
setTabOrder(qlwIcons, contentFocusWidget);
setTabOrder(contentFocusWidget, qcbProfiles);
setTabOrder(qcbProfiles, qpbProfileAdd);
setTabOrder(qpbProfileAdd, qpbProfileRename);
setTabOrder(qpbProfileRename, qpbProfileDelete);
if (resetButton && restoreButton && restoreAllButton) {
setTabOrder(contentFocusWidget, resetButton);
setTabOrder(qpbProfileDelete, resetButton);
setTabOrder(resetButton, restoreButton);
setTabOrder(restoreButton, restoreAllButton);
setTabOrder(restoreAllButton, applyButton);
} else {
setTabOrder(contentFocusWidget, applyButton);
setTabOrder(qpbProfileDelete, applyButton);
}
setTabOrder(applyButton, cancelButton);
}
Expand Down
1 change: 1 addition & 0 deletions src/mumble/ConfigDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public slots:
void on_pageButtonBox_clicked(QAbstractButton *);
void on_dialogButtonBox_clicked(QAbstractButton *);
void on_qlwIcons_currentItemChanged(QListWidgetItem *current, QListWidgetItem *previous);
void on_qcbProfiles_currentIndexChanged();
void apply();
void accept() Q_DECL_OVERRIDE;
};
Expand Down
67 changes: 56 additions & 11 deletions src/mumble/ConfigDialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -35,51 +35,96 @@
</size>
</property>
<property name="resizeMode">
<enum>QListView::Adjust</enum>
<enum>QListView::ResizeMode::Adjust</enum>
</property>
<property name="layoutMode">
<enum>QListView::Batched</enum>
<enum>QListView::LayoutMode::Batched</enum>
</property>
<property name="uniformItemSizes">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0" colspan="3">
<item row="1" column="0">
<widget class="QGroupBox" name="qgbProfiles">
<property name="title">
<string>Profile</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>9</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QComboBox" name="qcbProfiles"/>
</item>
<item>
<widget class="QPushButton" name="qpbProfileAdd">
<property name="text">
<string>Add</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="qpbProfileRename">
<property name="text">
<string>Rename</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="qpbProfileDelete">
<property name="text">
<string>Delete</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="2" column="0" colspan="3">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QDialogButtonBox" name="pageButtonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
</widget>
</item>
<item>
<spacer>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>474</width>
<height>22</height>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QDialogButtonBox" name="dialogButtonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
<set>QDialogButtonBox::StandardButton::Apply|QDialogButtonBox::StandardButton::Cancel|QDialogButtonBox::StandardButton::Ok</set>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="1">
<item row="0" column="2" rowspan="2">
<widget class="QStackedWidget" name="qswPages">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
Expand Down

0 comments on commit 62e1f8e

Please sign in to comment.