void CDialogConnect::OnBnClickedButtonTeachingDisconnect() { int connectIndex; connectIndex = m_listCtrl_connectedBots.GetSelectionMark(); if(connectIndex == -1) { return; } m_mobotManager->disconnect(connectIndex); refreshLists(); }
// GTK periodical function gint check_update( gpointer data ) { if (gNeedRebuild) { gNeedRebuild = FALSE; gNeedRefresh = FALSE; gUpdateFlag = TRUE; rebuildLists(); refreshLists(); gUpdateFlag = FALSE; } else if (gNeedRefresh) { gNeedRefresh = FALSE; gUpdateFlag = TRUE; refreshLists(); gUpdateFlag = FALSE; } return TRUE; }
static void initLists() { gUpdateFlag = TRUE; rebuildLists(); gCurRow=0; gCurRef=0; refreshLists(); gUpdateFlag = FALSE; }
void CDialogConnect::OnBnClickedButtonAddnewbot() { /* Get the text from the correct edit and put it in the config file */ USES_CONVERSION; TCHAR text[256]; LPCSTR address; int count; memset(text, 0, sizeof(TCHAR)*256); ((DWORD*)text)[0] = 256; count = m_edit_newRobotAddress.GetLine(0, text, 255); text[count] = (TCHAR)'\0'; /* Convert from wide char to normal char */ //size_t convertedChars = 0; //size_t origsize = wcslen(text)+1; //wcstombs_s(&convertedChars, address, origsize, text, _TRUNCATE); address = T2CA(text); m_mobotManager->addEntry(address); m_mobotManager->write(); refreshLists(); }
void CDialogConnect::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); DDX_Control(pDX, IDC_LIST_AVAILABLEBOTS, m_listCtrl_availableBots); DDX_Control(pDX, IDC_LIST_CONNECTEDBOTS, m_listCtrl_connectedBots); /* Set up list controls */ m_listCtrl_availableBots.InsertColumn( 0, TEXT("Mobot Address"), LVCFMT_LEFT, 120, -1); m_listCtrl_connectedBots.InsertColumn( 0, TEXT("Mobot Address"), LVCFMT_LEFT, 120, -1); refreshLists(); DDX_Control(pDX, IDC_EDIT_ROBOTADDRESS, m_edit_newRobotAddress); }
void CDialogConnect::OnBnClickedButtonTeachingConnect() { /* Get the selected item */ int index; int err; index = m_listCtrl_availableBots.GetSelectionMark(); if(index == -1) { return; } err = m_mobotManager->connect(index); if(err) { switch (err) { case -1: MessageBox( TEXT("Error connecting."), TEXT("Error"), MB_OK | MB_ICONINFORMATION ); break; case -2: MessageBox( TEXT("Error connecting. Another application is already connected to this Mobot."), TEXT("Error"), MB_OK | MB_ICONINFORMATION ); break; case -3: MessageBox( TEXT("Error connecting. Address format is incorrect."), TEXT("Error"), MB_OK | MB_ICONINFORMATION ); break; case -4: MessageBox( TEXT("Error connecting. Not enough Mobot address entries in configuration file."), TEXT("Error"), MB_OK | MB_ICONINFORMATION ); break; case -5: MessageBox( TEXT("Error connecting. Bluetooth dongle/device not found on local computer."), TEXT("Error"), MB_OK | MB_ICONINFORMATION ); break; case -6: MessageBox( TEXT("Error connecting. Mobot firmware version mismatch."), TEXT("Error"), MB_OK | MB_ICONINFORMATION ); break; default: MessageBox( TEXT("Error connecting."), TEXT("Error"), MB_OK | MB_ICONINFORMATION ); break; } } refreshLists(); }
static void select_appl(GtkWidget *widget, gint row, gint column, GdkEventButton *event, gpointer data) { if (!gUpdateFlag) { gCurRow = row; gCurRef = row2ref(row); refreshLists(); } }
void AnimeListWidget::customContextMenuRequested(const QPoint &t_pos) { auto model = m_ui->table->indexAt(t_pos); auto row = model.row(); if (row < 0) return; QPoint position = t_pos; position.setY(t_pos.y() + 20); QAction *pAnimePanel = new QAction(tr("Open Anime Panel"), m_ui->table); QAction *pEpisodeIncrement = new QAction(tr("Increment Progress by 1"), m_ui->table); QMenu *pStatusUpdate = new QMenu(tr("Status"), m_ui->table); QAction *pDeleteEntry = new QAction(tr("Delete Entry"), m_ui->table); QMenu *pCustomLists = new QMenu(tr("Custom Lists"), m_ui->table); QAction *pWatching = new QAction(tr("Watching"), pStatusUpdate); QAction *pOnHold = new QAction(tr("On Hold"), pStatusUpdate); QAction *pPlanToWatch = new QAction(tr("Plan to Watch"), pStatusUpdate); QAction *pCompleted = new QAction(tr("Completed"), pStatusUpdate); QAction *pDropped = new QAction(tr("Dropped"), pStatusUpdate); QAction *pHideDefault = new QAction(tr("Hide Default"), pCustomLists); QAction *pRuleAction = new QAction(tr("Create rule"), m_ui->table); QAction *pSearch = new QAction(tr("Search For Torrents"), m_ui->table); auto index = m_proxy_model->index(model.row(), ListRoles::Title); auto title = m_proxy_model->data(index, Qt::DisplayRole).toString(); AnimePtr anime = User::sharedUser()->getAnimeByTitle(title); for (int i = 0; i < User::sharedUser()->customListNames().count(); i++) { QString list = User::sharedUser()->customListNames().at(i); if (list.isEmpty()) continue; QAction *temp = new QAction(list, m_ui->table); temp->setCheckable(true); if (anime->customLists().at(i) == 1) { temp->setChecked(true); } else { temp->setChecked(false); } connect(temp, &QAction::toggled, [this, anime, i](bool selected) { QList<int> custom = anime->customLists(); custom.replace(i, selected ? 1 : 0); anime->setCustomLists(custom); QMap<QString, QString> data; data.insert("id", anime->id()); QString d; for (int i = 0; i < custom.length(); i++) { d += QString::number(custom.at(i)) + ((i == custom.length() - 1) ? "" : ","); } data.insert("custom_lists", d); auto api = API::sharedAPI()->sharedAniListAPI(); api->put(api->API_EDIT_LIST, data); emit refreshLists(); }); pCustomLists->addAction(temp); } pHideDefault->setCheckable(true); pHideDefault->setChecked(anime->hiddenDefault()); pCustomLists->addAction(pHideDefault); connect(pHideDefault, &QAction::toggled, [this, anime](bool selected) { QMap<QString, QString> data; data.insert("id", anime->id()); data.insert("hidden_default", selected ? "1" : "0"); if (selected) { User::sharedUser()->removeFromList(anime->listStatus(), anime); } emit animePayloadChanged(anime, data); }); pStatusUpdate->addAction(pWatching); pStatusUpdate->addAction(pOnHold); pStatusUpdate->addAction(pPlanToWatch); pStatusUpdate->addAction(pCompleted); pStatusUpdate->addAction(pDropped); connect(pAnimePanel, &QAction::triggered, [this, row, anime]() { emit animePanelRequested(anime); }); connect(pEpisodeIncrement, &QAction::triggered, [&anime, this]() { if (anime->episodesWatched() >= anime->totalEpisodes() && anime->totalEpisodes() != 0) { return; } anime->setEpisodesWatched(anime->episodesWatched() + 1); if (anime->episodesWatched() == anime->totalEpisodes() && anime->totalEpisodes() != 0) { anime->setListStatus("completed"); } m_proxy_model->invalidate(); emit animeChanged(anime); }); connect(pWatching, &QAction::triggered, [this, anime]() { updateStatus(anime, "watching"); }); connect(pPlanToWatch, &QAction::triggered, [this, anime]() { updateStatus(anime, "plan to watch"); }); connect(pOnHold, &QAction::triggered, [this, anime]() { updateStatus(anime, "on-hold"); }); connect(pDropped, &QAction::triggered, [this, anime]() { updateStatus(anime, "dropped"); }); connect(pCompleted, &QAction::triggered, [this, anime]() { updateStatus(anime, "completed"); }); connect(pDeleteEntry, &QAction::triggered, [this, anime]() { auto api = API::sharedAPI()->sharedAniListAPI(); auto url = api->API_DELETE_ANIME(anime->id()); api->deleteResource(url); User::sharedUser()->removeAll(anime); emit refreshLists(); }); connect(pRuleAction, &QAction::triggered, [this, anime]() { emit createAndShowRule(anime, ""); }); connect(pSearch, &QAction::triggered, [this, anime]() { emit searchTorrents(anime); }); QMenu *pContextMenu = new QMenu(this); pContextMenu->addAction(pAnimePanel); pContextMenu->addAction(pEpisodeIncrement); pContextMenu->addMenu(pStatusUpdate); if (User::sharedUser()->customListNames().length() > 0) { pContextMenu->addMenu(pCustomLists); } else { delete pCustomLists; } pContextMenu->addAction(pDeleteEntry); pContextMenu->addAction(pRuleAction); pContextMenu->addAction(pSearch); pContextMenu->exec(mapToGlobal(position)); delete pContextMenu; pContextMenu = nullptr; }
Gui_AdminWindow::Gui_AdminWindow(QWidget* parent) : QWidget(parent) { _admin = new LinqAdmin; setWindowFlags(Qt::FramelessWindowHint); setWindowOpacity(0.95); setStyleSheet(QStringLiteral("QGroupBox{border:1px solid #000;border-radius:15px;} QGroupBox::title {subcontrol-origin: margin;subcontrol-position: top center;top:-6px;}")); QLabel* linkLabel = new QLabel("User list"); QLabel* groupLabel = new QLabel("Group list"); QPushButton* add = new QPushButton("Insert"); add->setIcon(QPixmap("img/add70.png")); linkLabel->setMaximumSize(120,20); groupLabel->setMaximumSize(120,20); _level = new QComboBox; _level->addItem("Basic", QVariant(0)); _level->addItem("Business", QVariant(1)); _level->addItem("Executive", QVariant(2)); tbar = new QToolBar; QToolButton* rm = new QToolButton(tbar); QToolButton* ok = new QToolButton(tbar); QToolButton* next = new QToolButton(tbar); QToolButton* delG = new QToolButton(tbar); rm->setIcon(QPixmap("img/cross108.png")); rm->setToolTip("Remove this user from Linqedin"); ok->setIcon(QPixmap("img/check67.png")); ok->setToolTip("Upgrade this user"); next->setIcon(QPixmap("img/right244.png")); next->setToolTip("Next result"); delG->setIcon(QPixmap("img/cross108.png")); delG->setToolTip("Delete group"); connect(rm, SIGNAL(clicked()), this, SLOT(removeUser())); connect(add, SIGNAL(clicked()), this, SLOT(addUser())); connect(ok, SIGNAL(clicked()), this, SLOT(upgradeUser())); connect(next, SIGNAL(clicked()), this, SLOT(nextResult())); connect(delG, SIGNAL(clicked()), this, SLOT(deleteGroup())); tbar->addWidget(rm); tbar->addWidget(ok); tbar->addWidget(next); tbar->addWidget(delG); tbar->actions().at(1)->setVisible(false); tbar->hide(); QGroupBox* _admbox = new QGroupBox; QGroupBox* _admins = new QGroupBox; for(int i = 0; i < 5; ++i) edt[i] = new QLineEdit; // search bar edt[3]->setEchoMode(QLineEdit::Password); edt[4]->setPlaceholderText("Search user"); createSearch(); connect(edt[4], SIGNAL(returnPressed()), this, SLOT(startSearch())); QVBoxLayout* _mainLayout = new QVBoxLayout; _mainLayout->setSpacing(20); QGridLayout* _layout = new QGridLayout; QGridLayout* _inslay = new QGridLayout; QFormLayout* frmsx = new QFormLayout; QFormLayout* frmdx = new QFormLayout; _userList = new QListWidget; _groupList = new QListWidget; _userInfo = new Gui_DisplayInfo; _userInfo->setReadOnly(true); QPushButton* quit = new QPushButton; quit->setIcon(QPixmap("img/prohibited1.png")); connect(quit, SIGNAL(clicked()), this, SLOT(close())); createUserList(); createGroupList(); _mainLayout->addWidget(quit, 0, Qt::AlignTop | Qt::AlignRight); _layout->addWidget(linkLabel, 0, 0, 1, 1); _layout->addWidget(_userInfo, 0, 1, 4, 1); _layout->addWidget(_userList, 1, 0, 1, 1); _layout->addWidget(groupLabel, 2, 0, 1, 1); _layout->addWidget(_groupList, 3, 0, 1, 1); _layout->addWidget(edt[4], 4, 0, 1, 1); _layout->addWidget(tbar, 4, 1, 1, 1, Qt::AlignCenter); _layout->setRowStretch(0,0); _layout->setRowStretch(1,1); _layout->setRowStretch(2,0); _layout->setColumnStretch(0,1); _layout->setColumnStretch(1,5); frmsx->addRow("Name:", edt[0]); frmdx->addRow("Surname:", edt[1]); frmsx->addRow("Username:"******"Password:"******"Privilege:", _level); _inslay->addLayout(frmsx, 0, 0, 1, 1); _inslay->addLayout(frmdx, 0, 1, 1, 1); _inslay->addWidget(add, 1, 1, 1, 1, Qt::AlignCenter); _admbox->setLayout(_layout); _admins->setLayout(_inslay); _mainLayout->addWidget(_admbox); _mainLayout->addWidget(_admins); setLayout(_mainLayout); connect(this, SIGNAL(modified()), this, SLOT(refreshLists())); move(100, 30); resize(1150, 720); }