summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkat <kat@vector35.com>2024-02-06 19:28:16 -0500
committerkat <kat@vector35.com>2024-02-06 19:28:16 -0500
commit75ee61e20cea015448771efe816b841bb2147f34 (patch)
tree846b09fffc5dc7529fafe5a8d22a3f411e2d44cb
parent7264a843e47cd11aa3252bf5886719f8bda93a04 (diff)
New Tab Redesign
- Adds some fixes for Animation, an Update info support class and other small things required
-rw-r--r--binaryninjacore.h39
-rw-r--r--ui/animation.h19
-rw-r--r--ui/clickablelabel.h12
-rw-r--r--ui/tabwidget.h1
-rw-r--r--ui/theme.h10
-rw-r--r--ui/updateinfo.h70
6 files changed, 131 insertions, 20 deletions
diff --git a/binaryninjacore.h b/binaryninjacore.h
index 9090fdd5..085c52fb 100644
--- a/binaryninjacore.h
+++ b/binaryninjacore.h
@@ -2314,6 +2314,35 @@ extern "C"
char* latestVersion;
} BNUpdateChannel;
+ typedef struct BNVersionInfo {
+ uint32_t major;
+ uint32_t minor;
+ uint32_t build;
+ char* channel;
+ } BNVersionInfo;
+
+ typedef struct BNChangelogEntry {
+ BNVersionInfo version;
+ char* notes;
+ uint64_t time;
+ } BNChangelogEntry;
+
+ typedef struct BNUpdateVersionNew {
+ BNVersionInfo version;
+ char* name;
+ uint64_t time;
+ } BNUpdateVersionNew;
+
+ typedef struct BNUpdateChannelFullInfo {
+ BNUpdateVersionNew* versions;
+ uint64_t versionCount;
+ BNChangelogEntry* changelogEntries;
+ uint64_t changelogEntryCount;
+ char* name;
+ char* desc;
+ char* latestVersion;
+ } BNUpdateChannelFullInfo;
+
typedef struct BNUpdateVersion
{
char* version;
@@ -3051,14 +3080,6 @@ extern "C"
bool (*deleteData)(void* ctxt, const char* key);
} BNSecretsProviderCallbacks;
- typedef struct BNVersionInfo
- {
- uint32_t major;
- uint32_t minor;
- uint32_t build;
- const char* channel;
- } BNVersionInfo;
-
typedef struct BNMergedVariable
{
BNVariable target;
@@ -5969,6 +5990,8 @@ extern "C"
BINARYNINJACOREAPI void BNFreeUpdateChannelList(BNUpdateChannel* list, size_t count);
BINARYNINJACOREAPI BNUpdateVersion* BNGetUpdateChannelVersions(const char* channel, size_t* count, char** errors);
BINARYNINJACOREAPI void BNFreeUpdateChannelVersionList(BNUpdateVersion* list, size_t count);
+ BINARYNINJACOREAPI BNUpdateChannelFullInfo* BNGetFullInfoUpdateChannels(size_t* count, char** errors);
+ BINARYNINJACOREAPI void BNFreeFullInfoUpdateChannels(BNUpdateChannelFullInfo* list, size_t count);
BINARYNINJACOREAPI bool BNAreUpdatesAvailable(
const char* channel, uint64_t* expireTime, uint64_t* serverTime, char** errors);
diff --git a/ui/animation.h b/ui/animation.h
index cf5498b5..3bbd5b70 100644
--- a/ui/animation.h
+++ b/ui/animation.h
@@ -23,11 +23,6 @@ class SceneManager;
\ingroup uiapi
*/
-enum AnimationDirection
-{
- Forwards,
- Backwards
-};
/*! Animation is a helper class for setting up UI animations.
Animations can be created as standalone objects (for simpler single-item animations), and can also be used
@@ -55,21 +50,21 @@ class BINARYNINJAUIAPI Animation : public QVariantAnimation
std::string m_name;
bool m_overrideReducedAnimations = false;
- AnimationDirection m_direction = Forwards;
+ QAbstractAnimation::Direction m_direction = QAbstractAnimation::Forward;
bool m_ownerDestroyed = false;
std::unordered_map<QObject*, std::vector<std::string>> m_properties;
std::vector<std::function<void(double)>> m_callbacks;
- std::vector<std::function<void(AnimationDirection)>> m_startCallbacks;
- std::vector<std::function<void(AnimationDirection)>> m_endCallbacks;
+ std::vector<std::function<void(QAbstractAnimation::Direction)>> m_startCallbacks;
+ std::vector<std::function<void(QAbstractAnimation::Direction)>> m_endCallbacks;
friend SceneManager;
void addPropertyCallback(QObject* obj, QString property);
void addCallback(std::function<void(double)> callback);
- void addStartCallback(std::function<void(AnimationDirection)> startCallback);
- void addEndCallback(std::function<void(AnimationDirection)> endCallback);
+ void addStartCallback(std::function<void(QAbstractAnimation::Direction)> startCallback);
+ void addEndCallback(std::function<void(QAbstractAnimation::Direction)> endCallback);
Animation(QObject* owner = nullptr);
Animation* invertDirection();
@@ -147,7 +142,7 @@ public:
\param startCallback Function to be called
\return Pointer to this \c Animation object
*/
- Animation* thenOnStart(std::function<void(AnimationDirection)> startCallback);
+ Animation* thenOnStart(std::function<void(QAbstractAnimation::Direction)> startCallback);
/*! Callback to fire when this animation's progress is updated. This is where the bulk of your animation
logic will go.
@@ -187,7 +182,7 @@ public:
\param endCallback Function to be called
\return Pointer to this \c Animation object
*/
- Animation* thenOnEnd(std::function<void(AnimationDirection)> endCallback);
+ Animation* thenOnEnd(std::function<void(QAbstractAnimation::Direction)> endCallback);
/// ONLY use this if you are doing something like a loading spinner. AVOID IT
Animation* overridingReducedAnimationsForAVeryGoodReason()
diff --git a/ui/clickablelabel.h b/ui/clickablelabel.h
index d9b679d7..6051480e 100644
--- a/ui/clickablelabel.h
+++ b/ui/clickablelabel.h
@@ -69,6 +69,7 @@ class BINARYNINJAUIAPI ClickableIcon : public QWidget
bool m_canToggle = false;
bool m_active = true;
bool m_hover = false;
+ double m_opacity = 1.0;
QTimer* m_timer;
public:
@@ -80,6 +81,17 @@ class BINARYNINJAUIAPI ClickableIcon : public QWidget
void setImage(const QImage& icon);
+ Q_PROPERTY(QSize desiredPointSize READ desiredPointSize WRITE setDesiredPointSize)
+ QSize desiredPointSize() const { return rect().size(); }
+ void setDesiredPointSize(const QSize& size) { setFixedSize(size); }
+ Q_PROPERTY(double opacity READ opacity WRITE setOpacity)
+ double opacity() const { return m_opacity; }
+ void setOpacity(double opacity)
+ {
+ m_opacity = opacity;
+ update();
+ };
+
Q_SIGNALS:
void clicked();
void toggle(bool newState);
diff --git a/ui/tabwidget.h b/ui/tabwidget.h
index dad3d2ca..67fb1a17 100644
--- a/ui/tabwidget.h
+++ b/ui/tabwidget.h
@@ -398,6 +398,7 @@ class BINARYNINJAUIAPI SplitTabWidget : public QWidget
void tabClosed(QWidget* widget);
void currentChanged(QWidget* widget);
void layoutChanged();
+ void splitSizeChanged();
private Q_SLOTS:
void tabCloseRequested(int idx);
diff --git a/ui/theme.h b/ui/theme.h
index 8bb9d509..bee3a7e7 100644
--- a/ui/theme.h
+++ b/ui/theme.h
@@ -5,6 +5,7 @@
#include <vector>
#include "binaryninjaapi.h"
#include "uicontext.h"
+#include <QPushButton>
/*!
@addtogroup Theme
@@ -12,6 +13,13 @@
@{
*/
+class BINARYNINJAUIAPI CustomStyleFlatButton : public QPushButton
+{
+ Q_OBJECT
+public:
+ CustomStyleFlatButton(QWidget* parent = nullptr) : QPushButton(parent) {}
+};
+
class BINARYNINJAUIAPI CustomFusionStyle : public QProxyStyle
{
public:
@@ -25,6 +33,8 @@ class BINARYNINJAUIAPI CustomFusionStyle : public QProxyStyle
QStyle::SubElement element, const QStyleOption *option, const QWidget *widget) const override;
virtual void drawPrimitive(
PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const override;
+ virtual int styleHint(QStyle::StyleHint hint, const QStyleOption *option = nullptr, const QWidget *widget = nullptr,
+ QStyleHintReturn *returnData = nullptr) const override;
};
void BINARYNINJAUIAPI pixmapForBWMaskIcon(const QString& url, QPixmap* pixmapOut, BNThemeColor color = SidebarActiveIconColor, const QString& cacheSuffix = "");
diff --git a/ui/updateinfo.h b/ui/updateinfo.h
new file mode 100644
index 00000000..55102870
--- /dev/null
+++ b/ui/updateinfo.h
@@ -0,0 +1,70 @@
+#pragma once
+
+#include "uitypes.h"
+#include <QString>
+#include <QObject>
+#include <QVersionNumber>
+#include <QDateTime>
+#include "binaryninjaapi.h"
+
+class BINARYNINJAUIAPI UpdateInfoFetcher : public QObject
+{
+ Q_OBJECT
+
+public:
+ struct Version
+ {
+ QString versionStringToGiveToMainWindow;
+ QVersionNumber version;
+ QDateTime date;
+ bool isCurrent = false;
+ Version(BNUpdateVersionNew);
+ };
+ struct ChangelogEntryItem
+ {
+ QString author;
+ QString commit;
+ QString body;
+ ChangelogEntryItem(const QString& author = "", const QString& commit = "", const QString& body = "")
+ : author(author), commit(commit), body(body) {};
+ /// In-struct cache for wrapped text
+ mutable QString bodyWrapCache;
+ };
+ struct ChangelogEntry
+ {
+ QVersionNumber version;
+ QDateTime date;
+ bool isNew = false;
+ std::vector<ChangelogEntryItem> entryItems;
+ ChangelogEntry(BNChangelogEntry);
+ };
+ struct Channel
+ {
+ QString name;
+ QString description;
+ std::vector<Version> versions;
+ std::vector<ChangelogEntry> changelog;
+ Channel(BNUpdateChannelFullInfo);
+ Channel() {};
+ };
+ enum FetchError
+ {
+ NoError,
+ ConnectionError,
+ DeserError
+ };
+
+private:
+ std::vector<Channel> m_channels;
+ std::mutex m_infoMutex;
+ std::atomic<bool> m_done = false;
+
+public:
+ UpdateInfoFetcher() {};
+ bool done() { return m_done; }
+ void startFetch();
+ const std::vector<Channel>& getChannels();
+ const Channel* getActiveChannel();
+signals:
+ void fetchCompleted(const FetchError& error);
+}; \ No newline at end of file