コード例 #1
0
	DeclarativeWindow::DeclarativeWindow (const QUrl& url, QVariantMap params,
			const QPoint& orig, ViewManager *viewMgr, ICoreProxy_ptr proxy, QWidget *parent)
	: QDeclarativeView (parent)
	{
		new Util::AutoResizeMixin (orig, [viewMgr] () { return viewMgr->GetFreeCoords (); }, this);

		if (!params.take ("keepOnFocusLeave").toBool ())
			new Util::UnhoverDeleteMixin (this, SLOT (beforeDelete ()));

		setStyleSheet ("background: transparent");
		setWindowFlags (Qt::Tool | Qt::FramelessWindowHint);
		setAttribute (Qt::WA_TranslucentBackground);

		for (const auto& cand : Util::GetPathCandidates (Util::SysPath::QML, ""))
			engine ()->addImportPath (cand);

		rootContext ()->setContextProperty ("colorProxy",
				new Util::ColorThemeProxy (proxy->GetColorThemeManager (), this));
		for (const auto& key : params.keys ())
			rootContext ()->setContextProperty (key, params [key]);
		engine ()->addImageProvider ("ThemeIcons", new Util::ThemeImageProvider (proxy));
		setSource (url);

		connect (rootObject (),
				SIGNAL (closeRequested ()),
				this,
				SLOT (deleteLater ()));
	}
コード例 #2
0
ファイル: viewmanager.cpp プロジェクト: mirok0/leechcraft
	ViewManager::ViewManager (ICoreProxy_ptr proxy, Util::ShortcutManager *shortcutMgr, QMainWindow *window, QObject *parent)
	: QObject (parent)
	, Proxy_ (proxy)
	, ViewItemsModel_ (new ViewItemsModel (this))
	, View_ (new SBView)
	, Toolbar_ (new QToolBar (tr ("SB2 panel")))
	, Window_ (window)
	, IsDesktopMode_ (qApp->arguments ().contains ("--desktop"))
	, OnloadWindowIndex_ (GetWindowIndex ())
	, SettingsManager_ (new ViewSettingsManager (this))
	, GeomManager_ (new ViewGeometryManager (this))
	{
		const auto& file = Util::GetSysPath (Util::SysPath::QML, "sb2", "SideView.qml");
		if (file.isEmpty ())
		{
			qWarning () << Q_FUNC_INFO
					<< "file not found";
			return;
		}

		new ViewPropsManager (this, SettingsManager_, this);

		for (const auto& cand : Util::GetPathCandidates (Util::SysPath::QML, ""))
			View_->engine ()->addImportPath (cand);

		View_->rootContext ()->setContextProperty ("itemsModel", ViewItemsModel_);
		View_->rootContext ()->setContextProperty ("quarkProxy", new QuarkProxy (this, proxy, this));
		View_->rootContext ()->setContextProperty ("colorProxy",
				new Util::ColorThemeProxy (proxy->GetColorThemeManager (), this));
		View_->rootContext ()->setContextProperty ("SB2_settingsModeTooltip", tr ("Settings mode"));
		View_->rootContext ()->setContextProperty ("SB2_quarkOrderTooltip", tr ("Quarks order"));
		View_->rootContext ()->setContextProperty ("SB2_addQuarkTooltip", tr ("Add quark"));
		View_->rootContext ()->setContextProperty ("SB2_showPanelSettingsTooltip", tr ("Show panel settings"));
		View_->rootContext ()->setContextProperty ("quarkContext", "panel_" + QString::number (GetWindowIndex ()));
		View_->engine ()->addImageProvider (ImageProviderID, new Util::ThemeImageProvider (proxy));

		Toolbar_->addWidget (View_);
		View_->setVisible (true);

		GeomManager_->Manage ();

		View_->setSource (QUrl::fromLocalFile (file));

		LoadRemovedList ();
		LoadQuarkOrder ();

		auto toggleAct = Toolbar_->toggleViewAction ();
		toggleAct->setProperty ("ActionIcon", "layer-visible-on");
		toggleAct->setShortcut (QString ("Ctrl+J,S"));
		shortcutMgr->RegisterAction ("TogglePanel", toggleAct);

		window->addAction (toggleAct);
	}
