| 1 |
/* |
| 2 |
* Copyright (C) 2020 Rerrah |
| 3 |
* |
| 4 |
* Permission is hereby granted, free of charge, to any person |
| 5 |
* obtaining a copy of this software and associated documentation |
| 6 |
* files (the "Software"), to deal in the Software without |
| 7 |
* restriction, including without limitation the rights to use, |
| 8 |
* copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 9 |
* copies of the Software, and to permit persons to whom the |
| 10 |
* Software is furnished to do so, subject to the following |
| 11 |
* conditions: |
| 12 |
* |
| 13 |
* The above copyright notice and this permission notice shall be |
| 14 |
* included in all copies or substantial portions of the Software. |
| 15 |
* |
| 16 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 17 |
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
| 18 |
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 19 |
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
| 20 |
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
| 21 |
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 22 |
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| 23 |
* OTHER DEALINGS IN THE SOFTWARE. |
| 24 |
*/ |
| 25 |
|
| 26 |
#ifndef BOOKMARK_MANAGER_FORM_HPP |
| 27 |
#define BOOKMARK_MANAGER_FORM_HPP |
| 28 |
|
| 29 |
#include <QWidget> |
| 30 |
#include <QString> |
| 31 |
#include <QListWidgetItem> |
| 32 |
#include <QShortcut> |
| 33 |
#include <memory> |
| 34 |
#include "bamboo_tracker.hpp" |
| 35 |
|
| 36 |
namespace Ui { |
| 37 |
class BookmarkManagerForm; |
| 38 |
} |
| 39 |
|
| 40 |
class BookmarkManagerForm : public QWidget |
| 41 |
{ |
| 42 |
Q_OBJECT |
| 43 |
|
| 44 |
public: |
| 45 |
BookmarkManagerForm(std::weak_ptr<BambooTracker> core, bool showHex, |
| 46 |
QWidget *parent = nullptr); |
| 47 |
~BookmarkManagerForm() override; |
| 48 |
|
| 49 |
signals: |
| 50 |
void positionJumpRequested(int order, int step); |
| 51 |
void modified(); |
| 52 |
|
| 53 |
public slots: |
| 54 |
void onCurrentSongNumberChanged(); |
| 55 |
void onConfigurationChanged(bool showHex); |
| 56 |
void onBookmarkToggleRequested(int order, int step); |
| 57 |
void onBookmarkJumpRequested(bool toNext, int order, int step); |
| 58 |
|
| 59 |
private slots: |
| 60 |
void on_createPushButton_clicked(); |
| 61 |
void on_removePushButton_clicked(); |
| 62 |
void on_clearPushButton_clicked(); |
| 63 |
void on_upToolButton_clicked(); |
| 64 |
void on_downToolButton_clicked(); |
| 65 |
void on_positionPushButton_clicked(); |
| 66 |
void on_namePushButton_clicked(); |
| 67 |
void on_listWidget_currentRowChanged(int currentRow); |
| 68 |
void on_updatePushButton_clicked(); |
| 69 |
void on_listWidget_itemDoubleClicked(QListWidgetItem *item); |
| 70 |
|
| 71 |
private: |
| 72 |
Ui::BookmarkManagerForm *ui; |
| 73 |
std::weak_ptr<BambooTracker> bt_; |
| 74 |
|
| 75 |
int curSong_; |
| 76 |
int numWidth_, numBase_; |
| 77 |
|
| 78 |
std::unique_ptr<QShortcut> insSc_, delSc_, mvUpSc_, mvDnSc_; |
| 79 |
|
| 80 |
void initList(); |
| 81 |
|
| 82 |
inline void setNumberSettings(bool showHex) |
| 83 |
{ |
| 84 |
if (showHex) { |
| 85 |
numWidth_ = 2; |
| 86 |
numBase_ = 16; |
| 87 |
} |
| 88 |
else { |
| 89 |
numWidth_ = 3; |
| 90 |
numBase_ = 10; |
| 91 |
} |
| 92 |
} |
| 93 |
|
| 94 |
void addBookmark(QString name, int order, int step, bool onlyUi = false); |
| 95 |
void removeBookmark(int i); |
| 96 |
QString createText(QString name, int order, int step); |
| 97 |
void sortList(bool byPos); |
| 98 |
}; |
| 99 |
|
| 100 |
#endif // BOOKMARK_MANAGER_FORM_HPP |