id
int64
0
755k
file_name
stringlengths
3
109
file_path
stringlengths
13
185
content
stringlengths
31
9.38M
size
int64
31
9.38M
language
stringclasses
1 value
extension
stringclasses
11 values
total_lines
int64
1
340k
avg_line_length
float64
2.18
149k
max_line_length
int64
7
2.22M
alphanum_fraction
float64
0
1
repo_name
stringlengths
6
65
repo_stars
int64
100
47.3k
repo_forks
int64
0
12k
repo_open_issues
int64
0
3.4k
repo_license
stringclasses
9 values
repo_extraction_date
stringclasses
92 values
exact_duplicates_redpajama
bool
2 classes
near_duplicates_redpajama
bool
2 classes
exact_duplicates_githubcode
bool
2 classes
exact_duplicates_stackv2
bool
1 class
exact_duplicates_stackv1
bool
2 classes
near_duplicates_githubcode
bool
2 classes
near_duplicates_stackv1
bool
2 classes
near_duplicates_stackv2
bool
1 class
752,895
wavtable.h
syams86_Virtual-Audio-Pipeline/Virtual Audio Pipeline/wavtable.h
/* Module Name: wavtable.h Abstract: Declaration of wave miniport tables. */ #ifndef __WAVTABLE_H_ #define __WAVTABLE_H_ //============================================================================= static KSDATARANGE_AUDIO PinDataRangesStream[] = { { { sizeof(KSDATARANGE_AUDIO), 0, 0, 0, STATICGUIDOF(KSDATAFORMAT_TYPE_AUDIO), STATICGUIDOF(KSDATAFORMAT_SUBTYPE_PCM), STATICGUIDOF(KSDATAFORMAT_SPECIFIER_WAVEFORMATEX) }, MAX_CHANNELS_PCM, MIN_BITS_PER_SAMPLE_PCM, MAX_BITS_PER_SAMPLE_PCM, MIN_SAMPLE_RATE, MAX_SAMPLE_RATE }, }; static PKSDATARANGE PinDataRangePointersStream[] = { PKSDATARANGE(&PinDataRangesStream[0]) }; //============================================================================= static KSDATARANGE PinDataRangesBridge[] = { { sizeof(KSDATARANGE), 0, 0, 0, STATICGUIDOF(KSDATAFORMAT_TYPE_AUDIO), STATICGUIDOF(KSDATAFORMAT_SUBTYPE_ANALOG), STATICGUIDOF(KSDATAFORMAT_SPECIFIER_NONE) } }; static PKSDATARANGE PinDataRangePointersBridge[] = { &PinDataRangesBridge[0] }; //============================================================================= static PCPIN_DESCRIPTOR MiniportPins[] = { // Wave In Streaming Pin (Capture) KSPIN_WAVE_CAPTURE_SINK { MAX_OUTPUT_STREAMS, MAX_OUTPUT_STREAMS, 0, NULL, { 0, NULL, 0, NULL, SIZEOF_ARRAY(PinDataRangePointersStream), PinDataRangePointersStream, KSPIN_DATAFLOW_OUT, KSPIN_COMMUNICATION_SINK, &KSCATEGORY_AUDIO, &KSAUDFNAME_RECORDING_CONTROL, 0 } }, // Wave In Bridge Pin (Capture - From Topology) KSPIN_WAVE_CAPTURE_SOURCE { 0, 0, 0, NULL, { 0, NULL, 0, NULL, SIZEOF_ARRAY(PinDataRangePointersBridge), PinDataRangePointersBridge, KSPIN_DATAFLOW_IN, KSPIN_COMMUNICATION_NONE, &KSCATEGORY_AUDIO, NULL, 0 } }, // Wave Out Streaming Pin (Renderer) KSPIN_WAVE_RENDER_SINK { MAX_INPUT_STREAMS, MAX_INPUT_STREAMS, 0, NULL, { 0, NULL, 0, NULL, SIZEOF_ARRAY(PinDataRangePointersStream), PinDataRangePointersStream, KSPIN_DATAFLOW_IN, KSPIN_COMMUNICATION_SINK, &KSCATEGORY_AUDIO, &KSAUDFNAME_VOLUME_CONTROL, 0 } }, // Wave Out Bridge Pin (Renderer) KSPIN_WAVE_RENDER_SOURCE { 0, 0, 0, NULL, { 0, NULL, 0, NULL, SIZEOF_ARRAY(PinDataRangePointersBridge), PinDataRangePointersBridge, KSPIN_DATAFLOW_OUT, KSPIN_COMMUNICATION_NONE, &KSCATEGORY_AUDIO, NULL, 0 } }, }; //============================================================================= static PCPROPERTY_ITEM PropertiesDAC[] = { // KSPROPERTY_AUDIO_CHANNEL_CONFIG { &KSPROPSETID_Audio, // Property Set KSPROPERTY_AUDIO_CHANNEL_CONFIG, // Property ID PCPROPERTY_ITEM_FLAG_GET | PCPROPERTY_ITEM_FLAG_SET, // Flags PropertyHandler_Wave // Handler } }; //============================================================================= DEFINE_PCAUTOMATION_TABLE_PROP(AutomationDAC, PropertiesDAC); //============================================================================= static PCNODE_DESCRIPTOR MiniportNodes[] = { // KSNODE_WAVE_ADC { 0, // Flags NULL, // AutomationTable &KSNODETYPE_ADC, // Type NULL // Name }, // KSNODE_WAVE_DAC { 0, // Flags &AutomationDAC, // AutomationTable &KSNODETYPE_DAC, // Type NULL // Name } }; //============================================================================= static PCCONNECTION_DESCRIPTOR MiniportConnections[] = { { PCFILTER_NODE, KSPIN_WAVE_CAPTURE_SOURCE, KSNODE_WAVE_ADC, 1 }, { KSNODE_WAVE_ADC, 0, PCFILTER_NODE, KSPIN_WAVE_CAPTURE_SINK }, { PCFILTER_NODE, KSPIN_WAVE_RENDER_SINK, KSNODE_WAVE_DAC, 1 }, { KSNODE_WAVE_DAC, 0, PCFILTER_NODE, KSPIN_WAVE_RENDER_SOURCE }, }; #if 0 //============================================================================= static PCPROPERTY_ITEM PropertiesWaveFilter[] = { { &KSPROPSETID_General, KSPROPERTY_GENERAL_COMPONENTID, KSPROPERTY_TYPE_GET | KSPROPERTY_TYPE_BASICSUPPORT, PropertyHandler_WaveFilter }, }; DEFINE_PCAUTOMATION_TABLE_PROP(AutomationWaveFilter, PropertiesWaveFilter); #endif //============================================================================= static PCFILTER_DESCRIPTOR MiniportFilterDescriptor = { 0, // Version NULL, // AutomationTable sizeof(PCPIN_DESCRIPTOR), // PinSize SIZEOF_ARRAY(MiniportPins), // PinCount MiniportPins, // Pins sizeof(PCNODE_DESCRIPTOR), // NodeSize SIZEOF_ARRAY(MiniportNodes), // NodeCount MiniportNodes, // Nodes SIZEOF_ARRAY(MiniportConnections), // ConnectionCount MiniportConnections, // Connections 0, // CategoryCount NULL // Categories - use defaults (audio, render, capture) }; #endif
6,194
C++
.h
193
24.352332
108
0.464023
syams86/Virtual-Audio-Pipeline
128
38
11
GPL-2.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
752,896
toptable.h
syams86_Virtual-Audio-Pipeline/Virtual Audio Pipeline/toptable.h
/* Module Name: toptable.h Abstract: Declaration of topology tables. */ #ifndef __TOPTABLE_H_ #define __TOPTABLE_H_ //============================================================================= static KSDATARANGE PinDataRangesBridge[] = { { sizeof(KSDATARANGE), 0, 0, 0, STATICGUIDOF(KSDATAFORMAT_TYPE_AUDIO), STATICGUIDOF(KSDATAFORMAT_SUBTYPE_ANALOG), STATICGUIDOF(KSDATAFORMAT_SPECIFIER_NONE) } }; //============================================================================= static PKSDATARANGE PinDataRangePointersBridge[] = { &PinDataRangesBridge[0] }; //============================================================================= static PCPIN_DESCRIPTOR MiniportPins[] = { // KSPIN_TOPO_WAVEOUT_SOURCE { 0, 0, 0, // InstanceCount NULL, // AutomationTable { // KsPinDescriptor 0, // InterfacesCount NULL, // Interfaces 0, // MediumsCount NULL, // Mediums SIZEOF_ARRAY(PinDataRangePointersBridge), // DataRangesCount PinDataRangePointersBridge, // DataRanges KSPIN_DATAFLOW_IN, // DataFlow KSPIN_COMMUNICATION_NONE, // Communication &KSCATEGORY_AUDIO, // Category NULL, // Name 0 // Reserved } }, /* // KSPIN_TOPO_SYNTHOUT_SOURCE { 0, 0, 0, // InstanceCount NULL, // AutomationTable { // KsPinDescriptor 0, // InterfacesCount NULL, // Interfaces 0, // MediumsCount NULL, // Mediums SIZEOF_ARRAY(PinDataRangePointersBridge), // DataRangesCount PinDataRangePointersBridge, // DataRanges KSPIN_DATAFLOW_IN, // DataFlow KSPIN_COMMUNICATION_NONE, // Communication &KSNODETYPE_SYNTHESIZER, // Category &KSAUDFNAME_MIDI, // Name 0 // Reserved } }, // KSPIN_TOPO_SYNTHIN_SOURCE { 0, 0, 0, // InstanceCount NULL, // AutomationTable { // KsPinDescriptor 0, // InterfacesCount NULL, // Interfaces 0, // MediumsCount NULL, // Mediums SIZEOF_ARRAY(PinDataRangePointersBridge), // DataRangesCount PinDataRangePointersBridge, // DataRanges KSPIN_DATAFLOW_IN, // DataFlow KSPIN_COMMUNICATION_NONE, // Communication &KSNODETYPE_SYNTHESIZER, // Category &KSAUDFNAME_MIDI, // Name 0 // Reserved } }, */ // KSPIN_TOPO_MIC_SOURCE { 0, 0, 0, // InstanceCount NULL, // AutomationTable { // KsPinDescriptor 0, // InterfacesCount NULL, // Interfaces 0, // MediumsCount NULL, // Mediums SIZEOF_ARRAY(PinDataRangePointersBridge), // DataRangesCount PinDataRangePointersBridge, // DataRanges KSPIN_DATAFLOW_IN, // DataFlow KSPIN_COMMUNICATION_NONE, // Communication &KSNODETYPE_MICROPHONE, // Category NULL, // Name 0 // Reserved } }, // KSPIN_TOPO_LINEOUT_DEST { 0, 0, 0, // InstanceCount NULL, // AutomationTable { // KsPinDescriptor 0, // InterfacesCount NULL, // Interfaces 0, // MediumsCount NULL, // Mediums SIZEOF_ARRAY(PinDataRangePointersBridge), // DataRangesCount PinDataRangePointersBridge, // DataRanges KSPIN_DATAFLOW_OUT, // DataFlow KSPIN_COMMUNICATION_NONE, // Communication &KSNODETYPE_SPEAKER, // Category &KSAUDFNAME_VOLUME_CONTROL, // Name (this name shows up as // the playback panel name in SoundVol) 0 // Reserved } }, // KSPIN_TOPO_WAVEIN_DEST { 0, 0, 0, // InstanceCount NULL, // AutomationTable { // KsPinDescriptor 0, // InterfacesCount NULL, // Interfaces 0, // MediumsCount NULL, // Mediums SIZEOF_ARRAY(PinDataRangePointersBridge), // DataRangesCount PinDataRangePointersBridge, // DataRanges KSPIN_DATAFLOW_OUT, // DataFlow KSPIN_COMMUNICATION_NONE, // Communication &KSCATEGORY_AUDIO, // Category NULL, // Name 0 // Reserved } } }; //============================================================================= static PCPROPERTY_ITEM PropertiesVolume[] = { { &KSPROPSETID_Audio, KSPROPERTY_AUDIO_VOLUMELEVEL, KSPROPERTY_TYPE_GET | KSPROPERTY_TYPE_SET | KSPROPERTY_TYPE_BASICSUPPORT, PropertyHandler_Topology }, { &KSPROPSETID_Audio, KSPROPERTY_AUDIO_CPU_RESOURCES, KSPROPERTY_TYPE_GET | KSPROPERTY_TYPE_BASICSUPPORT, PropertyHandler_Topology } }; DEFINE_PCAUTOMATION_TABLE_PROP(AutomationVolume, PropertiesVolume); //============================================================================= static PCPROPERTY_ITEM PropertiesMute[] = { { &KSPROPSETID_Audio, KSPROPERTY_AUDIO_MUTE, KSPROPERTY_TYPE_GET | KSPROPERTY_TYPE_SET | KSPROPERTY_TYPE_BASICSUPPORT, PropertyHandler_Topology }, { &KSPROPSETID_Audio, KSPROPERTY_AUDIO_CPU_RESOURCES, KSPROPERTY_TYPE_GET | KSPROPERTY_TYPE_BASICSUPPORT, PropertyHandler_Topology } }; DEFINE_PCAUTOMATION_TABLE_PROP(AutomationMute, PropertiesMute); //============================================================================= static PCPROPERTY_ITEM PropertiesMux[] = { { &KSPROPSETID_Audio, KSPROPERTY_AUDIO_MUX_SOURCE, KSPROPERTY_TYPE_GET | KSPROPERTY_TYPE_SET | KSPROPERTY_TYPE_BASICSUPPORT, PropertyHandler_Topology }, { &KSPROPSETID_Audio, KSPROPERTY_AUDIO_CPU_RESOURCES, KSPROPERTY_TYPE_GET | KSPROPERTY_TYPE_BASICSUPPORT, PropertyHandler_Topology } }; DEFINE_PCAUTOMATION_TABLE_PROP(AutomationMux, PropertiesMux); //============================================================================= static PCNODE_DESCRIPTOR TopologyNodes[] = { // KSNODE_TOPO_WAVEOUT_VOLUME { 0, // Flags &AutomationVolume, // AutomationTable &KSNODETYPE_VOLUME, // Type &KSAUDFNAME_WAVE_VOLUME // Name }, // KSNODE_TOPO_WAVEOUT_MUTE { 0, // Flags &AutomationMute, // AutomationTable &KSNODETYPE_MUTE, // Type &KSAUDFNAME_WAVE_MUTE // Name }, /* // KSNODE_TOPO_SYNTHOUT_VOLUME { 0, // Flags &AutomationVolume, // AutomationTable &KSNODETYPE_VOLUME, // Type &KSAUDFNAME_MIDI_VOLUME // Name }, // KSNODE_TOPO_SYNTHOUT_MUTE { 0, // Flags &AutomationMute, // AutomationTable &KSNODETYPE_MUTE, // Type &KSAUDFNAME_MIDI_MUTE // Name }, */ // KSNODE_TOPO_MIC_VOLUME { 0, // Flags &AutomationVolume, // AutomationTable &KSNODETYPE_VOLUME, // Type &KSAUDFNAME_MIC_VOLUME // Name }, /* // KSNODE_TOPO_SYNTHIN_VOLUME { 0, // Flags &AutomationVolume, // AutomationTable &KSNODETYPE_VOLUME, // Type &KSAUDFNAME_MIDI_VOLUME // Name }, */ // KSNODE_TOPO_LINEOUT_MIX { 0, // Flags NULL, // AutomationTable &KSNODETYPE_SUM, // Type NULL // Name }, // KSNODE_TOPO_LINEOUT_VOLUME { 0, // Flags &AutomationVolume, // AutomationTable &KSNODETYPE_VOLUME, // Type &KSAUDFNAME_MASTER_VOLUME // Name }, // KSNODE_TOPO_WAVEIN_MUX { 0, // Flags &AutomationMux, // AutomationTable &KSNODETYPE_MUX, // Type &KSAUDFNAME_RECORDING_SOURCE // Name }, }; //============================================================================= static PCCONNECTION_DESCRIPTOR MiniportConnections[] = { // FromNode, FromPin, ToNode, ToPin { PCFILTER_NODE, KSPIN_TOPO_WAVEOUT_SOURCE, KSNODE_TOPO_WAVEOUT_VOLUME, 1 }, { KSNODE_TOPO_WAVEOUT_VOLUME, 0, KSNODE_TOPO_WAVEOUT_MUTE, 1 }, { KSNODE_TOPO_WAVEOUT_MUTE, 0, KSNODE_TOPO_LINEOUT_MIX, 1 }, /* { PCFILTER_NODE, KSPIN_TOPO_SYNTHOUT_SOURCE, KSNODE_TOPO_SYNTHOUT_VOLUME, 1 }, { KSNODE_TOPO_SYNTHOUT_VOLUME, 0, KSNODE_TOPO_SYNTHOUT_MUTE, 1 }, { KSNODE_TOPO_SYNTHOUT_MUTE, 0, KSNODE_TOPO_LINEOUT_MIX, 1 }, { PCFILTER_NODE, KSPIN_TOPO_SYNTHIN_SOURCE, KSNODE_TOPO_SYNTHIN_VOLUME, 1 }, { KSNODE_TOPO_SYNTHIN_VOLUME, 0, KSNODE_TOPO_WAVEIN_MUX, 4 }, */ { PCFILTER_NODE, KSPIN_TOPO_MIC_SOURCE, KSNODE_TOPO_MIC_VOLUME, 1 }, { KSNODE_TOPO_MIC_VOLUME, 0, KSNODE_TOPO_WAVEIN_MUX, 4 }, { KSNODE_TOPO_LINEOUT_MIX, 0, KSNODE_TOPO_LINEOUT_VOLUME, 1 }, { KSNODE_TOPO_LINEOUT_VOLUME, 0, PCFILTER_NODE, KSPIN_TOPO_LINEOUT_DEST }, { KSNODE_TOPO_WAVEIN_MUX, 0, PCFILTER_NODE, KSPIN_TOPO_WAVEIN_DEST } }; //============================================================================= static PCFILTER_DESCRIPTOR MiniportFilterDescriptor = { 0, // Version NULL, // AutomationTable sizeof(PCPIN_DESCRIPTOR), // PinSize SIZEOF_ARRAY(MiniportPins), // PinCount MiniportPins, // Pins sizeof(PCNODE_DESCRIPTOR), // NodeSize SIZEOF_ARRAY(TopologyNodes), // NodeCount TopologyNodes, // Nodes SIZEOF_ARRAY(MiniportConnections), // ConnectionCount MiniportConnections, // Connections 0, // CategoryCount NULL // Categories }; #endif
12,680
C++
.h
303
37.346535
123
0.424939
syams86/Virtual-Audio-Pipeline
128
38
11
GPL-2.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,076
dbus_consts.cpp
martyr-deepin_deepin-appstore/src/dbus/dbus_consts.cpp
/* * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "dbus/dbus_consts.h" namespace dstore { const char kAppStoreDbusPath[] = "/com/deepin/AppStore"; const char kAppStoreDbusService[] = "com.deepin.AppStore"; const char kAppstoreDaemonService[] = "com.deepin.AppStore.Daemon"; const char kAppstoreDaemonPath[] = "/com/deepin/AppStore/Metadata"; const char kAppstoreDaemonInterface[] = "com.deepin.AppStore.Metadata"; const char kAppstoreDaemonSettingsPath[] = "/com/deepin/AppStore/Settings"; const char kAppstoreDaemonSettingsInterface[] = "com.deepin.AppStore.Settings"; const char kLastoreDebDbusPath[] = "/com/deepin/AppStore/Backend"; const char kLastoreDebDbusService[] = "com.deepin.AppStore.Daemon"; const char kLastoreDebJobService[] = "com.deepin.AppStore.Daemon"; } // namespace dstore
1,457
C++
.cpp
30
46.833333
79
0.778169
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,077
deepinid_interface.cpp
martyr-deepin_deepin-appstore/src/dbus/deepinid_interface.cpp
/* * This file was generated by qdbusxml2cpp-fix version 0.8 * Command line was: qdbusxml2cpp-fix -c deepinid -p generated/com_deepin_deepinid /home/iceyer/Develop/deepin/dde-qt-dbus-factory/xml/com.deepin.deepinid.xml * * qdbusxml2cpp-fix is Copyright (C) 2016 Deepin Technology Co., Ltd. * * This is an auto-generated file. * This file may have been hand-edited. Look for HAND-EDIT comments * before re-generating it. */ #include "deepinid_interface.h" /* * Implementation of interface class __deepinid */ class __deepinidPrivate { public: __deepinidPrivate() = default; // begin member variables QString HardwareID; QString MachineName; DVariantMap UserInfo; public: QMap<QString, QDBusPendingCallWatcher *> m_processingCalls; QMap<QString, QList<QVariant>> m_waittingCalls; }; __deepinid::__deepinid(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent) : DBusExtendedAbstractInterface(service, path, staticInterfaceName(), connection, parent) , d_ptr(new __deepinidPrivate) { connect(this, &__deepinid::propertyChanged, this, &__deepinid::onPropertyChanged); if (QMetaType::type("DVariantMap") == QMetaType::UnknownType) { qRegisterMetaType<DVariantMap>("DVariantMap"); qDBusRegisterMetaType<DVariantMap>(); } } __deepinid::~__deepinid() { qDeleteAll(d_ptr->m_processingCalls.values()); delete d_ptr; } void __deepinid::onPropertyChanged(const QString &propName, const QVariant &value) { if (propName == QStringLiteral("HardwareID")) { const QString &HardwareID = qvariant_cast<QString>(value); if (d_ptr->HardwareID != HardwareID) { d_ptr->HardwareID = HardwareID; Q_EMIT HardwareIDChanged(d_ptr->HardwareID); } return; } if (propName == QStringLiteral("MachineName")) { const QString &MachineName = qvariant_cast<QString>(value); if (d_ptr->MachineName != MachineName) { d_ptr->MachineName = MachineName; Q_EMIT MachineNameChanged(d_ptr->MachineName); } return; } if (propName == QStringLiteral("UserInfo")) { const DVariantMap &UserInfo = qvariant_cast<DVariantMap>(value); if (d_ptr->UserInfo != UserInfo) { d_ptr->UserInfo = UserInfo; Q_EMIT UserInfoChanged(d_ptr->UserInfo); } return; } qWarning() << "property not handle: " << propName; return; } QString __deepinid::hardwareID() { return qvariant_cast<QString>(internalPropGet("HardwareID", &d_ptr->HardwareID)); } QString __deepinid::machineName() { return qvariant_cast<QString>(internalPropGet("MachineName", &d_ptr->MachineName)); } DVariantMap __deepinid::userInfo() { return qvariant_cast<DVariantMap>(internalPropGet("UserInfo", &d_ptr->UserInfo)); } void __deepinid::CallQueued(const QString &callName, const QList<QVariant> &args) { if (d_ptr->m_waittingCalls.contains(callName)) { d_ptr->m_waittingCalls[callName] = args; return; } if (d_ptr->m_processingCalls.contains(callName)) { d_ptr->m_waittingCalls.insert(callName, args); } else { QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(asyncCallWithArgumentList(callName, args)); connect(watcher, &QDBusPendingCallWatcher::finished, this, &__deepinid::onPendingCallFinished); d_ptr->m_processingCalls.insert(callName, watcher); } } void __deepinid::onPendingCallFinished(QDBusPendingCallWatcher *w) { w->deleteLater(); const auto callName = d_ptr->m_processingCalls.key(w); Q_ASSERT(!callName.isEmpty()); if (callName.isEmpty()) { return; } d_ptr->m_processingCalls.remove(callName); if (!d_ptr->m_waittingCalls.contains(callName)) { return; } const auto args = d_ptr->m_waittingCalls.take(callName); CallQueued(callName, args); }
3,949
C++
.cpp
111
30.648649
158
0.693536
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,078
dbus_extended_abstract_interface.cpp
martyr-deepin_deepin-appstore/src/dbus/dbus_extended_abstract_interface.cpp
/* * Copyright (C) 2018 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "dbus/dbus_extended_abstract_interface.h" #include <QDebug> #include <QtDBus/QtDBus> namespace { const char kPropIface[] = "org.freedesktop.DBus.Properties"; const char kPropName[] = "PropertiesChanged"; const char kPropType[] = "sa{sv}as"; } // namespace DbusExtendedAbstractInterface::DbusExtendedAbstractInterface( const QString& service, const QString& path, const char* interface, const QDBusConnection& connection, QObject* parent) : QDBusAbstractInterface(service, path, interface, connection, parent) { this->connection().connect(this->service(), this->path(), kPropIface, kPropName, kPropType, this, SLOT(propertyChanged(QDBusMessage))); } DbusExtendedAbstractInterface::~DbusExtendedAbstractInterface() { this->connection().disconnect(this->service(), this->path(), kPropIface, kPropName, kPropType, this, SLOT(propertyChanged(QDBusMessage))); } void DbusExtendedAbstractInterface::propertyChanged(const QDBusMessage& msg) { const QList<QVariant> arguments = msg.arguments(); if (arguments.count() != 3) { return; } const QString interface_name = arguments.at(0).toString(); if (interface_name != this->interface()) { return; } const QVariantMap changed_props = qdbus_cast<QVariantMap>( arguments.at(1).value<QDBusArgument>()); for (const QString& prop : changed_props.keys()) { const QMetaObject* self = this->metaObject(); for (int i = self->propertyOffset(); i < self->propertyCount(); ++i) { const QMetaProperty p = self->property(i); if (p.name() == prop) { emit p.notifySignal().invoke(this); } } } }
2,447
C++
.cpp
61
35.081967
78
0.696842
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,080
lastore_deb_interface.cpp
martyr-deepin_deepin-appstore/src/dbus/lastore_deb_interface.cpp
/* * This file was generated by qdbusxml2cpp version 0.8 * Command line was: qdbusxml2cpp com.deepin.AppStore.Backend.Deb.xml -p lastore_deb_interface -i dbus/dbus_variant/app_version.h -i dbus/dbus_variant/installed_app_info.h -i dbus/dbus_variant/installed_app_timestamp.h -i dbus/dbus_extended_abstract_interface.h -c LastoreDebInterface -l DbusExtendedAbstractInterface -N * * qdbusxml2cpp is Copyright (C) 2016 The Qt Company Ltd. * * This is an auto-generated file. * This file may have been hand-edited. Look for HAND-EDIT comments * before re-generating it. */ #include "lastore_deb_interface.h" /* * Implementation of interface class LastoreDebInterface */ LastoreDebInterface::LastoreDebInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent) : DbusExtendedAbstractInterface(service, path, staticInterfaceName(), connection, parent) { } LastoreDebInterface::~LastoreDebInterface() { }
966
C++
.cpp
21
44.047619
320
0.795745
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,082
app_version.cpp
martyr-deepin_deepin-appstore/src/dbus/dbus_variant/app_version.cpp
/* * Copyright (C) 2018 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "dbus/dbus_variant/app_version.h" #include <QtDBus/QtDBus> AppVersion::AppVersion() { } AppVersion::~AppVersion() { } void AppVersion::registerMetaType() { qRegisterMetaType<AppVersion>("AppVersion"); qDBusRegisterMetaType<AppVersion>(); qRegisterMetaType<AppVersionList>("AppVersionList"); qDBusRegisterMetaType<AppVersionList>(); } QDebug operator<<(QDebug debug, const AppVersion& info) { debug << info.pkg_name << info.installed_version << info.remote_version << info.upgradable; return debug; } QDBusArgument& operator<<(QDBusArgument& argument, const AppVersion& info) { argument.beginStructure(); argument << info.pkg_name << info.installed_version << info.remote_version << info.upgradable; argument.endStructure(); return argument; } QDataStream& operator<<(QDataStream& stream, const AppVersion& info) { stream << info.pkg_name << info.installed_version << info.remote_version << info.upgradable; return stream; } const QDBusArgument& operator>>(const QDBusArgument& argument, AppVersion& info) { argument.beginStructure(); argument >> info.pkg_name >> info.installed_version >> info.remote_version >> info.upgradable; argument.endStructure(); return argument; } const QDataStream& operator>>(QDataStream& stream, AppVersion& info) { stream >> info.pkg_name >> info.installed_version >> info.remote_version >> info.upgradable; return stream; }
2,302
C++
.cpp
69
28.521739
72
0.697884
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,083
app_metadata.cpp
martyr-deepin_deepin-appstore/src/dbus/dbus_variant/app_metadata.cpp
/* * Copyright (C) 2018 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "dbus/dbus_variant/app_metadata.h" #include <QtDBus/QtDBus> AppMetadata::AppMetadata() { } AppMetadata::~AppMetadata() { } void AppMetadata::registerMetaType() { qRegisterMetaType<AppMetadata>("AppMetadata"); qDBusRegisterMetaType<AppMetadata>(); } AppMetadata& AppMetadata::operator=(const AppMetadata& other) { this->name = other.name; this->icon = other.icon; this->category = other.category; return *this; } QDebug operator<<(QDebug debug, const AppMetadata& info) { debug << info.name << info.icon << info.category; return debug; } QDBusArgument& operator<<(QDBusArgument& argument, const AppMetadata& info) { argument.beginStructure(); argument << info.name << info.icon << info.category; argument.endStructure(); return argument; } QDataStream& operator<<(QDataStream& stream, const AppMetadata& info) { stream << info.name << info.icon << info.category; return stream; } const QDBusArgument& operator>>(const QDBusArgument& argument, AppMetadata& info) { argument.beginStructure(); argument >> info.name >> info.icon >> info.category; argument.endStructure(); return argument; } const QDataStream& operator>>(QDataStream& stream, AppMetadata& info) { stream >> info.name >> info.icon >> info.category; return stream; }
2,106
C++
.cpp
67
27.507463
77
0.707799
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,084
installed_app_timestamp.cpp
martyr-deepin_deepin-appstore/src/dbus/dbus_variant/installed_app_timestamp.cpp
/* * Copyright (C) 2018 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "dbus/dbus_variant/installed_app_timestamp.h" #include <QtDBus/QtDBus> InstalledAppTimestamp::InstalledAppTimestamp() { } InstalledAppTimestamp::~InstalledAppTimestamp() { } void InstalledAppTimestamp::registerMetaType() { qRegisterMetaType<InstalledAppTimestamp>("InstalledAppTimestamp"); qDBusRegisterMetaType<InstalledAppTimestamp>(); qRegisterMetaType<InstalledAppTimestampList>("InstalledAppTimestampList"); qDBusRegisterMetaType<InstalledAppTimestampList>(); } QDebug operator<<(QDebug debug, const InstalledAppTimestamp& info) { debug << info.pkg_name << info.timestamp; return debug; } QDBusArgument& operator<<(QDBusArgument& argument, const InstalledAppTimestamp& info) { argument.beginStructure(); argument << info.pkg_name << info.timestamp; argument.endStructure(); return argument; } QDataStream& operator<<(QDataStream& stream, const InstalledAppTimestamp& info) { stream << info.pkg_name << info.timestamp; return stream; } const QDBusArgument& operator>>(const QDBusArgument& argument, InstalledAppTimestamp& info) { argument.beginStructure(); argument >> info.pkg_name >> info.timestamp; argument.endStructure(); return argument; } const QDataStream& operator>>(QDataStream& stream, InstalledAppTimestamp& info) { stream >> info.pkg_name >> info.timestamp; return stream; }
2,144
C++
.cpp
59
32.474576
81
0.746261
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,085
installed_app_info.cpp
martyr-deepin_deepin-appstore/src/dbus/dbus_variant/installed_app_info.cpp
/* * Copyright (C) 2018 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "dbus/dbus_variant/installed_app_info.h" #include <QtDBus/QtDBus> InstalledAppInfo::InstalledAppInfo() { } InstalledAppInfo::~InstalledAppInfo() { } void InstalledAppInfo::registerMetaType() { qRegisterMetaType<InstalledAppInfo>("InstalledAppInfo"); qDBusRegisterMetaType<InstalledAppInfo>(); qRegisterMetaType<InstalledAppInfoList>("InstalledAppInfoList"); qDBusRegisterMetaType<InstalledAppInfoList>(); } QDebug operator<<(QDebug debug, const InstalledAppInfo &info) { debug << info.packageName << info.appName << info.version << info.size << info.installationTime << info.localeNames; return debug; } QDBusArgument &operator<<(QDBusArgument &argument, const InstalledAppInfo &info) { argument.beginStructure(); argument << info.packageName << info.appName << info.version << info.size << info.installationTime << info.localeNames; argument.endStructure(); return argument; } QDataStream &operator<<(QDataStream &stream, const InstalledAppInfo &info) { stream << info.packageName << info.appName << info.version << info.size << info.installationTime << info.localeNames; return stream; } const QDBusArgument &operator>>(const QDBusArgument &argument, InstalledAppInfo &info) { argument.beginStructure(); argument >> info.packageName >> info.appName >> info.version >> info.size >> info.installationTime >> info.localeNames; argument.endStructure(); return argument; } const QDataStream &operator>>(QDataStream &stream, InstalledAppInfo &info) { stream >> info.packageName >> info.appName >> info.version >> info.size >> info.installationTime >> info.localeNames;; return stream; }
2,713
C++
.cpp
87
25.045977
74
0.666412
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,086
theme.cpp
martyr-deepin_deepin-appstore/src/resources/theme.cpp
/* * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "resources/theme.h" #include <QMap> namespace dstore { unsigned int BackgroundColor(const QString &theme) { QMap<QString, unsigned int> themeBackgroundColor; themeBackgroundColor.insert("light", 0xFFFFFFFF); themeBackgroundColor.insert("dark", 0xFF1C1C1C); return themeBackgroundColor[theme]; } } // namespace store
1,044
C++
.cpp
28
34.964286
72
0.764356
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,087
images.cpp
martyr-deepin_deepin-appstore/src/resources/images.cpp
/* * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "resources/images.h" namespace dstore { const char* const kImageDeepinAppStore = ":/common/images/deepin-appstore.svg"; } // namespace store
850
C++
.cpp
20
40.6
79
0.759371
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,088
web_event_delegate.cpp
martyr-deepin_deepin-appstore/src/ui/web_event_delegate.cpp
/* * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "ui/web_event_delegate.h" #include <QDebug> #include <qcef_web_page.h> #include <QtGui/QDesktopServices> namespace dstore { namespace { enum MenuIds { // Normal navigation. MenuBack = QCefContextMenu::MENU_ID_USER_FIRST, MenuForward, MenuReload, MenuStop, // Editable. MenuUndo, MenuRedo, MenuCut, MenuCopy, MenuPaste, MenuDelete, MenuSelectAll, // Link. MenuOpenLinkInNewTab, MenuCopyLinkAddress, }; } // namespace WebEventDelegate::WebEventDelegate(QObject* parent) : QObject(parent) { this->setObjectName("WebEventDelegate"); } WebEventDelegate::~WebEventDelegate() { } bool WebEventDelegate::onBeforeBrowse(const QUrl& url, bool is_redirect) { return QCefBrowserEventDelegate::onBeforeBrowse(url, is_redirect); } void WebEventDelegate::onBeforeContextMenu( QCefWebPage* web_page, QCefContextMenu* menu, const QCefContextMenuParams& params) { QCefBrowserEventDelegate::onBeforeContextMenu(web_page, menu, params); auto type_flags = params.getTypeFlags(); if (type_flags & QCEF_CM_FLAG_EDITABLE) { // Editable menu. auto state = params.getEditStateFlags(); menu->addItem(MenuIds::MenuUndo, QObject::tr("Undo"), state & QCEF_CM_EDITFLAG_CAN_UNDO, [](QCefWebPage* page) { page->undo(); }); menu->addItem(MenuIds::MenuRedo, QObject::tr("Redo"), state & QCEF_CM_EDITFLAG_CAN_REDO, [](QCefWebPage* page) { page->redo(); }); menu->addSeparator(); menu->addItem(MenuIds::MenuCut, QObject::tr("Cut"), state & QCEF_CM_EDITFLAG_CAN_CUT, [](QCefWebPage* page) { page->cut(); }); menu->addItem(MenuIds::MenuCopy, QObject::tr("Copy"), state & QCEF_CM_EDITFLAG_CAN_COPY, [](QCefWebPage* page) { page->copy(); }); menu->addItem(MenuIds::MenuPaste, QObject::tr("Paste"), state & QCEF_CM_EDITFLAG_CAN_PASTE, [](QCefWebPage* page) { page->paste(); }); menu->addItem(MenuIds::MenuDelete, QObject::tr("Delete"), state & QCEF_CM_EDITFLAG_CAN_DELETE, [](QCefWebPage* page) { page->doDelete(); }); menu->addSeparator(); menu->addItem(MenuIds::MenuSelectAll, QObject::tr("Select all"), state & QCEF_CM_EDITFLAG_CAN_SELECT_ALL, [](QCefWebPage* page) { page->selectAll(); }); } else if (type_flags & QCEF_CM_FLAG_SELECTION) { // Support copy text auto state = params.getEditStateFlags(); menu->addItem(MenuIds::MenuCopy, QObject::tr("Copy"), state & QCEF_CM_EDITFLAG_CAN_COPY, [](QCefWebPage* page) { page->copy(); }); } } bool WebEventDelegate::onBeforePopup(const QUrl& url, QCefWindowOpenDisposition disposition) { QDesktopServices::openUrl(url); return QCefBrowserEventDelegate::onBeforePopup(url, disposition); } } // namespace dstore
3,985
C++
.cpp
111
27.900901
77
0.616222
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,089
web_window.cpp
martyr-deepin_deepin-appstore/src/ui/web_window.cpp
/* * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "ui/web_window.h" #include <DTitlebar> #include <DThemeManager> #include <DPlatformWindowHandle> #include <QApplication> #include <QDebug> #include <QDesktopWidget> #include <QResizeEvent> #include <QSettings> #include <QTimer> #include <QBuffer> #include <QWebChannel> #include <qcef_web_page.h> #include <qcef_web_settings.h> #include <qcef_web_view.h> #include <qcef_global_settings.h> #include "base/consts.h" #include "services/settings_manager.h" #include "ui/web_event_delegate.h" #include "ui/channel/image_viewer_proxy.h" #include "ui/channel/log_proxy.h" #include "ui/channel/menu_proxy.h" #include "ui/channel/search_proxy.h" #include "ui/channel/settings_proxy.h" #include "ui/channel/store_daemon_proxy.h" #include "ui/channel/account_proxy.h" #include "ui/channel/channel_proxy.h" #include "ui/widgets/image_viewer.h" #include "ui/widgets/search_completion_window.h" #include "ui/widgets/title_bar.h" #include "ui/widgets/title_bar_menu.h" namespace dstore { namespace { const int kSearchDelay = 200; const char kSettingsWinSize[] = "size"; const char kSettingsWinPos[] = "pos"; const char kSettingsWinMax[] = "isMaximized"; void BackupWindowState(QWidget *widget) { Q_ASSERT(widget != nullptr); QVariantMap windowState; windowState.insert(kSettingsWinPos, widget->pos()); windowState.insert(kSettingsWinSize, widget->size()); windowState.insert(kSettingsWinMax, widget->isMaximized()); QByteArray data; QDataStream dataStream(&data, QIODevice::WriteOnly); dataStream << windowState; SettingsManager::instance()->setWindowState(data); } void RestoreWindowState(QWidget *widget) { Q_ASSERT(widget != nullptr); QByteArray data = SettingsManager::instance()->windowState(); QBuffer readBuffer(&data); readBuffer.open(QIODevice::ReadOnly); QDataStream in(&readBuffer); QVariantMap settings; in >> settings; if (settings.contains(kSettingsWinSize)) { widget->resize(settings.value(kSettingsWinSize).toSize()); } if (settings.contains(kSettingsWinPos)) { widget->move(settings.value(kSettingsWinPos).toPoint()); } if (settings.value(kSettingsWinMax, false).toBool()) { widget->showMaximized(); } } } // namespace WebWindow::WebWindow(QWidget *parent) : DMainWindow(parent), search_timer_(new QTimer(this)), search_re_(QRegularExpression("[\\+\\$\\.\\^!@#%&\\(\\)]")) { this->setObjectName("WebWindow"); // 使用 redirectContent 模式,用于内嵌 x11 窗口时能有正确的圆角效果 DPlatformWindowHandle::enableDXcbForWindow(this, true); search_timer_->setSingleShot(true); this->initUI(); this->initServices(); this->initProxy(); // Connect signals to slots after all of internal objects are constructed. this->initConnections(); // Restore window state on init. RestoreWindowState(this); } WebWindow::~WebWindow() { // Save current window state. BackupWindowState(this); if (proxy_thread_ != nullptr) { proxy_thread_->quit(); proxy_thread_->deleteLater(); proxy_thread_ = nullptr; } if (image_viewer_proxy_ != nullptr) { image_viewer_proxy_->deleteLater(); image_viewer_proxy_ = nullptr; } if (log_proxy_ != nullptr) { log_proxy_->deleteLater(); log_proxy_ = nullptr; } if (menu_proxy_ != nullptr) { menu_proxy_->deleteLater(); menu_proxy_ = nullptr; } if (settings_proxy_ != nullptr) { settings_proxy_->deleteLater(); settings_proxy_ = nullptr; } if (store_daemon_proxy_ != nullptr) { store_daemon_proxy_->deleteLater(); store_daemon_proxy_ = nullptr; } if (account_proxy_ != nullptr) { account_proxy_->deleteLater(); account_proxy_ = nullptr; } } void WebWindow::setQCefSettings(QCefGlobalSettings *settings) { SettingsManager::instance()->setQCefSettings(settings); } void WebWindow::loadPage() { web_view_->load(QUrl(kIndexPage)); } void WebWindow::showWindow() { const QRect geometry = qApp->desktop()->availableGeometry(this); if (geometry.width() > 1024) { this->setMinimumSize(1200, 750); } else { this->setMinimumSize(960, 600); } this->show(); } void WebWindow::showAppDetail(const QString &app_name) { // TODO(Shaohua): Make sure angular context has been initialized. emit search_proxy_->openApp(app_name); } void WebWindow::raiseWindow() { this->raise(); } void WebWindow::initConnections() { connect(completion_window_, &SearchCompletionWindow::resultClicked, this, &WebWindow::onSearchResultClicked); connect(completion_window_, &SearchCompletionWindow::searchButtonClicked, this, &WebWindow::onSearchButtonClicked); connect(image_viewer_proxy_, &ImageViewerProxy::openImageFileRequested, image_viewer_, &ImageViewer::open); connect(image_viewer_proxy_, &ImageViewerProxy::openPixmapRequested, image_viewer_, &ImageViewer::openPixmap); connect(image_viewer_proxy_, &ImageViewerProxy::openOnlineImageRequest, image_viewer_, &ImageViewer::showIndicator); connect(image_viewer_, &ImageViewer::previousImageRequested, image_viewer_proxy_, &ImageViewerProxy::onPreviousImageRequested); connect(image_viewer_, &ImageViewer::nextImageRequested, image_viewer_proxy_, &ImageViewerProxy::onNextImageRequested); connect(search_proxy_, &SearchProxy::searchAppResult, this, &WebWindow::onSearchAppResult); connect(search_timer_, &QTimer::timeout, this, &WebWindow::onSearchTextChangedDelay); connect(title_bar_, &TitleBar::backwardButtonClicked, this, &WebWindow::webViewGoBack); connect(title_bar_, &TitleBar::forwardButtonClicked, this, &WebWindow::webViewGoForward); connect(title_bar_, &TitleBar::searchTextChanged, this, &WebWindow::onSearchTextChanged); connect(title_bar_, &TitleBar::downKeyPressed, completion_window_, &SearchCompletionWindow::goDown); connect(title_bar_, &TitleBar::enterPressed, this, &WebWindow::onTitleBarEntered); connect(title_bar_, &TitleBar::upKeyPressed, completion_window_, &SearchCompletionWindow::goUp); connect(title_bar_, &TitleBar::focusOut, this, &WebWindow::onSearchEditFocusOut); connect(title_bar_, &TitleBar::loginRequested, this, [&](bool login) { if (login) { account_proxy_->login(); } else { account_proxy_->logout(); } }); connect(tool_bar_menu_, &TitleBarMenu::recommendAppRequested, menu_proxy_, &MenuProxy::recommendAppRequested); connect(tool_bar_menu_, &TitleBarMenu::privacyAgreementRequested, menu_proxy_, &MenuProxy::privacyAgreementRequested); connect(tool_bar_menu_, &TitleBarMenu::switchThemeRequested, menu_proxy_, &MenuProxy::switchThemeRequested); connect(tool_bar_menu_, &TitleBarMenu::switchThemeRequested, this, &WebWindow::onThemeChaged); connect(tool_bar_menu_, &TitleBarMenu::clearCacheRequested, store_daemon_proxy_, &StoreDaemonProxy::clearArchives); connect(title_bar_, &TitleBar::commentRequested, menu_proxy_, &MenuProxy::commentRequested); connect(title_bar_, &TitleBar::requestDonates, menu_proxy_, &MenuProxy::donateRequested); connect(title_bar_, &TitleBar::requestApps, menu_proxy_, &MenuProxy::appsRequested); connect(menu_proxy_, &MenuProxy::userInfoUpdated, title_bar_, &TitleBar::setUserInfo); connect(web_view_->page(), &QCefWebPage::urlChanged, this, &WebWindow::onWebViewUrlChanged); connect(web_view_->page(), &QCefWebPage::fullscreenRequested, this, &WebWindow::onFullscreenRequest); connect(web_view_->page(), &QCefWebPage::loadingStateChanged, this, &WebWindow::onLoadingStateChanged); connect(settings_proxy_, &SettingsProxy::raiseWindowRequested, this, &WebWindow::raiseWindow); } void WebWindow::initProxy() { #ifdef DSTORE_DISABLE_MULTI_THREAD bool useMultiThread = false; #else bool useMultiThread = true; #endif auto parent = this; if (useMultiThread) { parent = nullptr; } auto page_channel = web_view_->page()->webChannel(); auto channel_proxy = new ChannelProxy(this); page_channel->registerObject("channelProxy", channel_proxy); auto web_channel = new QWebChannel(parent); web_channel->connectTo(channel_proxy->transport); store_daemon_proxy_ = new StoreDaemonProxy(parent); image_viewer_proxy_ = new ImageViewerProxy(parent); log_proxy_ = new LogProxy(parent); menu_proxy_ = new MenuProxy(parent); search_proxy_ = new SearchProxy(parent); settings_proxy_ = new SettingsProxy(parent); account_proxy_ = new AccountProxy(parent); web_channel->registerObject("imageViewer", image_viewer_proxy_); web_channel->registerObject("log", log_proxy_); web_channel->registerObject("menu", menu_proxy_); web_channel->registerObject("search", search_proxy_); web_channel->registerObject("settings", settings_proxy_); web_channel->registerObject("storeDaemon", store_daemon_proxy_); web_channel->registerObject("account", account_proxy_); if (useMultiThread) { proxy_thread_ = new QThread(parent); web_channel->moveToThread(proxy_thread_); image_viewer_proxy_->moveToThread(proxy_thread_); log_proxy_->moveToThread(proxy_thread_); menu_proxy_->moveToThread(proxy_thread_); search_proxy_->moveToThread(proxy_thread_); settings_proxy_->moveToThread(proxy_thread_); store_daemon_proxy_->moveToThread(proxy_thread_); account_proxy_->moveToThread(proxy_thread_); proxy_thread_->start(); } } void WebWindow::initUI() { Dtk::Widget::DThemeManager::instance()->registerWidget(this); web_view_ = new QCefWebView(); this->setCentralWidget(web_view_); image_viewer_ = new ImageViewer(this); completion_window_ = new SearchCompletionWindow(); completion_window_->hide(); title_bar_ = new TitleBar(SettingsManager::instance()->supportSignIn()); this->titlebar()->setCustomWidget(title_bar_, Qt::AlignCenter, false); this->titlebar()->setSeparatorVisible(true); tool_bar_menu_ = new TitleBarMenu(SettingsManager::instance()->supportSignIn(), this); this->titlebar()->setMenu(tool_bar_menu_); // Disable web security. auto settings = web_view_->page()->settings(); settings->setMinimumFontSize(8); settings->setWebSecurity(QCefWebSettings::StateDisabled); // init default font size settings->setDefaultFontSize(this->fontInfo().pixelSize()); web_event_delegate_ = new WebEventDelegate(this); web_view_->page()->setEventDelegate(web_event_delegate_); this->setFocusPolicy(Qt::ClickFocus); Dtk::Widget::DThemeManager::instance()->registerWidget(this->titlebar(), "DTitlebar"); } void WebWindow::initServices() { } bool WebWindow::eventFilter(QObject *watched, QEvent *event) { // Filters mouse press event only. if (event->type() == QEvent::MouseButtonPress && qApp->activeWindow() == this && watched->objectName() == QLatin1String("QMainWindowClassWindow")) { QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event); switch (mouseEvent->button()) { case Qt::BackButton: { this->webViewGoBack(); break; } case Qt::ForwardButton: { this->webViewGoForward(); break; } default: { } } } if (event->type() == QEvent::FontChange && watched == this) { if (this->settings_proxy_) { auto fontInfo = this->fontInfo(); Q_EMIT this->settings_proxy_->fontChangeRequested(fontInfo.family(), fontInfo.pixelSize()); } } return QObject::eventFilter(watched, event); } void WebWindow::resizeEvent(QResizeEvent *event) { QWidget::resizeEvent(event); title_bar_->setFixedWidth(event->size().width()); } void WebWindow::focusInEvent(QFocusEvent *event) { DMainWindow::focusInEvent(event); web_view_->setFocus(); } void WebWindow::onSearchAppResult(const SearchMetaList &result) { completion_window_->setSearchResult(result); if (result.isEmpty()) { // Hide completion window if no anchor entry matches. completion_window_->hide(); } else { completion_window_->show(); completion_window_->raise(); completion_window_->autoResize(); // Move to below of search edit. const QPoint local_point(this->rect().width() / 2 - 94, 36); const QPoint global_point(this->mapToGlobal(local_point)); completion_window_->move(global_point); completion_window_->setFocusPolicy(Qt::NoFocus); completion_window_->setFocusPolicy(Qt::StrongFocus); } } void WebWindow::onSearchEditFocusOut() { QTimer::singleShot(20, [ = ]() { this->completion_window_->hide(); }); } void WebWindow::onSearchButtonClicked() { this->prepareSearch(true); } void WebWindow::onSearchTextChangedDelay() { this->prepareSearch(false); } void WebWindow::prepareSearch(bool entered) { const QString text = title_bar_->getSearchText(); // Filters special chars. if (text.size() <= 1 || text.contains(search_re_)) { qCritical() << "Invalid regexp:" << text; return; } completion_window_->setKeyword(text); // Do real search. if (entered) { Q_EMIT search_proxy_->openAppList(text); completion_window_->hide(); } else { Q_EMIT search_proxy_->requestComplement(text); } } void WebWindow::onSearchResultClicked(const SearchMeta &result) { // Emit signal to web page. completion_window_->hide(); emit search_proxy_->openApp(result.name); } void WebWindow::onSearchTextChanged(const QString &text) { if (text.size() > 1) { search_timer_->stop(); search_timer_->start(kSearchDelay); } else { this->onSearchEditFocusOut(); } } void WebWindow::onTitleBarEntered() { const QString text = title_bar_->getSearchText(); if (text.size() > 1) { completion_window_->onEnterPressed(); } } void WebWindow::onThemeChaged(const QString theme_name) { Dtk::Widget::DThemeManager::instance()->setTheme(theme_name); title_bar_->refreshAvatar(); } void WebWindow::onWebViewUrlChanged(const QUrl &url) { Q_UNUSED(url); } void WebWindow::onLoadingStateChanged(bool, bool can_go_back, bool can_go_forward) { title_bar_->setBackwardButtonActive(can_go_back); title_bar_->setForwardButtonActive(can_go_forward); } void WebWindow::webViewGoBack() { auto page = web_view_->page(); if (page->canGoBack()) { page->back(); } } void WebWindow::webViewGoForward() { auto page = web_view_->page(); if (page->canGoForward()) { page->forward(); } } void WebWindow::onFullscreenRequest(bool fullscreen) { if (fullscreen) { this->titlebar()->hide(); this->showFullScreen(); } else { this->titlebar()->show(); this->showNormal(); } } } // namespace dstore
16,210
C++
.cpp
454
30.244493
103
0.682743
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,090
settings_proxy.cpp
martyr-deepin_deepin-appstore/src/ui/channel/settings_proxy.cpp
/* * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <QtGui/QDesktopServices> #include <QUrl> #include "ui/channel/settings_proxy.h" #include "services/settings_manager.h" namespace dstore { SettingsProxy::SettingsProxy(QObject *parent) : QObject(parent) { this->setObjectName("SettingsProxy"); } const QVariantMap SettingsProxy::getSettings() { return QVariantMap { // user settings { "themeName", SettingsManager::instance()->themeName() }, { "autoInstall", SettingsManager::instance()->autoInstall() }, { "allowShowPackageName", SettingsManager::instance()->allowShowPackageName() }, // system settings { "metadataServer", SettingsManager::instance()->metadataServer() }, { "operationServerMap", SettingsManager::instance()->operationServerMap()}, { "defaultRegion", SettingsManager::instance()->defaultRegion() }, { "allowSwitchRegion", SettingsManager::instance()->allowSwitchRegion() }, { "supportSignIn", SettingsManager::instance()->supportSignIn() }, {"supportAot", SettingsManager::instance()->supportAot()}, // Check whether UPYun banner should be shown in app-detail page. {"upyunBannerVisible", SettingsManager::instance()->upyunBannerVisible()}, // debug {"remoteDebug", SettingsManager::instance()->remoteDebug()}, }; } void SettingsProxy::setAutoInstall(bool autoInstall) { SettingsManager::instance()->setAutoInstall(autoInstall); } void SettingsProxy::openUrl(const QString &url) { QDesktopServices::openUrl(QUrl(url)); } void SettingsProxy::raiseWindow() { emit this->raiseWindowRequested(); } } // namespace dstore
2,347
C++
.cpp
59
35.847458
88
0.722955
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,091
store_daemon_proxy.cpp
martyr-deepin_deepin-appstore/src/ui/channel/store_daemon_proxy.cpp
/* * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "ui/channel/store_daemon_proxy.h" #include <QDBusPendingReply> #include "base/launcher.h" #include "dbus/dbus_consts.h" #include "dbus/lastore_job_interface.h" namespace dstore { StoreDaemonProxy::StoreDaemonProxy(QObject *parent) : QObject(parent), manager_thread_(new QThread(this)), manager_(new StoreDaemonManager()) { this->setObjectName("StoreDaemonProxy"); RegisterSearchMetaMetaType(); this->initConnections(); manager_thread_->start(); manager_->moveToThread(manager_thread_); } StoreDaemonProxy::~StoreDaemonProxy() { manager_thread_->quit(); manager_thread_->wait(3); } void StoreDaemonProxy::initConnections() { connect(manager_thread_, &QThread::finished, manager_, &StoreDaemonManager::deleteLater); connect(manager_, &StoreDaemonManager::jobListChanged, this, &StoreDaemonProxy::jobListChanged); } } // namespace dstore
1,630
C++
.cpp
47
31.468085
72
0.743312
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,092
log_proxy.cpp
martyr-deepin_deepin-appstore/src/ui/channel/log_proxy.cpp
/* * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "ui/channel/log_proxy.h" #include <QDebug> namespace dstore { LogProxy::LogProxy(QObject* parent) : QObject(parent) { this->setObjectName("LogProxy"); } LogProxy::~LogProxy() { } void LogProxy::debug(const QString& msg) { qDebug() << msg; } void LogProxy::warn(const QString& msg) { qWarning() << msg; } void LogProxy::error(const QString& msg) { qCritical() << msg; } } // namespace dstore
1,114
C++
.cpp
34
30.823529
72
0.738562
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,093
account_proxy.cpp
martyr-deepin_deepin-appstore/src/ui/channel/account_proxy.cpp
#include "account_proxy.h" #include "services/account_manager.h" namespace dstore { AccountProxy::AccountProxy(QObject *parent) : QObject(parent) { manager_ = new AccountManager(parent); connect(manager_, &AccountManager::userInfoChanged, this, &AccountProxy::userInfoChanged); } QVariantMap dstore::AccountProxy::getUserInfo() const { return manager_->getUserInfo(); } QString dstore::AccountProxy::getToken() const { return manager_->getToken(); } void dstore::AccountProxy::login() { manager_->login(); } void dstore::AccountProxy::logout() { manager_->logout(); } } // namespace dstore
634
C++
.cpp
27
20.851852
61
0.737896
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,094
search_proxy.cpp
martyr-deepin_deepin-appstore/src/ui/channel/search_proxy.cpp
/* * Copyright (C) 2018 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "ui/channel/search_proxy.h" #include <QDebug> #include <QJsonArray> #include <QJsonDocument> #include <QJsonObject> #include <QVariant> namespace dstore { SearchProxy::SearchProxy(QObject *parent) : QObject(parent) { this->setObjectName("SearchProxy"); } SearchProxy::~SearchProxy() { } void SearchProxy::setComplementList(const QVariantList &apps) { SearchMetaList result; for (auto &app : apps) { auto var = app.toMap(); SearchMeta meta; meta.name = var.value("name").toString(); meta.local_name = var.value("local_name").toString(); result.push_back(meta); } Q_EMIT searchAppResult(result); } } // namespace dstore
1,385
C++
.cpp
44
28.590909
72
0.730683
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,095
image_viewer_proxy.cpp
martyr-deepin_deepin-appstore/src/ui/channel/image_viewer_proxy.cpp
/* * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "ui/channel/image_viewer_proxy.h" #include <QDebug> #include <QPixmap> #include "base/file_util.h" namespace dstore { ImageViewerProxy::ImageViewerProxy(QObject* parent) : QObject(parent) { this->setObjectName("ImageViewerProxy"); } ImageViewerProxy::~ImageViewerProxy() { } void ImageViewerProxy::open(const QString& filepath) { emit this->openImageFileRequested(filepath); } void ImageViewerProxy::setImageList(const QStringList& urls, int current) { urls_ = urls; current_ = -1; if (current >= 0 && current < urls.length()) { current_ = current; // Notify web page to download current image. emit this->openOnlineImageRequest(urls.at(current)); } else { qWarning() << Q_FUNC_INFO << "Invalid url index:" << current << urls; } } void ImageViewerProxy::openBase64(const QString& url, const QString& data) { Q_ASSERT(current_ < urls_.length()); if (url != urls_.at(current_)) { qWarning() << Q_FUNC_INFO << "url not match," <<"expected:" << urls_.at(current_) << ", got:" << url; return; } const QByteArray img_data = QByteArray::fromBase64(data.toLocal8Bit()); QPixmap pixmap; const bool status = pixmap.loadFromData(img_data); if (status) { emit this->openPixmapRequested(pixmap); } else { qWarning() << Q_FUNC_INFO << "Failed to load pixmap:" << url; } } void ImageViewerProxy::onPreviousImageRequested() { current_ = (urls_.length() + current_ - 1) % urls_.length(); qDebug() << Q_FUNC_INFO << current_ << urls_.length(); emit this->openOnlineImageRequest(urls_.at(current_)); } void ImageViewerProxy::onNextImageRequested() { current_ = (current_ + 1) % urls_.length(); qDebug() << Q_FUNC_INFO << current_ << urls_.length(); emit this->openOnlineImageRequest(urls_.at(current_)); } } // namespace dstore
2,535
C++
.cpp
68
34.294118
76
0.702405
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,096
menu_proxy.cpp
martyr-deepin_deepin-appstore/src/ui/channel/menu_proxy.cpp
/* * Copyright (C) 2018 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "ui/channel/menu_proxy.h" #include <QDebug> namespace dstore { MenuProxy::MenuProxy(QObject *parent) : QObject(parent) { this->setObjectName("MenuProxy"); } MenuProxy::~MenuProxy() { } void MenuProxy::setUserInfo(QVariantMap info) { emit this->userInfoUpdated(info); } } // namespace dstore
1,007
C++
.cpp
32
29.46875
72
0.757764
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,097
user_menu.cpp
martyr-deepin_deepin-appstore/src/ui/widgets/user_menu.cpp
#include "user_menu.h" #include <QAction> namespace dstore { class UserMenuPrivate { public: UserMenuPrivate(UserMenu *parent) : q_ptr(parent) { userName = parent->addAction(UserMenu::tr("Username")); userName->setDisabled(true); comment = parent->addAction(UserMenu::tr("My comments")); parent->connect(comment, &QAction::triggered, parent, &UserMenu::commentRequested); Donates = parent->addAction(UserMenu::tr("My donations")); parent->connect(Donates, &QAction::triggered, parent, &UserMenu::requestDonates); apps = parent->addAction(UserMenu::tr("My apps")); parent->connect(apps, &QAction::triggered, parent, &UserMenu::requestApps); parent->addSeparator(); logout = parent->addAction(UserMenu::tr("Sign out")); parent->connect(logout, &QAction::triggered, parent, &UserMenu::requestLogout); } QAction *userName; QAction *comment; QAction *Donates; QAction *apps; QAction *logout; UserMenu *q_ptr; Q_DECLARE_PUBLIC(UserMenu) }; UserMenu::UserMenu(QWidget *parent) : QMenu(parent), dd_ptr(new UserMenuPrivate(this)) { } UserMenu::~UserMenu() { } void UserMenu::setUsername(const QString &username) { Q_D(UserMenu); d->userName->setText(username); } } // namespace dstore
1,424
C++
.cpp
45
25.133333
86
0.641758
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,098
search_edit.cpp
martyr-deepin_deepin-appstore/src/ui/widgets/search_edit.cpp
/* * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "ui/widgets/search_edit.h" #include <QKeyEvent> namespace dstore { SearchEdit::SearchEdit(QWidget* parent) : DSearchEdit(parent) { } SearchEdit::~SearchEdit() { } void SearchEdit::keyPressEvent(QKeyEvent* event) { switch (event->key()) { case Qt::Key_Up: { emit this->upKeyPressed(); break; } case Qt::Key_Down: { emit this->downKeyPressed(); break; } case Qt::Key_Enter: // Fall through case Qt::Key_Return: { emit this->enterPressed(); break; } default: { } } DSearchEdit::keyPressEvent(event); } } // namespace dstore
1,316
C++
.cpp
44
26.568182
72
0.703645
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,099
image_viewer.cpp
martyr-deepin_deepin-appstore/src/ui/widgets/image_viewer.cpp
/* * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "ui/widgets/image_viewer.h" #include <DWidgetUtil> #include <DThemeManager> #include <QApplication> #include <QDebug> #include <QPainter> #include <QPoint> #include <QResizeEvent> #include <QStackedLayout> #include <QtCore/QTimer> #include <QDesktopWidget> namespace dstore { namespace { const int kBorderSize = 12; const int kCloseBtnSize = 48; } // namespace ImageViewer::ImageViewer(QWidget* parent) : QDialog(parent) { this->setObjectName("ImageViewer"); this->initUI(); this->initConnection(); } ImageViewer::~ImageViewer() { } void ImageViewer::open(const QString& filepath) { // Escape uri. QString abspath(filepath); if (abspath.contains("://")) { QUrl url(abspath); abspath = url.path(); } const QPixmap pixmap(abspath); this->openPixmap(pixmap); } void ImageViewer::openPixmap(QPixmap pixmap) { if (!this->isVisible()) { return; } const QRect screen_rect = qApp->desktop()->screenGeometry(QCursor::pos()); const auto ratio=qApp->devicePixelRatio(); pixmap.setDevicePixelRatio(ratio); const int pixmap_max_width = static_cast<int>(screen_rect.width() * 0.8); const int pixmap_max_height = static_cast<int>(screen_rect.height() * 0.8); if ((pixmap.width() > pixmap_max_width) || (pixmap.height() > pixmap_max_height)) { pixmap = pixmap.scaled(pixmap_max_width, pixmap_max_height, Qt::KeepAspectRatio, Qt::SmoothTransformation); } this->move(screen_rect.topLeft()); this->resize(screen_rect.size()); this->showFullScreen(); // Hide spinner. spinner_->hide(); spinner_->stop(); const int button_width = static_cast<int>(screen_rect.width() * 0.1); previous_button_->setFixedWidth(button_width); next_button_->setFixedWidth(button_width); // Update pixmap of image label. img_label_->setPixmap(pixmap); img_label_->setFixedSize(pixmap.width()/ratio, pixmap.height()/ratio); QRect img_rect = img_label_->rect(); img_rect.moveTo( ((screen_rect.width() - pixmap.width()/ratio) / 2.0), ((screen_rect.height() - pixmap.height()/ratio) / 2.0)); img_label_->move(img_rect.topLeft()); // Move close button to top-right corner of image. const QPoint top_right_point = img_rect.topRight(); close_button_->move(top_right_point.x() - kCloseBtnSize / 2, top_right_point.y() - kCloseBtnSize / 2); close_button_->show(); close_button_->raise(); } void ImageViewer::showIndicator() { const QRect screen_rect = qApp->desktop()->screenGeometry(QCursor::pos()); this->move(screen_rect.topLeft()); this->resize(screen_rect.size()); this->showFullScreen(); const int button_width = static_cast<int>(screen_rect.width() * 0.1); previous_button_->setFixedWidth(button_width); next_button_->setFixedWidth(button_width); // Show spinner, moving to center of screen. spinner_->show(); spinner_->start(); spinner_->move(screen_rect.center()); // Reset pixmap of image label const QSize size = img_label_->size(); QPixmap empty_pixmap(size); empty_pixmap.fill(QColor(0, 0, 0, 1)); img_label_->setPixmap(empty_pixmap); // Hide close button close_button_->hide(); } void ImageViewer::initConnection() { connect(close_button_, &Dtk::Widget::DImageButton::clicked, this, &ImageViewer::close); connect(previous_button_, &Dtk::Widget::DImageButton::clicked, this, &ImageViewer::previousImageRequested); connect(next_button_, &Dtk::Widget::DImageButton::clicked, this, &ImageViewer::nextImageRequested); } void ImageViewer::initUI() { img_label_ = new QLabel(); img_label_->setObjectName("ImageLabel"); img_label_->setMinimumSize(640, 480); close_button_ = new Dtk::Widget::DImageButton(this); close_button_->setObjectName("CloseButton"); close_button_->raise(); previous_button_ = new Dtk::Widget::DImageButton(); previous_button_->setObjectName("PreviousButton"); next_button_ = new Dtk::Widget::DImageButton(); next_button_->setObjectName("NextButton"); spinner_ = new Dtk::Widget::DSpinner(this); spinner_->setFixedSize(96, 96); QHBoxLayout* layout = new QHBoxLayout(); layout->setContentsMargins(0, 0, 0, 0); layout->setSpacing(10); layout->addWidget(previous_button_); layout->addWidget(img_label_, 1, Qt::AlignCenter); layout->addWidget(next_button_); this->setContentsMargins(0, 0, 0, 0); this->setLayout(layout); this->setWindowFlags(Qt::FramelessWindowHint | Qt::BypassWindowManagerHint | Qt::Dialog | Qt::WindowStaysOnTopHint); this->setAttribute(Qt::WA_TranslucentBackground, true); this->setModal(true); Dtk::Widget::DThemeManager::instance()->registerWidget(this); } void ImageViewer::mousePressEvent(QMouseEvent* event) { QWidget::mousePressEvent(event); this->hide(); } void ImageViewer::paintEvent(QPaintEvent* event) { Q_UNUSED(event); QPainter painter(this); painter.fillRect(0, 0, this->width(), this->height(), QColor(0, 0, 0, 77)); } } // namespace dstore
5,804
C++
.cpp
157
33.012739
77
0.698611
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,100
title_bar.cpp
martyr-deepin_deepin-appstore/src/ui/widgets/title_bar.cpp
/* * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "ui/widgets/title_bar.h" #include <QDebug> #include <QTimer> #include <QDir> #include <QPainter> #include <QVariantMap> #include <DThemeManager> #include "ui/widgets/search_edit.h" #include "ui/widgets/user_menu.h" #include "base/consts.h" namespace dstore { TitleBar::TitleBar(bool support_sign_in, QWidget *parent) : QFrame(parent) { this->setObjectName("TitleBar"); this->initUI(support_sign_in); this->initConnections(); } TitleBar::~TitleBar() { } QString TitleBar::getSearchText() const { QString text = search_edit_->text(); return text.remove('\n').remove('\r').remove("\r\n"); } void TitleBar::setBackwardButtonActive(bool active) { back_button_->setEnabled(active); } void TitleBar::setForwardButtonActive(bool active) { forward_button_->setEnabled(active); } void TitleBar::setUserInfo(const QVariantMap &info) { user_name_ = info.value("name").toString(); auto name = info.value("nickname").toString(); if (name.isEmpty()) { name = user_name_; } user_menu_->setUsername(name); if (user_name_.isEmpty()) { avatar_button_->setObjectName("AvatarButton"); avatar_button_->setStyleSheet(this->styleSheet()); return; } QDir cache_dir(dstore::GetCacheDir()); auto avatarPath = cache_dir.filePath("avatar.png"); avatar_button_->setObjectName("AvatarButtonUser"); auto base64Data = QByteArray::fromStdString(info.value("profile_image").toString().toStdString()); auto imageData = QByteArray::fromBase64(base64Data); auto image = QImage::fromData(imageData); saveUserAvatar(image, avatarPath); auto style = QString("#AvatarButtonUser {border-image: url(%1);}").arg(avatarPath); avatar_button_->setStyleSheet(style); } void TitleBar::saveUserAvatar(const QImage &image, const QString &filePath) { QSize sz = avatar_button_->size(); QPixmap maskPixmap(sz); maskPixmap.fill(Qt::transparent); QPainterPath path; path.addEllipse(QRectF(0, 0, sz.width(), sz.height())); QPainter maskPainter(&maskPixmap); maskPainter.setRenderHint(QPainter::Antialiasing); maskPainter.setPen(QPen(Qt::white, 1)); maskPainter.fillPath(path, QBrush(Qt::white)); QPainter::CompositionMode mode = QPainter::CompositionMode_SourceIn; QImage contentImage = QImage(sz, QImage::Format_ARGB32_Premultiplied); QPainter contentPainter(&contentImage); contentPainter.setCompositionMode(QPainter::CompositionMode_Source); contentPainter.fillRect(contentImage.rect(), Qt::transparent); contentPainter.setCompositionMode(QPainter::CompositionMode_SourceOver); contentPainter.drawImage(0, 0, maskPixmap.toImage()); contentPainter.setCompositionMode(mode); contentPainter.drawImage(0, 0, image.scaled(avatar_button_->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation)); contentPainter.setCompositionMode(QPainter::CompositionMode_DestinationOver); contentPainter.end(); contentImage = contentImage.scaled(avatar_button_->size()); contentImage.save(filePath); QPixmap pixmap = QPixmap::fromImage(contentImage); // QPalette palette; // palette.setBrush(avatar_button_->backgroundRole(), // QBrush(pixmap)); avatar_button_->setFlat(true); avatar_button_->setAutoFillBackground(true); // avatar_button_->setPalette(palette); } void TitleBar::refreshAvatar() { if (user_name_.isEmpty()) { return; } QDir cache_dir(dstore::GetCacheDir()); auto avatarPath = cache_dir.filePath("avatar.png"); auto style = QString("#AvatarButtonUser {border-image: url(%1);}").arg(avatarPath); avatar_button_->setStyleSheet(style); } void TitleBar::initConnections() { connect(back_button_, &Dtk::Widget::DImageButton::clicked, this, &TitleBar::backwardButtonClicked); connect(forward_button_, &Dtk::Widget::DImageButton::clicked, this, &TitleBar::forwardButtonClicked); connect(search_edit_, &SearchEdit::textChanged, this, &TitleBar::onSearchTextChanged); connect(search_edit_, &SearchEdit::focusOut, this, &TitleBar::focusOut); connect(search_edit_, &SearchEdit::downKeyPressed, this, &TitleBar::downKeyPressed); connect(search_edit_, &SearchEdit::enterPressed, this, &TitleBar::enterPressed); connect(search_edit_, &SearchEdit::upKeyPressed, this, &TitleBar::upKeyPressed); connect(avatar_button_, &QPushButton::clicked, this, [&]() { if (user_name_.isEmpty()) { Q_EMIT loginRequested(true); } else { auto x = avatar_button_->rect().left(); auto y = avatar_button_->rect().bottom() + 10; user_menu_->popup(avatar_button_->mapToGlobal(QPoint(x, y))); } }); connect(user_menu_, &UserMenu::requestLogout, this, [&] { Q_EMIT this->loginRequested(false); }); connect(user_menu_, &UserMenu::commentRequested, this, &TitleBar::commentRequested); connect(user_menu_, &UserMenu::requestDonates, this, &TitleBar::requestDonates); connect(user_menu_, &UserMenu::requestApps, this, &TitleBar::requestApps); } void TitleBar::initUI(bool support_sign_in) { QLabel *app_icon = new QLabel(); app_icon->setObjectName("AppIcon"); app_icon->setFixedSize(26, 26); back_button_ = new Dtk::Widget::DImageButton(); back_button_->setObjectName("BackButton"); back_button_->setFixedSize(26, 26); forward_button_ = new Dtk::Widget::DImageButton(); forward_button_->setObjectName("ForwardButton"); forward_button_->setFixedSize(26, 26); avatar_button_ = new QPushButton(); avatar_button_->setObjectName("AvatarButton"); avatar_button_->setFixedSize(20, 20); avatar_button_->setContextMenuPolicy(Qt::CustomContextMenu); user_menu_ = new UserMenu(); QHBoxLayout *left_layout = new QHBoxLayout(); left_layout->setSpacing(0); left_layout->setContentsMargins(0, 0, 0, 0); left_layout->addWidget(app_icon); left_layout->addSpacing(10); left_layout->addWidget(back_button_); left_layout->addWidget(forward_button_); left_layout->addStretch(); QFrame *left_buttons = new QFrame(); left_buttons->setFixedWidth(26 + 10 + 26 + 26); left_buttons->setContentsMargins(0, 0, 0, 0); left_buttons->setLayout(left_layout); search_edit_ = new SearchEdit(); search_edit_->setObjectName("SearchEdit"); search_edit_->setFixedSize(242, 26); search_edit_->setPlaceHolder(QObject::tr("Search")); QHBoxLayout *main_layout = new QHBoxLayout(); main_layout->setSpacing(0); main_layout->setContentsMargins(0, 0, 0, 0); main_layout->addWidget(left_buttons); main_layout->addSpacing(160); main_layout->addWidget(search_edit_, 1, Qt::AlignCenter); main_layout->addWidget(avatar_button_, 0, Qt::AlignVCenter | Qt::AlignRight); main_layout->addSpacing(170); this->setLayout(main_layout); this->setAttribute(Qt::WA_TranslucentBackground, true); Dtk::Widget::DThemeManager::instance()->registerWidget(avatar_button_, "dstore--TitleBar"); Dtk::Widget::DThemeManager::instance()->registerWidget(this); if (!support_sign_in) { avatar_button_->hide(); } } void TitleBar::onSearchTextChanged() { emit this->searchTextChanged(search_edit_->text()); } } // namespace dstore
8,187
C++
.cpp
207
34.599034
102
0.696336
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,101
search_button.cpp
martyr-deepin_deepin-appstore/src/ui/widgets/search_button.cpp
/* * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "ui/widgets/search_button.h" namespace dstore { SearchButton::SearchButton(QWidget* parent) : QPushButton(parent) { } SearchButton::~SearchButton() { } void SearchButton::enterEvent(QEvent* event) { emit this->entered(); QPushButton::enterEvent(event); } } // namespace dstore
994
C++
.cpp
27
34.851852
72
0.758333
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,102
search_completion_window.cpp
martyr-deepin_deepin-appstore/src/ui/widgets/search_completion_window.cpp
/* * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "ui/widgets/search_completion_window.h" #include <QDebug> #include <QVBoxLayout> #include <DThemeManager> #include "ui/widgets/search_button.h" namespace dstore { namespace { const int kItemHeight = 25; } // namespace SearchCompletionWindow::SearchCompletionWindow(QWidget* parent) : QFrame(parent), keyword_() { this->setObjectName("SearchCompletionWindow"); this->initUI(); this->initConnections(); } SearchCompletionWindow::~SearchCompletionWindow() { } void SearchCompletionWindow::autoResize() { result_view_->setFixedHeight(model_->rowCount() * kItemHeight + 2); result_view_->setFixedWidth(this->width() - 2); search_button_->setFixedWidth(this->width() - 2); this->setFixedHeight(result_view_->height() + kItemHeight + 8 + 3); result_view_->setVisible(model_->rowCount() > 0); this->adjustSize(); result_view_->raise(); } void SearchCompletionWindow::goDown() { if (model_->rowCount() == 0) { search_button_->setChecked(true); } else { if (search_button_->isChecked()) { search_button_->setChecked(false); const QModelIndex first_idx = model_->index(0, 0); result_view_->setCurrentIndex(first_idx); } else { const int down_row = result_view_->currentIndex().row() + 1; if (down_row >= model_->rowCount()) { search_button_->setChecked(true); result_view_->setCurrentIndex(QModelIndex()); } else { const QModelIndex down_idx = model_->index(down_row, 0); result_view_->setCurrentIndex(down_idx); } } } } void SearchCompletionWindow::goUp() { if (model_->rowCount() == 0) { search_button_->setChecked(true); } else { if (search_button_->isChecked()) { search_button_->setChecked(false); // Select last item. const QModelIndex idx = model_->index(model_->rowCount() - 1, 0); result_view_->setCurrentIndex(idx); } else { const int up_row = result_view_->currentIndex().row() - 1; if (up_row < 0) { result_view_->setCurrentIndex(QModelIndex()); search_button_->setChecked(true); } else { const QModelIndex up_idx = model_->index(up_row, 0); result_view_->setCurrentIndex(up_idx); } } } } void SearchCompletionWindow::onEnterPressed() { if (search_button_->isChecked()) { emit this->searchButtonClicked(); } else { const QModelIndex idx = result_view_->currentIndex(); this->onResultListClicked(idx); } // Hide completion window whenever any items was activated. this->hide(); } void SearchCompletionWindow::setKeyword(const QString& keyword) { keyword_ = keyword; QFontMetrics metrics = search_button_->fontMetrics(); search_button_->setText( metrics.elidedText( QObject::tr("Search \"%1\" in Deepin Store").arg(keyword), Qt::ElideRight, search_button_->width() - 14)); model_->setStringList(QStringList()); } void SearchCompletionWindow::setSearchResult( const SearchMetaList& result) { result_ = result; QStringList names; for (const SearchMeta& entry : result) { names.append(entry.local_name); } model_->setStringList(names); this->autoResize(); } void SearchCompletionWindow::initConnections() { connect(result_view_, &QListView::activated, this, &SearchCompletionWindow::onResultListClicked); connect(result_view_, &QListView::entered, this, &SearchCompletionWindow::onResultListEntered); connect(result_view_, &QListView::pressed, this, &SearchCompletionWindow::onResultListClicked); connect(search_button_, &SearchButton::entered, this, &SearchCompletionWindow::onSearchButtonEntered); connect(search_button_, &QPushButton::pressed, this, &SearchCompletionWindow::searchButtonClicked); } void SearchCompletionWindow::initUI() { model_ = new QStringListModel(this); result_view_ = new QListView(); result_view_->setObjectName("ResultList"); result_view_->setModel(model_); result_view_->setMouseTracking(true); result_view_->setEditTriggers(QListView::NoEditTriggers); result_view_->setSelectionMode(QListView::SingleSelection); result_view_->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); result_view_->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); result_view_->setFocusPolicy(Qt::NoFocus); result_view_->setMinimumHeight(kItemHeight); result_view_->adjustSize(); search_button_ = new SearchButton(); search_button_->setObjectName("SearchButton"); search_button_->setCheckable(true); search_button_->setFixedHeight(25); search_button_->setText(QObject::tr("Search \"%1\" in Deepin Store")); QVBoxLayout* main_layout = new QVBoxLayout(); main_layout->setContentsMargins(0, 4, 0, 3); main_layout->setSpacing(0); main_layout->addWidget(result_view_, 0, Qt::AlignHCenter | Qt::AlignTop); main_layout->addSpacing(1); main_layout->addWidget(search_button_, 0, Qt::AlignCenter); main_layout->addSpacing(1); this->setLayout(main_layout); this->setContentsMargins(0, 0, 0, 0); this->setMinimumHeight(kItemHeight); this->setFixedWidth(242); this->setWindowFlags(Qt::FramelessWindowHint | Qt::CustomizeWindowHint | Qt::BypassWindowManagerHint); this->setAttribute(Qt::WA_NativeWindow, true); Dtk::Widget::DThemeManager::instance()->registerWidget(this); } void SearchCompletionWindow::onResultListClicked(const QModelIndex& index) { if (index.isValid()) { const int row = index.row(); emit this->resultClicked(result_.at(row)); } else { // Simulate button click event. emit this->searchButtonClicked(); } } void SearchCompletionWindow::onSearchButtonEntered() { search_button_->setChecked(true); result_view_->setCurrentIndex(QModelIndex()); } void SearchCompletionWindow::onResultListEntered(const QModelIndex& index) { result_view_->setCurrentIndex(index); search_button_->setChecked(false); } } // namespace dstore
6,677
C++
.cpp
179
33.206704
76
0.7104
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,103
title_bar_menu.cpp
martyr-deepin_deepin-appstore/src/ui/widgets/title_bar_menu.cpp
/* * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "ui/widgets/title_bar_menu.h" #include <QDebug> #include "services/settings_manager.h" namespace dstore { TitleBarMenu::TitleBarMenu(bool support_sign_in, QWidget *parent) : QMenu(parent), support_sign_in_(support_sign_in) { this->initActions(); } TitleBarMenu::~TitleBarMenu() { } void TitleBarMenu::setThemeName(QString theme_name) { theme_name_ = theme_name; SettingsManager::instance()->setThemeName(theme_name_); if (theme_name_ == "light") { switch_theme_action_->setChecked(false); } else { switch_theme_action_->setChecked(true); } } void TitleBarMenu::initActions() { if (support_sign_in_) { this->addAction(QObject::tr("Recommend App"), this, &TitleBarMenu::recommendAppRequested); } this->addAction(QObject::tr("Clear cache"), this, &TitleBarMenu::clearCacheRequested); theme_name_ = SettingsManager::instance()->themeName(); switch_theme_action_ = this->addAction(QObject::tr("Dark theme")); switch_theme_action_->setCheckable(true); connect(switch_theme_action_, &QAction::triggered, this, &TitleBarMenu::onThemeActionTriggered); this->setThemeName(theme_name_); privacy_agreement_action_ = this->addAction(QObject::tr("Privacy Policy")); connect(privacy_agreement_action_, &QAction::triggered, this, &TitleBarMenu::privacyAgreementRequested); this->addSeparator(); } void TitleBarMenu::onThemeActionTriggered() { if (theme_name_ == "light") { theme_name_ = "dark"; } else { theme_name_ = "light"; } this->setThemeName(theme_name_); emit this->switchThemeRequested(theme_name_); } } // namespace dstore
2,447
C++
.cpp
70
30.528571
79
0.698049
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,104
base64_image.cpp
martyr-deepin_deepin-appstore/src/app/base64_image.cpp
/* * Copyright (C) 2018 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <QApplication> #include <QDebug> #include <QLabel> #include "base/file_util.h" int main(int argc, char** argv) { QApplication app(argc, argv); QByteArray data; dstore::ReadRawFile("/tmp/output.img", data); qDebug() << "data: " << data; const QByteArray img_data = QByteArray::fromBase64(data); qDebug() << "img data:" << img_data; QPixmap image; const bool status = image.loadFromData(img_data); qDebug() << "status: " << status; QLabel* label = new QLabel(); label->setPixmap(image); label->show(); return app.exec(); }
1,250
C++
.cpp
35
33.4
72
0.723967
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,105
deepin_appstore.cpp
martyr-deepin_deepin-appstore/src/app/deepin_appstore.cpp
/* * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <DApplication> #include <DLog> #include <QIcon> #include <qcef_context.h> #include <qcef_web_settings.h> #include <DPlatformWindowHandle> #include "base/consts.h" #include "resources/images.h" #include "resources/theme.h" #include "services/dbus_manager.h" #include "services/settings_manager.h" #include "services/rcc_scheme_handler.h" #include "ui/web_window.h" namespace { const char kEnableDomStorageFlush[] = "--enable-aggressive-domstorage-flushing"; const char kDisableGpu[] = "--disable-gpu"; const char kEnableLogging[] = "--enable-logging"; const char kLogLevel[] = "--log-level"; } // namespace int main(int argc, char **argv) { qputenv("DXCB_FAKE_PLATFORM_NAME_XCB", "true"); QCefGlobalSettings settings; // Do not use sandbox. settings.setNoSandbox(true); if (qEnvironmentVariableIntValue("QCEF_DEBUG") == 1) { // Open http://localhost:9222 in chromium browser to see dev tools. settings.setRemoteDebug(true); settings.setLogSeverity(QCefGlobalSettings::LogSeverity::Verbose); } else { settings.setRemoteDebug(false); settings.setLogSeverity(QCefGlobalSettings::LogSeverity::Error); } // Disable GPU process. settings.addCommandLineSwitch(kDisableGpu, ""); // Enable aggressive storage commit to minimize data loss. // See public/common/content_switches.cc. settings.addCommandLineSwitch(kEnableDomStorageFlush, ""); // Set web cache folder. QDir cache_dir(dstore::GetCacheDir()); cache_dir.mkpath("."); settings.setCachePath(cache_dir.filePath("cache")); settings.setUserDataPath(cache_dir.filePath("cef-storage")); // TODO(Shaohua): Rotate console log. settings.setLogFile(cache_dir.filePath("web-console.log")); settings.addCommandLineSwitch(kEnableLogging, ""); settings.addCommandLineSwitch(kLogLevel, "0"); settings.addCommandLineSwitch("--use-views", ""); auto themName = dstore::SettingsManager::instance()->themeName(); settings.setCustomSchemeHandler(dstore::RccSchemeHandler); settings.addCustomScheme(QUrl("rcc://web")); settings.setBackgroundColor(dstore::BackgroundColor(themName)); if (QCefInit(argc, argv, settings) >= 0) { return 0; } #ifndef DSTORE_NO_DXCB Dtk::Widget::DApplication::loadDXcbPlugin(); #endif Dtk::Widget::DApplication app(argc, argv); if (!Dtk::Widget::DPlatformWindowHandle::pluginVersion().isEmpty()) { app.setAttribute(Qt::AA_DontCreateNativeWidgetSiblings, true); } app.setTheme(themName); app.setAttribute(Qt::AA_EnableHighDpiScaling, true); app.setWindowIcon(QIcon(dstore::kImageDeepinAppStore)); app.setProductIcon(QIcon(dstore::kImageDeepinAppStore)); app.setOrganizationName("deepin"); app.setOrganizationDomain("deepin.org"); app.setApplicationVersion(Dtk::Widget::DApplication::buildVersion("5.0.0.0")); app.setApplicationName(dstore::kAppName); app.loadTranslator(); app.setApplicationDisplayName(QObject::tr("Deepin Store")); app.setApplicationDescription(QObject::tr( "Deepin Store is an App Store with diverse and quality applications. " "It features popular recommendations, newly updated apps and hot topics, and supports one-click installation, " "updating and uninstalling.")); app.setApplicationAcknowledgementPage( "https://www.deepin.org/acknowledgments/deepin-appstore/"); Dtk::Core::DLogManager::registerConsoleAppender(); Dtk::Core::DLogManager::registerFileAppender(); dstore::DBusManager dbus_manager; if (dbus_manager.parseArguments()) { // Exit process after 1000ms. QTimer::singleShot(1000, [&]() { app.quit(); }); return app.exec(); } else { QCefBindApp(&app); dstore::WebWindow window; QObject::connect(&dbus_manager, &dstore::DBusManager::raiseRequested, &window, &dstore::WebWindow::raiseWindow); QObject::connect(&dbus_manager, &dstore::DBusManager::showDetailRequested, &window, &dstore::WebWindow::showAppDetail); app.installEventFilter(&window); window.setQCefSettings(&settings); window.loadPage(); window.showWindow(); return app.exec(); } }
5,102
C++
.cpp
118
37.313559
149
0.702419
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,106
test_launcher.cpp
martyr-deepin_deepin-appstore/src/app/test_launcher.cpp
/* * Copyright (C) 2018 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <QDebug> #include "base/launcher.h" int main(void) { const char kYelpFile[] = "/usr/share/applications/yelp.desktop"; const char kVlcFile[] = "/usr/share/applications/vlc.desktop"; qDebug() << dstore::GetExecFromDesktop(kYelpFile); qDebug() << dstore::GetExecFromDesktop(kVlcFile); dstore::ExecuteDesktopFile(kYelpFile); return 0; }
1,046
C++
.cpp
26
38.076923
72
0.753196
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,107
qurl_demo.cpp
martyr-deepin_deepin-appstore/src/app/qurl_demo.cpp
/* * Copyright (C) 2018 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <QDebug> #include <QUrl> int main(void) { const QUrl url("rcc://web/assets/icons/homepage.svg"); qDebug() << url.path(); return 0; }
838
C++
.cpp
23
34.478261
72
0.742015
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,108
test_image_viewer.cpp
martyr-deepin_deepin-appstore/src/app/test_image_viewer.cpp
/* * Copyright (C) 2018 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <QApplication> #include <QTimer> #include "ui/widgets/image_viewer.h" int main(int argc, char** argv) { QApplication app(argc, argv); dstore::ImageViewer* viewer = new dstore::ImageViewer(); QObject::connect(viewer, &dstore::ImageViewer::previousImageRequested, [&]() { viewer->showIndicator(); QTimer::singleShot(2000, [=]() { viewer->open("/tmp/demo2.jpg"); }); }); QObject::connect(viewer, &dstore::ImageViewer::nextImageRequested, [&]() { viewer->showIndicator(); QTimer::singleShot(2000, [=]() { viewer->open("/tmp/demo.jpg"); }); }); viewer->show(); return app.exec(); }
1,333
C++
.cpp
37
33.054054
80
0.707752
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,109
dbus_manager.cpp
martyr-deepin_deepin-appstore/src/services/dbus_manager.cpp
/* * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "services/dbus_manager.h" #include <QCommandLineParser> #include <QDebug> #include <QtDBus> #include "dbus/app_store_dbus_adapter.h" #include "dbus/app_store_dbus_interface.h" #include "dbus/dbus_consts.h" namespace dstore { DBusManager::DBusManager(QObject* parent) : QObject(parent) { } DBusManager::~DBusManager() { } bool DBusManager::parseArguments() { QCommandLineParser parser; parser.addHelpOption(); parser.addVersionOption(); parser.addOption(QCommandLineOption( "dbus", "enable daemon mode" )); parser.parse(qApp->arguments()); // Register dbus service. QDBusConnection session_bus = QDBusConnection::sessionBus(); AppStoreDBusAdapter* adapter = new AppStoreDBusAdapter(this); Q_UNUSED(adapter); if (!session_bus.registerService(kAppStoreDbusService) || !session_bus.registerObject(kAppStoreDbusPath, this)) { qWarning() << Q_FUNC_INFO << "Failed to register dbus service" << session_bus.lastError(); // Failed to register dbus service. // Open app with dbus interface. const QStringList args = parser.positionalArguments(); if (!args.isEmpty()) { AppStoreDBusInterface* interface = new AppStoreDBusInterface( kAppStoreDbusService, kAppStoreDbusPath, session_bus, this ); if (interface->isValid()) { // Only pass the first positional argument. interface->ShowAppDetail(args.first()); return true; } else { app_name_ = args.first(); return false; } } else { return true; } } else { const QStringList args = parser.positionalArguments(); if (!args.isEmpty()) { app_name_ = args.first(); } } return false; } void DBusManager::Raise() { emit this->raiseRequested(); } void DBusManager::ShowDetail(const QString& app_name) { emit this->showDetailRequested(app_name); } } // namespace dstore
2,656
C++
.cpp
81
28.481481
72
0.703284
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,110
rcc_scheme_handler.cpp
martyr-deepin_deepin-appstore/src/services/rcc_scheme_handler.cpp
/* * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "services/rcc_scheme_handler.h" #include <QDebug> #include <QFileInfo> #include <QLocale> namespace dstore { QString RccSchemeHandler(const QUrl& url) { const QString host = url.host(); if (host == "web") { const char kAppDefaultLocalDir[] = DSTORE_WEB_DIR "/appstore"; QString app_local_dir = QString("%1/appstore-%2") .arg(DSTORE_WEB_DIR) .arg(QLocale().name()); if (!QFileInfo::exists(app_local_dir)) { app_local_dir = kAppDefaultLocalDir; } QString filepath = QString("%1/%2").arg(app_local_dir).arg(url.path()); if (!QFileInfo::exists(filepath)) { filepath = QString("%1/%2").arg(app_local_dir).arg("index.html"); } return filepath; } else { // 404 not found. return ""; } } } // namespace dstore
1,490
C++
.cpp
42
32.166667
75
0.697642
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,111
store_daemon_manager.cpp
martyr-deepin_deepin-appstore/src/services/store_daemon_manager.cpp
/* * Copyright (C) 2018 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "services/store_daemon_manager.h" #include <QThread> #include "dbus/dbus_consts.h" #include "dbus/dbus_variant/app_version.h" #include "dbus/dbus_variant/installed_app_info.h" #include "dbus/dbus_variant/installed_app_timestamp.h" #include "dbus/lastore_deb_interface.h" #include "dbus/lastore_job_interface.h" #include "package/package_manager.h" #include "package/apt_package_manager.h" namespace dstore { namespace { const char kResultOk[] = "ok"; const char kResultErrName[] = "errorName"; const char kResultErrMsg[] = "errorMsg"; const char kResult[] = "result"; const char kResultName[] = "name"; bool ReadJobInfo(LastoreJobInterface &job_interface, const QString &job, QVariantMap &result) { result.insert("id", job_interface.id()); result.insert("job", job); result.insert("status", job_interface.status()); result.insert("type", job_interface.type()); result.insert("speed", job_interface.speed()); result.insert("progress", job_interface.progress()); result.insert("description", job_interface.description()); result.insert("packages", job_interface.packages()); result.insert("cancelable", job_interface.cancelable()); result.insert("downloadSize", job_interface.downloadSize()); result.insert("createTime", job_interface.createTime()); result.insert("name", job_interface.name()); QStringList app_names; // Package list may container additional language related packages. const QStringList pkgs = job_interface.packages(); if (pkgs.length() >= 1) { const QString &package_name = pkgs.at(0); auto packageID = package_name.split(":").first(); app_names.append(packageID); } result.insert("names", app_names); return (!app_names.isEmpty()); } } class StoreDaemonManagerPrivate { public: StoreDaemonManagerPrivate(StoreDaemonManager *parent) : deb_interface_(new LastoreDebInterface( kLastoreDebDbusService, kLastoreDebDbusPath, QDBusConnection::sessionBus(), parent)), q_ptr(parent) { auto aptPM = new AptPackageManager(parent); pm = new PackageManager(parent); pm->registerDpk("deb", aptPM); } void initConnections(); PackageManager *pm = nullptr; LastoreDebInterface *deb_interface_ = nullptr; QMap<QString, QString> apps; StoreDaemonManager *q_ptr; Q_DECLARE_PUBLIC(StoreDaemonManager) }; void StoreDaemonManagerPrivate::initConnections() { Q_Q(StoreDaemonManager); q->connect(deb_interface_, &LastoreDebInterface::jobListChanged, q, &StoreDaemonManager::onJobListChanged); } StoreDaemonManager::StoreDaemonManager(QObject *parent) : QObject(parent), dd_ptr(new StoreDaemonManagerPrivate(this)) { Q_D(StoreDaemonManager); this->setObjectName("StoreDaemonManager"); AppVersion::registerMetaType(); InstalledAppInfo::registerMetaType(); InstalledAppTimestamp::registerMetaType(); d->initConnections(); } StoreDaemonManager::~StoreDaemonManager() { } void StoreDaemonManager::clearArchives() { Q_D(StoreDaemonManager); d->deb_interface_->CleanArchives(); } void StoreDaemonManager::openApp(const QVariant &app) { Q_D(StoreDaemonManager); d->pm->Open(AppPackage::fromVariantMap(app.toMap())); } void StoreDaemonManager::updateAppList(const SearchMetaList &app_list) { Q_D(StoreDaemonManager); for (auto &app : app_list) { d->apps.insert(app.name, app.name); } } bool StoreDaemonManager::isDBusConnected() { Q_D(StoreDaemonManager); return d->deb_interface_->isValid(); } QVariantMap StoreDaemonManager::cleanJob(const QString &job) { LastoreJobInterface job_interface(kLastoreDebJobService, job, QDBusConnection::sessionBus(), this); if (job_interface.isValid()) { const QDBusPendingReply<> reply = job_interface.Clean(); if (reply.isError()) { return QVariantMap { { kResultOk, false }, { kResultErrName, reply.error().name() }, { kResultErrMsg, reply.error().message() }, { kResult, job} }; } else { return QVariantMap { { kResultOk, true }, { kResultErrName, "" }, { kResultErrMsg, "" }, { kResult, job} }; } } else { return QVariantMap { { kResultOk, false }, { kResultErrName, job_interface.lastError().name() }, { kResultErrMsg, job_interface.lastError().message() }, }; } } QVariantMap StoreDaemonManager::pauseJob(const QString &job) { LastoreJobInterface job_interface(kLastoreDebJobService, job, QDBusConnection::sessionBus(), this); if (job_interface.isValid()) { const QDBusPendingReply<> reply = job_interface.Pause(); if (reply.isError()) { return QVariantMap { { kResultOk, false }, { kResultErrName, reply.error().name() }, { kResultErrMsg, reply.error().message() }, { kResult, job} }; } else { return QVariantMap { { kResultOk, true }, { kResultErrName, "" }, { kResultErrMsg, "" }, { kResult, job} }; } } else { return QVariantMap { { kResultOk, false }, { kResultErrName, job_interface.lastError().name() }, { kResultErrMsg, job_interface.lastError().message() }, { kResult, QVariantMap { { kResultName, job }, } } }; } } QVariantMap StoreDaemonManager::startJob(const QString &job) { LastoreJobInterface job_interface(kLastoreDebJobService, job, QDBusConnection::sessionBus(), this); if (job_interface.isValid()) { const QDBusPendingReply<> reply = job_interface.Start(); if (reply.isError()) { return QVariantMap { { kResultOk, false }, { kResultErrName, reply.error().name() }, { kResultErrMsg, reply.error().message() }, { kResult, job} }; } else { return QVariantMap { { kResultOk, true }, { kResultErrName, "" }, { kResultErrMsg, "" }, { kResult, job} }; } } else { return QVariantMap { { kResultOk, false }, { kResultErrName, job_interface.lastError().name() }, { kResultErrMsg, job_interface.lastError().message() }, { kResult, job} }; } } QVariantMap StoreDaemonManager::installedPackages() { // TODO: filter install list Q_D(StoreDaemonManager); auto result = d->pm->ListInstalled(/*d->apps.keys()*/{}); // qDebug() << result.data; return QVariantMap { { kResultOk, result.success }, { kResultErrName, result.errName }, { kResultErrMsg, result.errMsg }, { kResult, result.data}, }; } QVariantMap StoreDaemonManager::installPackage(const QVariantList &apps) { Q_D(StoreDaemonManager); AppPackageList list; for (auto v : apps) { list.append(AppPackage::fromVariantMap(v.toMap())); } auto result = d->pm->Install(list); return QVariantMap { { kResultOk, result.success }, { kResultErrName, result.errName }, { kResultErrMsg, result.errMsg }, { kResult, result.data}, }; } QVariantMap StoreDaemonManager::updatePackage(const QVariantList &apps) { return this->installPackage(apps); } QVariantMap StoreDaemonManager::removePackage(const QVariantList &apps) { Q_D(StoreDaemonManager); AppPackageList list; for (auto v : apps) { list.append(AppPackage::fromVariantMap(v.toMap())); } auto result = d->pm->Remove(list); return QVariantMap { { kResultOk, result.success }, { kResultErrName, result.errName }, { kResultErrMsg, result.errMsg }, { kResult, result.data}, }; } QVariantMap StoreDaemonManager::jobList() { // TODO(Shaohua): List flatpak jobs. Q_D(StoreDaemonManager); const QList<QDBusObjectPath> jobs = d->deb_interface_->jobList(); QStringList paths; for (const QDBusObjectPath &job : jobs) { paths.append(job.path()); } return QVariantMap { { kResultOk, true }, { kResultErrName, "" }, { kResultErrMsg, "" }, { kResult, paths } }; } QVariantMap StoreDaemonManager::queryVersions(const QStringList &apps) { Q_D(StoreDaemonManager); auto result = d->pm->QueryVersion(apps); return QVariantMap { { kResultOk, result.success }, { kResultErrName, result.errName }, { kResultErrMsg, result.errMsg }, { kResult, result.data}, }; } QVariantMap StoreDaemonManager::query(const QVariantList &apps) { Q_D(StoreDaemonManager); AppPackageList list; for (auto v : apps) { list.append(AppPackage::fromVariantMap(v.toMap())); } auto result = d->pm->Query(list); return QVariantMap { { kResultOk, result.success }, { kResultErrName, result.errName }, { kResultErrMsg, result.errMsg }, { kResult, result.data}, }; } QVariantMap StoreDaemonManager::queryDownloadSize(const QVariantList &apps) { Q_D(StoreDaemonManager); AppPackageList list; for (auto v : apps) { list.append(AppPackage::fromVariantMap(v.toMap())); } auto result = d->pm->QueryDownloadSize(list); return QVariantMap { { kResultOk, result.success }, { kResultErrName, result.errName }, { kResultErrMsg, result.errMsg }, { kResult, result.data}, }; } QVariantMap StoreDaemonManager::getJobInfo(const QString &job) { QVariantMap result; LastoreJobInterface job_interface(kLastoreDebJobService, job, QDBusConnection::sessionBus(), this); if (job_interface.isValid()) { if (ReadJobInfo(job_interface, job, result)) { return QVariantMap { { kResultOk, true }, { kResultErrName, "" }, { kResultErrMsg, "" }, { kResult, result }, }; } else { return QVariantMap { { kResultOk, false }, { kResultErrName, "app name list is empty" }, { kResultErrMsg, "" }, { kResult, job }, }; } } else { return QVariantMap { { kResultOk, false }, { kResultErrName, "Invalid job interface" }, { kResultErrMsg, job_interface.lastError().message() }, { kResult, QVariantMap { { kResultName, job }, } }, }; } } QVariantMap StoreDaemonManager::getJobsInfo(const QStringList &jobs) { QVariantList jobs_info; for (const QString &job : jobs) { QVariantMap job_info; LastoreJobInterface job_interface(kLastoreDebJobService, job, QDBusConnection::sessionBus()); if (job_interface.isValid()) { if (ReadJobInfo(job_interface, job, job_info)) { jobs_info.append(job_info); } else { qWarning() << "Invalid app_names for job:" << job; } } } return QVariantMap { { kResultOk, true }, { kResultErrName, "" }, { kResultErrMsg, "" }, { kResult, jobs_info}, }; } void StoreDaemonManager::onJobListChanged() { Q_D(StoreDaemonManager); const QList<QDBusObjectPath> jobs = d->deb_interface_->jobList(); QStringList paths; for (const QDBusObjectPath &job : jobs) { paths.append(job.path()); } emit this->jobListChanged(paths); } QVariantMap StoreDaemonManager::fixError(const QString &error_type) { Q_D(StoreDaemonManager); const QDBusObjectPath path = d->deb_interface_->FixError(error_type); const QString job_path = path.path(); return QVariantMap { { kResultOk, (!job_path.isEmpty()) }, { kResultErrName, "" }, { kResultErrMsg, "" }, { kResult, job_path}, }; } } // namespace dstore
13,696
C++
.cpp
412
25.012136
75
0.596176
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,112
session_manager.cpp
martyr-deepin_deepin-appstore/src/services/session_manager.cpp
/* * Copyright (C) 2018 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "services/session_manager.h" #include <QThread> #include "services/dbus_manager.h" namespace dstore { SessionManager::SessionManager(QObject* parent) : QObject(parent) { this->setObjectName("SessionManager"); } SessionManager::~SessionManager() { } } // namespace dstore
979
C++
.cpp
26
35.730769
72
0.764271
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,113
search_result.cpp
martyr-deepin_deepin-appstore/src/services/search_result.cpp
/* * Copyright (C) 2018 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "services/search_result.h" #include <QtCore/QMetaType> namespace dstore { bool operator<(const SearchMeta& a, const SearchMeta& b) { return a.name < b.name; } bool operator==(const SearchMeta& a, const SearchMeta& b) { return a.name == b.name; } QDebug& operator<<(QDebug& debug, const SearchMeta& app) { debug << "App {" << "name:" << app.name << ", local_name:" << app.local_name << ", slogan:" << app.slogan << ", description:" << app.description << ", packages:" << app.package_uris << ", debs:" << app.debs; return debug; } void RegisterSearchMetaMetaType() { qRegisterMetaType<SearchMeta>("SearchMeta"); qRegisterMetaType<SearchMetaList>("SearchMetaList"); } } // namespace dstore
1,453
C++
.cpp
40
33.275
72
0.703704
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,114
account_manager.cpp
martyr-deepin_deepin-appstore/src/services/account_manager.cpp
#include "account_manager.h" #include "dbus/deepinid_interface.h" namespace dstore { namespace { const char kDeepinIDDbusService[] = "com.deepin.deepinid"; const char kDeepinIDDbusPath[] = "/com/deepin/deepinid"; } class AccountManagerPrivate { public: AccountManagerPrivate(AccountManager *parent) : q_ptr(parent) { } com::deepin::deepinid *deepinid_interface_ = nullptr; AccountManager *q_ptr; Q_DECLARE_PUBLIC(AccountManager) }; AccountManager::AccountManager(QObject *parent) : QObject(parent), dd_ptr(new AccountManagerPrivate(this)) { Q_D(AccountManager); d->deepinid_interface_ = new com::deepin::deepinid( kDeepinIDDbusService, kDeepinIDDbusPath, QDBusConnection::sessionBus(), this); auto userInfo = d->deepinid_interface_->userInfo(); // qDebug() << userInfo; connect(d->deepinid_interface_, &com::deepin::deepinid::UserInfoChanged, this, &AccountManager::userInfoChanged); // connect(d->deepinid_interface_, &com::deepin::deepinid::UserInfoChanged, // this, [&](DVariantMap userInfo) { // qDebug() << userInfo; // }); } AccountManager::~AccountManager() {} QString AccountManager::getToken() const { Q_D(const AccountManager); return d->deepinid_interface_->GetToken().value(); } QVariantMap AccountManager::getUserInfo() const { Q_D(const AccountManager); return d->deepinid_interface_->userInfo(); } void AccountManager::login() { Q_D(AccountManager); d->deepinid_interface_->Login(); } void AccountManager::logout() { Q_D(AccountManager); d->deepinid_interface_->Logout(); } } // namespace dstore
1,671
C++
.cpp
59
25
78
0.709718
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,115
settings_manager.cpp
martyr-deepin_deepin-appstore/src/services/settings_manager.cpp
/* * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "services/settings_manager.h" #include <QDebug> #include <QSettings> #include <QDBusReply> #include <QDBusInterface> #include <qcef_global_settings.h> #include "dbus/dbus_consts.h" #include "base/file_util.h" namespace dstore { namespace { const char kAutoInstall[] = "AutoInstall"; const char kThemeName[] = "ThemeName"; const char kWindowState[] = "WindowState"; const char kAllowShowPackageName[] = "AllowShowPackageName"; const char kSupportAot[] = "SupportAot"; const char kSupportSignin[] = "SupportSignIn"; const char kMetadataServer[] = "MetadataServer"; const char kOperationServerMap[] = "OperationServerMap"; const char kDefaultRegion[] = "DefaultRegion"; const char kAllowSwitchRegion[] = "AllowSwitchRegion"; const char kUpyunBannerVisible[] = "UpyunBannerVisible"; } SettingsManager::SettingsManager(QObject *parent) { settings_ifc_ = new QDBusInterface( kAppstoreDaemonService, kAppstoreDaemonSettingsPath, kAppstoreDaemonSettingsInterface, QDBusConnection::sessionBus(), parent); qDebug() << "connect" << kAppstoreDaemonInterface << settings_ifc_->isValid(); } SettingsManager::~SettingsManager() { } void SettingsManager::setQCefSettings(QCefGlobalSettings *settings) { qcef_settings_ = settings; } bool SettingsManager::remoteDebug() { return qcef_settings_->remoteDebug(); } QString SettingsManager::metadataServer() const { return getSettings(kMetadataServer).toString(); } QVariantMap SettingsManager::operationServerMap() const { return getMapSettings(kOperationServerMap); } QString SettingsManager::defaultRegion() const { return getSettings(kDefaultRegion).toString(); } bool SettingsManager::autoInstall() const { return getSettings(kAutoInstall).toBool(); } void SettingsManager::setAutoInstall(bool autoinstall) { setSettings(kAutoInstall, autoinstall); } QString SettingsManager::themeName() const { return getSettings(kThemeName).toString(); } void SettingsManager::setThemeName(const QString &themeName) const { setSettings(kThemeName, themeName); } QByteArray SettingsManager::windowState() const { auto base64str = getSettings(kWindowState).toString(); return QByteArray::fromBase64(base64str.toLatin1()); } void SettingsManager::setWindowState(QByteArray data) { setSettings(kWindowState, QString(data.toBase64())); } bool SettingsManager::supportSignIn() const { return getSettings(kSupportSignin).toBool(); } bool SettingsManager::supportAot() const { return getSettings(kSupportAot).toBool(); } bool SettingsManager::allowSwitchRegion() const { return getSettings(kAllowSwitchRegion).toBool(); } bool SettingsManager::allowShowPackageName() const { return getSettings(kAllowShowPackageName).toBool(); } bool SettingsManager::upyunBannerVisible() const { return getSettings(kUpyunBannerVisible).toBool(); } typedef QVariantMap OperationInfo; const QDBusArgument &operator>>(const QDBusArgument &argument, OperationInfo &info) { QString key; QString value; argument.beginMapEntry(); argument >> key >> value; argument.endMapEntry(); info[key] = value; return argument; } // a{ss} QVariantMap SettingsManager::getMapSettings(const QString &key) const { OperationInfo operationInfo; QDBusMessage reply = settings_ifc_->call("GetSettings", key); if (!reply.errorName().isEmpty()) { qWarning() << reply.errorName() << reply.errorMessage(); return operationInfo; } QList<QVariant> outArgs = reply.arguments(); QVariant first = outArgs.at(0); QDBusVariant dbvFirst = first.value<QDBusVariant>(); QVariant vFirst = dbvFirst.variant(); QDBusArgument dbusArgs = vFirst.value<QDBusArgument>(); dbusArgs.beginArray(); while (!dbusArgs.atEnd()) { dbusArgs >> operationInfo; } dbusArgs.endArray(); return operationInfo; } QVariant SettingsManager::getSettings(const QString &key) const { QDBusReply<QVariant> reply = settings_ifc_->call("GetSettings", key); if (reply.error().isValid()) { qWarning() << "getSettings failed" << key << reply.error(); } return reply.value(); } void SettingsManager::setSettings(const QString &key, const QVariant &value) const { QDBusReply<void> reply = settings_ifc_->call("SetSettings", key, value); if (reply.error().isValid()) { qWarning() << "setSettings failed" << key << reply.error() << value; } } } // namespace dstore
5,225
C++
.cpp
167
28.179641
82
0.749054
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,116
apt_util_worker.cpp
martyr-deepin_deepin-appstore/src/services/package/apt_util_worker.cpp
/* * Copyright (C) 2018 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "apt_util_worker.h" #include <QDebug> #include <QtDBus/QtDBus> #include "base/command.h" #include "base/launcher.h" namespace dstore { AptUtilWorker::AptUtilWorker(QObject* parent) : QObject(parent) { this->setObjectName("AptUtilWorker"); this->initConnections(); } AptUtilWorker::~AptUtilWorker() { } void AptUtilWorker::initConnections() { connect(this, &AptUtilWorker::openAppRequest, this, &AptUtilWorker::openApp); } void AptUtilWorker::openApp(const QString& app_name) { // TODO(Shaohua): Convert app_name to debPackageName. OpenApp(app_name); } void OpenApp(const QString& app_name) { QString output; if (SpawnCmd("lastore-tools", {"querydesktop", app_name}, output)) { const QString desktop_file = output.trimmed(); if(QDBusConnection::sessionBus().isConnected()) { quint32 timestamp = 0; QStringList ars; QDBusInterface manager("com.deepin.SessionManager","/com/deepin/StartManager","com.deepin.StartManager"); if(manager.isValid()){ manager.call("LaunchApp",QVariant::fromValue(desktop_file),QVariant::fromValue(timestamp),QVariant::fromValue(ars)); } } } } } // namespace dstore
1,889
C++
.cpp
51
33.784314
126
0.734392
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,117
dpk_url.cpp
martyr-deepin_deepin-appstore/src/services/package/dpk_url.cpp
/* * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "dpk_url.h" #include <QList> namespace dstore { namespace { const int kAppNameMaxLen = 64; const char kPkgDeb[] = "deb"; const char kPkgFlatPak[] = "flatpak"; enum class DpkURLValidationResult { Ok, InvalidFormat, InvalidSchemeName, InvalidPkgType, AppNameTooShort, AppNameTooLong, }; } // namespace DpkURLValidationResult IsValidDpkLink(const QString &uri) { const QStringList parts = uri.split('/'); if (parts.length() != 4) { return DpkURLValidationResult::InvalidFormat; } // Case sensitive if (parts.at(0) != "dpk:") { return DpkURLValidationResult::InvalidSchemeName; } if (!parts.at(1).isEmpty()) { return DpkURLValidationResult::InvalidFormat; } if (parts.at(2) != kPkgDeb && parts.at(2) != kPkgFlatPak) { return DpkURLValidationResult::InvalidPkgType; } if (parts.at(3).length() > kAppNameMaxLen) { return DpkURLValidationResult::AppNameTooLong; } if (parts.at(3).isEmpty()) { return DpkURLValidationResult::AppNameTooShort; } return DpkURLValidationResult::Ok; } bool DpkURI::isValid() const { return IsValidDpkLink(url) == DpkURLValidationResult::Ok; } QString DpkURI::getType() const { return type; } QString DpkURI::getID() const { return id; } DpkURI::DpkURI(const QString &dpk) { const QString schema = "dpk://"; url = dpk; url.replace(dpk.indexOf(schema), schema.size(), ""); type = url.left(url.indexOf("/")); id = url.right(url.length() - url.indexOf("/") - 1); // store dpk to url url = dpk; } } // namespace dstore
2,336
C++
.cpp
81
25.271605
72
0.699194
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,118
package_manager.cpp
martyr-deepin_deepin-appstore/src/services/package/package_manager.cpp
#include "package_manager.h" #include "dpk_url.h" #include <functional> #include <QDebug> namespace dstore { class PackageManagerPrivate { public: PackageManagerPrivate(PackageManager *parent) : q_ptr(parent) {} typedef PMResult PMHandler(const QString &, const QStringList &); typedef PMResult PMPackageHandler(const QString &, const QList<Package> &); PMResult mergeRun(const QStringList &list, std::function<PMHandler> callback) { QStringList dpks; for (auto appName : list) { dpks.append("dpk://deb/" + appName); } QMultiHash<QString, QString> ids; for (auto &packageURI : dpks) { DpkURI dpk(packageURI); ids.insert(dpk.getType(), dpk.getID()); } QVariantList pkgList; for (auto &key : pms.keys()) { auto idList = ids.values(key); auto result = callback(key, idList); auto data = result.data.toList(); pkgList.append(data); } // TODO: error handle return PMResult(true, "", "", pkgList); } QMap<QString, QVariant> mapRun(QList<Package> list, std::function<PMPackageHandler> callback) { QMultiHash<QString, QString> ids; for (auto &package : list) { ids.insert(package.dpk.getType(), package.dpk.getID()); } QMap<QString, QVariant> results; for (auto &key : pms.keys()) { auto packageList = ids.values(key); auto result = callback(key, list); auto packageMap = result.data.toMap(); for (auto k : packageMap.keys()) { results.insert(k, packageMap.value(k)); } } return results; } PMResult run(const AppPackageList &apps, std::function<PMPackageHandler> callback) { QList<Package> packages; for (const auto &v : apps) { for (auto p : v.packages) { packages.append(p); } } auto results = mapRun(packages, callback); QVariantMap appResults; for (auto v : apps) { QList<Package> packageResultList; for (auto package : v.packages) { auto packageResult = results.value(package.packageURI); packageResultList.append(Package::fromVariantMap(packageResult.toMap())); } v.packages = packageResultList; appResults.insert(v.name, v.toVariantMap()); } return PMResult::warp(appResults); } QMap<QString, PackageManagerInterface *> pms; PackageManager *q_ptr; Q_DECLARE_PUBLIC(PackageManager) }; PackageManager::PackageManager(QObject *parent) : QObject(parent), dd_ptr(new PackageManagerPrivate(this)) { } PackageManager::~PackageManager() { } void PackageManager::registerDpk(const QString &type, PackageManagerInterface *ifc) { Q_D(PackageManager); d->pms.insert(type, ifc); } void PackageManager::Open(const AppPackage &app) { Q_D(PackageManager); if (app.packages.length() < 1) { qWarning() << "app package is empty!" << app.toVariantMap(); return; } DpkURI dpk(app.packages.value(0).packageURI); auto pm = d->pms.value(dpk.getType()); if (!pm) { qWarning() << "app package manager can not find!" << app.toVariantMap(); return; } pm->Open(dpk.getID()); } PMResult PackageManager::Query(const AppPackageList &apps) { Q_D(PackageManager); return d->run(apps, [ & ](const QString & type, const QList<Package> &packages)-> PMResult { return d->pms.value(type)->Query(packages); }); } PMResult PackageManager::QueryDownloadSize(const AppPackageList &apps) { Q_D(PackageManager); return d->run(apps, [ & ](const QString & type, const QList<Package> &packages)-> PMResult { return d->pms.value(type)->QueryDownloadSize(packages); }); } PMResult PackageManager::Install(const AppPackageList &apps) { Q_D(PackageManager); QList<Package> packages; for (const auto &v : apps) { for (auto package : v.packages) { packages.append(package); qDebug() << package.packageURI << package.dpk.getID() << package.localName; } } auto results = d->mapRun(packages, [ & ](const QString & type, const QList<Package> &packages)-> PMResult { return d->pms.value(type)->Install(packages); }); QStringList paths; for (auto v : results) { paths << v.toString(); } return PMResult::warp(paths); } PMResult PackageManager::Remove(const AppPackageList &apps) { Q_D(PackageManager); QList<Package> packages; for (const auto &v : apps) { for (auto package : v.packages) { packages.append(package); qDebug() << package.packageURI << package.dpk.getID() << package.localName; } } auto results = d->mapRun(packages, [ & ](const QString & type, const QList<Package> &packages)-> PMResult { return d->pms.value(type)->Remove(packages); }); QStringList paths; for (auto v : results) { paths << v.toString(); } return PMResult::warp(paths); } PMResult PackageManager::QueryVersion(const QStringList &dpks) { Q_D(PackageManager); auto queryHandler = [ & ](const QString & key, const QStringList & idList) -> PMResult { // return d->pms.value(key)->QueryVersion(idList); Q_UNUSED(key); Q_UNUSED(idList); return PMResult::warp({}); }; return d->mergeRun(dpks, queryHandler); } PMResult PackageManager::QueryInstalledTime(const QStringList &dpks) { Q_D(PackageManager); auto queryHandler = [ & ](const QString & key, const QStringList & idList) -> PMResult { // return d->pms.value(key)->QueryInstalledTime(idList); Q_UNUSED(key); Q_UNUSED(key); Q_UNUSED(idList); return PMResult::warp({}); }; return d->mergeRun(dpks, queryHandler); } PMResult PackageManager::ListInstalled(const QStringList &packageID) { Q_D(PackageManager); auto queryHandler = [ & ](const QString & key, const QStringList & idList) -> PMResult { return d->pms.value(key)->ListInstalled(idList); }; return d->mergeRun(packageID, queryHandler); } }
6,391
C++
.cpp
190
26.8
97
0.622482
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,119
package_manager_interface.cpp
martyr-deepin_deepin-appstore/src/services/package/package_manager_interface.cpp
#include "package_manager_interface.h" namespace dstore { PackageManagerInterface::PackageManagerInterface(QObject *parent) : QObject(parent) { } AppPackage AppPackage::fromVariantMap(const QVariantMap &json) { AppPackage app; app.name = json.value("name").toString(); app.localName = json.value("localName").toString(); auto packages = json.value("packages").toList(); for (const auto &v : packages) { Package pkg; pkg.localName = app.localName; pkg.packageURI = v.toMap().value("packageURI").toString(); pkg.dpk = DpkURI(pkg.packageURI); app.packages.append(pkg); } return app; } QVariantMap AppPackage::toVariantMap() const { QVariantMap obj; obj.insert("name", name); obj.insert("localName", localName); QVariantList packagesList; for (auto p : packages) { packagesList.append(p.toVariantMap()); } obj.insert("packages", packagesList); return obj; } Package Package::fromVariantMap(const QVariantMap &obj) { Package pkg; pkg.packageURI = obj.value("packageURI").toString(); pkg.packageName = obj.value("packageName").toString(); pkg.appName = obj.value("appName").toString(); pkg.localVersion = obj.value("localVersion").toString(); pkg.remoteVersion = obj.value("remoteVersion").toString(); pkg.installedTime = static_cast<qlonglong>(obj.value("installedTime").toInt()); pkg.size = static_cast<qlonglong>(obj.value("size").toInt()); pkg.downloadSize = static_cast<qlonglong>(obj.value("downloadSize").toInt()); pkg.upgradable = obj.value("upgradable").toBool(); pkg.allLocalName = obj.value("allLocalName").toMap(); return pkg; } QVariantMap Package::toVariantMap() const { QVariantMap obj; obj.insert("packageURI", packageURI); obj.insert("packageName", packageName); obj.insert("appName", appName); obj.insert("localVersion", localVersion); obj.insert("remoteVersion", remoteVersion); obj.insert("installedTime", installedTime); obj.insert("upgradable", upgradable); obj.insert("size", size); obj.insert("downloadSize", downloadSize); obj.insert("localName", localName); obj.insert("allLocalName", allLocalName); return obj; } PMResult PMResult::warp(const QVariant &data) { return PMResult(true, "", "", data); } PMResult PMResult::dbusError(const QDBusError &err) { return PMResult(false, err.name(), err.message(), ""); } }
2,465
C++
.cpp
74
29.189189
83
0.701681
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,120
apt_package_manager.cpp
martyr-deepin_deepin-appstore/src/services/package/apt_package_manager.cpp
#include "apt_package_manager.h" #include <QEventLoop> #include <QCoreApplication> #include "base/command.h" #include "base/launcher.h" #include "dbus/dbus_consts.h" #include "dbus/dbus_variant/app_version.h" #include "dbus/dbus_variant/installed_app_info.h" #include "dbus/dbus_variant/installed_app_timestamp.h" #include "dbus/lastore_deb_interface.h" #include "dbus/lastore_job_interface.h" #include "services/store_daemon_manager.h" #include "apt_util_worker.h" namespace dstore { namespace { static QStringList getIDs(const QList<Package> &packages) { QStringList packageIDs; for (auto &package : packages) { packageIDs << package.dpk.getID(); } // qDebug() << packageIDs; return packageIDs; } } // namespace class AptPackageManagerPrivate { public: AptPackageManagerPrivate(AptPackageManager *parent) : deb_interface_(new LastoreDebInterface( kLastoreDebDbusService, kLastoreDebDbusPath, QDBusConnection::sessionBus(), parent)), q_ptr(parent) { apt_worker_ = new AptUtilWorker(); apt_worker_thread_ = new QThread(); apt_worker_thread_->start(); apt_worker_->moveToThread(apt_worker_thread_); } ~AptPackageManagerPrivate() { apt_worker_thread_->quit(); apt_worker_thread_->wait(3); } AptUtilWorker *apt_worker_ = nullptr; QThread *apt_worker_thread_ = nullptr; LastoreDebInterface *deb_interface_ = nullptr; AptPackageManager *q_ptr; Q_DECLARE_PUBLIC(AptPackageManager) }; AptPackageManager::AptPackageManager(QObject *parent) : PackageManagerInterface(parent), dd_ptr(new AptPackageManagerPrivate(this)) { } AptPackageManager::~AptPackageManager() { } PMResult AptPackageManager::Open(const QString &packageID) { Q_D(AptPackageManager); emit d->apt_worker_->openAppRequest(packageID); return PMResult::warp({}); } PMResult AptPackageManager::Query(const QList<Package> &packages) { Q_D(AptPackageManager); auto packageIDs = getIDs(packages); const QDBusPendingReply<AppVersionList> reply = d->deb_interface_->QueryVersion(packageIDs); while (!reply.isFinished()) { qApp->processEvents(); } if (reply.isError()) { qWarning() << reply.error(); return PMResult::dbusError(reply.error()); } const AppVersionList version_list = reply.value(); QMap<QString, Package> result; for (const AppVersion &version : version_list) { auto package_name = version.pkg_name; auto packageID = package_name.split(":").first(); // TODO: remove name Package pkg; pkg.packageURI = "dpk://deb/" + packageID; pkg.packageName = package_name; pkg.localVersion = version.installed_version; pkg.remoteVersion = version.remote_version; pkg.upgradable = version.upgradable; pkg.appName = packageID; result.insert(packageID, pkg); } const QDBusPendingReply<InstalledAppTimestampList> installTimeReply = d->deb_interface_->QueryInstallationTime(packageIDs); if (installTimeReply.isError()) { qDebug() << installTimeReply.error(); return PMResult::dbusError(installTimeReply.error()); } while (!installTimeReply.isFinished()) { qApp->processEvents(); } const InstalledAppTimestampList timestamp_list = installTimeReply.value(); for (const InstalledAppTimestamp &timestamp : timestamp_list) { auto package_name = timestamp.pkg_name; auto packageID = package_name.split(":").first(); auto pkg = result.value(package_name); pkg.installedTime = timestamp.timestamp; result.insert(package_name, pkg); } QVariantMap data; for (auto &p : result) { data.insert(p.packageURI, p.toVariantMap()); } return PMResult::warp(data); } PMResult AptPackageManager::QueryDownloadSize(const QList<Package> &packages) { Q_D(AptPackageManager); auto packageIDs = getIDs(packages); QMap<QString, Package> result; for (auto &packageName : packageIDs) { const QDBusPendingReply<qlonglong> sizeReply = d->deb_interface_->QueryDownloadSize(packageName); while (!sizeReply.isFinished()) { qApp->processEvents(); } if (sizeReply.isError()) { qDebug() << sizeReply.error(); return PMResult::dbusError(sizeReply.error()); } Package pkg; auto packageID = packageName.split(":").first(); pkg.packageURI = "dpk://deb/" + packageID; pkg.packageName = packageName; const qlonglong size = sizeReply.value(); pkg.size = 0; pkg.downloadSize = size; result.insert(packageName, pkg); } QVariantMap data; for (auto &p : result) { data.insert(p.packageURI, p.toVariantMap()); } // qDebug() << data; return PMResult::warp(data); } PMResult AptPackageManager::QueryVersion(const QList<Package> &packages) { Q_D(AptPackageManager); auto packageIDs = getIDs(packages); const QDBusPendingReply<AppVersionList> reply = d->deb_interface_->QueryVersion(packageIDs); while (!reply.isFinished()) { qApp->processEvents(); } if (reply.isError()) { qDebug() << reply.error(); return PMResult::dbusError(reply.error()); } const AppVersionList version_list = reply.value(); QVariantList result; for (const AppVersion &version : version_list) { auto package_name = version.pkg_name; auto packageID = package_name.split(":").first(); // TODO: remove name result.append(QVariantMap { { "dpk", "dpk://deb/" + packageID }, { "name", packageID }, { "localVersion", version.installed_version }, { "remoteVersion", version.remote_version }, { "upgradable", version.upgradable }, }); } return PMResult::warp(result); } PMResult AptPackageManager::QueryInstalledTime(const QList<Package> &packages) { Q_D(AptPackageManager); auto packageIDs = getIDs(packages); const QDBusPendingReply<InstalledAppTimestampList> reply = d->deb_interface_->QueryInstallationTime(packageIDs); if (reply.isError()) { qDebug() << reply.error(); return PMResult::dbusError(reply.error()); } const InstalledAppTimestampList timestamp_list = reply.value(); QVariantList result; for (const InstalledAppTimestamp &timestamp : timestamp_list) { auto package_name = timestamp.pkg_name; auto packageID = package_name.split(":").first(); result.append(QVariantMap { { "dpk", "dpk://deb/" + packageID }, { "app", packageID }, { "time", timestamp.timestamp }, }); } return PMResult::warp(result); } PMResult AptPackageManager::ListInstalled(const QList<QString> &/*packageIDs*/) { Q_D(AptPackageManager); // auto packageIDs = getIDs(packages); //TODO: remove // QMap<QString, int> apps; // for (auto id : packageIDs) { // apps.insert(id, 1); // } const QDBusPendingReply<InstalledAppInfoList> reply = d->deb_interface_->ListInstalled(); if (reply.isError()) { qDebug() << reply.error(); return PMResult::dbusError(reply.error()); } const InstalledAppInfoList list = reply.value(); QVariantList result; for (const InstalledAppInfo &info : list) { Package pkg; pkg.packageName = info.packageName; pkg.appName = info.appName; auto packageID = pkg.packageName.split(":").first(); pkg.localVersion = info.version; pkg.size = info.size; pkg.packageURI = "dpk://deb/" + packageID; for (auto k : info.localeNames.keys()) { pkg.allLocalName[k] = info.localeNames[k]; } pkg.installedTime = info.installationTime; // TODO: remove name // if (apps.contains(packageID)) { result.append(pkg.toVariantMap()); // qDebug() << info.pkg_name << info.size << info.version; // break; // for debug // } } return PMResult::warp(result); } PMResult AptPackageManager::Install(const QList<Package> &packages) { Q_D(AptPackageManager); QMap<QString, QVariant> result; for (auto &package : packages) { qDebug() << package.packageURI << package.dpk.getID() << package.localName; const QDBusPendingReply<QDBusObjectPath> reply = d->deb_interface_->Install(package.localName, package.dpk.getID()); while (!reply.isFinished()) { qApp->processEvents(); } if (reply.isError()) { qDebug() << reply.error(); return PMResult::dbusError(reply.error()); } result.insert(package.packageURI, reply.value().path()); } qDebug() << result; return PMResult::warp(result); } PMResult AptPackageManager::Remove(const QList<Package> &packages) { Q_D(AptPackageManager); QMap<QString, QVariant> result; for (auto &package : packages) { qDebug() << package.packageURI << package.dpk.getID() << package.localName; const QDBusPendingReply<QDBusObjectPath> reply = d->deb_interface_->Remove(package.localName, package.dpk.getID()); while (!reply.isFinished()) { qApp->processEvents(); } if (reply.isError()) { qDebug() << reply.error(); return PMResult::dbusError(reply.error()); } result.insert(package.packageURI, reply.value().path()); } qDebug() << result; return PMResult::warp(result); } }
9,835
C++
.cpp
279
28.695341
83
0.645117
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,121
chinese2pinyin.cpp
martyr-deepin_deepin-appstore/src/services/backend/chinese2pinyin.cpp
// Copyright (c) 2015 LiuLang. All rights reserved. // Use of this source is governed by General Public License that can be found // in the LICENSE file. #include "services/backend/chinese2pinyin.h" #include <QHash> #include <QRegularExpression> #include <QTextStream> #include "base/file_util.h" namespace dstore { namespace { static QHash<uint32_t, QString> dict = { }; const char kDictFile[] = ":/services/backend/pinyin.dict"; QRegularExpression g_num_reg("\\d+"); void InitDict() { if (dict.size() != 0) { return; } QString content = ReadFile(kDictFile); QTextStream stream(&content, QIODevice::ReadOnly); while (!stream.atEnd()) { const QString line = stream.readLine(); const QStringList items = line.split(QChar(':')); if (items.size() == 2) { dict.insert(static_cast<uint32_t>(items[0].toInt(nullptr, 16)), items[1]); } } } } // namespace QString Chinese2Pinyin(const QString& words) { InitDict(); QString result; for (const QChar& word : words) { const uint32_t key = static_cast<uint32_t>(word.unicode()); auto find_result = dict.find(key); if (find_result != dict.end()) { result.append(find_result.value()); } else { result.append(word); } } return result; } QString Chinese2PinyinNoSyl(const QString& words) { InitDict(); QString result; for (const QChar& word : words) { const uint32_t key = static_cast<uint32_t>(word.unicode()); auto find_result = dict.find(key); if (find_result != dict.end()) { QString value = find_result.value(); value = value.remove(g_num_reg); result.append(value); } else { result.append(word); } } // TODO(Shaohua): Remove space char. return result; } } // namespace dstore
1,771
C++
.cpp
60
25.966667
80
0.675915
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,122
command.cpp
martyr-deepin_deepin-appstore/src/base/command.cpp
/* * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "base/command.h" #include <QDebug> #include <QDir> #include <QProcess> namespace dstore { bool RunScriptFile(const QStringList& args) { Q_ASSERT(!args.isEmpty()); if (args.isEmpty()) { qCritical() << "RunScriptFile() args is empty!"; return false; } // Change working directory. const QString current_dir(QFileInfo(args.at(0)).absolutePath()); if (!QDir::setCurrent(current_dir)) { qCritical() << "Failed to change working directory:" << current_dir; return false; } // NOTE(xushaohua): If args[0] is not a script file, bash may raise // error message. return SpawnCmd("/bin/bash", args); } bool RunScriptFile(const QStringList& args, QString& output, QString& err) { Q_ASSERT(!args.isEmpty()); if (args.isEmpty()) { qCritical() << "RunScriptFile() arg is empty!"; return false; } // Change working directory. const QString current_dir(QFileInfo(args.at(0)).absolutePath()); if (!QDir::setCurrent(current_dir)) { qCritical() << "Failed to change working directory:" << current_dir; return false; } // TODO(xushaohua): Remove bash return SpawnCmd("/bin/bash", args, output, err); } bool SpawnCmd(const QString& cmd, const QStringList& args) { QProcess process; process.setProgram(cmd); process.setArguments(args); // Merge stdout and stderr of subprocess with main process. process.setProcessChannelMode(QProcess::ForwardedChannels); process.start(); // Wait for process to finish without timeout. process.waitForFinished(-1); return (process.exitStatus() == QProcess::NormalExit && process.exitCode() == 0); } bool SpawnCmd(const QString& cmd, const QStringList& args, QString& output) { QString err; return SpawnCmd(cmd, args, output, err); } bool SpawnCmd(const QString& cmd, const QStringList& args, QString& output, QString& err) { QProcess process; process.setProgram(cmd); process.setArguments(args); process.start(); // Wait for process to finish without timeout. process.waitForFinished(-1); output = process.readAllStandardOutput(); err = process.readAllStandardError(); return (process.exitStatus() == QProcess::NormalExit && process.exitCode() == 0); } } // namespace dstore
2,948
C++
.cpp
82
32.865854
77
0.721093
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
true
false
false
753,123
consts.cpp
martyr-deepin_deepin-appstore/src/base/consts.cpp
/* * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "base/consts.h" namespace dstore { const char kAppName[] = "deepin-appstore"; #ifndef NDEBUG const char kIndexPage[] = "http://localhost:4200"; #else const char kIndexPage[] = "rcc://web/index.html"; #endif // NDEBUG QString GetCacheDir() { const char kAppCacheDir[] = ".cache/deepin/deepin-appstore"; return QDir::home().absoluteFilePath(kAppCacheDir); } } // namespace dstore
1,095
C++
.cpp
29
35.896552
72
0.75
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,125
launcher.cpp
martyr-deepin_deepin-appstore/src/base/launcher.cpp
/* * Copyright (C) 2018 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "launcher.h" #include <QDebug> #include <QProcess> #include <QRegExp> #include <QSettings> namespace dstore { const QString GetExecFromDesktop(const QString& filepath) { QSettings settings(filepath, QSettings::IniFormat); settings.beginGroup("Desktop Entry"); if (settings.contains("Exec")) { QString exec = settings.value("Exec").toString(); exec.remove(QRegExp("%.")); exec.remove(QRegExp("^\"")); exec.remove(QRegExp(" *$")); return exec; } return QString(); } bool ExecuteDesktopFile(const QString& filepath) { const QString exec = GetExecFromDesktop(filepath); if (exec.isEmpty()) { qWarning() << Q_FUNC_INFO << "Failed to parse " << filepath; return false; } return QProcess::startDetached(exec); } } // namespace
1,470
C++
.cpp
43
31.651163
72
0.730661
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,126
app_store_dbus_adapter.h
martyr-deepin_deepin-appstore/src/dbus/app_store_dbus_adapter.h
/* * This file was generated by qdbusxml2cpp version 0.8 * Command line was: qdbusxml2cpp com.deepin.AppStore.xml -a app_store_dbus_adapter -c AppStoreDBusAdapter * * qdbusxml2cpp is Copyright (C) 2016 The Qt Company Ltd. * * This is an auto-generated file. * This file may have been hand-edited. Look for HAND-EDIT comments * before re-generating it. */ #ifndef APP_STORE_DBUS_ADAPTER_H #define APP_STORE_DBUS_ADAPTER_H #include <QtCore/QObject> #include <QtDBus/QtDBus> QT_BEGIN_NAMESPACE class QByteArray; template<class T> class QList; template<class Key, class Value> class QMap; class QString; class QStringList; class QVariant; QT_END_NAMESPACE /* * Adaptor class for interface com.deepin.AppStore */ class AppStoreDBusAdapter: public QDBusAbstractAdaptor { Q_OBJECT Q_CLASSINFO("D-Bus Interface", "com.deepin.AppStore") Q_CLASSINFO("D-Bus Introspection", "" " <interface name=\"com.deepin.AppStore\">\n" " <method name=\"Raise\"/>\n" " <method name=\"ShowAppDetail\">\n" " <arg direction=\"in\" type=\"s\"/>\n" " </method>\n" " </interface>\n" "") public: AppStoreDBusAdapter(QObject *parent); virtual ~AppStoreDBusAdapter(); public: // PROPERTIES public Q_SLOTS: // METHODS void Raise(); void ShowAppDetail(const QString &in0); Q_SIGNALS: // SIGNALS }; #endif
1,337
C++
.h
47
26.340426
106
0.729961
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,127
deepinid_interface.h
martyr-deepin_deepin-appstore/src/dbus/deepinid_interface.h
/* * This file was generated by qdbusxml2cpp-fix version 0.8 * Command line was: qdbusxml2cpp-fix -c deepinid -p generated/com_deepin_deepinid /home/iceyer/Develop/deepin/dde-qt-dbus-factory/xml/com.deepin.deepinid.xml * * qdbusxml2cpp-fix is Copyright (C) 2016 Deepin Technology Co., Ltd. * * This is an auto-generated file. * Do not edit! All changes made to it will be lost. */ #ifndef COM_DEEPIN_DEEPINID_H #define COM_DEEPIN_DEEPINID_H #include <QtCore/QObject> #include <QtCore/QByteArray> #include <QtCore/QList> #include <QtCore/QMap> #include <QtCore/QString> #include <QtCore/QStringList> #include <QtCore/QVariant> #include <DBusExtendedAbstractInterface> #include <QtDBus/QtDBus> typedef QVariantMap DVariantMap; /* * Proxy class for interface com.deepin.deepinid */ class __deepinidPrivate; class __deepinid : public DBusExtendedAbstractInterface { Q_OBJECT public: static inline const char *staticInterfaceName() { return "com.deepin.deepinid"; } public: explicit __deepinid(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0); ~__deepinid(); Q_PROPERTY(QString HardwareID READ hardwareID NOTIFY HardwareIDChanged) QString hardwareID(); Q_PROPERTY(QString MachineName READ machineName NOTIFY MachineNameChanged) QString machineName(); Q_PROPERTY(DVariantMap UserInfo READ userInfo NOTIFY UserInfoChanged) DVariantMap userInfo(); public Q_SLOTS: // METHODS inline QDBusPendingReply<QString> GetToken() { QList<QVariant> argumentList; return asyncCallWithArgumentList(QStringLiteral("GetToken"), argumentList); } inline QDBusPendingReply<> Login() { QList<QVariant> argumentList; return asyncCallWithArgumentList(QStringLiteral("Login"), argumentList); } inline void LoginQueued() { QList<QVariant> argumentList; CallQueued(QStringLiteral("Login"), argumentList); } inline QDBusPendingReply<> Logout() { QList<QVariant> argumentList; return asyncCallWithArgumentList(QStringLiteral("Logout"), argumentList); } inline void LogoutQueued() { QList<QVariant> argumentList; CallQueued(QStringLiteral("Logout"), argumentList); } inline QDBusPendingReply<> SetToken(DVariantMap in0) { QList<QVariant> argumentList; argumentList << QVariant::fromValue(in0); return asyncCallWithArgumentList(QStringLiteral("SetToken"), argumentList); } inline void SetTokenQueued(DVariantMap in0) { QList<QVariant> argumentList; argumentList << QVariant::fromValue(in0); CallQueued(QStringLiteral("SetToken"), argumentList); } Q_SIGNALS: // SIGNALS // begin property changed signals void HardwareIDChanged(const QString & value) const; void MachineNameChanged(const QString & value) const; void UserInfoChanged(DVariantMap value) const; public Q_SLOTS: void CallQueued(const QString &callName, const QList<QVariant> &args); private Q_SLOTS: void onPendingCallFinished(QDBusPendingCallWatcher *w); void onPropertyChanged(const QString &propName, const QVariant &value); private: __deepinidPrivate *d_ptr; }; namespace com { namespace deepin { typedef ::__deepinid deepinid; } } #endif
3,359
C++
.h
97
30.14433
158
0.742415
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,128
dbus_extended_abstract_interface.h
martyr-deepin_deepin-appstore/src/dbus/dbus_extended_abstract_interface.h
/* * Copyright (C) 2018 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef DEEPIN_APPSTORE_DBUS_DBUS_EXTENDED_ABSTRACT_INTERFACE_H #define DEEPIN_APPSTORE_DBUS_DBUS_EXTENDED_ABSTRACT_INTERFACE_H #include <QDBusAbstractInterface> /** * Extend qt dbus abstract interface to implements PropertiesChanged() * Subclass needs to statement its own signal names. */ class DbusExtendedAbstractInterface : public QDBusAbstractInterface { Q_OBJECT public: DbusExtendedAbstractInterface(const QString& service, const QString& path, const char* interface, const QDBusConnection& connection, QObject* parent); ~DbusExtendedAbstractInterface(); private slots: void propertyChanged(const QDBusMessage& msg); }; #endif // DEEPIN_APPSTORE_DBUS_DBUS_EXTENDED_ABSTRACT_INTERFACE_H
1,531
C++
.h
36
37.027778
72
0.723976
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,129
lastore_job_interface.h
martyr-deepin_deepin-appstore/src/dbus/lastore_job_interface.h
/* * This file was generated by qdbusxml2cpp version 0.8 * Command line was: qdbusxml2cpp com.deepin.AppStore.Backend.Job.xml -p lastore_job_interface -c LastoreJobInterface -N * * qdbusxml2cpp is Copyright (C) 2016 The Qt Company Ltd. * * This is an auto-generated file. * Do not edit! All changes made to it will be lost. */ #ifndef LASTORE_JOB_INTERFACE_H #define LASTORE_JOB_INTERFACE_H #include <QtCore/QObject> #include <QtCore/QByteArray> #include <QtCore/QList> #include <QtCore/QMap> #include <QtCore/QString> #include <QtCore/QStringList> #include <QtCore/QVariant> #include <QtDBus/QtDBus> /* * Proxy class for interface com.deepin.AppStore.Backend.Job */ class LastoreJobInterface: public QDBusAbstractInterface { Q_OBJECT public: static inline const char *staticInterfaceName() { return "com.deepin.AppStore.Backend.Deb.Job"; } public: LastoreJobInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0); ~LastoreJobInterface(); Q_PROPERTY(bool Cancelable READ cancelable) inline bool cancelable() const { return qvariant_cast< bool >(property("Cancelable")); } Q_PROPERTY(qlonglong CreateTime READ createTime) inline qlonglong createTime() const { return qvariant_cast< qlonglong >(property("CreateTime")); } Q_PROPERTY(QString Description READ description) inline QString description() const { return qvariant_cast< QString >(property("Description")); } Q_PROPERTY(qlonglong DownloadSize READ downloadSize) inline qlonglong downloadSize() const { return qvariant_cast< qlonglong >(property("DownloadSize")); } Q_PROPERTY(QString Id READ id) inline QString id() const { return qvariant_cast< QString >(property("Id")); } Q_PROPERTY(QString Name READ name) inline QString name() const { return qvariant_cast< QString >(property("Name")); } Q_PROPERTY(QStringList Packages READ packages) inline QStringList packages() const { return qvariant_cast< QStringList >(property("Packages")); } Q_PROPERTY(double Progress READ progress) inline double progress() const { return qvariant_cast< double >(property("Progress")); } Q_PROPERTY(qlonglong Speed READ speed) inline qlonglong speed() const { return qvariant_cast< qlonglong >(property("Speed")); } Q_PROPERTY(QString Status READ status) inline QString status() const { return qvariant_cast< QString >(property("Status")); } Q_PROPERTY(QString Type READ type) inline QString type() const { return qvariant_cast< QString >(property("Type")); } public Q_SLOTS: // METHODS inline QDBusPendingReply<> Clean() { QList<QVariant> argumentList; return asyncCallWithArgumentList(QStringLiteral("Clean"), argumentList); } inline QDBusPendingReply<> Pause() { QList<QVariant> argumentList; return asyncCallWithArgumentList(QStringLiteral("Pause"), argumentList); } inline QDBusPendingReply<> Start() { QList<QVariant> argumentList; return asyncCallWithArgumentList(QStringLiteral("Start"), argumentList); } Q_SIGNALS: // SIGNALS }; #endif
3,207
C++
.h
83
34.421687
125
0.733161
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,130
dbus_consts.h
martyr-deepin_deepin-appstore/src/dbus/dbus_consts.h
/* * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef DEEPIN_APPSTORE_DBUS_DBUS_CONSTS_H #define DEEPIN_APPSTORE_DBUS_DBUS_CONSTS_H namespace dstore { extern const char kAppStoreDbusPath[]; extern const char kAppStoreDbusService[]; extern const char kAppstoreDaemonService[]; extern const char kAppstoreDaemonPath[]; extern const char kAppstoreDaemonInterface[]; extern const char kAppstoreDaemonSettingsPath[]; extern const char kAppstoreDaemonSettingsInterface[]; extern const char kLastoreDebDbusPath[]; extern const char kLastoreDebDbusService[]; extern const char kLastoreDebJobService[]; } // namespace dstore #endif // DEEPIN_APPSTORE_DBUS_DBUS_CONSTS_H
1,322
C++
.h
31
40.870968
72
0.795632
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,132
lastore_deb_interface.h
martyr-deepin_deepin-appstore/src/dbus/lastore_deb_interface.h
/* * This file was generated by qdbusxml2cpp version 0.8 * Command line was: qdbusxml2cpp com.deepin.AppStore.Backend.Deb.xml -p lastore_deb_interface -i dbus/dbus_variant/app_version.h -i dbus/dbus_variant/installed_app_info.h -i dbus/dbus_variant/installed_app_timestamp.h -i dbus/dbus_extended_abstract_interface.h -c LastoreDebInterface -l DbusExtendedAbstractInterface -N * * qdbusxml2cpp is Copyright (C) 2016 The Qt Company Ltd. * * This is an auto-generated file. * Do not edit! All changes made to it will be lost. */ #ifndef LASTORE_DEB_INTERFACE_H #define LASTORE_DEB_INTERFACE_H #include <QtCore/QObject> #include <QtCore/QByteArray> #include <QtCore/QList> #include <QtCore/QMap> #include <QtCore/QString> #include <QtCore/QStringList> #include <QtCore/QVariant> #include <QtDBus/QtDBus> #include "dbus/dbus_variant/app_version.h" #include "dbus/dbus_variant/installed_app_info.h" #include "dbus/dbus_variant/installed_app_timestamp.h" #include "dbus/dbus_extended_abstract_interface.h" /* * Proxy class for interface com.deepin.AppStore.Backend */ class LastoreDebInterface: public DbusExtendedAbstractInterface { Q_OBJECT public: static inline const char *staticInterfaceName() { return "com.deepin.AppStore.Backend.Deb"; } public: LastoreDebInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0); ~LastoreDebInterface(); Q_PROPERTY(QList<QDBusObjectPath> JobList READ jobList NOTIFY jobListChanged) inline QList<QDBusObjectPath> jobList() const { return qvariant_cast< QList<QDBusObjectPath> >(property("JobList")); } public Q_SLOTS: // METHODS inline QDBusPendingReply<> CleanArchives() { QList<QVariant> argumentList; return asyncCallWithArgumentList(QStringLiteral("CleanArchives"), argumentList); } inline QDBusPendingReply<QDBusObjectPath> FixError(const QString &errType) { QList<QVariant> argumentList; argumentList << QVariant::fromValue(errType); return asyncCallWithArgumentList(QStringLiteral("FixError"), argumentList); } inline QDBusPendingReply<QDBusObjectPath> Install(const QString &localName, const QString &id) { QList<QVariant> argumentList; argumentList << QVariant::fromValue(localName) << QVariant::fromValue(id); return asyncCallWithArgumentList(QStringLiteral("Install"), argumentList); } inline QDBusPendingReply<InstalledAppInfoList> ListInstalled() { QList<QVariant> argumentList; return asyncCallWithArgumentList(QStringLiteral("ListInstalled"), argumentList); } inline QDBusPendingReply<qlonglong> QueryDownloadSize(const QString &id) { QList<QVariant> argumentList; argumentList << QVariant::fromValue(id); return asyncCallWithArgumentList(QStringLiteral("QueryDownloadSize"), argumentList); } inline QDBusPendingReply<InstalledAppTimestampList> QueryInstallationTime(const QStringList &idList) { QList<QVariant> argumentList; argumentList << QVariant::fromValue(idList); return asyncCallWithArgumentList(QStringLiteral("QueryInstallationTime"), argumentList); } inline QDBusPendingReply<AppVersionList> QueryVersion(const QStringList &idList) { QList<QVariant> argumentList; argumentList << QVariant::fromValue(idList); return asyncCallWithArgumentList(QStringLiteral("QueryVersion"), argumentList); } inline QDBusPendingReply<QDBusObjectPath> Remove(const QString &localName, const QString &id) { QList<QVariant> argumentList; argumentList << QVariant::fromValue(localName) << QVariant::fromValue(id); return asyncCallWithArgumentList(QStringLiteral("Remove"), argumentList); } Q_SIGNALS: // SIGNALS void jobListChanged(); }; #endif
3,871
C++
.h
89
38.741573
320
0.757568
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,133
app_metadata.h
martyr-deepin_deepin-appstore/src/dbus/dbus_variant/app_metadata.h
/* * Copyright (C) 2018 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef DEEPIN_APPSTORE_DBUS_DBUS_VARIANT_APP_METADATA_H #define DEEPIN_APPSTORE_DBUS_DBUS_VARIANT_APP_METADATA_H #include <QDBusArgument> #include <QDebug> #include <QList> #include <QString> #include <QVariant> struct AppMetadata { public: AppMetadata(); AppMetadata(const QString& name_, const QString& icon_, const QString& category_) : name(name_), icon(icon_), category(category_) { }; ~AppMetadata(); static void registerMetaType(); inline bool operator==(const AppMetadata& other) const { return this->name == other.name; } AppMetadata& operator=(const AppMetadata& other); friend QDebug operator<<(QDebug debug, const AppMetadata& info); friend QDBusArgument& operator<<(QDBusArgument& argument, const AppMetadata& info); friend QDataStream& operator<<(QDataStream& stream, const AppMetadata& info); friend const QDBusArgument& operator>>(const QDBusArgument& argument, AppMetadata& info); friend const QDataStream& operator>>(QDataStream& stream, AppMetadata& info); QString name; QString icon; QString category; }; Q_DECLARE_METATYPE(AppMetadata); #endif // DEEPIN_APPSTORE_DBUS_DBUS_VARIANT_APP_METADATA_H
2,051
C++
.h
53
32.830189
72
0.692153
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,134
installed_app_info.h
martyr-deepin_deepin-appstore/src/dbus/dbus_variant/installed_app_info.h
/* * Copyright (C) 2018 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef DEEPIN_APPSTORE_DBUS_DBUS_VARIANT_INSTALLED_APP_INFO_H #define DEEPIN_APPSTORE_DBUS_DBUS_VARIANT_INSTALLED_APP_INFO_H #include <QDBusArgument> #include <QDebug> #include <QList> #include <QMap> #include <QString> #include <QVariant> struct InstalledAppInfo { public: InstalledAppInfo(); ~InstalledAppInfo(); static void registerMetaType(); inline bool operator==(const InstalledAppInfo &other) const { return this->packageName == other.packageName; } friend QDebug operator<<(QDebug debug, const InstalledAppInfo &info); friend QDBusArgument &operator<<(QDBusArgument &argument, const InstalledAppInfo &info); friend QDataStream &operator<<(QDataStream &stream, const InstalledAppInfo &info); friend const QDBusArgument &operator>>(const QDBusArgument &argument, InstalledAppInfo &info); friend const QDataStream &operator>>(QDataStream &stream, InstalledAppInfo &info); QString packageName; QString appName; QString version; qint64 size; qint64 installationTime; QMap<QString, QString>localeNames; }; typedef QList<InstalledAppInfo> InstalledAppInfoList; Q_DECLARE_METATYPE(InstalledAppInfo); Q_DECLARE_METATYPE(InstalledAppInfoList); #endif // DEEPIN_APPSTORE_DBUS_DBUS_VARIANT_INSTALLED_APP_INFO_H
2,140
C++
.h
53
34.54717
73
0.714629
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,135
app_version.h
martyr-deepin_deepin-appstore/src/dbus/dbus_variant/app_version.h
/* * Copyright (C) 2018 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef DEEPIN_APPSTORE_DBUS_DBUS_VARIANT_APP_VERSION_H #define DEEPIN_APPSTORE_DBUS_DBUS_VARIANT_APP_VERSION_H #include <QDBusArgument> #include <QDebug> #include <QList> #include <QString> #include <QVariant> struct AppVersion { public: AppVersion(); ~AppVersion(); static void registerMetaType(); inline bool operator==(const AppVersion& other) const { return this->pkg_name == other.pkg_name; } friend QDebug operator<<(QDebug debug, const AppVersion& info); friend QDBusArgument& operator<<(QDBusArgument& argument, const AppVersion& info); friend QDataStream& operator<<(QDataStream& stream, const AppVersion& info); friend const QDBusArgument& operator>>(const QDBusArgument& argument, AppVersion& info); friend const QDataStream& operator>>(QDataStream& stream, AppVersion& info); QString pkg_name; QString installed_version; QString remote_version; bool upgradable; }; typedef QList<AppVersion> AppVersionList; Q_DECLARE_METATYPE(AppVersion); Q_DECLARE_METATYPE(AppVersionList); #endif // DEEPIN_APPSTORE_DBUS_DBUS_VARIANT_APP_VERSION_H
1,926
C++
.h
49
34.122449
72
0.714133
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,136
installed_app_timestamp.h
martyr-deepin_deepin-appstore/src/dbus/dbus_variant/installed_app_timestamp.h
/* * Copyright (C) 2018 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef DEEPIN_APPSTORE_DBUS_DBUS_VARIANT_INSTALLED_APP_TIMESTAMP_H #define DEEPIN_APPSTORE_DBUS_DBUS_VARIANT_INSTALLED_APP_TIMESTAMP_H #include <QDBusArgument> #include <QDebug> #include <QList> #include <QString> #include <QVariant> struct InstalledAppTimestamp { public: InstalledAppTimestamp(); ~InstalledAppTimestamp(); static void registerMetaType(); inline bool operator==(const InstalledAppTimestamp& other) const { return this->pkg_name == other.pkg_name; } friend QDebug operator<<(QDebug debug, const InstalledAppTimestamp& info); friend QDBusArgument& operator<<(QDBusArgument& argument, const InstalledAppTimestamp& info); friend QDataStream& operator<<(QDataStream& stream, const InstalledAppTimestamp& info); friend const QDBusArgument& operator>>(const QDBusArgument& argument, InstalledAppTimestamp& info); friend const QDataStream& operator>>(QDataStream& stream, InstalledAppTimestamp& info); QString pkg_name; qlonglong timestamp; }; typedef QList<InstalledAppTimestamp> InstalledAppTimestampList; Q_DECLARE_METATYPE(InstalledAppTimestamp); Q_DECLARE_METATYPE(InstalledAppTimestampList); #endif // DEEPIN_APPSTORE_DBUS_DBUS_VARIANT_INSTALLED_APP_TIMESTAMP_H
2,054
C++
.h
47
38.425532
76
0.736236
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,137
images.h
martyr-deepin_deepin-appstore/src/resources/images.h
/* * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef DEEPIN_APPSTORE_RESOURCES_IMAGES_H #define DEEPIN_APPSTORE_RESOURCES_IMAGES_H namespace dstore { extern const char* const kImageDeepinAppStore; } // namespace store #endif // DEEPIN_APPSTORE_RESOURCES_IMAGES_H
921
C++
.h
22
39.954545
72
0.770694
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,138
theme.h
martyr-deepin_deepin-appstore/src/resources/theme.h
/* * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef DEEPIN_APPSTORE_RESOURCES_THEME_H #define DEEPIN_APPSTORE_RESOURCES_THEME_H #include <QString> namespace dstore { unsigned int BackgroundColor(const QString& theme); } // namespace store #endif // DEEPIN_APPSTORE_RESOURCES_THEME_H
943
C++
.h
23
39.086957
72
0.769147
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,139
web_event_delegate.h
martyr-deepin_deepin-appstore/src/ui/web_event_delegate.h
/* * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef DEEPIN_APPSTORE_UI_WEB_EVENT_DELEGATE_H #define DEEPIN_APPSTORE_UI_WEB_EVENT_DELEGATE_H #include <qcef_browser_event_delegate.h> #include <QObject> namespace dstore { class WebEventDelegate : public QObject, public QCefBrowserEventDelegate { public: explicit WebEventDelegate(QObject* parent = nullptr); ~WebEventDelegate() override; bool onBeforeBrowse(const QUrl& url, bool is_redirect) override; void onBeforeContextMenu(QCefWebPage* web_page, QCefContextMenu* menu, const QCefContextMenuParams& params) override; bool onBeforePopup(const QUrl& url, QCefWindowOpenDisposition disposition) override; }; } // namespace dstore #endif // DEEPIN_APPSTORE_UI_WEB_EVENT_DELEGATE_H
1,476
C++
.h
34
39.235294
73
0.74529
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,140
web_window.h
martyr-deepin_deepin-appstore/src/ui/web_window.h
/* * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef DEEPIN_APPSTORE_UI_WEB_WINDOW_H #define DEEPIN_APPSTORE_UI_WEB_WINDOW_H #include <QAction> #include <DMainWindow> #include <QMenu> #include <QRegularExpression> class QCefWebView; class QCefGlobalSettings; class QTimer; #include "services/search_result.h" namespace dstore { class ImageViewer; class ImageViewerProxy; class LogProxy; class MenuProxy; class SearchCompletionWindow; class SearchProxy; class SettingsProxy; class StoreDaemonProxy; class AccountProxy; class TitleBar; class TitleBarMenu; class WebEventDelegate; /** * Main window of app store. */ class WebWindow : public Dtk::Widget::DMainWindow { Q_OBJECT public: explicit WebWindow(QWidget* parent = nullptr); ~WebWindow() override; void setQCefSettings(QCefGlobalSettings *settings); /** * Load app store main web page. */ void loadPage(); void showWindow(); bool eventFilter(QObject* watched, QEvent* event) override; public slots: void raiseWindow(); void showAppDetail(const QString& app_name); protected: // Update width of title bar when main window is resized. void resizeEvent(QResizeEvent* event) override; void focusInEvent(QFocusEvent *event) override; private: void initConnections(); void initUI(); void initProxy(); void initServices(); void prepareSearch(bool entered); QCefWebView* web_view_ = nullptr; ImageViewer* image_viewer_ = nullptr; ImageViewerProxy* image_viewer_proxy_ = nullptr; LogProxy* log_proxy_ = nullptr; MenuProxy* menu_proxy_ = nullptr; SearchCompletionWindow* completion_window_ = nullptr; SearchProxy* search_proxy_ = nullptr; AccountProxy* account_proxy_ = nullptr; QTimer* search_timer_ = nullptr; QThread* proxy_thread_ = nullptr; SettingsProxy* settings_proxy_ = nullptr; StoreDaemonProxy* store_daemon_proxy_ = nullptr; TitleBar* title_bar_ = nullptr; WebEventDelegate* web_event_delegate_ = nullptr; TitleBarMenu* tool_bar_menu_ = nullptr; QRegularExpression search_re_; private slots: void onSearchAppResult(const SearchMetaList& result); void onSearchEditFocusOut(); void onSearchButtonClicked(); void onSearchResultClicked(const SearchMeta& result); void onSearchTextChanged(const QString& text); void onSearchTextChangedDelay(); void onTitleBarEntered(); void onThemeChaged(const QString theme_name); void onWebViewUrlChanged(const QUrl& url); void onFullscreenRequest(bool fullscreen); void onLoadingStateChanged(bool is_loading, bool can_go_back, bool can_go_forward); void webViewGoBack(); void webViewGoForward(); }; } // namespace dstore #endif // DEEPIN_APPSTORE_UI_WEB_WINDOW_H
3,390
C++
.h
102
30.264706
72
0.764004
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,141
account_proxy.h
martyr-deepin_deepin-appstore/src/ui/channel/account_proxy.h
#pragma once #include <QObject> #include <QVariantMap> namespace dstore { class AccountManager; class AccountProxy : public QObject { Q_OBJECT public: explicit AccountProxy(QObject *parent = Q_NULLPTR); Q_SIGNALS: void userInfoChanged(const QVariantMap &info); public Q_SLOTS: QVariantMap getUserInfo() const; QString getToken() const; void login(); void logout(); private: AccountManager *manager_; }; } // namespace dstore
466
C++
.h
22
18.318182
55
0.754023
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,142
channel_proxy.h
martyr-deepin_deepin-appstore/src/ui/channel/channel_proxy.h
#include <QObject> #include <QWebChannelAbstractTransport> #include <QJsonDocument> #include <QJsonObject> namespace dstore { /** * This proxy object is used by web page to write log messages to local * log file. */ class ChannelTransport : public QWebChannelAbstractTransport{ Q_OBJECT public: ChannelTransport(QObject *parent): QWebChannelAbstractTransport(parent) { } signals: void sendMessageString(const QString &msg); public slots: void sendMessage(const QJsonObject &msg){ QJsonDocument doc(msg); emit this->sendMessageString(doc.toJson()); } }; class ChannelProxy : public QObject { Q_OBJECT public: ChannelTransport *transport = new ChannelTransport(this); ChannelProxy(QObject *parent): QObject(parent) { connect(this->transport,&ChannelTransport::sendMessageString,this,&ChannelProxy::message); } signals: void message(const QString &msgData); public slots: void send(const QString &msgData){ auto doc = QJsonDocument::fromJson(msgData.toUtf8()); if( doc.isObject() ){ emit this->transport->messageReceived(doc.object(), this->transport); } } }; } // namespace dstore
1,182
C++
.h
40
26
94
0.738556
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,143
store_daemon_proxy.h
martyr-deepin_deepin-appstore/src/ui/channel/store_daemon_proxy.h
/* * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef DEEPIN_APPSTORE_UI_STORE_DAEMON_PROXY_H #define DEEPIN_APPSTORE_UI_STORE_DAEMON_PROXY_H #include <QDebug> #include <QObject> #include <QThread> #include <QVariantMap> #include <QJsonArray> #include "services/search_result.h" #include "services/store_daemon_manager.h" namespace dstore { class StoreDaemonProxy : public QObject { Q_OBJECT public: explicit StoreDaemonProxy(QObject *parent = nullptr); ~StoreDaemonProxy() override; Q_SIGNALS: // void isDbusConnectedReply(bool state); /** * Emitted when apt-get clean is called. */ void clearArchives(); /** * Emitted when JobList property changed. * @param jobs */ void jobListChanged(const QStringList &jobs); public Q_SLOTS: /** * Check connecting to backend app store daemon or not. */ bool isDBusConnected() { return manager_->isDBusConnected(); } // Store Manager methods: /** * Query application version information. * @param apps */ QVariantMap query(const QVariantList &apps) { return manager_->query(apps); } /** * Get deb package size * @param app_name */ QVariantMap queryDownloadSize(const QVariantList &apps) { return manager_->queryDownloadSize(apps); } /** * Get a list of installed packages. */ QVariantMap installedPackages() { return manager_->installedPackages(); } /** * Request to open installed application. * @param app_name */ void openApp(const QVariant &app) { return manager_->openApp(app); } /** * apt-get install xxx, to install or upgrade a program. * @param app_name * @param app_local_name App local name is used by lastore daemon */ QVariantMap installPackages(const QVariantList &apps) { return manager_->installPackage(apps); } /** * apt-get upgrade xxx * @param app_name */ QVariantMap updatePackages(const QVariantList &apps) { return manager_->updatePackage(apps); } /** * apt-get remove xxx * @param app_name */ QVariantMap removePackages(const QVariantList &apps) { return manager_->removePackage(apps); } /** * Returns all of jobs existing in backend. * @return stringList */ QVariantMap jobList() { return manager_->jobList(); } /** * Get temporary job info. * * valid: bool, false if this job is invalid. * * id: string * * name: string * * status: string * * type: string * * speed: int64 * * progress: double * * description: string * * cancelable: boolean * * packages: stringList */ QVariantMap getJobInfo(const QString &job) { return manager_->getJobInfo(job); } QVariantMap getJobsInfo(const QStringList &jobs) { return manager_->getJobsInfo(jobs); } /** * Clean up a specific job. * @param job */ QVariantMap cleanJob(const QString &job) { return manager_->cleanJob(job); } /** * Pause a running job * @param job */ QVariantMap pauseJob(const QString &job) { return manager_->pauseJob(job); } /** * Resume a paused job * @param job */ QVariantMap startJob(const QString &job) { return manager_->startJob(job); } /** * Try to fix installation error. */ QVariantMap fixError(const QString &error_type) { return manager_->fixError(error_type); } QString test() { QThread::sleep(3); return "this is test"; } // TODO: just for search void updateAppList(const SearchMetaList &app_list) { return manager_->updateAppList(app_list); } private: void initConnections(); QThread *manager_thread_ = nullptr; StoreDaemonManager *manager_ = nullptr; }; } // namespace dstore #endif // DEEPIN_APPSTORE_UI_STORE_DAEMON_PROXY_H
4,768
C++
.h
186
20.505376
72
0.644112
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,144
image_viewer_proxy.h
martyr-deepin_deepin-appstore/src/ui/channel/image_viewer_proxy.h
/* * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef DEEPIN_APPSTORE_UI_IMAGE_VIEWER_PROXY_H #define DEEPIN_APPSTORE_UI_IMAGE_VIEWER_PROXY_H #include <QObject> namespace dstore { // Image viewer controller class ImageViewerProxy : public QObject { Q_OBJECT public: explicit ImageViewerProxy(QObject* parent = nullptr); ~ImageViewerProxy() override; signals: void openImageFileRequested(const QString& filepath); void openPixmapRequested(const QPixmap& pixmap); /** * Request to open online image file. * Call |openBase64| to send response. * @param url Image url */ void openOnlineImageRequest(const QString& url); public slots: /** * Open image in viewer window. * @param filepath Absolute path to image file. */ void open(const QString& filepath); /** * Update image url list. * Call this method * @param urls * @param current Index of image to be open. */ void setImageList(const QStringList& urls, int current); /** * Open base64-encoded image data. * @param url Image url * @param data Base64-encoded image content */ void openBase64(const QString& url, const QString& data); void onPreviousImageRequested(); void onNextImageRequested(); private: QStringList urls_; int current_; }; } // namespace dstore #endif // DEEPIN_APPSTORE_UI_IMAGE_VIEWER_PROXY_H
2,013
C++
.h
62
29.612903
72
0.742385
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,145
menu_proxy.h
martyr-deepin_deepin-appstore/src/ui/channel/menu_proxy.h
/* * Copyright (C) 2018 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef DEEPIN_APPSTORE_UI_CHANNEL_MENU_PROXY_H #define DEEPIN_APPSTORE_UI_CHANNEL_MENU_PROXY_H #include <QObject> #include <QVariantMap> namespace dstore { /** * Expose tool menu methods and signals to web page. */ class MenuProxy : public QObject { Q_OBJECT public: explicit MenuProxy(QObject *parent = nullptr); ~MenuProxy() override; signals: /** * This signal is emitted when Login/Logout menu item is activated. * @param login true if request to login, false for logout. */ // void loginRequested(bool login); /** * This signal is emitted when My Comment menu item is activated. */ void commentRequested(); /** * This signal is emitted when My Donates menu item is activated. */ void donateRequested(); /** * This signal is emitted when My Apps menu item is activated. */ void appsRequested(); /** * This signal is emitted when RecommendApp menu item is activated. */ void recommendAppRequested(); /** * this signal is emitted when user click menu */ void switchThemeRequested(QString themeName); /** * This signal is emitted when Privacy Policy menu item is activated. */ void privacyAgreementRequested(); public slots: /** * @brief update titlebar info, like avatar and user name * @param info */ void setUserInfo(QVariantMap info); // signals for ui Q_SIGNALS: /** * @brief notify user info change when user login/logout from web page * @param info */ void userInfoUpdated(QVariantMap info); }; } // namespace dstore #endif // DEEPIN_APPSTORE_UI_CHANNEL_MENU_PROXY_H
2,374
C++
.h
77
26.987013
74
0.705702
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,146
settings_proxy.h
martyr-deepin_deepin-appstore/src/ui/channel/settings_proxy.h
/* * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef DEEPIN_APPSTORE_UI_CHANNEL_SETTINGS_PROXY_H #define DEEPIN_APPSTORE_UI_CHANNEL_SETTINGS_PROXY_H #include <QObject> #include <QVariantMap> namespace dstore { /** * Expose backend settings to web page. */ class SettingsProxy : public QObject { Q_OBJECT public: explicit SettingsProxy(QObject *parent = nullptr); Q_SIGNALS: void raiseWindowRequested(); void fontChangeRequested(const QString &fontFamily, int pixelSize); public Q_SLOTS: /** * Returns metadata server and operation server address. * @return */ const QVariantMap getSettings(); /** * Allow auto install software */ void setAutoInstall(bool autoinstall); /** * Request to open url in external web browser. * @param url */ void openUrl(const QString &url); /** * Raise main window. */ void raiseWindow(); }; } // namespace dstore #endif // DEEPIN_APPSTORE_UI_CHANNEL_SETTINGS_PROXY_H
1,662
C++
.h
55
26.909091
72
0.724138
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,147
log_proxy.h
martyr-deepin_deepin-appstore/src/ui/channel/log_proxy.h
/* * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef DEEPIN_APPSTORE_UI_CHANNEL_LOG_PROXY_H #define DEEPIN_APPSTORE_UI_CHANNEL_LOG_PROXY_H #include <QObject> namespace dstore { /** * This proxy object is used by web page to write log messages to local * log file. */ class LogProxy : public QObject { Q_OBJECT public: explicit LogProxy(QObject* parent = nullptr); ~LogProxy() override; public slots: void debug(const QString& msg); void warn(const QString& msg); void error(const QString& msg); }; } // namespace dstore #endif // DEEPIN_APPSTORE_UI_CHANNEL_LOG_PROXY_H
1,246
C++
.h
36
32.527778
72
0.752286
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,148
search_proxy.h
martyr-deepin_deepin-appstore/src/ui/channel/search_proxy.h
/* * Copyright (C) 2018 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef DEEPIN_APPSTORE_UI_CHANNEL_SEARCH_PROXY_H #define DEEPIN_APPSTORE_UI_CHANNEL_SEARCH_PROXY_H #include <QObject> #include "services/search_result.h" namespace dstore { class SearchProxy : public QObject { Q_OBJECT public: explicit SearchProxy(QObject *parent = nullptr); ~SearchProxy() override; Q_SIGNALS: /** * Request to open app info page * @param name */ Q_SCRIPTABLE void requestComplement(const QString &keyword); /** * Request to open app info page * @param name */ Q_SCRIPTABLE void openApp(const QString &appid); /** * Request to open app search result page * @param keyword search keyword * @param names */ Q_SCRIPTABLE void openAppList(const QString &keyword); public Q_SLOTS: /** * Update app list used in search service. * @param apps Serialized application info */ Q_SCRIPTABLE void setComplementList(const QVariantList &apps); Q_SIGNALS: void searchAppResult(const SearchMetaList &result); }; } // namespace dstore #endif // DEEPIN_APPSTORE_UI_CHANNEL_SEARCH_PROXY_H
1,803
C++
.h
56
28.732143
72
0.727797
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,149
search_completion_window.h
martyr-deepin_deepin-appstore/src/ui/widgets/search_completion_window.h
/* * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef DEEPIN_APPSTORE_UI_WIDGETS_SEARCH_COMPLETION_WINDOW_H #define DEEPIN_APPSTORE_UI_WIDGETS_SEARCH_COMPLETION_WINDOW_H #include <QFrame> #include <QListView> #include <QPushButton> #include <QStringListModel> #include "services/search_result.h" namespace dstore { class SearchButton; class SearchCompletionWindow : public QFrame { Q_OBJECT public: explicit SearchCompletionWindow(QWidget* parent = nullptr); ~SearchCompletionWindow() override; void autoResize(); const SearchMetaList& searchResult() const { return result_; } const QString getKeyword() const { return keyword_; } signals: void resultClicked(const SearchMeta& result); void searchButtonClicked(); public slots: void goDown(); void goUp(); void onEnterPressed(); void setKeyword(const QString& keyword); void setSearchResult(const SearchMetaList& result); private: void initConnections(); void initUI(); QListView* result_view_ = nullptr; QStringListModel* model_ = nullptr; SearchButton* search_button_ = nullptr; SearchMetaList result_; QString keyword_; private slots: void onSearchButtonEntered(); void onResultListClicked(const QModelIndex& index); void onResultListEntered(const QModelIndex& index); }; } // namespace dstore #endif // DEEPIN_APPSTORE_UI_WIDGETS_SEARCH_COMPLETION_WINDOW_H
2,030
C++
.h
57
33.175439
72
0.776188
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,150
search_button.h
martyr-deepin_deepin-appstore/src/ui/widgets/search_button.h
/* * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef DEEPIN_APPSTORE_UI_WIDGETS_SEARCH_BUTTON_H #define DEEPIN_APPSTORE_UI_WIDGETS_SEARCH_BUTTON_H #include <QPushButton> namespace dstore { /** * Overloading of push button which emits entered() signal on mouse hover. */ class SearchButton : public QPushButton { Q_OBJECT public: explicit SearchButton(QWidget* parent = nullptr); ~SearchButton() override; signals: void entered(); protected: void enterEvent(QEvent* event) override; }; } // namespace dstore #endif // DEEPIN_APPSTORE_UI_WIDGETS_SEARCH_BUTTON_H
1,236
C++
.h
35
33.228571
74
0.763621
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,151
search_edit.h
martyr-deepin_deepin-appstore/src/ui/widgets/search_edit.h
/* * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef DEEPIN_APPSTORE_UI_WIDGETS_SEARCH_EDIT_H #define DEEPIN_APPSTORE_UI_WIDGETS_SEARCH_EDIT_H #include <DSearchEdit> namespace dstore { /** * Provides an edit box in TitleBar. */ class SearchEdit : public Dtk::Widget::DSearchEdit { Q_OBJECT public: explicit SearchEdit(QWidget* parent = nullptr); ~SearchEdit() override; signals: void downKeyPressed(); void enterPressed(); void upKeyPressed(); protected: void keyPressEvent(QKeyEvent* event) override; }; } // namespace dstore #endif // DEEPIN_APPSTORE_UI_WIDGETS_SEARCH_EDIT_H
1,258
C++
.h
37
31.864865
72
0.760099
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,152
title_bar.h
martyr-deepin_deepin-appstore/src/ui/widgets/title_bar.h
/* * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef DEEPIN_APPSTORE_UI_WIDGETS_TITLE_BAR_H #define DEEPIN_APPSTORE_UI_WIDGETS_TITLE_BAR_H #include <QFrame> #include <QLabel> #include <QPushButton> #include <QStackedLayout> #include <dimagebutton.h> namespace dstore { class SearchEdit; class UserMenu; // Customize widget in TitleBar. class TitleBar : public QFrame { Q_OBJECT public: explicit TitleBar(bool support_sign_in, QWidget *parent = nullptr); ~TitleBar() override; QString getSearchText() const; Q_SIGNALS: void loginRequested(bool login); void commentRequested(); void requestDonates(); void requestApps(); void backwardButtonClicked(); void forwardButtonClicked(); void searchTextChanged(const QString &text); void downKeyPressed(); void enterPressed(); void upKeyPressed(); void focusOut(); public Q_SLOTS: void setBackwardButtonActive(bool active); void setForwardButtonActive(bool active); void setUserInfo(const QVariantMap &info); void refreshAvatar(); private: void initUI(bool support_sign_in); void initConnections(); void saveUserAvatar(const QImage &image, const QString &filePath); Dtk::Widget::DImageButton *back_button_ = nullptr; Dtk::Widget::DImageButton *forward_button_ = nullptr; SearchEdit *search_edit_ = nullptr; QString user_name_ = ""; UserMenu *user_menu_ = nullptr; QPushButton *avatar_button_ = nullptr; private slots: void onSearchTextChanged(); }; } // namespace dstore #endif // DEEPIN_APPSTORE_UI_WIDGETS_TITLE_BAR_H
2,246
C++
.h
67
30.313433
72
0.746994
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,153
title_bar_menu.h
martyr-deepin_deepin-appstore/src/ui/widgets/title_bar_menu.h
/* * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef DEEPIN_APPSTORE_UI_WIDGETS_TOOL_BAR_MENU_H #define DEEPIN_APPSTORE_UI_WIDGETS_TOOL_BAR_MENU_H #include <QMenu> #include <QVariantMap> namespace dstore { class TitleBarMenu : public QMenu { Q_OBJECT public: explicit TitleBarMenu(bool support_sign_in, QWidget* parent = nullptr); ~TitleBarMenu() override; signals: void switchThemeRequested(QString themeName); void recommendAppRequested(); void clearCacheRequested(); void privacyAgreementRequested(); public slots: void setThemeName(QString themeName); private: void initActions(); bool support_sign_in_ = false; QString theme_name_ = "light"; QAction* switch_theme_action_ = nullptr; QAction* privacy_agreement_action_ = nullptr; private slots: void onThemeActionTriggered(); }; } // namespace dman #endif // DEEPIN_APPSTORE_UI_WIDGETS_TOOL_BAR_MENU_H
1,554
C++
.h
44
32.931818
73
0.766867
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,154
user_menu.h
martyr-deepin_deepin-appstore/src/ui/widgets/user_menu.h
#pragma once #include <QMenu> #include <QScopedPointer> namespace dstore { class UserMenuPrivate; class UserMenu : public QMenu { Q_OBJECT public: explicit UserMenu(QWidget *parent = Q_NULLPTR); ~UserMenu(); Q_SIGNALS: void requestLogout(); void commentRequested(); void requestDonates(); void requestApps(); public Q_SLOTS: void setUsername(const QString &username); private: QScopedPointer<UserMenuPrivate> dd_ptr; Q_DECLARE_PRIVATE_D(qGetPtrHelper(dd_ptr), UserMenu) }; }
522
C++
.h
24
18.791667
56
0.749491
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,155
image_viewer.h
martyr-deepin_deepin-appstore/src/ui/widgets/image_viewer.h
/* * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef DEEPIN_APPSTORE_UI_WIDGETS_IMAGE_VIEWER_H #define DEEPIN_APPSTORE_UI_WIDGETS_IMAGE_VIEWER_H #include <QDialog> #include <DSpinner> #include <dimagebutton.h> class QLabel; namespace dstore { class ImageViewer : public QDialog { Q_OBJECT public: explicit ImageViewer(QWidget* parent = nullptr); ~ImageViewer() override; signals: /** * Emitted when previous-button is clicked. */ void previousImageRequested(); /** * Emitted when next-button is clicked. */ void nextImageRequested(); public slots: /** * Open a local image file and render in image box. * @param filepath */ void open(const QString& filepath); /** * Open a raw pixmap and render in popup window. * Note that this pixmap object is duplicated and might be scaled if needed. * @param pixmap */ void openPixmap(QPixmap pixmap); /** * Show image loading indicator. */ void showIndicator(); protected: void mousePressEvent(QMouseEvent* event) override; void paintEvent(QPaintEvent* event) override; private: void initUI(); void initConnection(); QLabel* img_label_ = nullptr; Dtk::Widget::DImageButton* close_button_ = nullptr; Dtk::Widget::DImageButton* previous_button_ = nullptr; Dtk::Widget::DImageButton* next_button_ = nullptr; Dtk::Widget::DSpinner* spinner_ = nullptr; }; } // namespace dstore #endif // DEEPIN_APPSTORE_UI_WIDGETS_IMAGE_VIEWER_H
2,121
C++
.h
67
28.880597
78
0.73896
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,156
settings_manager.h
martyr-deepin_deepin-appstore/src/services/settings_manager.h
/* * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef DEEPIN_APPSTORE_SERVICES_SETTINGS_MANAGER_H #define DEEPIN_APPSTORE_SERVICES_SETTINGS_MANAGER_H #include <QObject> #include <DSingleton> class QDBusInterface; class QCefGlobalSettings; namespace dstore { enum OperationServerRegion { RegionChina = 0, RegionInternational = 1, }; class SettingsManager : public QObject, public Dtk::Core::DSingleton<SettingsManager> { Q_OBJECT friend class Dtk::Core::DSingleton<SettingsManager>; private: explicit SettingsManager(QObject *parent = nullptr); ~SettingsManager() override; Q_SIGNALS: public Q_SLOTS: void setQCefSettings(QCefGlobalSettings *settings); bool remoteDebug(); bool autoInstall() const; void setAutoInstall(bool autoinstall); QString themeName() const; void setThemeName(const QString &themeName) const; QByteArray windowState() const; void setWindowState(QByteArray data); bool allowShowPackageName() const; QString metadataServer() const; QVariantMap operationServerMap() const; QString defaultRegion() const; bool allowSwitchRegion() const; bool supportAot() const; bool supportSignIn() const; bool upyunBannerVisible() const; private: // TODO: use interface from dbus to xml QVariant getSettings(const QString &key) const; QVariantMap getMapSettings(const QString &key) const; void setSettings(const QString &key, const QVariant &value) const; QDBusInterface *settings_ifc_; QCefGlobalSettings *qcef_settings_; }; } // namespace dstore #endif // DEEPIN_APPSTORE_SERVICES_SETTINGS_MANAGER_H
2,289
C++
.h
63
33
85
0.765186
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,157
store_daemon_manager.h
martyr-deepin_deepin-appstore/src/services/store_daemon_manager.h
/* * Copyright (C) 2018 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef DEEPIN_APPSTORE_SERVICES_STORE_DAEMON_MANAGER_H #define DEEPIN_APPSTORE_SERVICES_STORE_DAEMON_MANAGER_H #include <QObject> #include <QScopedPointer> #include "services/search_result.h" namespace dstore { class StoreDaemonManagerPrivate; class StoreDaemonManager : public QObject { Q_OBJECT public: explicit StoreDaemonManager(QObject *parent = nullptr); ~StoreDaemonManager() override; Q_SIGNALS: /** * Emitted when JobList property changed. * @param jobs */ void jobListChanged(const QStringList &jobs); /* system login state change info: Map(("AccessToken", QVariant(QString, "EIhuP262Qi2vyaPSG_196Q"))("Expiry", QVariant(qlonglong, 1544583742))("HardwareID", QVariant(QString, "bdb3ff930e39c8726b29f2252b132b82da494f492ba41fa2f4b157951069b470"))("Token", QVariant(QString, "0cb068641e132fcba475276f0a0e590b"))("UserID", QVariant(qlonglong, 17898))("loggedIn", QVariant(bool, true))) or {} */ void loginStateChanged(QVariantMap info); public Q_SLOTS: /** * @brief clearArchives clean apt arvhives */ void clearArchives(); QVariantMap fixError(const QString &error_type); /** * Check connecting to backend app store daemon or not. */ bool isDBusConnected(); /** * @brief openApp by app_name * @param app_name: TODO, open by packageURI */ void openApp(const QVariant &app); // TODO: remove // update all list of app void updateAppList(const SearchMetaList &app_list); QVariantMap installedPackages(); QVariantMap query(const QVariantList &apps); QVariantMap queryDownloadSize(const QVariantList &apps); /** * apt-get install xxx * @param app_name * @param app_local_name */ QVariantMap installPackage(const QVariantList &apps); /** * apt-get upgrade xxx * @param app_name * @param app_local_name */ QVariantMap updatePackage(const QVariantList &apps); /** * apt-get remove xxx * @param app_name * @param app_local_name */ QVariantMap removePackage(const QVariantList &apps); QVariantMap queryVersions(const QStringList &apps); /** * Clean up a specific job. * @param job */ QVariantMap cleanJob(const QString &job); /** * Pause a running job * @param job */ QVariantMap pauseJob(const QString &job); /** * Resume a paused job * @param job */ QVariantMap startJob(const QString &job); /** * Get temporary job info. * * valid: bool, false if this job is invalid. * * id: string * * name: string * * status: string * * type: string * * speed: int64 * * progress: double * * description: string * * cancelable: boolean * * packages: stringList */ QVariantMap getJobInfo(const QString &job); QVariantMap getJobsInfo(const QStringList &jobs); /** * Returns all of jobs existing in backend. * @return stringList */ QVariantMap jobList(); void onJobListChanged(); private: QScopedPointer<StoreDaemonManagerPrivate> dd_ptr; Q_DECLARE_PRIVATE_D(qGetPtrHelper(dd_ptr), StoreDaemonManager) }; } // namespace dstore #endif // DEEPIN_APPSTORE_SERVICES_STORE_DAEMON_MANAGER_H
4,002
C++
.h
123
27.821138
365
0.695144
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,158
session_manager.h
martyr-deepin_deepin-appstore/src/services/session_manager.h
/* * Copyright (C) 2018 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef DEEPIN_APPSTORE_SERVICES_SESSION_MANAGER_H #define DEEPIN_APPSTORE_SERVICES_SESSION_MANAGER_H #include <QObject> namespace dstore { // SessionManager schedule dbus tasks, parse command line arguments and // controls when to show main web window. class SessionManager : public QObject { Q_OBJECT public: explicit SessionManager(QObject* parent = nullptr); ~SessionManager() override; }; } // namespace dstore #endif // DEEPIN_APPSTORE_SERVICES_SESSION_MANAGER_H
1,173
C++
.h
30
37.166667
72
0.773967
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,159
account_manager.h
martyr-deepin_deepin-appstore/src/services/account_manager.h
#pragma once #include <QObject> #include <QScopedPointer> #include <QVariantMap> namespace dstore { class AccountManagerPrivate; class AccountManager : public QObject { Q_OBJECT public: explicit AccountManager(QObject *parent = Q_NULLPTR); ~AccountManager(); Q_SIGNALS: void userInfoChanged(const QVariantMap &info); public Q_SLOTS: QVariantMap getUserInfo() const; QString getToken() const; void login(); void logout(); private: QScopedPointer<AccountManagerPrivate> dd_ptr; Q_DECLARE_PRIVATE_D(qGetPtrHelper(dd_ptr), AccountManager) }; } // namespace dstore
610
C++
.h
25
21.4
62
0.766957
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,160
dbus_manager.h
martyr-deepin_deepin-appstore/src/services/dbus_manager.h
/* * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef DEEPIN_APPSTORE_SERVICES_ARGS_PARSER_H #define DEEPIN_APPSTORE_SERVICES_ARGS_PARSER_H #include <QObject> #include "dbus/dbus_variant/app_metadata.h" namespace dstore { // DBusManager implements AppStoreDBusInterface. // Works in background thread. class DBusManager : public QObject { Q_OBJECT public: explicit DBusManager(QObject* parent = nullptr); ~DBusManager() override; bool parseArguments(); signals: void raiseRequested(); void showDetailRequested(const QString& app_name); public slots: // Implement AppStore dbus service. void Raise(); void ShowDetail(const QString& app_name); private: QString app_name_; }; } // namespace dstore #endif // DEEPIN_APPSTORE_SERVICES_ARGS_PARSER_H
1,431
C++
.h
41
32.682927
72
0.767948
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,161
search_result.h
martyr-deepin_deepin-appstore/src/services/search_result.h
/* * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef DEEPIN_APPSTORE_SERVICES_SEARCH_RESULT_H #define DEEPIN_APPSTORE_SERVICES_SEARCH_RESULT_H #include <QDebug> #include <QList> #include <QHash> #include <QtCore/QMetaType> namespace dstore { // App entry used in search service. struct SearchMeta { QString name; QString local_name; QString slogan; QString description; QStringList package_uris; // Package names used in deb format. QStringList debs; // Package names used in flatpak format. QStringList flatpaks; }; bool operator==(const SearchMeta& a, const SearchMeta& b); QDebug& operator<<(QDebug& debug, const SearchMeta& app); void RegisterSearchMetaMetaType(); bool operator<(const SearchMeta& a, const SearchMeta& b); typedef QList<SearchMeta> SearchMetaList; typedef QHash<QString, SearchMeta> SearchMetaMap; } // namespace dstore Q_DECLARE_METATYPE(dstore::SearchMeta); Q_DECLARE_METATYPE(dstore::SearchMetaList); #endif // DEEPIN_APPSTORE_SERVICES_SEARCH_RESULT_H
1,662
C++
.h
45
34.866667
72
0.777778
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,162
rcc_scheme_handler.h
martyr-deepin_deepin-appstore/src/services/rcc_scheme_handler.h
/* * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef DEEPIN_APPSTORE_SERVICES_RCC_SCHEME_HANDLER_H #define DEEPIN_APPSTORE_SERVICES_RCC_SCHEME_HANDLER_H #include <qcef_scheme_handler.h> namespace dstore { // Handles rcc:// scheme requests. QString RccSchemeHandler(const QUrl& url); } // namespace dstore #endif // DEEPIN_APPSTORE_SERVICES_RCC_SCHEME_HANDLER_H
1,020
C++
.h
24
40.625
72
0.768687
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,163
package_manager_interface.h
martyr-deepin_deepin-appstore/src/services/package/package_manager_interface.h
#pragma once #include <QMap> #include <QVariant> #include <QObject> #include <QScopedPointer> #include <QDBusError> #include "dpk_url.h" namespace dstore { class Package { public: ~Package() { installedTime = 0; size = 0; downloadSize = 0; upgradable = false; } QString packageURI; QString packageName; QString appName; QString localVersion; QString remoteVersion; qlonglong installedTime; qlonglong size; qlonglong downloadSize; bool upgradable; QMap<QString, QVariant> allLocalName; static Package fromVariantMap(const QVariantMap &json); QVariantMap toVariantMap() const; //private: QString localName; DpkURI dpk; }; typedef QMap<QString, Package> PackageMap; struct AppPackage { QString name; QString localName; // QStringList packageURI; QList<Package> packages; static AppPackage fromVariantMap(const QVariantMap &json); QVariantMap toVariantMap() const; }; typedef QList<AppPackage> AppPackageList; struct PMResult { PMResult(bool success, QString errName, QString errMsg, QVariant data): success(success), errName(errName), errMsg(errMsg), data(data) { } static PMResult warp(const QVariant &data); static PMResult dbusError(const QDBusError &err); bool success; QString errName; QString errMsg; QVariant data; }; typedef QMap<QString, PMResult> PMResultMap; class PackageManagerInterface : public QObject { Q_OBJECT public: explicit PackageManagerInterface(QObject *parent = Q_NULLPTR); Q_SIGNALS: public Q_SLOTS: virtual PMResult Open(const QString &packageID) = 0; /*! * \brief Query */ virtual PMResult Query(const QList<Package> &packageIDs) = 0; /*! * \brief QueryDownloadSize */ virtual PMResult QueryDownloadSize(const QList<Package> &packageIDs) = 0; virtual PMResult QueryVersion(const QList<Package> &packageIDs) = 0; /*! * \brief QueryRemote */ virtual PMResult QueryInstalledTime(const QList<Package> &packageIDs) = 0; /*! * \brief ListInstalled * \return */ virtual PMResult ListInstalled(const QList<QString> &packageIDs) = 0; /*! * \brief Async install package, return immediately. * \param packageIDList */ virtual PMResult Install(const QList<Package> &packageIDList) = 0; /*! * \brief Remove * \param packageIDList */ virtual PMResult Remove(const QList<Package> &packageIDList) = 0; }; }
2,609
C++
.h
99
21.626263
78
0.689891
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,164
apt_package_manager.h
martyr-deepin_deepin-appstore/src/services/package/apt_package_manager.h
#pragma once #include <QObject> #include <QScopedPointer> #include "package_manager_interface.h" namespace dstore { class AptPackageManagerPrivate; class AptPackageManager : public PackageManagerInterface { Q_OBJECT public: explicit AptPackageManager(QObject *parent = Q_NULLPTR); ~AptPackageManager() override; Q_SIGNALS: public Q_SLOTS: virtual PMResult Open(const QString &packageID) override; virtual PMResult Query(const QList<Package> &packages) override; virtual PMResult QueryDownloadSize(const QList<Package> &packages) override; virtual PMResult QueryVersion(const QList<Package> &packages) override; virtual PMResult QueryInstalledTime(const QList<Package> &packages) override; virtual PMResult ListInstalled(const QList<QString> &packageIDs) override; virtual PMResult Install(const QList<Package> &packages) override; virtual PMResult Remove(const QList<Package> &packages) override; private: QScopedPointer<AptPackageManagerPrivate> dd_ptr; Q_DECLARE_PRIVATE_D(qGetPtrHelper(dd_ptr), AptPackageManager) }; }
1,084
C++
.h
28
35.5
81
0.803059
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,165
package_manager.h
martyr-deepin_deepin-appstore/src/services/package/package_manager.h
#pragma once #include <QObject> #include <QScopedPointer> #include "package_manager_interface.h" namespace dstore { class PackageManagerInterface; class PackageManagerPrivate; class PackageManager : public QObject { Q_OBJECT public: explicit PackageManager(QObject *parent = Q_NULLPTR); ~PackageManager(); void registerDpk(const QString &type, PackageManagerInterface *); Q_SIGNALS: public Q_SLOTS: void Open(const AppPackage &app); PMResult Query(const AppPackageList &apps); PMResult QueryDownloadSize(const AppPackageList &apps); PMResult ListInstalled(const QStringList &packageID); PMResult Install(const AppPackageList &apps); PMResult Remove(const AppPackageList &apps); //TODO remove PMResult QueryVersion(const QStringList &packageID); PMResult QueryInstalledTime(const QStringList &packageID); private: QScopedPointer<PackageManagerPrivate> dd_ptr; Q_DECLARE_PRIVATE_D(qGetPtrHelper(dd_ptr), PackageManager) }; }
995
C++
.h
31
28.774194
69
0.790966
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,166
apt_util_worker.h
martyr-deepin_deepin-appstore/src/services/package/apt_util_worker.h
/* * Copyright (C) 2018 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef DEEPIN_APPSTORE_SERVICES_APT_UTIL_WORKER_H #define DEEPIN_APPSTORE_SERVICES_APT_UTIL_WORKER_H #include <QObject> namespace dstore { class AptUtilWorker : public QObject { Q_OBJECT public: explicit AptUtilWorker(QObject* parent = nullptr); ~AptUtilWorker() override; signals: void openAppRequest(const QString& app_name); private: void initConnections(); private slots: /** * Request to launch application. * @param app_name */ void openApp(const QString& app_name); }; void OpenApp(const QString& app_name); } // namespace dstore #endif // DEEPIN_APPSTORE_SERVICES_APT_UTIL_WORKER_H
1,316
C++
.h
39
31.487179
72
0.760852
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,167
dpk_url.h
martyr-deepin_deepin-appstore/src/services/package/dpk_url.h
/* * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include <QString> namespace dstore { /** dpk://type/id dpk://deb/deepin-manual dpk://flatpak/org.deepin.flatdeb.dde-calendar */ class DpkURI { public: DpkURI() {} DpkURI(const QString &dpk); bool isValid() const; QString getType() const; QString getID() const; private: QString url; QString type; QString id; }; } // namespace dstore
1,083
C++
.h
39
25.410256
72
0.736031
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,168
chinese2pinyin.h
martyr-deepin_deepin-appstore/src/services/backend/chinese2pinyin.h
// Copyright (c) 2015 LiuLang. All rights reserved. // Use of this source is governed by General Public License that can be found // in the LICENSE file. #ifndef SERVICE_BACKEND_CHINESE_TO_PINYIN_H_ #define SERVICE_BACKEND_CHINESE_TO_PINYIN_H_ #include <QString> namespace dstore { /** * Convert Chinese word into pinyin, with syllable. * @param words * @return */ QString Chinese2Pinyin(const QString& words); /** * Convert Chinese word into pinyin, without syllable. * @param words * @return */ QString Chinese2PinyinNoSyl(const QString& words); } // namespace dstore #endif // SERVICE_BACKEND_CHINESE_TO_PINYIN_H_
634
C++
.h
21
28.47619
77
0.762376
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,169
file_util.h
martyr-deepin_deepin-appstore/src/base/file_util.h
/* * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef DEEPIN_APPSTORE_BASE_FILE_UTIL_H #define DEEPIN_APPSTORE_BASE_FILE_UTIL_H #include <QDir> #include <QString> namespace dstore { // Create a folder with |folder_name| in |parent_dir| directory and // returns a QDir object referencing to its absolute path. QDir ConcateDir(const QDir& parent_dir, const QString& folder_name); // Copy file from |src_file| to |dest_file|. // If |dest_file| exists, overwrite its content if |overwrite| is true, or // returns false if not overwrite. bool CopyFile(const QString& src_file, const QString& dest_file, bool overwrite); // Folder content in |src_dir| into |dest_dir|. // This method only copy normal files, folders and symbolic link file. // Other type of files and character device, FIFO and device file are ignored. // For advanced copy function, see misc/unsquashfs.cpp bool CopyFolder(const QString src_dir, const QString& dest_dir, bool recursive = true); // Copy file/folder mode from |src_file| to |dest_file| // Both |src_file| and |dest_file| should not be symbolic link. bool CopyMode(const char* src_file, const char* dest_file); // Create parent folders and itself. bool CreateDirs(const QString& dirpath); // Create parent folders. bool CreateParentDirs(const QString& filepath); // Returns basename of |filepath|. QString GetFileBasename(const QString& filepath); // Returns lower cased extension name of |filepath|, might be empty. QString GetFileExtname(const QString& filepath); // Returns filename of |filepath|. QString GetFileName(const QString& filepath); // Get size of file. If file not found or has no access, returns 0. qint64 GetFileSize(const QString& filepath); // Read contents of file, returns an empty string if failed. // DEPRECATED: call ReadTextFile() instead. QString ReadFile(const QString& path); // Read text file encoded in GB18030. QString ReadGBKFile(const QString& path); // Read content of file at |path|, and save its content into |content|. // Returns true if succeeded, or false otherwise. bool ReadRawFile(const QString& path, QByteArray& content); // Read contents of text file, returns true if succeeded, or false otherwise. // |content| holds the content of that file. bool ReadTextFile(const QString& path, QString& content); // Write content to file, returns true if succeeded, or false otherwise. bool WriteTextFile(const QString& path, const QString& content); bool WriteRawFile(const QString& path, const QByteArray& content); } // namespace dstore #endif // DEEPIN_APPSTORE_BASE_FILE_UTIL_H
3,231
C++
.h
65
47.907692
81
0.767568
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,170
command.h
martyr-deepin_deepin-appstore/src/base/command.h
/* * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef INSTALLER_BASE_COMMAND_H #define INSTALLER_BASE_COMMAND_H #include <QStringList> namespace dstore { // Run a script file in bash, no matter it is executable or not. // First argument in |args| is the path to script file. // Current working directory is changed to folder of |args[0]|. // Returns true if |args[0]| executed and exited with 0. // |output| and |err| are content of stdout and stderr. bool RunScriptFile(const QStringList& args); bool RunScriptFile(const QStringList& args, QString& output, QString& err); // Run |cmd| with |args| in background and returns its result. bool SpawnCmd(const QString& cmd, const QStringList& args); bool SpawnCmd(const QString& cmd, const QStringList& args, QString& output); bool SpawnCmd(const QString& cmd, const QStringList& args, QString& output, QString& err); } // namespace dstore #endif // INSTALLER_BASE_COMMAND_H
1,594
C++
.h
34
44.823529
76
0.755312
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,171
consts.h
martyr-deepin_deepin-appstore/src/base/consts.h
/* * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef DEEPIN_MANUAL_BASE_CONSTS_H #define DEEPIN_MANUAL_BASE_CONSTS_H #include <QDir> namespace dstore { extern const char kAppName[]; extern const char kIndexPage[]; // Get user cache directory. QString GetCacheDir(); } // namespace dstore #endif // DEEPIN_MANUAL_BASE_CONSTS_H
986
C++
.h
26
36.076923
72
0.762854
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,172
launcher.h
martyr-deepin_deepin-appstore/src/base/launcher.h
/* * Copyright (C) 2018 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef DEEPIN_APPSTORE_BASE_LAUNCHER_H #define DEEPIN_APPSTORE_BASE_LAUNCHER_H #include <QString> namespace dstore { /** * Get "Exec" field in a desktop file. * @param filepath absolute filepath to desktop file. * @return empty string if failed to parse. */ const QString GetExecFromDesktop(const QString& filepath); /** * Execute an application defined in a desktop file. * @param filepath * @return */ bool ExecuteDesktopFile(const QString& filepath); } // namespace #endif // DEEPIN_APPSTORE_BASE_LAUNCHER_H
1,218
C++
.h
34
33.941176
72
0.762107
martyr-deepin/deepin-appstore
114
40
17
GPL-3.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
753,173
nova_renderer.cpp
NovaMods_nova-renderer/src/nova_renderer.cpp
#include "nova_renderer/nova_renderer.hpp" #include <array> #include <future> #include <unordered_map> #include <Tracy.hpp> #include <TracyVulkan.hpp> #include <glm/ext.hpp> #include <glm/glm.hpp> #include <spdlog/sinks/stdout_color_sinks.h> #include <spdlog/spdlog.h> #include "nova_renderer/constants.hpp" #include "nova_renderer/loading/renderpack_loading.hpp" #include "nova_renderer/procedural_mesh.hpp" #include "nova_renderer/rendergraph.hpp" #include "nova_renderer/renderpack_data_conversions.hpp" #include "nova_renderer/rhi/command_list.hpp" #include "nova_renderer/rhi/swapchain.hpp" #include "nova_renderer/ui_renderer.hpp" #include "nova_renderer/util/platform.hpp" #include "debugging/renderdoc.hpp" #include "loading/renderpack/render_graph_builder.hpp" #include "logging/console_log_stream.hpp" #include "render_objects/uniform_structs.hpp" #include "renderer/builtin/backbuffer_output_pass.hpp" using namespace nova::mem; using namespace operators; namespace nova::renderer { static auto logger = spdlog::stdout_color_mt("NovaRenderer"); struct BackbufferOutputPipelineCreateInfo : RhiGraphicsPipelineState { BackbufferOutputPipelineCreateInfo(); }; BackbufferOutputPipelineCreateInfo::BackbufferOutputPipelineCreateInfo() { name = BACKBUFFER_OUTPUT_PIPELINE_NAME; const std::string vertex_source{R"( struct VsInput { float2 position : POSITION; }; struct VsOutput { float4 position : SV_POSITION; float2 uv : TEXCOORD; }; VsOutput main(VsInput input) { VsOutput output; output.position = float4(input.position * 2.0 - 1.0, 0, 1); output.uv = input.position; return output; })"}; const auto& vertex_spirv = renderpack::compile_shader(vertex_source, rhi::ShaderStage::Vertex, rhi::ShaderLanguage::Hlsl); if(vertex_spirv.empty()) { logger->error("Could not compile builtin backbuffer output vertex shader"); } vertex_shader = {"/nova/shaders/backbuffer_output.vertex.hlsl", vertex_spirv}; const std::string pixel_source{R"( [[vk::binding(0, 0)]] Texture2D ui_output : register(t0); [[vk::binding(1, 0)]] Texture2D scene_output : register(t1); [[vk::binding(2, 0)]] SamplerState tex_sampler : register(s0); struct VsOutput { float4 position : SV_POSITION; float2 uv : TEXCOORD; }; float3 main(VsOutput input) : SV_Target { float4 ui_color = ui_output.Sample(tex_sampler, input.uv); float4 scene_color = scene_output.Sample(tex_sampler, input.uv); float3 combined_color = lerp(scene_color.rgb, ui_color.rgb, ui_color.a); return combined_color; })"}; const auto& pixel_spirv = renderpack::compile_shader(pixel_source, rhi::ShaderStage::Pixel, rhi::ShaderLanguage::Hlsl); if(pixel_spirv.empty()) { logger->error("Could not compile builtin backbuffer output pixel shader"); } pixel_shader = ShaderSource{.filename = "/nova/shaders/backbuffer_output.pixel.hlsl", .source = pixel_spirv}; vertex_fields.emplace_back("position", rhi::VertexFieldFormat::Float2); // TODO: Figure out how to make the input textures into input attachments color_attachments.emplace_back(BACKBUFFER_NAME, rhi::PixelFormat::Rgba8, false); } static BackbufferOutputPipelineCreateInfo backbuffer_output_pipeline_create_info{}; bool FullMaterialPassName::operator==(const FullMaterialPassName& other) const { return material_name == other.material_name && pass_name == other.pass_name; } NovaRenderer::NovaRenderer(const NovaSettings& settings) : settings{settings} { spdlog::flush_on(spdlog::level::err); ZoneScoped; create_global_allocators(); initialize_virtual_filesystem(); window = std::make_unique<NovaWindow>(settings); if(settings.debug.renderdoc.enabled) { ZoneScoped; auto rd_load_result = load_renderdoc(settings.debug.renderdoc.renderdoc_dll_path); rd_load_result .map([&](RENDERDOC_API_1_3_0* api) { render_doc = api; render_doc->SetCaptureFilePathTemplate(settings.debug.renderdoc.capture_path); RENDERDOC_InputButton capture_key[] = {eRENDERDOC_Key_F12, eRENDERDOC_Key_PrtScrn}; render_doc->SetCaptureKeys(capture_key, 2); render_doc->SetCaptureOptionU32(eRENDERDOC_Option_AllowFullscreen, 1U); render_doc->SetCaptureOptionU32(eRENDERDOC_Option_AllowVSync, 1U); render_doc->SetCaptureOptionU32(eRENDERDOC_Option_VerifyMapWrites, 1U); render_doc->SetCaptureOptionU32(eRENDERDOC_Option_SaveAllInitials, 1U); render_doc->SetCaptureOptionU32(eRENDERDOC_Option_APIValidation, 1U); logger->info("Loaded RenderDoc successfully"); return 0; }) .on_error([](const ntl::NovaError& error) { logger->error("%s", error.to_string()); }); } { ZoneScoped; device = rhi::create_render_device(this->settings, *window); } swapchain = device->get_swapchain(); create_global_sync_objects(); create_global_samplers(); create_resource_storage(); create_builtin_render_targets(); create_builtin_uniform_buffers(); create_builtin_meshes(); create_renderpass_manager(); create_builtin_renderpasses(); cameras.reserve(MAX_NUM_CAMERAS); camera_data = std::make_unique<PerFrameDeviceArray<CameraUboData>>(MAX_NUM_CAMERAS, settings.max_in_flight_frames, *device); } NovaRenderer::~NovaRenderer() {} NovaSettingsAccessManager& NovaRenderer::get_settings() { return settings; } void NovaRenderer::execute_frame() { { ZoneScoped; frame_count++; cur_frame_idx = device->get_swapchain()->acquire_next_swapchain_image(); std::vector<rhi::RhiFence*> cur_frame_fences{frame_fences[cur_frame_idx]}; device->wait_for_fences(cur_frame_fences); device->reset_fences(cur_frame_fences); FrameContext ctx = {}; ctx.frame_count = frame_count; ctx.frame_idx = cur_frame_idx; ctx.nova = this; ctx.swapchain_framebuffer = swapchain->get_framebuffer(cur_frame_idx); ctx.swapchain_image = swapchain->get_image(cur_frame_idx); ctx.camera_matrix_buffer = camera_data->get_buffer_for_frame(cur_frame_idx); ctx.material_buffer = material_device_buffers[cur_frame_idx]; rhi::RhiRenderCommandList* cmds = device->create_command_list(0, rhi::QueueType::Graphics, rhi::RhiRenderCommandList::Level::Primary); cmds->set_debug_name("RendergraphCommands"); const auto images = get_all_images(); cmds->bind_material_resources(ctx.camera_matrix_buffer, ctx.material_buffer->buffer, point_sampler, point_sampler, point_sampler, images); const auto& renderpass_order = rendergraph->calculate_renderpass_execution_order(); for(const std::string& renderpass_name : renderpass_order) { auto* renderpass = rendergraph->get_renderpass(renderpass_name); renderpass->execute(*cmds, ctx); } // The rendergraph may update the camera and material data, so we upload the data at the end of the frame update_camera_matrix_buffer(cur_frame_idx); device->write_data_to_buffer(material_buffer->data(), ctx.material_buffer->size, ctx.material_buffer->buffer); device->submit_command_list(cmds, rhi::QueueType::Graphics, frame_fences[cur_frame_idx]); // Wait for the GPU to finish before presenting. This destroys pipelining and throughput, however at this time I'm not sure how // best to say "when GPU finishes this task, CPU should do something" device->wait_for_fences(cur_frame_fences); device->get_swapchain()->present(cur_frame_idx); } FrameMark; #ifdef TRACY_ENABLE Tracyvk::NewFrame(renderer::RenderBackend::tracy_context); Tracyvk::Collect(renderer::RenderBackend::tracy_context); #endif } void NovaRenderer::set_num_meshes(const uint32_t /* num_meshes */) { /* TODO? */ } MeshId NovaRenderer::create_mesh(const MeshData& mesh_data) { if(mesh_data.num_vertex_attributes == 0) { logger->error("Can not add a mesh with zero vertex attributes"); } if(mesh_data.num_indices == 0) { logger->error("Can not add a mesh with zero indices"); } rhi::RhiBufferCreateInfo vertex_buffer_create_info; vertex_buffer_create_info.buffer_usage = rhi::BufferUsage::VertexBuffer; vertex_buffer_create_info.size = mesh_data.vertex_data_size; rhi::RhiBuffer* vertex_buffer = device->create_buffer(vertex_buffer_create_info); // TODO: Try to get staging buffers from a pool { rhi::RhiBufferCreateInfo staging_vertex_buffer_create_info = vertex_buffer_create_info; staging_vertex_buffer_create_info.buffer_usage = rhi::BufferUsage::StagingBuffer; rhi::RhiBuffer* staging_vertex_buffer = device->create_buffer(staging_vertex_buffer_create_info); device->write_data_to_buffer(mesh_data.vertex_data_ptr, vertex_buffer_create_info.size, staging_vertex_buffer); rhi::RhiRenderCommandList* vertex_upload_cmds = device->create_command_list(0, rhi::QueueType::Transfer, rhi::RhiRenderCommandList::Level::Primary); vertex_upload_cmds->set_debug_name("VertexDataUpload"); vertex_upload_cmds->copy_buffer(vertex_buffer, 0, staging_vertex_buffer, 0, vertex_buffer_create_info.size); rhi::RhiResourceBarrier vertex_barrier = {}; vertex_barrier.resource_to_barrier = vertex_buffer; vertex_barrier.old_state = rhi::ResourceState::CopyDestination; vertex_barrier.new_state = rhi::ResourceState::Common; vertex_barrier.access_before_barrier = rhi::ResourceAccess::CopyWrite; vertex_barrier.access_after_barrier = rhi::ResourceAccess::VertexAttributeRead; vertex_barrier.source_queue = rhi::QueueType::Transfer; vertex_barrier.destination_queue = rhi::QueueType::Graphics; vertex_barrier.buffer_memory_barrier.offset = 0; vertex_barrier.buffer_memory_barrier.size = vertex_buffer->size; vertex_upload_cmds->resource_barriers(rhi::PipelineStage::Transfer, rhi::PipelineStage::VertexInput, {vertex_barrier}); device->submit_command_list(vertex_upload_cmds, rhi::QueueType::Transfer); // TODO: Barrier on the mesh's first usage } rhi::RhiBufferCreateInfo index_buffer_create_info; index_buffer_create_info.buffer_usage = rhi::BufferUsage::IndexBuffer; index_buffer_create_info.size = mesh_data.index_data_size; rhi::RhiBuffer* index_buffer = device->create_buffer(index_buffer_create_info); { rhi::RhiBufferCreateInfo staging_index_buffer_create_info = index_buffer_create_info; staging_index_buffer_create_info.buffer_usage = rhi::BufferUsage::StagingBuffer; rhi::RhiBuffer* staging_index_buffer = device->create_buffer(staging_index_buffer_create_info); device->write_data_to_buffer(mesh_data.index_data_ptr, index_buffer_create_info.size, staging_index_buffer); rhi::RhiRenderCommandList* indices_upload_cmds = device->create_command_list(0, rhi::QueueType::Transfer, rhi::RhiRenderCommandList::Level::Primary); indices_upload_cmds->set_debug_name("IndexDataUpload"); indices_upload_cmds->copy_buffer(index_buffer, 0, staging_index_buffer, 0, index_buffer_create_info.size); rhi::RhiResourceBarrier index_barrier = {}; index_barrier.resource_to_barrier = index_buffer; index_barrier.old_state = rhi::ResourceState::CopyDestination; index_barrier.new_state = rhi::ResourceState::Common; index_barrier.access_before_barrier = rhi::ResourceAccess::CopyWrite; index_barrier.access_after_barrier = rhi::ResourceAccess::IndexRead; index_barrier.source_queue = rhi::QueueType::Transfer; index_barrier.destination_queue = rhi::QueueType::Graphics; index_barrier.buffer_memory_barrier.offset = 0; index_barrier.buffer_memory_barrier.size = index_buffer->size; indices_upload_cmds->resource_barriers(rhi::PipelineStage::Transfer, rhi::PipelineStage::VertexInput, {index_barrier}); device->submit_command_list(indices_upload_cmds, rhi::QueueType::Transfer); // TODO: Barrier on the mesh's first usage } // TODO: Clean up staging buffers Mesh mesh; mesh.num_vertex_attributes = mesh_data.num_vertex_attributes; mesh.vertex_buffer = vertex_buffer; mesh.index_buffer = index_buffer; mesh.num_indices = mesh_data.num_indices; const MeshId new_mesh_id = next_mesh_id; next_mesh_id++; meshes.emplace(new_mesh_id, mesh); return new_mesh_id; } ProceduralMeshAccessor NovaRenderer::create_procedural_mesh(const uint64_t vertex_size, const uint64_t index_size) { const MeshId our_id = next_mesh_id; next_mesh_id++; proc_meshes.emplace(our_id, ProceduralMesh{vertex_size, index_size, settings->max_in_flight_frames, device.get()}); return ProceduralMeshAccessor{&proc_meshes, our_id}; } std::optional<Mesh> NovaRenderer::get_mesh(const MeshId mesh_id) { if(const auto mesh_itr = meshes.find(mesh_id); mesh_itr != meshes.end()) { return mesh_itr->second; } else { return std::nullopt; } } void NovaRenderer::load_renderpack(const std::string& renderpack_name) { ZoneScoped; const renderpack::RenderpackData data = renderpack::load_renderpack_data(renderpack_name); if(renderpacks_loaded) { destroy_dynamic_resources(); destroy_renderpasses(); logger->debug("Resources from old renderpack destroyed"); } create_dynamic_textures(data.resources.render_targets); logger->debug("Dynamic textures created"); create_render_passes(data.graph_data.passes, data.pipelines); logger->debug("Created render passes"); create_pipelines_and_materials(data.pipelines, data.materials); logger->debug("Created pipelines and materials"); renderpacks_loaded = true; logger->debug("Renderpack %s loaded successfully", renderpack_name); } const std::vector<MaterialPass>& NovaRenderer::get_material_passes_for_pipeline(const std::string& pipeline) { return passes_by_pipeline.find(pipeline)->second; } std::optional<RenderpassMetadata> NovaRenderer::get_renderpass_metadata(const std::string& renderpass_name) const { return rendergraph->get_metadata_for_renderpass(renderpass_name); } void NovaRenderer::create_dynamic_textures(const std::vector<renderpack::TextureCreateInfo>& texture_create_infos) { ZoneScoped; for(const renderpack::TextureCreateInfo& create_info : texture_create_infos) { ZoneScoped; const auto size = create_info.format.get_size_in_pixels(device->get_swapchain()->get_size()); const auto render_target = device_resources->create_render_target(create_info.name, size.x, size.y, create_info.format.pixel_format); dynamic_texture_infos.emplace(create_info.name, create_info); } } void NovaRenderer::create_render_passes(const std::vector<renderpack::RenderPassCreateInfo>& pass_create_infos, const std::vector<renderpack::PipelineData>& pipelines) const { ZoneScoped; device->set_num_renderpasses(static_cast<uint32_t>(pass_create_infos.size())); for(const renderpack::RenderPassCreateInfo& create_info : pass_create_infos) { ZoneScoped; auto* renderpass = new Renderpass(create_info.name); if(rendergraph->add_renderpass(renderpass, create_info, *device_resources) != nullptr) { for(const renderpack::PipelineData& pipeline : pipelines) { if(pipeline.pass == create_info.name) { renderpass->pipeline_names.emplace_back(pipeline.name); } } } else { logger->error("Could not create renderpass %s", create_info.name); } } } void NovaRenderer::create_pipelines_and_materials(const std::vector<renderpack::PipelineData>& pipeline_create_infos, const std::vector<renderpack::MaterialData>& materials) { ZoneScoped; for(const renderpack::PipelineData& rp_pipeline_state : pipeline_create_infos) { ZoneScoped; const auto pipeline_state = to_pipeline_state_create_info(rp_pipeline_state, *rendergraph); if(!pipeline_state) { logger->error("Could not create pipeline %s", rp_pipeline_state.name); continue; } // TODO: A way for renderpack pipelines to say if they're global or surface pipelines Pipeline pipeline; pipeline.pipeline = device->create_surface_pipeline(*pipeline_state); create_materials_for_pipeline(pipeline, materials, rp_pipeline_state.name); pipelines.emplace(rp_pipeline_state.name, std::move(pipeline)); return; } } void NovaRenderer::create_materials_for_pipeline(const Pipeline& pipeline, const std::vector<renderpack::MaterialData>& materials, const std::string& pipeline_name) { ZoneScoped; // Determine the pipeline layout so the material can create descriptors for the pipeline MaterialPassKey template_key = {}; template_key.pipeline_name = pipeline_name; // Large overestimate, but that's fine std::vector<MaterialPass> passes; passes.reserve(materials.size()); for(const renderpack::MaterialData& material_data : materials) { for(const renderpack::MaterialPass& pass_data : material_data.passes) { if(pass_data.pipeline == pipeline_name) { const auto& event_name = fmt::format("{}.{}", material_data.name, pass_data.name); ZoneScoped; MaterialPass pass = {}; pass.pipeline_interface = pipeline.pipeline_interface; const FullMaterialPassName full_pass_name{pass_data.material_name, pass_data.name}; pass.name = full_pass_name; MaterialPassMetadata pass_metadata{}; pass_metadata.data = pass_data; material_metadatas.emplace(full_pass_name, pass_metadata); MaterialPassKey key = template_key; key.material_pass_index = static_cast<uint32_t>(passes.size()); material_pass_keys.emplace(full_pass_name, key); passes.push_back(pass); } } } passes_by_pipeline.emplace(pipeline.pipeline->name, passes); } void NovaRenderer::update_camera_matrix_buffer(const uint32_t frame_idx) { ZoneScoped; for(const Camera& cam : cameras) { if(cam.is_active) { auto& data = camera_data->at(cam.index); data.previous_view = data.view; data.previous_projection = data.projection; data.view = translate({}, cam.position); data.view = rotate(data.view, cam.rotation.x, {1, 0, 0}); data.view = rotate(data.view, cam.rotation.y, {0, 1, 0}); data.view = rotate(data.view, cam.rotation.z, {0, 0, 1}); if(cam.field_of_view > 0) { data.projection = glm::perspective(cam.field_of_view, cam.aspect_ratio, cam.near_plane, cam.far_plane); } else { const auto framebuffer_size = device->get_swapchain()->get_size(); glm::mat4 ui_matrix{ {2.0f, 0.0f, 0.0f, -1.0f}, {0.0f, 2.0f, 0.0f, -1.0f}, {0.0f, 0.0f, -1.0f, 0.0f}, {0.0f, 0.0f, 0.0f, 1.0f}, }; ui_matrix[0][0] /= framebuffer_size.x; ui_matrix[1][1] /= framebuffer_size.y; data.projection = ui_matrix; } } } camera_data->upload_to_device(frame_idx); } std::vector<rhi::RhiImage*> NovaRenderer::get_all_images() { std::vector<rhi::RhiImage*> images{}; const auto& textures = device_resources->get_all_textures(); images.reserve(textures.size()); for(const TextureResource& texture : textures) { images.emplace_back(texture.image); } return images; } void NovaRenderer::destroy_dynamic_resources() { ZoneScoped; if(loaded_renderpack) { for(const renderpack::TextureCreateInfo& tex_data : loaded_renderpack->resources.render_targets) { device_resources->destroy_render_target(tex_data.name); } logger->debug("Deleted all dynamic textures from renderpack %s", loaded_renderpack->name); } } void NovaRenderer::destroy_renderpasses() { ZoneScoped; for(const renderpack::RenderPassCreateInfo& renderpass : loaded_renderpack->graph_data.passes) { rendergraph->destroy_renderpass(renderpass.name); } } rhi::RhiSampler* NovaRenderer::get_point_sampler() const { return point_sampler; } Pipeline* NovaRenderer::find_pipeline(const std::string& pipeline_name) { if(const auto pipeline_itr = pipelines.find(pipeline_name); pipeline_itr != pipelines.end()) { return &pipeline_itr->second; } return nullptr; } RenderableId NovaRenderer::add_renderable_for_material(const FullMaterialPassName& material_name, const StaticMeshRenderableCreateInfo& create_info) { ZoneScoped; const RenderableId id = next_renderable_id.load(); next_renderable_id.fetch_add(1); const auto pass_key_itr = material_pass_keys.find(material_name); if(pass_key_itr == material_pass_keys.end()) { logger->error("No material named %s for pass %s", material_name.material_name, material_name.pass_name); return std::numeric_limits<uint64_t>::max(); } const auto& pass_key = pass_key_itr->second; RenderableKey key; key.pipeline_name = pass_key.pipeline_name; key.material_pass_idx = pass_key.material_pass_index; // Figure out where to put the renderable auto materials_itr = passes_by_pipeline.find(pass_key.pipeline_name); if(materials_itr == passes_by_pipeline.end()) { return std::numeric_limits<uint64_t>::max(); } auto& material = materials_itr->second[pass_key.material_pass_index]; StaticMeshRenderCommand command = make_render_command(create_info, id); if(const auto& mesh_itr = meshes.find(create_info.mesh); mesh_itr != meshes.end()) { const auto& mesh = mesh_itr->second; if(create_info.is_static) { key.type = RenderableType::StaticMesh; bool need_to_add_batch = true; uint32_t batch_idx = 0; for(MeshBatch<StaticMeshRenderCommand>& batch : material.static_mesh_draws) { if(batch.vertex_buffer == mesh.vertex_buffer) { key.batch_idx = batch_idx; key.renderable_idx = static_cast<uint32_t>(batch.commands.size()); batch.commands.emplace_back(command); need_to_add_batch = false; break; } batch_idx++; } if(need_to_add_batch) { MeshBatch<StaticMeshRenderCommand> batch; batch.num_vertex_attributes = mesh.num_vertex_attributes; batch.num_indices = mesh.num_indices; batch.vertex_buffer = mesh.vertex_buffer; batch.index_buffer = mesh.index_buffer; batch.commands.emplace_back(command); key.batch_idx = static_cast<uint32_t>(material.static_mesh_draws.size()); key.renderable_idx = 0; material.static_mesh_draws.emplace_back(batch); } } } else if(const auto& proc_mesh_itr = proc_meshes.find(create_info.mesh); proc_mesh_itr != proc_meshes.end()) { if(create_info.is_static) { key.type = RenderableType::ProceduralMesh; bool need_to_add_batch = false; uint32_t batch_idx = 0; for(ProceduralMeshBatch<StaticMeshRenderCommand>& batch : material.static_procedural_mesh_draws) { if(batch.mesh.get_key() == create_info.mesh) { key.batch_idx = batch_idx; key.renderable_idx = static_cast<uint32_t>(batch.commands.size()); batch.commands.emplace_back(command); need_to_add_batch = false; break; } batch_idx++; } if(need_to_add_batch) { ProceduralMeshBatch<StaticMeshRenderCommand> batch{&proc_meshes, create_info.mesh}; batch.commands.emplace_back(command); key.batch_idx = static_cast<uint32_t>(material.static_mesh_draws.size()); key.renderable_idx = 0; material.static_procedural_mesh_draws.emplace_back(batch); } } } else { logger->error("Could not find a mesh with ID %u", create_info.mesh); return std::numeric_limits<uint64_t>::max(); } renderable_keys.emplace(id, key); return id; } void NovaRenderer::update_renderable(RenderableId renderable, const StaticMeshRenderableUpdateData& update_data) { ZoneScoped; const auto& key_itr = renderable_keys.find(renderable); if(key_itr == renderable_keys.end()) { logger->error("Could not update renderable %u", renderable); return; } auto passes_itr = passes_by_pipeline.find(key_itr->second.pipeline_name); if(passes_itr == passes_by_pipeline.end()) { logger->error("Could not find draws for pipeline %s, as requested by renderable %u", key_itr->second.pipeline_name, renderable); return; } const auto& key = key_itr->second; auto& material_pass = passes_itr->second[key.material_pass_idx]; auto command = [&] { switch(key.type) { case RenderableType::StaticMesh: { auto& batch = material_pass.static_mesh_draws[key.batch_idx]; return batch.commands[key.renderable_idx]; } case RenderableType::ProceduralMesh: { auto& batch = material_pass.static_procedural_mesh_draws[key.batch_idx]; return batch.commands[key.renderable_idx]; } } }(); command.is_visible = update_data.visible; // TODO: Make sure my matrix math is correct command.model_matrix = glm::translate(glm::mat4{1}, update_data.position); command.model_matrix = glm::scale(command.model_matrix, update_data.scale); command.model_matrix = glm::rotate(command.model_matrix, update_data.rotation.x, {1, 0, 0}); command.model_matrix = glm::rotate(command.model_matrix, update_data.rotation.y, {0, 1, 0}); command.model_matrix = glm::rotate(command.model_matrix, update_data.rotation.z, {0, 0, 1}); } CameraAccessor NovaRenderer::create_camera(const CameraCreateInfo& create_info) { const auto idx = cameras.size(); cameras.emplace_back(create_info); CameraAccessor camera{&cameras, idx}; camera->index = camera_data->get_next_free_slot(); return camera; } rhi::RenderDevice& NovaRenderer::get_device() const { return *device; } NovaWindow& NovaRenderer::get_window() const { return *window; } DeviceResources& NovaRenderer::get_resource_manager() const { return *device_resources; } void NovaRenderer::initialize_virtual_filesystem() { // The host application MUST register its data directory before initializing Nova const auto vfs = filesystem::VirtualFilesystem::get_instance(); const auto renderpacks_directory = vfs->get_folder_accessor(RENDERPACK_DIRECTORY); vfs->add_resource_root(renderpacks_directory); } void NovaRenderer::create_global_sync_objects() { frame_fences = device->create_fences(settings->max_in_flight_frames, true); } void NovaRenderer::create_global_samplers() { { // Default sampler create info will give us a delicious point sampler point_sampler = device->create_sampler({}); } } void NovaRenderer::create_resource_storage() { device_resources = std::make_unique<DeviceResources>(*this); } void NovaRenderer::create_builtin_render_targets() { const auto& swapchain_size = device->get_swapchain()->get_size(); { const auto scene_output = device_resources->create_render_target(SCENE_OUTPUT_RT_NAME, swapchain_size.x, swapchain_size.y, rhi::PixelFormat::Rgba8, true); if(!scene_output) { logger->error("Could not create scene output render target"); } else { dynamic_texture_infos .emplace(SCENE_OUTPUT_RT_NAME, renderpack::TextureCreateInfo{.name = SCENE_OUTPUT_RT_NAME, .usage = renderpack::ImageUsage::RenderTarget, .format = {.pixel_format = rhi::PixelFormat::Rgba8, .dimension_type = renderpack::TextureDimensionType::ScreenRelative, .width = 1, .height = 1}}); } } { const auto ui_output = device_resources->create_render_target(UI_OUTPUT_RT_NAME, swapchain_size.x, swapchain_size.y, rhi::PixelFormat::Rgba8, true); if(!ui_output) { logger->error("Could not create UI output render target"); } else { dynamic_texture_infos .emplace(UI_OUTPUT_RT_NAME, renderpack::TextureCreateInfo{.name = UI_OUTPUT_RT_NAME, .usage = renderpack::ImageUsage::RenderTarget, .format = {.pixel_format = rhi::PixelFormat::Rgba8, .dimension_type = renderpack::TextureDimensionType::ScreenRelative, .width = 1, .height = 1}}); } } } void NovaRenderer::create_builtin_uniform_buffers() { material_buffer = std::make_unique<MaterialDataBuffer>(); for(uint32_t i = 0; i < settings->max_in_flight_frames; i++) { const auto buffer_name = fmt::format("{}_{}", MATERIAL_DATA_BUFFER_NAME, i); if(auto buffer = device_resources->create_uniform_buffer(buffer_name, MATERIAL_BUFFER_SIZE); buffer) { builtin_buffer_names.emplace_back(buffer_name); material_device_buffers.emplace_back(*buffer); } else { logger->error("Could not create builtin buffer %s", buffer_name); } } if(device_resources->create_uniform_buffer(PER_FRAME_DATA_NAME, sizeof(PerFrameUniforms))) { builtin_buffer_names.emplace_back(PER_FRAME_DATA_NAME); } else { logger->error("Could not create builtin buffer %s", PER_FRAME_DATA_NAME); } if(device_resources->create_uniform_buffer(MODEL_MATRIX_BUFFER_NAME, sizeof(glm::mat4) * 0xFFFF)) { builtin_buffer_names.emplace_back(MODEL_MATRIX_BUFFER_NAME); } else { logger->error("Could not create builtin buffer %s", MODEL_MATRIX_BUFFER_NAME); } } void NovaRenderer::create_builtin_meshes() { const static std::array TRIANGLE_VERTICES{0.0f, 0.0f, 2.0f, 0.0f, 0.0f, 2.0f}; const static std::array TRIANGLE_INDICES{0, 1, 2}; const MeshData fullscreen_triangle_data{1, 3, TRIANGLE_VERTICES.data(), TRIANGLE_VERTICES.size() * sizeof(float), TRIANGLE_INDICES.data(), TRIANGLE_INDICES.size() * sizeof(uint32_t)}; fullscreen_triangle_id = create_mesh(fullscreen_triangle_data); } void NovaRenderer::create_renderpass_manager() { rendergraph = std::make_unique<Rendergraph>(*device); } // ReSharper disable once CppMemberFunctionMayBeConst void NovaRenderer::create_builtin_renderpasses() { const auto& ui_output = *device_resources->get_render_target(UI_OUTPUT_RT_NAME); const auto& scene_output = *device_resources->get_render_target(SCENE_OUTPUT_RT_NAME); backbuffer_output_pipeline_create_info.viewport_size = device->get_swapchain()->get_size(); auto backbuffer_pipeline = device->create_global_pipeline(*backbuffer_output_pipeline_create_info); if(rendergraph->create_renderpass<BackbufferOutputRenderpass>(*device_resources, ui_output->image, scene_output->image, point_sampler, std::move(backbuffer_pipeline), fullscreen_triangle_id, *device) == nullptr) { logger->error("Could not create the backbuffer output renderpass"); } } void NovaRenderer::create_builtin_pipelines() {} } // namespace nova::renderer
37,649
C++
.cpp
653
41.686064
140
0.579863
NovaMods/nova-renderer
114
12
25
MPL-2.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
true
true
true
false
false
true
false
false
753,174
renderables.cpp
NovaMods_nova-renderer/src/render_objects/renderables.cpp
#include "nova_renderer/renderables.hpp" #include <glm/ext/matrix_transform.inl> namespace nova::renderer { StaticMeshRenderCommand make_render_command(const StaticMeshRenderableCreateInfo& data, const RenderableId id) { StaticMeshRenderCommand command = {}; command.id = id; command.is_visible = true; // TODO: Make sure this is accurate command.model_matrix = glm::translate(command.model_matrix, data.position); command.model_matrix = glm::rotate(command.model_matrix, data.rotation.x, {1, 0, 0}); command.model_matrix = glm::rotate(command.model_matrix, data.rotation.y, {0, 1, 0}); command.model_matrix = glm::rotate(command.model_matrix, data.rotation.z, {0, 0, 1}); command.model_matrix = glm::scale(command.model_matrix, data.scale); // Uniform scaling only return command; } } // namespace nova::renderer
905
C++
.cpp
16
49.875
116
0.697517
NovaMods/nova-renderer
114
12
25
MPL-2.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
true
false
false
true
false
false
753,175
procedural_mesh.cpp
NovaMods_nova-renderer/src/render_objects/procedural_mesh.cpp
#include "nova_renderer/procedural_mesh.hpp" #include <rx/core/log.h> #include "nova_renderer/rhi/render_device.hpp" #include "../util/memory_utils.hpp" using namespace nova::mem; namespace nova::renderer { RX_LOG("ProceduralMesh", logger); using namespace rhi; ProceduralMesh::ProceduralMesh(const uint64_t vertex_buffer_size, const uint64_t index_buffer_size, const uint32_t num_in_flight_frames, RenderDevice* device, const std::string& name) : device(device), name(name) #ifdef NOVA_DEBUG , vertex_buffer_size(vertex_buffer_size), index_buffer_size(index_buffer_size) #endif { const auto aligned_vertex_buffer_size = align(vertex_buffer_size, 256); const auto aligned_index_buffer_size = align(index_buffer_size, 256); const auto host_memory_size = aligned_vertex_buffer_size + aligned_index_buffer_size; const auto device_memory_size = host_memory_size * 3; allocator = &rx::memory::g_system_allocator; vertex_buffers.resize(num_in_flight_frames); index_buffers.resize(num_in_flight_frames); for(uint32_t i = 0; i < num_in_flight_frames; i++) { vertex_buffers[i] = device->create_buffer({std::string::format("%sVertices%d", name, i), vertex_buffer_size, BufferUsage::VertexBuffer}, *allocator); index_buffers[i] = device->create_buffer({std::string::format("%sIndices%d", name, i), index_buffer_size, BufferUsage::IndexBuffer}, *allocator); } cached_vertex_buffer = device->create_buffer({std::string::format("%sStagingVertices", name), vertex_buffer_size, BufferUsage::StagingBuffer}, *allocator); cached_index_buffer = device->create_buffer({std::string::format("%sStagingIndices", name), index_buffer_size, BufferUsage::StagingBuffer}, *allocator); } ProceduralMesh::ProceduralMesh(ProceduralMesh&& old) noexcept : device{old.device}, vertex_buffers{std::move(old.vertex_buffers)}, index_buffers{std::move(old.index_buffers)}, cached_vertex_buffer{old.cached_vertex_buffer}, cached_index_buffer{old.cached_index_buffer}, num_vertex_bytes_to_upload{old.num_vertex_bytes_to_upload}, num_index_bytes_to_upload{old.num_index_bytes_to_upload}, allocator { old.allocator } #if NOVA_DEBUG , vertex_buffer_size{old.vertex_buffer_size}, index_buffer_size { old.index_buffer_size } #endif { old.device = nullptr; } ProceduralMesh& ProceduralMesh::operator=(ProceduralMesh&& old) noexcept { device = old.device; vertex_buffers = std::move(old.vertex_buffers); index_buffers = std::move(old.index_buffers); cached_vertex_buffer = old.cached_vertex_buffer; cached_index_buffer = old.cached_index_buffer; num_vertex_bytes_to_upload = old.num_vertex_bytes_to_upload; num_index_bytes_to_upload = old.num_index_bytes_to_upload; allocator = old.allocator; #if NOVA_DEBUG vertex_buffer_size = old.vertex_buffer_size; index_buffer_size = old.index_buffer_size; #endif old.device = nullptr; return *this; } void ProceduralMesh::set_vertex_data(const void* data, const uint64_t size) { #ifdef NOVA_DEBUG if(size > vertex_buffer_size) { logger->error( "Cannot upload vertex data. There's only space for %uz bytes, you tried to upload %uz. Truncating vertex data to fit", vertex_buffer_size, size); device->write_data_to_buffer(data, vertex_buffer_size, cached_vertex_buffer); num_vertex_bytes_to_upload = vertex_buffer_size; } else { #endif device->write_data_to_buffer(data, size, cached_vertex_buffer); num_vertex_bytes_to_upload = size; #ifdef NOVA_DEBUG } #endif } void ProceduralMesh::set_index_data(const void* data, const uint64_t size) { #ifdef NOVA_DEBUG if(size > index_buffer_size) { logger->error( "Cannot upload index data. There's only space for %uz bytes, you tried to upload %uz. Truncating vertex data to fit", index_buffer_size, size); device->write_data_to_buffer(data, index_buffer_size, cached_index_buffer); num_index_bytes_to_upload = index_buffer_size; } else { #endif device->write_data_to_buffer(data, size, cached_index_buffer); num_index_bytes_to_upload = size; #ifdef NOVA_DEBUG } #endif } void ProceduralMesh::record_commands_to_upload_data(RhiRenderCommandList* cmds, const uint8_t frame_idx) const { const bool should_upload_vertex_buffer = num_vertex_bytes_to_upload > 0; const bool should_upload_index_buffer = num_index_bytes_to_upload > 0; auto* cur_vertex_buffer = vertex_buffers[frame_idx]; auto* cur_index_buffer = index_buffers[frame_idx]; std::vector<RhiResourceBarrier> barriers_before_upload; if(should_upload_vertex_buffer) { RhiResourceBarrier barrier_before_vertex_upload = {}; barrier_before_vertex_upload.resource_to_barrier = cur_vertex_buffer; barrier_before_vertex_upload.access_before_barrier = ResourceAccess::VertexAttributeRead; barrier_before_vertex_upload.access_after_barrier = ResourceAccess::MemoryWrite; barrier_before_vertex_upload.old_state = ResourceState::VertexBuffer; barrier_before_vertex_upload.new_state = ResourceState::CopyDestination; barrier_before_vertex_upload.source_queue = QueueType::Graphics; barrier_before_vertex_upload.destination_queue = QueueType::Graphics; barrier_before_vertex_upload.buffer_memory_barrier.offset = 0; barrier_before_vertex_upload.buffer_memory_barrier.size = num_vertex_bytes_to_upload; barriers_before_upload.push_back(barrier_before_vertex_upload); } if(should_upload_index_buffer) { RhiResourceBarrier barrier_before_index_upload = {}; barrier_before_index_upload.resource_to_barrier = cur_index_buffer; barrier_before_index_upload.access_before_barrier = ResourceAccess::IndexRead; barrier_before_index_upload.access_after_barrier = ResourceAccess::MemoryWrite; barrier_before_index_upload.old_state = ResourceState::IndexBuffer; barrier_before_index_upload.new_state = ResourceState::CopyDestination; barrier_before_index_upload.source_queue = QueueType::Graphics; barrier_before_index_upload.destination_queue = QueueType::Graphics; barrier_before_index_upload.buffer_memory_barrier.offset = 0; barrier_before_index_upload.buffer_memory_barrier.size = num_index_bytes_to_upload; barriers_before_upload.push_back(barrier_before_index_upload); } if(barriers_before_upload.is_empty()) { return; } cmds->resource_barriers(PipelineStage::VertexInput, PipelineStage::Transfer, barriers_before_upload); if(should_upload_vertex_buffer) { cmds->copy_buffer(cur_vertex_buffer, 0, cached_vertex_buffer, 0, num_vertex_bytes_to_upload); } if(should_upload_index_buffer) { cmds->copy_buffer(cur_index_buffer, 0, cached_index_buffer, 0, num_index_bytes_to_upload); } std::vector<RhiResourceBarrier> barriers_after_upload; if(should_upload_vertex_buffer) { RhiResourceBarrier barrier_after_vertex_upload = {}; barrier_after_vertex_upload.resource_to_barrier = cur_vertex_buffer; barrier_after_vertex_upload.access_before_barrier = ResourceAccess::MemoryWrite; barrier_after_vertex_upload.access_after_barrier = ResourceAccess::VertexAttributeRead; barrier_after_vertex_upload.old_state = ResourceState::CopyDestination; barrier_after_vertex_upload.new_state = ResourceState::VertexBuffer; barrier_after_vertex_upload.source_queue = QueueType::Graphics; barrier_after_vertex_upload.destination_queue = QueueType::Graphics; barrier_after_vertex_upload.buffer_memory_barrier.offset = 0; barrier_after_vertex_upload.buffer_memory_barrier.size = num_vertex_bytes_to_upload; barriers_after_upload.push_back(barrier_after_vertex_upload); } if(should_upload_index_buffer) { RhiResourceBarrier barrier_after_index_upload = {}; barrier_after_index_upload.resource_to_barrier = cur_index_buffer; barrier_after_index_upload.access_before_barrier = ResourceAccess::MemoryWrite; barrier_after_index_upload.access_after_barrier = ResourceAccess::IndexRead; barrier_after_index_upload.old_state = ResourceState::CopyDestination; barrier_after_index_upload.new_state = ResourceState::IndexBuffer; barrier_after_index_upload.source_queue = QueueType::Graphics; barrier_after_index_upload.destination_queue = QueueType::Graphics; barrier_after_index_upload.buffer_memory_barrier.offset = 0; barrier_after_index_upload.buffer_memory_barrier.size = num_index_bytes_to_upload; barriers_after_upload.push_back(barrier_after_index_upload); } if(barriers_after_upload.is_empty()) { return; } cmds->resource_barriers(PipelineStage::Transfer, PipelineStage::VertexInput, barriers_after_upload); } ProceduralMesh::Buffers ProceduralMesh::get_buffers_for_frame(const uint8_t frame_idx) const { auto* vertex_buffer = vertex_buffers[frame_idx]; auto* index_buffer = index_buffers[frame_idx]; return {vertex_buffer, index_buffer}; } } // namespace nova::renderer
10,710
C++
.cpp
192
42.807292
134
0.628042
NovaMods/nova-renderer
114
12
25
MPL-2.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
true
true
false
false
true
false
false
753,176
windows_utils.cpp
NovaMods_nova-renderer/src/util/windows_utils.cpp
#include "windows_utils.hpp" #include "nova_renderer/util/windows.hpp" #include "rx/core/string.h" std::wstring s2ws(const std::string& s) { const int slength = static_cast<int>(s.length()) + 1; const int len = MultiByteToWideChar(CP_ACP, 0, s.c_str(), slength, nullptr, 0); wchar_t* buf = new wchar_t[len]; MultiByteToWideChar(CP_ACP, 0, s.c_str(), slength, buf, len); std::wstring r(buf); delete[] buf; return r; } std::string get_last_windows_error() { const DWORD errorMessageID = GetLastError(); if(errorMessageID == 0) { return {}; // No error message has been recorded } LPSTR messageBuffer = nullptr; const size_t size = FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, nullptr, errorMessageID, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), reinterpret_cast<LPSTR>(&messageBuffer), 0, nullptr); std::string message(messageBuffer, size); // Free the buffer. LocalFree(messageBuffer); return message.c_str(); }
1,286
C++
.cpp
30
31.433333
131
0.574059
NovaMods/nova-renderer
114
12
25
MPL-2.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
true
true
false
false
true
false
false
753,178
linux_utils.cpp
NovaMods_nova-renderer/src/util/linux_utils.cpp
#include <array> #include <cstdlib> #include <iostream> #include <string> #include <cxxabi.h> #include <execinfo.h> void nova_backtrace() { std::array<void*, 50> array{}; // get void*'s for all entries on the stack int size = backtrace(array.data(), array.size()); // print out all the frames to stderr std::cerr << "Stacktrace: " << std::endl; char** data = backtrace_symbols(array.data(), size); for(int i = 0; i < size; i++) { std::string str(data[i]); if(str.find_last_of('(') != std::string::npos && str.find_last_of(')') != std::string::npos) { try { std::string path = str.substr(0, str.find_last_of('(')); std::string symbol = str.substr(str.find_last_of('(') + 1, str.find_last_of('+') - str.find_last_of('(') - 1); std::string address = str.substr(str.find_last_of('+'), str.find_last_of(')') - str.find_last_of('+')); std::string load_address = str.substr(str.find_last_of('[') + 1, str.find_last_of(']') - str.find_last_of('[')); if(!symbol.empty()) { char* name = abi::__cxa_demangle(symbol.data(), nullptr, nullptr, nullptr); str = std::string(path) + "(" + std::string(name ? name : symbol.c_str()) + std::string(address) + ") [" + load_address + "]"; // NOLINTNEXTLINE(cppcoreguidelines-no-malloc,cppcoreguidelines-owning-memory) free(name); } } catch(const std::exception& e) { std::cerr << "Demangle failed: " << e.what() << std::endl; } } if(str[str.size() - 1] == '\n') { str = str.substr(0, str.size() - 1); } std::cerr << "\t" << str << std::endl; } // NOLINTNEXTLINE(cppcoreguidelines-no-malloc,cppcoreguidelines-owning-memory) free(data); }
1,916
C++
.cpp
40
38.125
146
0.53244
NovaMods/nova-renderer
114
12
25
MPL-2.0
9/20/2024, 9:42:13 PM (Europe/Amsterdam)
false
false
true
false
false
true
false
false