コード例 #3
0
	TabUnhideListView::TabUnhideListView (const QList<TabClassInfo>& tcs, ICoreProxy_ptr proxy, QWidget *parent)
	: QDeclarativeView (parent)
	, Model_ (new UnhideListModel (this))
	{
		new Util::UnhoverDeleteMixin (this);

		const auto& file = Util::GetSysPath (Util::SysPath::QML, "sb2", "TabUnhideListView.qml");
		if (file.isEmpty ())
		{
			qWarning () << Q_FUNC_INFO
					<< "file not found";
			deleteLater ();
			return;
		}

		setStyleSheet ("background: transparent");
		setWindowFlags (Qt::ToolTip);
		setAttribute (Qt::WA_TranslucentBackground);

		rootContext ()->setContextProperty ("unhideListModel", Model_);
		rootContext ()->setContextProperty ("colorProxy",
				new Util::ColorThemeProxy (proxy->GetColorThemeManager (), this));
		engine ()->addImageProvider ("ThemeIcons", new ThemeImageProvider (proxy));
		setSource (QUrl::fromLocalFile (file));

		for (const auto& tc : tcs)
		{
			auto item = new QStandardItem;
			item->setData (tc.TabClass_, UnhideListModel::Roles::TabClass);
			item->setData (tc.VisibleName_, UnhideListModel::Roles::TabName);
			item->setData (tc.Description_, UnhideListModel::Roles::TabDescription);
			item->setData (Util::GetAsBase64Src (tc.Icon_.pixmap (32, 32).toImage ()),
					UnhideListModel::Roles::TabIcon);
			Model_->appendRow (item);
		}

		connect (rootObject (),
				SIGNAL (closeRequested ()),
				this,
				SLOT (deleteLater ()));
		connect (rootObject (),
				SIGNAL (tabUnhideRequested (QString)),
				this,
				SLOT (unhide (QString)),
				Qt::QueuedConnection);
	}
コード例 #4
0
ファイル: maillistview.cpp プロジェクト: devel29a/leechcraft
	MailListView::MailListView (const ConvInfos_t& infos, ICoreProxy_ptr proxy, QWidget *parent)
	: QQuickWidget (parent)
	, Model_ (new MailListModel (this))
	{
		new Util::UnhoverDeleteMixin (this);

		const auto& file = Util::GetSysPath (Util::SysPath::QML, "gmailnotifier", "MailListView.qml");
		if (file.isEmpty ())
		{
			qWarning () << Q_FUNC_INFO
					<< "file not found";
			deleteLater ();
			return;
		}

		const auto& now = QDateTime::currentDateTime ();
		for (const auto& info : infos)
		{
			auto item = new QStandardItem;
			item->setData (info.Title_, MailListModel::Roles::Subject);
			item->setData (info.AuthorEmail_, MailListModel::Roles::AuthorEmail);
			item->setData (info.AuthorName_, MailListModel::Roles::AuthorName);
			item->setData (info.Summary_, MailListModel::Roles::Summary);

			QString dateString;
			if (info.Modified_.secsTo (now) < 12 * 60 * 60)
				dateString = info.Modified_.time ().toString ("hh:mm");
			else if (now.date ().day () == info.Modified_.date ().day () - 1)
				dateString = tr ("Yesterday, %1").arg (info.Modified_.time ().toString ());
			else if (now.date ().year () == info.Modified_.date ().year ())
				dateString = info.Modified_.date ().toString ("d MMM");
			else
				dateString = info.Modified_.date ().toString (Qt::DefaultLocaleShortDate);
			item->setData (dateString, MailListModel::Roles::ModifiedDate);
			Model_->appendRow (item);
		}

		setStyleSheet ("background: transparent");
		setWindowFlags (Qt::ToolTip);
		setAttribute (Qt::WA_TranslucentBackground);

		rootContext ()->setContextProperty ("mailListModel", Model_);
		rootContext ()->setContextProperty ("colorProxy",
				new Util::ColorThemeProxy (proxy->GetColorThemeManager (), this));
		setSource (QUrl::fromLocalFile (file));
	}
コード例 #5
0
	UnhideListViewBase::UnhideListViewBase (ICoreProxy_ptr proxy, QWidget *parent)
	: QDeclarativeView (parent)
	, Model_ (new UnhideListModel (this))
	{
		new UnhoverDeleteMixin (this);

		const auto& file = GetSysPath (SysPath::QML, "common", "UnhideListView.qml");
		if (file.isEmpty ())
		{
			qWarning () << Q_FUNC_INFO
					<< "file not found";
			deleteLater ();
			return;
		}

		setStyleSheet ("background: transparent");
		setWindowFlags (Qt::ToolTip);
		setAttribute (Qt::WA_TranslucentBackground);

		for (const auto& cand : GetPathCandidates (SysPath::QML, ""))
			engine ()->addImportPath (cand);

		rootContext ()->setContextProperty ("unhideListModel", Model_);
		rootContext ()->setContextProperty ("colorProxy",
				new Util::ColorThemeProxy (proxy->GetColorThemeManager (), this));
		engine ()->addImageProvider ("ThemeIcons", new Util::ThemeImageProvider (proxy));
		setSource (QUrl::fromLocalFile (file));

		connect (rootObject (),
				SIGNAL (closeRequested ()),
				this,
				SLOT (deleteLater ()));
		connect (rootObject (),
				SIGNAL (itemUnhideRequested (QString)),
				this,
				SIGNAL (itemUnhideRequested (QString)));
	}