LeechCraft 0.6.70-16373-g319c272718
Modular cross-platform feature rich live environment.
Loading...
Searching...
No Matches
unhidelistviewbase.cpp
Go to the documentation of this file.
1/**********************************************************************
2 * LeechCraft - modular cross-platform feature rich internet client.
3 * Copyright (C) 2006-2014 Georg Rudoy
4 *
5 * Distributed under the Boost Software License, Version 1.0.
6 * (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
7 **********************************************************************/
8
10#include <QQmlContext>
11#include <QQuickItem>
12#include <QtDebug>
16#include <util/sys/paths.h>
18#include <util/qml/util.h>
19
20namespace LC::Util
21{
23 const std::function<void (UnhideListModel*)>& filler, QWidget *parent)
24 : QQuickWidget (parent)
25 , Model_ (new UnhideListModel (this))
26 {
27 new UnhoverDeleteMixin (this);
28
29 if (filler)
30 filler (Model_);
31
32 const auto& file = GetSysPath (SysPath::QML, QStringLiteral ("common"), QStringLiteral ("UnhideListView.qml"));
33 if (file.isEmpty ())
34 {
35 qWarning () << Q_FUNC_INFO
36 << "file not found";
37 deleteLater ();
38 return;
39 }
40
41 setWindowFlags (Qt::ToolTip);
43
44 for (const auto& cand : GetPathCandidates (SysPath::QML, {}))
45 engine ()->addImportPath (cand);
46
47 rootContext ()->setContextProperty (QStringLiteral ("unhideListModel"), Model_);
48 rootContext ()->setContextProperty (QStringLiteral ("colorProxy"),
49 new Util::ColorThemeProxy (proxy->GetColorThemeManager (), this));
50 engine ()->addImageProvider (QStringLiteral ("ThemeIcons"), new Util::ThemeImageProvider (proxy));
51 setSource (QUrl::fromLocalFile (file));
52
53 connect (rootObject (),
54 SIGNAL (closeRequested ()),
55 this,
56 SLOT (deleteLater ()));
57 connect (rootObject (),
58 SIGNAL (itemUnhideRequested (QString)),
59 this,
60 SIGNAL (itemUnhideRequested (QString)));
61 }
62
64 {
65 Model_->invisibleRootItem ()->appendRows (items);
66 }
67}
virtual IColorThemeManager * GetColorThemeManager() const =0
Returns the color theme manager.
Proxy for QML files to use colors from current color theme.
Provides icons from the current theme by their FDO name.
A model to be used with UnhideListViewBase.
UnhideListViewBase(const ICoreProxy_ptr &proxy, const std::function< void(UnhideListModel *)> &modelFiller, QWidget *parent=nullptr)
Initializes the view and fills it with the items.
void itemUnhideRequested(const QString &itemId)
Emitted when an item with the given itemId is activated.
UnhideListModel *const Model_
void SetItems(const QList< QStandardItem * > &items)
Sets the items of the view model to items.
Allows to hide a widget or popup after mouse leave.
std::shared_ptr< ICoreProxy > ICoreProxy_ptr
Definition icoreproxy.h:181
void EnableTransparency(QQuickWidget &widget)
Definition util.cpp:17
QString GetSysPath(SysPath path, const QString &suffix, const QString &filename)
Returns path to the file in the given root path and subfolder.
Definition paths.cpp:56
QStringList GetPathCandidates(SysPath path, QString suffix)
Returns possible full paths for the path and subfolder.
Definition paths.cpp:24
@ QML
Root path for QML files.