Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • videolan/vlc
  • chouquette/vlc
  • bakiewicz.marek122/vlc
  • devnexen/vlc
  • rohanrajpal/vlc
  • blurrrb/vlc
  • gsoc/gsoc2019/darkapex/vlc
  • b1ue/vlc
  • fkuehne/vlc
  • magsoft/vlc
  • chub/vlc
  • cramiro9/vlc
  • robUx4/vlc
  • rom1v/vlc
  • akshayaky/vlc
  • tmk907/vlc
  • akymaster/vlc
  • govind.sharma/vlc
  • psilokos/vlc
  • xjbeta/vlc
  • jahan/vlc
  • 1480c1/vlc
  • amanchande/vlc
  • aaqib/vlc
  • rist/vlc
  • apol/vlc
  • mindfreeze/vlc
  • alexandre-janniaux/vlc
  • sandsmark/vlc
  • jagannatharjun/vlc
  • gsoc/gsoc2020/matiaslgonzalez/vlc
  • gsoc/gsoc2020/jagannatharjun/vlc
  • mstorsjo/vlc
  • gsoc/gsoc2020/vedenta/vlc
  • gsoc/gsoc2020/arnav-ishaan/vlc
  • gsoc/gsoc2020/andreduong/vlc
  • fuzun/vlc
  • gsoc/gsoc2020/vatsin/vlc
  • gsoc/gsoc2020/sagid/vlc
  • yaron/vlc
  • Phoenix/vlc
  • Garf/vlc
  • ePiratWorkarounds/vlc
  • tguillem/vlc
  • jnqnfe/vlc
  • mdc/vlc
  • Vedaa/vlc
  • rasa/vlc
  • quink/vlc
  • yealo/vlc
  • aleksey_ak/vlc
  • ePirat/vlc
  • ilya.yanok/vlc
  • asenat/vlc
  • m/vlc
  • bunjee/vlc
  • BLumia/vlc
  • sagudev/vlc
  • hamedmonji30/vlc
  • nullgemm/vlc
  • DivyamAhuja/vlc
  • thesamesam/vlc
  • dag7/vlc
  • snehil101/vlc
  • haasn/vlc
  • jbk/vlc
  • ValZapod/vlc
  • mfkl/vlc
  • WangChuan/vlc
  • core1024/vlc
  • GhostVaibhav/vlc
  • dfuhrmann/vlc
  • davide.prade/vlc
  • tmatth/vlc
  • Courmisch/vlc
  • zouya/vlc
  • hpi/vlc
  • EwoutH/vlc
  • aleung27/vlc
  • hengwu0/vlc
  • saladin/vlc
  • ashuio/vlc
  • richselwood/vlc
  • verma16Ayush/vlc
  • chemicalflash/vlc
  • PoignardAzur/vlc
  • huangjieNT/vlc
  • Blake-Haydon/vlc
  • AnuthaDev/vlc
  • gsoc/gsoc2021/mpd/vlc
  • nicolas_lequec/vlc
  • sambassaly/vlc
  • thresh/vlc
  • bonniegong/vlc
  • myaashish/vlc
  • stavros.vagionitis/vlc
  • ileoo/vlc
  • louis-santucci/vlc
  • cchristiansen/vlc
  • sabyasachi07/vlc
  • AbduAmeen/vlc
  • ashishb0410/vlc
  • urbanhusky/vlc
  • davidepietrasanta/vlc
  • riksleutelstad/vlc
  • jeremyVignelles/vlc
  • komh/vlc
  • iamjithinjohn/vlc
  • JohannesKauffmann/vlc2
  • kunglao/vlc
  • natzberg/vlc
  • jill/vlc
  • cwendling/vlc
  • adufou/vlc
  • ErwanAirone/vlc
  • HasinduDilshan10/vlc
  • vagrantc/vlc
  • rafiv/macos-bigsur-icon
  • Aymeriic/vlc
  • saranshg20/vlc
  • metzlove24/vlc
  • linkfanel/vlc
  • Ds886/vlc
  • metehan-arslan/vlc
  • Skantes/vlc
  • kgsandundananjaya96/vlc
  • mitchcapper/vlc
  • advaitgupta/vlc
  • StefanBruens/vlc
  • ratajs/vlc
  • T.M.F.B.3761/vlc
  • m222059/vlc
  • casemerrick/vlc
  • joshuaword2alt/vlc
  • sjwaddy/vlc
  • dima/vlc
  • Ybalrid/vlc
  • umxprime/vlc
  • eschmidt/vlc
  • vannieuwenhuysenmichelle/vlc
  • badcf00d/vlc
  • wesinator/vlc
  • louis/vlc
  • xqq/vlc
  • EmperorYP7/vlc
  • NicoLiam/vlc
  • loveleen/vlc
  • rofferom/vlc
  • rbultje/vlc
  • TheUnamed/vlc
  • pratiksharma341/vlc
  • Saurab17/vlc
  • purist.coder/vlc
  • Shuicheng/vlc
  • mdrrubel292/vlc
  • silverbleu00/vlc
  • metif12/vlc
  • asher-m/vlc
  • jeffk/vlc
  • Brandonbr1/vlc
  • beautyyuyanli/vlc
  • rego21/vlc
  • muyangren907/vlc
  • collectionbylawrencejason/vlc
  • evelez/vlc
  • GSMgeeth/vlc
  • Oneric/vlc
  • TJ5/vlc
  • XuanTung95/vlc
  • darrenjenny21/vlc
  • Trenly/vlc
  • RockyTDR/vlc
  • mjakubowski/vlc
  • caprica/vlc
  • ForteFrankie/vlc
  • seannamiller19/vlc
  • junlon2006/vlc
  • kiwiren6666/vlc
  • iuseiphonexs/vlc
  • fenngtun/vlc
  • Rajdutt999/vlc
  • typx/vlc
  • leon.vitanos/vlc
  • robertogarci0938/vlc
  • gsoc/gsoc2022/luc65r/vlc-mpd
  • skeller/vlc
  • MCJack123/vlc
  • luc65r/vlc-mpd
  • popov895/vlc
  • claucambra/vlc
  • brad/vlc
  • matthewmurua88/vlc
  • Tomas8874/vlc
  • philenotfound/vlc
  • makita-do3/vlc
  • LZXCorp/vlc
  • mar0x/vlc
  • senojetkennedy0102/vlc
  • shaneb243/vlc
  • ahmadbader/vlc
  • rajduttcse26/vlc-audio-filters
  • Juniorzito8415/vlc
  • achernyakov/vlc
  • lucasjetgroup/vlc
  • pupdoggy666/vlc
  • gmde9363/vlc
  • alexnwayne/vlc
  • bahareebrahimi781/vlc
  • hamad633666/vlc
  • umghof3112/vlc
  • joe0199771874/vlc
  • Octocats66666666/vlc
  • jjm_223/vlc
  • btech10110.19/vlc
  • sunnykfc028/vlc-audio-filters
  • loic/vlc
  • nguyenminhducmx1/vlc
  • JanekKrueger/vlc
  • bstubbington2/vlc
  • rcombs/vlc
  • Ordissimo/vlc
  • king7532/vlc
  • noobsauce101/vlc
  • schong0525/vlc
  • myQwil/vlc
  • apisbg91/vlc
  • geeboy0101017/vlc
  • kim.faughey/vlc
  • nurupo/vlc
  • yyusea/vlc
  • 0711235879.khco/vlc
  • ialo/vlc
  • iloveyeye2/vlc
  • gdtdftdqtd/vlc
  • leandroconsiglio/vlc
  • AndyHTML2012/vlc
  • ncz/vlc
  • lucenticus/vlc
  • knr1931/vlc
  • kjoonlee/vlc
  • chandrakant100/vlc-qt
  • johge42/vlc
  • polter/vlc
  • hexchain/vlc
  • Tushwrld/vlc
  • mztea928/vlc
  • jbelloncastro/vlc
  • alvinhochun/vlc
  • ghostpiratecrow/vlc
  • ujjwaltwitx/vlc
  • alexsonarin06/vlc
  • adrianbon76/vlc
  • altsod/vlc
  • damien.lucas44/vlc
  • dmytrivtaisa/vlc
  • utk202/vlc
  • aaxhrj/vlc
  • thomas.hermes/vlc
  • structurenewworldorder/vlc
  • slomo/vlc
  • wantlamy/vlc
  • musc.o3cminc/vlc
  • thebarshablog/vlc
  • kerrick/vlc
  • kratos142518/vlc
  • leogps/vlc
  • vacantron/vlc
  • luna_koly/vlc
  • Ratio2/vlc
  • anuoshemohammad/vlc
  • apsun/vlc
  • aaa1115910/vlc
  • alimotmoyo/vlc
  • Ambossmann/vlc
  • Sam-LearnsToCode/vlc
  • Chilledheart/vlc
  • Labnann/vlc
  • ktcoooot1/vlc
  • mohit-marathe/vlc
  • johnddx/vlc
  • manstabuk/vlc
  • Omar-ahmed314/vlc
  • vineethkm/vlc
  • 9Enemi86/vlc
  • radoslav.m.panteleev/vlc
  • ashishami2002/vlc
  • Corbax/vlc
  • firnasahmed/vlc
  • pelayarmalam4/vlc
  • c0ff330k/vlc
  • shikhindahikar/vlc
  • l342723951/vlc
  • christianschwandner/vlc
  • douniwan5788/vlc
  • 7damian7/vlc
  • ferdnyc/vlc
  • f.ales1/vlc
  • pandagby/vlc
  • BaaBaa/vlc
  • jewe37/vlc
  • w00drow/vlc
  • russelltg/vlc
  • ironicallygod/vlc
  • soumyaDghosh/vlc
  • linzihao1999/vlc
  • deyayush6/vlc
  • mibi88/vlc
  • newabdallah10/vlc
  • jhorbincolombia/vlc
  • rimvihaqueshupto/vlc
  • andrewkhon98/vlc
  • fab78/vlc
  • lapaz17/vlc
  • amanna13/vlc
  • mdakram28/vlc
  • 07jw1980/vlc
  • sohamgupta/vlc
  • Eson-Jia1/vlc
  • Sumou/vlc
  • vikram-kangotra/vlc
  • chalice191/vlc
  • olivercalder/vlc
  • aaasg4001/vlc
  • zipdox/vlc
  • kwizart/vlc
  • Dragon-S/vlc
  • jdemeule/vlc
  • gabriel_lt/vlc
  • locutusofborg/vlc
  • sammirata/vlc-librist
  • another/vlc
  • Benjamin_Loison/vlc
  • ahmedmoselhi/vlc
  • petergaal/vlc
  • huynhsontung/vlc
  • dariusmihut/vlc
  • tvermaashutosh/vlc
  • buti/vlc
  • Niram7777/vlc
  • rohan-here/vlc
  • balaji-sivasakthi/vlc
  • rlindner81/vlc
  • Kakadus/vlc
  • djain/vlc
  • ABBurmeister/vlc
  • craighuggins/vlc
  • orbea/vlc
  • maxos/vlc
  • aakarshmj/vlc
  • kblaschke/vlc
  • ankitm/vlc
  • advait-0/vlc
  • mohak2003/vlc
  • yselkowitz/vlc
  • AZM999/vlc-azm
  • andrey.turkin/vlc
  • Disha-Baghel/vlc
  • nowrep/vlc
  • Apeng/vlc
  • Choucroute_melba/vlc
  • autra/vlc
  • eclipseo/vlc
  • fhuber/vlc
  • olafhering/vlc
  • sdasda7777/vlc
  • 1div0/vlc
  • skosnits/vlc-extended-playlist-support
  • dnicolson/vlc
  • Timshel/vlc
  • octopols/vlc
  • MangalK/vlc
  • nima64/vlc
  • misawai/vlc
  • Alexander-Wilms/vlc
  • Maxime2/vlc-fork-for-visualizer
  • ww/vlc
  • jeske/vlc
  • sgross-emlix/vlc
  • morenonatural/vlc
  • freakingLovesVLC/vlc
  • borisgolovnev/vlc
  • mpromonet/vlc
  • diogo.simao-marques/vlc
  • masstock/vlc
  • pratikpatel8982/vlc
  • hugok79/vlc
  • longervision/vlc
  • abhiudaysurya/vlc
  • rishabhgarg/vlc
  • tumic/vlc
  • cart/vlc
  • shubham442/vlc
  • Aditya692005/vlc
  • sammirata/vlc4
  • syrykh/vlc
  • Vvorcun/macos-new-icon
  • AyaanshC/vlc
  • nasso/vlc
  • Quark/vlc
  • sebastinas/vlc
  • rhstone/vlc
  • talregev/vlc
  • Managor/vlc
