forked from openkylin/quarkai
Add startupmanager plugin
This commit is contained in:
parent
667bb23aa6
commit
7c78e8b08b
|
@ -0,0 +1,100 @@
|
|||
|
||||
#include "startupitem.h"
|
||||
#include "../../component/kylinswitcher.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QPainter>
|
||||
#include <QLabel>
|
||||
|
||||
StartupItem::StartupItem(QWidget *parent) : QWidget(parent)
|
||||
,isEntered(false)
|
||||
{
|
||||
item = new QListWidgetItem();
|
||||
// item->setSizeHint(QSize(400, 60));
|
||||
|
||||
m_layout = new QHBoxLayout();
|
||||
m_leftLayout = new QHBoxLayout();
|
||||
m_switchLayout = new QHBoxLayout();
|
||||
|
||||
m_appIcon = new QLabel();
|
||||
m_appIcon->setFixedSize(40, 40);
|
||||
m_appIcon->setScaledContents(true);//自动缩放,显示图像大小自动调整为Qlabel大小
|
||||
m_appIcon->setPixmap(QPixmap("://res/ubuntukylin.png"));
|
||||
|
||||
m_appNameLabel = new QLabel();
|
||||
m_appDescLabel = new QLabel();
|
||||
m_appDescLabel->setText("ppppp");
|
||||
|
||||
switcher = new KylinSwitcher();
|
||||
switcher->switchedOn = false;
|
||||
connect(switcher, &KylinSwitcher::clicked, [=] () {
|
||||
//changeAutoStartAppStatus
|
||||
emit changeStartup();
|
||||
});
|
||||
m_switchLayout->addWidget(switcher, 0, Qt::AlignCenter);
|
||||
|
||||
m_leftLayout->addWidget(m_appIcon);
|
||||
|
||||
m_labelWidget = new QWidget();
|
||||
m_labelLayout = new QVBoxLayout(m_labelWidget);
|
||||
m_labelLayout->addWidget(m_appNameLabel);
|
||||
m_labelLayout->addWidget(m_appDescLabel);
|
||||
m_leftLayout->addWidget(m_labelWidget);
|
||||
|
||||
m_layout->addLayout(m_leftLayout);
|
||||
m_layout->addStretch();
|
||||
m_layout->addLayout(m_switchLayout);
|
||||
m_layout->setContentsMargins(10, 0, 10, 0);
|
||||
this->setLayout(m_layout);
|
||||
}
|
||||
|
||||
QListWidgetItem* StartupItem::getItem()
|
||||
{
|
||||
return item;
|
||||
}
|
||||
|
||||
void StartupItem::setItemHovered()
|
||||
{
|
||||
isEntered = true;
|
||||
repaint();
|
||||
}
|
||||
|
||||
void StartupItem::unsetItemHovered()
|
||||
{
|
||||
isEntered = false;
|
||||
repaint();
|
||||
}
|
||||
|
||||
void StartupItem::setAppName(const QString &name)
|
||||
{
|
||||
m_appName = name;
|
||||
m_appNameLabel->setText(name);
|
||||
}
|
||||
|
||||
QString StartupItem::getAppName()
|
||||
{
|
||||
return this->m_appName;
|
||||
}
|
||||
|
||||
void StartupItem::enterEvent(QEvent *event)
|
||||
{
|
||||
emit this->enter();
|
||||
|
||||
QWidget::enterEvent(event);
|
||||
}
|
||||
|
||||
void StartupItem::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
if (isEntered) {
|
||||
QPainter painter(this);
|
||||
painter.setRenderHint(QPainter::Antialiasing, true);
|
||||
|
||||
QPainterPath path;
|
||||
path.addRoundedRect(QRectF(rect()), 2, 2);
|
||||
painter.fillPath(path, QColor(135, 206, 250, 127));
|
||||
}
|
||||
|
||||
QWidget::paintEvent(event);
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
#ifndef STARTUPITEM_H
|
||||
#define STARTUPITEM_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QListWidgetItem>
|
||||
|
||||
class KylinSwitcher;
|
||||
|
||||
class StartupItem : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
StartupItem(QWidget *parent=0);
|
||||
|
||||
QListWidgetItem* getItem();
|
||||
QString getAppName();
|
||||
void setAppName(const QString &name);
|
||||
|
||||
void setItemHovered();
|
||||
void unsetItemHovered();
|
||||
|
||||
signals:
|
||||
void changeStartup();
|
||||
void enter();
|
||||
|
||||
protected:
|
||||
void enterEvent(QEvent *event);
|
||||
void paintEvent(QPaintEvent *);
|
||||
|
||||
private:
|
||||
bool isEntered;
|
||||
QListWidgetItem *item = nullptr;
|
||||
QString m_appName;
|
||||
|
||||
QLabel *m_appIcon = nullptr;
|
||||
QLabel *m_appNameLabel = nullptr;
|
||||
QLabel *m_appDescLabel = nullptr;
|
||||
KylinSwitcher *switcher = nullptr;
|
||||
|
||||
QWidget *m_labelWidget = nullptr;
|
||||
|
||||
QHBoxLayout *m_switchLayout = nullptr;
|
||||
QVBoxLayout *m_labelLayout = nullptr;
|
||||
QHBoxLayout *m_leftLayout = nullptr;
|
||||
QHBoxLayout *m_layout = nullptr;
|
||||
};
|
||||
|
||||
#endif // STARTUPITEM_H
|
|
@ -0,0 +1,567 @@
|
|||
#include "startuplistwidget.h"
|
||||
#include "startupitem.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QLabel>
|
||||
#include <QListWidgetItem>
|
||||
#include <QScrollBar>
|
||||
#include <QDirIterator>
|
||||
|
||||
#include <fstream>
|
||||
#include <qdiriterator.h>
|
||||
#include <sstream>
|
||||
#include <stdio.h>
|
||||
#include <string>
|
||||
|
||||
|
||||
#include <glib-object.h>
|
||||
#include <glib.h>
|
||||
|
||||
|
||||
static char **
|
||||
gsm_util_get_standard_autostart_dirs (void)
|
||||
{
|
||||
GPtrArray *dirs;
|
||||
const char * const *system_config_dirs;
|
||||
const char * const *system_data_dirs;
|
||||
int i;
|
||||
|
||||
dirs = g_ptr_array_new ();
|
||||
|
||||
g_ptr_array_add (dirs,
|
||||
g_build_filename (g_get_user_config_dir (),
|
||||
"autostart", NULL));
|
||||
|
||||
system_data_dirs = g_get_system_data_dirs ();
|
||||
for (i = 0; system_data_dirs[i]; i++) {
|
||||
g_ptr_array_add (dirs,
|
||||
g_build_filename (system_data_dirs[i],
|
||||
"gnome", "autostart", NULL));
|
||||
}
|
||||
|
||||
system_config_dirs = g_get_system_config_dirs ();
|
||||
for (i = 0; system_config_dirs[i]; i++) {
|
||||
g_ptr_array_add (dirs,
|
||||
g_build_filename (system_config_dirs[i],
|
||||
"autostart", NULL));
|
||||
}
|
||||
|
||||
g_ptr_array_add (dirs, NULL);
|
||||
|
||||
return (char **) g_ptr_array_free (dirs, FALSE);
|
||||
}
|
||||
|
||||
char **
|
||||
gsm_util_get_autostart_dirs ()
|
||||
{
|
||||
// if (autostart_dirs) {
|
||||
// return g_strdupv ((char **)autostart_dirs);
|
||||
// }
|
||||
|
||||
return gsm_util_get_standard_autostart_dirs ();
|
||||
}
|
||||
|
||||
//static int
|
||||
//gsp_app_manager_get_dir_index (GspAppManager *manager,
|
||||
// const char *dir)
|
||||
//{
|
||||
// GSList *l;
|
||||
// GspXdgDir *xdgdir;
|
||||
|
||||
// g_return_val_if_fail (GSP_IS_APP_MANAGER (manager), -1);
|
||||
// g_return_val_if_fail (dir != NULL, -1);
|
||||
|
||||
// for (l = manager->priv->dirs; l != NULL; l = l->next) {
|
||||
// xdgdir = l->data;
|
||||
// if (strcmp (dir, xdgdir->dir) == 0) {
|
||||
// return xdgdir->index;
|
||||
// }
|
||||
// }
|
||||
|
||||
// return -1;
|
||||
//}
|
||||
|
||||
|
||||
//const char *
|
||||
//gsp_app_manager_get_dir (GspAppManager *manager,
|
||||
// unsigned int index)
|
||||
//{
|
||||
// GSList *l;
|
||||
// GspXdgDir *xdgdir;
|
||||
|
||||
// g_return_val_if_fail (GSP_IS_APP_MANAGER (manager), NULL);
|
||||
|
||||
// for (l = manager->priv->dirs; l != NULL; l = l->next) {
|
||||
// xdgdir = l->data;
|
||||
// if (index == xdgdir->index) {
|
||||
// return xdgdir->dir;
|
||||
// }
|
||||
// }
|
||||
|
||||
// return NULL;
|
||||
//}
|
||||
|
||||
//static gboolean
|
||||
//gsp_app_manager_xdg_dir_monitor (GFileMonitor *monitor,
|
||||
// GFile *child,
|
||||
// GFile *other_file,
|
||||
// GFileMonitorEvent flags,
|
||||
// gpointer data)
|
||||
//{
|
||||
// GspAppManager *manager;
|
||||
// GspApp *old_app;
|
||||
// GspApp *app;
|
||||
// GFile *parent;
|
||||
// char *basename;
|
||||
// char *dir;
|
||||
// char *path;
|
||||
// int index;
|
||||
|
||||
// manager = GSP_APP_MANAGER (data);
|
||||
|
||||
// basename = g_file_get_basename (child);
|
||||
// if (!g_str_has_suffix (basename, ".desktop")) {
|
||||
// /* not a desktop file, we can ignore */
|
||||
// g_free (basename);
|
||||
// return TRUE;
|
||||
// }
|
||||
// old_app = gsp_app_manager_find_app_with_basename (manager, basename);
|
||||
|
||||
// parent = g_file_get_parent (child);
|
||||
// dir = g_file_get_path (parent);
|
||||
// g_object_unref (parent);
|
||||
|
||||
// index = gsp_app_manager_get_dir_index (manager, dir);
|
||||
// if (index < 0) {
|
||||
// /* not a directory we know; should never happen, though */
|
||||
// g_free (dir);
|
||||
// return TRUE;
|
||||
// }
|
||||
|
||||
// path = g_file_get_path (child);
|
||||
|
||||
// switch (flags) {
|
||||
// case G_FILE_MONITOR_EVENT_CHANGED:
|
||||
// case G_FILE_MONITOR_EVENT_CREATED:
|
||||
// /* we just do as if it was a new file: GspApp is clever enough
|
||||
// * to do the right thing */
|
||||
// app = gsp_app_new (path, (unsigned int) index);
|
||||
|
||||
// /* we didn't have this app before, so add it */
|
||||
// if (old_app == NULL && app != NULL) {
|
||||
// gsp_app_manager_add (manager, app);
|
||||
// g_object_unref (app);
|
||||
// }
|
||||
// /* else: it was just updated, GspApp took care of
|
||||
// * sending the event */
|
||||
// break;
|
||||
// case G_FILE_MONITOR_EVENT_DELETED:
|
||||
// if (!old_app) {
|
||||
// /* it got deleted, but we don't know about it, so
|
||||
// * nothing to do */
|
||||
// break;
|
||||
// }
|
||||
|
||||
// _gsp_app_manager_handle_delete (manager, old_app,
|
||||
// basename, index);
|
||||
// break;
|
||||
// default:
|
||||
// break;
|
||||
// }
|
||||
|
||||
// g_free (path);
|
||||
// g_free (dir);
|
||||
// g_free (basename);
|
||||
|
||||
// return TRUE;
|
||||
//}
|
||||
|
||||
//static void
|
||||
//_gsp_app_manager_fill_from_dir (GspAppManager *manager,
|
||||
// GspXdgDir *xdgdir)
|
||||
//{
|
||||
// GFile *file;
|
||||
// GDir *dir;
|
||||
// const char *name;
|
||||
|
||||
// file = g_file_new_for_path (xdgdir->dir);
|
||||
// xdgdir->monitor = g_file_monitor_directory (file, G_FILE_MONITOR_NONE,
|
||||
// NULL, NULL);
|
||||
// g_object_unref (file);
|
||||
|
||||
// if (xdgdir->monitor) {
|
||||
// g_signal_connect (xdgdir->monitor, "changed",
|
||||
// G_CALLBACK (gsp_app_manager_xdg_dir_monitor),
|
||||
// manager);
|
||||
// }
|
||||
|
||||
// dir = g_dir_open (xdgdir->dir, 0, NULL);
|
||||
// if (!dir) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
// while ((name = g_dir_read_name (dir))) {
|
||||
// GspApp *app;
|
||||
// char *desktop_file_path;
|
||||
|
||||
// if (!g_str_has_suffix (name, ".desktop")) {
|
||||
// continue;
|
||||
// }
|
||||
|
||||
// desktop_file_path = g_build_filename (xdgdir->dir, name, NULL);
|
||||
// app = gsp_app_new (desktop_file_path, xdgdir->index);
|
||||
|
||||
// if (app != NULL) {
|
||||
// gsp_app_manager_add (manager, app);
|
||||
// g_object_unref (app);
|
||||
// }
|
||||
|
||||
// g_free (desktop_file_path);
|
||||
// }
|
||||
|
||||
// g_dir_close (dir);
|
||||
//}
|
||||
void test_func()
|
||||
{
|
||||
char **autostart_dirs;
|
||||
int i;
|
||||
|
||||
autostart_dirs = gsm_util_get_autostart_dirs ();
|
||||
/* we always assume that the first directory is the user one */
|
||||
g_assert (g_str_has_prefix (autostart_dirs[0],
|
||||
g_get_user_config_dir ()));
|
||||
|
||||
for (i = 0; autostart_dirs[i] != NULL; i++) {
|
||||
// GspXdgDir *xdgdir;
|
||||
|
||||
// if (gsp_app_manager_get_dir_index (manager,
|
||||
// autostart_dirs[i]) >= 0) {
|
||||
// continue;
|
||||
// }
|
||||
// xdgdir = _gsp_xdg_dir_new (autostart_dirs[i], i);
|
||||
// manager->priv->dirs = g_slist_prepend (manager->priv->dirs,
|
||||
// xdgdir);
|
||||
// _gsp_app_manager_fill_from_dir (manager, xdgdir);
|
||||
}
|
||||
|
||||
g_strfreev (autostart_dirs);
|
||||
}
|
||||
|
||||
//static void
|
||||
//_fill_iter_from_app (GtkListStore *list_store,
|
||||
// GtkTreeIter *iter,
|
||||
// GspApp *app)
|
||||
//{
|
||||
// gboolean hidden;
|
||||
// gboolean display;
|
||||
// gboolean enabled;
|
||||
// gboolean shown;
|
||||
// GIcon *icon;
|
||||
// const char *description;
|
||||
// const char *app_name;
|
||||
|
||||
// hidden = gsp_app_get_hidden (app);
|
||||
// display = gsp_app_get_display (app);
|
||||
// enabled = gsp_app_get_enabled (app);
|
||||
// shown = gsp_app_get_shown (app);
|
||||
// icon = gsp_app_get_icon (app);
|
||||
// description = gsp_app_get_description (app);
|
||||
// app_name = gsp_app_get_name (app);
|
||||
|
||||
// if (G_IS_THEMED_ICON (icon)) {
|
||||
// GtkIconTheme *theme;
|
||||
// const char * const *icon_names;
|
||||
|
||||
// theme = gtk_icon_theme_get_default ();
|
||||
// icon_names = g_themed_icon_get_names (G_THEMED_ICON (icon));
|
||||
// if (icon_names[0] == NULL ||
|
||||
// !gtk_icon_theme_has_icon (theme, icon_names[0])) {
|
||||
// g_object_unref (icon);
|
||||
// icon = NULL;
|
||||
// }
|
||||
// } else if (G_IS_FILE_ICON (icon)) {
|
||||
// GFile *iconfile;
|
||||
|
||||
// iconfile = g_file_icon_get_file (G_FILE_ICON (icon));
|
||||
// if (!g_file_query_exists (iconfile, NULL)) {
|
||||
// g_object_unref (icon);
|
||||
// icon = NULL;
|
||||
// }
|
||||
// }
|
||||
|
||||
// if (icon == NULL) {
|
||||
// icon = g_themed_icon_new (STARTUP_APP_ICON);
|
||||
// }
|
||||
|
||||
// gtk_list_store_set (list_store, iter,
|
||||
// STORE_COL_VISIBLE, !hidden && shown && display,
|
||||
// STORE_COL_ENABLED, enabled,
|
||||
// STORE_COL_GICON, icon,
|
||||
// STORE_COL_DESCRIPTION, description,
|
||||
// STORE_COL_APP, app,
|
||||
// STORE_COL_SEARCH, app_name,
|
||||
// -1);
|
||||
// g_object_unref (icon);
|
||||
//}
|
||||
//static void
|
||||
//append_app (GsmPropertiesDialog *dialog,
|
||||
// GspApp *app)
|
||||
//{
|
||||
// GtkTreeIter iter;
|
||||
|
||||
// gtk_list_store_append (dialog->priv->list_store, &iter);
|
||||
// _fill_iter_from_app (dialog->priv->list_store, &iter, app);
|
||||
|
||||
// g_signal_connect_swapped (app, "changed",
|
||||
// G_CALLBACK (_app_changed), dialog);
|
||||
//}
|
||||
//static void
|
||||
//populate_model (GsmPropertiesDialog *dialog)
|
||||
//{
|
||||
// GSList *apps;
|
||||
// GSList *l;
|
||||
|
||||
// apps = gsp_app_manager_get_apps (dialog->priv->manager);
|
||||
// for (l = apps; l != NULL; l = l->next) {
|
||||
// append_app (dialog, GSP_APP (l->data));
|
||||
// }
|
||||
// g_slist_free (apps);
|
||||
//}
|
||||
|
||||
//populate_model (dialog);
|
||||
|
||||
//inline QPixmap getDesktopFileIcon(QString desktopFile, int iconSize)
|
||||
//{
|
||||
// std::string desktop_file;
|
||||
// desktopFile = desktopFile.toStdString();
|
||||
// std::ifstream in;
|
||||
// in.open(desktop_file);
|
||||
// QIcon defaultExecutableIcon = QIcon::fromTheme("application-x-executable");
|
||||
// QIcon icon;
|
||||
// QString iconName;
|
||||
// while(!in.eof()) {
|
||||
// std::string line;
|
||||
// std::getline(in,line);
|
||||
// iconName = QString::fromStdString(line);
|
||||
|
||||
// if (iconName.startsWith("Icon=")) {
|
||||
// iconName.remove(0,5); // remove the first 5 chars
|
||||
// } else {
|
||||
// continue;
|
||||
// }
|
||||
|
||||
// if (iconName.contains("/")) {
|
||||
// icon = QIcon(iconName);
|
||||
// } else {
|
||||
// icon = QIcon::fromTheme(iconName, defaultExecutableIcon);
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// in.close();
|
||||
|
||||
// qreal devicePixelRatio = qApp->devicePixelRatio();
|
||||
|
||||
// QPixmap pixmap = icon.pixmap(iconSize * devicePixelRatio, iconSize * devicePixelRatio);
|
||||
// pixmap.setDevicePixelRatio(devicePixelRatio);
|
||||
|
||||
// return pixmap;
|
||||
//}
|
||||
|
||||
inline QString getDesktopFile(QString processname)
|
||||
{
|
||||
QDirIterator dir("/usr/share/applications", QDirIterator::Subdirectories);
|
||||
// std::string desktopFile;
|
||||
QString desktopFile;
|
||||
|
||||
QString procname = processname.toLower();
|
||||
procname.replace("_", "-");
|
||||
|
||||
QString processFilename = procname + ".desktop";
|
||||
|
||||
while(dir.hasNext()) {
|
||||
if (dir.fileInfo().suffix() == "desktop") {
|
||||
if (dir.fileName().toLower().contains(processFilename)) {
|
||||
// desktopFile = dir.filePath().toStdString();
|
||||
desktopFile = dir.filePath();
|
||||
break;
|
||||
}
|
||||
}
|
||||
dir.next();
|
||||
}
|
||||
|
||||
// return QString::fromStdString(desktopFile);
|
||||
return desktopFile;
|
||||
}
|
||||
|
||||
//inline QString getDisplayNameFromName(QString procName, QString desktopFile, bool displayProcessName)
|
||||
//{
|
||||
// QString procname = procName.toLower();
|
||||
// if (processDescriptions.contains(procname)) {
|
||||
// if (displayProcessName) {
|
||||
// return QString("%1 ( %2 )").arg(processDescriptions[procname], procName);
|
||||
// } else {
|
||||
// return processDescriptions[procname];
|
||||
// }
|
||||
// }
|
||||
|
||||
// if (desktopFile.size() == 0) {
|
||||
// return procName;
|
||||
// }
|
||||
|
||||
// std::ifstream in;
|
||||
// in.open(desktopFile);
|
||||
// QString displayName = procName;
|
||||
// while(!in.eof()) {
|
||||
// std::string line;
|
||||
// std::getline(in,line);
|
||||
|
||||
// QString lineContent = QString::fromStdString(line);
|
||||
|
||||
// QString localNameFlag = QString("Name[%1]=").arg(QLocale::system().name());
|
||||
// QString nameFlag = "Name=";
|
||||
// QString genericNameFlag = QString("GenericName[%1]=").arg(QLocale::system().name());
|
||||
|
||||
// if (lineContent.startsWith(localNameFlag)) {
|
||||
// displayName = lineContent.remove(0, localNameFlag.size());
|
||||
|
||||
// break;
|
||||
// } else if (lineContent.startsWith(genericNameFlag)) {
|
||||
// displayName = lineContent.remove(0, genericNameFlag.size());
|
||||
// break;
|
||||
// } else if (lineContent.startsWith(nameFlag)) {
|
||||
// displayName = lineContent.remove(0, nameFlag.size());
|
||||
// continue;
|
||||
// } else {
|
||||
// continue;
|
||||
// }
|
||||
// }
|
||||
// in.close();
|
||||
|
||||
// return displayName;
|
||||
//}
|
||||
|
||||
|
||||
StartupListWidget::StartupListWidget(QWidget *parent) : QListWidget(parent)
|
||||
{
|
||||
// this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
|
||||
this->setFixedWidth(parent->width());
|
||||
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
|
||||
connect(this, &StartupListWidget::itemDoubleClicked, [=] (QListWidgetItem *item) {
|
||||
StartupItem *fileItem = static_cast<StartupItem *>(itemWidget(item));
|
||||
qDebug() << fileItem->getAppName();
|
||||
});
|
||||
|
||||
// loadItems(QStringList(), 0);
|
||||
QStringList tmp;
|
||||
tmp.append("AAA");
|
||||
tmp.append("BBB");
|
||||
tmp.append("CCC");
|
||||
tmp.append("DDD");
|
||||
tmp.append("EEE");
|
||||
tmp.append("FFF");
|
||||
tmp.append("GGG");
|
||||
tmp.append("HHH");
|
||||
tmp.append("JJJ");
|
||||
tmp.append("KKK");
|
||||
tmp.append("III");
|
||||
loadItems(tmp, 0);
|
||||
}
|
||||
|
||||
StartupListWidget::~StartupListWidget()
|
||||
{
|
||||
for(int i = 0; i < this->count(); i++) {
|
||||
QListWidgetItem *listItem = item(i);
|
||||
StartupItem *item = static_cast<StartupItem *>(itemWidget(listItem));
|
||||
if (item) {
|
||||
item->deleteLater();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void StartupListWidget::loadItem(QString info)
|
||||
{
|
||||
StartupItem *item = new StartupItem();
|
||||
item->setAppName(info);
|
||||
connect(item, SIGNAL(changeStartup()), this, SLOT(onChangeStartup()));
|
||||
connect(item, SIGNAL(enter()), this, SLOT(onMouseEnter()));
|
||||
addItem(item->getItem());
|
||||
item->getItem()->setSizeHint(QSize(this->width() - 10, 60));
|
||||
setItemWidget(item->getItem(), item);
|
||||
}
|
||||
|
||||
void StartupListWidget::loadItems(QStringList items, int scrollValue)
|
||||
{
|
||||
clear();
|
||||
|
||||
foreach (auto item, items) {
|
||||
loadItem(item);
|
||||
}
|
||||
|
||||
this->verticalScrollBar()->setValue(scrollValue);
|
||||
}
|
||||
|
||||
void StartupListWidget::onChangeStartup()
|
||||
{
|
||||
QString appName = ((StartupItem*) sender())->getAppName();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// def interface_get_status(fobj):
|
||||
// locale_language = locale.getdefaultlocale()[0]
|
||||
// try:
|
||||
// obj = Desktop_Autostart_Manage()
|
||||
// obj.get_final_status()
|
||||
// up = obj.dic.get("autostart", [])
|
||||
// if up:
|
||||
// for upvalue in up:
|
||||
// up_list = obj.get_desktop_info(upvalue, locale_language)
|
||||
// up_list.append('Status:' + 'true')
|
||||
// fobj.autostartmanage_data_signal(up_list)
|
||||
|
||||
// down = obj.dic.get("notautostart", [])
|
||||
// if down:
|
||||
// for downvalue in down:
|
||||
// down_list = obj.get_desktop_info(downvalue, locale_language)
|
||||
// down_list.append('Status:' + 'false')
|
||||
// fobj.autostartmanage_data_signal(down_list)
|
||||
|
||||
|
||||
// std::string desktopFile;
|
||||
// if (trayProcessMap.contains(pid)) {
|
||||
// desktopFile = Utils::getProcessEnvironmentVariable(pid, "GIO_LAUNCHED_DESKTOP_FILE").toStdString();
|
||||
// } else {
|
||||
// desktopFile = getDesktopFileFromName(pid, name, cmdline);
|
||||
// }
|
||||
|
||||
// QPixmap icon;
|
||||
// if (desktopFile.size() == 0) {
|
||||
// qreal devicePixelRatio = qApp->devicePixelRatio();
|
||||
// icon = findWindowTitle->getWindowIcon(findWindowTitle->getWindow(pid), 96 * devicePixelRatio);
|
||||
// icon.setDevicePixelRatio(devicePixelRatio);
|
||||
// } else {
|
||||
// icon = getDesktopFileIcon(desktopFile, 96);
|
||||
// }
|
||||
// QString displayName = getDisplayNameFromName(name, desktopFile, false);
|
||||
|
||||
}
|
||||
|
||||
void StartupListWidget::onMouseEnter()
|
||||
{
|
||||
for(int i = 0; i < this->count(); i++) {
|
||||
QListWidgetItem *listItem = item(i);
|
||||
StartupItem *item = static_cast<StartupItem *>(itemWidget(listItem));
|
||||
if (item->getAppName() == ((StartupItem*) sender())->getAppName()) {
|
||||
item->setItemHovered();
|
||||
} else {
|
||||
item->unsetItemHovered();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
#ifndef STARTUPLISTWIDGET_H
|
||||
#define STARTUPLISTWIDGET_H
|
||||
|
||||
#include "startupitem.h"
|
||||
|
||||
#include <QListWidget>
|
||||
|
||||
class StartupListWidget : public QListWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
StartupListWidget(QWidget *parent=0);
|
||||
~StartupListWidget();
|
||||
|
||||
void loadItem(QString info);
|
||||
void loadItems(QStringList items, int scrollValue);
|
||||
|
||||
public slots:
|
||||
void onChangeStartup();
|
||||
void onMouseEnter();
|
||||
};
|
||||
|
||||
#endif // STARTUPLISTWIDGET_H
|
|
@ -0,0 +1,87 @@
|
|||
/*
|
||||
* Copyright (C) 2013 ~ 2018 National University of Defense Technology(NUDT) & Tianjin Kylin Ltd.
|
||||
*
|
||||
* Authors:
|
||||
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "startupmanager.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QApplication>
|
||||
#include <QDesktopWidget>
|
||||
#include <QStackedLayout>
|
||||
|
||||
|
||||
//#sudo apt-get install rcconf
|
||||
//root 下运行: #sudo rcconf
|
||||
//功能更全的工具:sysv-rc-conf
|
||||
//#sudo apt-get update
|
||||
//#sudo apt-get install sysv-rc-conf
|
||||
//运行:#sudo sysv-rc-conf
|
||||
|
||||
//gnome-session-properties
|
||||
|
||||
|
||||
StartupManager::StartupManager(QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
startup_dialog = new StartupWidget;
|
||||
}
|
||||
|
||||
StartupManager::~StartupManager()
|
||||
{
|
||||
if (startup_dialog) {
|
||||
delete startup_dialog;
|
||||
startup_dialog = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
QString StartupManager::getGuid()
|
||||
{
|
||||
return "UBUNTU-KYLIN-STARTUP";
|
||||
}
|
||||
|
||||
QString StartupManager::getName()
|
||||
{
|
||||
return tr("Kylin Startup Manager");
|
||||
}
|
||||
|
||||
QString StartupManager::getDescribe()
|
||||
{
|
||||
return tr("Help user to manager application startup items");
|
||||
}
|
||||
|
||||
QString StartupManager::getPicture()
|
||||
{
|
||||
return "startupmanager.png";
|
||||
}
|
||||
|
||||
void StartupManager::doAction()
|
||||
{
|
||||
startup_dialog->show();
|
||||
startup_dialog->raise();
|
||||
startup_dialog->setFocus();
|
||||
}
|
||||
|
||||
QWidget *StartupManager::centralWidget()
|
||||
{
|
||||
return startup_dialog;
|
||||
}
|
||||
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
|
||||
Q_EXPORT_PLUGIN2(StartupManager, StartupManager)
|
||||
#endif
|
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* Copyright (C) 2013 ~ 2018 National University of Defense Technology(NUDT) & Tianjin Kylin Ltd.
|
||||
*
|
||||
* Authors:
|
||||
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef STARTUPMANAGER_H
|
||||
#define STARTUPMANAGER_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include "../../component/plugininterface.h"
|
||||
#include "startupwidget.h"
|
||||
|
||||
//插件入口
|
||||
class StartupManager : public QObject , PluginInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(PluginInterface)
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
|
||||
Q_PLUGIN_METADATA(IID "com.kylin.Plugin.PluginInterface" FILE "startupmanager.json")//指定IID和.json文件
|
||||
#endif
|
||||
|
||||
public:
|
||||
explicit StartupManager(QObject* parent = 0);
|
||||
virtual ~StartupManager();
|
||||
QWidget *centralWidget();
|
||||
|
||||
public:
|
||||
virtual QString getGuid();
|
||||
virtual QString getName();
|
||||
virtual QString getDescribe();
|
||||
virtual QString getPicture();
|
||||
virtual void doAction();
|
||||
|
||||
private:
|
||||
StartupWidget *startup_dialog = nullptr;
|
||||
};
|
||||
|
||||
#endif // STARTUPMANAGER_H
|
|
@ -0,0 +1 @@
|
|||
{}
|
|
@ -0,0 +1,51 @@
|
|||
#-------------------------------------------------
|
||||
#
|
||||
# Project created by QtCreator 2015-01-26T09:16:38
|
||||
#
|
||||
#-------------------------------------------------
|
||||
|
||||
QT += core
|
||||
|
||||
isEqual(QT_MAJOR_VERSION, 5) {
|
||||
QT += widgets gui svg
|
||||
}
|
||||
|
||||
TARGET = startupmanager
|
||||
TEMPLATE = lib
|
||||
DESTDIR = $$_PRO_FILE_PWD_/../
|
||||
CONFIG += plugin c++11 link_pkgconfig
|
||||
PKGCONFIG += glib-2.0 gobject-2.0
|
||||
|
||||
target.path = $${PREFIX}/lib/kylin-assistant/plugins/
|
||||
INSTALLS += target
|
||||
|
||||
unix {
|
||||
UI_DIR = .ui
|
||||
MOC_DIR = .moc
|
||||
OBJECTS_DIR = .obj
|
||||
}
|
||||
|
||||
HEADERS += \
|
||||
startupmanager.h \
|
||||
startupwidget.h \
|
||||
../../component/plugininterface.h \
|
||||
startuptitlewidget.h \
|
||||
../widgets/myimagebutton.h \
|
||||
startuplistwidget.h \
|
||||
startupitem.h \
|
||||
../../component/kylinswitcher.h
|
||||
|
||||
SOURCES += \
|
||||
startupmanager.cpp \
|
||||
startupwidget.cpp \
|
||||
startuptitlewidget.cpp \
|
||||
../widgets/myimagebutton.cpp \
|
||||
startuplistwidget.cpp \
|
||||
startupitem.cpp \
|
||||
../../component/kylinswitcher.cpp
|
||||
|
||||
OTHER_FILES += \
|
||||
startupmanager.json
|
||||
|
||||
RESOURCES += \
|
||||
../../src/img.qrc
|
|
@ -0,0 +1,137 @@
|
|||
/*
|
||||
* Copyright (C) 2013 ~ 2018 National University of Defense Technology(NUDT) & Tianjin Kylin Ltd.
|
||||
*
|
||||
* Authors:
|
||||
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "startuptitlewidget.h"
|
||||
#include "../widgets/myimagebutton.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
#include <QHBoxLayout>
|
||||
#include <QPainter>
|
||||
#include <QResizeEvent>
|
||||
#include <QStyleFactory>
|
||||
|
||||
StartupTitleWidget::StartupTitleWidget(QWidget *parent)
|
||||
:QFrame(parent)
|
||||
{
|
||||
installEventFilter(this);
|
||||
setMouseTracking(true);
|
||||
setFixedHeight(39);
|
||||
|
||||
m_topBorderColor = QColor(255, 255, 255, 153);
|
||||
this->setAutoFillBackground(true);
|
||||
QPalette palette;
|
||||
palette.setColor(QPalette::Background, QColor("#0d87ca"));
|
||||
this->setPalette(palette);
|
||||
|
||||
initWidgets();
|
||||
}
|
||||
|
||||
StartupTitleWidget::~StartupTitleWidget()
|
||||
{
|
||||
//Segmentation fault
|
||||
QLayoutItem *child;
|
||||
while ((child = m_lLayout->takeAt(0)) != 0) {
|
||||
if (child->widget())
|
||||
child->widget()->deleteLater();
|
||||
delete child;
|
||||
}
|
||||
|
||||
while ((child = m_rLayout->takeAt(0)) != 0) {
|
||||
if (child->widget())
|
||||
child->widget()->deleteLater();
|
||||
delete child;
|
||||
}
|
||||
delete m_layout;
|
||||
}
|
||||
|
||||
void StartupTitleWidget::paintEvent(QPaintEvent *e)
|
||||
{
|
||||
|
||||
QFrame::paintEvent(e);
|
||||
|
||||
QPainter p(this);
|
||||
p.setRenderHint(QPainter::Antialiasing);
|
||||
|
||||
const QColor tc(m_topBorderColor);
|
||||
int borderHeight = 1;
|
||||
QPainterPath tPath;
|
||||
tPath.moveTo(QPointF(x(), y() + borderHeight - 0.5));
|
||||
tPath.lineTo(QPointF(x() + width(), y() + borderHeight - 0.5));
|
||||
p.setPen(QPen(tc));
|
||||
p.drawPath(tPath);
|
||||
}
|
||||
|
||||
void StartupTitleWidget::initLeftContent()
|
||||
{
|
||||
QWidget *w = new QWidget;
|
||||
m_lLayout = new QHBoxLayout(w);
|
||||
m_lLayout->setContentsMargins(6, 0, 0, 0);
|
||||
m_lLayout->setSpacing(0);
|
||||
|
||||
QLabel *label = new QLabel;
|
||||
label->setStyleSheet("QLabel{border-image: url(://res/kylin-assistant.png);}");
|
||||
label->setFixedSize(24, 24);
|
||||
m_lLayout->addWidget(label);
|
||||
|
||||
QLabel *titleLabel = new QLabel;
|
||||
titleLabel->setStyleSheet("QLabel{background-color:transparent;color:#ffffff; font-size:12px;}");
|
||||
titleLabel->setText(tr("Kylin Startup Manager"));
|
||||
m_lLayout->addSpacing(5);
|
||||
m_lLayout->addWidget(titleLabel);
|
||||
|
||||
m_layout->addWidget(w, 1, Qt::AlignLeft);
|
||||
}
|
||||
|
||||
void StartupTitleWidget::initRightContent()
|
||||
{
|
||||
QWidget *w = new QWidget;
|
||||
m_rLayout = new QHBoxLayout(w);
|
||||
m_rLayout->setContentsMargins(0, 0, 6, 0);
|
||||
m_rLayout->setSpacing(0);
|
||||
|
||||
m_layout->addWidget(w, 1, Qt::AlignRight);
|
||||
|
||||
MyImageButton *minBtn = new MyImageButton;
|
||||
minBtn->setObjectName("MinButton");
|
||||
connect(minBtn, &MyImageButton::clicked, this, [=] {
|
||||
if (parentWidget() && parentWidget()->parentWidget()) {
|
||||
parentWidget()->parentWidget()->showMinimized();
|
||||
}
|
||||
});
|
||||
|
||||
MyImageButton *closeBtn = new MyImageButton;
|
||||
closeBtn->setObjectName("CloseButton");
|
||||
connect(closeBtn, &MyImageButton::clicked, this, [=] {
|
||||
window()->close();
|
||||
});
|
||||
m_rLayout->addWidget(minBtn);
|
||||
m_rLayout->addWidget(closeBtn);
|
||||
}
|
||||
|
||||
void StartupTitleWidget::initWidgets()
|
||||
{
|
||||
m_layout = new QHBoxLayout(this);
|
||||
m_layout->setContentsMargins(0, 0, 0, 0);
|
||||
m_layout->setSpacing(0);
|
||||
this->setLayout(m_layout);
|
||||
|
||||
initLeftContent();
|
||||
initRightContent();
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* Copyright (C) 2013 ~ 2018 National University of Defense Technology(NUDT) & Tianjin Kylin Ltd.
|
||||
*
|
||||
* Authors:
|
||||
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef STARTUPTITLEWIDGET_H
|
||||
#define STARTUPTITLEWIDGET_H
|
||||
|
||||
#include <QFrame>
|
||||
#include <QTimer>
|
||||
|
||||
class QHBoxLayout;
|
||||
|
||||
class StartupTitleWidget : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
StartupTitleWidget(QWidget *parent);
|
||||
~StartupTitleWidget();
|
||||
void initLeftContent();
|
||||
void initRightContent();
|
||||
void initWidgets();
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *e) override;
|
||||
|
||||
private:
|
||||
QColor m_topBorderColor;
|
||||
QHBoxLayout *m_layout;
|
||||
QHBoxLayout *m_lLayout;
|
||||
QHBoxLayout *m_rLayout;
|
||||
};
|
||||
|
||||
#endif // STARTUPTITLEWIDGET_H
|
|
@ -0,0 +1,135 @@
|
|||
/*
|
||||
* Copyright (C) 2013 ~ 2018 National University of Defense Technology(NUDT) & Tianjin Kylin Ltd.
|
||||
*
|
||||
* Authors:
|
||||
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "startupwidget.h"
|
||||
#include "startuptitlewidget.h"
|
||||
#include "startuplistwidget.h"
|
||||
|
||||
#include <QFileSystemWatcher>
|
||||
#include <QLabel>
|
||||
#include <QDebug>
|
||||
#include <QPainter>
|
||||
#include <QMouseEvent>
|
||||
#include <QDesktopWidget>
|
||||
#include <QFile>
|
||||
#include <QHBoxLayout>
|
||||
#include <QVBoxLayout>
|
||||
#include <QApplication>
|
||||
#include <QScreen>
|
||||
|
||||
StartupWidget::StartupWidget(QWidget *parent)
|
||||
: QFrame(parent)
|
||||
, mousePressed(false)
|
||||
{
|
||||
this->setWindowFlags(this->windowFlags() | Qt::FramelessWindowHint | Qt::WindowCloseButtonHint);//去掉边框
|
||||
this->setAttribute(Qt::WA_TranslucentBackground);//背景透明
|
||||
|
||||
this->setAutoFillBackground(true);
|
||||
this->setMouseTracking(true);
|
||||
|
||||
this->setFixedSize(500, 645);
|
||||
|
||||
m_titleWidget = new StartupTitleWidget(this);
|
||||
m_titleWidget->setFixedSize(this->width(), 39);
|
||||
|
||||
m_layout = new QVBoxLayout();
|
||||
m_layout->setSpacing(0);
|
||||
m_layout->setMargin(0);
|
||||
m_layout->setContentsMargins(0,0,0,0);
|
||||
setLayout(m_layout);
|
||||
|
||||
m_startupView = new StartupListWidget(this);
|
||||
m_layout->addWidget(m_titleWidget, 0, Qt::AlignTop);
|
||||
m_layout->addWidget(m_startupView, 0, Qt::AlignHCenter);
|
||||
|
||||
this->moveCenter();
|
||||
}
|
||||
|
||||
StartupWidget::~StartupWidget()
|
||||
{
|
||||
if (m_titleWidget) {
|
||||
delete m_titleWidget;
|
||||
m_titleWidget = nullptr;
|
||||
}
|
||||
if (m_startupView) {
|
||||
delete m_startupView;
|
||||
m_startupView = nullptr;
|
||||
}
|
||||
delete m_layout;
|
||||
}
|
||||
|
||||
void StartupWidget::moveCenter()
|
||||
{
|
||||
QPoint pos = QCursor::pos();
|
||||
QRect primaryGeometry;
|
||||
for (QScreen *screen : qApp->screens()) {
|
||||
if (screen->geometry().contains(pos)) {
|
||||
primaryGeometry = screen->geometry();
|
||||
}
|
||||
}
|
||||
|
||||
if (primaryGeometry.isEmpty()) {
|
||||
primaryGeometry = qApp->primaryScreen()->geometry();
|
||||
}
|
||||
|
||||
this->move(primaryGeometry.x() + (primaryGeometry.width() - this->width())/2,
|
||||
primaryGeometry.y() + (primaryGeometry.height() - this->height())/2);
|
||||
}
|
||||
|
||||
void StartupWidget::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
event->accept();
|
||||
}
|
||||
|
||||
void StartupWidget::paintEvent(QPaintEvent *)
|
||||
{
|
||||
QPainter painter(this);
|
||||
|
||||
QPainterPath path;
|
||||
path.addRect(QRectF(rect()));
|
||||
painter.setOpacity(1);
|
||||
painter.fillPath(path, QColor("#FFFFFF"));
|
||||
}
|
||||
|
||||
void StartupWidget::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
if (event->button() == Qt::LeftButton) {
|
||||
this->dragPosition = event->globalPos() - frameGeometry().topLeft();
|
||||
this->mousePressed = true;
|
||||
}
|
||||
QFrame::mousePressEvent(event);
|
||||
}
|
||||
|
||||
void StartupWidget::mouseReleaseEvent(QMouseEvent *event)
|
||||
{
|
||||
if (event->button() == Qt::LeftButton) {
|
||||
this->mousePressed = false;
|
||||
}
|
||||
|
||||
QFrame::mouseReleaseEvent(event);
|
||||
}
|
||||
|
||||
void StartupWidget::mouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
if (this->mousePressed) {
|
||||
move(event->globalPos() - this->dragPosition);
|
||||
}
|
||||
|
||||
QFrame::mouseMoveEvent(event);
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
* Copyright (C) 2013 ~ 2018 National University of Defense Technology(NUDT) & Tianjin Kylin Ltd.
|
||||
*
|
||||
* Authors:
|
||||
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef STARTUPWIDGET_H
|
||||
#define STARTUPWIDGET_H
|
||||
|
||||
|
||||
#include <QFrame>
|
||||
#include <QStackedWidget>
|
||||
#include <QLabel>
|
||||
|
||||
class QVBoxLayout;
|
||||
class StartupListWidget;
|
||||
class StartupTitleWidget;
|
||||
|
||||
class StartupWidget : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
StartupWidget(QWidget *parent = 0);
|
||||
~StartupWidget();
|
||||
|
||||
void moveCenter();
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *);
|
||||
void closeEvent(QCloseEvent *event);
|
||||
void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
|
||||
void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
|
||||
void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
|
||||
|
||||
private:
|
||||
StartupTitleWidget *m_titleWidget = nullptr;
|
||||
StartupListWidget *m_startupView = nullptr;
|
||||
QVBoxLayout *m_layout = nullptr;
|
||||
QPoint dragPosition;
|
||||
bool mousePressed;
|
||||
};
|
||||
|
||||
#endif // STARTUPWIDGET_H
|
Loading…
Reference in New Issue