forked from Chatterino/chatterino2
-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/master' into chatterino7
- Loading branch information
Showing
49 changed files
with
1,475 additions
and
733 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 26 additions & 3 deletions
29
src/controllers/moderationactions/ModerationActionModel.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,51 @@ | ||
#include "controllers/moderationactions/ModerationActionModel.hpp" | ||
|
||
#include "controllers/moderationactions/ModerationAction.hpp" | ||
#include "messages/Image.hpp" | ||
#include "util/LoadPixmap.hpp" | ||
#include "util/PostToThread.hpp" | ||
#include "util/StandardItemHelper.hpp" | ||
|
||
#include <QIcon> | ||
#include <QPixmap> | ||
|
||
namespace chatterino { | ||
|
||
// commandmodel | ||
ModerationActionModel ::ModerationActionModel(QObject *parent) | ||
: SignalVectorModel<ModerationAction>(1, parent) | ||
: SignalVectorModel<ModerationAction>(2, parent) | ||
{ | ||
} | ||
|
||
// turn a vector item into a model row | ||
ModerationAction ModerationActionModel::getItemFromRow( | ||
std::vector<QStandardItem *> &row, const ModerationAction &original) | ||
{ | ||
return ModerationAction(row[0]->data(Qt::DisplayRole).toString()); | ||
return ModerationAction( | ||
row[Column::Command]->data(Qt::DisplayRole).toString(), | ||
row[Column::Icon]->data(Qt::UserRole).toString()); | ||
} | ||
|
||
// turns a row in the model into a vector item | ||
void ModerationActionModel::getRowFromItem(const ModerationAction &item, | ||
std::vector<QStandardItem *> &row) | ||
{ | ||
setStringItem(row[0], item.getAction()); | ||
setStringItem(row[Column::Command], item.getAction()); | ||
setFilePathItem(row[Column::Icon], item.iconPath()); | ||
if (!item.iconPath().isEmpty()) | ||
{ | ||
auto oImage = item.getImage(); | ||
assert(oImage.has_value()); | ||
if (oImage.has_value()) | ||
{ | ||
auto url = oImage->get()->url(); | ||
loadPixmapFromUrl(url, [row](const QPixmap &pixmap) { | ||
postToThread([row, pixmap]() { | ||
row[Column::Icon]->setData(pixmap, Qt::DecorationRole); | ||
}); | ||
}); | ||
} | ||
} | ||
} | ||
|
||
} // namespace chatterino |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.