403 results
Show changes
Commits on Source (4)
......@@ -141,12 +141,24 @@ void FirstRunWizard::finish()
config_PutInt( "qt-pin-controls", ui.layoutGroup->checkedId() );
ControlbarProfileModel* controlbarModel = p_intf->p_mi->controlbarProfileModel();
assert(controlbarModel);
if( ui.layoutGroup->checkedId() )
controlbarModel->setSelectedProfileFromId(ControlbarProfileModel::CLASSIC_STYLE);
else
controlbarModel->setSelectedProfileFromId(ControlbarProfileModel::DEFAULT_STYLE);
{
ControlbarProfileModel* controlbarModel = p_intf->p_mi->controlbarProfileModel();
assert(controlbarModel);
ControlbarProfileModel::Style style;
if( ui.layoutGroup->checkedId() )
style = ControlbarProfileModel::Style::CLASSIC_STYLE;
else
style = ControlbarProfileModel::Style::DEFAULT_STYLE;
std::unique_ptr<ControlbarProfile> profile( controlbarModel->generateProfileFromStyle( style ) );
assert( profile );
const std::optional<int> index = controlbarModel->findModel( profile.get() );
if( index )
controlbarModel->setSelectedProfile( *index );
else
controlbarModel->insertProfile( std::move( profile ), true );
}
/* Commit changes to the scanned folders for the Media Library */
if( vlc_ml_instance_get( p_intf ) && mlFoldersEditor )
......@@ -311,7 +323,6 @@ void FirstRunWizard::reject()
config_PutInt( "qt-menubar", 0 );
config_PutInt( "qt-titlebar", 0 );
p_intf->p_mi->setPinVideoControls( 0 );
p_intf->p_mi->controlbarProfileModel()->setSelectedProfileFromId(ControlbarProfileModel::DEFAULT_STYLE);
/* Folders Page settings */
if ( mlFoldersEditor )
......
......@@ -23,85 +23,9 @@
#include "player/player_controlbar_model.hpp"
decltype(ControlbarProfile::m_defaults)
ControlbarProfile::m_defaults =
{
{
PlayerControlbarModel::Videoplayer,
{
{
{
ControlListModel::LANG_BUTTON,
ControlListModel::BOOKMARK_BUTTON,
ControlListModel::EXTENDED_BUTTON,
ControlListModel::NAVIGATION_BUTTONS
},
{
ControlListModel::SKIP_BACK_BUTTON,
ControlListModel::PREVIOUS_BUTTON,
ControlListModel::PLAY_BUTTON,
ControlListModel::NEXT_BUTTON,
ControlListModel::SKIP_FW_BUTTON
},
{
ControlListModel::VOLUME,
ControlListModel::RENDERER_BUTTON,
ControlListModel::FULLSCREEN_BUTTON
}
}
}
},
{
PlayerControlbarModel::Audioplayer,
{
{
{
ControlListModel::LANG_BUTTON,
ControlListModel::BOOKMARK_BUTTON,
ControlListModel::EXTENDED_BUTTON
},
{
ControlListModel::RANDOM_BUTTON,
ControlListModel::PREVIOUS_BUTTON,
ControlListModel::PLAY_BUTTON,
ControlListModel::NEXT_BUTTON,
ControlListModel::LOOP_BUTTON
},
{
ControlListModel::VOLUME,
ControlListModel::RENDERER_BUTTON,
ControlListModel::FULLSCREEN_BUTTON
}
}
}
},
{
PlayerControlbarModel::Miniplayer,
{
{
{
ControlListModel::ARTWORK_INFO
},
{
ControlListModel::RANDOM_BUTTON,
ControlListModel::PREVIOUS_BUTTON,
ControlListModel::PLAY_BUTTON,
ControlListModel::NEXT_BUTTON,
ControlListModel::LOOP_BUTTON
},
{
ControlListModel::VOLUME,
ControlListModel::PLAYER_SWITCH_BUTTON
}
}
}
}
};
ControlbarProfile::ControlbarProfile(QObject *parent) : QObject(parent)
{
injectDefaults();
}
PlayerControlbarModel *ControlbarProfile::newModel(int identifier)
......@@ -189,16 +113,6 @@ void ControlbarProfile::setName(const QString &name)
emit nameChanged(m_name);
}
void ControlbarProfile::setId( const int id )
{
if(id == m_id)
return;
m_id = id;
emit idChanged(m_id);
}
bool ControlbarProfile::dirty() const
{
return (m_dirty > 0);
......@@ -209,17 +123,31 @@ QString ControlbarProfile::name() const
return m_name;
}
int ControlbarProfile::id() const
bool ControlbarProfile::operator==(const ControlbarProfile &model) const
{
return m_id;
}
if (m_models.count() != model.m_models.count())
return false;
void ControlbarProfile::injectDefaults(bool resetDirty)
{
injectModel(m_defaults);
if (m_models != model.m_models)
{
// Deep comparison
QMapIterator<int, PlayerControlbarModel *> i(m_models);
while (i.hasNext())
{
i.next();
if (!model.m_models.contains(i.key()))
return false;
assert(model.m_models[i.key()]);
assert(i.value());
if (*model.m_models[i.key()] != *i.value())
return false;
}
}
if (resetDirty)
this->resetDirty(); // defaults normally should not make the profile dirty
return true;
}
void ControlbarProfile::injectModel(const QVector<ControlbarProfile::Configuration> &modelData)
......
......@@ -33,7 +33,6 @@ class ControlbarProfile : public QObject
Q_PROPERTY(bool dirty READ dirty RESET resetDirty NOTIFY dirtyChanged FINAL)
Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged FINAL)
Q_PROPERTY(int profileId READ id WRITE setId NOTIFY idChanged FINAL)
friend class ControlbarProfileModel;
......@@ -48,21 +47,17 @@ public:
void deleteModel(int identifier);
Q_INVOKABLE void injectDefaults(bool resetDirty = true);
bool dirty() const;
QString name() const;
// The id is a unique number supplied to each profile
// which differentiates it independently from its index
// in the profiles array. Provides a more stable way to
// identify a profile than using its name.
int id() const;
bool operator==(const ControlbarProfile& model) const;
bool operator!=(const ControlbarProfile& model) const {
return !(operator==(model));
}
public slots:
void resetDirty();
void setName(const QString& name);
void setId( const int id );
private:
// m_dirty indicates the count of PlayerControlbarModel
......@@ -70,8 +65,7 @@ private:
// set true.
int m_dirty = 0;
int m_id = -1;
QString m_name {"N/A"};
QString m_name = QStringLiteral("N/A");
bool m_pauseControlListGeneration = false;
// According to benchmarks, QMap performs better than
......@@ -84,7 +78,6 @@ private:
int identifier;
std::array<QVector<int>, 3> data;
};
static const QVector<Configuration> m_defaults;
private:
void injectModel(const QVector<Configuration>& modelData);
......@@ -95,7 +88,6 @@ private slots:
signals:
void dirtyChanged(bool dirty);
void nameChanged(QString name);
void idChanged(int id);
void controlListChanged(const QVector<int>& linearControlList);
};
......
......@@ -29,7 +29,6 @@
#define SETTINGS_ARRAYNAME_PROFILES "Profiles"
#define SETTINGS_KEY_NAME "Name"
#define SETTINGS_KEY_MODEL "Model"
#define SETTINGS_KEY_ID "Id"
#define SETTINGS_CONTROL_SEPARATOR QChar(',')
#define SETTINGS_CONFIGURATION_SEPARATOR QChar('|')
......@@ -39,7 +38,83 @@ decltype (ControlbarProfileModel::m_defaults)
ControlbarProfileModel::m_defaults =
{
{
MINIMALIST_STYLE,
Style::DEFAULT_STYLE,
N_("Default Style"),
{
{
PlayerControlbarModel::Videoplayer,
{
{
{
ControlListModel::LANG_BUTTON,
ControlListModel::BOOKMARK_BUTTON,
ControlListModel::EXTENDED_BUTTON,
ControlListModel::NAVIGATION_BUTTONS
},
{
ControlListModel::SKIP_BACK_BUTTON,
ControlListModel::PREVIOUS_BUTTON,
ControlListModel::PLAY_BUTTON,
ControlListModel::NEXT_BUTTON,
ControlListModel::SKIP_FW_BUTTON
},
{
ControlListModel::VOLUME,
ControlListModel::RENDERER_BUTTON,
ControlListModel::FULLSCREEN_BUTTON
}
}
}
},
{
PlayerControlbarModel::Audioplayer,
{
{
{
ControlListModel::LANG_BUTTON,
ControlListModel::BOOKMARK_BUTTON,
ControlListModel::EXTENDED_BUTTON
},
{
ControlListModel::RANDOM_BUTTON,
ControlListModel::PREVIOUS_BUTTON,
ControlListModel::PLAY_BUTTON,
ControlListModel::NEXT_BUTTON,
ControlListModel::LOOP_BUTTON
},
{
ControlListModel::VOLUME,
ControlListModel::RENDERER_BUTTON,
ControlListModel::FULLSCREEN_BUTTON
}
}
}
},
{
PlayerControlbarModel::Miniplayer,
{
{
{
ControlListModel::ARTWORK_INFO
},
{
ControlListModel::RANDOM_BUTTON,
ControlListModel::PREVIOUS_BUTTON,
ControlListModel::PLAY_BUTTON,
ControlListModel::NEXT_BUTTON,
ControlListModel::LOOP_BUTTON
},
{
ControlListModel::VOLUME,
ControlListModel::PLAYER_SWITCH_BUTTON
}
}
}
}
}
},
{
Style::MINIMALIST_STYLE,
N_("Minimalist Style"),
{
{
......@@ -107,7 +182,7 @@ decltype (ControlbarProfileModel::m_defaults)
}
},
{
ONE_LINER_STYLE,
Style::ONE_LINER_STYLE,
N_("One-liner Style"),
{
{
......@@ -185,7 +260,7 @@ decltype (ControlbarProfileModel::m_defaults)
}
},
{
SIMPLEST_STYLE,
Style::SIMPLEST_STYLE,
N_("Simplest Style"),
{
{
......@@ -242,7 +317,7 @@ decltype (ControlbarProfileModel::m_defaults)
}
},
{
CLASSIC_STYLE,
Style::CLASSIC_STYLE,
N_("Classic Style"),
{
{
......@@ -359,15 +434,10 @@ ControlbarProfileModel::ControlbarProfileModel(qt_intf_t *p_intf, QObject *paren
void ControlbarProfileModel::insertDefaults()
{
// First, add a blank new profile:
// ControlbarProfile will inject the default configurations during its construction.
m_maxId = 0;
newProfile(tr("Default Profile"), DEFAULT_STYLE);
// Add default profiles:
for (const auto& i : m_defaults)
{
const auto ptrNewProfile = newProfile(qfut(i.name), i.id);
const auto ptrNewProfile = newProfile(qfut(i.name));
if (!ptrNewProfile)
continue;
......@@ -562,18 +632,6 @@ ControlbarProfile* ControlbarProfileModel::currentModel() const
return getProfile(selectedProfile());
}
/* Set the selected profile to the profile with the matching id */
bool ControlbarProfileModel::setSelectedProfileFromId(int id)
{
for(int i = 0; i < rowCount(); i++)
{
if(id == m_profiles.at(i)->id())
return setSelectedProfile(i);
}
return false;
}
void ControlbarProfileModel::save(bool clearDirty) const
{
assert(m_intf);
......@@ -633,7 +691,6 @@ void ControlbarProfileModel::save(bool clearDirty) const
settings->setValue(SETTINGS_KEY_NAME, m_profiles.at(i)->name());
settings->setValue(SETTINGS_KEY_MODEL, val);
settings->setValue(SETTINGS_KEY_ID, m_profiles.at(i)->id());
}
settings->endArray();
......@@ -681,7 +738,6 @@ bool ControlbarProfileModel::reload()
const auto ptrNewProfile = new ControlbarProfile(this);
ptrNewProfile->setName(settings->value(SETTINGS_KEY_NAME).toString());
ptrNewProfile->setId(settings->value(SETTINGS_KEY_ID).toInt());
for (auto j : val)
{
......@@ -737,7 +793,6 @@ bool ControlbarProfileModel::reload()
bool ok = false;
int index = settings->value(SETTINGS_KEY_SELECTEDPROFILE).toInt(&ok);
m_maxId = m_profiles.isEmpty() ? 0 : m_profiles.back()->id() + 1;
if (ok)
setSelectedProfile(index);
......@@ -780,6 +835,38 @@ bool ControlbarProfileModel::setSelectedProfile(int selectedProfile)
return true;
}
std::optional<int> ControlbarProfileModel::findModel(const ControlbarProfile *profile) const
{
assert(profile);
for (int i = 0; i < m_profiles.count(); ++i)
{
if (m_profiles[i] == profile)
return i;
else
{
assert(m_profiles[i]);
if (*m_profiles[i] == *profile)
return i;
}
}
return std::nullopt;
}
void ControlbarProfileModel::insertProfile(std::unique_ptr<ControlbarProfile> profile, bool select)
{
assert(profile);
const auto ptrProfile = profile.release();
ptrProfile->setParent(this);
beginInsertRows(QModelIndex(), m_profiles.size(), m_profiles.size());
m_profiles.append(ptrProfile);
endInsertRows();
if (select)
setSelectedProfile(m_profiles.count() - 1);
}
ControlbarProfile *ControlbarProfileModel::getProfile(int index) const
{
if (index < 0 || index >= m_profiles.size())
......@@ -788,7 +875,7 @@ ControlbarProfile *ControlbarProfileModel::getProfile(int index) const
return m_profiles.at(index);
}
ControlbarProfile *ControlbarProfileModel::newProfile(const QString &name, const int id)
ControlbarProfile *ControlbarProfileModel::newProfile(const QString &name)
{
if (name.isEmpty())
return nullptr;
......@@ -796,8 +883,6 @@ ControlbarProfile *ControlbarProfileModel::newProfile(const QString &name, const
const auto ptrProfile = newProfile();
ptrProfile->setName(generateUniqueName(name));
ptrProfile->setId(id);
m_maxId++;
return ptrProfile;
}
......@@ -817,8 +902,7 @@ ControlbarProfile *ControlbarProfileModel::newProfile()
ControlbarProfile *ControlbarProfileModel::cloneProfile(const ControlbarProfile *profile)
{
// Any new profiles will just have the next incremental id
const auto ptrNewProfile = newProfile(profile->name(), m_maxId);
const auto ptrNewProfile = newProfile(profile->name());
if (!ptrNewProfile)
return nullptr;
......@@ -876,3 +960,21 @@ void ControlbarProfileModel::deleteSelectedProfile()
else
setSelectedProfile(_selectedProfile);
}
ControlbarProfile *ControlbarProfileModel::generateProfileFromStyle(const Style style)
{
for (const auto& i : m_defaults)
{
if (i.id == style)
{
const auto ptrNewProfile = new ControlbarProfile();
ptrNewProfile->injectModel(i.modelData);
ptrNewProfile->setName(i.name);
ptrNewProfile->resetDirty(); // default profiles should not be dirty initially
return ptrNewProfile;
}
}
// Style does not exist
return nullptr;
}
......@@ -42,7 +42,15 @@ public:
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
QHash<int, QByteArray> roleNames() const override;
enum {DEFAULT_STYLE, MINIMALIST_STYLE, ONE_LINER_STYLE, SIMPLEST_STYLE, CLASSIC_STYLE};
enum class Style
{
DEFAULT_STYLE,
MINIMALIST_STYLE,
ONE_LINER_STYLE,
SIMPLEST_STYLE,
CLASSIC_STYLE
};
// Editable:
Q_INVOKABLE bool setData(const QModelIndex &index, const QVariant &value,
......@@ -63,24 +71,32 @@ public:
int selectedProfile() const;
ControlbarProfile* currentModel() const;
bool setSelectedProfileFromId(int id);
ControlbarProfile* cloneProfile(const ControlbarProfile* profile);
Q_INVOKABLE void cloneSelectedProfile(const QString& newProfileName);
Q_INVOKABLE ControlbarProfile* getProfile(int index) const;
Q_INVOKABLE ControlbarProfile* newProfile(const QString& name, const int id);
Q_INVOKABLE ControlbarProfile* newProfile(const QString& name);
ControlbarProfile* newProfile();
Q_INVOKABLE void deleteSelectedProfile();
// This is a static method, caller takes the ownership
// of the profile:
static ControlbarProfile* generateProfileFromStyle(const Style style);
// ControlbarProfileModel takes the ownership:
void insertProfile(std::unique_ptr<ControlbarProfile> profile, bool select);
public slots:
void save(bool clearDirty = true) const;
bool reload();
bool setSelectedProfile(int selectedProfile);
std::optional<int> findModel(const ControlbarProfile* profile) const;
signals:
void countChanged();
void selectedProfileChanged();
......@@ -91,10 +107,9 @@ private:
QVector<ControlbarProfile *> m_profiles;
int m_selectedProfile = -1;
int m_maxId = 0;
struct Profile {
const int id;
const Style id;
const char* name;
QVector<ControlbarProfile::Configuration> modelData;
};
......
......@@ -157,17 +157,6 @@ WindowDialog {
}
}
Widgets.IconToolButton {
id: useDefaultButton
description: qsTr("Use Default")
text: VLCIcons.history
onClicked: {
MainCtx.controlbarProfileModel.currentModel.injectDefaults(false)
}
}
Widgets.IconToolButton {
description: qsTr("Delete the current profile")
text: VLCIcons.del
......
......@@ -102,6 +102,16 @@ public:
QVector<int> getControls() const;
void setControls(const QVector<int>& list);
bool operator==(const ControlListModel& model) const
{
return m_controls == model.m_controls;
}
bool operator!=(const ControlListModel& model) const
{
return !(operator==(model));
}
signals:
void countChanged();
......
......@@ -126,6 +126,26 @@ ControlListModel *PlayerControlbarModel::right() const
return m_right;
}
bool PlayerControlbarModel::operator==(const PlayerControlbarModel &model) const
{
assert(m_left && model.m_left);
assert(m_center && model.m_center);
assert(m_right && model.m_right);
// Deep comparison
if (*m_left != *model.m_left)
return false;
if (*m_center != *model.m_center)
return false;
if (*m_right != *model.m_right)
return false;
return true;
}
void PlayerControlbarModel::setDirty(bool dirty)
{
if (m_dirty == dirty)
......
......@@ -80,6 +80,11 @@ public:
ControlListModel* center() const;
ControlListModel* right() const;
bool operator==(const PlayerControlbarModel& model) const;
bool operator!=(const PlayerControlbarModel& model) const {
return !(operator==(model));
}
public slots:
void setDirty(bool dirty);
......