Kludget::Kludget(KClient *parent) : QObject(parent), client(parent), window(new KWindow), settings(new KSettings(this)), system(new KSystem(this)), prefWindow(0), aboutWindow(0), firstShow(true) { setObjectName("Kludget"); settings->setRootKey("kludget"); connect(system, SIGNAL(execUpdate(long)), this, SLOT(onSystemExecUpdate(long))); connect(system, SIGNAL(execFinish(long)), this, SLOT(onSystemExecFinish(long))); connect(window, SIGNAL(destroyed()), this, SLOT(onWindowDestroyed())); connect(window, SIGNAL(onShow()), this, SLOT(onShow())); connect(window, SIGNAL(onHide()), this, SLOT(onHide())); connect(window, SIGNAL(onStartDrag()), this, SLOT(onStartDrag())); connect(window, SIGNAL(onEndDrag()), this, SLOT(onEndDrag())); connect(window, SIGNAL(onSettingsChanged()), this, SLOT(onSettingsChanged())); connect(window->view(), SIGNAL(contextMenuRequested()), this, SLOT(onContextMenu())); connect(window->view(), SIGNAL(urlReceived(const QUrl*)), this, SLOT(onUrlReceived(const QUrl*))); connect(window->view()->page(), SIGNAL(loadFinished(bool)), this, SLOT(show())); connect(window->view()->page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(onJavaScriptWindowObjectCleared())); connect(window->view()->page(), SIGNAL(frameCreated(QWebFrame*)), this, SLOT(onFrameCreated(QWebFrame*))); connect(this, SIGNAL(evaluate(const QString &)), this, SLOT(onEvaluate(const QString &))); connect(&customMenuMapper, SIGNAL(mapped(const QString &)), this, SIGNAL(evaluate(const QString &))); connect(&ipcClient, SIGNAL(messageReceived(QString,QString,QString)), this, SLOT(messageReceived(QString,QString,QString))); KLog::log("Kludget::created"); }
bool DesignerEventHandler::eventFilter(QObject* o, QEvent* e) { switch (e->type()){ // case QEvent::ContextMenu: // qDebug () << "context menu event !!!"; // break; case QEvent::MouseButtonPress: //context_widget = dynamic_cast<VtlWidget*>(o); onMousePress((QMouseEvent*)e); break; case QEvent::MouseMove: onMouseMove((QMouseEvent*)e); break; case QEvent::MouseButtonRelease: onMouseRelease((QMouseEvent*)e); //context_widget = 0; break; case QEvent::MouseButtonDblClick: showWidgetProperties(); break; case QEvent::ContextMenu: //qDebug () << o->className(); qDebug () << "context menu event !!!"; onContextMenu((QContextMenuEvent*)e); break; case QEvent::KeyPress: onKeyPress((QKeyEvent*)e); break; // case QEvent::Paint: // onPaintEvent ( static_cast<QPaintEvent*>(e) ); // break; case OutsideEvent::Outside:{ VtlWidget * w = ((OutsideEvent *)e)->widget(); if (selections[w]){ selections[w]->updateSelectionPos(); } } return true; case AddToSelEvent::AddToSel: if (static_cast<AddToSelEvent*>(e)->clearSel()) clearSelection( ); addWidgetToSelection(static_cast<AddToSelEvent*>(e)->widget()); return true; default: break; } return QObject::eventFilter(o, e); }
/* QPlasmaPakFile */ QPlasmaPakFile::QPlasmaPakFile(QWidget* parent) : QPlasmaDocument(kDocPackage, parent) { fFileList = new QTreeWidget(this); fFileList->setUniformRowHeights(true); fFileList->setRootIsDecorated(false); fFileList->setEditTriggers(QAbstractItemView::SelectedClicked | QAbstractItemView::EditKeyPressed); fFileList->setContextMenuPolicy(Qt::CustomContextMenu); fFileList->setSelectionMode(QAbstractItemView::ExtendedSelection); fFileList->setHeaderLabels(QStringList() << "Filename" << "Size"); QToolBar* toolbar = new QToolBar(this); toolbar->setOrientation(Qt::Vertical); toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly); toolbar->setIconSize(QSize(22, 22)); QGridLayout* layout = new QGridLayout(this); layout->setContentsMargins(4, 4, 4, 4); layout->addWidget(fFileList, 0, 0); layout->addWidget(toolbar, 0, 1); setLayout(layout); fActions[kAdd] = new QAction(qStdIcon("list-add"), tr("&Add / Update..."), this); fActions[kDel] = new QAction(qStdIcon("list-remove"), tr("&Delete"), this); fActions[kExtract] = new QAction(qStdIcon("document-save"), tr("&Extract..."), this); fActions[kExtractAll] = new QAction(QIcon(":/img/pak.png"), tr("Ex&tract all..."), this); toolbar->addAction(fActions[kAdd]); toolbar->addAction(fActions[kDel]); toolbar->addSeparator(); toolbar->addAction(fActions[kExtract]); toolbar->addAction(fActions[kExtractAll]); connect(fFileList, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(onContextMenu(QPoint))); connect(fActions[kAdd], SIGNAL(triggered()), this, SLOT(onAdd())); connect(fActions[kDel], SIGNAL(triggered()), this, SLOT(onDel())); connect(fActions[kExtract], SIGNAL(triggered()), this, SLOT(onExtract())); connect(fActions[kExtractAll], SIGNAL(triggered()), this, SLOT(onExtractAll())); }
QPlasmaSumFile::QPlasmaSumFile(QWidget* parent) : QPlasmaDocument(kDocManifest, parent) { fFileList = new QTreeWidget(this); fFileList->setUniformRowHeights(true); fFileList->setRootIsDecorated(false); fFileList->setEditTriggers(QAbstractItemView::SelectedClicked | QAbstractItemView::EditKeyPressed); fFileList->setContextMenuPolicy(Qt::CustomContextMenu); fFileList->setSelectionMode(QAbstractItemView::ExtendedSelection); fFileList->setHeaderLabels(QStringList() << "Filename" << "Timestamp" << "MD5"); QToolBar* toolbar = new QToolBar(this); toolbar->setOrientation(Qt::Vertical); toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly); toolbar->setIconSize(QSize(22, 22)); QGridLayout* layout = new QGridLayout(this); layout->setContentsMargins(4, 4, 4, 4); layout->addWidget(fFileList, 0, 0); layout->addWidget(toolbar, 0, 1); setLayout(layout); fActions[kAUpdate] = new QAction(qStdIcon("view-refresh"), tr("&Update all..."), this); fActions[kAAdd] = new QAction(qStdIcon("list-add"), tr("&Add / Update..."), this); fActions[kADel] = new QAction(qStdIcon("list-remove"), tr("&Remove"), this); toolbar->addAction(fActions[kAUpdate]); toolbar->addSeparator(); toolbar->addAction(fActions[kAAdd]); toolbar->addAction(fActions[kADel]); connect(fFileList, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(onContextMenu(QPoint))); connect(fFileList, SIGNAL(itemChanged(QTreeWidgetItem*, int)), this, SLOT(onItemChanged(QTreeWidgetItem*, int))); connect(fActions[kAUpdate], SIGNAL(triggered()), this, SLOT(onUpdate())); connect(fActions[kAAdd], SIGNAL(triggered()), this, SLOT(onAdd())); connect(fActions[kADel], SIGNAL(triggered()), this, SLOT(onDel())); }
ApplicationsWindow::ApplicationsWindow(cDataManager *DataManager) : QMainWindow(0), ui(new Ui::ApplicationsWindow) { ui->setupUi(this); m_DataManager = DataManager; m_LoadingData = false; connect(ui->comboBoxProfiles, SIGNAL(currentIndexChanged(int)), this, SLOT(onProfileSelection(int))); connect(ui->pushButtonEditProfiles, SIGNAL(released()), this, SLOT(onEditProfiles())); m_CategoriesMenu.addAction(tr("New category"))->setData("NEW_CATEGORY_MENU"); m_CategoriesMenu.addAction(tr("Delete category"))->setData("DELETE_CATEGORY_MENU"); m_CategoriesMenu.addAction(tr("Set category color"))->setData("SET_CATEGORY_COLOR_MENU"); connect(&m_CategoriesMenu, SIGNAL(triggered(QAction*)), this, SLOT(onMenuSelection(QAction*))); ui->treeWidgetApplications->setAcceptDrops(true); ui->treeWidgetApplications->setDragEnabled(true); ui->treeWidgetApplications->setDragDropMode(QAbstractItemView::InternalMove); connect(ui->treeWidgetApplications,SIGNAL(itemMoved(QTreeWidgetItem*,QTreeWidgetItem*)),this,SLOT(onApplicationMoved(QTreeWidgetItem*,QTreeWidgetItem*))); connect(ui->treeWidgetApplications, SIGNAL (itemChanged(QTreeWidgetItem *, int)),this, SLOT (onCategoryChanged(QTreeWidgetItem *, int))); ui->treeWidgetApplications->setContextMenuPolicy(Qt::CustomContextMenu); connect(ui->treeWidgetApplications,SIGNAL(customContextMenuRequested(QPoint)),this,SLOT(onContextMenu(QPoint))); connect(&m_CategoriesMenu, SIGNAL(triggered(QAction*)), this, SLOT(onMenuSelection(QAction*))); }
void Kludget::messageReceived(QString message, QString id, QString instance) { if (instance != "") { if (info.instance != instance) return; } if (message == "ping") { ipcClient.sendMessage("pong", info.id, info.instance); return; } KLog::log(QString("kludget messageReceived: %1").arg(message)); int messageId = message.toUInt(); switch (messageId) { case KIPC::ShowHUD: { window->moveToTop(); //window->updateMouseIgnore(false); break; } case KIPC::HideHUD: { //window->applySettings(); window->moveToBottom(); break; } case KIPC::ShowWindow: { show(); window->moveToTop(); window->applySettings(); break; } case KIPC::HideWindow: { hide(); break; } case KIPC::LowerWindow: { window->lower(); break; } case KIPC::SettingsChanged: { onSettingsChanged(); break; } case KIPC::ShowOptions: { onContextMenu(); break; } case KIPC::Configure: { configure(); break; } default: evaluate(message); break; } }
LRESULT PowerWinApp::onMessage(UINT msg, WPARAM wparam, LPARAM lparam) { switch (msg) { // internal management messages case Messages::RegisterHooklib: hooklibs_.registerHookLib(reinterpret_cast<HWND>(wparam)); return 0; // internal messages case WM_NCCREATE: case WM_CREATE: case WM_DESTROY: case WM_NCDESTROY: return Control::onMessage(msg, wparam, lparam); // filter meaningless messages case WM_MOVE: case WM_SIZE: return ::DefWindowProc(getHWND(), msg, wparam, lparam); // trayicon case TrayIcon::MessageId: return tray_icon_.handleMessage(wparam, lparam, [=](UINT ti_msg, Point pt) { pt = getCursorPosition(); switch (ti_msg) { // case NIN_POPUPOPEN: case NIN_SELECT: case NIN_KEYSELECT: case WM_LBUTTONDOWN: case WM_RBUTTONDOWN: case WM_CONTEXTMENU: onContextMenu(pt); return 1; } return 0; }); // Messages des PopupMenus case WM_COMMAND: { int id = LOWORD(wparam); int event = HIWORD(wparam); // Menüauswahl bearbeiten: switch (id) { case InfoEntry: openProjectWebsite(); return 0; case InfoLicence: openLicence(); return 0; case AutostartEntry: onAutostartSet(!popup_menu_.isEntryChecked(AutostartEntry)); return 0; case QuitEntry: destroy(); return 0; } return 0; } } // pass message to modules auto result = global_events_.handleWindowsMessage(msg, wparam, lparam); return result ? result.value() : Control::onMessage(msg, wparam, lparam); }
ProfilesWindow::ProfilesWindow(cDataManager *DataManager) : QMainWindow(0), ui(new Ui::ProfilesWindow) { ui->setupUi(this); m_DataManager = DataManager; m_Menu.addAction(tr("New profile"))->setData("NEW_PROFILE"); m_Menu.addAction(tr("Clone profile"))->setData("CLONE_PROFILE"); m_Menu.addAction(tr("Merge profiles"))->setData("MERGE_PROFILES"); connect(&m_Menu, SIGNAL(triggered(QAction*)), this, SLOT(onMenuSelection(QAction*))); ui->listWidgetProfiles->setContextMenuPolicy(Qt::CustomContextMenu); connect(ui->listWidgetProfiles,SIGNAL(customContextMenuRequested(QPoint)),this,SLOT(onContextMenu(QPoint))); connect(ui->listWidgetProfiles, SIGNAL (itemChanged(QListWidgetItem *)),this, SLOT (onProfileChanged(QListWidgetItem *))); }