Skip to content

Commit

Permalink
Add edit menu to favorites
Browse files Browse the repository at this point in the history
  • Loading branch information
Salanto committed Jan 29, 2023
1 parent fc0156a commit 6eeceb4
Show file tree
Hide file tree
Showing 13 changed files with 281 additions and 104 deletions.
4 changes: 3 additions & 1 deletion .clang-format
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
BasedOnStyle: LLVM
BreakBeforeBraces: Stroustrup
AllowShortIfStatementsOnASingleLine: true
AllowShortIfStatementsOnASingleLine: true
NamespaceIndentation: All

21 changes: 21 additions & 0 deletions include/interfaces/server_dialog.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include <QDialog>
#pragma once

#ifndef AO_UI_FAVORITESERVERDIALOG
#define AO_UI_FAVORITESRRVERDIALOG
namespace AttorneyOnline {
namespace UI {
class FavoriteServerDialog : public QDialog {
public:
FavoriteServerDialog() = default;
~FavoriteServerDialog() = default;

const QString DEFAULT_UI = "favorite_server_dialog.ui";
const int TCP_INDEX = 0;
private slots:
virtual void onSavePressed() = 0;
virtual void onCancelPressed() = 0;
};
} // namespace UI
} // namespace AttorneyOnline
#endif // AO_UI_FAVORITESERVERDIALOG
3 changes: 2 additions & 1 deletion include/lobby.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class Lobby : public QMainWindow {
QPushButton *ui_add_to_favorite_button;
QPushButton *ui_add_server_button;
QPushButton *ui_remove_from_favorites_button;
QPushButton *ui_edit_favorite_button;
QPushButton *ui_direct_connect_button;
QPushButton *ui_refresh_button;

Expand All @@ -88,11 +89,11 @@ private slots:
void on_direct_connect_released();
void on_add_to_fav_released();
void on_add_server_to_fave_released();
void on_edit_favorite_released();
void on_remove_from_fav_released();
void on_about_clicked();
void on_server_list_clicked(QTreeWidgetItem *p_item, int column);
void on_list_doubleclicked(QTreeWidgetItem *p_item, int column);
void on_favorite_list_context_menu_requested(const QPoint &point);
void on_favorite_tree_clicked(QTreeWidgetItem *p_item, int column);
void on_server_search_edited(QString p_text);
void on_demo_clicked(QTreeWidgetItem *item, int column);
Expand Down
1 change: 1 addition & 0 deletions include/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ class Options {
// Interactions with favorite servers
void removeFavorite(int index);
void addFavorite(server_type server);
void updateFavorite(server_type server, int index);

// Theming Nonesense!
QString getUIAsset(QString f_asset_name);
Expand Down
52 changes: 24 additions & 28 deletions include/widgets/add_server_dialog.h
Original file line number Diff line number Diff line change
@@ -1,48 +1,44 @@
#pragma once

#ifndef ADD_SERVER_DIALOG_H
#define ADD_SERVER_DIALOG_H

#include <QDialog>
#include <QString>
#include "interfaces/server_dialog.h"

class QPushButton;
class QDialogButton;
class QLabel;
class QLineEdit;
class QComboBox;
class QSpinBox;
class QPlainTextEdit;
class QDialogButtonBox;
class QSettings;

class AddServerDialog : public QDialog {
Q_OBJECT
public :
AddServerDialog();
~AddServerDialog() = default;
class AddServerDialog : public AttorneyOnline::UI::FavoriteServerDialog {
Q_OBJECT
public:
AddServerDialog();
~AddServerDialog() = default;

private:
QWidget* ui_widget;

QLineEdit* ui_server_display_name_edit;
QLineEdit* ui_server_hostname_edit;
QSpinBox* ui_server_port_box;
QComboBox* ui_server_protocol_box;
QPlainTextEdit* ui_server_description_edit;
QDialogButtonBox* ui_server_dialog_button;

// Legacy Server UI
QLineEdit* ui_server_legacy_edit;
QPushButton* ui_server_legacy_load_button;


QSettings* m_favorite_ini;
QWidget *ui_widget;

const int TCP_INDEX = 0;
QLineEdit *ui_server_display_name_edit;
QLineEdit *ui_server_hostname_edit;
QSpinBox *ui_server_port_box;
QComboBox *ui_server_protocol_box;
QPlainTextEdit *ui_server_description_edit;
QDialogButtonBox *ui_server_dialog_button;

const QString DEFAULT_UI = "add_server_dialog.ui";
// Legacy Server UI
QLabel *ui_server_legacy_lbl;
QLineEdit *ui_server_legacy_edit;
QPushButton *ui_server_legacy_load_button;

private slots:
void savePressed();
void discardPressed();
void parseLegacyServerEntry();
void onSavePressed() override;
void onCancelPressed() override;
void parseLegacyServerEntry();
};

#endif // ADD_SERVER_DIALOG_H
46 changes: 46 additions & 0 deletions include/widgets/edit_server_dialog.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#pragma once

#ifndef EDIT_SERVER_DIALOG_H
#define EDIT_SERVER_DIALOG_H

#include "interfaces/server_dialog.h"

class QPushButton;
class QDialogButton;
class QLabel;
class QLineEdit;
class QComboBox;
class QSpinBox;
class QPlainTextEdit;
class QDialogButtonBox;

class EditServerDialog : public AttorneyOnline::UI::FavoriteServerDialog {
Q_OBJECT
public:
EditServerDialog(int index);
~EditServerDialog() = default;

private:
QWidget *ui_widget;

QLineEdit *ui_server_display_name_edit;
QLineEdit *ui_server_hostname_edit;
QSpinBox *ui_server_port_box;
QComboBox *ui_server_protocol_box;
QPlainTextEdit *ui_server_description_edit;
QDialogButtonBox *ui_server_dialog_button;

// Legacy Server UI
QLabel *ui_server_legacy_lbl;
QLineEdit *ui_server_legacy_edit;
QPushButton *ui_server_legacy_load_button;

int index;
void loadEntry();

private slots:
void onSavePressed() override;
void onCancelPressed() override;
};

#endif // EDIT_SERVER_DIALOG_H
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="4" column="0">
<item row="2" column="0">
<layout class="QHBoxLayout" name="server_legacy_layout">
<item>
<widget class="QLabel" name="server_legacy_lbl">
Expand All @@ -35,17 +35,7 @@
</item>
</layout>
</item>
<item row="2" column="0">
<widget class="Line" name="line">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="1" column="0">
<item row="0" column="0">
<layout class="QFormLayout" name="server_new_layout">
<item row="0" column="0">
<widget class="QLabel" name="server_display_name_lbl">
Expand Down Expand Up @@ -88,13 +78,6 @@
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="server_description_lbl">
<property name="text">
<string>Description:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="server_protocol_box">
<item>
Expand All @@ -109,6 +92,13 @@
</item>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="server_description_lbl">
<property name="text">
<string>Description:</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QPlainTextEdit" name="server_description_edit">
<property name="sizePolicy">
Expand All @@ -121,27 +111,23 @@
</item>
</layout>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Add your server to your favorites :</string>
<item row="1" column="0">
<widget class="Line" name="server_legacy_bar">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="5" column="0">
<item row="3" column="0">
<widget class="QDialogButtonBox" name="server_dialog_button">
<property name="standardButtons">
<set>QDialogButtonBox::Close|QDialogButtonBox::Save</set>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Convert legacy favorite entries:</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
Expand Down
27 changes: 19 additions & 8 deletions resource/ui/lobby.ui
Original file line number Diff line number Diff line change
Expand Up @@ -328,30 +328,41 @@
<item>
<layout class="QHBoxLayout" name="common_controls">
<item>
<widget class="QPushButton" name="direct_connect_button">
<widget class="QPushButton" name="add_server_button">
<property name="text">
<string>Direct Connect</string>
<string>Add Server</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="add_to_favorite_button">
<widget class="QPushButton" name="remove_from_favorites_button">
<property name="text">
<string>Add To Favorites</string>
<string>Remove Server</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="add_server_button">
<widget class="QPushButton" name="edit_favorite_button">
<property name="text">
<string>Edit Server</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QPushButton" name="direct_connect_button">
<property name="text">
<string>Add</string>
<string>Direct Connect</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="remove_from_favorites_button">
<widget class="QPushButton" name="add_to_favorite_button">
<property name="text">
<string>Remove</string>
<string>Add To Favorites</string>
</property>
</widget>
</item>
Expand Down
2 changes: 1 addition & 1 deletion resources.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<file>resource/translations/ao_pt.qm</file>
<file>resource/translations/ao_ru.qm</file>
<file>resource/ui/options_dialog.ui</file>
<file>resource/ui/add_server_dialog.ui</file>
<file>resource/ui/favorite_server_dialog.ui</file>
<file>resource/ui/direct_connect_dialog.ui</file>
<file>resource/ui/lobby.ui</file>
</qresource>
Expand Down
Loading

0 comments on commit 6eeceb4

Please sign in to comment.