2017-03-29 10:18:37 +00:00
|
|
|
#ifndef QHELPERS_H
|
|
|
|
#define QHELPERS_H
|
|
|
|
|
2017-04-13 15:04:30 +00:00
|
|
|
#include <QString>
|
2017-12-03 14:46:22 +00:00
|
|
|
#include <QColor>
|
2017-11-03 17:22:54 +00:00
|
|
|
#include <QSizePolicy>
|
2019-04-27 17:58:44 +00:00
|
|
|
#include <functional>
|
2017-04-13 15:04:30 +00:00
|
|
|
|
2019-04-27 17:58:44 +00:00
|
|
|
class QIcon;
|
2017-04-05 08:56:59 +00:00
|
|
|
class QPlainTextEdit;
|
|
|
|
class QTextEdit;
|
2017-04-18 10:03:47 +00:00
|
|
|
class QString;
|
2017-04-13 15:04:30 +00:00
|
|
|
class QTreeWidget;
|
2017-04-28 13:09:40 +00:00
|
|
|
class QTreeWidgetItem;
|
|
|
|
class QAbstractItemView;
|
2017-10-01 14:36:40 +00:00
|
|
|
class QAbstractButton;
|
2017-11-03 17:22:54 +00:00
|
|
|
class QWidget;
|
2017-12-23 16:42:42 +00:00
|
|
|
class QTreeView;
|
2019-09-25 14:18:30 +00:00
|
|
|
class QAction;
|
|
|
|
class QMenu;
|
2019-10-06 17:35:44 +00:00
|
|
|
class QPaintDevice;
|
2017-03-29 10:18:37 +00:00
|
|
|
|
2018-03-21 20:32:32 +00:00
|
|
|
namespace qhelpers {
|
2019-12-15 07:44:43 +00:00
|
|
|
QString formatBytecount(const uint64_t bytecount);
|
2018-03-21 20:32:32 +00:00
|
|
|
void adjustColumns(QTreeView *tv, int columnCount, int padding);
|
|
|
|
void adjustColumns(QTreeWidget *tw, int padding);
|
2019-09-01 21:30:25 +00:00
|
|
|
bool selectFirstItem(QAbstractItemView *itemView);
|
2018-03-21 20:32:32 +00:00
|
|
|
QTreeWidgetItem *appendRow(QTreeWidget *tw, const QString &str, const QString &str2 = QString(),
|
|
|
|
const QString &str3 = QString(), const QString &str4 = QString(), const QString &str5 = QString());
|
2017-04-13 15:04:30 +00:00
|
|
|
|
2018-03-21 20:32:32 +00:00
|
|
|
void setVerticalScrollMode(QAbstractItemView *tw);
|
2017-10-01 14:36:40 +00:00
|
|
|
|
2018-03-21 20:32:32 +00:00
|
|
|
void setCheckedWithoutSignals(QAbstractButton *button, bool checked);
|
2017-11-03 17:22:54 +00:00
|
|
|
|
|
|
|
|
2018-03-21 20:32:32 +00:00
|
|
|
struct SizePolicyMinMax {
|
|
|
|
QSizePolicy sizePolicy;
|
|
|
|
int min;
|
|
|
|
int max;
|
2017-11-03 17:22:54 +00:00
|
|
|
|
2018-03-21 20:32:32 +00:00
|
|
|
void restoreWidth(QWidget *widget);
|
|
|
|
void restoreHeight(QWidget *widget);
|
|
|
|
};
|
2017-11-03 17:22:54 +00:00
|
|
|
|
2018-03-21 20:32:32 +00:00
|
|
|
SizePolicyMinMax forceWidth(QWidget *widget, int width);
|
|
|
|
SizePolicyMinMax forceHeight(QWidget *widget, int height);
|
2017-11-15 21:56:10 +00:00
|
|
|
|
2018-03-21 20:32:32 +00:00
|
|
|
int getMaxFullyDisplayedLines(QTextEdit *textEdit);
|
|
|
|
int getMaxFullyDisplayedLines(QPlainTextEdit *plainTextEdit);
|
2017-12-03 14:46:22 +00:00
|
|
|
|
2018-03-21 20:32:32 +00:00
|
|
|
QByteArray applyColorToSvg(const QByteArray &data, QColor color);
|
|
|
|
QByteArray applyColorToSvg(const QString &filename, QColor color);
|
2019-04-27 17:58:44 +00:00
|
|
|
|
|
|
|
void setThemeIcons(QList<QPair<void*, QString>> supportedIconsNames, std::function<void(void *, const QIcon &)> setter);
|
|
|
|
|
2019-09-25 14:18:30 +00:00
|
|
|
void prependQAction(QAction *action, QMenu *menu);
|
2019-10-06 17:35:44 +00:00
|
|
|
qreal devicePixelRatio(const QPaintDevice *p);
|
2019-09-25 14:18:30 +00:00
|
|
|
|
2019-04-27 17:58:44 +00:00
|
|
|
} // qhelpers
|
2017-03-29 10:18:37 +00:00
|
|
|
|
|
|
|
#endif // HELPERS_H
|