File indexing completed on 2024-05-05 04:34:53
0001 /* SPDX-FileCopyrightText: 2022 Noah Davis <noahadvs@gmail.com> 0002 * SPDX-License-Identifier: LGPL-2.0-or-later 0003 */ 0004 0005 #pragma once 0006 0007 #include "Platforms/ImagePlatform.h" 0008 0009 #include <QAbstractListModel> 0010 0011 /** 0012 * This is a model containing the current supported capture modes and their labels and shortcuts. 0013 */ 0014 class CaptureModeModel : public QAbstractListModel 0015 { 0016 Q_OBJECT 0017 Q_PROPERTY(int count READ rowCount NOTIFY countChanged FINAL) 0018 public: 0019 CaptureModeModel(ImagePlatform::GrabModes grabModes, QObject *parent = nullptr); 0020 0021 enum CaptureMode { 0022 RectangularRegion, 0023 AllScreens, 0024 // TODO: find a more user configuration friendly way to scale source images 0025 AllScreensScaled, 0026 CurrentScreen, 0027 ActiveWindow, 0028 WindowUnderCursor 0029 }; 0030 Q_ENUM(CaptureMode) 0031 0032 enum { 0033 CaptureModeRole = Qt::UserRole + 1, 0034 ShortcutsRole = Qt::UserRole + 2, 0035 }; 0036 0037 QHash<int, QByteArray> roleNames() const override; 0038 QVariant data(const QModelIndex &index, int role) const override; 0039 int rowCount(const QModelIndex &parent = QModelIndex()) const override; 0040 0041 int indexOfCaptureMode(CaptureMode captureMode) const; 0042 0043 void setGrabModes(ImagePlatform::GrabModes modes); 0044 0045 Q_SIGNALS: 0046 void captureModesChanged(); 0047 void countChanged(); 0048 0049 private: 0050 struct Item { 0051 CaptureModeModel::CaptureMode captureMode; 0052 QString label; 0053 QString shortcuts = {}; // default value in case there's nothing 0054 }; 0055 0056 QList<Item> m_data; 0057 QHash<int, QByteArray> m_roleNames; 0058 ImagePlatform::GrabModes m_grabModes; 0059 };