lxqt-pael源碼分析

關於lxqt-panel
20190812
使用lxqt-panel0.14與lxqt-panel0.12的不同
首先就是在調試的過程中0.14會進入到一串彙編代碼中
0.12在調試的時候沒有出現過這種情況

第二點是12.0是比較基礎的版本,在12.0上面基本全是英文,這些英文基本是在代碼中是字符串,有標註的
那麼在可以使用qt的查找功能 ctrl+shift+f5 來查找
但是在14.0中全部是中文,很難查找
但是有一點]:在14.0的版本中可以修改ui文件例如修改 background 這個在ui文件裏面是background但是在 真正程序運行的時候,是背景顏色 四個大字,應該是採用了字符串的轉換,在修改background 爲 hpybackground之後,在程序運行的地方也是出現了hpybackground,進一步證明了是採用了字符串轉化.


lxqt-panel的目錄結構

autostart
menu
panel
plugin-colorpicker
plugin-cpuload
…(下面全是plugin-…)

其中基本全部的代碼實現都在panel這個目錄下
panel目錄下是lxqt-panel的構建目錄

lxqtpanel
-config
—addplugin

關於mainmenu的show出來是在lxqtpanel.cpp的showPopupMenu函數中
應該也是關於

####################################################################################################
關於插件的
20190813
pm
調試 刪除其中一個插件worldclock
1.刪除lxqt-panel/plugin-worldclock 文件夾
2.提示 error :CMakeLists.txt:51 (include) 所以 vim CMakeLists.txt:51 (include) #51行

fatal error: …/plugin-worldclock/lxqtworldclock.h: 沒有那個文件或目錄
#include “…/plugin-worldclock/lxqtworldclock.h” // worldclock
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
panel/CMakeFiles/lxqt-panel.dir/build.make:308: recipe for target ‘panel/CMakeFiles/lxqt-panel.dir/plugin.cpp.o’ failed
make[2]: *** [panel/CMakeFiles/lxqt-panel.dir/plugin.cpp.o] Error 1
CMakeFiles/Makefile2:1595: recipe for target ‘panel/CMakeFiles/lxqt-panel.dir/all’ failed
make[1]: *** [panel/CMakeFiles/lxqt-panel.dir/all] Error 2
Makefile:129: recipe for target ‘all’ failed
make: *** [all] Error 2

3.在plugin.cpp中
//#include “…/plugin-worldclock/lxqtworldclock.h” // worldclock

這裏show出來的是 管理小部件這個欄的 添加小部件之後彈出來的添加框
void ConfigPluginsWidget::showAddPluginDialog()
{
if (mAddPluginDialog.isNull())
{
mAddPluginDialog.reset(new AddPluginDialog);
connect(mAddPluginDialog.data(), &AddPluginDialog::pluginSelected,
mPanel->mPlugins.data(), &PanelPluginsModel::addPlugin);
}
mAddPluginDialog->show();
mAddPluginDialog->raise();
mAddPluginDialog->activateWindow();
}

20190814

註釋掉CMakeLists.txt的其中幾行
因爲list(APPEND STATIC_PLUGINS “worldclock”)這裏的worldclock是沒有辦法改動的,一旦改動就報錯
#setByDefault(WORLDCLOCK_PLUGIN Yes)
#if(WORLDCLOCK_PLUGIN)

list(APPEND STATIC_PLUGINS “worldclock”)

add_definitions(-DWITH_WORLDCLOCK_PLUGIN)

list(APPEND ENABLED_PLUGINS “hpy Clock”)

add_subdirectory(plugin-hpyclock)

#endif(WORLDCLOCK_PLUGIN)

這個時候在任務欄中worldclock這個插件就消失了,並且在配置面板中worldclock也變成了unknown(worldclock)


20190815

由於在修改插件的過程中
遇到Warning: “Plugin worldclock not found in the” ("", “/usr/local/lib/lxqt-panel”)
找到源頭

if (!isLoaded())
{
if (!found)
qWarning() << QString(“Plugin %1 not found in the”).arg(desktopFile.id()) << dirs;

    return;
}

這裏的desktopFile.id就是worldclock 這個插件

關於id
在lxqtplugin.h文件中
QString id() const { return mId; }
找到mId
無法看到lxqtplugininfo.cpp
找到lxqtplugininfo.h所在文件夾

$dpkg -S lxqtplugininfo.h
$liblxqt0-dev: /usr/include/lxqt/LXQt/lxqtplugininfo.h
$apt-get source liblxqt0-dev

在lxqtplugininfo.cpp中
——————————————————————————————————————————————
bool PluginInfo::load(const QString& fileName)

{

XdgDesktopFile::load(fileName);

mId = QFileInfo(fileName).completeBaseName();

return isValid();

}
——————————————————————————————————————————————

/*!
* \brief pluginNames returns a list of names for all the Plugins in
* this panel. The names are not the human-readable names but the names
* that are used to identify the Plugins, e.g. in the config files. These
* names can be used in the method pluginByName() to get a corresponding
* Plugin.
*
* The plugin names are normally chosen to be equal to the
* filename of the corresponding *.desktop-file. If multiple instances
* of a single plugin-type are created, their names are created by
* appending increasing numbers, e.g. ‘mainmenu’ and ‘mainmenu2’.
*
* \sa findNewPluginSettingsGroup
*/
QStringList pluginNames() const;
brief pluginNames返回此面板中所有插件的名稱列表。 名稱不是人類可讀的名稱,而是用於標識插件的名稱,例如 在配置文件中。 可以在方法pluginByName()中使用這些名稱來獲取相應的插件。

通常選擇插件名稱等於相應* .desktop文件的文件名。 如果創建了單個插件類型的多個實例,則通過附加增加的數字來創建它們的名稱,例如, ‘mainmenu’和’mainmenu2’。

sa findNewPluginSettingsGroup

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章