Skip to content

Commit

Permalink
Merge pull request #215 from hakaishi/fix_settings_open_notes_from_tray
Browse files Browse the repository at this point in the history
update gitigore; fix open notes from tray settings; removed obsolete method
  • Loading branch information
Christian Metscher authored Apr 24, 2020
2 parents c62c862 + 2e4b26e commit cb6f57c
Show file tree
Hide file tree
Showing 7 changed files with 163 additions and 133 deletions.
30 changes: 17 additions & 13 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# C++ objects and libs

*.slo
*.lo
*.o
*.a
*.la
*.lai
*.so
*.dll
*.dylib
**.slo
**.lo
**.o
**.a
**.la
**.lai
**.so
**.dll
**.dylib

# Qt-es

Expand All @@ -18,18 +18,22 @@
*.pro.user.*
*.qbs.user
*.qbs.user.*
*.moc
*.qmlc
**.moc
**.qmlc
moc_*.cpp
qrc_*.cpp
ui_*.h
Makefile*
*build-*
*.qm
**.qm

# folders
build/
bin/

# QtCreator

*.autosave
**.autosave

# QtCtreator Qml
*.qmlproject.user
Expand Down
52 changes: 40 additions & 12 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,22 +78,25 @@ MainWindow::MainWindow()

//TrayIconContextMenu
iMenu = new QMenu(this);

// context menu needs at least one action else right click will not work
// context menu needs at least one action else right click will not work
iMenu->addAction(minimizeRestoreAction);
iMenu->addAction(actionQuitSystrayMenu);

SystemTrayCreator * creator = new SystemTrayCreator(this);

connect(creator,&SystemTrayCreator::noteClicked,this,&MainWindow::openOneNote);

TIcon->setContextMenu(iMenu); //setting contextmenu for the systray
connect(iMenu,&QMenu::aboutToShow,this,[this,creator](){

iconCreator = new SystemTrayCreator(this);

if(QSettings().value("open_notes_from_tray", false).toBool()){
connect(iconCreator,&SystemTrayCreator::noteClicked,this,&MainWindow::openOneNote);
connect(iMenu,&QMenu::aboutToShow,this,[=](){
iconCreator->populateMenu(iMenu);
iMenu->addSeparator();
iMenu->addAction(minimizeRestoreAction);
iMenu->addAction(actionQuitSystrayMenu);
});
}

creator->populateMenu(iMenu);
iMenu->addSeparator();
iMenu->addAction(minimizeRestoreAction);
iMenu->addAction(quit_action);
});
#endif

//Toolbar
Expand Down Expand Up @@ -362,10 +365,32 @@ void MainWindow::showPreferences()
connect(pref, SIGNAL(pathChanged()), this, SLOT(changeRootIndex()));
connect(pref,SIGNAL(kineticScrollingEnabledChanged(bool)),this,SLOT(setKineticScrollingEnabled(bool)));
connect(pref, SIGNAL(recentCountChanged()), this, SLOT(createAndUpdateRecent()));
connect(pref, SIGNAL(accepted()), this, SLOT(settingsAccepted()));
}
pref->show();
}

void MainWindow::settingsAccepted(){
#ifndef NO_SYSTEM_TRAY_ICON
iconCreator->disconnect();
iMenu->disconnect();
if(QSettings().value("open_notes_from_tray", false).toBool()){
connect(iconCreator,&SystemTrayCreator::noteClicked,this,&MainWindow::openOneNote);
connect(iMenu,&QMenu::aboutToShow,this,[=](){
iconCreator->populateMenu(iMenu);
iMenu->addSeparator();
iMenu->addAction(minimizeRestoreAction);
iMenu->addAction(actionQuitSystrayMenu);
});
}
else{
iMenu->clear();
iMenu->addAction(minimizeRestoreAction);
iMenu->addAction(actionQuitSystrayMenu);
}
#endif
}

void MainWindow::showBackupWindow()
{
if(!backup)
Expand Down Expand Up @@ -550,6 +575,7 @@ void MainWindow::closeEvent(QCloseEvent* window_close)
QSettings().setValue("mainwindow_size", saveGeometry());
QSettings().setValue("splitter", splitter->saveState());

// find widgets that still are saving their settings and let their futuures (worker threads) finish
QListIterator<QPointer<QWidget> > it(openNotes);
while(it.hasNext())
{
Expand All @@ -558,6 +584,8 @@ void MainWindow::closeEvent(QCloseEvent* window_close)
Note * note = qobject_cast<Note*>(widget);
if(note != NULL)
{
// calls close event (this is normally not called, because Notes are no childs of this)
// TODO check why Notes are no children of this

note->close();

Expand Down
3 changes: 3 additions & 0 deletions src/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ class Highlighter;
class ProgressReceiver;
class Backup;
class FlickCharm;
class SystemTrayCreator;

class MainWindow : public QMainWindow, public Ui::MainWindow
{
Expand Down Expand Up @@ -121,6 +122,7 @@ public slots:
#ifndef NO_SYSTEM_TRAY_ICON
QMenu *iMenu;
QSystemTrayIcon *TIcon;
SystemTrayCreator *iconCreator;
#endif

Note * noteWindow(const QString & filePath); // return the open note window for the note at filePath
Expand Down Expand Up @@ -166,6 +168,7 @@ public slots:
void pasteFiles();
void about();
void selectFolder();
void settingsAccepted();

protected:
void keyPressEvent(QKeyEvent *k);
Expand Down
2 changes: 2 additions & 0 deletions src/preferences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Preferences::Preferences(QWidget *parent): QDialog(parent)
for(int size : sizes)
fontSizeComboBox->addItem(QString::number(size));

openNotesFromTray->setChecked(settings->value("open_notes_from_tray", false).toBool());
dontQuit->setChecked(settings->value("dont_quit_on_close",false).toBool());
convertNotes->setChecked(settings->value("convert_notes",true).toBool());
showSource->setChecked(settings->value("show_source", false).toBool());
Expand Down Expand Up @@ -107,6 +108,7 @@ void Preferences::saveSettings()
}

settings->setValue("dont_quit_on_close", dontQuit->isChecked());
settings->setValue("open_notes_from_tray", openNotesFromTray->isChecked());
settings->setValue("convert_notes", convertNotes->isChecked());
settings->setValue("note_editor_default_size", QSize(sizeSpinWidth->value(),sizeSpinHeight->value()));
settings->setValue("show_source", showSource->isChecked());
Expand Down
6 changes: 0 additions & 6 deletions src/textbrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,6 @@ void TextBrowser::insertFromMimeData(const QMimeData *source)
}
}

bool TextBrowser::canInsertFromMimeData(const QMimeData *source) const
{
QTextCharFormat format = this->textCursor().charFormat();

}

void TextBrowser::slotSetReadOnly(bool ro)
{
this->setReadOnly(ro);
Expand Down
1 change: 0 additions & 1 deletion src/textbrowser.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ public slots:
private slots:
void openLinkInBrowser(const QUrl link);
void insertFromMimeData(const QMimeData *source);
bool canInsertFromMimeData(const QMimeData *source) const;
};

#endif // TEXTEDIT_H
Expand Down
Loading

0 comments on commit cb6f57c

Please sign in to comment.