bool ImportIconsWizard::initialLoad(QString name) { QString dirpath = GetConfDir(); QDir configDir(dirpath); if (!configDir.exists() && !configDir.mkdir(dirpath)) { LOG(VB_GENERAL, LOG_ERR, QString("Could not create %1").arg(dirpath)); } m_strChannelDir = QString("%1/%2").arg(configDir.absolutePath()) .arg("/channels"); QDir strChannelDir(m_strChannelDir); if (!strChannelDir.exists() && !strChannelDir.mkdir(m_strChannelDir)) { LOG(VB_GENERAL, LOG_ERR, QString("Could not create %1").arg(m_strChannelDir)); } m_strChannelDir += "/"; bool closeDialog = false; QString querystring("SELECT chanid, name, xmltvid, callsign," "dtv_multiplex.transportid, atsc_major_chan, " "atsc_minor_chan, dtv_multiplex.networkid, " "channel.serviceid, channel.mplexid," "dtv_multiplex.mplexid, channel.icon, channel.visible " "FROM channel LEFT JOIN dtv_multiplex " "ON channel.mplexid = dtv_multiplex.mplexid " "WHERE "); if (!name.isEmpty()) querystring.append("name=\"" + name + "\""); else querystring.append("channel.visible"); querystring.append(" ORDER BY name"); MSqlQuery query(MSqlQuery::InitCon()); query.prepare(querystring); m_listEntries.clear(); m_nCount=0; m_nMaxCount=0; m_missingMaxCount=0; if (query.exec() && query.size() > 0) { m_progressDialog = new MythUIProgressDialog(tr("Initializing, please wait..."), m_popupStack, "IconImportInitProgress"); if (m_progressDialog->Create()) { m_popupStack->AddScreen(m_progressDialog); m_progressDialog->SetTotal(query.size()); } else { delete m_progressDialog; m_progressDialog = NULL; } while(query.next()) { CSVEntry entry; if (m_fRefresh) { if (QFile(query.value(11).toString()).exists()) continue; } entry.strChanId=query.value(0).toString(); entry.strName=query.value(1).toString(); entry.strXmlTvId=query.value(2).toString(); entry.strCallsign=query.value(3).toString(); entry.strTransportId=query.value(4).toString(); entry.strAtscMajorChan=query.value(5).toString(); entry.strAtscMinorChan=query.value(6).toString(); entry.strNetworkId=query.value(7).toString(); entry.strServiceId=query.value(8).toString(); entry.strIconCSV= QString("%1,%2,%3,%4,%5,%6,%7,%8,%9\n"). arg(escape_csv(entry.strChanId)). arg(escape_csv(entry.strName)). arg(escape_csv(entry.strXmlTvId)). arg(escape_csv(entry.strCallsign)). arg(escape_csv(entry.strTransportId)). arg(escape_csv(entry.strAtscMajorChan)). arg(escape_csv(entry.strAtscMinorChan)). arg(escape_csv(entry.strNetworkId)). arg(escape_csv(entry.strServiceId)); entry.strNameCSV=escape_csv(entry.strName); LOG(VB_CHANNEL, LOG_INFO, QString("chanid %1").arg(entry.strIconCSV)); m_listEntries.append(entry); m_nMaxCount++; if (m_progressDialog) m_progressDialog->SetProgress(m_nMaxCount); } if (m_progressDialog) { m_progressDialog->Close(); m_progressDialog = NULL; } } m_iter = m_listEntries.begin(); m_progressDialog = new MythUIProgressDialog(tr("Downloading, please wait..."), m_popupStack, "IconImportInitProgress"); if (m_progressDialog->Create()) { m_popupStack->AddScreen(m_progressDialog); m_progressDialog->SetTotal(m_listEntries.size()); } else { delete m_progressDialog; m_progressDialog = NULL; } while (!closeDialog && (m_iter != m_listEntries.end())) { QString message = QString("Downloading %1 / %2 : ").arg(m_nCount+1) .arg(m_listEntries.size()) + (*m_iter).strName; if (m_missingEntries.size() > 0) message.append(QString("\nCould not find %1 icons.").arg(m_missingEntries.size())); if (!findmissing((*m_iter).strIconCSV)) { m_missingEntries.append((*m_iter)); m_missingMaxCount++; } m_nCount++; m_iter++; if (m_progressDialog) { m_progressDialog->SetMessage(message); m_progressDialog->SetProgress(m_nCount); } } if (m_progressDialog) { m_progressDialog->Close(); m_progressDialog = NULL; } if (m_missingEntries.size() == 0 || closeDialog) return false; if (m_nMaxCount <= 0) return false; return true; }
void ImmersiveVideoWindow::LoadPlugins(void) { image_id addonId; status_t err = B_NO_ERROR; ImmersiveVideoPlugin* aktPlugin=NULL; ImmersiveVideoPlugin* (*NewImmersiveVideoPlugin)(image_id); app_info info; BFile *file; BPath path; BPath *configPath = new BPath(); BPath *pluginPath = new BPath(); BEntry *entry =new BEntry(); find_directory(B_COMMON_SETTINGS_DIRECTORY,pluginPath,false,NULL); pluginPath->Append("Immersive Video/plugins"); /*pfad von der Anwendung besorgen, von der aus ein ImmersiveVideoWindow aufgerufen wurde*/ /* be_app->GetAppInfo(&info); BEntry entry(&info.ref); entry.GetPath(&path); path.GetParent(&path); //in das Unterverzeichniss "Plugins wechseln" path.Append("plugins");*/ BDirectory dir(pluginPath->Path()); printf("Laden der Plugins..\n"); /*config Pfad holen*/ find_directory(B_COMMON_SETTINGS_DIRECTORY,configPath,false,NULL); configPath->Append("Immersive Video/config"); BDirectory configDir(configPath->Path()); /*alle Dateien in diesem Verzeichniss durchlaufen und jede Datei überprüfen ob sie ein gültiges Plugin ist. ?muss ich vorher testen ob der Pfadgültig ist ?*/ while( err == B_NO_ERROR ) { // nächsten Verweis auf eine Datei auslesen err = dir.GetNextEntry(entry, TRUE ); //testen ob es ein gültiger Verweis ist if( entry->InitCheck() != B_NO_ERROR ) { break; } //einen Pfad(+Dateiname) von dem aktuellen Verweis erstellen lassen ->Path if( entry->GetPath(&path) != B_NO_ERROR ) { //printf( "entry.GetPath failed\n" ); } else { //Versuch die über path angegebene Datei als Addon zu laden addonId = load_add_on( path.Path() ); if( addonId < 0 ) { //Wenns schief ging, kein Poblem, dann wars irgendeine andere Datei //printf( "load_add_on( %s ) failed\n", path.Path() ); } else { //wenns geklappt hatt dann kleine Naricht auf stdout printf( "\t%s\t\tloaded\n", path.Leaf()); /*überprüfen ob es ein Addon war, welches unsere Schnittstelle entspricht Schnittstelle heist hier NewImmersiveVideoPlugin und es muss mit dem Protypen (void **)NewImmersiveVideoPlugin gekennzeichnet*/ if( get_image_symbol( addonId, "NewImmersiveVideoPlugin", B_SYMBOL_TYPE_TEXT, (void **)&NewImmersiveVideoPlugin) ) { // wenn wir ein ungülitges Plugin geladen hatten, wieder wegwerfen ;-) //printf( "get_image_symbol( NewImmersiveVideoPlugin ) failed\n" ); unload_add_on(addonId ); } else { //ansonsten von dem geleadenen Plugin mit der addonID ein gültiges Objekt erzeugen aktPlugin = (*NewImmersiveVideoPlugin)( addonId ); if( !aktPlugin ) { printf( "failed to create a new plugin\n" ); } else { file=new BFile(&configDir,aktPlugin->GetName(),B_READ_ONLY); if (file->InitCheck()==B_OK) { //BMessage laden welches alle Einstellungen enhält BMessage *archive=new BMessage(); archive->Unflatten(file); //daraus das Plugin alles bauen lassen, was es benötigt aktPlugin->Init(archive); delete archive; archive=NULL; } else { //wenn keine Configdatei gefunden wurde, wird das Plugin "pur" initialisiert aktPlugin->Init(); } // pluginWindow = new PluginWin(this,aktPlugin); //aktuelles Plugin der Liste (in diesm Fall der Grafischen Liste) als Eintrag hinzufügen listView->AddItem(new PluginItem(aktPlugin)); } } } } } listView->Select(0); }
Widget::Widget() : QWidget(), m_label(new QLabel) { setLayout(new QVBoxLayout); layout()->addWidget(m_label); setWindowFlags(Qt::WindowStaysOnTopHint | Qt::X11BypassWindowManagerHint | Qt::WindowDoesNotAcceptFocus | Qt::Tool); setAttribute(Qt::WA_TranslucentBackground); m_label->setTextInteractionFlags(Qt::TextSelectableByKeyboard); m_label->setTextFormat(Qt::PlainText); m_label->setWordWrap(true); layout()->setMargin(0); setMaximumWidth(1000); setMaximumHeight(1000); setMinimumWidth(500); setMinimumHeight(128); m_label->setAlignment(Qt::AlignLeft | Qt::AlignTop); m_label->setMargin(5); QFont font; font.setPixelSize(15); setFont(font); //connect(qApp->clipboard(), &QClipboard::dataChanged, this, &Widget::onClipboardUpdated); connect(qApp->clipboard(), &QClipboard::dataChanged, &m_updateTimer, [=]() { m_updateTimer.start(10); }); connect(&m_updateTimer, &QTimer::timeout, this, &Widget::onClipboardUpdated); m_updateTimer.setSingleShot(true); m_timer.setSingleShot(true); connect(&m_timer, &QTimer::timeout, this, &QWidget::hide); QString stylesheet( "QLabel {\n" " border: 3px solid white;\n" " background-color: rgba(0, 0, 0, 128);\n" " selection-color: black;\n" " selection-background-color: white;\n" "}\n" ); const QString configLocation = QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation); QDir configDir(configLocation); if (!configDir.exists()) { configDir.mkpath(configLocation); } QString stylePath = configDir.absoluteFilePath("pastenotifier.qss"); QFile styleFile(stylePath); if (styleFile.exists()) { if (styleFile.open(QIODevice::ReadOnly)) { qDebug() << "Loading stylesheet" << stylePath; stylesheet = QString::fromLocal8Bit(styleFile.readAll()); } else { qWarning() << "Unable to open qss file:" << stylePath << styleFile.errorString(); } } else { if (styleFile.open(QIODevice::WriteOnly)) { styleFile.write(stylesheet.toUtf8()); } else { qWarning() << "Unable to open qss file for writing:" << stylePath << styleFile.errorString(); } } QAction *showAction = new QAction(this); connect(showAction, &QAction::triggered, [=](){ setWindowOpacity(1); show(); m_timer.start(5000); }); showAction->setObjectName("showpastenotifier"); KGlobalAccel::setGlobalShortcut(showAction, QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_V)); setStyleSheet(stylesheet); onClipboardUpdated(); }