Beispiel #1
0
	void Plugin::hookRemovingDockAction (IHookProxy_ptr,
			QMainWindow *win, QAction *act, Qt::DockWidgetArea area)
	{
		auto rootWM = Proxy_->GetRootWindowsManager ();
		const int idx = rootWM->GetWindowIndex (win);

		Managers_ [idx].Dock_->RemoveAction (act);
	}
Beispiel #2
0
	void Plugin::hookAddingDockAction (IHookProxy_ptr,
			QMainWindow *win, QAction *act, Qt::DockWidgetArea area)
	{
		auto rootWM = Proxy_->GetRootWindowsManager ();
		const int idx = rootWM->GetWindowIndex (win);

		Managers_ [idx].Dock_->AddActions ({ act }, TrayComponent::ActionPos::Beginning);
	}
Beispiel #3
0
void SetMenuCheckedState(HMENU menu, int did, int id)
{
    MENUITEMINFO info;
    info.cbSize = sizeof(MENUITEMINFO);
    info.fMask = MIIM_STATE;
    GetMenuItemInfo(menu, id, MF_BYCOMMAND, &info);
    info.fState = (info.fState &~MFS_CHECKED) | (GetWindowIndex(did) == -1 ? 0 :
        MFS_CHECKED);
    SetMenuItemInfo(menu, id, MF_BYCOMMAND, &info);
}
Beispiel #4
0
	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);
	}
Beispiel #5
0
std::shared_ptr<QSettings> ViewManager::GetSettings () const
{
    const auto subSet = GetWindowIndex () || IsDesktopMode_;

    const auto& org = QCoreApplication::organizationName ();
    const auto& app = QCoreApplication::applicationName () + "_SB2";
    std::shared_ptr<QSettings> result (new QSettings (org, app),
                                       [subSet] (QSettings *settings)
    {
        if (subSet)
            settings->endGroup ();
        delete settings;
    });

    if (subSet)
        result->beginGroup (QString ("%1_%2")
                            .arg (OnloadWindowIndex_)
                            .arg (IsDesktopMode_));

    return result;
}
Beispiel #6
0
int ViewManager::GetWindowIndex () const
{
    auto rootWM = Proxy_->GetRootWindowsManager ();
    return rootWM->GetWindowIndex (Window_);
}
	QMenu* SeparateTabWidget::GetTabMenu (int index)
	{
		QMenu *menu = new QMenu ();

		const auto widget = Widget (index);
		const auto imtw = qobject_cast<ITabWidget*> (widget);

		if (XmlSettingsManager::Instance ()->
				property ("ShowPluginMenuInTabs").toBool ())
		{
			bool asSub = XmlSettingsManager::Instance ()->
				property ("ShowPluginMenuInTabsAsSubmenu").toBool ();
			if (imtw)
			{
				const auto& tabActions = imtw->GetTabBarContextMenuActions ();

				QMenu *subMenu = asSub ?
						new QMenu (TabText (index), menu) :
						nullptr;
				for (auto act : tabActions)
					(asSub ? subMenu : menu)->addAction (act);

				if (asSub)
					menu->addMenu (subMenu);

				if (tabActions.size ())
					menu->addSeparator ();
			}
		}

		auto rootWM = Core::Instance ().GetRootWindowsManager ();
		const int windowIndex = rootWM->GetWindowIndex (Window_);

		auto moveMenu = menu->addMenu (tr ("Move tab to"));
		auto toNew = moveMenu->addAction (tr ("New window"),
				rootWM, SLOT (moveTabToNewWindow ()));
		toNew->setProperty ("TabIndex", index);
		toNew->setProperty ("FromWindowIndex", windowIndex);
		if (rootWM->GetWindowsCount () > 1)
		{
			moveMenu->addSeparator ();

			for (int i = 0; i < rootWM->GetWindowsCount (); ++i)
			{
				auto thatWin = rootWM->GetMainWindow (i);
				if (thatWin == Window_)
					continue;

				const auto& actTitle = tr ("To window %1 (%2)")
							.arg (i + 1)
							.arg (thatWin->windowTitle ());
				auto toExisting = moveMenu->addAction (actTitle,
						rootWM, SLOT (moveTabToExistingWindow ()));
				toExisting->setProperty ("TabIndex", index);
				toExisting->setProperty ("FromWindowIndex", windowIndex);
				toExisting->setProperty ("ToWindowIndex", i);
			}
		}

		const auto irt = qobject_cast<IRecoverableTab*> (widget);
		if (imtw &&
				irt &&
				(imtw->GetTabClassInfo ().Features_ & TabFeature::TFOpenableByRequest) &&
				!(imtw->GetTabClassInfo ().Features_ & TabFeature::TFSingle))
		{
			const auto cloneAct = menu->addAction (tr ("Clone tab"),
					this, SLOT (handleCloneTab ()));
			cloneAct->setProperty ("TabIndex", index);
			cloneAct->setProperty ("ActionIcon", "tab-duplicate");
		}

		for (auto act : TabBarActions_)
		{
			if (!act)
			{
				qWarning () << Q_FUNC_INFO
						<< "detected null pointer";
				continue;
			}
			menu->addAction (act);
		}

		Util::DefaultHookProxy_ptr proxy (new Util::DefaultHookProxy);
		emit hookTabContextMenuFill (proxy, menu, index,
				Core::Instance ().GetRootWindowsManager ()->GetWindowIndex (Window_));

		return menu;
	}