- implement: when startup , open file provided by commmand line options

- implement: open files pasted by clipboard
This commit is contained in:
royqh1979@gmail.com 2021-10-04 20:05:24 +08:00
parent 0ae9b92924
commit b28d2d4ab4
6 changed files with 40 additions and 13 deletions

View File

@ -14,6 +14,8 @@ Version 0.6.0
- enhancement: refactor in project (using search symbol occurence and replace in files)
- fix: search in files
- implement: register file associations
- implement: when startup , open file provided by commmand line options
- implement: open files pasted by clipboard
Version 0.5.0
- enhancement: support C++ using type alias;

View File

@ -98,11 +98,17 @@ int main(int argc, char *argv[])
MainWindow mainWindow;
pMainWindow = &mainWindow;
if (app.arguments().count()>1) {
QStringList filesToOpen = app.arguments();
filesToOpen.pop_front();
pMainWindow->openFiles(filesToOpen);
} else {
if (pSettings->editor().autoLoadLastFiles())
pMainWindow->loadLastOpens();
if (pMainWindow->editorList()->pageCount()==0) {
pMainWindow->newEditor();
}
}
mainWindow.show();
int retCode = app.exec();
// save settings

View File

@ -2857,11 +2857,27 @@ void MainWindow::on_actionCopy_triggered()
void MainWindow::on_actionPaste_triggered()
{
QClipboard* clipboard = QGuiApplication::clipboard();
const QMimeData* data = clipboard->mimeData();
if (!data)
return;
if (data->hasUrls()) {
QStringList filesToOpen;
foreach (const QUrl& url, data->urls()) {
QString s = url.toLocalFile();
if (!s.isEmpty()) {
filesToOpen.append(s);
}
}
if (!filesToOpen.isEmpty())
openFiles(filesToOpen);
} else {
Editor * editor = mEditorList->getEditor();
if (editor != NULL ) {
editor->pasteFromClipboard();
}
}
}
void MainWindow::on_actionIndent_triggered()
{

View File

@ -91,6 +91,8 @@ public:
void saveLastOpens();
void loadLastOpens();
void openFiles(const QStringList& files);
void newEditor();
QPlainTextEdit* txtLocals();
@ -154,7 +156,6 @@ private:
void prepareProjectForCompile();
void closeProject(bool refreshEditor);
void updateProjectView();
void openFiles(const QStringList& files);
void openFile(const QString& filename);
void openProject(const QString& filename);
CompileTarget getCompileTarget();

View File

@ -191,7 +191,9 @@ QString Settings::Dirs::config(Settings::Dirs::DataType dataType) const
QString Settings::Dirs::executable() const
{
return QApplication::instance()->applicationFilePath();
QString s = QApplication::instance()->applicationFilePath();
s.replace("/",QDir::separator());
return s;
}
void Settings::Dirs::doSave()

View File

@ -69,7 +69,7 @@ void FileAssociationModel::updateAssociationStates()
"."+item->suffix,
"DevCpp."+item->suffix,
item->name,
"open",
"Open",
pSettings->dirs().executable()+" \"%1\""
);
item->defaultSelected = item->selected;
@ -111,7 +111,7 @@ void FileAssociationModel::saveAssociations()
PFileAssociationItem item = fileTypeDescriptions[fileType];
ok = registerFileType(fileType,
item->name,
"open",
"Open",
pSettings->dirs().executable(),
item->icon);
} else {
@ -167,7 +167,7 @@ bool FileAssociationModel::checkAssociation(const QString &extension, const QStr
if (result != ERROR_SUCCESS )
return false;
QString keyString = QString("%1\\shell\\%2\\command").arg(filetype).arg(verb);
QString keyString = QString("%1\\Shell\\%2\\Command").arg(filetype).arg(verb);
QString value1,value2;
if (!readRegistry(HKEY_CLASSES_ROOT,keyString.toLocal8Bit(),value1))
return false;
@ -254,7 +254,7 @@ bool FileAssociationModel::registerFileType(const QString &filetype, const QStri
keyString.toLocal8Bit(),
value.toLocal8Bit()))
return false;
keyString = QString("%1\\shell\\%2\\command").arg(filetype).arg(verb);
keyString = QString("%1\\Shell\\%2\\Command").arg(filetype).arg(verb);
value = serverApp+" \"%1\"";
if (!writeRegistry(HKEY_CLASSES_ROOT,
keyString.toLocal8Bit(),